aboutsummaryrefslogtreecommitdiff
path: root/sys/cam/cam_queue.c
Commit message (Collapse)AuthorAgeFilesLines
* Revert r327828, r327949, r327953, r328016-r328026, r328041:Pedro F. Giffuni2018-01-211-1/+1
| | | | | | | | | | | | | | | | | | Uses of mallocarray(9). The use of mallocarray(9) has rocketed the required swap to build FreeBSD. This is likely caused by the allocation size attributes which put extra pressure on the compiler. Given that most of these checks are superfluous we have to choose better where to use mallocarray(9). We still have more uses of mallocarray(9) but hopefully this is enough to bring swap usage to a reasonable level. Reported by: wosch PR: 225197 Notes: svn path=/head/; revision=328218
* cam: make some use of mallocarray(9).Pedro F. Giffuni2018-01-151-1/+1
| | | | | | | | | | | | | | | | Focus on code where we are doing multiplications within malloc(9). None of these ire likely to overflow, however the change is still useful as some static checkers can benefit from the allocation attributes we use for mallocarray. This initial sweep only covers malloc(9) calls with M_NOWAIT. No good reason but I started doing the changes before r327796 and at that time it was convenient to make sure the sorrounding code could handle NULL values. X-Differential revision: https://reviews.freebsd.org/D13837 Notes: svn path=/head/; revision=328022
* sys/cam: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-271-0/+2
| | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using misidentified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Notes: svn path=/head/; revision=326265
* CAM ccbq sanity: checks on insert and removeMark Johnston2016-10-051-2/+5
| | | | | | | | | | | | | | | | | | | | | | KASSERT in cam_ccbq_insert_ccb that only XPT_FC_QUEUED ops are queued, and XPT_FC_USER_CCB ops are not. Otherwise cam_ccbq_ccb_done may be skipped. Bounds check the index used for camq_remove in order to panic instead of scribble on removal of an out-of-bounds index (e.g. consider the effect of camq_remove of CAM_UNQUEUED_INDEX). KASSERT in cam_ccbq_remove_ccb that the ccb removed by index was the one sought. Submitted by: Ryan Libby <rlibby@gmail.com> Reviewed by: imp, mav MFC after: 2 weeks Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D8151 Notes: svn path=/head/; revision=306710
* sys/cam: spelling fixes.Pedro F. Giffuni2016-04-291-1/+1
| | | | | | | | | Affects a debug message. MFC after: 2 weeks Notes: svn path=/head/; revision=298809
* Update CAM CCB accounting for the new status quo.Alexander Motin2014-09-141-2/+0
| | | | | | | | | | | | | | | 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. MFC after: 1 month Notes: svn path=/head/; revision=271588
* Merge CAM locking changes from the projects/camlock branch to radicallyAlexander Motin2013-10-211-4/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | reduce lock congestion and improve SMP scalability of the SCSI/ATA stack, preparing the ground for the coming next GEOM direct dispatch support. Replace big per-SIM locks with bunch of smaller ones: - per-LUN locks to protect device and peripheral drivers state; - per-target locks to protect list of LUNs on target; - per-bus locks to protect reference counting; - per-send queue locks to protect queue of CCBs to be sent; - per-done queue locks to protect queue of completed CCBs; - remaining per-SIM locks now protect only HBA driver internals. While holding LUN lock it is allowed (while not recommended for performance reasons) to take SIM lock. The opposite acquisition order is forbidden. All the other locks are leaf locks, that can be taken anywhere, but should not be cascaded. Many functions, such as: xpt_action(), xpt_done(), xpt_async(), xpt_create_path(), etc. are no longer require (but allow) SIM lock to be held. To keep compatibility and solve cases where SIM lock can't be dropped, all xpt_async() calls in addition to xpt_done() calls are queued to completion threads for async processing in clean environment without SIM lock held. Instead of single CAM SWI thread, used for commands completion processing before, use multiple (depending on number of CPUs) threads. Load balanced between them using "hash" of the device B:T:L address. HBA drivers that can drop SIM lock during completion processing and have sufficient number of completion threads to efficiently scale to multiple CPUs can use new function xpt_done_direct() to avoid extra context switch. Make ahci(4) driver to use this mechanism depending on hardware setup. Sponsored by: iXsystems, Inc. MFC after: 2 months Notes: svn path=/head/; revision=256843
* MFprojects/camlock r249505:Alexander Motin2013-08-051-23/+8
| | | | | | | | | | | | | | | | | | 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(). Notes: svn path=/head/; revision=253958
* MFprojects/camlock r248890, r248897, r248898, r248900, r248903, r248905,Alexander Motin2013-04-141-17/+4
| | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=249466
* Increase device CCB queue array size by CAM_RL_VALUES - 1 (4) elements.Alexander Motin2012-10-111-2/+3
| | | | | | | | | | | | | It is required to store extra recovery requests in case of bus resets. On ATA/SATA this fixes assertion panics on HEAD with INVARIANTS enabled or possible memory corruptions otherwise if timeout/reset happens when device CCB queue is already full. Reported by: gibbs@ MFC after: 1 week Notes: svn path=/head/; revision=241444
* Change queue overflow checks from DIAGNOSTIC+panic() to KASSERT() to makeAlexander Motin2012-09-281-9/+7
| | | | | | | | them enabled on HEAD by default. It is probably better to do single compare then hunt for unexpected memory corruption. Notes: svn path=/head/; revision=241028
* Mark MALLOC_DEFINEs static that have no corresponding MALLOC_DECLAREs.Ed Schouten2011-11-071-3/+3
| | | | | | | This means that their use is restricted to a single C file. Notes: svn path=/head/; revision=227293
* MFp4:Alexander Motin2009-11-141-1/+0
| | | | | | | Some more missed parts from previous commits. Notes: svn path=/head/; revision=199281
* After thinking again, implement cam_ccbq_fini().Alexander Motin2009-10-221-1/+8
| | | | | | | This is effectively NULL change, but makes this API a bit more consistent. Notes: svn path=/head/; revision=198377
* - Providing fine-grained malloc statistic by replacing M_DEVBUF withTai-hwa Liang2005-07-011-13/+18
| | | | | | | | | | | | | | | | 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) Notes: svn path=/head/; revision=147723
* Start each of the license/copyright comments with /*-Warner Losh2005-01-051-1/+1
| | | | Notes: svn path=/head/; revision=139743
* Use __FBSDID().David E. O'Brien2003-06-101-2/+4
| | | | Notes: svn path=/head/; revision=116161
* Fix typos, mostly s/ an / a / where appropriate and a few s/an/and/Jens Schweikhardt2002-12-301-1/+1
| | | | | | | Add FreeBSD Id tag where missing. Notes: svn path=/head/; revision=108470
* $Id$ -> $FreeBSD$Peter Wemm1999-08-281-1/+1
| | | | Notes: svn path=/head/; revision=50477
* Fix a long standing bug in the camq teardown code.Justin T. Gibbs1999-08-161-3/+3
| | | | Notes: svn path=/head/; revision=49862
* cam_periph.c:Justin T. Gibbs1999-04-191-21/+36
| | | | | | | | | | | | | | | | | | | | Move handling of CAM_AUTOSENSE_FAIL into block dealing with all other scsi status errors. cam_queue.c: cam_queue.h: Fix 'off by one' heap bug in a more efficient manner. Since heap algorithms like to deal with indexes started from 1, offset our heap array pointer at allocation time to make this so for a C environment. This makes the implementation of the algorithm a bit more efficient. cam_xpt.c: Use macros for accessing the head of the heap so that code is isolated from implementation details of the heap. Notes: svn path=/head/; revision=45844
* Remove camq_regen(). We already perform modular comparisonsJustin T. Gibbs1999-04-071-44/+6
| | | | | | | | | | for generation counts, so no further steps to deal with generation count wrap are required. Fix an off by one problem in the camq heap code. Notes: svn path=/head/; revision=45441
* CAM Transport Layer (XPT).Justin T. Gibbs1998-09-151-0/+441
Submitted by: The CAM Team Notes: svn path=/head/; revision=39212