summaryrefslogtreecommitdiff
path: root/sys/scsi/cd.c
AgeCommit message (Collapse)Author
2017-12-30Don't pull in <sys/file.h> just to get fcntl.hPhilip Guenther
ok deraadt@ krw@
2017-09-08If you use sys/param.h, you don't need sys/types.hTheo de Raadt
2017-05-29To prevent anyone else from stumbling on this (now) archaic bit ofKenneth R Westerback
history, nuke all mentions of XS_NO_CCB and the #define. 2006 - 2017. R.I.P. ok kettenis@ inferred ok dlg@
2017-05-04Also pass the blk offset to disk_unbusy(), so that it can pass it toTheo de Raadt
the random subsystem as entropy. This value is pretty much unknown, and anyways our entropy input ring does not saturate from knowns. ok mikeb djm
2016-03-12Standardize on calling local scsi_link variables 'link' instead ofKenneth R Westerback
'sc_link'. 'sc_link' is a field in the various device *_softc structures, where the sc_ prefix was for 'softc'. Reduces potential mental confusion. Newer code from down under was already using 'link'. No functional change. Prompted by bluhm@'s adventures in scsi. ok dlg@ jmatthew@
2015-06-07More damned eye searing whitespace.Kenneth R Westerback
2014-12-15convert bcopy to memcpy. ok dlg krwTed Unangst
2014-09-14remove uneeded proc.h includesJonathan Gray
ok mpi@ kspillner@
2014-07-12add a size argument to free. will be used soon, but for now default to 0.Ted Unangst
after discussions with beck deraadt kettenis.
2013-11-01Sprinkle (long long) casts where %lld is being used to print daddr_tKenneth R Westerback
variables. Some random whitespace/knf repairs encountered on the way. ok miod@ on inspection, feedback & more suggestions from millert@
2013-10-03Print daddr_t variables with %lld, u_int64_t variables with %llu.Kenneth R Westerback
2013-09-27scsi_size() is now used only by cd(4). So move it from scsi_base.cKenneth R Westerback
to cd.c and call it cd_size(), like sd_size() lives in sd.c. Tweak some daddr_t variables to u_int64_t on the way, when they are for disk sector numbers, not 512-byte block numbers.
2013-09-15cddump() takes a daddr_t parameter. Call that parameter 'blkno' and notKenneth R Westerback
'secno'. This is what sddump() already does and consistant is good. No function change.
2013-09-15Use DL_SECTOBLK() and DL_BLKTOSEC() to clarify code and removeKenneth R Westerback
repeated handrolling of same code. Use daddr_t variable to calculate daddr_t return values, and u_int64_t variables to calculate disk sector values. No functional change.
2013-06-11final removal of daddr64_t. daddr_t has been 64 bit for a long enoughTheo de Raadt
test period; i think 3 years ago the last bugs fell out. ok otto beck others
2011-07-06Eliminate redundant buf validation checks in xxstrategy() methods nowMatthew Dempsky
that they're implemented consistently in bounds_check_with_label(). Also, per krw's request, change bounds_check_with_label() to return 0 if the checks succeed, and change the drivers to test == -1 instead of <= 0. (Man page update to follow; intentionally omitting arch/vax/mba/hp.c from this commit because it doesn't even build currently and miod@ promises to kill it soon.) ok krw@
2011-07-03Remove config_activate() and DVACT_ACTIVATE. PCMCIA's the only thingMatthew Dempsky
that's ever used it, and it's long since been changed to use DVACT_{QUIESCE,SUSPEND,RESUME} instead. ok deraadt@, dlg@; miod@ also agreed with this idea when I brought it up a few weeks ago
2011-06-30Refactor some common open/close/detach disk driver code intoMatthew Dempsky
subr_disk.c. For now just the MI disk drivers. ok deraadt@, krw@; jsing@ liked the approach too
2011-06-19Use disk_lock_nointr() in the xxclose() routines so that they cannotTheo de Raadt
be interrupted. ok matthew
2011-06-19Use disk_lock/disk_unlock directly and in the same way in these drivers,Theo de Raadt
rather than using various wrappings. Convert vnd to using the sc_dk rwlock instead of using one of its own. ok matthew
2011-06-06Delete the long dead LOCKED and WANTED flags from cd(4), sd(4), andMatthew Dempsky
wd(4). They haven't been used for 10+ years, since the drivers were switched to use disk_lock() and disk_unlock() instead. No binary change.
2011-06-05Drop kernel support for the useless DIOCWLABEL ioctl and prune a lotMatthew Dempsky
of silly flag twiddling code in various disk drivers. ok deraadt@, miod@ N.B., users will need a -current disklabel(8) to be able to write new disklabels to disk now.
2011-06-03Get rid of the wlabel argument to bounds_check_with_label(). It'sMatthew Dempsky
never done anything in OpenBSD and just clutters disk drivers with silly flag handling. More cleanup to follow. ok deraadt@, millert@; no objections krw@
2011-05-31Change a few of the more common disk drivers (sd, cd, wd, rd, and vnd)Matthew Dempsky
to return EBUSY if the user tries to modify an open partition's offset or size. Only sadness can result if a user tries this, and rejecting it prevents a race between sdstart() and sdstrategy(). Curiously, there was already code in the kernel and in disklabel(8) to detect/handle this, but it was effectively disabled because the disk drivers always used something like "/* sc->sc_dk.dk_openmask */ 0", and this commented out code has existed since even r1.1 in NetBSD. I had no problems building a release and messing around with disklabel(8) for a bit with this diff. Canarying the more common MI disk drivers until we gain confidence that there aren't any regressions, then we can switch the remaining drivers. "I am surprised you got me convinced that this stuff is safe" deraadt@ ok krw@
2011-03-17use dma_alloc/dma_free instead of malloc to allocate buffers which needTheo de Raadt
to be in the right address space. help from matthew and krw
2010-11-22SCSI devices are assumed to be T_FIXED unless they say otherwise.Kenneth R Westerback
cd(4) did not believe any T_FIXED device was its responsibility. Thus when a USB CD forgot to mention that it is T_REMOV, it appeared as uk(4). Make cd(4) accept even T_FIXED devices that claim to be T_CDROM or T_WORM. Noticed and fix tested by Rene Maroufi. Closes PR #6513.
2010-09-23Introduce a DKF_NOLABELREAD flag, which is used by a device to preventJoel Sing
automatic reading of disklabel on attach. ok deraadt@ miod@ krw@
2010-09-22All users of physio(9) now pass NULL as the buf pointer argument, soMatthew Dempsky
no point in keeping it around. "i like this" thib@ (a while back); ok krw@ and oga@; reminder to update the man page and tweaks jmc@
2010-09-21Add a real DIOCGPDINFO, allowing access to the physical informationKenneth R Westerback
about the device rather than the contents of whichever disklabel was read. Tweak whitespace in sd.c to make the code appearance consistant.
2010-09-20bufq_drain() does not need to be done in deactivate; we only needTheo de Raadt
to deactivate transactions we are currently doing. ok dlg
2010-09-14scsi_xsh_del the xs handler on DEACTIVATE.David Gwynne
same change as sd.c r1.212. matthew@ pointed out that cd(4) and st(4) would need the same change.
2010-09-12Make cd the same as sd by calling the cd_parms member of the softc 'params'Kenneth R Westerback
rather than 'sc_params'. No change to .o file.
2010-09-11Be more ruthlessly consistent in variable names for blk/block ==Kenneth R Westerback
512 == DEV_BSIZE units and variable-sized physical device 'sectors'. I hope this reduces confusion a bit more. No change to .o files. ok for intent miod@, with tweak.
2010-09-08Introduce a disk_lookup() function which calls device_lookup(), beforeJoel Sing
verifying that the resulting device is present on the disklist. This avoids a race whereby the disk driver can be accessed as soon as the softc has been allocated, but before the disk has completed initialisation and has called disk_attach() (up until this point dk_label is still a null pointer). Cut cd(4), sd(4) and wd(4) across to disk_lookup(). All callers of disk_attach() need to be tested and cut over in due course. ok deraadt@ krw@
2010-09-08Store a struct device pointer within struct disk and populate this whenJoel Sing
disk_attach() is called by the device driver. We will be building on this shortly. ok deraadt@ krw@
2010-09-07remove the powerhook code. All architectures now use the ca_activate treeTheo de Raadt
traversal code to suspend/resume ok oga kettenis blambert
2010-09-07rely on SCSI_AUTOCONF for cd_resume instead of wrapping it in a workqTheo de Raadt
(which creates a potential race against cd detach) discussed with krw and dlg seperately
2010-09-01make struct bufq a member of the softc for devices that use it,David Gwynne
rather than it being a pointer to something that needs to be allocated at attach. since all these devices need a bufq to operate, it makes sense to have it allocated as part of the softc and get bufq_init to just initialise all its fields. it also gets rid of the possibility that you wont be able to allocate the bufq struct during attach, which is something you dont want to happen. secondly, it consistently implements a split between wrapper functions and the per discipline implementation of the bufq handlers. it consistently does the locking in the wrappers rather than doing half in the wrappers and the other half in the implementations. it also consistently handles the outstanding bufq bq pointer in the wrappers. this hides most of the implementation inside kern_bufq.c. the only stuff left in buf.h is for the bits each implementation needs to put inside struct buf. tested by thib@ krw@ and me ok thib@ matthew@ no objection from krw@
2010-08-31Change the powerhook into an activation routine. It has to use a workq.Theo de Raadt
There is a bit of concern that this workq can race against a detach happening... any solutions from the peanut gallery?
2010-08-30Avoid possible aliasing-related compiler issues by always writing toMatthew Dempsky
cmd->opcode through the type casted command pointer rather than through xs->cmd->opcode. Requested by deraadt@; ok krw@.
2010-08-28Garbage collect struct dkdriver.Matthew Dempsky
ok miod@; "please go ahead" jsing@
2010-07-28DVD_INVALIDATE_AGID is a 'no payload' operation, so don't setKenneth R Westerback
xs->datalen and reset xs->data to NULL. This prevents a spurious attempt to setup (dma map, etc) and possibly attempt data tranfser. In line with what Linux and FreeBSD do as far as I can tell. Reduces the delay before my DVD starts playing its movie. Idea to also set xs->data to NULL from matthew@. "No objection" matthew@
2010-07-25Missing SCSI_DATA_IN flag in dvd_read_copyright() causedKenneth R Westerback
confusion. Fixes at least my usb DVD reader and The Blue Tick.
2010-07-25Let DVD's play again. Logic reversal prevented copyright reading.Kenneth R Westerback
Symptoms noted by oga@. actual bug spotted by dlg@
2010-07-22Fix a few more scsi_scsi_cmd() removal regressions, caught byMatthew Dempsky
-Wuninitialized. Silly typo in my first diff noticed by oga@ and krw@; ok krw@
2010-07-22Appropriately set SCSI_DATA_IN or SCSI_DATA_OUT depending on type ofMatthew Dempsky
dvd_auth command. Fixes regression from scsi_scsi_cmd() removal. ok dlg@
2010-07-22Eliminate scsi_scsi_cmd() now that ss(4) is gone and with it theKenneth R Westerback
last bastardized sync and buf call through scsi_scsi_cmd(). Flatten code to call scsi_xs_sync() directly for all commands. Airplane typos shaken out by various. ok dlg@ matthew@ deraadt@
2010-07-01Die struct scsi_device! Die! Instead, save a pointer to the routineKenneth R Westerback
to interpret sense errors. This is initialized to the basic interpretation routine, and specific scsi drivers (sd/st/cd) can replace this with their own. While here kill EJUSTRETURN dance and make more specialized interpretation routines directly call the basic routine if desired. Fixes by matthew@ to my first diff. Most original work by dlg@. ok matthew@ marco@ dlg@
2010-07-01Restore setting xs->bp; fixes ncr(4) on VAX.Matthew Dempsky
ok miod@, krw@
2010-06-30Bring cd(4) into line with sd(4) and st(4) by implementing CDF_DYINGKenneth R Westerback
to better handle detaching. ok deraadt@