aboutsummaryrefslogtreecommitdiff
path: root/sys/cam/scsi/scsi_cd.c
Commit message (Collapse)AuthorAgeFilesLines
* scsi_cd: pass correct pointer to free()Andriy Gapon2010-06-041-1/+1
| | | | | | | | | Found with: Coverity Prevent(tm) CID: 2986 MFC after: 4 days Notes: svn path=/head/; revision=208800
* scsi_cd: CD_FLAG_VALID_MEDIA is sufficient to set d_sectorsize andAndriy Gapon2010-04-151-4/+5
| | | | | | | | | | | | | | | | | | d_mediasize CD_FLAG_VALID_TOC is not required for setting those media properties. PR: kern/145385 Submitted by: Juergen Lock <nox@jelal.kn-bremen.de> a slightly different version Tested by: Pavel Sukhoy <sukhoy@ripn.net>, Markus Wild <m.wild@cybernet.ch>, Juergen Lock <nox@jelal.kn-bremen.de>, uqs MFC after: 1 week Notes: svn path=/head/; revision=206648
* Make CD driver a bit more robust and predictable to unreported errors.Alexander Motin2010-02-151-17/+13
| | | | Notes: svn path=/head/; revision=203931
* MFp4: Large set of CAM inprovements.Alexander Motin2010-01-281-24/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Unify bus reset/probe sequence. Whenever bus attached at boot or later, CAM will automatically reset and scan it. It allows to remove duplicate code from many drivers. - Any bus, attached before CAM completed it's boot-time initialization, will equally join to the process, delaying boot if needed. - New kern.cam.boot_delay loader tunable should help controllers that are still unable to register their buses in time (such as slow USB/ PCCard/ CardBus devices), by adding one more event to wait on boot. - To allow synchronization between different CAM levels, concept of requests priorities was extended. Priorities now split between several "run levels". Device can be freezed at specified level, allowing higher priority requests to pass. For example, no payload requests allowed, until PMP driver enable port. ATA XPT negotiate transfer parameters, periph driver configure caching and so on. - Frozen requests are no more counted by request allocation scheduler. It fixes deadlocks, when frozen low priority payload requests occupying slots, required by higher levels to manage theit execution. - Two last changes were holding proper ATA reinitialization and error recovery implementation. Now it is done: SATA controllers and Port Multipliers now implement automatic hot-plug and should correctly recover from timeouts and bus resets. - Improve SCSI error recovery for devices on buses without automatic sense reporting, such as ATAPI or USB. For example, it allows CAM to wait, while CD drive loads disk, instead of immediately return error status. - Decapitalize diagnostic messages and make them more readable and sensible. - Teach PMP driver to limit maximum speed on fan-out ports. - Make boot wait for PMP scan completes, and make rescan more reliable. - Fix pass driver, to return CCB to user level in case of error. - Increase number of retries in cd driver, as device may return several UAs. Notes: svn path=/head/; revision=203108
* Remove duplicate devstat_start_transaction_bio() call. It is already calledAlexander Motin2009-12-181-2/+0
| | | | | | | from geom_disk. Dulicate call causes wrong queue depth and busy accounting. Notes: svn path=/head/; revision=200668
* Clear result before requesting XPT_PATH_INQ.Alexander Motin2009-12-091-0/+1
| | | | | | | Many SIMs doesn't fill maxio field yet. Notes: svn path=/head/; revision=200295
* MFp4:Alexander Motin2009-12-061-2/+6
| | | | | | | | | | | | | | | | | | | | | Introduce ATA_CAM kernel option, turning ata(4) controller drivers into cam(4) interface modules. When enabled, this options deprecates all ata(4) peripheral drivers (ad, acd, ...) and interfaces and allows cam(4) drivers (ada, cd, ...) and interfaces to be natively used instead. As side effect of this, ata(4) mode setting code was completely rewritten to make controller API more strict and permit above change. While doing this, SATA revision was separated from PATA mode. It allows DMA-incapable SATA devices to operate and makes hw.ata.atapi_dma tunable work again. Also allow ata(4) controller drivers (except some specific or broken ones) to handle larger data transfers. Previous constraint of 64K was artificial and is not really required by PCI ATA BM specification or hardware. Submitted by: nwitehorn (powerpc part) Notes: svn path=/head/; revision=200171
* Fix several cases where the periph lock was held over malloc.Scott Long2009-12-021-54/+24
| | | | | | | Submitted by: Jaakko Heinonen Notes: svn path=/head/; revision=200036
* MFp4:Alexander Motin2009-11-141-2/+4
| | | | | | | Fix several device freeze counting bugs. Notes: svn path=/head/; revision=199279
* Replace most of priority numbers with defines. No logical changes.Alexander Motin2009-10-231-24/+24
| | | | Notes: svn path=/head/; revision=198382
* Free the correct buffer in an error case.Scott Long2009-09-081-1/+1
| | | | | | | Submitted by: phk Notes: svn path=/head/; revision=196983
* Revert previous commit and add myself to the list of people who shouldPoul-Henning Kamp2009-09-081-1/+1
| | | | | | | know better than to commit with a cat in the area. Notes: svn path=/head/; revision=196970
* Add necessary include.Poul-Henning Kamp2009-09-081-1/+1
| | | | Notes: svn path=/head/; revision=196969
* Separate the parallel scsi knowledge out of the core of the XPT, andScott Long2009-07-101-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | modularize it so that new transports can be created. Add a transport for SATA Add a periph+protocol layer for ATA Add a driver for AHCI-compliant hardware. Add a maxio field to CAM so that drivers can advertise their max I/O capability. Modify various drivers so that they are insulated from the value of MAXPHYS. The new ATA/SATA code supports AHCI-compliant hardware, and will override the classic ATA driver if it is loaded as a module at boot time or compiled into the kernel. The stack now support NCQ (tagged queueing) for increased performance on modern SATA drives. It also supports port multipliers. ATA drives are accessed via 'ada' device nodes. ATAPI drives are accessed via 'cd' device nodes. They can all be enumerated and manipulated via camcontrol, just like SCSI drives. SCSI commands are not translated to their ATA equivalents; ATA native commands are used throughout the entire stack, including camcontrol. See the camcontrol manpage for further details. Testing this code may require that you update your fstab, and possibly modify your BIOS to enable AHCI functionality, if available. This code is very experimental at the moment. The userland ABI/API has changed, so applications will need to be recompiled. It may change further in the near future. The 'ada' device name may also change as more infrastructure is completed in this project. The goal is to eventually put all CAM busses and devices until newbus, allowing for interesting topology and management options. Few functional changes will be seen with existing SCSI/SAS/FC drivers, though the userland ABI has still changed. In the future, transports specific modules for SAS and FC may appear in order to better support the topologies and capabilities of these technologies. The modularization of CAM and the addition of the ATA/SATA modules is meant to break CAM out of the mold of being specific to SCSI, letting it grow to be a framework for arbitrary transports and protocols. It also allows drivers to be written to support discrete hardware without jeopardizing the stability of non-related hardware. While only an AHCI driver is provided now, a Silicon Image driver is also in the works. Drivers for ICH1-4, ICH5-6, PIIX, classic IDE, and any other hardware is possible and encouraged. Help with new transports is also encouraged. Submitted by: scottl, mav Approved by: re Notes: svn path=/head/; revision=195534
* Reorder dacleanup() and cdcleanup() slightly so that the sysctl context isJohn Baldwin2009-02-111-6/+6
| | | | | | | | | | freed while the periph lock is not held. While here, wait until after freeing the softc before reacquiring the periph lock. Tested by: sbruno Notes: svn path=/head/; revision=188503
* Adding dynamic sysctls no longer requires Giant.John Baldwin2009-02-101-4/+0
| | | | | | | Submitted by: rdivacky Notes: svn path=/head/; revision=188458
* Make it possible to override the number of retries for the CD media.Warner Losh2009-01-081-1/+8
| | | | | | | | | | | | | | | | | | When trying to read scratched or damaged CDs and DVDs, the default mechanism is sub-optimal. Programs like ddrescue do much better if you turn off retries entirely, since their algorithms are designed scan big areas fast, then winnow the areas down. Turning off retries speeds these programs up by as much as 20x, since the drive is able to 'stream past' many small errors... The sysctl/tunable kern.cam.cd.retry_count controls this. That defaults to '4' (for a total of 5 attempts). Setting to 0 turns off all retry attempts. Reviewed by: scottl@ Notes: svn path=/head/; revision=186882
* Fix refcount locking in cd, pass, and sg periphs.Scott Long2008-12-211-7/+9
| | | | Notes: svn path=/head/; revision=186371
* Do not forget to cam_periph_unhold the peripheral before exitingAlexander Kabaev2007-07-211-2/+5
| | | | | | | | | | | due to error. PR: kern/114636 Submitted by: Tijl Coosemans Approved by: re (hrs) Notes: svn path=/head/; revision=171529
* Add a helper function for registering async callbacks. BesidesScott Long2007-05-161-32/+4
| | | | | | | eliminating a lot of duplicated code, this also fixes a locking edge case. Notes: svn path=/head/; revision=169605
* Eliminate the use of M_TEMP.Scott Long2007-05-141-66/+68
| | | | Notes: svn path=/head/; revision=169562
* Drop the periph/sim lock when calling disk_destroy().Scott Long2007-04-161-0/+2
| | | | Notes: svn path=/head/; revision=168786
* Remove Giant from CAM. Drivers (SIMs) now register a mutex that CAM willScott Long2007-04-151-194/+244
| | | | | | | | | | | | | | use to synchornize and protect all data objects that are used for that SIM. Drivers that are not yet MPSAFE register Giant and operate as usual. RIght now, no drivers are MPSAFE, though a few will be changed in the coming week as this work settles down. The driver API has changed, so all CAM drivers will need to be recompiled. The userland API has not changed, so tools like camcontrol do not need to be recompiled. Notes: svn path=/head/; revision=168752
* Add an xpt_print function to reduce most of the xpt_print_path/printfMatt Jacob2006-12-051-31/+23
| | | | | | | | | | pairs. Convert the core code to use it. Reviewed by: scsi (various folks weighing in with good advice) MFC after: 2 weeks Notes: svn path=/head/; revision=164906
* Drop Giant before returning in error path, thus eliminatesXin LI2006-07-141-0/+1
| | | | | | | | | | | two mutex leaks. Submitted by: Beyond Luo <fedora ercist iscas ac cn> PR: kern/100046 Reviewed by: ken, scottl Notes: svn path=/head/; revision=160345
* o Do not double i/o stats for cd(4) already acounted in g_disk_done().Maxim Konovalov2006-04-171-1/+1
| | | | | | | | | | PR: kern/95707 Submitted by: Andre Albsmeier Reviewed by: phk MFC after: 2 weeks Notes: svn path=/head/; revision=157806
* Fix a bug that caused some /dev entries to continue to exist afterJohn Polstra2005-11-181-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | the underlying drive had been hot-unplugged from the system. Here is a specific example. Filesystem code had opened /dev/da1s1e. Subsequently, the drive was hot-unplugged. This (correctly) caused all of the associated /dev/da1* entries to be deleted. When the filesystem later realized that the drive was gone it closed the device, reducing the write-access counts to 0 on the geom providers for da1s1e, da1s1, and da1. This caused geom to re-taste the providers, resulting in the devices being created again. When the drive was hot-plugged back in, it resulted in duplicate /dev entries for da1s1e, da1s1, and da1. This fix adds a new disk_gone() function which is called by CAM when a drive goes away. It orphans all of the providers associated with the drive, setting an error condition of ENXIO in each one. In addition, we prevent a re-taste on last close for writing if an error condition has been set in the provider. Sponsored by: Isilon Systems Reviewed by: phk MFC after: 1 week Notes: svn path=/head/; revision=152565
* Fix a problem with the cd(4) driver -- the CAMGETPASSTHRU ioctl wouldn'tKenneth D. Merry2005-03-261-1/+7
| | | | | | | | | | | | | | | succeed if there was no media in the drive. This was broken in rev 1.72 when the media check was added to cdioctl(). For now, check the ioctl group to decide whether to check for media or not. (We only need to check for media on CD-specific ioctls.) Reported by: bland MFC after: 3 days Notes: svn path=/head/; revision=144135
* Boot away another stackgap (one of the lest ones in linuxlator/i386) byMaxim Sobolev2005-01-301-3/+11
| | | | | | | | | | | | | providing special version of CDIOCREADSUBCHANNEL ioctl(), which assumes that result has to be placed into kernel space not user space. In the long run more generic solution has to be designed WRT emulating various ioctl()s that operate on userspace buffers, but right now there is only one such ioctl() is emulated, so that it makes little sense. MFC after: 2 weeks Notes: svn path=/head/; revision=141031
* Start each of the license/copyright comments with /*-Warner Losh2005-01-051-2/+2
| | | | Notes: svn path=/head/; revision=139743
* For removable devices without media we set a zero mediasize but a non-zeroPoul-Henning Kamp2004-09-051-1/+1
| | | | | | | | | | | sectorsize in order to avoid a lot of checks around various divisions etc. Enforce the sectorsize being > 0 with a KASSERT on successful open. Fix scsi_cd.c to return 2k sectors when no media inserted. Notes: svn path=/head/; revision=134824
* Change the disk(9) API in order to make device removal more robust.Poul-Henning Kamp2004-02-181-23/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | Previously the "struct disk" were owned by the device driver and this gave us problems when the device disappared and the users of that device were not immediately disappearing. Now the struct disk is allocate with a new call, disk_alloc() and owned by geom_disk and just abandonned by the device driver when disk_create() is called. Unfortunately, this results in a ton of "s/\./->/" changes to device drivers. Since I'm doing the sweep anyway, a couple of other API improvements have been carried out at the same time: The Giant awareness flag has been flipped from DISKFLAG_NOGIANT to DISKFLAG_NEEDSGIANT A version number have been added to disk_create() so that we can detect, report and ignore binary drivers with old ABI in the future. Manual page update to follow shortly. Notes: svn path=/head/; revision=125975
* In camperiphdone(), make sure we check for fatal errors and bail outKenneth D. Merry2003-10-271-14/+0
| | | | | | | | | | | | | | | | | | | | | | | | | instead of retrying them blindly. This should fix some of the problems people have been having with cdrom drives taking a long time to probe. This should also eliminate the need for the initial TUR in cdsize(). cam_periph.c: Don't keep retrying if the error we get back is a fatal error. This should help us detect the transition from "Logical unit not ready, cause not reportable" to "Medium not present" in the "TUR many" handler. (The TUR many handler gets triggered for Logical unit not ready, cause not reportable errors.) scsi_cd.c: Remove the initial test unit ready in cdsize(). Hopefully it isn't necessary after the above change. Submitted by: gibbs (mostly) Tested by: peter MFC After: 2 weeks Notes: svn path=/head/; revision=121602
* Use bio_offset instead of bio_blknoPoul-Henning Kamp2003-10-181-2/+2
| | | | Notes: svn path=/head/; revision=121209
* (cdcleanup): Defend against calling sysctl_ctx_free before the sysctl_ctxThomas Quinot2003-10-071-12/+15
| | | | | | | | | | | | | | has been initialized. (cdsysctlinit): Set flag CD_FLAG_SCTX_INIT after sysctl_ctx has been initialized. This resolves a panic encountered when a cd drive is sucessfully probed but fails to attach. Reviewed by: ken Notes: svn path=/head/; revision=120884
* Add disk_destroy() call to detach processing.Poul-Henning Kamp2003-10-061-0/+15
| | | | | | | Add short tempered TUR to cdsize() as a workaround. Notes: svn path=/head/; revision=120854
* GEOMify.Poul-Henning Kamp2003-09-301-78/+39
| | | | Notes: svn path=/head/; revision=120599
* Disable the use of cloning use in floppy and CD drivers.Poul-Henning Kamp2003-09-111-4/+4
| | | | | | | | | | | | | This commit puts the relevant code snippets under #ifdef GONE_IN_5 (rather than #ifndef BURN_BRIDGES) thereby disabling the code now. The code wil be entirely removed before 5.2 unless we find reasons why this would be a bad idea. Approach suggested by: imp Notes: svn path=/head/; revision=119994
* Put the device cloning functions for disk-drivers under #ifndef BURN_BRIDGES.Poul-Henning Kamp2003-09-051-0/+8
| | | | | | | | | | | | | | For the floppy driver, use fdcontrol to manipulate density selection. For the CD drivers, the 'a' and 'c' suffix is without actual effect and any applications insisting on it can be satisfied with a symlink: ln -s /dev/cd0 /dev/cd0a Ongoing discussion may result in these pieces of code being removed before the 5-stable branch as opposed to after. Notes: svn path=/head/; revision=119761
* Move dynamic sysctl(8) variable creation for the cd(4) and da(4) driversKenneth D. Merry2003-09-031-21/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | out of cdregister() and daregister(), which are run from interrupt context. The sysctl code does blocking mallocs (M_WAITOK), which causes problems if malloc(9) actually needs to sleep. The eventual fix for this issue will involve moving the CAM probe process inside a kernel thread. For now, though, I have fixed the issue by moving dynamic sysctl variable creation for these two drivers to a task queue running in a kernel thread. The existing task queues (taskqueue_swi and taskqueue_swi_giant) run in software interrupt handlers, which wouldn't fix the problem at hand. So I have created a new task queue, taskqueue_thread, that runs inside a kernel thread. (It also runs outside of Giant -- clients must explicitly acquire and release Giant in their taskqueue functions.) scsi_cd.c: Remove sysctl variable creation code from cdregister(), and move it to a new function, cdsysctlinit(). Queue cdsysctlinit() to the taskqueue_thread taskqueue once we have fully registered the cd(4) driver instance. scsi_da.c: Remove sysctl variable creation code from daregister(), and move it to move it to a new function, dasysctlinit(). Queue dasysctlinit() to the taskqueue_thread taskqueue once we have fully registered the da(4) instance. taskqueue.h: Declare the new taskqueue_thread taskqueue, update some comments. subr_taskqueue.c: Create the new kernel thread taskqueue. This taskqueue runs outside of Giant, so any functions queued to it would need to explicitly acquire/release Giant if they need it. cd.4: Update the cd(4) man page to talk about the minimum command size sysctl/loader tunable. Also note that the changer variables are available as loader tunables as well. da.4: Update the da(4) man page to cover the retry_count, default_timeout and minimum_cmd_size sysctl variables/loader tunables. Remove references to /dev/r???, they aren't used any longer. cd.9: Update the cd(9) man page to describe the CD_Q_10_BYTE_ONLY quirk. taskqueue.9: Update the taskqueue(9) man page to describe the new thread task queue, and the taskqueue_swi_giant queue. MFC after: 3 days Notes: svn path=/head/; revision=119708
* Add a PATH_INQ flag, PIM_NO_6_BYTE, which indicates the SIM never wishes toNate Lawson2003-07-281-0/+8
| | | | | | | | | | | | | receive 6 byte commands. Add a check for this flag to da(4) and cd(4) so that they honor it. This is a quick workaround for many devices (especially USB) that require da(4) quirks to operate. The more complete approach is to finish the new transport code which will be aware of the SCSI version a transport implements. MFC after: 1 day Notes: svn path=/head/; revision=118105
* Use __FBSDID().David E. O'Brien2003-06-101-2/+4
| | | | Notes: svn path=/head/; revision=116162
* Use bioq_flush() to drain a bio queue with a specific error code.Poul-Henning Kamp2003-04-011-13/+3
| | | | | | | | | | | Retain the mistake of not updating the devstat API for now. Spell bioq_disksort() consistently with the remaining bioq_*(). #include <geom/geom_disk.h> where this is more appropriate. Notes: svn path=/head/; revision=112946
* Clean up dynamically allocated sysctl variables when we run dacleanup() andKenneth D. Merry2003-03-261-0/+6
| | | | | | | | | | | | | | cdcleanup(). This fixes sysctl problems ("can't re-use a leaf") when someone adds another peripheral at the same unit number. (e.g. rescan da0, it goes away, then rescan again and da0 comes back, but since we haven't cleaned up the sysctl variables from the last da0 instance, we can't register the variables for the new instance under the same name.) Reported by: njl Tested by: njl Notes: svn path=/head/; revision=112668
* Don't use the devstat->busy_count for state decisions in the devicePoul-Henning Kamp2003-03-151-4/+7
| | | | | | | | | | drivers. Doing so imposes atomicity and locking constraints on the devstat API. By: ken Notes: svn path=/head/; revision=112262
* Call devstat_start_transaction_bio() instead of devstat_start_transaction()Poul-Henning Kamp2003-03-151-1/+1
| | | | Notes: svn path=/head/; revision=112260
* Allocate the devstat structure with devstat_new_entry().Poul-Henning Kamp2003-03-081-14/+14
| | | | Notes: svn path=/head/; revision=112006
* Gigacommit to improve device-driver source compatibility betweenPoul-Henning Kamp2003-03-031-13/+9
| | | | | | | | | | | | | | | | branches: Initialize struct cdevsw using C99 sparse initializtion and remove all initializations to default values. This patch is automatically generated and has been tested by compiling LINT with all the fields in struct cdevsw in reverse order on alpha, sparc64 and i386. Approved by: re(scottl) Notes: svn path=/head/; revision=111815
* Fix ATAPI/USB/Firewire CDROM drive handling in cd(4) and hopefully fixKenneth D. Merry2003-02-211-265/+926
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | a number of related problems along the way. - Automatically detect CDROM drives that can't handle 6 byte mode sense and mode select, and adjust our command size accordingly. We have to handle this in the cd(4) driver (where the buffers are allocated), since the parameter list length is different for the 6 and 10 byte mode sense commands. - Remove MODE_SENSE and MODE_SELECT translation removed in ATAPICAM and in the umass(4) driver, since there's no way for that to work properly. - Add a quirk entry for CDROM drives that just hang when they get a 6 byte mode sense or mode select. The reason for the quirk must be documented in a PR, and all quirks must be approved by ken@FreeBSD.org. This is to make sure that we fully understand why each quirk is needed. Once the CAM_NEW_TRAN_CODE is finished, we should be able to remove any such quirks, since we'll know what protocol the drive speaks (SCSI, ATAPI, etc.) and therefore whether we should use 6 or 10 byte mode sense/select commands. - Change the way the da(4) handles the no_6_byte sysctl. There is now a per-drive sysctl to set the minimum command size for that particular disk. (Since you could have multiple disks with multiple requirements in one system.) - Loader tunable support for all the sysctls in the da(4) and cd(4) drivers. - Add a CDIOCCLOSE ioctl for cd(4) (bde pointed this out a long time ago). - Add a media validation routine (cdcheckmedia()) to the cd(4) driver, to fix some problems bde pointed out a long time ago. We now allow open() to succeed no matter what, but if we don't detect valid media, the user can only issue CDIOCCLOSE or CDIOCEJECT ioctls. - The media validation routine also reads the table of contents off the drive. We use the table of contents to implement the CDIOCPLAYTRACKS ioctl using the PLAY AUDIO MSF command. The PLAY AUDIO TRACK INDEX command that we previously used was deprecated after SCSI-2. It works in every SCSI CDROM I've tried, but doesn't seem to work on ATAPI CDROM drives. We still use the play audio track index command if we don't have a valid TOC, but I suppose it'll fail anyway in that case. - Add _len() versions of scsi_mode_sense() and scsi_mode_select() so that we can specify the minimum command length. - Fix a couple of formatting problems in the sense printing code. MFC after: 4 weeks Notes: svn path=/head/; revision=111206
* Back out M_* changes, per decision of the TRB.Warner Losh2003-02-191-22/+22
| | | | | | | Approved by: trb Notes: svn path=/head/; revision=111119