History log of /freebsd-10-stable/sys/dev/mpr/mpr.c
Revision Date Author Comments
# 322661 18-Aug-2017 ken

MFC r321502, r321714, r321733, r321737, r321799, r322364:

------------------------------------------------------------------------
r321502 | scottl | 2017-07-25 19:48:13 -0600 (Tue, 25 Jul 2017) | 2 lines

Quiet a message that sounds far more dire than it really is.

------------------------------------------------------------------------
r321714 | scottl | 2017-07-30 00:53:58 -0600 (Sun, 30 Jul 2017) | 13 lines

Split the interrupt setup code into two parts: allocation and configuration.
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

------------------------------------------------------------------------
r321733 | scottl | 2017-07-30 16:34:24 -0600 (Sun, 30 Jul 2017) | 5 lines

Change from using underbar function names to normal function names for
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.

------------------------------------------------------------------------
r321737 | scottl | 2017-07-30 18:05:49 -0600 (Sun, 30 Jul 2017) | 3 lines

Don't re-parse PCI IDs in order to set card-specific flags, use
the flags field in the PCIID table.

------------------------------------------------------------------------
r321799 | scottl | 2017-07-31 10:55:56 -0600 (Mon, 31 Jul 2017) | 4 lines

Fix a logic bug in the split PCI interrupt code that slipped through

Reported by: Harry Schmalzbauer

------------------------------------------------------------------------
r322364 | ken | 2017-08-10 08:59:17 -0600 (Thu, 10 Aug 2017) | 39 lines

Changes to make mps(4) and mpr(4) handle reinit with reallocation.

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
Sponsored by: Spectra Logic

------------------------------------------------------------------------

Approved by: re (marius)


# 321416 24-Jul-2017 ken

MFC r321207:
------------------------------------------------------------------------
r321207 | ken | 2017-07-19 09:39:01 -0600 (Wed, 19 Jul 2017) | 14 lines

Fix spurious timeouts on commands sent to mps(4) and mpr(4) controllers.

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
Sponsored by: Spectra Logic


# 319445 01-Jun-2017 slm

MFC r318895: Fix several problems with mapping code in mps(4).
MFC r318896: Fix several problems with mapping code in mpr(4).

-Add several comments describing what the mapping code is doing.
-Added a callout timer to improve check for missing devices when discovery has
completed so that missing counts are incremented correctly.
-Fix problems with missing counts not being saved to the HBA.
-Update man pages mps(4) and mpr(4) to include a description of the use
use_phy_num sysctl variable.
-Remove channel field in the mapping structure because it's not used.
-Improve logging by using mps_dprint or mpr_dprint instead of printf and adding
more logging where appropriate.
-Add check for a bad index before writing mapping entries to controller.
-The high missing count check in the mapping table was using the incorrect
initial value, which could lead to a bad result.
-The usage of the IN_USE flag for volume mapping was changed to be more
intuitive, and was not being used correctly.
-The check for a free DPM entry was changed, as this was completely wrong.
-Updates to the missing count for volumes were not being done correctly, so this
function was completely rewritten.
-_mapping_add_to_removal_table() was overly complicated and incorrectly used, so
this function was rewritten.
-Missing counts for all devices were not being incremented properly, so this
functionality was added.
-The search for space in the mapping table for missing enclosures was not
calculating the found space correctly due to not breaking out of a loop when
required, and the num_found variable was not being reset when needed.
-Retries when a device fails to get added due to a full mapping table were
removed because this is unneccessary.
-mps_mapping_is_reinit_required() and mpr_mapping_is_reinit_required() were
removed because they were not being used.
-Some functions were renamed to avoid confusion between Target IDs and SAS IDs.
-_mapping_check_update_ir_mt_idx() was removed because it was overly
complicating volume mapping.
-The setting of the maxtargets variable was changed to include max volumes.
-The setting of the initiator_id variable was changed to be the invalid target
ID after all targets, including volumes. Previously, this was set to the last
valid target ID.
-Don't exclude target IDs of RAID components or check for a reuse of a target ID
for RAID components.
-Some endienness was added.

Approved by: ken, mav


# 319436 01-Jun-2017 slm

MFC r286567, r286568, r289426, r289429, r295113, r295286, r299367, r299369,
r308217, r308301, r311958, r312437, r318188, r318427, r318679

r286567:
Remove some unused code.

Obtained from: Netflix, Inx.

r286568:
Remove mps_request_polled(), it's redundant to mps_wait_command()

Obtained from: Netflix, Inc.

r289426:
Remove _FreeBSD_version check for something that was only an issue with
9-CURRENT.

Obtained from: Netlfix, Inc
MFC after: 3 days

r289429:
Revert an extra hunk that crept into the last commit.

Submitted by: emax
Obtained from: Netflix, Inc.
MFC after: 3 days

r295113:
Clean up unused-but-set-variable spotted by gcc-4.9.

Reviewed by: mav, slm
Approved by: rodrigc (mentor)
MFC after: 2 weeks
Sponsored by: gandi.net

r295286:
Add sysctls for dumping out the device mapping tables. I'm finding this
useful for debugging device-target translation bugs.

MFC after: 3 days
Sponsored by: Netflix

r299367:
Remove NULL checks after M_WAITOK allocations from mps(4).

Reviewed by: asomers@
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D6296

r299369:
Remove NULL checks after M_WAITOK allocations from mpr(4).

Reviewed by: asomers@
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D6297

r308217:
Add a fallback to the device mapper logic. We've seen systems in the field
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

r308301:
Record the LogInfo field when reporting the IOCStatus. Helps in
debugging errors.

Submitted by: slm
Obtained from: Netflix
MFC after: 3 days

r311958:
Print out the number of queues/MSIx vectors.

Sponsored by: Netflix

r312437:
Rework the debug print API. Event printing no longer gets special handling.
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

r318188:
Improve error messages during command timeout for the mpr and mps
drivers.

Sponsored by: Netflix

r318427:
Add tri-mode support (SAS/SATA/PCIe).

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

r318679:
Fix powerpc compiler error.

Approved by: ken


# 303089 20-Jul-2016 slm

MFC r302673
Use real values to calculate Max I/O size instead of guessing.

Reviewed by: ken, scottl
Approved by: ken, scottl, ambrisko (mentors)
Differential Revision: https://reviews.freebsd.org/D7043


# 299962 16-May-2016 slm

MFC r299263, r299265, r299266, r299267, r299268, r299269, r299270, r299271,
r299272, r299274, r299275

- (r299263) Update MPI headers to version 42.
- (r299265) Several style changes and add copyrights for 2016.
- (r299266) Add support for the Broadcom (Avago/LSI) 9305 16 and 24 port HBA's.
- (r299267) No log bit in IOCStatus and endian-safe changes.

Use MPI2_IOCSTATUS_MASK when checking IOCStatus to mask off the log bit, and
make a few more things endian-safe.

- (r299268) Change logging level for a debug string to use MPR_LOG instead of
MPR_INFO.

- (r299269) Fix possible use of invalid pointer.

It was possible to use an invalid pointer to get the target ID value. To fix
this, initialize a local Target ID variable to an invalid value and change that
variable to a valid value only if the pointer to the Target ID is not NULL.

- (r299270) No need to set the MPRSAS_SHUTDOWN flag because it's never used.
- (r299271) Use callout_reset_sbt() instead of callout_reset() if FreeBSD ver
is >= 1000029

- (r299272) done_ccb pointer can be used if it is NULL.

To prevent this, move check for done_ccb == NULL to before done_ccb is used in
mprsas_stop_unit_done().

- (r299274) Disks can go missing until a reboot is done in some cases.

This is due to the DevHandle not being released, which causes the Firmware to
not allow that disk to be re-added.

- (r299275) Bump version of mpr driver to 13.00.00.00-fbsd


# 283990 04-Jun-2015 slm

MFC: r283661
- 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 mprssas_async, which gets Advanced Info but not
Inquiry data, the setting of supports_SSU was moved to the
mprsas_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
mprsas_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 mprsas_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 mpr driver to 9.255.01.00-fbsd

PR: 191348


# 273736 27-Oct-2014 hselasky

MFC r263710, r273377, r273378, r273423 and r273455:

- De-vnet hash sizes and hash masks.
- Fix multiple issues related to arguments passed to SYSCTL macros.

Sponsored by: Mellanox Technologies


# 266548 22-May-2014 ken

MFC mpr(4) changes: r265484, r265485, r265709 and r265712

------------------------------------------------------------------------
r265484 | ken | 2014-05-06 23:11:16 -0600 (Tue, 06 May 2014) | 5 lines

Remove some debugging code.

Submitted by: Steve McConnell <stephen.mcconnell@avagotech.com>

------------------------------------------------------------------------
------------------------------------------------------------------------
r265485 | ken | 2014-05-06 23:14:48 -0600 (Tue, 06 May 2014) | 9 lines

Hold the SIM lock when calling xpt_create_path() and xpt_action() in
mprsas_SSU_to_SATA_devices().

This fixes an assertion on shutdown with INVARIANTS enabled with SATA
drives present on an IR firmware controller.

Reviewed by: Steve McConnell <stephen.mcconnell@avagotech.com>.

------------------------------------------------------------------------
------------------------------------------------------------------------
r265709 | ken | 2014-05-08 14:28:22 -0600 (Thu, 08 May 2014) | 15 lines

Fix TLR (Transport Layer Retry) support in the mps(4) and mpr(4) drivers.

TLR is necessary for reliable communication with SAS tape drives.

This was broken by change 246713 in the mps(4) driver. It changed the
cm_data field for SCSI I/O requests to point to the CCB instead of the data
buffer. So, instead, look at the CCB's data pointer to determine whether
or not we're talking to a tape drive.

Also, take the residual into account to make sure that we don't go off the
end of the request.

Sponsored by: Spectra Logic Corporation

------------------------------------------------------------------------
------------------------------------------------------------------------
r265712 | ken | 2014-05-08 14:46:46 -0600 (Thu, 08 May 2014) | 10 lines

Add #ifdefs in the mpr(4) driver so that versions of stable/9 that
have implemented the PIM_NOSCAN rescan functionality will have it
enabled.

This is a no-op for head.

Reviewed by: slm
Sponsored by: Spectra Logic Corporation

------------------------------------------------------------------------

Sponsored by: Spectra Logic, Avago


# 283990 04-Jun-2015 slm

MFC: r283661
- 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 mprssas_async, which gets Advanced Info but not
Inquiry data, the setting of supports_SSU was moved to the
mprsas_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
mprsas_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 mprsas_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 mpr driver to 9.255.01.00-fbsd

PR: 191348


# 273736 27-Oct-2014 hselasky

MFC r263710, r273377, r273378, r273423 and r273455:

- De-vnet hash sizes and hash masks.
- Fix multiple issues related to arguments passed to SYSCTL macros.

Sponsored by: Mellanox Technologies


# 266548 22-May-2014 ken

MFC mpr(4) changes: r265484, r265485, r265709 and r265712

------------------------------------------------------------------------
r265484 | ken | 2014-05-06 23:11:16 -0600 (Tue, 06 May 2014) | 5 lines

Remove some debugging code.

Submitted by: Steve McConnell <stephen.mcconnell@avagotech.com>

------------------------------------------------------------------------
------------------------------------------------------------------------
r265485 | ken | 2014-05-06 23:14:48 -0600 (Tue, 06 May 2014) | 9 lines

Hold the SIM lock when calling xpt_create_path() and xpt_action() in
mprsas_SSU_to_SATA_devices().

This fixes an assertion on shutdown with INVARIANTS enabled with SATA
drives present on an IR firmware controller.

Reviewed by: Steve McConnell <stephen.mcconnell@avagotech.com>.

------------------------------------------------------------------------
------------------------------------------------------------------------
r265709 | ken | 2014-05-08 14:28:22 -0600 (Thu, 08 May 2014) | 15 lines

Fix TLR (Transport Layer Retry) support in the mps(4) and mpr(4) drivers.

TLR is necessary for reliable communication with SAS tape drives.

This was broken by change 246713 in the mps(4) driver. It changed the
cm_data field for SCSI I/O requests to point to the CCB instead of the data
buffer. So, instead, look at the CCB's data pointer to determine whether
or not we're talking to a tape drive.

Also, take the residual into account to make sure that we don't go off the
end of the request.

Sponsored by: Spectra Logic Corporation

------------------------------------------------------------------------
------------------------------------------------------------------------
r265712 | ken | 2014-05-08 14:46:46 -0600 (Thu, 08 May 2014) | 10 lines

Add #ifdefs in the mpr(4) driver so that versions of stable/9 that
have implemented the PIM_NOSCAN rescan functionality will have it
enabled.

This is a no-op for head.

Reviewed by: slm
Sponsored by: Spectra Logic Corporation

------------------------------------------------------------------------

Sponsored by: Spectra Logic, Avago