aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/mpr/mpr_user.c
Commit message (Collapse)AuthorAgeFilesLines
* Refine the busdma template interface. Provide tools for filling in fieldsScott Long2020-09-141-4/+4
| | | | | | | | | | that can be extended, but also ensure compile-time type checking. Refactor common code out of arch-specific implementations. Move the mpr and mps drivers to this new API. The template type remains visible to the consumer so that it can be allocated on the stack, but should be considered opaque. Notes: svn path=/head/; revision=365706
* mpr: clean up empty lines in .c and .h filesMateusz Guzik2020-09-011-3/+2
| | | | Notes: svn path=/head/; revision=365204
* mpr(4), mps(4): Stop checking for failures from malloc(M_WAITOK).Mark Johnston2020-07-271-7/+0
| | | | | | | | | | | PR: 240545 Submitted by: Andrew Reiter <arr@watson.org> Reviewed by: imp MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D25766 Notes: svn path=/head/; revision=363608
* Centralize compatability translation macros.Brooks Davis2020-04-141-10/+1
| | | | | | | | | | | | | | | | 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
* Convert the mpr driver to use busdma templates.Scott Long2019-12-241-11/+6
| | | | Notes: svn path=/head/; revision=356052
* Fix busy status leak in case of incorrect passthrough args.Alexander Motin2019-05-301-2/+4
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=348417
* Fix whitespace from r342528Scott Long2018-12-311-3/+2
| | | | Notes: svn path=/head/; revision=342659
* Update copyright informationKashyap D Desai2018-12-261-2/+3
| | | | | | | | | | | Submitted by: Sreekanth Reddy <sreekanth.reddy@broadcom.com> Reviewed by: Kashyap Desai <Kashyap.Desai@broadcom.com> Approved by: ken MFC after: 3 days Sponsored by: Broadcom Inc Notes: svn path=/head/; revision=342535
* Copy back the Sense data at proper location expected by the applicationKashyap D Desai2018-12-261-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | typedef struct mps_pass_thru { uint64_t PtrRequest; uint64_t PtrReply; uint64_t PtrData; uint32_t RequestSize; uint32_t ReplySize; uint32_t DataSize; uint32_t DataDirection; uint64_t PtrDataOut; uint32_t DataOutSize; uint32_t Timeout; } mps_pass_thru_t, * ptrmpssas_pass_thru_t; In the above mps_pass_thru structure; Application expects PrtReply buffer should contain both MPI reply followed by sense data. So, updated driver to copy sense data at PtrReply + sizeof(MPI2 reply) location where application wants the driver to copy back the sense data info. Submitted by: Sreekanth Reddy <sreekanth.reddy@broadcom.com> Reviewed by: Kashyap Desai <Kashyap.Desai@broadcom.com> Approved by: ken MFC after: 3 days Sponsored by: Broadcom Inc Notes: svn path=/head/; revision=342528
* First step in refactoring and fixing the error recovery and task managementScott Long2018-12-241-2/+0
| | | | | | | | code in the mpr and mps drivers. Eliminate duplicated code and fix some comments. Notes: svn path=/head/; revision=342386
* Move most of the contents of opt_compat.h to opt_global.h.Brooks Davis2018-04-061-2/+0
| | | | | | | | | | | | | | | | | | | | | opt_compat.h is mentioned in nearly 180 files. In-progress network driver compabibility improvements may add over 100 more so this is closer to "just about everywhere" than "only some files" per the guidance in sys/conf/options. Keep COMPAT_LINUX32 in opt_compat.h as it is confined to a subset of sys/compat/linux/*.c. A fake _COMPAT_LINUX option ensure opt_compat.h is created on all architectures. Move COMPAT_LINUXKPI to opt_dontuse.h as it is only used to control the set of compiled files. Reviewed by: kib, cem, jhb, jtl Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D14941 Notes: svn path=/head/; revision=332122
* Update mpr(4) driver from v15 to v18 from Broadcom site.Alexander Motin2018-03-191-1/+4
| | | | | | | | | | | | | | Version 16 is just a number bump, since we already had those changes. Version 17 introduces new AdapterType value, that allows new user-space tools from Broadcom to differentiate adapter generations 3 and 3.5. Version 18 updates headers and adds SAS_DEVICE_DISCOVERY_ERROR reporting. MFC after: 2 weeks Notes: svn path=/head/; revision=331228
* Cache the value of the request and reply frame size since it's used quiteScott Long2018-02-061-3/+3
| | | | | | | | | | | 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
* Diagnostic buffer fixes for the mps(4) and mpr(4) drivers.Kenneth D. Merry2018-02-061-14/+118
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Start overhauling debug printing in the MPS and MPR drivers. The focus of thisScott Long2017-08-271-4/+4
| | | | | | | | | | | 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-101-18/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 several problems with mapping code.Stephen McConnell2017-05-251-1/+1
| | | | | | | | | | 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
* Add tri-mode support (SAS/SATA/PCIe).Stephen McConnell2017-05-171-7/+75
| | | | | | | | | | | | | | | | | | | | 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
* 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
* No log bit in IOCStatus and endian-safe changes.Stephen McConnell2016-05-091-6/+9
| | | | | | | | | | | | | Use MPI2_IOCSTATUS_MASK when checking IOCStatus to mask off the log bit, and make a few more things endian-safe. Reviewed by: ken, scottl, ambrisko, asomers Approved by: ken, scottl, ambrisko MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D6097 Notes: svn path=/head/; revision=299267
* Several style changes and add copyrights for 2016.Stephen McConnell2016-05-091-23/+21
| | | | | | | | | | Reviewed by: ken, scottl, ambrisko, asomers Approved by: ken, scottl, ambrisko MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D6103 Notes: svn path=/head/; revision=299265
* The wrong commit message was given with r283632. This is the correct message.Stephen McConnell2015-05-281-12/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Updated all files with 2015 Avago copyright, and updated LSI's copyright dates. - Changed all of the PCI device strings from LSI to Avago Technologies (LSI). - Added a sysctl variable to control how StartStopUnit behavior works. User can select to spin down disks based on if disk is SSD or HDD. - Inquiry data is required to tell if a disk will support SSU at shutdown or not. Due to the addition of mpssas_async, which gets Advanced Info but not Inquiry data, the setting of supports_SSU was moved to the mpssas_scsiio_complete function, which snoops for any Inquiry commands. And, since disks are shutdown as a target and not a LUN, this process was simplified by basing it on targets and not LUNs. - Added a sysctl variable that sets the amount of time to retry after sending a failed SATA ID command. This helps with some bad disks and large disks that require a lot of time to spin up. Part of this change was to add a callout to handle timeouts with the SATA ID command. The callout function is called mpssas_ata_id_timeout(). (Fixes PR 191348) - Changed the way resets work by allowing I/O to continue to devices that are not currently under a reset condition. This uses devq's instead of simq's and makes use of the MPSSAS_TARGET_INRESET flag. This change also adds a function called mpssas_prepare_tm(). - Some changes were made to reduce code duplication when getting a SAS address for a SATA disk. - Fixed some formatting and whitespace. - Bump version of mps driver to 9.255.01.00-fbsd PR: 191348 Reviewed by: ken, scottl Approved by: ken, scottl MFC after: 1 week Notes: svn path=/head/; revision=283661
* The wrong commit message was given with r283632. To get the correct commitStephen McConnell2015-05-281-29/+12
| | | | | | | | | | | message synced to the changes in r283632, those changes are now backed out. Another commit will be done that is exactly the same as r283632 except it will have to correct commit message. Approved by: ken, scottl, asomers, gibbs Notes: svn path=/head/; revision=283660
* This setting of stop_at_shutdown should have been removed with r279253Stephen McConnell2015-05-271-12/+29
| | | | | | | | Approved by: ken MFC after: 1 week Notes: svn path=/head/; revision=283632
* Change the device name for mpr(4) from /dev/mpr_N to /dev/mprN.Kenneth D. Merry2014-05-061-1/+1
| | | | | | | | | | This is more consistent with the existing mps(4) behavior. Reviewed by: Steve McConnell <stephen.mcconnell@avagotech.com> MFC after: 3 days Notes: svn path=/head/; revision=265473
* Bring in the mpr(4) driver for LSI's MPT3 12Gb SAS controllers.Kenneth D. Merry2014-05-021-0/+2453
This is derived from the mps(4) driver, but it supports only the 12Gb IT and IR hardware including the SAS 3004, SAS 3008 and SAS 3108. Some notes about this driver: o The 12Gb hardware can do "FastPath" I/O, and that capability is included in this driver. o WarpDrive functionality has been removed, since it isn't supported in the 12Gb driver interface. o The Scatter/Gather list handling code is significantly different between the 6Gb and 12Gb hardware. The 12Gb boards support IEEE Scatter/Gather lists. Thanks to LSI for developing and testing this driver for FreeBSD. share/man/man4/mpr.4: mpr(4) man page. sys/dev/mpr/*: mpr(4) driver files. sys/modules/Makefile, sys/modules/mpr/Makefile: Add a module Makefile for the mpr(4) driver. sys/conf/files: Add the mpr(4) driver. sys/amd64/conf/GENERIC, sys/i386/conf/GENERIC, sys/mips/conf/OCTEON1, sys/sparc64/conf/GENERIC: Add the mpr(4) driver to all config files that currently have the mps(4) driver. sys/ia64/conf/GENERIC: Add the mps(4) and mpr(4) drivers to the ia64 GENERIC config file. sys/i386/conf/XEN: Exclude the mpr module from building here. Submitted by: Steve McConnell <Stephen.McConnell@lsi.com> MFC after: 3 days Tested by: Chris Reeves <chrisr@spectralogic.com> Sponsored by: LSI, Spectra Logic Relnotes: LSI 12Gb SAS driver mpr(4) added Notes: svn path=/head/; revision=265236