[PATCH net-next] net: ethernet: ti: am65-cpsw: Fix xdp_rxq error for disabled port
From: Julien Panis
Date: Thu Apr 18 2024 - 11:35:49 EST
When an ethX port is disabled in the device tree, an error is returned
by xdp_rxq_info_reg() function while transitioning the CPSW device to
the up state. The message 'Missing net_device from driver' is output.
This patch fixes the issue by registering xdp_rxq info only if ethX
port is enabled (i.e. ndev pointer is not NULL).
Fixes: 8acacc40f733 ("net: ethernet: ti: am65-cpsw: Add minimal XDP support")
Link: https://lore.kernel.org/all/260d258f-87a1-4aac-8883-aab4746b32d8@xxxxxx/
Reported-by: Siddharth Vadapalli <s-vadapalli@xxxxxx>
Closes: https://gist.github.com/Siddharth-Vadapalli-at-TI/5ed0e436606001c247a7da664f75edee
Signed-off-by: Julien Panis <jpanis@xxxxxxxxxxxx>
---
When an ethX port is disabled in the device tree, an error is returned
by xdp_rxq_info_reg() function while transitioning the CPSW device to
the up state. The following message is output:
[ 1.966094] Missing net_device from driver
[ 1.966154] WARNING: CPU: 2 PID: 1 at net/core/xdp.c:173 __xdp_rxq_info_reg+0xcc/0xd8
[ 1.978064] Modules linked in:
[ 1.981113] CPU: 2 PID: 1 Comm: swapper/0 Not tainted 6.9.0-rc4-next-20240417 #1
[ 1.988494] Hardware name: Texas Instruments AM62A7 SK (DT)
[ 1.993944] mmc1: new high speed SDHC card at address aaaa
[ 1.994051] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[ 2.000135] mmcblk1: mmc1:aaaa SL32G 29.7 GiB
[ 2.006459] pc : __xdp_rxq_info_reg+0xcc/0xd8
[ 2.006468] lr : __xdp_rxq_info_reg+0xcc/0xd8
[ 2.006476] sp : ffff800082babad0
[ 2.006479] x29: ffff800082babad0
[ 2.015506] mmcblk1: p1 p2 p3
[ 2.019500] x28: 0000000000000440 x27: 0000000000000001
[ 2.019510] x26: ffff000800c10880 x25: ffff000801f29480 x24: 0000000000000000
[ 2.019520] x23: ffff000801f30000 x22: ffff000800c10080 x21: ffff000801f28080
[ 2.048687] x20: ffff000801e69800 x19: 0000000000000000 x18: 0000000000000028
[ 2.055813] x17: 00000000cd537234 x16: 0000000046cc0f2d x15: fffffffffffe51d8
[ 2.062938] x14: ffff8000826020f0 x13: 0000000000000396 x12: 0000000000000132
[ 2.070064] x11: fffffffffffe51d8 x10: fffffffffffe51b0 x9 : 00000000fffff132
[ 2.077189] x8 : ffff8000826020f0 x7 : ffff80008265a0f0 x6 : 0000000000000e58
[ 2.084314] x5 : 40000000fffff132 x4 : 000000000000aff5 x3 : 0000000000000000
[ 2.091439] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff000800110000
[ 2.098565] Call trace:
[ 2.101001] __xdp_rxq_info_reg+0xcc/0xd8
[ 2.105004] am65_cpsw_nuss_ndo_slave_open+0x358/0x8c4
[ 2.110137] __dev_open+0xec/0x1d8
[ 2.113533] __dev_change_flags+0x190/0x208
[ 2.117710] dev_change_flags+0x24/0x6c
[ 2.121539] ip_auto_config+0x248/0x10b4
[ 2.125456] do_one_initcall+0x6c/0x1b0
[ 2.129285] kernel_init_freeable+0x1cc/0x294
[ 2.133634] kernel_init+0x20/0x1dc
[ 2.137119] ret_from_fork+0x10/0x20
[ 2.140688] ---[ end trace 0000000000000000 ]---
[ 2.145443] am65-cpsw-nuss 8000000.ethernet: Failed to create XDP rx queues
This patch fixes the issue by registering xdp_rxq info only if ethX
port is enabled (i.e. ndev pointer is not NULL).
---
drivers/net/ethernet/ti/am65-cpsw-nuss.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
index bfba883d4fc4..022942281767 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
@@ -391,6 +391,9 @@ static void am65_cpsw_destroy_xdp_rxqs(struct am65_cpsw_common *common)
int i;
for (i = 0; i < common->port_num; i++) {
+ if (!common->ports[i].ndev)
+ continue;
+
rxq = &common->ports[i].xdp_rxq;
if (xdp_rxq_info_is_reg(rxq))
@@ -426,6 +429,9 @@ static int am65_cpsw_create_xdp_rxqs(struct am65_cpsw_common *common)
rx_chn->page_pool = pool;
for (i = 0; i < common->port_num; i++) {
+ if (!common->ports[i].ndev)
+ continue;
+
rxq = &common->ports[i].xdp_rxq;
ret = xdp_rxq_info_reg(rxq, common->ports[i].ndev, i, 0);
---
base-commit: aa37f8916d20cf58437d507fc9599492a342b3cd
change-id: 20240418-am65-cpsw-am62a-crash-2e87ae0281f5
Best regards,
--
Julien Panis <jpanis@xxxxxxxxxxxx>