Created attachment 238184 [details] 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.
Can you try this one: https://people.freebsd.org/~bz/tmp/20221121-01-iwlwifi-completion.diff
Ah, torch relay ;) Thank You. Installed, and did work thru a couple of unload/load.
(In reply to Peter Much from comment #2) Thanks a lot for reporting and testing! I'll commit this tomorrow and then I can go back and looking into the other teardown issues as well. I found at least two problems so far. But more about the elsewhere.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=bee60c98974593d25aa18743f9413a78e0d57dc9 commit bee60c98974593d25aa18743f9413a78e0d57dc9 Author: Bjoern A. Zeeb <bz@FreeBSD.org> AuthorDate: 2022-11-22 17:29:41 +0000 Commit: Bjoern A. Zeeb <bz@FreeBSD.org> CommitDate: 2022-11-22 17:29:41 +0000 iwlwifi: fix hang on unloading driver f808c43ad9234670770601ba32a7426b00bbf528 introduced a FreeBSD specific behaviour to wait for firmware load completion before returning from loading the driver. This does no longer allow iwl_drv_stop to detect that startup has completed and it will wait indefinitely for a completion event that will not happen. We could change the complete() call to a complete_all() but to avoid confusion, future side effects, and for simplicity daisy-chain two complete events in FreeBSD. PR: 267869 Reported by: Peter Much (pmc citylink.dinoex.sub.org) Tested by: Peter Much (pmc citylink.dinoex.sub.org) Sponsored by: The FreeBSD Foundation MFC after: 3 days sys/contrib/dev/iwlwifi/iwl-drv.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
A commit in branch stable/13 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=46c09d766d265a886a7fd11ee5dd88bb17e9a0af commit 46c09d766d265a886a7fd11ee5dd88bb17e9a0af Author: Bjoern A. Zeeb <bz@FreeBSD.org> AuthorDate: 2022-11-22 17:29:41 +0000 Commit: Bjoern A. Zeeb <bz@FreeBSD.org> CommitDate: 2022-11-28 16:34:46 +0000 iwlwifi: fix hang on unloading driver f808c43ad9234670770601ba32a7426b00bbf528 introduced a FreeBSD specific behaviour to wait for firmware load completion before returning from loading the driver. This does no longer allow iwl_drv_stop to detect that startup has completed and it will wait indefinitely for a completion event that will not happen. We could change the complete() call to a complete_all() but to avoid confusion, future side effects, and for simplicity daisy-chain two complete events in FreeBSD. PR: 267869 Reported by: Peter Much (pmc citylink.dinoex.sub.org) Tested by: Peter Much (pmc citylink.dinoex.sub.org) Sponsored by: The FreeBSD Foundation (cherry picked from commit bee60c98974593d25aa18743f9413a78e0d57dc9) sys/contrib/dev/iwlwifi/iwl-drv.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
Now also merged to stable/13. Thanks a lot again for reporting and testing the change!