aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/ata/ata-all.c
Commit message (Collapse)AuthorAgeFilesLines
* machine/stdarg.h -> sys/stdarg.hBrooks Davis2025-06-111-1/+1
| | | | | | | | | | | | | Switch to using sys/stdarg.h for va_list type and va_* builtins. Make an attempt to insert the include in a sensible place. Where style(9) was followed this is easy, where it was ignored, aim for the first block of sys/*.h headers and don't get too fussy or try to fix other style bugs. Reviewed by: imp Exp-run by: antoine (PR 286274) Pull Request: https://github.com/freebsd/freebsd-src/pull/1595
* sys: Automated cleanup of cdefs and other formattingWarner Losh2023-11-271-1/+0
| | | | | | | | | | | | | | | | Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row. Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/ Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/ Remove /\n+#if.*\n#endif.*\n+/ Remove /^#if.*\n#endif.*\n/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/ Sponsored by: Netflix
* ata: Retire unused variable / externsWarner Losh2023-11-241-2/+1
| | | | | | | When looking for something else, I noticed these are no longer used anywhere. Sponsored by: Netflix
* sys: Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-161-2/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-05-121-1/+1
| | | | | | | | | The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause. Discussed with: pfg MFC After: 3 days Sponsored by: Netflix
* ata: Remove ata_devclass from DRIVER_MODULE invocations.John Baldwin2022-05-061-1/+2
| | | | | | | Keep the global variable for its uses in ata-pci.c and chipsets/ata-fsl.c but initialize it in the existing ata_module_event_handler. Move the module event handler a bit earlier to ensure the variable is set before any devices are attached.
* Make MAXPHYS tunable. Bump MAXPHYS to 1M.Konstantin Belousov2020-11-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replace MAXPHYS by runtime variable maxphys. It is initialized from MAXPHYS by default, but can be also adjusted with the tunable kern.maxphys. Make b_pages[] array in struct buf flexible. Size b_pages[] for buffer cache buffers exactly to atop(maxbcachebuf) (currently it is sized to atop(MAXPHYS)), and b_pages[] for pbufs is sized to atop(maxphys) + 1. The +1 for pbufs allow several pbuf consumers, among them vmapbuf(), to use unaligned buffers still sized to maxphys, esp. when such buffers come from userspace (*). Overall, we save significant amount of otherwise wasted memory in b_pages[] for buffer cache buffers, while bumping MAXPHYS to desired high value. Eliminate all direct uses of the MAXPHYS constant in kernel and driver sources, except a place which initialize maxphys. Some random (and arguably weird) uses of MAXPHYS, e.g. in linuxolator, are converted straight. Some drivers, which use MAXPHYS to size embeded structures, get private MAXPHYS-like constant; their convertion is out of scope for this work. Changes to cam/, dev/ahci, dev/ata, dev/mpr, dev/mpt, dev/mvs, dev/siis, where either submitted by, or based on changes by mav. Suggested by: mav (*) Reviewed by: imp, mav, imp, mckusick, scottl (intermediate versions) Tested by: pho Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D27225 Notes: svn path=/head/; revision=368124
* Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)Pawel Biernacki2020-02-261-1/+2
| | | | | | | | | | | | | | | | | | | r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are still not MPSAFE (or already are but aren’t properly marked). Use it in preparation for a general review of all nodes. This is non-functional change that adds annotations to SYSCTL_NODE and SYSCTL_PROC nodes using one of the soon-to-be-required flags. Mark all obvious cases as MPSAFE. All entries that haven't been marked as MPSAFE before are by default marked as NEEDGIANT Approved by: kib (mentor, blanket) Commented by: kib, gallatin, melifaro Differential Revision: https://reviews.freebsd.org/D23718 Notes: svn path=/head/; revision=358333
* Use a void * argument to callout handlers instead of timeout_t casts.John Baldwin2019-12-051-1/+3
| | | | | | | | Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D22684 Notes: svn path=/head/; revision=355426
* Reset indentiation of ata_suspend() such that its clear we fall throughSean Bruno2018-07-031-7/+7
| | | | | | | | | | this function and that we aren't supposed to be controlled by the first if() conditional. Found with gcc. No functional change is intended with this commit. Notes: svn path=/head/; revision=335896
* sys/dev: 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=326255
* Remove dead mentions of CAM target mode APIs from drivers.Alexander Motin2017-02-191-4/+0
| | | | | | | This makes grepping kernel for target mode implementation much easier. Notes: svn path=/head/; revision=313949
* Always null-terminate ccb_pathinq.(sim_vid|hba_vid|dev_name)Alan Somers2017-01-041-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The sim_vid, hba_vid, and dev_name fields of struct ccb_pathinq are fixed-length strings. AFAICT the only place they're read is in sbin/camcontrol/camcontrol.c, which assumes they'll be null-terminated. However, the kernel doesn't null-terminate them. A bunch of copy-pasted code uses strncpy to write them, and doesn't guarantee null-termination. For at least 4 drivers (mpr, mps, ciss, and hyperv), the hba_vid field actually overflows. You can see the result by doing "camcontrol negotiate da0 -v". This change null-terminates those fields everywhere they're set in the kernel. It also shortens a few strings to ensure they'll fit within the 16-character field. PR: 215474 Reported by: Coverity CID: 1009997 1010000 1010001 1010002 1010003 1010004 1010005 CID: 1331519 1010006 1215097 1010007 1288967 1010008 1306000 CID: 1211924 1010009 1010010 1010011 1010012 1010013 1010014 CID: 1147190 1010017 1010016 1010018 1216435 1010020 1010021 CID: 1010022 1009666 1018185 1010023 1010025 1010026 1010027 CID: 1010028 1010029 1010030 1010031 1010033 1018186 1018187 CID: 1010035 1010036 1010042 1010041 1010040 1010039 Reviewed by: imp, sephe, slm MFC after: 4 weeks Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D9037 Differential Revision: https://reviews.freebsd.org/D9038 Notes: svn path=/head/; revision=311305
* sys/dev: minor spelling fixes.Pedro F. Giffuni2016-05-031-1/+1
| | | | | | | Most affect comments, very few have user-visible effects. Notes: svn path=/head/; revision=298955
* Implement Auxiliary register. Add PIM_ATA_EXT flag to flag that a SIMWarner Losh2016-04-171-0/+6
| | | | | | | | | | | | can handle it, and add the code to add it to the FIS that's sent to the drive. The mvs driver is the only other ATA driver in the system, and its hardware doesn't appear to support setting the Auxiliary register. Differential Revision: https://reviews.freebsd.org/D5598 Notes: svn path=/head/; revision=298143
* Add defines for WRITE_UNCORRECTABLE ATA command, and improve command loggingRavi Pokala2016-02-041-8/+92
| | | | | | | | | | | | | | | Add #defines for ATA_WRITE_UNCORRECTABLE48 and its features. Update the decoding in ATACAM to recognize the new values. Also improve command decoding for a few other commands (SMART, NOP, SET_FEATURES). Bring the decoding in ata(4) up to parity with ATACAM. Reviewed by: mav, imp MFC after: 1 month Sponsored by: Panasas, Inc. Differential Revision: https://reviews.freebsd.org/D5181 Notes: svn path=/head/; revision=295276
* Small addition to r286814.Alexander Motin2015-08-151-2/+0
| | | | | | | | Submitted by: bz MFC after: 2 weeks Notes: svn path=/head/; revision=286816
* Remove UMA allocation of ATA requests.Alexander Motin2015-08-151-26/+2
| | | | | | | | | | | After CAM replaced old ATA stack, this driver processes no more then one request at a time per channel. Using UMA after that is overkill, so replace it with simple preallocation of one request per channel. MFC after: 2 weeks Notes: svn path=/head/; revision=286814
* Disable 32-bit PIO for 6Gbit/s Intel SATA controllers.Alexander Motin2015-08-081-0/+1
| | | | | | | | | | | | | | | | For some reason 32-bit PIO writes are not working on 6Gbit/s Intel SATA ports, while 16/32-bit PIO reads and 16-bit PIO writes are working fine. 3Gbit/s ports on the same controllers have no this problem. Workaround this by disabling 32-bit PIO for all Intel controllers that may have 6Gbit/s ports. It halves PIO performance from 6MB/s to 3MB/s, but who bother about speed of such rare and slow mode, which is also highly discouraged by SATA specifications? MFC after: 2 weeks Notes: svn path=/head/; revision=286448
* Add unmapped I/O support to ata(4) driver.Alexander Motin2015-08-071-1/+1
| | | | | | | | | Main problem there was PIO mode support, that required KVA mapping. Handle that case using recently added pmap_quick_enter_page(9) KPI, mapping data pages to KVA one at a time. Notes: svn path=/head/; revision=286415
* Reduce priority of ATA/SATA drivers.Alexander Motin2015-03-231-1/+1
| | | | | | | | | | Legacy ata(4) -> BUS_PROBE_LOW_PRIORITY; more functional ahci(4), siis(4), mvs(4) -> BUS_PROBE_DEFAULT; BUS_PROBE_VENDOR leave for vendor drivers. MFC after: 2 weeks Notes: svn path=/head/; revision=280393
* Pull in r267961 and r267973 again. Fix for issues reported will follow.Hans Petter Selasky2014-06-281-2/+1
| | | | Notes: svn path=/head/; revision=267992
* Revert r267961, r267973:Glen Barber2014-06-271-1/+2
| | | | | | | | | | | | | These changes prevent sysctl(8) from returning proper output, such as: 1) no output from sysctl(8) 2) erroneously returning ENOMEM with tools like truss(1) or uname(1) truss: can not get etype: Cannot allocate memory Notes: svn path=/head/; revision=267985
* Extend the meaning of the CTLFLAG_TUN flag to automatically check ifHans Petter Selasky2014-06-271-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | there is an environment variable which shall initialize the SYSCTL during early boot. This works for all SYSCTL types both statically and dynamically created ones, except for the SYSCTL NODE type and SYSCTLs which belong to VNETs. A new flag, CTLFLAG_NOFETCH, has been added to be used in the case a tunable sysctl has a custom initialisation function allowing the sysctl to still be marked as a tunable. The kernel SYSCTL API is mostly the same, with a few exceptions for some special operations like iterating childrens of a static/extern SYSCTL node. This operation should probably be made into a factored out common macro, hence some device drivers use this. The reason for changing the SYSCTL API was the need for a SYSCTL parent OID pointer and not only the SYSCTL parent OID list pointer in order to quickly generate the sysctl path. The motivation behind this patch is to avoid parameter loading cludges inside the OFED driver subsystem. Instead of adding special code to the OFED driver subsystem to post-load tunables into dynamically created sysctls, we generalize this in the kernel. Other changes: - Corrected a possibly incorrect sysctl name from "hw.cbb.intr_mask" to "hw.pcic.intr_mask". - Removed redundant TUNABLE statements throughout the kernel. - Some minor code rewrites in connection to removing not needed TUNABLE statements. - Added a missing SYSCTL_DECL(). - Wrapped two very long lines. - Avoid malloc()/free() inside sysctl string handling, in case it is called to initialize a sysctl from a tunable, hence malloc()/free() is not ready when sysctls from the sysctl dataset are registered. - Bumped FreeBSD version to indicate SYSCTL API change. MFC after: 2 weeks Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=267961
* Fix the style of ata_interrupt_locked().Rui Paulo2014-04-121-13/+11
| | | | Notes: svn path=/head/; revision=264389
* Merge CAM locking changes from the projects/camlock branch to radicallyAlexander Motin2013-10-211-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Allow the legacy CDROM device to be accessed in a FreeBSD guest, whilePeter Grehan2013-10-101-1/+1
| | | | | | | | | | still using enlightened drivers for other block devices. Submitted by: Microsoft hyperv dev team, mav@ Approved by: re@ Notes: svn path=/head/; revision=256304
* - With the demise of !ATA_CAM, ATA_STATIC_ID is the only ata(4) relatedMarius Strobl2013-04-061-1/+0
| | | | | | | | | | | | option left but actually consumed by ada(4), so move it to opt_ada.h and get rid of opt_ata.h. - Fix stand-alone build of atacore(4) by adding opt_cam.h. - Use __FBSDID. - Use DEVMETHOD_END. - Use NULL instead of 0 for pointers. Notes: svn path=/head/; revision=249213
* - Make ata_str2mode() static, it's not used outside of ata-all.c.Marius Strobl2013-04-061-3/+151
| | | | | | | | | | | | | - Move ata_timeout() to ata-all.c so we don't need to expose both this function and ata_cam_end_transaction() but only the former. - Move ata_cmd2str() from ata-queue.c to ata-all.c so we can get rid of the former. - Add some missing prototypes. MFC after: 3 days Notes: svn path=/head/; revision=249203
* Unbreak ATA_NO_48BIT_DMA with ATA_CAM by treating 48-bit DMA as anMarius Strobl2013-04-061-7/+23
| | | | | | | | | | optional property with PATA transport. Reviewed by: mav MFC after: 3 days Notes: svn path=/head/; revision=249199
* Remove all legacy ATA code parts, not used since options ATA_CAM enabled inAlexander Motin2013-04-041-997/+1
| | | | | | | | | | | | most kernels before FreeBSD 9.0. Remove such modules and respective kernel options: atadisk, ataraid, atapicd, atapifd, atapist, atapicam. Remove the atacontrol utility and some man pages. Remove useless now options ATA_CAM. No objections: current@, stable@ MFC after: never Notes: svn path=/head/; revision=249083
* Add some more ATA_CAM ifdefs.Alexander Motin2013-04-031-1/+7
| | | | | | | | Submitted by: marius (partially) MFC after: 1 week Notes: svn path=/head/; revision=249052
* Fix command timeout caused by data underrun during fetching ATAPI senseAlexander Motin2013-02-221-0/+1
| | | | | | | | | | | data, introduced by r246713. There are two places where ata_request is filled in ATA_CAM: ata_cam_begin_transaction() and ata_cam_request_sense(). In the first case DMA should be done for addresses from the CCB. In second case, DMA should be done to the different address, the address of the sense buffer inside the CCB structure itself. Notes: svn path=/head/; revision=247165
* Only four specific ATA PIO commands transfer several sectors per DRQ blockAlexander Motin2012-11-011-2/+10
| | | | | | | | | (interrupt). All other ATA PIO commands transfer one sector or 512 bytes at one time. Hardcode these exceptions in ata(4) with ATA_CAM option. This fixes timeout of READ LOG EXT command used by `smartctl -x /dev/adaX`. Notes: svn path=/head/; revision=242422
* Implement CAM_ATAIO_NEEDRESULT (fetching full set of result registers) forAlexander Motin2012-10-261-0/+2
| | | | | | | | | | ata(4) driver in ATA_CAM mode. That slighty improves error reporting and also should fix `smartctl -l scterc /dev/adaX` operation. MFC after: 3 weeks Notes: svn path=/head/; revision=242156
* Implement SATA revision (speed) control for legacy SATA controller forAlexander Motin2012-10-021-0/+9
| | | | | | | | | | both boot (via loader tunables) and run-time (via `camcontrol negotiate`). Tested to work at least on NVIDIA MCP55 chipset. H/w provided by: glebius Notes: svn path=/head/; revision=241144
* Fix typo in bzero length argument during sense fetching.Alexander Motin2012-07-211-1/+1
| | | | | | | | | For me it at least fixed CD burning in PIO mode. MFC after: 3 days Notes: svn path=/head/; revision=238666
* Partially revert r236666:Alexander Motin2012-06-101-1/+1
| | | | | | | | | | | | | | Return PROTO_ATA protocol in response to XPT_PATH_INQ. smartmontools uses it to identify ATA devices and I don't know any other place now where it is important. It could probably use XPT_GDEV_TYPE instead for more accurate protocol information, but let it live for now. Reported by: matthew MFC after: 3 days Notes: svn path=/head/; revision=236847
* ATA/SATA controllers have no idea about protocol of the connected deviceAlexander Motin2012-06-061-2/+2
| | | | | | | | | | 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. Notes: svn path=/head/; revision=236666
* Make legacy ATA to not call device_add_child() with unit number butAlexander Motin2012-05-281-1/+1
| | | | | | | | | without driver name. This fixed legacy ATA breakage by r235978. MFC after: 1 week Notes: svn path=/head/; revision=236184
* Add two functions xpt_batch_start() and xpt_batch_done() to the CAM SIM KPIAlexander Motin2012-05-121-0/+2
| | | | | | | | | | | | 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 Notes: svn path=/head/; revision=235333
* - First pass at const'ifying ata(4) as appropriate.Marius Strobl2012-03-211-1/+1
| | | | | | | | | | - Use DEVMETHOD_END. - Use NULL instead of 0 for pointers MFC after: 1 week Notes: svn path=/head/; revision=233282
* Remove remnants of ATA_LOCKING uses in the ATA_CAM case and wrap itMarius Strobl2012-03-211-2/+40
| | | | | | | | | | | | | | | | | | along with functions, SYSCTLs and tunables that are not used with ATA_CAM in #ifndef ATA_CAM, similar to the existing #ifdef'ed ATA_CAM code for the other way around. This makes it easier to understand which parts of ata(4) actually are used in the new world order and to later on remove the !ATA_CAM bits. It also makes it obvious that there is something fishy with the C-bus front-end as well as in the ATP850 support, as these used ATA_LOCKING which is defunct in the ATA_CAM case. When fixing the former, ATA_LOCKING probably needs to be brought back in some form or other. Reviewed by: mav MFC after: 1 week Notes: svn path=/head/; revision=233274
* Convert files to UTF-8Ulrich Spörlein2012-01-151-1/+1
| | | | Notes: svn path=/head/; revision=230132
* Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs.Ed Schouten2011-11-071-1/+1
| | | | | | | | | The SYSCTL_NODE macro defines a list that stores all child-elements of that node. If there's no SYSCTL_DECL macro anywhere else, there's no reason why it shouldn't be static. Notes: svn path=/head/; revision=227309
* Add a "kern.features.ata_cam" sysctl in the kernel when the ATA_CAM kernelCraig Rodrigues2011-10-091-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | option is defined. This sysctl can be queried by feature_present(3). Query for this feature in /sbin/atacontrol and /usr/sbin/burncd. If these utilities detect that ATA_CAM is enabled, then these utilities will error out. These utilities are compatible with the old ATA driver, but are incomptible with the new ATA_CAM driver. By erroring out, we give end-users an idea as to what remedies to use, and reduce the need for them to file PR's. For atacontrol, camcontrol must be used instead, and for burncd, alternative utilties from the ports collection must be used such as sysutils/cdrtools. In future, maybe someone can re-write burncd to work with ATA_CAM, but at least for now, we give a somewhat useful error message to end users. PR: 160979 Reviewed by: jh, Arnaud Lacombe <lacombar at gmail dot com> Reported by: Joe Barbish <fbsd8 at a1poweruser dot com> MFC after: 3 days Notes: svn path=/head/; revision=226179
* Fix a typo in a comment.Wesley Shields2011-10-061-1/+1
| | | | | | | Approved by: kib@ Notes: svn path=/head/; revision=226064
* Use periodic status polling added at r214671 only in ATA_CAM mode. LegacyAlexander Motin2011-04-211-7/+13
| | | | | | | mode won't receive much benefit from it due to its hot-plug limitations. Notes: svn path=/head/; revision=220917
* Implement automatic SCSI sense fetching for ata(4) in ATA_CAM mode.Alexander Motin2011-04-121-2/+78
| | | | | | | | While it could be successfully done by CAM error recovery code, I was told by several people that it is also a SIM obligation. Notes: svn path=/head/; revision=220563
* Make ATA_CAM wrapper to report SATA power management capabilities to CAM toAlexander Motin2010-11-181-0/+19
| | | | | | | | make it configure device to initiate transitions if controller configured to accept them. This makes hint.ata.X.pm_level=1 mode working. Notes: svn path=/head/; revision=215468