[Bug 267869] iwlwifi cannot kldunload after device is attached

From: <bugzilla-noreply_at_freebsd.org>
Date: Sat, 19 Nov 2022 21:12:42 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=267869

            Bug ID: 267869
           Summary: iwlwifi cannot kldunload after device is attached
           Product: Base System
           Version: 13.1-STABLE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: wireless
          Assignee: wireless@FreeBSD.org
          Reporter: pmc@citylink.dinoex.sub.org

Created attachment 238184
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=238184&action=edit
wait for completion without resetting condition

When trying to kldunload if_iwlwifi, the command will not succeed and neither
fail. It will instead hang forever in the "completi" wchan.

The exact location is in the first line of iwl-drv.c:iwl_drv_stop():
    wait_for_completion(&drv->request_firmware_complete);

This behaviour was introduced by change f808c43ad9234670 
    "iwlwifi: enforce FreeBSD specific (expected) behaviour" 
which now does another wait_for_completion() already in iwl_drv_start().

The problem is that wait_for_completion() apparently does not only wait for the
condition, but also reset the condition, and so the now second invocation in
iwl_drv_stop does wait forever for a condition that will not appear again.

I created a quick workaround patch - without bothering to understand the
intended use of the completion, or the use of the sleepq, so this should be
rewritten more nicely - but it works for now so we can focus on the other
issues.

-- 
You are receiving this mail because:
You are the assignee for the bug.