Jump to content

propose a patch to make UWE5622 driver set mac address properly


Recommended Posts

Current UWE5622 driver(from the extension) will trigger a kernel warning raised by `void dev_addr_check(struct net_device *dev)`. The following patch seems fix the problem.

The bug reporting guide told me not to post this to armbian/build so I decide to make a shout in the forum.

 

diff --git a/drivers/net/wireless/uwe5622/unisocwifi/main.c b/drivers/net/wireless/uwe5622/unisocwifi/main.c
index bf2ec6c..b83ab8e 100644
--- a/drivers/net/wireless/uwe5622/unisocwifi/main.c
+++ b/drivers/net/wireless/uwe5622/unisocwifi/main.c
@@ -15,6 +15,7 @@
  * GNU General Public License for more details.
  */
 
+#include <linux/etherdevice.h>
 #include "sprdwl.h"
 #include "npi.h"
 #include "cfg80211.h"
@@ -944,12 +945,12 @@ static int sprdwl_set_mac(struct net_device *dev, void *addr)
         if (!is_zero_ether_addr(sa->sa_data)) {
             vif->has_rand_mac = true;
             memcpy(vif->random_mac, sa->sa_data, ETH_ALEN);
-            memcpy(dev->dev_addr, sa->sa_data, ETH_ALEN);
+            eth_hw_addr_set(dev, sa->sa_data);
         } else {
             vif->has_rand_mac = false;
             netdev_info(dev, "need clear random mac for sta/softap mode\n");
             memset(vif->random_mac, 0, ETH_ALEN);
-            memcpy(dev->dev_addr, vif->mac, ETH_ALEN);
+            eth_hw_addr_set(dev, vif->mac);
         }
     }
     /*return success to pass vts test*/

 

BTW here's the kernel warning log(the real hardware address is masked):

 

[  429.029816] unisoc_wifi unisoc_wifi wlan0: start set random mac: de:cd:04:5c:1e:4d
[  429.031469] unisoc_wifi unisoc_wifi wlan0: Current addr:  de cd 04 5c 1e 4d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[  429.031505] unisoc_wifi unisoc_wifi wlan0: Expected addr: aa bb cc dd ee ff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[  429.031525] ------------[ cut here ]------------
[  429.031535] netdevice: wlan0: Incorrect netdev->dev_addr
[  429.031656] WARNING: CPU: 0 PID: 861 at net/core/dev_addr_lists.c:519 dev_addr_check+0xb0/0x140
[  429.031701] Modules linked in: algif_hash algif_skcipher af_alg bnep sprdwl_ng hci_uart btqca btrtl btintel btbcm bluetooth ecdh_generic ecc sunxi_addr cfg80211 lz4hc lz4 zram binfmt_misc snd_soc_hdmi_codec sunxi_cedrus(C) polyval_ce polyval_generic v4l2_mem2mem dw_hdmi_i2s_audio dw_hdmi_cec sunxi_cir rc_core videobuf2_dma_contig videobuf2_memops joydev videobuf2_v4l2 videodev videobuf2_common pwm_sunxi_enhance mc dump_reg display_connector cpufreq_dt sprdbt_tty uwe5622_bsp_sdio rfkill fuse dm_mod cdc_ether usbnet r8152
[  429.032075] CPU: 0 PID: 861 Comm: NetworkManager Tainted: G        WC         6.6.31-current-sunxi64 #1
[  429.032096] Hardware name: OrangePi Zero 2W (DT)
[  429.032109] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[  429.032131] pc : dev_addr_check+0xb0/0x140
[  429.032150] lr : dev_addr_check+0xb0/0x140
[  429.032168] sp : ffff800083f83510
[  429.032178] x29: ffff800083f83510 x28: ffff800080f49a18 x27: 0000000000000000
[  429.032213] x26: 0000000000000001 x25: 0000000000000000 x24: ffff0000c2b80268
[  429.032246] x23: 0000000000001002 x22: ffff800083f839c0 x21: ffff8000810859c8
[  429.032281] x20: ffff0000c2b80000 x19: ffff0000c2b80000 x18: 0000000000000000
[  429.032314] x17: 0000000000000000 x16: 0000000000000000 x15: fffffffffffcbb27
[  429.032347] x14: 2030302030302030 x13: 00000000000002a6 x12: 00000000ffffffea
[  429.032381] x11: 00000000ffffefff x10: 00000000ffffefff x9 : ffff800081567ba8
[  429.032415] x8 : 0000000000017fe8 x7 : c0000000ffffefff x6 : 0000000000000001
[  429.032447] x5 : ffff0000ff75da08 x4 : 0000000000000000 x3 : 0000000000000027
[  429.032480] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff0000ca116200
[  429.032513] Call trace:
[  429.032524]  dev_addr_check+0xb0/0x140
[  429.032545]  __dev_open+0x40/0x1e0
[  429.032571]  __dev_change_flags+0x1e8/0x2b8
[  429.032598]  dev_change_flags+0x24/0x6c
[  429.032622]  do_setlink+0x220/0xe20
[  429.032648]  __rtnl_newlink+0x494/0x8c0
[  429.032665]  rtnl_newlink+0x50/0x7c
[  429.032681]  rtnetlink_rcv_msg+0x2b0/0x384
[  429.032705]  netlink_rcv_skb+0x5c/0x128
[  429.032724]  rtnetlink_rcv+0x18/0x24
[  429.032747]  netlink_unicast+0x2c0/0x328
[  429.032773]  netlink_sendmsg+0x1d4/0x440
[  429.032789]  __sock_sendmsg+0x54/0x60
[  429.032807]  ____sys_sendmsg+0x27c/0x2e0
[  429.032824]  ___sys_sendmsg+0x80/0xdc
[  429.032844]  __sys_sendmsg+0x68/0xc4
[  429.032862]  __arm64_sys_sendmsg+0x24/0x30
[  429.032881]  invoke_syscall+0x48/0x118
[  429.032907]  el0_svc_common.constprop.0+0x40/0xe8
[  429.032931]  do_el0_svc+0x20/0x2c
[  429.032952]  el0_svc+0x40/0xf4
[  429.032977]  el0t_64_sync_handler+0x13c/0x158
[  429.033001]  el0t_64_sync+0x190/0x194
[  429.033021] ---[ end trace 0000000000000000 ]---

 

reproduced on:

  • orangepi zero2w community build
  • custom orangepi zero2w kernel using armbian's patches

 

I wonder if this is the correct fix as I have little knowledge in linux netdev drivers.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines