* [PATCH wireless-next] wifi: rtw88: Un-embed dummy device
@ 2024-04-25 8:29 Breno Leitao
2024-04-26 0:14 ` Ping-Ke Shih
2024-05-09 6:18 ` Ping-Ke Shih
0 siblings, 2 replies; 3+ messages in thread
From: Breno Leitao @ 2024-04-25 8:29 UTC (permalink / raw)
To: Ping-Ke Shih, Kalle Valo
Cc: leit, open list:REALTEK WIRELESS DRIVER (rtw88), 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 the private struct by converting it
into a pointer. Then use the leverage the new alloc_netdev_dummy()
helper to allocate and initialize dummy devices.
[1] https://lore.kernel.org/all/20240229225910.79e224cf@kernel.org/
Signed-off-by: Breno Leitao <leitao@debian.org>
---
drivers/net/wireless/realtek/rtw88/pci.c | 17 +++++++++++++----
drivers/net/wireless/realtek/rtw88/pci.h | 2 +-
2 files changed, 14 insertions(+), 5 deletions(-)
PS: This is compile-tested only due to lack of hardware to do better
testing.
diff --git a/drivers/net/wireless/realtek/rtw88/pci.c b/drivers/net/wireless/realtek/rtw88/pci.c
index 9986a4cb37eb..4ff4f875cefb 100644
--- a/drivers/net/wireless/realtek/rtw88/pci.c
+++ b/drivers/net/wireless/realtek/rtw88/pci.c
@@ -1681,12 +1681,16 @@ static int rtw_pci_napi_poll(struct napi_struct *napi, int budget)
return work_done;
}
-static void rtw_pci_napi_init(struct rtw_dev *rtwdev)
+static int rtw_pci_napi_init(struct rtw_dev *rtwdev)
{
struct rtw_pci *rtwpci = (struct rtw_pci *)rtwdev->priv;
- init_dummy_netdev(&rtwpci->netdev);
- netif_napi_add(&rtwpci->netdev, &rtwpci->napi, rtw_pci_napi_poll);
+ rtwpci->netdev = alloc_netdev_dummy(0);
+ if (!rtwpci->netdev)
+ return -ENOMEM;
+
+ netif_napi_add(rtwpci->netdev, &rtwpci->napi, rtw_pci_napi_poll);
+ return 0;
}
static void rtw_pci_napi_deinit(struct rtw_dev *rtwdev)
@@ -1695,6 +1699,7 @@ static void rtw_pci_napi_deinit(struct rtw_dev *rtwdev)
rtw_pci_napi_stop(rtwdev);
netif_napi_del(&rtwpci->napi);
+ free_netdev(rtwpci->netdev);
}
int rtw_pci_probe(struct pci_dev *pdev,
@@ -1744,7 +1749,11 @@ int rtw_pci_probe(struct pci_dev *pdev,
goto err_pci_declaim;
}
- rtw_pci_napi_init(rtwdev);
+ ret = rtw_pci_napi_init(rtwdev);
+ if (ret) {
+ rtw_err(rtwdev, "failed to setup NAPI\n");
+ goto err_pci_declaim;
+ }
ret = rtw_chip_info_setup(rtwdev);
if (ret) {
diff --git a/drivers/net/wireless/realtek/rtw88/pci.h b/drivers/net/wireless/realtek/rtw88/pci.h
index 0c37efd8c66f..13988db1cb4c 100644
--- a/drivers/net/wireless/realtek/rtw88/pci.h
+++ b/drivers/net/wireless/realtek/rtw88/pci.h
@@ -215,7 +215,7 @@ struct rtw_pci {
bool running;
/* napi structure */
- struct net_device netdev;
+ struct net_device *netdev;
struct napi_struct napi;
u16 rx_tag;
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [PATCH wireless-next] wifi: rtw88: Un-embed dummy device
2024-04-25 8:29 [PATCH wireless-next] wifi: rtw88: Un-embed dummy device Breno Leitao
@ 2024-04-26 0:14 ` Ping-Ke Shih
2024-05-09 6:18 ` Ping-Ke Shih
1 sibling, 0 replies; 3+ messages in thread
From: Ping-Ke Shih @ 2024-04-26 0:14 UTC (permalink / raw)
To: Breno Leitao, Kalle Valo
Cc: leit, open list:REALTEK WIRELESS DRIVER (rtw88), 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 the private struct by converting it
> into a pointer. Then use the leverage the new alloc_netdev_dummy()
> helper to allocate and initialize dummy devices.
>
> [1] https://lore.kernel.org/all/20240229225910.79e224cf@kernel.org/
>
> Signed-off-by: Breno Leitao <leitao@debian.org>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
Like patch of rtw89, I will take it to my tree weeks later.
> ---
> drivers/net/wireless/realtek/rtw88/pci.c | 17 +++++++++++++----
> drivers/net/wireless/realtek/rtw88/pci.h | 2 +-
> 2 files changed, 14 insertions(+), 5 deletions(-)
>
> PS: This is compile-tested only due to lack of hardware to do better
> testing.
Tested with real hardware RTL8723DE and RTL8822CE.
Tested-by: Ping-Ke Shih <pkshih@realtek.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH wireless-next] wifi: rtw88: Un-embed dummy device
2024-04-25 8:29 [PATCH wireless-next] wifi: rtw88: Un-embed dummy device Breno Leitao
2024-04-26 0:14 ` Ping-Ke Shih
@ 2024-05-09 6:18 ` Ping-Ke Shih
1 sibling, 0 replies; 3+ messages in thread
From: Ping-Ke Shih @ 2024-05-09 6:18 UTC (permalink / raw)
To: Breno Leitao, Ping-Ke Shih, Kalle Valo
Cc: leit, open list:REALTEK WIRELESS DRIVER (rtw88), 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 the private struct by converting it
> into a pointer. Then use the leverage the new alloc_netdev_dummy()
> helper to allocate and initialize dummy devices.
>
> [1] https://lore.kernel.org/all/20240229225910.79e224cf@kernel.org/
>
> Signed-off-by: Breno Leitao <leitao@debian.org>
> Acked-by: Ping-Ke Shih <pkshih@realtek.com>
> Tested-by: Ping-Ke Shih <pkshih@realtek.com>
1 patch(es) applied to rtw-next branch of rtw.git, thanks.
d0bcb10e7b94 wifi: rtw88: Un-embed dummy device
---
https://github.com/pkshih/rtw.git
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-05-09 6:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-25 8:29 [PATCH wireless-next] wifi: rtw88: Un-embed dummy device Breno Leitao
2024-04-26 0:14 ` Ping-Ke Shih
2024-05-09 6:18 ` Ping-Ke Shih
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).