summaryrefslogtreecommitdiffstats
path: root/sys/cam
Commit message (Collapse)AuthorAgeFilesLines
* Add and utilize defines for the ATA device register.brueffer2012-07-121-3/+3
| | | | | | | PR: 169764 Submitted by: Steven Hartland <steven.hartland@multiplay.co.uk> Reviewed by: mav MFC after: 2 weeks
* Apply similar same change as in r238379:brueffer2012-07-111-2/+2
| | | | | | | Renamed the kern.cam.ada.ada_send_ordered sysctl and tunable to kern.cam.ada.send_ordered, more in line with the other da sysctls/tunables. Suggested by: kib
* Renamed the kern.cam.da.da_send_ordered sysctl and tunable tobrueffer2012-07-111-2/+2
| | | | | | | | kern.cam.da.send_ordered, more in line with the other da sysctls/tunables. PR: 169765 Submitted by: Steven Hartland <steven.hartland@multiplay.co.uk> Reviewed by: mav
* - fix description of SECURITY_FREEZE_LOCK (1)brueffer2012-07-111-2/+2
| | | | | | | | | - add missing underscores to SECURITY_DISABLE_PASSWORD PR: 169763 (1) Submitted by: Steven Hartland <steven.hartland@multiplay.co.uk> Reviewed by: mav MFC after: 1 week
* Make the da(4) driver notify GEOM about LUN size change.trasz2012-07-071-0/+2
| | | | | Reviewed by: mav Sponsored by: FreeBSD Foundation
* Remove variables which are initialized but never used thereaftereadler2012-07-072-8/+2
| | | | | | | | reported by gcc46 warning Reviewed by: scottl Approved by: cperciva MFC after: 1 week
* Add a loader tunable, kern.cam.ctl.disable, that will disableken2012-06-285-1/+33
| | | | | | loading CTL. This may be useful in very low memory installations. MFC after: 3 days
* Add a sysctl to set the cdrom timeout. Data recovery operations fromimp2012-06-281-2/+10
| | | | | | | | | | a CD or DVD drive with a damaged disc often benefit from a shorter timeout. Also, when retries are set to 0, an application is expecting errors and recovering them so do not print the error into the log. The number of expected errors can literally be in the hundreds of thousands which significantly slows data recovery. Reviewed by: ken@ (but quite some time ago).
* Fix a typo in a panic() call.ken2012-06-281-1/+1
| | | | | | PR: kern/169497 Submitted by: Steven Hartland <steven.hartland@multiplay.co.uk> MFC after: 3 days
* Fix an issue that caused the kernel to panic inside CTL when tryingken2012-06-261-9/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | to attach to target capable HBAs that implement the old immediate notify (XPT_IMMED_NOTIFY) and notify acknowledge (XPT_NOTIFY_ACK) CCBs. The new API has been in place since SVN change 196008 in 2009. The solution is two-fold: fix CTL to handle the responses from the HBAs, and convert the HBA drivers in question to use the new API. These drivers have not been tested with CTL, so how well they will interoperate with CTL is unknown. scsi_target.c: Update the userland target example code to use the new immediate notify API. scsi_ctl.c: Detect when an immediate notify CCB is returned with CAM_REQ_INVALID or CAM_PROVIDE_FAIL status, and just free it. Fix a duplicate assignment. aic79xx.c, aic79xx_osm.c: Update the aic79xx driver to use the new API. Target mode is not enabled on for this driver, so the changes will have no practical effect. aic7xxx.c, aic7xxx_osm.c: Update the aic7xxx driver to use the new API. sbp_targ.c: Update the firewire target code to work with the new API. mpt_cam.c: Update the mpt(4) driver to work with the new API. Target mode is only enabled for Fibre Channel mpt(4) devices. MFC after: 3 days
* Fix a bug which causes a panic in daopen(). The panic is caused byken2012-06-242-15/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | a da(4) instance going away while GEOM is still probing it. In this case, the GEOM disk class instance has been created by disk_create(), and the taste of the disk is queued in the GEOM event queue. While that event is queued, the da(4) instance goes away. When the open call comes into the da(4) driver, it dereferences the freed (but non-NULL) peripheral pointer provided by GEOM, which results in a panic. The solution is to add a callback to the GEOM disk code that is called when all of its resources are cleaned up. This is implemented inside GEOM by adding an optional callback that is called when all consumers have detached from a provider, and the provider is about to be deleted. scsi_cd.c, scsi_da.c: In the register routine for the cd(4) and da(4) routines, acquire a reference to the CAM peripheral instance just before we call disk_create(). Use the new GEOM disk d_gone() callback to register a callback (dadiskgonecb()/cddiskgonecb()) that decrements the peripheral reference count once GEOM has finished cleaning up its resources. In the cd(4) driver, clean up open and close behavior slightly. GEOM makes sure we only get one open() and one close call, so there is no need to set an open flag and decrement the reference count if we are not the first open. In the cd(4) driver, use cam_periph_release_locked() in a couple of error scenarios to avoid extra mutex calls. geom.h: Add a new, optional, providergone callback that is called when a provider is about to be deleted. geom_disk.h: Add a new d_gone() callback to the GEOM disk interface. Bump the DISK_VERSION to version 2. This probably should have been done after a couple of previous changes, especially the addition of the d_getattr() callback. geom_disk.c: Add a providergone callback for the disk class, g_disk_providergone(), that calls the user's d_gone() callback if it exists. Bump the DISK_VERSION to 2. geom_subr.c: In g_destroy_provider(), call the providergone callback if it has been provided. In g_new_geomf(), propagate the class's providergone callback to the new geom instance. blkfront.c: Callers of disk_create() are supposed to pass in DISK_VERSION, not an explicit disk API version number. Update the blkfront driver to do that. disk.9: Update the disk(9) man page to include information on the new d_gone() callback, as well as the previously added d_getattr() callback, d_descr field, and HBA PCI ID fields. MFC after: 5 days
* Add scsi_extract_sense_ccb() -- wrapper around scsi_extract_sense_len().mav2012-06-235-71/+56
| | | | It allows to remove number of duplicate checks from several places.
* Change 'camcontrol defects' to first probe a drive to find out how muchken2012-06-221-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | defect information it has before grabbing the full defect list. This works around a bug with some Hitachi drives that generate data overrun errors when they are asked for more defect data than they have. The change is done in a spec-compliant way, so it should have no negative impact on drives that don't have this issue. This is based on work originally done at Sandvine. scsi_da.h: Add a define for the maximum amount of data that can be contained in a defect list. camcontrol.c: Update the readdefects() function to issue an initial command to determine the length of the defect list, and then use that length in the request for the full defect list. camcontrol.8: Add a note that some drives will report 0 defects available if you don't request either the PLIST or GLIST. Submitted by: Mark Johnston <markjdb@gmail.com> (original version) MFC after: 3 days
* Don't print SCSI Queue Full and CAM_REQUEUE_REQ statuses as errors if theymav2012-06-221-1/+4
| | | | | | were handled and retried. They are part of normal operation for SCSI TCQ. MFC after: 3 days
* Make cam_periph_hold() behavior consistent: drop taken reference andmav2012-06-211-0/+4
| | | | | | return ENXIO if periph was invalidated while we were waiting for it. MFC after: 1 week
* In camisr() clear CAM_SIM_ON_DONEQ flag after camisr_runqueue() purged SIMmav2012-06-211-1/+1
| | | | | | | | | | done queue. Clearing it before caused extra SIM queueing in some cases. It was invisible during normal operation, but during USB device unplug and respective SIM destruction it could keep pointer on SIM without having counted reference and as result crash the system by use afer free. Reported by: hselasky MFC after: 1 week
* Remove unused error variables in cdclose() and daclose().mav2012-06-202-4/+2
|
* Check status of cam_periph_hold() inside cdclose(). If cd device wasmav2012-06-201-1/+6
| | | | | | | | invalidated while open, cam_periph_hold() will return error and won't get the reference. Following reference release will crash the system. Sponsored by: iXsystems, Inc. MFC after: 3 days
* Fix several reference counting and object lifetime issues betweenken2012-06-205-22/+125
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the pass(4) and enc(4) drivers and devfs. The pass(4) driver uses the destroy_dev_sched() routine to schedule its device node for destruction in a separate thread context. It does this because the passcleanup() routine can get called indirectly from the passclose() routine, and that would cause a deadlock if the close routine tried to destroy its own device node. In any case, once a particular passthrough driver number, e.g. pass3, is destroyed, CAM considers that unit number (3 in this case) available for reuse. The problem is that devfs may not be done cleaning up the previous instance of pass3, and will panic if isn't done cleaning up the previous instance. The solution is to get a callback from devfs when the device node is removed, and make sure we hold a reference to the peripheral until that happens. Testing exposed some other cases where we have reference counting issues, and those were also fixed in the pass(4) driver. cam_periph.c: In camperiphfree(), reorder some of the operations. The peripheral destructor needs to be called before the peripheral is removed from the peripheral is removed from the list. This is because once we remove the peripheral from the list, and drop the topology lock, the peripheral number may be reused. But if the destructor hasn't been called yet, there may still be resources hanging around (like devfs nodes) that haven't been fully cleaned up. cam_xpt.c: Add an argument to xpt_remove_periph() to indicate whether the topology lock is already held. scsi_enc.c: Acquire an extra reference to the peripheral during registration, and release it once we get a callback from devfs indicating that the device node is gone. Call destroy_dev_sched_cb() in enc_oninvalidate() instead of calling destroy_dev() in the cleanup routine. scsi_pass.c: Add reference counting to handle peripheral and devfs object lifetime issues. Add a reference to the peripheral and the devfs node in the peripheral registration. Don't attempt to add a physical path alias if the peripheral has been marked invalid. Release the devfs reference once the initial physical path alias taskqueue run has completed. Schedule devfs node destruction in the passoninvalidate(), and release our peripheral reference in a new routine, passdevgonecb() once the devfs node is gone. This allows the peripheral to fully go away, and the peripheral destructor, passcleanup(), will get called. MFC after: 3 days Sponsored by: Spectra Logic
* Remove never used CD/DA_FLAG_TAGGED_QUEUING flags.mav2012-06-182-6/+0
| | | | MFC after: 1 week
* One more major cam_periph_error() rewrite to improve error handling andmav2012-06-0910-537/+263
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | reporting. It includes: - removing of error messages controlled by bootverbose, replacing them with more universal and informative debugging on CAM_DEBUG_INFO level, that is now built into the kernel by default; - more close following to the arguments submitted by caller, such as SF_PRINT_ALWAYS, SF_QUIET_IR and SF_NO_PRINT; consumer knows better which errors are usual/expected at this point and which are really informative; - adding two new flags SF_NO_RECOVERY and SF_NO_RETRY to allow caller specify how much assistance it needs at this point; previously consumers controlled that by not calling cam_periph_error() at all, but that made behavior inconsistent and debugging complicated; - tuning debug messages and taken actions order to make debugging output more readable and cause-effect relationships visible; - making camperiphdone() (common device recovery completion handler) to also use cam_periph_error() in most cases, instead of own dumb code; - removing manual sense fetching code from cam_periph_error(); I was told by number of people that it is SIM obligation to fetch sense data, so this code is useless and only significantly complicates recovery logic; - making ada, da and pass driver to use cam_periph_error() with new limited recovery options to handle error recovery and debugging in common way; as one of results, CAM_REQUEUE_REQ and other retrying statuses are now working fine with pass driver, that caused many problems before. - reverting r186891 by raj@ to avoid burning few seconds in tight DELAY() loops on device probe, while device simply loads media; I think that problem may already be fixed in other way, and even if it is not, solution must be different. Sponsored by: iXsystems, Inc. MFC after: 2 weeks
* Add CAM_DEBUG_INFO debug messages for periph created/invalidated/destroyedmav2012-06-072-3/+29
| | | | and for asyncs sent.
* To make CAM debugging easier, compile in some debug flags (CAM_DEBUG_INFO,mav2012-06-075-69/+49
| | | | | | | | | | CAM_DEBUG_CDB, CAM_DEBUG_PERIPH and CAM_DEBUG_PROBE) by default. List of these flags can be modified with CAM_DEBUG_COMPILE kernel option. CAMDEBUG kernel option still enables all possible debug, if not overriden. Additional 50KB of kernel size is a good price for the ability to debug problems without rebuilding the kernel. In case where size is important, debugging can be compiled out by setting CAM_DEBUG_COMPILE option to 0.
* Remove declaration of scsi_interpret_sense(), removed 11 years ago.mav2012-06-061-13/+0
|
* Fix a memory leak in the kernel case in scsi_command_string().ken2012-06-061-0/+4
| | | | | Submitted by: Kashyap Desai <Kashyap.Desai@lsi.com> MFC after: 3 days
* ATA/SATA controllers have no idea about protocol of the connected devicemav2012-06-061-1/+19
| | | | | | | until transport will do some probe actions (at least soft reset). Make ATA/SATA SIMs to not report bogus and confusing PROTO_ATA protocol. Make ATA/SATA transport to fill that gap by reporting protocol to SIM with XPT_SET_TRAN_SETTINGS and patching XPT_GET_TRAN_SETTINGS results if needed.
* Use default error handler when flushing disk caches.mav2012-06-051-1/+1
|
* Tune and add some more CAM_DEBUG() points for the probe sequences.mav2012-06-052-39/+44
|
* Replace #ifdef CAMDEBUG + if + panic() with single KASSERT().mav2012-06-051-7/+2
|
* Do not reinvent a wheel and let default error handler do its job.mav2012-06-051-25/+4
|
* Tune and add some missing CAM_DEBUG() points for better consistency.mav2012-06-055-16/+48
|
* Remove some dead code that I doubt will ever be implemented.mav2012-06-041-108/+0
|
* Rewrite enabling NCQ for SATA devices in a way more alike to SCSI TCQ.mav2012-06-023-99/+115
| | | | | | | This allows to control it with `camcontrol negotiate adaX -T (en|dis)able` on the fly, same as for SCSI devices. Sponsored by: iXsystems, Inc.
* Print FC PortID as a hex number. This makes it easy tomjacob2012-06-011-3/+3
| | | | | | | | | | | | figure out domain, etc.. Zero ATIO and INOTify allocations. It makes for much less guesswork when looking at the structure and seeing 'deadc0de' present. Reviewed by: kdm MFC after: 2 weeks Sponsored by: Spectralogic
* Use AC_GETDEV_CHANGED async to notify ada driver about DMA and NCQ statusmav2012-06-013-6/+37
| | | | change. Now that allows switching between PIO and DMA modes on the fly.
* Add support for newer garmin deviceseadler2012-05-301-0/+4
| | | | | | | PR: kern/163932 Submitted by: Bartosz Fabianowski <freebsd@chillt.de> Approved by: cperciva MFC after: 1 week
* Allow to change number of openings (used tags) for ATA/SATA devicesmav2012-05-292-15/+15
| | | | | | | via `camcontrol tags ... -N ...`. There is no need to tune it in usual cases, but some users want to have it for debugging purposes. MFC after: 2 weeks
* Plug request and references leak caused by race between invalidatedmav2012-05-292-11/+21
| | | | | | | | ond probe periph destruction and new incoming probe request. This at least caused problems with SATA Port Multipliers hot-plug. MFC after: 2 weeks
* Work around a race condition in devfs by changing the way closesken2012-05-275-69/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | are handled in most CAM peripheral drivers that are not handled by GEOM's disk class. The usual character driver open and close semantics are that the driver gets N open calls, but only one close, when the last caller closes the device. CAM peripheral drivers expect that behavior to be honored to the letter, and the CAM peripheral driver code (specifically cam_periph_release_locked_busses()) panics if it is done incorrectly. Since devfs has to drop its locks while it calls a driver's close routine, and it does not have a way to delay or prevent open calls while it is calling the close routine, there is a race. The sequence of events, simplified a bit, is: - devfs acquires a lock - devfs checks the reference count, and if it is 1, continues to close. - devfs releases the lock - 2nd process open call on the device happens here - devfs calls the driver's close routine - devfs acquires a lock - devfs decrements the reference count - devfs releases the lock - 2nd process close call on the device happens here At the second close, we get a panic in cam_periph_release_locked_busses(), complaining that peripheral has been released when the reference count is already 0. This is because we have gotten two closes in a row, which should not happen. The fix is to add the D_TRACKCLOSE flag to the driver's cdevsw, so that we get a close() call for each open(). That does happen reliably, so we can make sure that our reference counts are correct. Note that the sa(4) and pt(4) drivers only allow one context through the open routine. So these drivers aren't exposed to the same race condition. scsi_ch.c, scsi_enc.c, scsi_enc_internal.h, scsi_pass.c, scsi_sg.c: For these drivers, change the open() routine to increment the reference count for every open, and just decrement the reference count in the close. Call cam_periph_release_locked() in some scenarios to avoid additional lock and unlock calls. scsi_pt.c: Call cam_periph_release_locked() in some scenarios to avoid additional lock and unlock calls. MFC after: 3 days
* Add tunable/sysctl kern.cam.pmp.hide_special, controlling whether specialmav2012-05-251-17/+35
| | | | | | | | PMP ports such as PMP configuration or SEMB should be exposed or hidden. These ports were always hidden before as useless and sometimes promatic. But with updated ses driver supporting SEMB it is no longer so straight. Keep ports hidden by default to avoid probe request ttimeouts if SEP is not connected to PMP's SEMB via I2C, that is very often situation.
* Remove sleep() from invalidate call in ses driver, waiting for daemonmav2012-05-251-10/+8
| | | | | | | | | process exit. Instead use CAM's standard reference counting to prevent periph going away until process won't complete. I think that sleep in single CAM SWI thread is not a good idea and may lead to deadlocks if daemon process waits for some command completion. Combined with recent patch avoiding use of CAM SWI for ATA it just causes panics because of sleeps prohibited in interrupt thread context.
* MFprojects/zfsd:mav2012-05-247-2628/+7766
| | | | | | | | | | | Revamp the CAM enclosure services driver. This updated driver uses an in-kernel daemon to track state changes and publishes physical path location information\for disk elements into the CAM device database. Sponsored by: Spectra Logic Corporation Sponsored by: iXsystems, Inc. Submitted by: gibbs, will, mav
* MFprojects/zfsd:mav2012-05-248-12/+412
| | | | | | | | - Add low-level support for SATA Enclosure Management Bridge (SEMB) devices -- SATA equivalents of the SCSI SES/SAF-TE devices. - Add some utility functions for SCSI SAF-TE devices access. Sponsored by: iXsystems, Inc.
* Add two functions xpt_batch_start() and xpt_batch_done() to the CAM SIM KPImav2012-05-123-1/+24
| | | | | | | | | to allow drivers to handle request completion directly without passing them to the CAM SWI thread removing extra context switch. Modify all ATA/SATA drivers to use them. Reviewed by: gibbs, ken MFC after: 2 weeks
* Add support for:eadler2012-04-291-0/+21
| | | | | | | | | | | Olympus FE-210 camera LG UP3S MP3 player Laser MP3-2GA13 MP3 PR: usb/119201 Submitted by: Peter Jeremy <peterjeremy@optushome.com.au> Approved by: cperciva MFC after: 1 week
* Alike to SCSI make adaclose() to not return error if device gone.mav2012-04-181-3/+2
| | | | | | This fixes KASSERT panic inside GEOM if kernel built with INVARIANTS. MFC after: 1 week
* Fix panic at boot with SD/MMC readers with no media present, introducedtrasz2012-04-171-1/+3
| | | | | at r234177. Note that this is a temporary fix, until I come up with something prettier.
* Refactor da(4) to remove one of two code paths used to query capacitytrasz2012-04-121-184/+72
| | | | | | | data. Reviewed by: ken, mav (earlier version) Sponsored by: The FreeBSD Foundation
* Change the SCSI INQUIRY peripheral qualifier that CTL reports for LUNsken2012-04-067-6/+84
| | | | | | | | | | | | | | | | | | | | | | | | | | | | that don't exist. Anecdotal evidence indicates that it is better to return 011b (bad LUN) than 001b (LUN offline). However, this change also gives the user a sysctl/tunable, kern.cam.ctl.inquiry_pq_no_lun, to override the change and return to the previous behavior. (The previous behavior was to return 001b, or LUN offline.) ctl.c: Change the default inquiry peripheral qualifier to 011b, and add a sysctl and tunable to allow the user to change it back to 001b if needed. Don't insert a Copan copyright statement in the inquiry data. The copyright statements on the files are sufficient. ctl_private.h: Add sysctl variable context to the CTL softc. ctl_cmd_table.c, ctl_frontend_internal.c, ctl_frontend.c, ctl_backend.c, ctl_error.c: Include sys/sysctl.h. MFC after: 3 days
* Be more conservative in using READ CAPACITY(16) command. Previous codemav2012-03-311-3/+1
| | | | | | | | | checked PROTECT bit in INQUIRY data for all SPC devices, while it is defined only since SPC-3. But there are some SPC-2 USB devices were reported, that have PROTECT bit set, return no error for READ CAPACITY(16) command, but return wrong sector count value in response. MFC after: 3 days
OpenPOWER on IntegriCloud