aboutsummaryrefslogtreecommitdiff
path: root/sys/cam
Commit message (Collapse)AuthorAgeFilesLines
* Add NO_SYNC_CACHE quirk for PENTAX camerasWarner Losh2019-01-081-0/+8
| | | | | | | | PR: 93389 Submitted by: Demin Alexander Notes: svn path=/head/; revision=342866
* Add NO_RC16 quirk for Chipfancier 16GB USB stick...Warner Losh2018-12-311-0/+8
| | | | | | | | Submitted by: osef.lar@gmail.com PR: 234503 Notes: svn path=/head/; revision=342657
* add a knob that disables detection of write protected disksAndriy Gapon2018-12-171-1/+15
| | | | | | | | | | | | | | | | | | It has been reported that on some systems (with real hardware passed through to a virtual machine) the WP detection causes USB disk probing failures. While here, also fix the selection of the next state in the case of malloc failure in DA_STATE_PROBE_WP. It was DA_STATE_PROBE_RC unconditionally even when it should have been DA_STATE_PROBE_RC16. PR: 225794 Reported by: David Boyd <David.Boyd49@twc.com> MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D18496 Notes: svn path=/head/; revision=342169
* nda(4) fix check for Dataset Management supportChuck Tuffli2018-12-131-1/+1
| | | | | | | | | | | | | | | | | | | In the nda(4) driver, only set DISKFLAG_CANDELETE (a.k.a. can support BIO_DELETE) if the drive supports Dataset Management. There are reports that without this check, VMWare Workstation does not work reliably. Fix is to check the ONCS field in the NVMe Controller Data structure for support. This check previously existed but did not survive the big-endian changes. Reported by: yuripv@yuripv.net Reviewed by: imp, mav, jimharris Approved by: imp (mentor) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D18493 Notes: svn path=/head/; revision=342046
* Send a START UNIT command when a disk responds with an ASC of 04/1C.Warner Losh2018-12-091-1/+1
| | | | | | | | | | This will hopefully spin up a disk that's in low-power mode. Sponsored by: Netflix Submitted by: scottl@ Notes: svn path=/head/; revision=341769
* Don't allocate the config_intrhook separately from the softc, it's smallScott Long2018-12-091-15/+4
| | | | | | | enough that it costs more code to handle the malloc/free than it saves. Notes: svn path=/head/; revision=341756
* daprobedone: announce if a disk is write-protectedAndriy Gapon2018-12-071-0/+5
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=341681
* NVME trim clockingWarner Losh2018-11-272-7/+85
| | | | | | | | | | | | | | | | | | | | | | | | Add the ability to set two goals for trims in the I/O scheduler. The first goal is the number of BIO_DELETEs to accumulate (kern.cam.XX.U.trim_goal). When non-zero, this many trims will be accumulated before we start to transfer them to lower layers. This is useful for devices that like to get lots of trims all at once in one transaction (not all devices are like this, and some vary by workload). The second is a number of ticks to defer trims. If you've set a trim goal, then kern.cam.XX.U.trim_ticks controls how long the system will defer those trims before timing out and sending them anyway. It has no effect when trim_goal is 0. In any event, a BIO_FLUSH will cause all the TRIMs to be released to the periph drivers. This may be a minor overloading of what BIO_FLUSH is supposed to mean, but it's useful to preserve other ordering semantics that users of BIO_FLUSH reply on. Sponsored by: Netflix, Inc Notes: svn path=/head/; revision=341005
* Minor tweaks to the formattingWarner Losh2018-11-261-7/+11
| | | | | | | | | | Tweak the format of the trim + read bias code. Add similar debug to the read + writes case. Spondored by: Netflix Notes: svn path=/head/; revision=341003
* Add cam_iosched_set_latfcn to set a latency callback for high latency.Warner Losh2018-11-152-3/+35
| | | | | | | | | | | | | | | It's often useful to have a callback when an I/O takes more than a threshold amount of time. This adds the infrastructure for periph devices to register one. One use-case is as a debugging aide when you need a semi-realtime indication of an I/O outlier so you can trigger bus capture gear for vendor analysis. Sponsored by: Netflix, Inc Notes: svn path=/head/; revision=340453
* Introduce scsi_ata_setfeatures() as a convenient way to makeWarner Losh2018-11-152-0/+38
| | | | | | | | | a passthru ATA SETFEATURES command. Sponsored by: Netflix, Inc Notes: svn path=/head/; revision=340452
* Remove trailing white space in advance of other changes.Warner Losh2018-11-142-52/+48
| | | | Notes: svn path=/head/; revision=340448
* Only assert locked for many async events.Warner Losh2018-11-051-14/+17
| | | | | | | | | | | | | | | | | | | | | | | | Many async events that we see are called for this specific path. When calling an async callback for a targetted device, XTP will lock that specific device's path lock (same as what cam_periph_lock does). For those AC_ events, assert we have the lock rather than trying to recusrively take it (which causes panics since it's not recursive). Add annotations about this and about the fact that AC_SCSI_AEN events are generated now only in the ata stack (which cannot have a scsi_da attachment). Leave it in place in case I've overlooked something as the code is harmless. This is fallout from my attempts to "fix" locking for softc->flags in r330796 that's not been triggered often enough to get my attention until now. Sponsored by: Netflix MFC After: 3 days Differential Revision: https://reviews.freebsd.org/D17837 Notes: svn path=/head/; revision=340155
* Add comments explaining what hold/unhold doWarner Losh2018-11-012-3/+10
| | | | | | | | They act as a simple one-deep semaphore to keep open/close/probe from running at the same time to avoid races that creates. Notes: svn path=/head/; revision=340024
* Add statistics for TRIM comandsWarner Losh2018-10-263-6/+60
| | | | | | | | | | Add a counter for the LBAs, Ranges and hardware commands so that we can provide additional color to the statistics we provide to vendors. Sponsored by: Netflix, Inc Notes: svn path=/head/; revision=339777
* Retire scsi_lowWarner Losh2018-10-223-5168/+0
| | | | | | | | | | scsi_low was a common set of routines to do the SCSI bus sequencing for the ncv, nsp and stg drivers. Those have been removed, so it's no longer needed since nothing else in the tree uses it and nothing likely ever will (it's for super-low-end 8-bit parallel SCSI cards). Notes: svn path=/head/; revision=339573
* Move 32-bit compat support for CDIOREADTOCENTRYS to the right place.Brooks Davis2018-10-021-1/+41
| | | | | | | | | | | | | | | | | | ioctl(2) commands only have meaning in the context of a file descriptor so translating them in the syscall layer is incorrect. The new handler users an accessor to retrieve/construct a pointer from the last member of the passed structure and relies on type punning to access the other members which require no translation. Reviewed by: kib (prior version), jhb Approved by: re (rgrimes) Obtained from: CheriBSD Sponsored by: DARPA, AFRL Differential Review: https://reviews.freebsd.org/D17378 Notes: svn path=/head/; revision=339101
* Fix a da(4) driver memory leak for SCSI SMR devices.Kenneth D. Merry2018-10-011-0/+3
| | | | | | | | | | | | | | | In the probe case for SCSI SMR Host Aware or Most Managed drives, be sure to free allocated memory. sys/cam/scsi/scsi_da.c: In dadone_probezone(), free the data pointer before returning. MFC after: 3 days Sponsored by: Spectra Logic Approved by: re (kib) Notes: svn path=/head/; revision=339076
* Make the wait in cfiscsi_offline() interruptible. This is the second halfEdward Tomasz Napierala2018-09-111-3/+9
| | | | | | | | | | | | | | of the fix/workaround for the "ctld hanging on reload" problem. PR: 220175 Reported by: Eugene M. Zheganin <emz at norma.perm.ru> Tested by: Eugene M. Zheganin <emz at norma.perm.ru> Approved by: re (kib) MFC after: 2 weeks Sponsored by: playkey.net Notes: svn path=/head/; revision=338586
* Add missing copyin() to access LUN and port ioctl arguments.Alexander Motin2018-09-061-2/+20
| | | | | | | | | | | Somehow this was working even after PTI in, at least on amd64, and got broken by something only very recently. Reviewed by: araujo Approved by: re (gjb) Notes: svn path=/head/; revision=338494
* Try harder in cfiscsi_offline(). This is believed to be the workaroundEdward Tomasz Napierala2018-09-011-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | for the "ctld hanging on reload" problem observed in same cases under high load. I'm not 100% sure it's _the_ fix, as the issue is rather hard to reproduce, but it was tested as part of a larger path and the problem disappeared. It certainly shouldn't break anything. Now, technically, it shouldn't be needed. Quoting mav@, "After ct->ct_online == 0 there should be no new sessions attached to the target. And if you see some problems abbout it, it may either mean that there are some races where single cfiscsi_session_terminate(cs) call may be lost, or as a guess while this thread was sleeping target was reenabbled and redisabled again". Should such race be discovered and properly fixed in the future, than this and the followup two commits can be backed out. PR: 220175 Reported by: Eugene M. Zheganin <emz at norma.perm.ru> Tested by: Eugene M. Zheganin <emz at norma.perm.ru> Discussed with: mav Approved by: re (gjb) MFC after: 2 weeks Sponsored by: playkey.net Notes: svn path=/head/; revision=338426
* Make NVMe compatible with the original APIChuck Tuffli2018-08-221-9/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | The original NVMe API used bit-fields to represent fields in data structures defined by the specification (e.g. the op-code in the command data structure). The implementation targeted x86_64 processors and defined the bit fields for little endian dwords (i.e. 32 bits). This approach does not work as-is for big endian architectures and was changed to use a combination of bit shifts and masks to support PowerPC. Unfortunately, this changed the NVMe API and forces #ifdef's based on the OS revision level in user space code. This change reverts to something that looks like the original API, but it uses bytes instead of bit-fields inside the packed command structure. As a bonus, this works as-is for both big and little endian CPU architectures. Bump __FreeBSD_version to 1200081 due to API change Reviewed by: imp, kbowling, smh, mav Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D16404 Notes: svn path=/head/; revision=338182
* Remove unneccessary code, which also introduced a (very minor)Edward Tomasz Napierala2018-08-211-6/+0
| | | | | | | | | | | | race condition, due to a missing call to cfiscsi_target_release(). Discussed with: mav@ Tested by: Eugene M. Zheganin <emz at norma.perm.ru> (earlier version) MFC after: 2 weeks Sponsored by: playkey.net Notes: svn path=/head/; revision=338139
* Flesh out a comment about what we're doing with read bias and trims.Warner Losh2018-08-151-1/+3
| | | | | | | Sponsored by: Netflix Notes: svn path=/head/; revision=337824
* Create xpt_sim_poll and refactor a bit using it.Warner Losh2018-08-132-19/+22
| | | | | | | | | | | | | | | | | | xpt_sim_poll takes the sim to poll as an argument. It will do the proper locking protocol, call the SIM polling routine, and then call camisr_runqueue to process completions on any CCBs the SIM's poll routine completed. It will be used during late shutdown when a SIM is waiting for CCBs it sent during shutdown to finish and the scheduler isn't running because we've panic'd. This sequence was used twice in cam_xpt, so refactor those to use this new function. Sponsored by: Netflix Differential Review: https://reviews.freebsd.org/D16663 Notes: svn path=/head/; revision=337723
* Walk back r337554 while discussion continuesConrad Meyer2018-08-104-9/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | The idea was to get the uncontroversial mechanical change out of the way, then get the meatier functional changes reviewed subsequently. I had not realized that the immediately adjacent issue was addressed in a different direction in r334506 (see Warner's guidance in D15592). Discussion continues, trying to determine if there is a secondary issue still[1] and how best to fix it. With 12-related activities coming up, while that is ongoing, just take this back for now. [1]: Shutdown-time eventhandler events fire normally during panic's reboot path. Driver callbacks that attempt to issue and wait on interrupt- completed IO may never complete, hanging the system. This is particularly obnoxious in the shutdown/panic path, as the debugger cannot be entered anymore and the hang prevents reboot restoring availability. (There's nothing CAM-specific about this problem -- any shutdown event-triggered driver could do something like this during panic. But most NICs, etc. don't try to send spin-down commands at shutdown. ;-)) Discussed with: imp, markj Notes: svn path=/head/; revision=337583
* cam(4): Add an xpt-neutral flag indicating a valid panic CCBConrad Meyer2018-08-094-1/+9
| | | | | | | | | | | | | | | No functional change. Note that this change is careful to set the CCB header xflags after foo_fill_bar() routines, which generally zero existing flags. An earlier version of this patch mistakenly set the flag before the fill routines. Submitted by: Scott Ferris <sferris AT isilon.com>, jhibbits@ Reviewed by: bdrewery@, markj@, and non-committer FreeBSD contributor Anton Rang Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=337554
* cam_ccb.h: Remove redundant declarations of static inline functionsConrad Meyer2018-08-091-42/+0
| | | | | | | | | | | No functional change. They're unnecessarily confusing for tools like grep or ctags. Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=337551
* For the dynamic I/O scheduler, make the TRIM stuff also count againstWarner Losh2018-07-261-1/+17
| | | | | | | | | | | | | | read bias so we do reads in preference to TRIMs. This helps a lot when many trims are delivered at once from the upper layers as they tend to delay READs due to priority inversion in the code today. The non iosched case will be fixed when the trim comibing changes needed for nvme come in later this year. Sponsored by: Netflix Notes: svn path=/head/; revision=336752
* Stop further SCSI recovery attempts after one has failed.Alexander Motin2018-07-211-5/+13
| | | | | | | | | | | | | | | | | | | | | | We've got a set of probably damaged hard disks, reporting 0x04,0x02 ("Logical unit not ready, initializing command required") in response to READ CAPACITY(16), where attempts to use START STOP UNIT for recovery results in 0x44,0x00 ("Internal target failure") after ~1 second delay. As result of all recovery retries, device open attempt took ~3 seconds before finally reporting to GEOM that device is opened, but has no media. If the open was for writing and since it hasn't formally failed, following close triggered GEOM retaste, opening device few more times with respective delays. This change reduces whole time of this cycle from ~12 seconds to ~3 by giving up on recovery after the first failure. Reviewed by: ken MFC after: 2 weeks Sponsored by: iXsystems, Inc. Notes: svn path=/head/; revision=336590
* remove unneeded inclusion of sys/interrupt.h from several filesAndriy Gapon2018-07-044-4/+0
| | | | | | | | | | | It's likely that the header was needed in the past for swi(9). But now that code does not use swi(9) or any other interfaces defined in sys/interrupt.h. MFC after: 1 week Notes: svn path=/head/; revision=335934
* Fix setting RCA for MMC cardsIlya Bakulin2018-06-192-3/+34
| | | | | | | | | | | | | | Unlike SD cards, that publish RCA in response to CMD3, MMC cards expect the host to set RCA itself. Since we don't support multiple MMC cards on the bus, just assign a static RCA of 2 to the attached MMC card. Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D13063 Notes: svn path=/head/; revision=335384
* Don't try to turn power down MMC bus if it is already downIlya Bakulin2018-06-191-6/+8
| | | | | | | | | | | Regulator framework doens't like turning off already turned off regulators, so we get panic on AllWinner boards. Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D15890 Notes: svn path=/head/; revision=335367
* Correctly define rawscr so initializing it doesn't result in overwriting memory.Ilya Bakulin2018-06-191-3/+4
| | | | | | | | | | We need 8 bytes of storage for rawscr. Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D15889 Notes: svn path=/head/; revision=335366
* Set MMC_DATA_MULTI flag when doing multi-block transfersIlya Bakulin2018-06-191-0/+1
| | | | | | | | | | | | | | | Lower layers (MMC / SDHCI controller drivers) may make certain decisions based on the presence of this flag. The fact that sdhci.c doesn't look at this flag is another problem that should be fixed separately. Found when adding MMCCAM support to AllWinner MMC controller driver where the presence of this flag actually matters. Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D15888 Notes: svn path=/head/; revision=335365
* Fix da(4) locking when probing SMR drives.Kenneth D. Merry2018-06-141-8/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Probing host aware and host managed SMR drives got broken in revision 330796. The added cam_periph_lock() calls were in areas in dadone() where the peripheral lock was already held. Since then, dadone() has been split into separate functions that are dedicated to each probe state. The result is that when probing a host aware drive, I ran into a recursive lock acquisition in dadone_probeatalogdir(). I would have run into the same problem in dadone_probeataiddir(), and in dadone_probeatasup() and dadone_probeatazone() in the error paths had the probe continued. The solution is to take out all of the extra cam_periph_lock() calls. I also added cam_periph_assert(periph, MA_OWNED) near the top of each of the dadone_* calls. These make it clear to anyone coming along in the the future that the lock is held in the probe done functions. Also add a locking assert in daprobedone(), to make it clear that it must be called with the periph lock held. Sponsored by: Spectra Logic Differential Revision: https://reviews.freebsd.org/D15764 Notes: svn path=/head/; revision=335154
* Enable high-speed on the card before increasing frequency on the controllerIlya Bakulin2018-06-051-8/+62
| | | | | | | | | | | | | Increasing operating frequency without telling card to switch to high-speed mode first upsets some cards and generates CRC errors. While here, deselect / reselect cards after CMD6 and SCR fetch, as in original code. Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D15568 Notes: svn path=/head/; revision=334651
* cam nvme: fix array overrunEric van Gyzen2018-05-281-1/+1
| | | | | | | | | | | | Fix a classic array overrun where the index could be one past the end. Reported by: Coverity CID: 1356596 MFC after: 3 days Sponsored by: Dell EMC Notes: svn path=/head/; revision=334273
* Refactor NVMe CAM integration.Alexander Motin2018-05-253-44/+155
| | | | | | | | | | | | | | | | | | | | | | | | - Remove layering violation, when NVMe SIM code accessed CAM internal device structures to set pointers on controller and namespace data. Instead make NVMe XPT probe fetch the data directly from hardware. - Cleanup NVMe SIM code, fixing support for multiple namespaces per controller (reporting them as LUNs) and adding controller detach support and run-time namespace change notifications. - Add initial support for namespace change async events. So far only in CAM mode, but it allows run-time namespace arrival and departure. - Add missing nvme_notify_fail_consumers() call on controller detach. Together with previous changes this allows NVMe device detach/unplug. Non-CAM mode still requires a lot of love to stay on par, but at least CAM mode code should not stay in the way so much, becoming much more self-sufficient. Reviewed by: imp MFC after: 1 month Sponsored by: iXsystems, Inc. Notes: svn path=/head/; revision=334200
* We can't release the refcount outside of the periph lock.Warner Losh2018-05-241-6/+5
| | | | | | | | | | | | We're dropping the periph lock then dropping the refcount. However, that violates the locking protocol and is racy. This seems to be the cause of weird occasional panics with a bogus assert. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D15517 Notes: svn path=/head/; revision=334166
* Implement initial MMC partitions support for MMCCAM.Ilya Bakulin2018-05-221-209/+620
| | | | | | | | | | | | | | For MMC cards, add partitions found on the card as separate disk(9) devices. Don't do anything with RPMB partition for now. Lots of code is copied almost 1:1 from the mmcsd.c in the old stack, credits Marius Strobl (marius@FreeBSD.org) Reviewed by: marius Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D12762 Notes: svn path=/head/; revision=334065
* Fix MMCCAM scanning for new cards.Ilya Bakulin2018-05-221-1/+1
| | | | | | | | | | r326645 used an incorrect argument for xpt_path_inq(). Reviewed by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D15521 Notes: svn path=/head/; revision=334059
* Hold the reference count until the CCB is releasedWarner Losh2018-05-153-4/+14
| | | | | | | | | | | | | | | When a disk disappears and the periph is invalidated, any I/Os that are pending with the controller can cause a crash when they complete. Move to holding the softc reference count taken in dastart() until the I/O is complete rather than only until xpt_action() returns. (This approach was suggested by Ken Merry.) This extends the method used in da to ada, nda, and mda. Sponsored by: Netflix Submitted by: Chuck Silvers Notes: svn path=/head/; revision=333651
* Hold the reference count until the CCB is releasedWarner Losh2018-05-151-5/+6
| | | | | | | | | | | | | | | When a disk disappears and the periph is invalidated, any I/Os that are pending with the controller can cause a crash when they complete. Move to holding the softc reference count taken in dastart() until the I/O is complete rather than only until xpt_action() returns. (This approach was suggested by Ken Merry.) Sponsored by: Netflix Submitted by: Chuck Silvers Differential Revision: https://reviews.freebsd.org/D15435 Notes: svn path=/head/; revision=333648
* Fix build for platforms using GCC:Li-Wen Hsu2018-05-101-33/+4
| | | | | | | | | | | | - Remove unused or dead store variable - Remove unused function ctl_copyin_alloc - Add missing curly brackets, this seems a regression in r287720 Reviewed by: jhibbits Differential Revision: https://reviews.freebsd.org/D15383 Notes: svn path=/head/; revision=333465
* Rework CTL frontend & backend options to use nv(3), allow creating multipleMarcelo Araujo2018-05-1012-405/+510
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ioctl frontend ports. This revision introduces two changes to CTL: - Changes the way options are passed to CTL_LUN_REQ and CTL_PORT_REQ ioctls. Removes ctl_be_arg structure and associated logic and replaces it with nv(3)-based logic for passing in and out arguments. - Allows creating multiple ioctl frontend ports using either ctladm(8) or ctld(8). New frontend ports are represented by /dev/cam/ctl<pp>.<vp> nodes, eg /dev/cam/ctl5.3. Those device nodes respond only to CTL_IO ioctl. New command-line options for ctladm: # creates new ioctl frontend port with using free pp and vp=0 ctladm port -c # creates new ioctl frontend port with pp=10 and vp=0 ctladm port -c -O pp=10 # creates new ioctl frontend port with pp=11 and vp=12 ctladm port -c -O pp=11 -O vp=12 # removes port with number 4 (it's a "targ_port" number, not pp number) ctladm port -r -p 4 New syntax for ctl.conf: target ... { port ioctl/<pp> ... } target ... { port ioctl/<pp>/<vp> ... Note: Most of this work was made by jceel@, thank you. Submitted by: jceel Reworked by: myself Reviewed by: mav (earlier versions and recently during the rework) Obtained from: FreeNAS and TrueOS Relnotes: Yes Sponsored by: iXsystems Inc. Differential Revision: https://reviews.freebsd.org/D9299 Notes: svn path=/head/; revision=333446
* Remove the 'All Rights Reserved' clause from some of the stuff I'veWarner Losh2018-05-096-6/+0
| | | | | | | done for Netflix, since I'm in the neighborhood. Notes: svn path=/head/; revision=333434
* Refactor dadone(). There was no useful code sharing in it; it was justScott Long2018-05-011-1144/+1240
| | | | | | | | | | a 1500 line switch statement. Callers now specify a discrete completion handler, though they're still welcome to track state via ccb_state. Sponsored by: Netflix Notes: svn path=/head/; revision=333154
* cam_periph_runccb() changed several years ago to overwrite the ccb callbackScott Long2018-05-016-57/+53
| | | | | | | | | | | pointer. It's now unhelpful and misleading for callers to continue to set it, so bring all callers into conformance. There's no real functional change, but it makes reading the code a lot less confusing. Sponsored by: Netflix Notes: svn path=/head/; revision=333152
* Add and fix comments for cam_periph_runccb()Scott Long2018-05-011-3/+7
| | | | | | | Sponsored by: Netflix Notes: svn path=/head/; revision=333147