svn commit: r322960 - in head/sys/dev/cxgbe: . common
Navdeep Parhar
np at FreeBSD.org
Mon Aug 28 03:13:17 UTC 2017
Author: np
Date: Mon Aug 28 03:13:16 2017
New Revision: 322960
URL: https://svnweb.freebsd.org/changeset/base/322960
Log:
cxgbe(4): Verify that the driver accesses the firmware mailbox in a
thread-safe manner.
MFC after: 3 days
Modified:
head/sys/dev/cxgbe/adapter.h
head/sys/dev/cxgbe/common/t4_hw.c
head/sys/dev/cxgbe/t4_main.c
Modified: head/sys/dev/cxgbe/adapter.h
==============================================================================
--- head/sys/dev/cxgbe/adapter.h Mon Aug 28 02:42:20 2017 (r322959)
+++ head/sys/dev/cxgbe/adapter.h Mon Aug 28 03:13:16 2017 (r322960)
@@ -151,7 +151,7 @@ enum {
/* adapter flags */
FULL_INIT_DONE = (1 << 0),
FW_OK = (1 << 1),
- /* INTR_DIRECT = (1 << 2), No longer used. */
+ CHK_MBOX_ACCESS = (1 << 2),
MASTER_PF = (1 << 3),
ADAP_SYSCTL_CTX = (1 << 4),
/* TOM_INIT_DONE= (1 << 5), No longer used */
Modified: head/sys/dev/cxgbe/common/t4_hw.c
==============================================================================
--- head/sys/dev/cxgbe/common/t4_hw.c Mon Aug 28 02:42:20 2017 (r322959)
+++ head/sys/dev/cxgbe/common/t4_hw.c Mon Aug 28 03:13:16 2017 (r322960)
@@ -286,6 +286,9 @@ int t4_wr_mbox_meat_timeout(struct adapter *adap, int
__be64 cmd_rpl[MBOX_LEN/8];
u32 pcie_fw;
+ if (adap->flags & CHK_MBOX_ACCESS)
+ ASSERT_SYNCHRONIZED_OP(adap);
+
if ((size & 15) || size > MBOX_LEN)
return -EINVAL;
Modified: head/sys/dev/cxgbe/t4_main.c
==============================================================================
--- head/sys/dev/cxgbe/t4_main.c Mon Aug 28 02:42:20 2017 (r322959)
+++ head/sys/dev/cxgbe/t4_main.c Mon Aug 28 03:13:16 2017 (r322960)
@@ -1221,6 +1221,15 @@ t4_attach(device_t dev)
goto done;
}
+ /*
+ * Ensure thread-safe mailbox access (in debug builds).
+ *
+ * So far this was the only thread accessing the mailbox but various
+ * ifnets and sysctls are about to be created and their handlers/ioctls
+ * will access the mailbox from different threads.
+ */
+ sc->flags |= CHK_MBOX_ACCESS;
+
rc = bus_generic_attach(dev);
if (rc != 0) {
device_printf(dev,
@@ -1336,6 +1345,7 @@ t4_detach_common(device_t dev)
sc = device_get_softc(dev);
+ sc->flags &= ~CHK_MBOX_ACCESS;
if (sc->flags & FULL_INIT_DONE) {
if (!(sc->flags & IS_VF))
t4_intr_disable(sc);
More information about the svn-src-all
mailing list