* [PATCH wireless-next] wil6210: Do not use embedded netdev in wil6210_priv
@ 2024-05-03 10:32 Breno Leitao
2024-05-04 14:48 ` Simon Horman
2024-05-07 10:05 ` Kalle Valo
0 siblings, 2 replies; 3+ messages in thread
From: Breno Leitao @ 2024-05-03 10:32 UTC (permalink / raw)
To: Kalle Valo
Cc: netdev, merez, quic_ailizaro,
open list:WILOCITY WIL6210 WIRELESS DRIVER, open list
Embedding net_device into structures prohibits the usage of flexible
arrays in the net_device structure. For more details, see the discussion
at [1].
Un-embed the net_device from struct wil6210_priv by converting it
into a pointer. Then use the leverage alloc_netdev_dummy() to allocate
the net_device object at wil_if_add(). The free of the device
occurs at wil_if_remove().
[1] https://lore.kernel.org/all/20240229225910.79e224cf@kernel.org/
Signed-off-by: Breno Leitao <leitao@debian.org>
---
drivers/net/wireless/ath/wil6210/netdev.c | 21 +++++++++++++++------
drivers/net/wireless/ath/wil6210/wil6210.h | 2 +-
2 files changed, 16 insertions(+), 7 deletions(-)
PS: I only compile-tested this patch due to lack of hardware.
diff --git a/drivers/net/wireless/ath/wil6210/netdev.c b/drivers/net/wireless/ath/wil6210/netdev.c
index ee7d7e9c2718..d5d364683c0e 100644
--- a/drivers/net/wireless/ath/wil6210/netdev.c
+++ b/drivers/net/wireless/ath/wil6210/netdev.c
@@ -453,16 +453,21 @@ int wil_if_add(struct wil6210_priv *wil)
return rc;
}
- init_dummy_netdev(&wil->napi_ndev);
+ wil->napi_ndev = alloc_netdev_dummy(0);
+ if (!wil->napi_ndev) {
+ wil_err(wil, "failed to allocate dummy netdev");
+ rc = -ENOMEM;
+ goto out_wiphy;
+ }
if (wil->use_enhanced_dma_hw) {
- netif_napi_add(&wil->napi_ndev, &wil->napi_rx,
+ netif_napi_add(wil->napi_ndev, &wil->napi_rx,
wil6210_netdev_poll_rx_edma);
- netif_napi_add_tx(&wil->napi_ndev,
+ netif_napi_add_tx(wil->napi_ndev,
&wil->napi_tx, wil6210_netdev_poll_tx_edma);
} else {
- netif_napi_add(&wil->napi_ndev, &wil->napi_rx,
+ netif_napi_add(wil->napi_ndev, &wil->napi_rx,
wil6210_netdev_poll_rx);
- netif_napi_add_tx(&wil->napi_ndev,
+ netif_napi_add_tx(wil->napi_ndev,
&wil->napi_tx, wil6210_netdev_poll_tx);
}
@@ -474,10 +479,12 @@ int wil_if_add(struct wil6210_priv *wil)
wiphy_unlock(wiphy);
rtnl_unlock();
if (rc < 0)
- goto out_wiphy;
+ goto free_dummy;
return 0;
+free_dummy:
+ free_netdev(wil->napi_ndev);
out_wiphy:
wiphy_unregister(wiphy);
return rc;
@@ -554,5 +561,7 @@ void wil_if_remove(struct wil6210_priv *wil)
netif_napi_del(&wil->napi_tx);
netif_napi_del(&wil->napi_rx);
+ free_netdev(wil->napi_ndev);
+
wiphy_unregister(wiphy);
}
diff --git a/drivers/net/wireless/ath/wil6210/wil6210.h b/drivers/net/wireless/ath/wil6210/wil6210.h
index 22a6eb3e12b7..9bd1286d2857 100644
--- a/drivers/net/wireless/ath/wil6210/wil6210.h
+++ b/drivers/net/wireless/ath/wil6210/wil6210.h
@@ -983,7 +983,7 @@ struct wil6210_priv {
spinlock_t eap_lock; /* guarding access to eap rekey fields */
struct napi_struct napi_rx;
struct napi_struct napi_tx;
- struct net_device napi_ndev; /* dummy net_device serving all VIFs */
+ struct net_device *napi_ndev; /* dummy net_device serving all VIFs */
/* DMA related */
struct wil_ring ring_rx;
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH wireless-next] wil6210: Do not use embedded netdev in wil6210_priv
2024-05-03 10:32 [PATCH wireless-next] wil6210: Do not use embedded netdev in wil6210_priv Breno Leitao
@ 2024-05-04 14:48 ` Simon Horman
2024-05-07 10:05 ` Kalle Valo
1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2024-05-04 14:48 UTC (permalink / raw)
To: Breno Leitao
Cc: Kalle Valo, netdev, merez, quic_ailizaro, linux-wireless,
linux-kernel
On Fri, May 03, 2024 at 03:32:56AM -0700, Breno Leitao wrote:
> Embedding net_device into structures prohibits the usage of flexible
> arrays in the net_device structure. For more details, see the discussion
> at [1].
>
> Un-embed the net_device from struct wil6210_priv by converting it
> into a pointer. Then use the leverage alloc_netdev_dummy() to allocate
> the net_device object at wil_if_add(). The free of the device
> occurs at wil_if_remove().
>
> [1] https://lore.kernel.org/all/20240229225910.79e224cf@kernel.org/
>
> Signed-off-by: Breno Leitao <leitao@debian.org>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH wireless-next] wil6210: Do not use embedded netdev in wil6210_priv
2024-05-03 10:32 [PATCH wireless-next] wil6210: Do not use embedded netdev in wil6210_priv Breno Leitao
2024-05-04 14:48 ` Simon Horman
@ 2024-05-07 10:05 ` Kalle Valo
1 sibling, 0 replies; 3+ messages in thread
From: Kalle Valo @ 2024-05-07 10:05 UTC (permalink / raw)
To: Breno Leitao
Cc: netdev, merez, quic_ailizaro,
open list:WILOCITY WIL6210 WIRELESS DRIVER, open list
Breno Leitao <leitao@debian.org> wrote:
> Embedding net_device into structures prohibits the usage of flexible
> arrays in the net_device structure. For more details, see the discussion
> at [1].
>
> Un-embed the net_device from struct wil6210_priv by converting it
> into a pointer. Then use the leverage alloc_netdev_dummy() to allocate
> the net_device object at wil_if_add(). The free of the device
> occurs at wil_if_remove().
>
> Link: https://lore.kernel.org/all/20240229225910.79e224cf@kernel.org/ [1]
> Signed-off-by: Breno Leitao <leitao@debian.org>
> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Patch applied to ath-next branch of ath.git, thanks.
10d2b4f4aa0b wifi: wil6210: Do not use embedded netdev in wil6210_priv
--
https://patchwork.kernel.org/project/linux-wireless/patch/20240503103304.339489-1-leitao@debian.org/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-05-07 10:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-03 10:32 [PATCH wireless-next] wil6210: Do not use embedded netdev in wil6210_priv Breno Leitao
2024-05-04 14:48 ` Simon Horman
2024-05-07 10:05 ` Kalle Valo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).