summaryrefslogtreecommitdiff
path: root/sys/dev/mpt
Commit message (Collapse)AuthorAgeFilesLines
* mpt(4): Fix two typos in debug statementsGordon Bergling2022-11-101-2/+2
| | | | | | | | - s/Intermidiate/Intermediate/ Obtained from: NetBSD (cherry picked from commit 00b0158d2ca6f0405468c2338d823091963c18ed)
* mpt(4): Fix a typo in a source code commentGordon Bergling2022-04-141-1/+1
| | | | | | - s/proccessor/processor/ (cherry picked from commit a37c6fcc46caffc15f0f22a7e4afce9192872c1a)
* mpr/mps/mpt: verify cfg page ioctl lengthsEd Maste2022-04-041-0/+13
| | | | | | | | | | | | | | | | | | | | | | | *_CFG_PAGE ioctl handlers in the mpr, mps, and mpt drivers allocated a buffer of a caller-specified size, but copied to it a fixed size header. Add checks that the size is at least the required minimum. Note that the device nodes are owned by root:operator with 0640 permissions so the ioctls are not available to unprivileged users. This change includes suggestions from scottl, markj and mav. Two of the mpt cases were reported by Lucas Leong (@_wmliang_) of Trend Micro Zero Day Initiative; scottl reported the third case in mpt. Same issue found in mpr and mps after discussion with imp. Reported by: Lucas Leong (@_wmliang_), Trend Micro Zero Day Initiative Reviewed by: imp, mav MFC after: 3 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D34692 (cherry picked from commit 8276c4149b5fc7c755d6b244fbbf6dae1939f087)
* Mark some sysctls as CTLFLAG_MPSAFE.Alexander Motin2021-08-251-9/+3
| | | | | | MFC after: 2 weeks (cherry picked from commit b776de6796fa0cd1b7dfaad75402e10907d47f29)
* mpt(4): Remove incorrect S/G segments limits.Alexander Motin2021-04-241-20/+0
| | | | | | | | | | | | First, two of those four checks are unreachable. Second, I don't believe there should be ">=" instead of ">". Third, bus_dma(9) already returns the same EFBIG if ">". This fixes false I/O errors in worst S/G cases with maxphys >= 2MB. MFC after: 1 week (cherry picked from commit 0f29396e493bd87ffa6a63fcb602b12e79d21a1e)
* Make MAXPHYS tunable. Bump MAXPHYS to 1M.Konstantin Belousov2020-11-282-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* mpt: clean up empty lines in .c and .h filesMateusz Guzik2020-09-0119-248/+9
| | | | Notes: svn path=/head/; revision=365202
* Centralize compatability translation macros.Brooks Davis2020-04-141-5/+3
| | | | | | | | | | | | | | | | Copy the CP, PTRIN, etc macros from freebsd32.h into a sys/abi_compat.h and replace existing definitation with includes where required. This eliminates duplicate code and allows Linux and FreeBSD compatability headers to be included in the same files. Input from: cem, jhb Obtained from: CheriBSD MFC after: 2 weeks Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D24275 Notes: svn path=/head/; revision=359937
* Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)Pawel Biernacki2020-02-261-9/+9
| | | | | | | | | | | | | | | | | | | 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
* Remove sparc64 kernel supportWarner Losh2020-02-032-9/+0
| | | | | | | | | Remove all sparc64 specific files Remove all sparc64 ifdefs Removee indireeect sparc64 ifdefs Notes: svn path=/head/; revision=357455
* Use callout_func_t instead of the deprecated timeout_t.John Baldwin2019-12-102-2/+2
| | | | | | | | Reviewed by: kib, imp Differential Revision: https://reviews.freebsd.org/D22752 Notes: svn path=/head/; revision=355601
* Revert r327828, r327949, r327953, r328016-r328026, r328041:Pedro F. Giffuni2018-01-211-3/+3
| | | | | | | | | | | | | | | | | | 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
* dev: make some use of mallocarray(9).Pedro F. Giffuni2018-01-131-3/+3
| | | | | | | | | | | | | | Focus on code where we are doing multiplications within malloc(9). None of these is 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. Notes: svn path=/head/; revision=327949
* sys/dev: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-279-0/+18
| | | | | | | | | | | | | | | 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
* sys/dev: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-2014-1/+29
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 3-Clause license. 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. Special thanks to Wind River for providing access to "The Duke of Highlander" tool: an older (2014) run over FreeBSD tree was useful as a starting point. Notes: svn path=/head/; revision=326022
* mpt.h: macro parenthesizationRyan Libby2017-06-301-2/+2
| | | | | | | | | | | | | Build with gcc -Wint-in-bool-context revealed a macro parenthesization error (invoking mpt_lprt with a ternary expression for level). Reviewed by: markj Approved by: markj (mentor) Sponsored by: Dell EMC Isilon Differential revision: https://reviews.freebsd.org/D11412 Notes: svn path=/head/; revision=320513
* Partially fix target task management requests handling.Alexander Motin2017-03-112-109/+125
| | | | | | | | | | | | | | | | | - XPT_NOTIFY_ACKNOWLEDGE was not handled, causing stuck requests. - XPT_ABORT was not even trying to abort active ATIOs/INOTs. - Initiator's tag was not stored and not used where needed. - List of TM request types needed update. - mpt_scsi_tgt_status() missed some useful debugging. After this change global TM requests, such as reset, should work properly. ABORT TASK (ABTS) requests are still not passes to CTL, that is not good and should be fixed. MFC after: 2 weeks Notes: svn path=/head/; revision=315067
* Add PIM_EXTLUNS support to mpt(4).Alexander Motin2017-03-102-51/+19
| | | | | | | | | | Target mode is still limited to 256 LUNs due to the way driver is written, but initiator can now use full 8 byte LUN space. MFC after: 2 weeks Notes: svn path=/head/; revision=315004
* Improve residuals reporting in target mode.Alexander Motin2017-03-102-2/+7
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=315002
* Fix panic on wildcard target LUN disable.Alexander Motin2017-03-101-1/+1
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=315001
* Fix FC target mode in mpt(4), broken in multiple ways.Alexander Motin2017-03-102-92/+51
| | | | | | | | | | | | | | | | - Not set BufferLength caused receive of empty ATIOs. - CDB length guessing was broken at least for RC16. - mpt_req_untimeout() was called with wrong req parameter. - Sense data reporting was broken in several ways. With this change my LSI7204EP-LC can pass at least basic tests as target. The code is still far from perfect, but finally I found second hw/driver after isp(4) that really can work in CAM target mode. MFC after: 2 weeks Notes: svn path=/head/; revision=314998
* Report some more data in XPT_PATH_INQ.Alexander Motin2017-03-092-0/+7
| | | | | | | | | I am not sure they are used anywhere, but why not. MFC after: 2 weeks Notes: svn path=/head/; revision=314968
* Add support for XPT_GET_SIM_KNOB in FC mode.Alexander Motin2017-03-092-19/+43
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=314967
* Report FC link speed.Alexander Motin2017-03-091-3/+21
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=314966
* "Buses" is the preferred plural of "bus"Conrad Meyer2017-01-153-6/+6
| | | | | | | | | | | | | | | | | | | | Replace archaic "busses" with modern form "buses." Intentionally excluded: * Old/random drivers I didn't recognize * Old hardware in general * Use of "busses" in code as identifiers No functional change. http://grammarist.com/spelling/buses-busses/ PR: 216099 Reported by: bltsrc at mail.ru Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=312234
* 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
* Fix the fallout from r308268 (mpt driver causes endless witness warnings inScott Long2016-11-071-0/+8
| | | | | | | | | | VMWare and elsewhere) with the precision of a dull, rusty butter knife. Reported by: tuexen Obtained from: Netflix Notes: svn path=/head/; revision=308423
* Remove NULL check after M_WAITOK allocation from mpt(4).Edward Tomasz Napierala2016-08-091-4/+0
| | | | | | | MFC after: 1 month Notes: svn path=/head/; revision=303874
* sys/dev: minor spelling fixes.Pedro F. Giffuni2016-05-035-14/+14
| | | | | | | Most affect comments, very few have user-visible effects. Notes: svn path=/head/; revision=298955
* Replace 0 with NULL for pointers in misc. device drivers.Pedro F. Giffuni2016-04-121-1/+1
| | | | | | | Found with devel/coccinelle. Notes: svn path=/head/; revision=297862
* - In mpt_send_handshake_cmd(), use bus_space_write_stream_4(9) for writingMarius Strobl2015-07-242-9/+14
| | | | | | | | | | | | | raw data to the doorbell offset in order to clarify the intent and for avoiding unnecessarily converting the endianess back and forth. Unfortunately, the same can't be done in mpt_recv_handshake_reply() as 16-bit data needs to be read using 32-bit bus accessors. - In mpt_recv_handshake_reply(), get rid of a redundant variable. MFC after: 1 fortnight Notes: svn path=/head/; revision=285840
* Squelch a (bogus) used before init warning when building with gcc.Ian Lepore2014-11-231-0/+1
| | | | Notes: svn path=/head/; revision=274926
* Prevent overflow issues in timeout processingSteven Hartland2014-11-213-13/+15
| | | | | | | | | | | | | | | | | | | | | | | | Previously, any timeout value for which (timeout * hz) will overflow the signed integer, will give weird results, since callout(9) routines will convert negative values of ticks to '1'. For unsigned integer overflow we will get sufficiently smaller timeout values than expected. Switch from callout_reset, which requires conversion to int based ticks to callout_reset_sbt to avoid this. Also correct isci to correctly resolve ccb timeout. This was based on the original work done by Eygene Ryabinkin <rea@freebsd.org> back in 5 Aug 2011 which used a macro to help avoid the overlow. Differential Revision: https://reviews.freebsd.org/D1157 Reviewed by: mav, davide MFC after: 1 month Sponsored by: Multiplay Notes: svn path=/head/; revision=274819
* Hide a harmless "QUEUE FULL EVENT" message behind bootverbose.Hiren Panchasara2014-06-201-2/+5
| | | | | | | | | | Requested by: A bunch of users on mailing-lists Suggested by: scottl MFC after: 1 week Sponsored by: Yahoo! inc. Notes: svn path=/head/; revision=267690
* - Remove a redundant variable in mpt_pci_attach().Marius Strobl2013-12-294-201/+49
| | | | | | | | | | | | | | | - #if 0 the currently unused paired port linking and unlinking of dual adapters. - Simplify MSI/MSI-X allocation and release. For a single one, we don't need to fiddle with the MSI/MSI-X count and pci_release_msi(9) is smart enough to just do nothing in case of INTx. - Canonicalize actions taken on attach failure and detach. - Remove the remainder of incomplete support for older FreeBSD versions. MFC after: 1 week Notes: svn path=/head/; revision=260058
* Fix undefined behavior: (1 << 31) is not defined as 1 is an int and thisEitan Adler2013-11-301-2/+2
| | | | | | | | | | | | | | | | shifts into the sign bit. Instead use (1U << 31) which gets the expected result. This fix is not ideal as it assumes a 32 bit int, but does fix the issue for most cases. A similar change was made in OpenBSD. Discussed with: -arch, rdivacky Reviewed by: cperciva Notes: svn path=/head/; revision=258780
* Adjust various SCSI drivers to handle either a 32-bit or 64-bit lun_id_t,Nathan Whitehorn2013-10-301-13/+15
| | | | | | | | | | mostly by adjustments to debugging printf() format specifiers. For high numbered LUNs, also switch to printing them in hex as per SAM-5. MFC after: 2 weeks Notes: svn path=/head/; revision=257381
* Partial MFproject/camlock r256671:Alexander Motin2013-10-211-2/+1
| | | | | | | | Fix several target mode SIMs to not blindly clear ccb_h.flags field of ATIO CCBs. Not all CCB flags there belong to them. Notes: svn path=/head/; revision=256826
* Update PCI drivers to no longer look at the MEMIO-enabled bit in the PCIScott Long2013-08-121-6/+1
| | | | | | | | | | | | | | | | | | | | command register. The lazy BAR allocation code in FreeBSD sometimes disables this bit when it detects a range conflict, and will re-enable it on demand when a driver allocates the BAR. Thus, the bit is no longer a reliable indication of capability, and should not be checked. This results in the elimination of a lot of code from drivers, and also gives the opportunity to simplify a lot of drivers to use a helper API to set the busmaster enable bit. This changes fixes some recent reports of disk controllers and their associated drives/enclosures disappearing during boot. Submitted by: jhb Reviewed by: jfv, marius, achadd, achim MFC after: 1 day Notes: svn path=/head/; revision=254263
* Flag mpt(4) as supporting unmapped I/O; all necessary conversion actuallyMarius Strobl2013-06-241-5/+5
| | | | | | | | | already has been done as part of r246713 except for a comment update. MFC after: 3 days Notes: svn path=/head/; revision=252180
* Explicitly use a pair of parentheses to ensure correct evaluationXin LI2013-05-312-3/+3
| | | | | | | | | | ordering for bitwise operation. Submitted by: swildner (DragonFly) MFC after: 2 weeks Notes: svn path=/head/; revision=251187
* Move hptmv and mpt drivers shutdown a bit later to the SHUTDOWN_PRI_LASTAlexander Motin2013-04-241-1/+1
| | | | | | | | | | stage of shutdown_post_sync. That should allow CAM to do final cache flush at the SHUTDOWN_PRI_DEFAULT without using polling magic. MFC after: 3 days Notes: svn path=/head/; revision=249849
* MFprojects/camlock r248982:Alexander Motin2013-04-142-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. Notes: svn path=/head/; revision=249468
* Reform the busdma API so that new types may be added without modifyingKonstantin Belousov2013-02-121-100/+20
| | | | | | | | | | | | | | | | | | | | | | | | 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>) Notes: svn path=/head/; revision=246713
* Remove support for using Giant for locking within mpt(4). Finer grainedMarius Strobl2012-10-223-117/+0
| | | | | | | | | locking has been working fine for ~5.5 years by now. MFC after: 1 week Notes: svn path=/head/; revision=241875
* After r241858, remove the remainder of FreeBSD ~4 support from mpt(4).Marius Strobl2012-10-225-252/+30
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=241874
* Now that device disabling is generic, remove the non-standardEitan Adler2012-10-221-5/+0
| | | | | | | | | | | | implementation from mpt Don't MFC this to retain backwards compatibility. Reviewed by: des, mjacob Approved by: cperciva Notes: svn path=/head/; revision=241863
* Remove unused code since the 5.x daysEitan Adler2012-10-221-63/+0
| | | | | | | | | Reviewed by: des, scottl Approved by: cperciva MFC after: 1 week Notes: svn path=/head/; revision=241858
* Fix an issue that caused the kernel to panic inside CTL when tryingKenneth D. Merry2012-06-261-17/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | to attach to target capable HBAs that implement the old immediate notify (XPT_IMMED_NOTIFY) and notify acknowledge (XPT_NOTIFY_ACK) CCBs. The new API has been in place since SVN change 196008 in 2009. The solution is two-fold: fix CTL to handle the responses from the HBAs, and convert the HBA drivers in question to use the new API. These drivers have not been tested with CTL, so how well they will interoperate with CTL is unknown. scsi_target.c: Update the userland target example code to use the new immediate notify API. scsi_ctl.c: Detect when an immediate notify CCB is returned with CAM_REQ_INVALID or CAM_PROVIDE_FAIL status, and just free it. Fix a duplicate assignment. aic79xx.c, aic79xx_osm.c: Update the aic79xx driver to use the new API. Target mode is not enabled on for this driver, so the changes will have no practical effect. aic7xxx.c, aic7xxx_osm.c: Update the aic7xxx driver to use the new API. sbp_targ.c: Update the firewire target code to work with the new API. mpt_cam.c: Update the mpt(4) driver to work with the new API. Target mode is only enabled for Fibre Channel mpt(4) devices. MFC after: 3 days Notes: svn path=/head/; revision=237601
* Correct sizeof usageKevin Lo2012-06-251-1/+1
| | | | | | | Obtained from: DragonFly Notes: svn path=/head/; revision=237546