Subject: [PATCH net v2] Revert "net/ncsi: change from ndo_set_mac_address to dev_set_mac_address"

From: Jakub Kicinski <[email-masked]>
Date: Wed, 8 Jan 2025 11:23:46 -0800

From: Potin Lai <[email-masked]>

This reverts commit 790071347a0a1a89e618eedcd51c687ea783aeb3.

We are seeing kernel panic when enabling two NCSI interfaces at same
time. It looks like mutex lock is being used in softirq caused the
issue.

Kernel panic log:

  8021q: adding VLAN 0 to HW filter on device eth0
  ftgmac100 1e670000.ethernet eth0: NCSI: Handler for packet type 0x82 returned -19
  BUG: scheduling while atomic: systemd-network/697/0x00000100
  Modules linked in:
  8021q: adding VLAN 0 to HW filter on device eth1
  CPU: 0 PID: 697 Comm: systemd-network Tainted: G        W          6.6.62-8ea1fc6-dirty-cbd80d0-gcbd80d04d13c #1
  Hardware name: Generic DT based system
   unwind_backtrace from show_stack+0x18/0x1c
   show_stack from dump_stack_lvl+0x40/0x4c
   dump_stack_lvl from __schedule_bug+0x5c/0x70
   __schedule_bug from __schedule+0x884/0x968
   __schedule from schedule+0x58/0xa8
   schedule from schedule_preempt_disabled+0x14/0x18
   schedule_preempt_disabled from __mutex_lock.constprop.0+0x350/0x76c
   __mutex_lock.constprop.0 from ncsi_rsp_handler_oem_gma+0x104/0x1a0
   ncsi_rsp_handler_oem_gma from ncsi_rcv_rsp+0x120/0x2cc
   ncsi_rcv_rsp from __netif_receive_skb_one_core+0x60/0x84
   __netif_receive_skb_one_core from netif_receive_skb+0x38/0x148
   netif_receive_skb from ftgmac100_poll+0x358/0x444
   ftgmac100_poll from __napi_poll.constprop.0+0x34/0x1d0
   __napi_poll.constprop.0 from net_rx_action+0x350/0x43c
   net_rx_action from handle_softirqs+0x114/0x32c
   handle_softirqs from irq_exit+0x88/0xb8
   irq_exit from call_with_stack+0x18/0x20
   call_with_stack from __irq_usr+0x78/0xa0
  Exception stack(0xe075dfb0 to 0xe075dff8)
  dfa0:                                     00000000 00000000 00000000 00000020
  dfc0: 00000069 aefde3e0 00000000 00000000 00000000 00000000 00000000 aefde4e4
  dfe0: 01010101 aefddf20 a6b4331c a6b43618 600f0010 ffffffff

Fixes: 790071347a0a ("net/ncsi: change from ndo_set_mac_address to dev_set_mac_address")
Signed-off-by: Potin Lai <[email-masked]>
Signed-off-by: Jakub Kicinski <[email-masked]>
---
Looks like we're not making any progress on this one, so let's
go with the revert for 6.13.

Original posting by Potin Lai:
  https://lore.kernel.org/[email-masked]

I added the Fixes tag and trimmed the kernel log.

CC: [email-masked]
CC: [email-masked]
CC: [email-masked]
---
 net/ncsi/ncsi-rsp.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/net/ncsi/ncsi-rsp.c b/net/ncsi/ncsi-rsp.c
index e28be33bdf2c..0cd7b916d3f8 100644
--- a/net/ncsi/ncsi-rsp.c
+++ b/net/ncsi/ncsi-rsp.c
@@ -629,6 +629,7 @@ static int ncsi_rsp_handler_oem_gma(struct ncsi_request *nr, int mfr_id)
 {
 	struct ncsi_dev_priv *ndp = nr->ndp;
 	struct net_device *ndev = ndp->ndev.dev;
+	const struct net_device_ops *ops = ndev->netdev_ops;
 	struct ncsi_rsp_oem_pkt *rsp;
 	struct sockaddr saddr;
 	u32 mac_addr_off = 0;
@@ -655,9 +656,7 @@ static int ncsi_rsp_handler_oem_gma(struct ncsi_request *nr, int mfr_id)
 	/* Set the flag for GMA command which should only be called once */
 	ndp->gma_flag = 1;
 
-	rtnl_lock();
-	ret = dev_set_mac_address(ndev, &saddr, NULL);
-	rtnl_unlock();
+	ret = ops->ndo_set_mac_address(ndev, &saddr);
 	if (ret < 0)
 		netdev_warn(ndev, "NCSI: 'Writing mac address to device failed\n");
 
-- 
2.47.1