aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/mpr
Commit message (Collapse)AuthorAgeFilesLines
...
* Teach mps(4) and mpr(4) drivers to autotune chain frames.Alexander Motin2018-02-103-49/+61
| | | | | | | | | | | | | | | | This is a first part of the change. It makes the drivers to calculate the required number of chain frames to satisfy worst case scenarios, but it does not change existing overly strict limits on them. The next step will be to rewrite the allocator to not require megabytes of physically contiguous address space, that may be problematic if done after boot, after doing which the limits can be removed. Until that this code can just correct user set limits, if they are set too high. Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D14261 Notes: svn path=/head/; revision=329096
* Cache the value of the request and reply frame size since it's used quiteScott Long2018-02-063-16/+29
| | | | | | | | | | | a bit in the normal operation of the driver. Covert it to represent bytes instead of 32bit words. Fix what I believe to be is a bug in this respect with the Tri-mode cards. Sponsored by: Netflix Notes: svn path=/head/; revision=328950
* Fix queue length reporting in mps(4) and mpr(4).Alexander Motin2018-02-063-4/+7
| | | | | | | | | | | | | | | Both drivers were found to report CAM bigger queue depth then they really can handle. It made them later under high load with many disks return some of submitted requests back with CAM_REQUEUE_REQ status for later resubmission. Reviewed by: scottl MFC after: 1 week Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D14215 Notes: svn path=/head/; revision=328937
* Diagnostic buffer fixes for the mps(4) and mpr(4) drivers.Kenneth D. Merry2018-02-063-14/+165
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In mp{r,s}_diag_register(), which is used to register diagnostic buffers with the mp{r,s}(4) firmware, we allocate DMAable memory. There were several issues here: o No checking of the bus_dmamap_load() return value. If the load failed or got deferred, mp{r,s}_diag_register() continued on as if nothing had happened. We now check the return value and bail out if it fails. o No waiting for a deferred load callback. bus_dmamap_load() calls a supplied callback when the mapping is done. This is generally done immediately, but it can be deferred. mp{r,s}_diag_register() did not check to see whether the callback was already done before proceeding on. We now sleep until the callback is done if it is deferred. o No call to bus_dmamap_sync(... BUS_DMASYNC_PREREAD) after the memory is allocated and loaded. This is necessary on some platforms to synchronize host memory that is going to be updated by a device. Both drivers would also panic if the firmware was reinitialized while a diagnostic buffer operation was in progress. This fixes that problem as well. (The driver will reinitialize the firmware in various circumstances, but the problem I ran into was that the firmware would generate an IOC Fault due to a PCIe error.) mp{r,s}var.h: Add a new structure, struct mpr_busdma_context, that is used for deferred busdma load callbacks. Add a prototype for mp{r,s}_memaddr_wait_cb(). mp{r,s}.c: Add a new busdma callback function, mp{r,s}_memaddr_wait_cb(). This provides synchronization for callers that want to wait on a deferred bus_dmamap_load() callback. mp{r,s}_user.c: In bus_dmamap_register(), add a call to bus_dmamap_sync() with the BUS_DMASYNC_PREREAD flag set after an allocation is loaded. Also, check the return value of bus_dmamap_load(). If it fails, bail out. If it is EINPROGRESS, wait for the callback to happen. We use an interruptible sleep (msleep with PCATCH) and let the callback clean things up if we get interrupted. In mpr_diag_read_buffer() and mps_diag_read_buffer(), call bus_dmamap_sync(..., BUS_DMASYNC_POSTREAD) before copying the data out to make sure the data is in stable storage. In mp{r,s}_post_fw_diag_buffer() and mp{r,s}_release_fw_diag_buffer(), check the reply to see whether it is NULL. It can be NULL (and the command non-NULL) if the controller gets reinitialized while we're waiting for the command to complete but the driver structures aren't reallocated. The driver structures generally won't be reallocated unless there is a firmware upgrade that changes one of the IOCFacts. When freeing diagnostic buffers in mp{r,s}_diag_register() and mp{r,s}_diag_unregister(), zero/NULL out the buffer after freeing it. This will prevent a duplicate free in some situations. Sponsored by: Spectra Logic Reviewed by: mav, scottl MFC after: 1 week Differential Revision: D13453 Notes: svn path=/head/; revision=328936
* Minimal changes for MPR to build on architectures with physical addresses ↵Justin Hibbits2018-02-041-2/+2
| | | | | | | | | | | | | | | | larger than virtual Summary: Some architectures use large (36-bit) physical addresses, with smaller virtual addresses. Casting between vm_paddr_t (or bus_addr_t) and void * is considered illegal, so cast through uintptr_t. No functional change on existing platforms. Reviewed By: scottl Differential Revision: https://reviews.freebsd.org/D14042 Notes: svn path=/head/; revision=328850
* Revert r327828, r327949, r327953, r328016-r328026, r328041:Pedro F. Giffuni2018-01-212-12/+12
| | | | | | | | | | | | | | | | | | 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-132-12/+12
| | | | | | | | | | | | | | 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
* Refactoring the interrupt setup code introduced a bug where the driversScott Long2017-11-101-1/+5
| | | | | | | | | | | | | would attempt to re-allocate interrupts during a chip reset without first de-allocating them. Doing that right is going to be tricky, so just band-aid it for now so that a re-init doesn't guarantee a failure due to resource re-use. Reported by: gallatin Sponsored by: Netflix Notes: svn path=/head/; revision=325667
* Fix mpr(4) panics caused by bad drive mapping tablesAlan Somers2017-11-031-6/+20
| | | | | | | | | | | | | | | | | sys/dev/mpr/mpr_mapping.c If _mapping_process_dpm_pg0 detects inconsistencies in the drive mapping table (stored in the HBA's NVRAM), abort reading it and continue to boot as if the mapping table were blank. I observed such inconsistencies in several HBAs after upgrading firmware from 14.0.0.0 to 15.0.0.0. Reviewed by: slm MFC after: 3 weeks Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D12901 Notes: svn path=/head/; revision=325363
* Improve the debug parsing to allow flags to be added and subtractedScott Long2017-10-011-1/+29
| | | | | | | | | from the existing set. Submitted by: rea@freebsd.org Notes: svn path=/head/; revision=324162
* Convert sysctl sbuf usage to use a fully dynaic sbuf. This is strictlyScott Long2017-09-291-8/+8
| | | | | | | | | | needed, but it silences an erroneous Coverity warning and makes the code a little more logically consistent. Also mark the sysctl as MPSAFE. Sponsored by: Netflix Notes: svn path=/head/; revision=324097
* Add the ability to report and set debug flags as text strings instead ofScott Long2017-09-241-6/+112
| | | | | | | | | | just integer flags. Report both for convenience. Submitted by: Eygene Ryabinkin (manpage) Sponsored by: Netflix Notes: svn path=/head/; revision=323969
* Garbage collect usued fieldsScott Long2017-09-231-3/+0
| | | | | | | Sponsored by: Netflix Notes: svn path=/head/; revision=323946
* Clean up error messages related to device discoveryScott Long2017-09-221-12/+18
| | | | | | | Sponsored by: Netflix Notes: svn path=/head/; revision=323922
* Fix line wrap issues.Scott Long2017-09-151-4/+4
| | | | | | | Sponsored by: Netflix Notes: svn path=/head/; revision=323629
* Add infrastructure for allocating multiple MSI-X interrupts. AlsoScott Long2017-09-114-26/+140
| | | | | | | | | add more fine-tuned controls for allocating requests and replies. Sponsored by: Netflix Notes: svn path=/head/; revision=323412
* Fix intrhook release in MPR and MPS for EARLY_AP_STARTUP.Scott Long2017-09-102-6/+5
| | | | | | | | Reported by: Limelight Sponsored by: Netflix Notes: svn path=/head/; revision=323384
* More code refactoring in preparation for enabling multiqueue.Scott Long2017-09-101-44/+54
| | | | | | | Sponsored by: Netflix Notes: svn path=/head/; revision=323383
* Convert some in-line printing of diagnostic into tables.Scott Long2017-09-093-160/+73
| | | | | | | Sponsored by: Netflix Notes: svn path=/head/; revision=323380
* Remove the unnecessary use of a temporary string buffer.Scott Long2017-09-092-11/+9
| | | | | | | Sponsored by: Netflix Notes: svn path=/head/; revision=323370
* Start separating the LSI drivers into per-queue structures. NoScott Long2017-09-093-20/+74
| | | | | | | | | functional change. Sponsored by: Netflix Notes: svn path=/head/; revision=323369
* Refactor interrupt allocation and deallocation. Add some extraScott Long2017-09-081-50/+52
| | | | | | | | | diagnostics. No other functional changes. Sponsored by: Netflix Notes: svn path=/head/; revision=323330
* Checkpoint the next phase in debug message cleanup, this time focusing onScott Long2017-09-061-82/+110
| | | | | | | | | error recovery messages. Sponsored by: Netflix Notes: svn path=/head/; revision=323215
* Start overhauling debug printing in the MPS and MPR drivers. The focus of thisScott Long2017-08-275-117/+163
| | | | | | | | | | | commit it to make initiazation less chatty in the normal case, and more useful and informative when real debugging is turned on. Reviewed by: ken (earlier version) Sponsored by: Netflix Notes: svn path=/head/; revision=322943
* Changes to make mps(4) and mpr(4) handle reinit with reallocation.Kenneth D. Merry2017-08-106-92/+144
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the mps(4) and mpr(4) drivers need to reinitialize the firmware, they sometimes need to reallocate all of the memory allocated by the driver. The reallocation happens whenever the IOC Facts change. That should only happen after a firmware upgrade. If the reinitialization happens as a result of a timed out command sent to the card, the command that timed out and triggered the reinit may have been freed if iocfacts_allocate() reallocated all memory. If the caller attempts to access the command after that, the kernel will panic because the caller will be dereferencing freed memory. The solution is to set a flag in the softc when we reallocate, and avoid dereferencing the command strucure if we've reallocated. The changes are largely the same in both drivers, since mpr(4) is a derivative of mps(4). o In iocfacts_allocate(), if the IOC Facts have changed and we need to reallocate, set the REALLOCATED flag in the softc. o Change wait_command() to take a struct mps_command ** instead of a struct mps_command *. This allows us to NULL out the caller's command pointer if we have to reinit the controller and the data structures get reallocated. (The REALLOCATED flag will be set in the softc if that has happened.) o In every place that calls wait_command(), make sure we handle the case where the command is NULL after the call. o The mpr(4) driver has mpr_request_polled() which can also reinitialize the card. Also check for reallocation there. Reviewed by: scottl, slm MFC after: 1 week Sponsored by: Spectra Logic Notes: svn path=/head/; revision=322364
* Fix a logic bug in the split PCI interrupt code that slipped throughScott Long2017-07-311-1/+2
| | | | | | | Reported by: Harry Schmalzbauer Notes: svn path=/head/; revision=321799
* Don't re-parse PCI IDs in order to set card-specific flags, useScott Long2017-07-311-22/+18
| | | | | | | the flags field in the PCIID table. Notes: svn path=/head/; revision=321737
* Change from using underbar function names to normal function names forScott Long2017-07-304-68/+27
| | | | | | | | | the informational print functions. Collapse the debug API a bit to be more generic and not require as much code duplication. While here, fix a bug in MPS that was already fixed in MPR. Notes: svn path=/head/; revision=321733
* Split the interrupt setup code into two parts: allocation and configuration.Scott Long2017-07-303-8/+34
| | | | | | | | | | | | | | | | | Do the allocation before requesting the IOCFacts message. This triggers the LSI firmware to recognize the multiqueue should be enabled if available. Multiqueue isn't used by the driver yet, but this also fixes a problem with the cached IOCFacts not matching latter checks, leading to potential problems with error recovery. As a side-effect, fetch the driver tunables as early as possible. Reviewed by: slm Obtained from: Netflix Differential Revision: D9243 Notes: svn path=/head/; revision=321714
* Quiet a message that sounds far more dire than it really is.Scott Long2017-07-261-1/+1
| | | | Notes: svn path=/head/; revision=321502
* Fix spurious timeouts on commands sent to mps(4) and mpr(4) controllers.Kenneth D. Merry2017-07-191-4/+15
| | | | | | | | | | | | | | | | | mps_wait_command() and mpr_wait_command() were using getmicrotime() to determine elapsed time when checking for a timeout in polled mode. getmicrotime() isn't guaranteed to monotonically increase, and that caused spurious timeouts occasionally. Switch to using getmicrouptime(), which does increase monotonically. This fixes the spurious timeouts in my test case. Reviewed by: slm, scottl MFC after: 3 days Sponsored by: Spectra Logic Notes: svn path=/head/; revision=321207
* Fix several problems with mapping code.Stephen McConnell2017-05-256-459/+915
| | | | | | | | | | Reviewed by: ken, scottl, asomers, ambrisko, mav Approved by: ken, mav MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D10861 Notes: svn path=/head/; revision=318896
* Fix powerpc compiler error.Stephen McConnell2017-05-221-2/+2
| | | | | | | Approved by: ken Notes: svn path=/head/; revision=318679
* Add tri-mode support (SAS/SATA/PCIe).Stephen McConnell2017-05-1720-202/+3522
| | | | | | | | | | | | | | | | | | | | This includes NVMe device support and adds support for the following adapters: SAS 3408 SAS 3416 SAS 3508 SAS 3516 SAS 3616 SAS 3708 SAS 3716 Reviewed by: ken, scottl, asomers, mav Approved by: ken, scottl, mav MFC after: 2 weeks Relnotes: yes Differential Revision: https://reviews.freebsd.org/D10095 Notes: svn path=/head/; revision=318427
* Improve error messages during command timeout for the mpr and mpsScott Long2017-05-111-4/+5
| | | | | | | | | drivers. Sponsored by: Netflix Notes: svn path=/head/; revision=318188
* Import mpr(4) driver P12 to P14 diff from vendor site.Alexander Motin2017-03-064-5/+26
| | | | | | | | | | | | This is mostly a version bump to stay in version number sync with firmware. The only change there was cosmetic: Display degraded speed message upon receiving Active Cable Exception Event with DEGRADED reason code. Discussed with: slm@ MFC after: 1 week Notes: svn path=/head/; revision=314786
* Initialize a stack variable in mprsas_get_sas_address_for_sata_diskAlan Somers2017-01-301-0/+1
| | | | | | | | | | | | | | | Thought it's difficult to reproduce, I think this variable was responsible for a use-after-free panic when a SATA disk timed out responding to a SATA identify command during boot. Submitted by: slm Reviewed by: slm MFC after: 4 weeks Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D9364 Notes: svn path=/head/; revision=312995
* Rework the debug print API. Event printing no longer gets special handling.Scott Long2017-01-194-82/+122
| | | | | | | | | | | | | | | | | All of the printing from the tables file now has wrappers so that the handling is cleaner and it's possible to print something out (say, during development) without having to fight the global debug flags. This re-org will also make it easier to have the tables be compiled out at build time if desired. Other than fixing some minor bugs, there are no user-visible changes from this change Sponsored by: Netflix, Inc. Differential Revision: D9238 Notes: svn path=/head/; revision=312437
* Print out the number of queues/MSIx vectors.Scott Long2017-01-121-0/+1
| | | | | | | Sponsored by: Netflix Notes: svn path=/head/; revision=311958
* 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
* misc minor fixes in mpr(4)Alan Somers2017-01-032-8/+14
| | | | | | | | | | | | | | | | | | | | | sys/dev/mpr/mpr_sas.c * Fix a potential null pointer dereference (CID 1305731) * Check for overrun of the ccb_scsiio.cdb_io.cdb_bytes buffer (CID 1211934) sys/dev/mpr/mpr_sas_lsi.c * Nullify a dangling pointer in mprsas_get_sata_identify * Fix a memory leak in mprsas_SSU_to_SATA_devices (CID 1211935) Reported by: Coverity (partially) CID: 1305731 1211934 1211935 Reviewed by: slm MFC after: 4 weeks Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D8880 Notes: svn path=/head/; revision=311160
* Record the LogInfo field when reporting the IOCStatus. Helps inScott Long2016-11-041-4/+6
| | | | | | | | | | | debugging errors. Submitted by: slm Obtained from: Netflix MFC after: 3 days Notes: svn path=/head/; revision=308301
* Add a fallback to the device mapper logic. We've seen systems in the fieldScott Long2016-11-023-7/+36
| | | | | | | | | | | | | | | that are apparently misconfigured by the manufacturer and cause the mapping logic to fail. The fallback allows drive numbers to be assigned based on the PHY number that they're attached to. Add sysctls and tunables to overrid this new behavior, but they should be considered only necessary for debugging. Reviewed by: imp, smh Obtained from: Netflix MFC after: 3 days Sponsored by: D8403 Notes: svn path=/head/; revision=308217
* Use real values to calculate Max I/O size instead of guessing.Stephen McConnell2016-07-123-6/+31
| | | | | | | | | | Reviewed by: ken, scottl Approved by: ken, scottl, ambrisko (mentors) MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D7043 Notes: svn path=/head/; revision=302673
* Remove NULL checks after M_WAITOK allocations from mpr(4).Edward Tomasz Napierala2016-05-101-38/+13
| | | | | | | | | | Reviewed by: asomers@ MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D6297 Notes: svn path=/head/; revision=299369
* Bump version of mpr driver to 13.00.00.00-fbsdStephen McConnell2016-05-091-1/+1
| | | | | | | | Approved by: ken, scottl, ambrisko MFC after: 1 week Notes: svn path=/head/; revision=299275
* Disks can go missing until a reboot is done in some cases.Stephen McConnell2016-05-091-8/+2
| | | | | | | | | | | | | This is due to the DevHandle not being released, which causes the Firmware to not allow that disk to be re-added. Reviewed by: ken, scottl, ambrisko, asomers Approved by: ken, scottl, ambrisko MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D6102 Notes: svn path=/head/; revision=299274
* done_ccb pointer can be used if it is NULL.Stephen McConnell2016-05-091-3/+3
| | | | | | | | | | | | | To prevent this, move check for done_ccb == NULL to before done_ccb is used in mprsas_stop_unit_done(). Reviewed by: ken, scottl, ambrisko, asomers Approved by: ken, scottl, ambrisko MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D6099 Notes: svn path=/head/; revision=299272
* Use callout_reset_sbt() instead of callout_reset() if FreeBSD ver is >= 1000029Stephen McConnell2016-05-091-0/+5
| | | | | | | | | | Reviewed by: ken, scottl, ambrisko, asomers Approved by: ken, scottl, ambrisko MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D6101 Notes: svn path=/head/; revision=299271
* No need to set the MPRSAS_SHUTDOWN flag because it's never used.Stephen McConnell2016-05-091-1/+0
| | | | | | | | Approved by: ken, scottl, ambrisko MFC after: 1 week Notes: svn path=/head/; revision=299270