summaryrefslogtreecommitdiffstats
path: root/sys/cam/cam_periph.c
Commit message (Collapse)AuthorAgeFilesLines
* Separate the parallel scsi knowledge out of the core of the XPT, andscottl2009-07-101-4/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Change cam_periph_ioctl() to take 'cmd' and a u_long instead of anscottl2009-06-221-1/+1
| | | | | | | | | int. All of its callers pass in cmd as a u_long, so this has always been a dangerous type demotion. It was spooted by clang/llvm trying to do a type promotion and sign extension within cam_periph_ioctl. Submitted by: rdivacky
* Add missing free(9) in error case.trasz2009-05-121-0/+1
| | | | | Found with: Coverity Prevent(tm) CID: 4224
* cam_periph_alloc: fix "invalid periph name" error conditionfjoe2009-02-091-1/+1
| | | | | Found with: Coverity Prevent(tm) CID: 130
* Now that mtx_sleep/msleep can accept Giant as the interlock, simplify thejhb2009-01-261-19/+6
| | | | | | | CAM locking code slightly to no longer special case sleeping when a sim uses Giant for its lock. Tested by: trasz
* Guard against NULL pointer dereference.trasz2009-01-231-0/+4
| | | | | | | | Reviewed by: scottl Approved by: rwatson (mentor) Sponsored by: FreeBSD Foundation Found with: Coverity Prevent(tm) CID: 130
* Periph driver fixes, second try.trasz2008-12-191-3/+17
| | | | | | Reviewed by: scottl Approved by: rwatson (mentor) Sponsored by: FreeBSD Foundation
* Move mtx_assert lower, when we can be sure that the pointertrasz2008-12-191-2/+1
| | | | | | | | to the mutex is valid. Reviewed by: scottl Approved by: rwatson (mentor) Sponsored by: FreeBSD Foundation
* Revert r186186 for now; it breaks stuff.trasz2008-12-171-2/+2
| | | | Approved by: rwatson (mentor)
* Fix locking in periph drivers - don't try to unlock periphtrasz2008-12-161-2/+2
| | | | | | | | that was already deallocated. Reviewed by: scottl Approved by: rwatson (mentor) Sponsored by: FreeBSD Foundation
* Fix typo.raj2008-02-121-1/+1
| | | | Approved by: cognet (mentor)
* Eliminate the use of M_TEMP.scottl2007-05-141-2/+3
|
* Retire the spl() markers. Add in some minor missed locking as a result.scottl2007-04-191-23/+7
|
* Inline cam_periph_lock|unlock to make debugging easier. Use morescottl2007-04-191-20/+0
| | | | CAM_SIM_LOCK() more uniformly.
* Drop the topology lock before calling the periph oninvalidate and dtorscottl2007-04-161-7/+5
| | | | vectors.
* Remove Giant from CAM. Drivers (SIMs) now register a mutex that CAM willscottl2007-04-151-45/+86
| | | | | | | | | | | 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.
* Add an xpt_print function to reduce most of the xpt_print_path/printfmjacob2006-12-051-38/+28
| | | | | | | pairs. Convert the core code to use it. Reviewed by: scsi (various folks weighing in with good advice) MFC after: 2 weeks
* Put a bit of hysteresis into both BUSY SCSI status returnsmjacob2006-10-011-4/+20
| | | | | | | | | | | | | | | | | and CAM_RESRC_UNAVAIL returns. Delay a tunable amount for either between retries. This came up because the MPT IOC was returning "IOC out of resources" for some user and this caused a CAM_RESRC_UNAVAIL return. Putting a bit of delay between retries helped them out. There was some discussion that an async event should be used to clear CAM_RESRC_UNAVAIL. That's probably a better notion eventually. Reviewed by: scsi@freebsd.org (ade, scott) MFC after: 1 week
* Make physical buffers in cam_periph_mapmem owned by the kernel in case wemjacob2006-05-241-0/+10
| | | | | | | | return to user space w/o waiting for I/O to complete. I tried to get several folks who know this code better than me to review it with no luck. I *do* know that w/o this code, using the SCSI target driver panics in userret (if it doesn't panic in knote first).
* There should be no need to retry when the CCB status code isiedowse2006-01-081-0/+2
| | | | | | | CAM_LUN_INVALID or CAM_TID_INVALID. Retries were being triggered here when a umass device was unplugged, and while the retries themselves are probably harmless, they complicated finding the real SIM removal problems.
* - Providing fine-grained malloc statistic by replacing M_DEVBUF withavatar2005-07-011-3/+6
| | | | | | | | | | | | | module-specific malloc types. These should help us to pinpoint the possible memory leakage in the future. - Implementing xpt_alloc_ccb_nowait() and replacing all malloc/free based CCB memory management with xpt_alloc_ccb[_nowait]/xpt_free_ccb. Hopefully this would be helpful if someday we move the CCB allocator to use UMA instead of malloc(). Encouraged by: jeffr, rwatson Reviewed by: gibbs, scottl Approved by: re (scottl)
* Protect against trying to free a non-existant peripheral.scottl2005-02-201-0/+4
| | | | | Submitted by: Coverity Prevent analysis tool MFC After: 3 days
* Start each of the license/copyright comments with /*-imp2005-01-051-1/+1
|
* Correct a typo in a comment: alloation->allocationgibbs2004-08-301-1/+1
| | | | Reported by: Jens Schweikhardt <schweikh@schweikhardt.net>
* Don't be so chatty when performing manual sense. This should make ATAPICAMscottl2003-11-081-2/+2
| | | | devices a lot more quiet.
* In camperiphdone(), make sure we check for fatal errors and bail outken2003-10-271-2/+17
| | | | | | | | | | | | | | | | | | | | | | 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
* There is no need to muck about with the B_PHYS flag here. We never evenphk2003-10-181-8/+0
| | | | get close to DEV_STRATEGY() which is the only place it is relevant.
* (camperiphdone): When the cam_periph layer performs sense recovery,thomas2003-09-211-1/+1
| | | | | | | | completion of recovery is indicated by positioning the CAM_AUTOSNS_VALID bit in the status field of the CCB, not in the flags field. This fixes an endless loop of sense recovery actions. Reviewed by: ken
* In case vmapbuf() fails, release all of the held resources.alc2003-09-101-5/+3
| | | | Submitted by: tegge
* Use __FBSDID().obrien2003-06-101-2/+3
|
* Add /* FALLTHROUGH */phk2003-06-011-0/+4
| | | | Found by: FlexeLint
* Add /* FALLTHROUGH */phk2003-05-311-0/+3
| | | | Found by: FlexeLint
* Sufficient access checks are performed by vmapbuf() that calling useracc()alc2003-04-061-19/+0
| | | | is pointless. Remove the calls to useracc().
* Run a revision of the devstat interface:phk2003-03-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Kernel: Change statistics to use the *uptime() timescale (ie: relative to boottime) rather than the UTC aligned timescale. This makes the device statistics code oblivious to clock steps. Change timestamps to bintime format, they are cheaper. Remove the "busy_count", and replace it with two counter fields: "start_count" and "end_count", which are updated in the down and up paths respectively. This removes the locking constraint on devstat. Add a timestamp argument to devstat_start_transaction(), this will normally be a timestamp set by the *_bio() function in bp->bio_t0. Use this field to calculate duration of I/O operations. Add two timestamp arguments to devstat_end_transaction(), one is the current time, a NULL pointer means "take timestamp yourself", the other is the timestamp of when this transaction started (see above). Change calculation of busy_time to operate on "the salami principle": Only when we are idle, which we can determine by the start+end counts being identical, do we update the "busy_from" field in the down path. In the up path we accumulate the timeslice in busy_time and update busy_from. Change the byte_* and num_* fields into two arrays: bytes[] and operations[]. Userland: Change the misleading "busy_time" name to be called "snap_time" and make the time long double since that is what most users need anyway, fill it using clock_gettime(CLOCK_MONOTONIC) to put it on the same timescale as the kernel fields. Change devstat_compute_etime() to operate on struct bintime. Remove the version 2 legacy interface: the change to bintime makes compatibility far too expensive. Fix a bug in systat's "vm" page where boot relative busy times would be bogus. Bump __FreeBSD_version to 500107 Review & Collaboration by: ken
* Back out M_* changes, per decision of the TRB.imp2003-02-191-1/+1
| | | | Approved by: trb
* Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.alfred2003-01-211-1/+1
| | | | Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.
* Close the remaining user address mapping races for physicaldillon2003-01-201-3/+23
| | | | | | | I/O, CAM, and AIO. Still TODO: streamline useracc() checks. Reviewed by: alc, tegge MFC after: 7 days
* Panic message strings do not need a trailing \n.imp2002-11-141-1/+1
| | | | Reviewed by: ken
* Make SCSI_DELAY setable at boot time and runtime via thebrooks2002-09-021-1/+1
| | | | | | kern.cam.scsi_delay tunable/sysctl. Reviewed by: mdodd, njl
* Add some \n's to printf()speter2002-08-241-5/+5
|
* Fix unit wiring. Also, change the variable "hit" to "wired" so that itpeter2002-08-241-11/+9
| | | | | | is more obvious. Obtained from: gibbs/ken
* If we boot verbose, then print out 'interesting' CAM errors that otherwisemjacob2002-06-071-5/+65
| | | | would hide problems (like Selection Timeout).
* Kill the command (don't rerun it) if we had an AUTOSENSE failure.mjacob2001-07-301-3/+5
| | | | | | If we had an AUTOSENSE failure, we don't know what SENSE DATA we had for a CHECK CONDITION. It's far better to assume failure in this case.
* Hints overhaul:peter2001-06-121-14/+15
| | | | | | | | | - Replace some very poorly thought out API hacks that should have been fixed a long while ago. - Provide some much more flexible search functions (resource_find_*()) - Use strings for storage instead of an outgrowth of the rather inconvenient temporary ioconf table from config(). We already had a fallback to using strings before malloc/vm was running anyway.
* In camperiphscsisenseerror(), don't return an error when the error actionken2001-04-301-0/+3
| | | | | | is SS_NOP. Submitted by: joerg
* Fix an off-by-2 error in periphdriver_register(). The read side of theken2001-04-161-1/+1
| | | | | | | | bcopy would go off the end of the array by two elements, which sometimes causes a panic if it happens to cross into a page that isn't mapped. Submitted by: gibbs Reviewed by: peter
* If we have and error and are booting verbosely, don't be complainingmjacob2001-04-041-1/+7
| | | | | if this was a non-retryable selection timeout- wading through 256 targets worth of Fibre Channel 'selection timeouts' is tedious at best.
* Catch up to header include changes:jhb2001-03-281-0/+2
| | | | | - <sys/mutex.h> now requires <sys/systm.h> - <sys/mutex.h> and <sys/sx.h> now require <sys/lock.h>
* Rewrite of the CAM error recovery code.ken2001-03-271-473/+445
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some of the major changes include: - The SCSI error handling portion of cam_periph_error() has been broken out into a number of subfunctions to better modularize the code that handles the hierarchy of SCSI errors. As a result, the code is now much easier to read. - String handling and error printing has been significantly revamped. We now use sbufs to do string formatting instead of using printfs (for the kernel) and snprintf/strncat (for userland) as before. There is a new catchall error printing routine, cam_error_print() and its string-based counterpart, cam_error_string() that allow the kernel and userland applications to pass in a CCB and have errors printed out properly, whether or not they're SCSI errors. Among other things, this helped eliminate a fair amount of duplicate code in camcontrol. We now print out more information than before, including the CAM status and SCSI status and the error recovery action taken to remedy the problem. - sbufs are now available in userland, via libsbuf. This change was necessary since most of the error printing code is shared between libcam and the kernel. - A new transfer settings interface is included in this checkin. This code is #ifdef'ed out, and is primarily intended to aid discussion with HBA driver authors on the final form the interface should take. There is example code in the ahc(4) driver that implements the HBA driver side of the new interface. The new transfer settings code won't be enabled until we're ready to switch all HBA drivers over to the new interface. src/Makefile.inc1, lib/Makefile: Add libsbuf. It must be built before libcam, since libcam uses sbuf routines. libcam/Makefile: libcam now depends on libsbuf. libsbuf/Makefile: Add a makefile for libsbuf. This pulls in the sbuf sources from sys/kern. bsd.libnames.mk: Add LIBSBUF. camcontrol/Makefile: Add -lsbuf. Since camcontrol is statically linked, we can't depend on the dynamic linker to pull in libsbuf. camcontrol.c: Use cam_error_print() instead of checking for CAM_SCSI_STATUS_ERROR on every failed CCB. sbuf.9: Change the prototypes for sbuf_cat() and sbuf_cpy() so that the source string is now a const char *. This is more in line wth the standard system string functions, and helps eliminate warnings when dealing with a const source buffer. Fix a typo. cam.c: Add description strings for the various CAM error status values, as well as routines to look up those strings. Add new cam_error_string() and cam_error_print() routines for userland and the kernel. cam.h: Add a new CAM flag, CAM_RETRY_SELTO. Add enumerated types for the various options available with cam_error_print() and cam_error_string(). cam_ccb.h: Add new transfer negotiation structures/types. Change inq_len in the ccb_getdev structure to be "reserved". This field has never been filled in, and will be removed when we next bump the CAM version. cam_debug.h: Fix typo. cam_periph.c: Modularize cam_periph_error(). The SCSI error handling part of cam_periph_error() is now in camperiphscsistatuserror() and camperiphscsisenseerror(). In cam_periph_lock(), increase the reference count on the periph while we wait for our lock attempt to succeed so that the periph won't go away while we're sleeping. cam_xpt.c: Add new transfer negotiation code. (ifdefed out) Add a new function, xpt_path_string(). This is a string/sbuf analog to xpt_print_path(). scsi_all.c: Revamp string handing and error printing code. We now use sbufs for much of the string formatting code. More of that code is shared between userland the kernel. scsi_all.h: Get rid of SS_TURSTART, it wasn't terribly useful in the first place. Add a new error action, SS_REQSENSE. (Send a request sense and then retry the command.) This is useful when the controller hasn't performed autosense for some reason. Change the default actions around a bit. scsi_cd.c, scsi_da.c, scsi_pt.c, scsi_ses.c: SF_RETRY_SELTO -> CAM_RETRY_SELTO. Selection timeouts shouldn't be covered by a sense flag. scsi_pass.[ch]: SF_RETRY_SELTO -> CAM_RETRY_SELTO. Get rid of the last vestiges of a read/write interface. libkern/bsearch.c, sys/libkern.h, conf/files: Add bsearch.c, which is needed for some of the new table lookup routines. aic7xxx_freebsd.c: Define AHC_NEW_TRAN_SETTINGS if CAM_NEW_TRAN_CODE is defined. sbuf.h, subr_sbuf.c: Add the appropriate #ifdefs so sbufs can compile and run in userland. Change sbuf_printf() to use vsnprintf() instead of kvprintf(), which is only available in the kernel. Change the source string for sbuf_cpy() and sbuf_cat() to be a const char *. Add __BEGIN_DECLS and __END_DECLS around function prototypes since they're now exported to userland. kdump/mkioctls: Include stdio.h before cam.h since cam.h now includes a function with a FILE * argument. Submitted by: gibbs (mostly) Reviewed by: jdp, marcel (libsbuf makefile changes) Reviewed by: des (sbuf changes) Reviewed by: ken
* Change the peripheral driver list from a linker set to module drivenpeter2001-02-071-6/+26
| | | | | driver registration. This should allow things like da, sa, cd etc to be in seperate KLD's to the cam core and make them preloadable.
OpenPOWER on IntegriCloud