summaryrefslogtreecommitdiffstats
path: root/sys/cam/cam_xpt.c
Commit message (Collapse)AuthorAgeFilesLines
* MFC 278228:ken2015-02-181-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The __FreeBSD_version has been changed to 1001508 for the addition of the CDAI_TYPE_EXT_INQ request type. ------------------------------------------------------------------------ r278228 | ken | 2015-02-04 17:12:21 -0700 (Wed, 04 Feb 2015) | 32 lines Add support for probing the SCSI VPD Extended Inquiry page (0x86). This VPD page is effectively an extension of the standard Inquiry data page, and includes lots of additional bits. This commit includes support for probing the page in the SCSI probe code, and an additional request type for the XPT_DEV_ADVINFO CCB. CTL already supports the Extended Inquiry page. Support for querying this page in the sa(4) driver will come later. sys/cam/scsi/scsi_xpt.c: Probe the Extended Inquiry page, if the device supports it, and return it in response to a XPT_DEV_ADVINFO CCB if it is requested. sys/cam/scsi/cam_ccb.h: Define a new advanced information CCB data type, CDAI_TYPE_EXT_INQ. sys/cam/cam_xpt.c: Free the extended inquiry data in a device when the device goes away. sys/cam/cam_xpt_internal.h: Add an extended inquiry data pointer and length to struct cam_ed. sys/sys/param.h Bump __FreeBSD_version for the addition of the new CDAI_TYPE_EXT_INQ advanced information type. Sponsored by: Spectra Logic MFC after: 1 week ------------------------------------------------------------------------ Sponsored by: Spectra Logic
* MFC r277385: Remove extra mtx_unlock().mav2015-01-261-1/+0
| | | | Submitted by: Dmitry Luhtionov <dmitryluhtionov@gmail.com>
* MFC r274819:smh2014-12-211-5/+5
| | | | | | | | | Prevent overflow issues in timeout processing MFC r274852: Fix build with asr driver Sponsored by: Multiplay
* MFC r275368:mav2014-12-081-2/+9
| | | | | | | | | | When passing LUN IDs through treat ASCII values as fixed-length, not interpreating NULLs as EOLs, but converting them to spaces. SPC-4 does not tell that T10-based IDs should be NULL-terminated/padded. And while it tells that it should include only ASCII chars (0x20-0x7F), there are some USB sticks (SanDisk Ultra Fit), that have NULLs inside the value. Treating NULLs as EOLs there made those LUN IDs non-unique.
* MFC r271718 (by bdrewery): Correct a commentmav2014-10-201-1/+1
|
* MFC r271588: Update CAM CCB accounting for the new status quo.mav2014-10-141-5/+8
| | | | | | | | | | devq_openings counter lost its meaning after allocation queues has gone. held counter is still meaningful, but problematic to update due to separate locking of CCB allocation and queuing. To fix that replace devq_openings counter with allocated counter. held is now calculated on request as difference between number of allocated, queued and active CCBs.
* Use proper variable when looping through periphs with CAM_PERIPH_FREE.mav2014-10-121-2/+2
| | | | | | PR: 194256 Submitted by: Scott M. Ferris <smferris@gmail.com> Sponsored by: EMC/Isilon Storage Division
* MFC r264406:mav2014-05-081-1/+1
| | | | Report more readable state "-" for idle CAM scan thread.
* MFC r260509:mav2014-05-081-2/+4
| | | | | | | | Replace several instances of -1 with appropriate CAM_*_WILDCARD and types. It was equal before r259397, but for good or bad, not any more for LUNs. This change fixes at least CAM debugging.
* MFC r260996:mav2014-02-041-1/+3
| | | | | Fix memory and references leak due to unfreed path in case we can't allocate bus scan CCB.
* MFC r260549:mav2014-01-251-6/+2
| | | | | | | | | Move xpt_run_devq() call before request completion callback where it was originally. I am not sure why exactly have I moved it during one of many refactorings during camlock project, but obviously it opens race window that may cause use after free panics during SIM (in reported cases umass(4)) detach.
* MFC r260541, r260547:mav2014-01-141-3/+1
| | | | | | | Take additional reference on SCSI probe periph to cover its freeze count. Otherwise periph may be invalidated and freed before single-stepping freeze is dropped, causing use after free panic.
* MFC Alexander Motin's direct dispatch, multi-queue, and finer-grainedscottl2014-01-071-763/+979
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | locking support for CAM r256826: Fix several target mode SIMs to not blindly clear ccb_h.flags field of ATIO CCBs. Not all CCB flags there belong to them. r256836: Remove hard limit on number of BIOs handled with one ATA TRIM request. r256843: Merge CAM locking changes from the projects/camlock branch to radically reduce lock congestion and improve SMP scalability of the SCSI/ATA stack, preparing the ground for the coming next GEOM direct dispatch support. r256888: Unconditionally acquire periph reference on CCB allocation failure. r256895: Fix memory and references leak due to unfreed path. r256960: Move CAM_UNQUEUED_INDEX setting to the last moment and under the periph lock. This fixes race condition with cam_periph_ccbwait(), causing use-after-free. r256975: Minor (mostly cosmetical) addition to r256960. r257054: Some microoptimizations for da and ada drivers: - Replace ordered_tag_count counter with single flag; - From da remove outstanding_cmds counter, duplicating pending_ccbs list; - From da_softc remove unused links field. r257482: Fix lock recursion, triggered by `smartctl -a /dev/adaX`. r257501: Make getenv_*() functions and respectively TUNABLE_*_FETCH() macros not allocate memory and so not require sleepable environment. getenv() has already used on-stack temporary storage, so just use it more rationally. getenv_string() receives buffer as argument, so don't need another one. r257914: Some CAM locks polishing: - Fix LOR and possible lock recursion when handling high-power commands. Introduce new lock to protect left power quota and list of frozen devices. - Correct locking around xpt periph creation. - Remove seems never used XPT_FLAG_OPEN xpt periph flag. Again, Netflix assisted with testing the merge, but all of the credit goes to Alexander and iX Systems. Submitted by: mav Sponsored by: iX Systems
* MFC r257345,257382,257388:nwhitehorn2013-12-101-8/+9
| | | | | | | | | | | | | | | | | | | | | | | | | Implement extended LUN support. If PIM_EXTLUNS is set by a SIM, encode the upper 32-bits of the LUN, if possible, into the target_lun field as passed directly from the REPORT LUNs response. This allows extended LUN support to work for all LUNs with zeros in the lower 32-bits, which covers most addressing modes without breaking KBI. Behavior for drivers not setting PIM_EXTLUNS is unchanged. No user-facing interfaces are modified. Extended LUNs are stored with swizzled 16-bit word order so that, for devices implementing LUN addressing (like SCSI-2), the numerical representation of the LUN is identical with and without PIM_EXTLUNS. Thus setting PIM_EXTLUNS keeps most behavior, and user-facing LUN IDs, unchanged. This follows the strategy used in Solaris. A macro (CAM_EXTLUN_BYTE_SWIZZLE) is provided to transform a lun_id_t into a uint64_t ordered for the wire. This is the second part of work for full 64-bit extended LUN support and is designed to a bridge for stable/10 to the final 64-bit LUN code. The third and final part will involve widening lun_id_t to 64 bits and will not be MFCed. This third part will break the KBI but will keep the KPI unchanged so that all drivers that will care about this can be updated now and not require code changes between HEAD and stable/10. Reviewed by: scottl
* MFC r256552:mav2013-10-241-0/+32
| | | | | | | Unify periph invalidation and destruction reporting. Print message containing device model and serial number on invalidation. Approved by: re (hrs)
* MFC r256533:mav2013-10-241-1/+1
| | | | | | | | Unhide "Serial Number" lines from bootverbose. That information may be useful for system administration to have in hard copy (in logs) if one of several devices suddenly dies. Approved by: re (hrs)
* Close the race on path ID allocation in xpt_bus_register() if two buses aremav2013-10-091-9/+6
| | | | | | | | | | | registered simultaneously. Due to topology unlock between the ID allocation and the bus registration there is a chance that two buses may get the same IDs. That is supposed reason of lock assertion panic in CAM during initial bus scanning after new iscsid initiates two sessions same time. Reported by: trasz Approved by: re (glebus, marius) MFC after: 2 weeks
* Make sure the CCB xflags field is initialized to zero so thatnwhitehorn2013-09-271-0/+2
| | | | | | | | | CAM_EXTLUN_VALID is not erroneously set. Also add an XPORT_SRP identifier to the known SCSI transports for the SCSI RDMA protocol, as used, for example with Infiniband storage. Reviewed by: scottl Approved by: re (marius)
* Re-do r255853. Along with adding back the API/ABI changes from thescottl2013-09-251-5/+1
| | | | | | | | original, this hides the contents of cam_compat.h from ktrace/kdump/truss, avoiding problems there. There are no user-servicable parts in there, so no need for those tools to be groping around in there. Approved by: re
* Revert r255853 pending fixes to build errors in usr.bin/kdumpgjb2013-09-251-1/+5
| | | | Approved by: re (implicit)
* Update the CAM API for FreeBSD 10:scottl2013-09-241-5/+1
| | | | | | | | | | | | | | | | | | | | | | - Remove the timeout_ch field. It's been deprecated since FreeBSD 7.0; MPSAFE drivers should be managing their own timeout storage. The remaining non-MPSAFE drivers have been modified to also manage their own storage, and should be considered for updating to MPSAFE (or removal) during the FreeBSD 10.x lifecycle. - Add fields related to soft timeouts and quality of service, to be used in upcoming work. - Add room for more flags in the CCB header and path_inq structures. - Begin support for extended 64-bit LUNs. - Bump the CAM version number to 0x18, but add compat shims. Tested with camcontrol and smartctl. Reviewed by: nathanw, ken, kib Approved by: re Obtained from: Netflix
* Add debug trace points for freeze/release device queue.mav2013-09-011-0/+57
|
* Add new attribute lunname to report only textual LUN-specific device IDs.mav2013-08-241-5/+9
| | | | | While lunid attribute prefers to report numeric ones, having both may be useful in some situations.
* Remove droping topology mutex after iterating 100 periphs in CAMGETPASSTHRU.mav2013-08-071-37/+2
| | | | | That is not so slow and so often operation to handle unneeded otherwise xsoftc.xpt_generation and respective locking complications.
* MFprojects/camlock r249006:mav2013-08-051-16/+13
| | | | | Pass SIM pointer as an argument to camisr_runqueue() instead of doneq pointer.
* MFprojects/camlock r249505:mav2013-08-051-17/+9
| | | | | | | | | | | | | | | Change CCB queue resize logic to be able safely handle overallocations: - (re)allocate queue space in power of 2 chunks with 64 elements minimum and never shrink it; with only 4/8 bytes per element size is insignificant. - automatically reallocate the queue to double size if it is overflowed. - if queue reallocation failed, store extra CCBs in unsorted TAILQ, fetching them back as soon as some queue element is freed. To free space in CCB for TAILQ linking, change highpowerq from keeping high-power CCBs to keeping devices frozen due to high-power CCBs. This encloses all pieces of queue resize logic inside of cam_queue.[ch], removing some not obvious duties from xpt_release_ccb().
* CAM and mps(4) driver scanning changes.ken2013-07-221-9/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a PIM_NOSCAN flag to the CAM path inquiry CCB. This tells CAM not to perform a rescan on a bus when it is registered. We now use this flag in the mps(4) driver. Since it knows what devices it has attached, it is more efficient for it to just issue a target rescan on the targets that are attached. Also, remove the private rescan thread from the mps(4) driver in favor of the rescan thread already built into CAM. Without this change, but with the change above, the MPS scanner could run before or during CAM's initial setup, which would cause duplicate device reprobes and announcements. sys/param.h: Bump __FreeBSD_version to 1000039 for the inclusion of the PIM_RESCAN CAM path inquiry flag. sys/cam/cam_ccb.h: sys/cam/cam_xpt.c: Added a PIM_NOSCAN flag. If a SIM sets this in the path inquiry ccb, then CAM won't rescan the bus in xpt_bus_regsister. sys/dev/mps/mps_sas.c For versions of FreeBSD that have the PIM_NOSCAN path inquiry flag, don't freeze the sim queue during scanning, because CAM won't be scanning this bus. Instead, hold up the boot. Don't call mpssas_rescan_target in mpssas_startup_decrement; it's redundant and I don't know why it was in there. Set PIM_NOSCAN in path inquiry CCBs. Remove methods related to the internal rescan daemon. Always use async events to trigger a probe for EEDP support. In older versions of FreeBSD where AC_ADVINFO_CHANGED is not available, use AC_FOUND_DEVICE and issue the necessary READ CAPACITY manually. Provide a path to xpt_register_async() so that we only receive events for our own SCSI domain. Improve error reporting in cases where setup for EEDP detection fails. sys/dev/mps/mps_sas.h: Remove softc flags and data related to the scanner thread. sys/dev/mps/mps_sas_lsi.c: Unconditionally rescan the target whenever a device is added. Sponsored by: Spectra Logic MFC after: 1 week
* Make some improvements to r253322 to really rescan target, not a bus.mav2013-07-151-4/+7
| | | | Add there and in two more places checks for NULL on xpt_alloc_ccb_nowait().
* Add infrastructure for doing compatibility shims, as has been sorelyscottl2013-06-171-0/+15
| | | | | | | | | | | | | | needed for the last 10 years. Far too much of the internal API is exposed, and every small adjustment causes applications to stop working. To kick this off, bump the API version to 0x17 as should have been done with r246713, but add shims to compensate. Thanks to the shims, there should be no visible change in application behavior. I have plans to do a significant overhaul of the API to harnen it for the future, but until then, I welcome others to add shims for older versions of the API. Obtained from: Netflix
* Make CAM return and GEOM DISK pass through new GEOM::lunid attribute.mav2013-06-121-5/+42
| | | | | | | | | | | | | | | | | | SPC-4 specification states that serial number may be property of device, but not a specific logical unit. People reported about FC storages using serial number in that way, making it unusable for purposes of LUN multipath detection. SPC-4 states that designators associated with logical unit from the VPD page 83h "Device Identification" should be used for that purpose. Report first of them in the new attribute in such preference order: NAA, EUI-64, T10 and SCSI name string. While there, make GEOM DISK properly report GEOM::ident in XML output also using d_getattr() method, if available. This fixes serial numbers reporting for SCSI disks in `geom disk list` output and confxml. Discussed with: gibbs, ken Sponsored by: iXsystems, Inc. MFC after: 2 weeks
* Added output of device QUIRKS for CAM and AHCI devices during boot.smh2013-05-181-0/+9
| | | | | | Reviewed by: mav Approved by: pjd (mentor) MFC after: 2 weeks
* Expose CAM_BOOT_DELAY as a kernel conf item now.sbruno2013-04-201-0/+7
| | | | | | | | | This allows users who boot without loader to adjust their environments around slightly buggy or slow hardware. PR: kern/161809 Submitted by: rozhuk.im@gmail.com MFC after: 2 weeks
* Remove owner field from struct cam_ed, unused at least since FreeBSD 7.mav2013-04-141-1/+0
|
* MFprojects/camlock r248982:mav2013-04-141-4/+4
| | | | | | | | Stop abusing xpt_periph in random plases that really have no periph related to CCB, for example, bus scanning. NULL value is fine in such cases and it is correctly logged in debug messages as "noperiph". If at some point we need some real XPT periphs (alike to pmpX now), quite likely they will be per-bus, and not a single global instance as xpt_periph now.
* MFprojects/camlock r248890, r248897, r248898, r248900, r248903, r248905,mav2013-04-141-197/+76
| | | | | | | | | | | | | | | | | | r248917, r248918, r248978, r249001, r249014, r249030: Remove multilevel freezing mechanism, implemented to handle specifics of the ATA/SATA error recovery, when post-reset recovery commands should be allocated when queues are already full of payload requests. Instead of removing frozen CCBs with specified range of priorities from the queue to provide free openings, use simple hack, allowing explicit CCBs over- allocation for requests with priority higher (numerically lower) then CAM_PRIORITY_OOB threshold. Simplify CCB allocation logic by removing SIM-level allocation queue. After that SIM-level queue manages only CCBs execution, while allocation logic is localized within each single device. Suggested by: gibbs
* MFprojects/camlock:mav2013-04-041-135/+141
| | | | | | | | | | | | | | | | r249017: Some cosmetic things: - Unify device to target insertion inside xpt_alloc_device() instead of duplicating it three times. - Remove extra checks for empty lists of devices and targets on release since zero refcount check also implies it. - Reformat code to reduce indentation. r249103: - Add lock assertions to every point where reference counters are modified. - When reference counters are reaching zero, add assertions that there are no children items left. - Add a bit more locking to the xptpdperiphtraverse().
* MFprojects/camlock r248928:mav2013-04-041-12/+22
| | | | | | | | Move CAM_DEBUG_CDB messages from the point of queuing to the point of sending to SIM. That allows to inspect real requests execution order, respecting priorities, freezing, etc. MFC after: 2 weeks
* Remove xpt_sim_opened(), the only consumer of which was atapicam, which ismav2013-04-041-33/+0
| | | | now gone.
* Use xpt_lock_buses() instead of equivalent mtx_lock(&xsoftc.xpt_topo_lock)mav2013-04-041-32/+32
| | | | to unify the code.
* Reform the busdma API so that new types may be added without modifyingkib2013-02-121-1/+2
| | | | | | | | | | | | | | | | | | | | | every architecture's busdma_machdep.c. It is done by unifying the bus_dmamap_load_buffer() routines so that they may be called from MI code. The MD busdma is then given a chance to do any final processing in the complete() callback. The cam changes unify the bus_dmamap_load* handling in cam drivers. The arm and mips implementations are updated to track virtual addresses for sync(). Previously this was done in a type specific way. Now it is done in a generic way by recording the list of virtuals in the map. Submitted by: jeff (sponsored by EMC/Isilon) Reviewed by: kan (previous version), scottl, mjacob (isp(4), no objections for target mode changes) Discussed with: ian (arm changes) Tested by: marius (sparc64), mips (jmallet), isci(4) on x86 (jharris), amd64 (Fabian Keil <freebsd-listen@fabiankeil.de>)
* Fix a panic during CAM EDT traversal.ken2012-12-071-14/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The problem was a race condition between the EDT traversal used by things like 'camcontrol devlist', and CAM peripheral driver removal. The EDT traversal code holds the CAM topology lock, and wants to show devices that have been invalidated. It acquires a reference to the peripheral to make sure the peripheral it is examining doesn't go away. However, because the peripheral removal code in camperiphfree() drops the CAM topology lock to call the peripheral's destructor routine, we can run into a situation where the EDT traversal increments the peripheral reference count after free process is already in progress. At that point, the reference count is ignored, because it was 0 when we started the process. Fix this race by setting a flag, CAM_PERIPH_FREE, that I previously added and checked in xptperiphtraverse() and xptpdperiphtravsere(), but failed to use. If the EDT traversal code sees that flag, it will know that the peripheral free process has already started, and that it should not access that peripheral. Also, fix an inconsistency in the locking between xptpdperiphtraverse() and xptperiphtraverse(). They now both hold the CAM topology lock while calling the peripheral traversal function. cam_xpt.c: Change xptperiphtraverse() to hold the CAM topology lock across calls to the traversal function. Take out the comment in xptpdperiphtraverse() that referenced the locking inconsistency. cam_periph.c: Set the CAM_PERIPH_FREE flag when we are in the process of freeing a peripheral driver. Sponsored by: Spectra Logic Corporation MFC after: 1 week
* Remove priority enforcement from xpt_ation(). It is not good and even notmav2012-10-271-3/+0
| | | | | | | | | | | | safe in some cases to reduce CCB priority after it was scheduled with high priority. This fixes reproducible deadlock when command sent through the pass interface while ATA XPT recovers from command timeout. Instead of that enforce priority at passioctl(). libcam provides no obvious interface to specify CCB priority and so much (all?) code specifies zero (highest) priority. This change limits pass CCBs priority to NORMAL run level, allowing XPT to complete bus and device recovery after reset before running any payload.
* Don't exclude XPT SIM from locking in xpt_create_path_unlocked().mav2012-10-131-9/+4
| | | | | We don't want xpt periph, device, target or bus disappeared because of incorrect reference counting.
* Use xpt_create_path_unlocked() for initial debug path compilation becausemav2012-10-131-6/+1
| | | | we are not holding respective SIM lock.
* Fix XPT_DEBUG paths operations locking:mav2012-10-131-8/+16
| | | | | | | - Extend the lock to cover xpt_path_release() for the new path. - While xpt_action() is called while holding right SIM lock for the new bus, the old path release may require different SIM lock. So we have to temporary drop the new lock and get the old one.
* XPT_DEV_MATCH is probably the only xpt_action() method that is calledmav2012-10-131-0/+8
| | | | | | | without holding SIM lock. It really doesn't need that lock, but adding it removes that specific exception, allowing to assert locking there later. Submitted by: ken@ (earlier version)
* Protect xpt_getattr() calls with the SIM lock and assert that.mav2012-10-121-0/+2
| | | | Submitted by: ken@ (earlier version)
* Use separate malloc buckets for CAM devices, CCBs and paths. This willmav2012-10-111-12/+15
| | | | | | make it easier to track down the source of any use after free problems. Submitted by: ken@
* Don't duplicate path/ccb allocation code, use existing functions.mav2012-10-111-7/+1
|
* Really handle xpt_compile_path() error in xpt_bus_register() instead ofmav2012-10-101-2/+5
| | | | | | print error message and probably crash just after it on NULL dereference. Found by: Clang Static Analyzer
OpenPOWER on IntegriCloud