opnsense-src/sys
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
..
amd64 Split identify_cpu() into two functions for amd64 as we do for i386. This 2017-08-09 18:09:09 +00:00
arm Enable pl310 coherent operation in platform init for Armada 38x 2017-08-09 01:25:47 +00:00
arm64 Mark each cpu in the appropriate cpuset_domain set. This allows devices to 2017-08-05 20:57:34 +00:00
boot Support for v1.10 (latest) of RISC-V privilege specification. 2017-08-10 14:18:09 +00:00
bsm Commit the 64-bit inode project. 2017-05-23 09:29:05 +00:00
cam Do not loose CCB flags after r320493. 2017-08-09 09:13:15 +00:00
cddl MFV r322242: 8373 TXG_WAIT in ZIL commit path 2017-08-08 11:26:03 +00:00
compat Use integer type to pass around jiffies and/or ticks values in the 2017-08-10 13:05:40 +00:00
conf Support for v1.10 (latest) of RISC-V privilege specification. 2017-08-10 14:18:09 +00:00
contrib Fix matchcing of NATed ICMP queries (resolving NATed MTU discovery). 2017-08-05 00:28:42 +00:00
crypto Remove register keyword from sys/ and ANSIfy prototypes 2017-05-17 00:34:34 +00:00
ddb Include opt files in the kernel with "" instead of <>. 2017-07-10 05:08:01 +00:00
dev Changes to make mps(4) and mpr(4) handle reinit with reallocation. 2017-08-10 14:59:17 +00:00
fs Bump the maximum file name length in pseudofs filesystems to 48. 2017-08-03 21:35:53 +00:00
gdb
geom Also provide a warning for geom_fox. 2017-08-09 16:37:37 +00:00
gnu Update DTS files from Linux 4.12 2017-07-09 13:53:32 +00:00
i386 Split identify_cpu() into two functions for amd64 as we do for i386. This 2017-08-09 18:09:09 +00:00
isa Protect access to the AT realtime clock with its own mutex. 2017-07-12 02:42:57 +00:00
kern Plug uninitialized stack variable leak in sendfile(2). 2017-08-09 17:48:38 +00:00
kgssapi kgssapi: insignificant spelling fix. 2016-05-03 22:05:03 +00:00
libkern arm64: add ".arch armv8-a+crc" to allow use of crc instructions 2017-06-08 20:06:09 +00:00
mips [ar71xx] get rid of ath_pci - it's built as a module now. 2017-07-28 01:17:38 +00:00
modules Provide compile to choose receive processing in either Ithread or Taskqueue Thread. 2017-08-09 22:18:49 +00:00
net Don't leak mbufs if clusers exceeds the number of segments. This would 2017-08-10 03:43:23 +00:00
net80211 sys/net8021: Add missing braces in setcurchan(). 2017-08-01 03:13:43 +00:00
netgraph Check return value from soaccept(). 2017-06-14 16:13:20 +00:00
netinet Fix comment typo. 2017-08-09 10:46:34 +00:00
netinet6 After inpcb route caching was put back in place there is no need for 2017-07-27 13:03:36 +00:00
netipsec Make user supplied data checks a bit stricter. 2017-08-09 19:58:38 +00:00
netpfil pf_get_sport(): Prevent possible endless loop when searching for an unused nat port 2017-08-08 21:09:26 +00:00
netsmb sys/net*: minor spelling fixes. 2016-05-03 18:05:43 +00:00
nfs Improve FHA locality control for NFS read/write requests. 2017-07-31 15:23:19 +00:00
nfsclient Add an NFSv4.1 mount option for "use one openowner". 2017-04-13 21:54:19 +00:00
nfsserver Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
nlm Commit the 64-bit inode project. 2017-05-23 09:29:05 +00:00
ofed Change reject message type when destroying cm_id in ibore. 2017-08-03 09:31:10 +00:00
opencrypto Use const with some read-only buffers in opencrypto APIs. 2017-05-09 18:28:42 +00:00
powerpc Add cpufreq support for P1022 and MPC8536 2017-07-21 03:40:05 +00:00
riscv Support for v1.10 (latest) of RISC-V privilege specification. 2017-08-10 14:18:09 +00:00
rpc Listening sockets improvements. 2017-06-08 21:30:34 +00:00
security Correct bitwise test in mac_bsdextended ugidfw_rule_valid() 2017-06-13 01:17:58 +00:00
sparc64 Introduce vm_page_grab_pages(), which is intended to replace loops calling 2017-08-09 04:23:04 +00:00
sys o Replace __riscv__ with __riscv 2017-08-07 14:09:57 +00:00
teken Oops, my fix for bright colors broke bright black some more (in cases 2017-03-27 10:48:28 +00:00
tests style(9): sort headers 2017-05-09 05:08:47 +00:00
tools make.conf: Add the possibility to use another DTC 2017-06-17 23:34:53 +00:00
ufs Since the switch to GPT disk labels, fsck for UFS/FFS has been 2017-08-09 05:17:21 +00:00
vm Introduce vm_page_grab_pages(), which is intended to replace loops calling 2017-08-09 04:23:04 +00:00
x86 x86: bump MAX_APIC_ID to 512 2017-08-10 09:16:40 +00:00
xdr * limit size of buffers to RPC_MAXDATASIZE 2017-06-01 06:12:25 +00:00
xen xenstore: fix suspension when using the xenstore device 2017-03-07 09:17:48 +00:00
Makefile Remove glimpse make target added in r181432 2017-05-22 15:53:30 +00:00