Commit Graph

234 Commits

Author SHA1 Message Date
reinoud 19eca236e0 Improve disc size reporting. The current discsize thats reported is the
current recorded extent and not the complete maximum extent of the disc.

An empty CD/DVD disc is seen as having an invalid length and given 800 Mb
size. This makes it possible to write to a CD-R using `dd' as some tend to
do.

However when an extent is recorded the initial recorded length is seen as
valid and is thus set as absolute upperbound to read and write actions
preventing extention of the disc.

Committed after consultation on tech-kern with a positive advice by Manuel
Bouyer.
2005-12-21 13:11:27 +00:00
christos 04735b5d69 delete extraneous verbiage. 2005-12-16 17:54:36 +00:00
reinoud 4cdfa6bead Clean up cdgetdisklabel. It was jumping over a return... 2005-12-15 17:56:32 +00:00
christos 95e1ffb156 merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
reinoud 17f915ee27 Fix illogical use of extra variable. It was mainly to get a better
readability in KNF. This solution gives better readability without the
extra variable.
2005-12-11 00:01:54 +00:00
reinoud 705000f60a Second stage of read TOC modifications. Introducing the various forms of
TOC reading. Note that the external interfaces haven't changed. Only the
formatted toc is requestable.

The read msinfo command hasn't been changed in this patch though it could
become more clever using the CD_TOC_MSINFO format.
2005-12-10 21:17:21 +00:00
yamt aec75b1cc6 - change the way to specify a bufq strategy. (by string rather than by number)
- rather than embedding bufq_state in driver softc,
  have a pointer to the former.
- move bufq related functions from kern/subr_disk.c to kern/subr_bufq.c.
- rename method to strategy for consistency.
- move some definitions which don't need to be exposed to the rest of kernel
  from sys/bufq.h to sys/bufq_impl.h.
  (is it better to move it to kern/ or somewhere?)
- fix some obvious breakage in dev/qbus/ts.c.  (not tested)
2005-10-15 17:29:10 +00:00
reinoud 04d00c8e39 Cleanup and fix cd_size() function; it was returning wrong results.
Also factor out read_cd_capacity()
2005-09-06 22:19:14 +00:00
reinoud d462489ea5 Implement DIOCCACHESYNC for SCSI/ATAPI cd/mmc recordable devices found by
scsipi/cd.c by issueing the SYNCHRONISE CACHES scsi/atapi call as defined
per MMC standard.
2005-09-05 21:16:24 +00:00
reinoud b28d0c5529 Document executed SCSI commands with the IOCTL's to prevent confusion. 2005-08-28 22:51:01 +00:00
bouyer a5bc956f51 Always allow open() on the raw partition to succeed, even if any of the
SCSI command in cdopen() fails. Fix PR kern/30288 by Pavel Cahyna.
2005-07-06 14:28:39 +00:00
christos 3acb3fe622 - Sprinkle const
- Avoid variable shadowing.
- Eliminate some caddr_t abuse.
2005-05-29 22:00:50 +00:00
drochner 99c093bad3 fix more SSD_RCODE_VALID misuse introduced in cleanup 2005-04-25 17:52:30 +00:00
yamt 99229e5d39 introduce a function to drain bufq and use it where appropriate. 2005-03-31 11:28:53 +00:00
perry f31bd063e9 nuke trailing whitespace 2005-02-27 00:26:58 +00:00
thorpej df9803ce96 Part 1 of a cleanup pass over the SCSI subsystem. The aim is to name
everything "scsi_*", since we really are talking about the SCSI command
set, ATAPI transport not withstanding.  Improve the names of many structures,
and prepend "SCSI_" onto all SCSI command opcodes.  Place items described
by the SCSI Primary Commands document into scsi_spc.h.
2005-02-21 00:29:06 +00:00
reinoud f323bc537c Backing out changes to clean up scsipi. I was pointed out there were
problems i hadn't seen. To prevent lossage i'd decided to back off all
changes and let them be reviewed on tech-kern.
2005-02-01 00:19:34 +00:00
reinoud 4145e39ac7 Fix LP64 problems introduced by my u_long->uint32_t conversion. 2005-01-31 23:39:02 +00:00
reinoud b220d67a3e Part of the cleanup of sys/scsipi's use of types; rename all u_int* to
uint* and change the u_long's to uint32_t's where possible. Note that the
iocl definitions/hooks have to be ulong (or u_long) or they'll bomb out.
2005-01-31 23:06:41 +00:00
reinoud f93ea32254 As part of cleaning up sys/scsipi, replace all u_char by uint8_t and
replace all `short' with int16_t.
2005-01-31 21:13:16 +00:00
reinoud 842f22fc3a As in revision 1.213, not all information is returned in read-TOC format 0. In order to add a new generic read-toc ioctl, i renamed the origional to _f0 to indicate its only format 0. The routines can then be changed one at a time to the new generic calling. This patch fixes two calls i'd overseen.... silly me forgot to recompile :( 2005-01-30 23:42:58 +00:00
reinoud 82eee08288 The code asumes all programs want to know is TOC response format 0. Support
for TOC response format 1 and 2 are mandatory on CD/DVD too and provide
more information.

Next an IOCTL needs to be implemented that can read all TOC formats in a
generic way. This is pending.
2005-01-30 23:39:42 +00:00
thorpej ce91ac7d6b USe more appropriate macro/struct names for READ/WRITE (6) and
READ/WRITE (10).
2004-12-07 23:07:31 +00:00
yamt 05f25dcc2a move buffer queue related stuffs from buf.h to their own header, bufq.h. 2004-10-28 07:07:35 +00:00
dogcow f3084b1ba9 Fix debug message output args to match yamt's src/sys/sys/buf.h changes. 2004-09-26 09:00:37 +00:00
mycroft 8f93b96f00 Standardize some variable names and the calling pattern for scsipi_command().
Use void pointer casts.
2004-09-18 00:08:16 +00:00
mycroft 1e243afe67 Remove the "xfer" argument to scsipi_command(). 2004-09-17 23:43:17 +00:00
mycroft cdc20e6ce8 In places where we've already called scsipi_make_xs(), call scsipi_execute_xs()
directly rather than going through scsipi_command().
2004-09-17 23:35:13 +00:00
mycroft 8b6c2af171 Do not manipulate xs->bp in "generic" code -- do it only in the psw_done
routine.  As part of this, pass down our pre-parsed error code -- though this
interface will probably change later to accomodate better error handling.
2004-09-17 23:10:50 +00:00
bouyer 4849b82163 Make the xxstart() functions reentrant again, as some drivers HBA can call
scsipi_done() from their scsipi_request().
For this, add a struct scsipi_xfer * argument to scsipi_command().
If not NULL scsipi_command() will use this to enqueue this xfer, otherwise
it'll try to allocate a new one. This scsipi_xfer has to be allocated
and initialised by scsipi_make_xs() or equivalent.
In xxstart(), allocate a scsipi_xfer using scsipi_make_xs(), and if not NULL,
dequeue the buffer before calling scsipi_command(). This makes sure that
scsipi_command() will not fail, and also makes sure that xxstart() won't
be called again between the BUFQ_PEEK() and BUFQ_GET().

Fix "dequeued wrong buf" panics reported by Juergen Hannken-Illjes in
private mail and Andreas Wrede on current-users@.
Thanks to Jason Thorpe and Chuck Silver for review, and Andreas Wrede for
testing the patch.
2004-09-09 19:35:30 +00:00
bouyer 76f52e0733 Fix comment: xxstart() can also be called from xxrestart() 2004-09-06 20:38:14 +00:00
bouyer 80620a83a7 Improve handling of memory shortage, to fix problems like:
sd3(mpt0:0:1:0): unable to allocate scsipi_xfer
sd3: not queued, error 12
Havard Eidnes's analysis of this problem is that the scsipi_xfer pool is
competing for resources with other pools, including the the inode and vnode
pools which can grow quite large.

*_scsipi_cmd(): don't biodone the buffer if scsipi_make_xs() fails, let the
   caller deal with the problem
start function of block devices drivers: dequeue the buffer after the
   scsipi_command() call. If scsipi_command() fails with ENOMEM don't dequeue
   the buffer, and schedule a callout to call the start function after
   some delay.
scsipi_init(): prime the scsipi_xfer_pool with one page. This ensure that
   there is always some scsipi_xfer to play with. If scsipi_command() fails
   because of pool_get(), we're sure there will be resources available later,
   when the pending commands have completed.

Reviewed by Jason Thorpe and Havard Eidnes.
Todo: remove the "unable to allocate scsipi_xfer" and "not queued, error %d"
printfs, but I choose to keep them for now, to help make sure the code does
what it should.
2004-08-27 20:37:28 +00:00
thorpej 6cb9b7482f Use ANSI function decls and make use of static. 2004-08-21 17:40:25 +00:00
pk 95149aa7b9 Some older devices do not understand the `disable block descriptor' bit in
the mode sense request. So fall back on mode sense data including a block
descriptor section.

See also sd.c rev. 1.214.  Again: should we bother trying DBD at all?
2004-04-24 09:26:14 +00:00
enami 18a61d4783 Backout an obvious bug introduced in rev. 1.145. 2004-02-22 00:26:43 +00:00
yamt 7266a95907 store a i/o priority hint in struct buf for buffer queue discipline. 2004-01-10 14:39:50 +00:00
wiz ee1b406595 Spell address with two d's. Inspired by similar changes in OpenBSD,
originating from Jonathon Gray and forwarded by jmc@openbsd.
2003-11-10 08:51:51 +00:00
mycroft 9dbb8c86d4 Merge the geometry and cache handling code for all direct access and optical
devices, as it's general to all SCSI MMC devices.  In the process, remove
PQUIRK_NO_FLEX_PAGE.
2003-09-18 00:06:31 +00:00
mycroft 10675507e9 Don't be silent if there is no media present. 2003-09-13 15:49:04 +00:00
mycroft 953ba0b251 Make sure the "raw partition" can always be opened again. 2003-09-13 14:44:50 +00:00
mycroft 67ed54a25b In the test for whether to start the unit, I used the wrong error code.
ENODEV is only returned when we get "medium not present," which we can fail
immediately on.  All other "not ready" cases return EIO.
2003-09-09 02:43:34 +00:00
mycroft 7365679351 Oops. Fix a typo in cd_mode_select(). 2003-09-08 23:44:29 +00:00
mycroft 648730c4cf Do a START UNIT only if the TEST UNIT READY reports that the device is not
ready.  This avoids gratuitously starting the motor on floppy and CD-ROM
drives, and eliminates the need for the audio playing test in cdopen().

Therefore, also remove PQUIRK_NOSTARTUNIT.
2003-09-08 18:51:33 +00:00
mycroft 2bfde7f903 Attempt to deal with Martin's weirdass Sun drive by setting the mode sense
allocation length a little more precisely -- add the space for the header in
cd_mode_sense().  Also delete the XS_CTL_SILENT, since we really do want to
see errors.

Lastly, add a similar wrapper for mode select, simplifying the callers
slightly.
2003-09-08 16:16:43 +00:00
mycroft f2a492ff6b Eliminate the separate ATAPI and SCSI attachments for "cd". 2003-09-08 01:56:33 +00:00
mycroft cd456a7097 Nuke some printf()s. 2003-09-08 01:13:04 +00:00
mycroft b6e043eed2 Set PQUIRK_ONLYBIG in the wdc-atapi frontend, obviating the need to ever test
the "bus type" for this.

Merge all the code in the SCSI and ATAPI backends for "cd" devices.  All of
the mode page handling and whatnot is general to SCSI MMC devices, and should
never have been separated to begin with.  This fixes a variety of problems,
and adds load/unload support for SCSI-attached devices.
2003-09-07 22:11:22 +00:00
wiz 86e9cd6e52 Add a cast to avoid an integer overflow.
Fixes playing (at least some) DVDs.
Patch from Tsubai Masanari (tsubai at iri.co.jp) -- thanks a lot!
2003-07-18 14:33:54 +00:00
martin 15a7538ed4 If a CD drive reports != 2048 byte block size, try to change it into
2048 byte mode. Fixes PR kern/22090.
Reviewed by Manuel Bouyer.
2003-07-10 18:18:40 +00:00
fvdl d5aece61d6 Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
2003-06-29 22:28:00 +00:00