aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/mpi3mr
Commit message (Collapse)AuthorAgeFilesLines
* chore: replace {0, 0} with {DEV,KOBJ}METHOD_ENDEnji Cooper2026-02-251-1/+1
| | | | | | | | | | | | | | Both of the aforementioned macros have been present in FreeBSD for well over a decade: 2009 for `KOBJMETHOD_END`; 2011 for `DEVMETHOD_END`. Adapt all hardcoded references of `{0, 0}` with `DEVMETHOD_END` and `KOBJMETHOD_END` as appropriate. This helps ensure that future adaptations to drivers following patterns documented in driver(9) can be made more easily/without issue. MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D55414
* mpi3mr: Get rid of a supurious printfWarner Losh2025-09-141-2/+3
| | | | | | | | | | If we have outstanding tractions and then poll and still have outstanding transactions, we print a warning. However, we print the warning, confusingly, even if there's 0 left. Enclose the two statements in {} to avoid this relatively harmless effect and quiet gcc12's indentation complaint. Sponsored by: Netflix
* mpi3mr: Build with gcc12 by being more explicit about conditionsWarner Losh2025-09-141-3/+3
| | | | | | | | | | | | | | Help the flow analysis in gcc12 by initializing scsi_reply to NULL and testing it along with sense_buf. Sense buf should be non-null only in this code path, but might also be non-null if the PA for is somehow set to zero. I debated adding an assert for the latter, but opted to instead preserve existing behavior. Also set host_diagnostic to 0. gcc12 can't quite realize that we only test it after we've been through this loop at least once to report an error condition. Initialize to 0 to avoid a diagnostic. Sponsored by: Netflix
* mpr3mr: Fix missing bracesWarner Losh2025-09-141-1/+2
| | | | | | | | We detect an error condiction and print it. And then unconditionally jump to the err code, which is incorrect. It's clear from indentation and code tracing there should be braces here. Sponsored by: Netflix
* machine/stdarg.h -> sys/stdarg.hBrooks Davis2025-06-111-2/+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
* mpi3mr: modified the log messages to be on a single lineChandrakanth patil2025-04-281-7/+4
| | | | | | | | | qThis change was made after feedback from upstream, aiming to align with the style guide for consistent log formatting. No functional changes were made to the driver, only the formatting of the log messages. Reviewed by: ssaxena, imp Differential Revision: https://reviews.freebsd.org/D49799
* mpi3mr: Update Driver Version to 8.14.0.2.0Chandrakanth patil2025-04-281-2/+2
| | | | | | | | | The driver version has been updated to 8.14.0.2.0 to reflect the latest release. This is a version-only update with no functional code changes. Reviewed by: ssaxena, imp Differential Revision: https://reviews.freebsd.org/D49753
* mpi3mr: Update Copyright Year to 2025Chandrakanth patil2025-04-287-7/+7
| | | | | | | | All driver source files have been updated to reflect the year 2025. This change is cosmetic and does not affect functionality. Reviewed by: ssaxena, imp Differential Revision: https://reviews.freebsd.org/D49752
* mpi3mr: Process LOG Data Events in Interrupt Top Half for Early NotificationChandrakanth patil2025-04-282-14/+6
| | | | | | | | | | | | | | The driver now processes LOG Data events in the interrupt top half instead of the bottom half. This allows LOG events to be handled immediately upon receipt, reducing latency and enabling early notification to the Library or applications. This change ensures LOG event handling occurs closer to the firmware's generation point, improving alignment with event-driven diagnostic and monitoring mechanisms. Reviewed by: ssaxena, imp Differential Revision: https://reviews.freebsd.org/D49751
* mpi3mr: Enable Diag Save for All Diagnostic Fault CasesChandrakanth patil2025-04-281-2/+9
| | | | | | | | | | | | | This patch ensures the driver sets the Diag Save bit for all diagnostic fault conditions before issuing a Diagnostic Fault Reset. The firmware now incorporates logic to manage snapdump saving and requires the driver to always set the Diag Save bit to enable this feature. This change supports improved diagnostic data collection and fault handling. Reviewed by: ssaxena, imp Differential Revision: https://reviews.freebsd.org/D49750
* mpi3mr: Block I/Os While Task Management is in ProgressChandrakanth patil2025-04-281-0/+17
| | | | | | | | | | | | | | | | | | | | The driver previously blocked I/Os only for OS-initiated task management commands. This patch extends the behavior to also block I/Os during application-initiated task management operations (excluding Task Abort). Before submitting such commands to the firmware, I/O submissions are paused for the respective device. Once the command completes, I/O operations are resumed. This ensures safe and consistent task management handling. [[ Note: Warner landed this with the pending suggestion since this change is good enough for 14.3, but chs' suggestion for better atomics needs to be implemented soon ]] Discussed with: imp, chs Differential Revision: https://reviews.freebsd.org/D49749
* mpi3mr: Add NVData Parameter for Host Timestamp SynchronizationChandrakanth patil2025-04-283-2/+362
| | | | | | | | | | | | The driver now retrieves the Time Stamp value from Driver Page 1 during load and after controller reset. If the value is valid, it is used to enable periodic host timestamp synchronization. This adds a tunable NVData parameter to control the behavior of host time sync, enhancing flexibility and platform-specific control. Reviewed by: ssaxena, imp Differential Revision: https://reviews.freebsd.org/D49748
* mpi3mr: Handle Insufficient Power Fault CodeChandrakanth patil2025-04-281-11/+39
| | | | | | | | | | | | | | | The driver now checks for insufficient power faults during the load phase and immediately fails initialization instead of retrying. Additionally, if an insufficient power fault is detected by the watchdog after the controller is up, the controller is marked as unrecoverable instead of triggering a reset. This improves fault handling and avoids unnecessary recovery attempts in low-power conditions. Reviewed by: ssaxena, imp Differential Revision: https://reviews.freebsd.org/D49747
* mpi3mr: Enhance Controller Enable Retry Logic in Host DriversChandrakanth patil2025-04-281-98/+118
| | | | | | | | | | | | | | | This patch improves the retry logic during the IOC enable process. If a controller faults or if the reset history bit is detected during the ready status check, the driver will retry initialization up to three times or until 510 seconds have passed. A soft reset will also be issued if the controller is detected while waiting for the ready status. This enhances reliability during controller initialization. Reviewed by: ssaxena, imp Differential Revision: https://reviews.freebsd.org/D49746
* mpi3mr: Set Driver Capability for OS Exposure in IOCInitChandrakanth patil2025-04-281-1/+1
| | | | | | | | | This patch updates the driver to set the OSExposure field in DriverCapability during IOCInit to MPI3_IOCINIT_DRIVERCAP_OSEXPOSURE_NO_SPECIAL(0x1), aligning with the latest MPI specification version 36. Reviewed by: ssaxena, imp Differential Revision: https://reviews.freebsd.org/D49745
* mpi3mr: Update MPI Header to Version 36Chandrakanth patil2025-04-2812-46/+336
| | | | | | | | | Updated the MPI header files to version 36 to align with the latest MPI specification. This includes updated structures, field definitions, and constants required for compatibility with updated firmware. Reviewed by: ssaxena, imp Differential Revision: https://reviews.freebsd.org/D49743
* mpi3mr: configure larger max I/O size if the HBA firmware supports itChuck Silvers2025-04-234-10/+41
| | | | | | | | | | | | | | The max I/O size that an mpi3mr HBA supports is reported in the IOCFacts structure (with 0 representing the legacy max I/O size of 1 MB). By default, set the max I/O size of devices attached to mpi3mr controllers to the smaller of the HBA's max I/O size and the kernel's maxphys. Allow this default to be overriden by a global tunable "hw.mpi3mr.max_sgl_entries" or by a per-controller tunable "dev.mpi3mr.N.max_sgl_entries". Sponsored by: Netflix Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D49090
* mpi3mr: Remove a stray semicolonZhenlei Huang2024-10-241-1/+1
| | | | MFC after: 1 week
* mpi3mr(4): Stop checking for failures from malloc(M_WAITOK)Zhenlei Huang2024-09-031-6/+0
| | | | | MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D45852
* mpi3mr: Track IO per target counter during queue poll with local variableChandrakanth patil2024-06-061-10/+12
| | | | | | Reviewed by: imp Approved by: imp Differential revision: https://reviews.freebsd.org/D44494
* mpi3mr: Divert large WriteSame IOs to firmware if unmap and ndob bits are setChandrakanth patil2024-06-064-0/+54
| | | | | | | | | | | Firmware advertises the transfer lenght for writesame commands to driver during init. So for any writesame IOs with ndob and unmap bit set and transfer lengh is greater than the max write same length specified by the firmware, then direct those commands to firmware instead of hardware otherwise hardware will break. Reviewed by: imp Approved by: imp Differential revision: https://reviews.freebsd.org/D44452
* mpi3mr: driver version update to 8.10.0.1.0Chandrakanth patil2024-06-061-2/+2
| | | | | | Reviewed by: imp Approved by: imp Differential revision: https://reviews.freebsd.org/D44430
* mpi3mr: copyright year update to 2024Chandrakanth patil2024-06-067-7/+7
| | | | | | Reviewed by: imp Approved by: imp Differential revision: https://reviews.freebsd.org/D44429
* mpi3mr: mpi headers update to latestChandrakanth patil2024-06-0614-160/+251
| | | | | | Reviewed by: imp Approved by: imp Differential revision: https://reviews.freebsd.org/D44428
* mpi3mr: Adding FreeBSD OS Type to Fault/Reset Reason CodeChandrakanth patil2024-06-063-13/+25
| | | | | | | | | The driver is modified to add FreeBSD OS type in the upper nibble of the fault/reset reason code for appropriate qualification of the reason code. Reviewed by: imp Approved by: imp Differential revision: https://reviews.freebsd.org/D44427
* mpi3mr: diag fault success beyond F000 fault codeChandrakanth patil2024-06-061-6/+2
| | | | | | | | | Accept any fault as successful for diagnostic fault reset, not just the 0xF000 code. print fault information and return. Reviewed by: imp Approved by: imp Differential revision: https://reviews.freebsd.org/D44426
* mpi3mr: Update consumer index of admin and operational reply queues after ↵Chandrakanth patil2024-06-062-1/+15
| | | | | | | | | | | | every 100 replies Instead of updating the ConsumerIndex of the Admin and Operational ReplyQueues after processing all replies in the queue, it will now be periodically updated after processing every 100 replies. Reviewed by: imp Approved by: imp Differential revision: https://reviews.freebsd.org/D44425
* mpi3mr: Decrement per controller and per target counter post resetChandrakanth patil2024-06-062-12/+2
| | | | | | | | | | | | | Post controller reset, If any device removal events arrive, and if there are any outstanding IOs then the driver will unnecessarily wait in the loop for 30 seconds before removing the device from the OS. reset target outstanding IO counter and controller outstanding IO counter and remove the redundant wait loop. Reviewed by: imp Approved by: imp Differential revision: https://reviews.freebsd.org/D44424
* mpi3mr: poll reply queue and add MPI3MR_DEV_REMOVE_HS_COMPLETED flagChandrakanth patil2024-06-063-22/+27
| | | | | | | | | | | | | | | | An outstanding IO counter per target check has been added before deleting the target from the OS which will poll the reply queue if there are any outstanding IOs are found. A new flag, named "MPI3MR_DEV_REMOVE_HS_COMPLETED," is added. If a remove event for a target occurs and before the deletion of the target resource if the add event for another target arrives reusing the same target ID then this flag will prevent the removal of the target reference. This flag ensures synchronization between the interrupt top and bottom half during target removal and addition events. Reviewed by: imp Approved by: imp Differential revision: https://reviews.freebsd.org/D44423
* mpi3mr: Controller state check before enabling PELChandrakanth patil2024-06-061-0/+12
| | | | | | Reviewed by: imp Approved by: imp Differential revision: https://reviews.freebsd.org/D44422
* mpi3mr: Block devices persist despite being offlined during resetChandrakanth patil2024-06-061-0/+2
| | | | | | | | | The driver removes the drive from the OS if firmware sends 'device added' event with hidden bit or inaccessible status. Reviewed by: imp Approved by: imp Differential revision: https://reviews.freebsd.org/D44421
* mpi3mr: Fix confusion over | and &Warner Losh2024-01-291-2/+2
| | | | | | | | Use sc->mpi3mr_debug & MPI3MR_IOT over the | version to test if a bit is set. CID: 1529718 Sponsored by: Netflix
* mpi3mr: add missing terminator entry to mpi3mr_identifiers arrayChuck Silvers2024-01-191-0/+1
| | | | | | | Reported by: KASAN Sponsored by: Netflix Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D43519
* mpi3mr: Check for copyin errors in mpi3mr_map_data_buffer_dma()Mark Johnston2023-12-261-1/+10
| | | | | | | | | | | | | A failed copyin will cause the driver to use the contents of uninitialized buffers instead, which is unlikely to be the behaviour that we want. Check for errors. This is in preparation for annotating copyin() and related functions with __result_use_check. Reviewed by: imp MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D43098
* mpi3mr: Minor tweak to task queue pausingWarner Losh2023-11-291-5/+8
| | | | | | | | Use a while loop with cancel / drain to make sure that all tasks have completed before proceeding to reset. Suggested by: jhb Sponsored by: Netflix
* mpi3mr: Assume dma_hiaddr is BUS_SPACE_MAXADDRWarner Losh2023-11-293-26/+24
| | | | | | | | | No sense having a variable for this. So use BUS_SPACE_MAXADDR and remove dma_hiaddr from softc. Suggested by: jhb Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D42808
* mpi3mr: Replace can't happen DataLength == 0 with an assertWarner Losh2023-11-291-12/+6
| | | | | | | | Replace the test for DataLength == 0 with an assert. It can't happen, but an assert doesn't hurt. Emacs removed some trailing white space too. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D42807
* mpi3mr: Use template for main busdma tag.Alexander Motin2023-11-291-12/+4
| | | | | | | | Use the simpler template code for the parent busdma tag for all I/O to this card. Reviewed by: mav, jhb, imp Differential Revision: https://reviews.freebsd.org/D42607
* mpi3mr: Make these bus_dmamap_load calls synchronousAlexander Motin2023-11-292-17/+18
| | | | | | | | | | | | These calls "should" all be synchrounous. There's no bouncing that's needed for them (at least in the typical case that we have a sane card that has more bits of dma addresses decoded than we have memory), so there's no errors possible. Ensure these calls are really synchronous with BUS_DMA_NOWAIT flags (which should never fail now that the bus_dmamem_alloc() has succeeded). Reviewed by: mav, jhb, imp Differential Revision: https://reviews.freebsd.org/D42606
* mpi3mr: Fix MAXPHYS usageAlexander Motin2023-11-291-2/+2
| | | | | | | | This usage is obsolete. Replace with maximum bus space size. maxphys will sort itself out at higher levels. Reviewed by: mav, jhb, imp Differential Revision: https://reviews.freebsd.org/D42605
* mpi3mr: Add firmware versionWarner Losh2023-11-293-8/+14
| | | | | | | | Publish the firmware version on the card like we do for mps/mpr. Sponsored by: Netflix Reviewed by: mav Differential Revision: https://reviews.freebsd.org/D42588
* mpi3mr: Trivial trailing white space reductionWarner Losh2023-11-295-63/+64
| | | | Sponsored by: Netflix
* mpi3mr: Honor the dma mask from IOCFactsWarner Losh2023-11-292-0/+37
| | | | | | | | | | | | | | | | | | | | The number of signficant bits that are decoded are returned in the flags field of the IOCFacts structure from the device. Rather than assume the worst with a pessimal 32-bit maximum, look at this value and pass it along to all the dma map creation requests. A lof of those creations are repetitive and could just inherit from the base tag if we moved to the templated interface. This is called out as desireable future work not done at this time. In addition, due to a chicken and an egg problem, we have to allocate some of the maps with a 32-bit loaddr. These are the ones we need to read iocfacts. And they are fine to be so restricted: they are little used after startup, and when they are used, bouncing is fine. Sponsored by: Netflix Reviewed by: mav Differential Revision: https://reviews.freebsd.org/D42559
* mpi3mr: Fix EINPROGRESS errors hanging the cardWarner Losh2023-11-292-58/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move enqueueing of commands to bus_dmamap_load_ccb callback Fix fundamental difference between FreeBSD and Linux. On Linux, your dma load callback always happends before it returns, so drivers are written to load the map, then submit to hardware. On FreeBSD, the callback may be deferred and return EINPROGRESS. This means the callback is responsible for queueing the request to the hardware is done after the SGL list is created. Make a number of interrelated cahnages: At the end of mpi3mr_prepare_sgls, add a call to mpi3mr_enqueue_request. Split the hardware submission out from the end of mpi3mr_action_scsiio and move it into a new routine mpi3mr_enqueue_request. Move all error completion from the end of mpi3mr_action_scsiio to where the error is detected. We cannot pass errors back from the mpi3mr_enqueue_request to do this on a 'failed' mpi3mr in a centralized place (since it has to be fire and forget). Add comments about zero length SGLs never making it into mpi3mr_prepare_sgls. Keep the code there for the moment, but we only set cm->data to non-NULL when scsiio_req->DataLength is not zero. So the datalength can't be zero and we can't send the zero SGLs. Add commentts about other "impossible" tests in mpi3mr_prepare_sgls that really should be simple asserts of some flavor. Eliminate cm->error_code, since we can't pass data back from the mpi3mr_prepare_sgl callback anymore. In mpi3mr_map_request, call mpi3mr_enqueue_request for the no data case. This seems to work even though we've not done the special zero length handling that was in mpi3mr_prepare_sgls, giving further evidence to it not actually being needed. This is needed for SCSI CDBs that have no data to pass to the drive like TEST UNIT READY. With this change, and the prior ones, we're now able to run with mpi3mr on 128GB systems and very heavy disk load (so many buffers land > 4GB: the driver instructs busdma to never use memory abouve 4GB, which may be too conservative, but an issue for another time). Sponsored by: Netflix Reviewed by: sumit.saxena_broadcom.com, mav, jhb Differential Revision: https://reviews.freebsd.org/D42543
* mpi3mr: Cleaup setting of status in processing scsiio requestsWarner Losh2023-11-291-8/+7
| | | | | | | | | | | | | | More uniformly use mpi3mr_set_ccbstatus in mpi3mr_action_scsiio. The routine mostly used it, but also has setting of status by hand. In those cases where we want to error out the request, use this routine. As part of this, move setting CAM_SIM_QUEUED later in the function to when we're sure it's been queued. Remove the places we clear it before this. Sponsored by: Netflix Reviewed by: mav, jhb Differential Revision: https://reviews.freebsd.org/D42542
* mpi3mr: Only set callout_owned when we create a timeoutWarner Losh2023-11-291-3/+3
| | | | | | | | | | Since we assume there's a timeout to cancel when this is true, only set it true when we set the timeout. Otherwise we may try to cancel a timeout when there's been an error in submission. Sponsored by: Netflix Reviewed by: mav Differential Revision: https://reviews.freebsd.org/D42541
* mpi3mr: Minor style fixWarner Losh2023-11-291-2/+1
| | | | | | | | Fold two lines to make this more readable. Sponsored by: Netflix Reviewed by: mav, jhb Differential Revision: https://reviews.freebsd.org/D42540
* mpi3mr: Reduce the scope of the reset_mutextWarner Losh2023-11-292-10/+20
| | | | | | | | | | | | | | | | | | Reduce the scope of reset_mutext to protect the msleep in the watch dog thread as well as the MPI3MR_FLAGS_SHUTDOWN bit. Use it to protect the wakeup in mpi3mr_detach so this thread can exit sooner when we're trying to do an orderly shutdown. Optimize the flow to check the sleep and other conditions before going to sleep. It's an open question if this should protect sc->unrecoverable, and if we should wakeup the watchdog thread when we set it. We might also want to move too booleans for the three flags that we have now in mpi3mr_flags. There are a number of U8s that should really be bools and we might want to also group them together to pack softc better. Sponsored by: Netflix Reviewed by: mav Differential Revision: https://reviews.freebsd.org/D42539
* mpi3mr: Remove unused fields in struct mpi3mr_cmdWarner Losh2023-11-292-9/+0
| | | | | | | | | | All of these fields are either unused, or just initialized. Remove them. This saves about 1MB of memory for the cards that I have which can do 8k transactions at once. Sponsored by: Netflix Reviewed by: mav, jhb Differential Revision: https://reviews.freebsd.org/D42538
* mpi3mr: Don't hold fwevt_lock over call to taskqueue_drainWarner Losh2023-11-291-5/+7
| | | | | | | | | | | | | | | | | | | | | | | Holding fwevt_lock when we call taskqueue_drain can lead to deadlock because it's draining a queue needs fwevt_lock to do work, so that other thread will try to take out the lock and block, making the thread never finish and taskqueue_drain never complete. There's a witness warning/error for this which was exposed when the lock was converted to a MTX_DEF lock from a MTX_SPIN prior to committing to the FreeBSD tree. The lock appears to be to protect against additional items being added to the event list while we're doing a reset. Since the taskqueue is blocked, items can get added to the list, but won't be processed during the reset, but there is still a (likely small) race between the taskqueue_drain and the taskqueue_block calls where an interrupt could fire on another CPU, resulting in a task being enqueued and started before the block can take effect. The only way to fix that race is to turn off interrupt processing during a reset. So we replace a deadlock with a smaller race. Sponsored by: Netflix Reviewed by: sumit.saxena_broadcom.com, mav, jhb Differential Revision: https://reviews.freebsd.org/D42537