* [PATCH net v2 0/2] fix ti-am65-cpsw-nuss module removal @ 2024-10-03 17:07 Nicolas Pitre 2024-10-03 17:07 ` [PATCH net v2 1/2] net: ethernet: ti: am65-cpsw: prevent WARN_ON upon " Nicolas Pitre 2024-10-03 17:07 ` [PATCH net v2 2/2] net: ethernet: ti: am65-cpsw: avoid devm_alloc_etherdev, fix " Nicolas Pitre 0 siblings, 2 replies; 4+ messages in thread From: Nicolas Pitre @ 2024-10-03 17:07 UTC (permalink / raw) To: David S. Miller, Paolo Abeni; +Cc: Nicolas Pitre, netdev, linux-kernel Fix issues preventing rmmod of ti-am65-cpsw-nuss from working properly. v2: - conform to netdev patch submission customs - address patch review trivias v1: https://lore.kernel.org/netdev/20240927025301.1312590-2-nico@fluxnic.net/T/ ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net v2 1/2] net: ethernet: ti: am65-cpsw: prevent WARN_ON upon module removal 2024-10-03 17:07 [PATCH net v2 0/2] fix ti-am65-cpsw-nuss module removal Nicolas Pitre @ 2024-10-03 17:07 ` Nicolas Pitre 2024-10-03 17:07 ` [PATCH net v2 2/2] net: ethernet: ti: am65-cpsw: avoid devm_alloc_etherdev, fix " Nicolas Pitre 1 sibling, 0 replies; 4+ messages in thread From: Nicolas Pitre @ 2024-10-03 17:07 UTC (permalink / raw) To: David S. Miller, Paolo Abeni; +Cc: Nicolas Pitre, netdev, linux-kernel From: Nicolas Pitre <npitre@baylibre.com> In am65_cpsw_nuss_remove(), move the call to am65_cpsw_unregister_devlink() after am65_cpsw_nuss_cleanup_ndev() to avoid triggering the WARN_ON(devlink_port->type != DEVLINK_PORT_TYPE_NOTSET) in devl_port_unregister(). Makes it coherent with usage in m65_cpsw_nuss_register_ndevs()'s cleanup path. Signed-off-by: Nicolas Pitre <npitre@baylibre.com> Fixes: 58356eb31d60 ("net: ti: am65-cpsw-nuss: Add devlink support") --- drivers/net/ethernet/ti/am65-cpsw-nuss.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c index cbe99017cb..f6bc8a4dc6 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c @@ -3652,13 +3652,13 @@ static void am65_cpsw_nuss_remove(struct platform_device *pdev) return; } - am65_cpsw_unregister_devlink(common); am65_cpsw_unregister_notifiers(common); /* must unregister ndevs here because DD release_driver routine calls * dma_deconfigure(dev) before devres_release_all(dev) */ am65_cpsw_nuss_cleanup_ndev(common); + am65_cpsw_unregister_devlink(common); am65_cpsw_nuss_phylink_cleanup(common); am65_cpts_release(common->cpts); am65_cpsw_disable_serdes_phy(common); -- 2.46.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH net v2 2/2] net: ethernet: ti: am65-cpsw: avoid devm_alloc_etherdev, fix module removal 2024-10-03 17:07 [PATCH net v2 0/2] fix ti-am65-cpsw-nuss module removal Nicolas Pitre 2024-10-03 17:07 ` [PATCH net v2 1/2] net: ethernet: ti: am65-cpsw: prevent WARN_ON upon " Nicolas Pitre @ 2024-10-03 17:07 ` Nicolas Pitre 2024-10-04 0:40 ` Jakub Kicinski 1 sibling, 1 reply; 4+ messages in thread From: Nicolas Pitre @ 2024-10-03 17:07 UTC (permalink / raw) To: David S. Miller, Paolo Abeni; +Cc: Nicolas Pitre, netdev, linux-kernel From: Nicolas Pitre <npitre@baylibre.com> Usage of devm_alloc_etherdev_mqs() conflicts with am65_cpsw_nuss_cleanup_ndev() as the same struct net_device instances get unregistered twice. Switch to alloc_etherdev_mqs() and make sure am65_cpsw_nuss_cleanup_ndev() unregisters and frees those net_device instances properly. With this, it is finally possible to rmmod the driver without oopsing the kernel. Signed-off-by: Nicolas Pitre <npitre@baylibre.com> Fixes: 93a76530316a ("net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver") --- drivers/net/ethernet/ti/am65-cpsw-nuss.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c index f6bc8a4dc6..e95457c988 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c @@ -2744,10 +2744,9 @@ am65_cpsw_nuss_init_port_ndev(struct am65_cpsw_common *common, u32 port_idx) return 0; /* alloc netdev */ - port->ndev = devm_alloc_etherdev_mqs(common->dev, - sizeof(struct am65_cpsw_ndev_priv), - AM65_CPSW_MAX_QUEUES, - AM65_CPSW_MAX_QUEUES); + port->ndev = alloc_etherdev_mqs(sizeof(struct am65_cpsw_ndev_priv), + AM65_CPSW_MAX_QUEUES, + AM65_CPSW_MAX_QUEUES); if (!port->ndev) { dev_err(dev, "error allocating slave net_device %u\n", port->port_id); @@ -2868,8 +2867,12 @@ static void am65_cpsw_nuss_cleanup_ndev(struct am65_cpsw_common *common) for (i = 0; i < common->port_num; i++) { port = &common->ports[i]; - if (port->ndev && port->ndev->reg_state == NETREG_REGISTERED) + if (!port->ndev) + continue; + if (port->ndev->reg_state == NETREG_REGISTERED) unregister_netdev(port->ndev); + free_netdev(port->ndev); + port->ndev = NULL; } } @@ -3613,16 +3616,17 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev) ret = am65_cpsw_nuss_init_ndevs(common); if (ret) - goto err_free_phylink; + goto err_ndevs_clear; ret = am65_cpsw_nuss_register_ndevs(common); if (ret) - goto err_free_phylink; + goto err_ndevs_clear; pm_runtime_put(dev); return 0; -err_free_phylink: +err_ndevs_clear: + am65_cpsw_nuss_cleanup_ndev(common); am65_cpsw_nuss_phylink_cleanup(common); am65_cpts_release(common->cpts); err_of_clear: -- 2.46.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net v2 2/2] net: ethernet: ti: am65-cpsw: avoid devm_alloc_etherdev, fix module removal 2024-10-03 17:07 ` [PATCH net v2 2/2] net: ethernet: ti: am65-cpsw: avoid devm_alloc_etherdev, fix " Nicolas Pitre @ 2024-10-04 0:40 ` Jakub Kicinski 0 siblings, 0 replies; 4+ messages in thread From: Jakub Kicinski @ 2024-10-04 0:40 UTC (permalink / raw) To: Nicolas Pitre Cc: David S. Miller, Paolo Abeni, Nicolas Pitre, netdev, linux-kernel On Thu, 3 Oct 2024 13:07:13 -0400 Nicolas Pitre wrote: > Signed-off-by: Nicolas Pitre <npitre@baylibre.com> > Fixes: 93a76530316a ("net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver") Please make sure you CC the people involved in the blamed commit. Run get_maintainers.pl on the patch not the file path. Please put your SoB after the Fixes tag (last). -- pw-bot: cr ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-10-04 0:40 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-10-03 17:07 [PATCH net v2 0/2] fix ti-am65-cpsw-nuss module removal Nicolas Pitre 2024-10-03 17:07 ` [PATCH net v2 1/2] net: ethernet: ti: am65-cpsw: prevent WARN_ON upon " Nicolas Pitre 2024-10-03 17:07 ` [PATCH net v2 2/2] net: ethernet: ti: am65-cpsw: avoid devm_alloc_etherdev, fix " Nicolas Pitre 2024-10-04 0:40 ` Jakub Kicinski
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).