netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v2] net: liquidio: release resources when liquidio driver open failed
@ 2022-11-10 10:30 Zhengchao Shao
  2022-11-10 10:38 ` Leon Romanovsky
  2022-11-14 10:10 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Zhengchao Shao @ 2022-11-10 10:30 UTC (permalink / raw)
  To: netdev, dchickles, sburla, fmanlunas, davem, edumazet, kuba,
	pabeni, richardcochran
  Cc: rvatsavayi, gregkh, tseewald, weiyongjun1, yuehaibing,
	shaozhengchao

When liquidio driver open failed, it doesn't release resources. Compile
tested only.

Fixes: 5b07aee11227 ("liquidio: MSIX support for CN23XX")
Fixes: dbc97bfd3918 ("net: liquidio: Add missing null pointer checks")
Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
---
v2: simplify "if" judgment statements
---
 .../net/ethernet/cavium/liquidio/lio_main.c   | 34 ++++++++++++++-----
 1 file changed, 26 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c b/drivers/net/ethernet/cavium/liquidio/lio_main.c
index d312bd594935..75771825c3f9 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
@@ -1794,13 +1794,10 @@ static int liquidio_open(struct net_device *netdev)
 
 	ifstate_set(lio, LIO_IFSTATE_RUNNING);
 
-	if (OCTEON_CN23XX_PF(oct)) {
-		if (!oct->msix_on)
-			if (setup_tx_poll_fn(netdev))
-				return -1;
-	} else {
-		if (setup_tx_poll_fn(netdev))
-			return -1;
+	if (!OCTEON_CN23XX_PF(oct) || (OCTEON_CN23XX_PF(oct) && !oct->msix_on)) {
+		ret = setup_tx_poll_fn(netdev);
+		if (ret)
+			goto err_poll;
 	}
 
 	netif_tx_start_all_queues(netdev);
@@ -1813,7 +1810,7 @@ static int liquidio_open(struct net_device *netdev)
 	/* tell Octeon to start forwarding packets to host */
 	ret = send_rx_ctrl_cmd(lio, 1);
 	if (ret)
-		return ret;
+		goto err_rx_ctrl;
 
 	/* start periodical statistics fetch */
 	INIT_DELAYED_WORK(&lio->stats_wk.work, lio_fetch_stats);
@@ -1824,6 +1821,27 @@ static int liquidio_open(struct net_device *netdev)
 	dev_info(&oct->pci_dev->dev, "%s interface is opened\n",
 		 netdev->name);
 
+	return 0;
+
+err_rx_ctrl:
+	if (!OCTEON_CN23XX_PF(oct) || (OCTEON_CN23XX_PF(oct) && !oct->msix_on))
+		cleanup_tx_poll_fn(netdev);
+err_poll:
+	if (lio->ptp_clock) {
+		ptp_clock_unregister(lio->ptp_clock);
+		lio->ptp_clock = NULL;
+	}
+
+	if (oct->props[lio->ifidx].napi_enabled == 1) {
+		list_for_each_entry_safe(napi, n, &netdev->napi_list, dev_list)
+			napi_disable(napi);
+
+		oct->props[lio->ifidx].napi_enabled = 0;
+
+		if (OCTEON_CN23XX_PF(oct))
+			oct->droq[0]->ops.poll_mode = 0;
+	}
+
 	return ret;
 }
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net v2] net: liquidio: release resources when liquidio driver open failed
  2022-11-10 10:30 [PATCH net v2] net: liquidio: release resources when liquidio driver open failed Zhengchao Shao
@ 2022-11-10 10:38 ` Leon Romanovsky
  2022-11-14 10:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Leon Romanovsky @ 2022-11-10 10:38 UTC (permalink / raw)
  To: Zhengchao Shao
  Cc: netdev, dchickles, sburla, fmanlunas, davem, edumazet, kuba,
	pabeni, richardcochran, rvatsavayi, gregkh, tseewald, weiyongjun1,
	yuehaibing

On Thu, Nov 10, 2022 at 06:30:37PM +0800, Zhengchao Shao wrote:
> When liquidio driver open failed, it doesn't release resources. Compile
> tested only.
> 
> Fixes: 5b07aee11227 ("liquidio: MSIX support for CN23XX")
> Fixes: dbc97bfd3918 ("net: liquidio: Add missing null pointer checks")
> Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
> ---
> v2: simplify "if" judgment statements
> ---
>  .../net/ethernet/cavium/liquidio/lio_main.c   | 34 ++++++++++++++-----
>  1 file changed, 26 insertions(+), 8 deletions(-)
> 

Thanks,
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net v2] net: liquidio: release resources when liquidio driver open failed
  2022-11-10 10:30 [PATCH net v2] net: liquidio: release resources when liquidio driver open failed Zhengchao Shao
  2022-11-10 10:38 ` Leon Romanovsky
@ 2022-11-14 10:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-11-14 10:10 UTC (permalink / raw)
  To: Zhengchao Shao
  Cc: netdev, dchickles, sburla, fmanlunas, davem, edumazet, kuba,
	pabeni, richardcochran, rvatsavayi, gregkh, tseewald, weiyongjun1,
	yuehaibing

Hello:

This patch was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:

On Thu, 10 Nov 2022 18:30:37 +0800 you wrote:
> When liquidio driver open failed, it doesn't release resources. Compile
> tested only.
> 
> Fixes: 5b07aee11227 ("liquidio: MSIX support for CN23XX")
> Fixes: dbc97bfd3918 ("net: liquidio: Add missing null pointer checks")
> Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
> 
> [...]

Here is the summary with links:
  - [net,v2] net: liquidio: release resources when liquidio driver open failed
    https://git.kernel.org/netdev/net/c/8979f428a4af

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-11-14 10:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-10 10:30 [PATCH net v2] net: liquidio: release resources when liquidio driver open failed Zhengchao Shao
2022-11-10 10:38 ` Leon Romanovsky
2022-11-14 10:10 ` patchwork-bot+netdevbpf

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).