Page MenuHomeFreeBSD

snd_hda: Fix cleanup regression in hdac_detach()
AbandonedPublic

Authored by christos on May 16 2025, 3:23 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Sep 28, 7:22 AM
Unknown Object (File)
Thu, Sep 25, 7:14 PM
Unknown Object (File)
Wed, Sep 17, 7:23 AM
Unknown Object (File)
Sep 16 2025, 7:23 AM
Unknown Object (File)
Jul 31 2025, 5:01 AM
Unknown Object (File)
Jul 29 2025, 5:00 AM
Unknown Object (File)
Jul 29 2025, 1:20 AM
Unknown Object (File)
Jul 28 2025, 8:30 AM
Subscribers

Details

Summary

bus_generic_detach() does not clean up properly and if we unload and
reload, we get an additional duplicate hdacc for each reload, along with
duplicate PCM devices.

Fixes: 11a9117871e6 ("Use bus_generic_detach to detach and delete child devices during detach")
Sponsored by: The FreeBSD Foundation
MFC after: 1 day

Diff Detail

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

Event Timeline

The only real difference I can see is that this change causes child devices to be detached in reverse order. Does the order matter for some reason?

The only real difference I can see is that this change causes child devices to be detached in reverse order. Does the order matter for some reason?

Correct me if I'm wrong, but unlike bus_generic_detach() which just calls device_detach(), device_delete_children() seems to be calling device_delete_child(), which in turns calls device_detach(), and then does additional cleanup. In any case, this change does fix the bug. That's also how the rest of the HDA layers (hdacc, hdaa) cleanup.

The only real difference I can see is that this change causes child devices to be detached in reverse order. Does the order matter for some reason?

Correct me if I'm wrong, but unlike bus_generic_detach() which just calls device_detach(), device_delete_children() seems to be calling device_delete_child(), which in turns calls device_detach(), and then does additional cleanup. In any case, this change does fix the bug.

bus_generic_detach() calls device_detach() on each child, then calls device_delete_children(). With this patch we're just calling device_delete_children().

I believe you that the change fixes a problem, but it's not clear to me at least why it fixes it, so it's hard to say that the change is right. Maybe someone more familiar with newbus can chime in. Failing that, it'd be helpful to know what exactly is failing during detach such that the driver isn't cleaning up properly. Is one of hdacc_detach() or hdaa_detach() returning an error?

That's also how the rest of the HDA layers (hdacc, hdaa) cleanup.

I don't quite follow: hdacc_detach() and hdaa_detach() both call bus_generic_detach().

I don't quite follow: hdacc_detach() and hdaa_detach() both call bus_generic_detach().

Scratch that... I hadn't rebased my work branch for a while and so I cherrypicked only 11a9117871e6 and missed the rest of the series. I now did a proper rebase and the bug does not exist. Sorry about the noise.