Repository navigation
wifi: brcmfmac: pcie: don't arm a reset from a setup that fails - #65
Conversation
When brcmf_pcie_setup() fails, it reports the crash with
brcmf_fw_crashed() and then releases the driver. brcmf_fw_crashed()
also arms the bus reset work. brcmf_pcie_remove(), called from
device_release_driver(), drains that work with
brcmf_bus_cancel_reset_work(); but by then the reset has usually run:
it detached the bus and queued a new firmware request. That request's
brcmf_pcie_setup() then runs while remove frees the chip, and it
dereferences devinfo->ci in the firmware wait loop of
brcmf_pcie_download_fw_nvram():
Unable to handle kernel NULL pointer dereference at virtual address 000000000000001c
pc : brcmf_pcie_setup+0x4d0/0x1008 [brcmfmac]
Call trace:
brcmf_pcie_setup+0x4d0/0x1008 [brcmfmac] (P)
brcmf_fw_request_done+0x144/0x188 [brcmfmac]
request_firmware_work_func+0x50/0xec
The reset work and the firmware workers stay stuck afterwards.
Block the reset before reporting the crash, as remove does: the driver
is released anyway, so the report keeps its coredump and nothing races
the release.
Found on a Pixel 9a (BCM4383) by suspending with the driver loaded: the
chip doesn't survive s2idle, the hot resume finds the firmware crashed,
the recovery reset's firmware download fails ("FW failed to
initialize"), and the second firmware request crashed as above. With
this change the same sequence ends with "Dongle setup failed", the
driver released, no oops and no task stuck in D state.
Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
|
Thanks, this is right, and a nice catch. I traced it through: For the Pixel 7 Pro nothing changes in practice: I built This applies to mainline as it is: the Two small asks for next time, not for this one: the Gate passes on today's |
When brcmf_pcie_setup() fails it calls brcmf_fw_crashed(), which arms the bus reset, and then releases the driver. By the time brcmf_pcie_remove() drains the reset, the reset has already queued a new firmware request, and that request's brcmf_pcie_setup() runs while remove frees the chip. It oopses on devinfo->ci (NULL) in the firmware wait loop and leaves the reset and firmware workers stuck.
The fix blocks the reset before reporting the crash, as remove does. The coredump still happens, and nothing races the release.
I hit it on the palmtop (Pixel 9a, BCM4383) by suspending with brcmfmac loaded: hot resume finds the firmware crashed, the recovery download fails with "FW failed to initialize", and the second request oopsed at brcmf_pcie_setup+0x4d0. With this patch the same test ends with "Dongle setup failed", the driver released, no oops and nothing in D state.
Built with W=1 (no new warnings). checkpatch --strict is clean apart from the quoted oops line in the commit message.