HomeFreeBSD

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

Description

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

Details

Provenance
kenAuthored on
Reviewer
scottl
Parents
rS322363: Purge deprecated locking macros.
Branches
Unknown
Tags
Unknown