freebsd-nq/sys/dev/mps
Kenneth D. Merry 6d4ffcb4ac 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
MFC after:	1 week
Sponsored by:	Spectra Logic
2017-08-10 14:59:17 +00:00
..
mpi
mps_config.c Changes to make mps(4) and mpr(4) handle reinit with reallocation. 2017-08-10 14:59:17 +00:00
mps_ioctl.h
mps_mapping.c
mps_mapping.h
mps_pci.c Fix a logic bug in the split PCI interrupt code that slipped through 2017-07-31 16:55:56 +00:00
mps_sas_lsi.c Changes to make mps(4) and mpr(4) handle reinit with reallocation. 2017-08-10 14:59:17 +00:00
mps_sas.c Changes to make mps(4) and mpr(4) handle reinit with reallocation. 2017-08-10 14:59:17 +00:00
mps_sas.h
mps_table.c Change from using underbar function names to normal function names for 2017-07-30 22:34:24 +00:00
mps_table.h Change from using underbar function names to normal function names for 2017-07-30 22:34:24 +00:00
mps_user.c Changes to make mps(4) and mpr(4) handle reinit with reallocation. 2017-08-10 14:59:17 +00:00
mps.c Changes to make mps(4) and mpr(4) handle reinit with reallocation. 2017-08-10 14:59:17 +00:00
mpsvar.h Changes to make mps(4) and mpr(4) handle reinit with reallocation. 2017-08-10 14:59:17 +00:00