1From 31b7849092c43805c7fbaf7518b99874aa1b310c Mon Sep 17 00:00:00 2001
2From: Joan Bruguera <joanbrugueram@gmail.com>
3Date: Wed, 12 Jan 2022 20:49:20 +0100
4Subject: [PATCH] Tentative fix for broadcom-wl 6.30.223.271 driver for Linux 5.17-rc1
5
6Set netdev->dev_addr through dev_addr_mod + PDE_DATA fix
7
8Since Linux 5.17 netdev->dev_addr is const and must be changed through
9dev_addr_mod, otherwise a warning is logged in dmesg and bad things may happen.
10
11NB: The #if is not wrong, dev_addr_mod is defined since Linux 5.15-rc1
12
13Plus a trivial fix for PDE_DATA.
14
15Applies on top of all the patches applied to broadcom-wl-dkms 6.30.223.271-28 on Arch Linux.
16
17See also: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=adeef3e32146a8d2a73c399dc6f5d76a449131b1
18 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=359745d78351c6f5442435f81549f0207ece28aa
19---
20 src/wl/sys/wl_linux.c | 16 +++++++++++++---
21 1 file changed, 13 insertions(+), 3 deletions(-)
22
23diff --git a/src/wl/sys/wl_linux.c b/src/wl/sys/wl_linux.c
24index e491df7..e4614fb 100644
25--- a/src/wl/sys/wl_linux.c
26+++ b/src/wl/sys/wl_linux.c
27@@ -93,6 +93,10 @@ struct iw_statistics *wl_get_wireless_stats(struct net_device *dev);
28
29 #include <wlc_wowl.h>
30
31+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0))
32+#define PDE_DATA pde_data
33+#endif
34+
35 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
36 static void wl_timer(struct timer_list *tl);
37 #else
38@@ -490,6 +494,12 @@ wl_if_setup(struct net_device *dev)
39 #endif
40 }
41
42+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0)
43+static inline void eth_hw_addr_set(struct net_device *dev, const void *addr) {
44+ memcpy(dev->dev_addr, addr, ETHER_ADDR_LEN);
45+}
46+#endif
47+
48 static wl_info_t *
49 wl_attach(uint16 vendor, uint16 device, ulong regs,
50 uint bustype, void *btparam, uint irq, uchar* bar1_addr, uint32 bar1_size)
51@@ -634,7 +644,7 @@ wl_attach(uint16 vendor, uint16 device, ulong regs,
52 WL_ERROR(("wl%d: Error setting MAC ADDRESS\n", unit));
53 }
54 #endif
55- bcopy(&wl->pub->cur_etheraddr, dev->dev_addr, ETHER_ADDR_LEN);
56+ eth_hw_addr_set(dev, wl->pub->cur_etheraddr.octet);
57
58 online_cpus = 1;
59
60@@ -1835,7 +1845,7 @@ wl_set_mac_address(struct net_device *dev, void *addr)
61
62 WL_LOCK(wl);
63
64- bcopy(sa->sa_data, dev->dev_addr, ETHER_ADDR_LEN);
65+ eth_hw_addr_set(dev, sa->sa_data);
66 err = wlc_iovar_op(wl->wlc, "cur_etheraddr", NULL, 0, sa->sa_data, ETHER_ADDR_LEN,
67 IOV_SET, (WL_DEV_IF(dev))->wlcif);
68 WL_UNLOCK(wl);
69@@ -3010,7 +3020,7 @@ _wl_add_monitor_if(wl_task_t *task)
70 else
71 dev->type = ARPHRD_IEEE80211_RADIOTAP;
72
73- bcopy(wl->dev->dev_addr, dev->dev_addr, ETHER_ADDR_LEN);
74+ eth_hw_addr_set(dev, wl->dev->dev_addr);
75
76 #if defined(WL_USE_NETDEV_OPS)
77 dev->netdev_ops = &wl_netdev_monitor_ops;
78--
792.35.1
80