Bug 278081 - Kernel panic in bwn
Summary: Kernel panic in bwn
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: wireless (show other bugs)
Version: 13.3-RELEASE
Hardware: amd64 Any
: --- Affects Only Me
Assignee: Bjoern A. Zeeb
URL:
Keywords: crash
Depends on:
Blocks:
 
Reported: 2024-03-31 20:54 UTC by tom.mcclean@gmail.com
Modified: 2024-05-19 06:38 UTC (History)
2 users (show)

See Also:


Attachments
Core.txt file from kernel panic caused by if_bwn (131.04 KB, text/plain)
2024-05-05 01:04 UTC, tom.mcclean@gmail.com
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description tom.mcclean@gmail.com 2024-03-31 20:54:27 UTC
The Broadcom wifi driver causes a kernel panic (page fault) at line 1041 of /usr/src/sys/dev/bwn/if_bwn.c on a MacBook Pro 5,5 witha Broadcom BCM4322 running a fresh install of FreeBSD 13.3.

This occurs every time the wifi connection is configured, up and being actively used, but the precise timing varies. It appears to be related to the overall volume of traffic. The panic sometimes occurs within minutes of cold boot, sometimes up to a quarter of an hour later.

This issue appears to be specific to FreeBSD 13.3. It does not arise on the same machine running a fresh install of FreeBSD 13.2 (which runs regularly for at least 8h under heavy wifi load with no issues). Nor does the difference appear to be due to configuration issues. Under both FreeBSD 13.2 and 13.3, I use a custom kernel where the only change from GENERIC is to enable options for BWN_DEBUG and BWN_GPL_PHY. Both machines have correct firmware installed by building the port net/bwn-firmware-kmod with no special options.
Comment 1 Bjoern A. Zeeb freebsd_committer freebsd_triage 2024-04-01 16:08:43 UTC
(In reply to tom.mcclean@gmail.com from comment #0)
We did one change to bwn in the last months.

On stable/13 the line you are quoting is an assignment:
https://cgit.freebsd.org/src/tree/sys/dev/bwn/if_bwn.c?h=stable/13#n1401
of functions.

Do you have a picture (if not a transcribe) of this?

Ans just checking given you are saying it is 13.3 specific and didn't happen on 13.2; the card/freebsd/driver used to work on the same macbook before?
Comment 2 tom.mcclean@gmail.com 2024-04-02 20:31:54 UTC
Apologies - I got the line wrong. I've double checked and it's line 1037. A dereference of a pointer to a struct in bwn_tx_isfull()

https://cgit.freebsd.org/src/tree/sys/dev/bwn/if_bwn.c?h=stable/13#n1037

Yes, this is 13.3-specific. I upgraded from 13.2 to 13.3 a week ago and had this problem all week, after never having had it before. I downgraded back to 13.2 over the weekend via a fresh install (full format of the hard disk and all). The problem has disappeared.
Comment 3 Bjoern A. Zeeb freebsd_committer freebsd_triage 2024-04-02 23:17:39 UTC
Do you happen to have a core dump or a log or a picture of the crash still?
Comment 4 Bjoern A. Zeeb freebsd_committer freebsd_triage 2024-04-03 16:55:00 UTC
(In reply to Bjoern A. Zeeb from comment #3)

If not, one thing you could do to not crash your base install is to install 13.3-R into a bhyve and use devctl to assign the bwn to ppt and pass it in as a passthru device while testing.  During that time you won't have it avail on the base system (no wireless) but at least testing should be easier and going back and forth if needed?
Comment 5 tom.mcclean@gmail.com 2024-04-04 05:46:54 UTC
(In reply to Bjoern A. Zeeb from comment #4)

Thanks for the tip. I was going to try to reinstall 13.3 but that's a much easier way to proceed. I'll do this over the weekend and report back. If it doesn't work, I'll just do a full reinstall and send the crash logs.
Comment 6 Bjoern A. Zeeb freebsd_committer freebsd_triage 2024-04-06 22:07:18 UTC
(In reply to tom.mcclean@gmail.com from comment #5)

In case you need help to get it setup, please feel free to ask.
Comment 7 tom.mcclean@gmail.com 2024-04-09 10:55:25 UTC
(In reply to Bjoern A. Zeeb from comment #6)

I haven't forgotten this, I promise. I just need to find time to repartition my hard disk and install 13.2 and 13.3 side-by-side. I want to try that instead of installing 13.3 in BHYVE, to make sure virtualisation doesn't mask the bug. It may take me a few weeks to do this.
Comment 8 tom.mcclean@gmail.com 2024-05-05 01:04:46 UTC
Created attachment 250408 [details]
Core.txt file from kernel panic caused by if_bwn
Comment 9 tom.mcclean@gmail.com 2024-05-05 01:07:37 UTC
I've reproduced the kernel panic this morning on a fresh install of FreeBSD 13.4. See attached core.txt.0.

The machine is the same as the original report. The kernel is modified by adding OPTIONS BWN_PHY_GPL and OPTIONS BWN_DEBUG only.

The crash now occurs during boot, when the machine first tries to connect to the wireless network. There is no crash if I do not configure the wireless network in rc.conf. The machine can connect to wifi without problems under FreeBSD 12, too.
Comment 10 tom.mcclean@gmail.com 2024-05-05 01:08:38 UTC
edit: FreeBSD 14.0 today, sorry
Comment 11 Bjoern A. Zeeb freebsd_committer freebsd_triage 2024-05-07 10:17:57 UTC
14.0 would still suffer from the problem referenced in the bug I just added to "See also" though 13.3 should no longer have.  This seems a lot similar if I read the modern backtrace correct (m valid @entry but on return it's 4).  Unfortunately the maths values as optimized out.

Do you think you could try a 14.1-BETA1?  Or would you be willing to try a patch, recompiling your own kernel?
Comment 12 tom.mcclean@gmail.com 2024-05-07 11:03:16 UTC
I’d be very happy to patch my kernel and repot back, if someone can supply the patch. That’s easier for me than installing a beta kernel
Comment 13 Bjoern A. Zeeb freebsd_committer freebsd_triage 2024-05-11 01:42:40 UTC
(In reply to tom.mcclean@gmail.com from comment #12)

This is the change you want for 14.0-R:

https://cgit.freebsd.org/src/commit/?id=4e219655d0f7e1134c040468c0e7d91c671e57fb
Comment 14 tom.mcclean@gmail.com 2024-05-19 06:38:45 UTC
I did a fresh install of FreeBSD14.0 last week. The sources already had the patch applied. I've compiled a custom kernel to enable GPL PHY, and installed the bwn firmware, but made no other changes. 

I'm able to boot, and to ping common servers like www.google.com. For some reason ping causes a general protection fault when I stop it (ctrl-C). But the wifi itself seems to be working.