HomeFreeBSD

cxgbe(4): Fix bad races between sysctl and driver detach.

Description

cxgbe(4): Fix bad races between sysctl and driver detach.

The default sysctl context setup by newbus for a device is eventually
freed by device_sysctl_fini, which runs after the device driver's detach
routine. sysctl nodes associated with this context must not use any
resources (like driver locks, hardware access, counters, etc.) that are
released by driver detach.

There are a lot of sysctl nodes like this in cxgbe(4) and the fix is to
hang them off a context that is explicitly freed by the driver before it
releases any resource that might be used by a sysctl.

This fixes panics when running "sysctl dev.t6nex dev.cc" in a tight loop
and loading/unloading the driver in parallel.

Reported by: Suhas Lokesha
Sponsored by: Chelsio Communications

(cherry picked from commit a727d9531afbd58e304acc27e3717031e78bff90)

Details

Provenance
npAuthored on Jan 13 2022, 10:21 PM
Parents
rGc50239ee3048: cxgbe(4): Fix regression in previous attempt to fix FEC selection.
Branches
Unknown
Tags
Unknown