Page MenuHomeFreeBSD

nhi: Fix a race with interrupt teardown during detach
AcceptedPublic

Authored by jhb on Sun, Oct 19, 8:00 PM.
Tags
None
Referenced Files
F132961228: D53201.id164549.diff
Tue, Oct 21, 2:07 PM
F132961223: D53201.id.diff
Tue, Oct 21, 2:07 PM
Unknown Object (File)
Tue, Oct 21, 2:14 AM
Unknown Object (File)
Mon, Oct 20, 2:20 PM
Unknown Object (File)
Mon, Oct 20, 2:05 PM
Unknown Object (File)
Mon, Oct 20, 1:46 PM
Unknown Object (File)
Mon, Oct 20, 9:08 AM
Subscribers

Details

Reviewers
obiwac
Summary

When nhi fails to attach on one of my systems (X1 Carbon 6th gen), an
interrupt races with the teardown code such that the rings have been
freed by nhi_detach() before an interrupt triggers. At the time of
the crash, the thread invoking nhi_attach() is blocked in
bus_teardown_intr() from nhi_pci_free() waiting for the interrupt
thread to finish executing the handler.

To fix, don't just disable the interrupts in nhi_detach(), but
actually tear the handlers down and disable MSI-X before freeing the
rings.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 67919
Build 64802: arc lint + arc unit

Event Timeline

jhb requested review of this revision.Sun, Oct 19, 8:00 PM

thanks!

tested it out on my machine and all is good

This revision is now accepted and ready to land.Mon, Oct 20, 2:25 PM

This fixes a panic when devmatch autoloads on my laptop.

In D53201#1215648, @jhb wrote:

This fixes a panic when devmatch autoloads on my laptop.

oh yeah sorry I could've worded that better - I meant that this change doesn't break anything unexpected when unloading on my laptop