Skip to content

[follow-up to #167] Bluetooth: hci_bcm4377: drain recovery work before module exit - #186

Merged
RyanTheTide merged 5 commits into
aurora-wipfrom
fix/pr167-review
Oct 8, 2026
Merged

RyanTheTide merged 5 commits into
aurora-wipfrom
fix/pr167-review

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

Queue recovery on a dedicated workqueue. Unregister the PCI driver and
its HCI timeout producers before draining that queue, so no callback can
outlive the module text. A module reference released inside a callback
alone would not guarantee that the callback has returned before
unloading.

Follow-up to #167; original contributor commits are preserved. These fixes are based on public Linux/PR source and Linux-side tests.

Validation: targeted arm64 driver build passed (object checks only); strict checkpatch passed for the final code changes with only the required Assisted-by trailer diagnostic excluded.

Hardware qualification is pending. No boot, suspend, fault-injection or firmware recovery pass is claimed. The publication gate is separate from runtime acceptance.

Any outstanding contributor certification on the original PR remains outstanding; no contributor sign-off was added by this follow-up.

🤖 Generated with Claude Code

rryan and others added 5 commits October 2, 2026 20:46
…esponding

After some suspend-to-idle cycles on a BCM4388 (MacBook Pro 16" M2 Max),
the controller no longer answers HCI commands. hci_resume_dev() times out
on Set Event Mask (0x0c01), followed by Write Scan Enable, LE address
resolution and scan parameter commands. Every later command times out as
well, until the module is reloaded, which recovers it.

Install an hdev->reset handler, which the HCI core calls on a command
timeout, and recover the same way: rebind the driver with
device_reprobe(), so probe resets the function and boots the firmware
again. The work and its device reference are allocated separately
because the reprobe frees bcm4377_data. Timeouts during setup are left
alone, as are timeouts while a reprobe is already queued.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: RJ Skerry-Ryan <[email protected]>
(cherry picked from commit 37e9742)
bcm4377_suspend() and bcm4377_resume() write SLEEP_CONTROL and return
without reading anything back, so the PCIe write can still be posted
when the system enters suspend-to-idle, or when hci_resume_dev() starts
sending commands. On a BCM4388 (MacBook Pro 16" M2 Max) about a quarter
to half of all resumes then left the controller unresponsive: every
resume command timed out, stalling resume by about 20 s.

Read the register back after both writes. With a read-back in place, 8
of 8 resumes succeeded, including 10 and 20 minute sleeps.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: RJ Skerry-Ryan <[email protected]>
(cherry picked from commit 4d662f9)
The driver has no hdev->wakeup callback, so the HCI core never offers
HCI_CONN_FLAG_REMOTE_WAKEUP: bluetoothd's attempt to allow wakeup for a
paired mouse fails with "Bad flag given (0x1) vs supported (0xe)", and
suspend always disconnects without programming a wake filter.

Report device_may_wakeup() as the wakeup state. When wakeup is enabled,
keep the firmware running and the function in D0 through system sleep,
and arm the interrupt for wakeup, so that a connection attempt or
advertisement from a wake-allowed device wakes the system. Otherwise
quiesce the firmware as before.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: RJ Skerry-Ryan <[email protected]>
(cherry picked from commit 8f373b9)
Queue recovery on a dedicated workqueue. Unregister the PCI driver and
its HCI timeout producers before draining that queue, so no callback can
outlive the module text. A module reference released inside a callback
alone would not guarantee that the callback has returned before
unloading.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
Add the declaration separator required by strict checkpatch. This is a
formatting follow-up to the supplied recovery-work lifetime fix and
does not change workqueue or module teardown behavior.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants