All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com,
	andrew+netdev@lunn.ch, horms@kernel.org, almasrymina@google.com,
	michael.chan@broadcom.com, tariqt@nvidia.com,
	dtatulea@nvidia.com, hawk@kernel.org,
	ilias.apalodimas@linaro.org, alexanderduyck@fb.com,
	sdf@fomichev.me, Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH net-next 06/15] eth: fbnic: request ops lock
Date: Tue, 19 Aug 2025 19:56:55 -0700	[thread overview]
Message-ID: <20250820025704.166248-7-kuba@kernel.org> (raw)
In-Reply-To: <20250820025704.166248-1-kuba@kernel.org>

We'll add queue ops soon so. queue ops will opt the driver into
extra locking. Request this locking explicitly already to make
future patches smaller and easier to review.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 drivers/net/ethernet/meta/fbnic/fbnic_netdev.c |  2 ++
 drivers/net/ethernet/meta/fbnic/fbnic_pci.c    |  9 ++++++++-
 drivers/net/ethernet/meta/fbnic/fbnic_txrx.c   | 15 ++++++++-------
 3 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_netdev.c b/drivers/net/ethernet/meta/fbnic/fbnic_netdev.c
index b8b684ad376b..37c900ce8257 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_netdev.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_netdev.c
@@ -750,6 +750,8 @@ struct net_device *fbnic_netdev_alloc(struct fbnic_dev *fbd)
 
 	fbnic_set_ethtool_ops(netdev);
 
+	netdev->request_ops_lock = true;
+
 	fbn = netdev_priv(netdev);
 
 	fbn->netdev = netdev;
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_pci.c b/drivers/net/ethernet/meta/fbnic/fbnic_pci.c
index b70e4cadb37b..bc51e1e4846e 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_pci.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_pci.c
@@ -206,8 +206,11 @@ static void fbnic_service_task(struct work_struct *work)
 
 	fbnic_health_check(fbd);
 
-	if (netif_carrier_ok(fbd->netdev))
+	if (netif_carrier_ok(fbd->netdev)) {
+		netdev_lock(fbd->netdev);
 		fbnic_napi_depletion_check(fbd->netdev);
+		netdev_unlock(fbd->netdev);
+	}
 
 	if (netif_running(fbd->netdev))
 		schedule_delayed_work(&fbd->service_task, HZ);
@@ -392,12 +395,14 @@ static int fbnic_pm_suspend(struct device *dev)
 		goto null_uc_addr;
 
 	rtnl_lock();
+	netdev_lock(netdev);
 
 	netif_device_detach(netdev);
 
 	if (netif_running(netdev))
 		netdev->netdev_ops->ndo_stop(netdev);
 
+	netdev_unlock(netdev);
 	rtnl_unlock();
 
 null_uc_addr:
@@ -463,6 +468,7 @@ static int __fbnic_pm_resume(struct device *dev)
 	fbnic_reset_queues(fbn, fbn->num_tx_queues, fbn->num_rx_queues);
 
 	rtnl_lock();
+	netdev_lock(netdev);
 
 	if (netif_running(netdev)) {
 		err = __fbnic_open(fbn);
@@ -470,6 +476,7 @@ static int __fbnic_pm_resume(struct device *dev)
 			goto err_free_mbx;
 	}
 
+	netdev_unlock(netdev);
 	rtnl_unlock();
 
 	return 0;
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
index 8dbe83bc2be1..dc0735b20739 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
@@ -1501,7 +1501,7 @@ static void fbnic_free_napi_vector(struct fbnic_net *fbn,
 	}
 
 	fbnic_napi_free_irq(fbd, nv);
-	netif_napi_del(&nv->napi);
+	netif_napi_del_locked(&nv->napi);
 	fbn->napi[fbnic_napi_idx(nv)] = NULL;
 	kfree(nv);
 }
@@ -1611,11 +1611,12 @@ static int fbnic_alloc_napi_vector(struct fbnic_dev *fbd, struct fbnic_net *fbn,
 
 	/* Tie napi to netdev */
 	fbn->napi[fbnic_napi_idx(nv)] = nv;
-	netif_napi_add(fbn->netdev, &nv->napi, fbnic_poll);
+	netif_napi_add_locked(fbn->netdev, &nv->napi, fbnic_poll);
 
 	/* Record IRQ to NAPI struct */
-	netif_napi_set_irq(&nv->napi,
-			   pci_irq_vector(to_pci_dev(fbd->dev), nv->v_idx));
+	netif_napi_set_irq_locked(&nv->napi,
+				  pci_irq_vector(to_pci_dev(fbd->dev),
+						 nv->v_idx));
 
 	/* Tie nv back to PCIe dev */
 	nv->dev = fbd->dev;
@@ -1704,7 +1705,7 @@ static int fbnic_alloc_napi_vector(struct fbnic_dev *fbd, struct fbnic_net *fbn,
 	return 0;
 
 napi_del:
-	netif_napi_del(&nv->napi);
+	netif_napi_del_locked(&nv->napi);
 	fbn->napi[fbnic_napi_idx(nv)] = NULL;
 	kfree(nv);
 	return err;
@@ -2173,7 +2174,7 @@ void fbnic_napi_disable(struct fbnic_net *fbn)
 	int i;
 
 	for (i = 0; i < fbn->num_napi; i++) {
-		napi_disable(&fbn->napi[i]->napi);
+		napi_disable_locked(&fbn->napi[i]->napi);
 
 		fbnic_nv_irq_disable(fbn->napi[i]);
 	}
@@ -2621,7 +2622,7 @@ void fbnic_napi_enable(struct fbnic_net *fbn)
 	for (i = 0; i < fbn->num_napi; i++) {
 		struct fbnic_napi_vector *nv = fbn->napi[i];
 
-		napi_enable(&nv->napi);
+		napi_enable_locked(&nv->napi);
 
 		fbnic_nv_irq_enable(nv);
 
-- 
2.50.1


  parent reply	other threads:[~2025-08-20  2:57 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-20  2:56 [PATCH net-next 00/15] eth: fbnic: support queue API and zero-copy Rx Jakub Kicinski
2025-08-20  2:56 ` [PATCH net-next 01/15] net: page_pool: add page_pool_get() Jakub Kicinski
2025-08-20 10:35   ` Jesper Dangaard Brouer
2025-08-20 10:58   ` Dragos Tatulea
2025-08-20 23:11   ` Mina Almasry
2025-08-20  2:56 ` [PATCH net-next 02/15] eth: fbnic: move page pool pointer from NAPI to the ring struct Jakub Kicinski
2025-08-20  2:56 ` [PATCH net-next 03/15] eth: fbnic: move xdp_rxq_info_reg() to resource alloc Jakub Kicinski
2025-08-20  2:56 ` [PATCH net-next 04/15] eth: fbnic: move page pool alloc to fbnic_alloc_rx_qt_resources() Jakub Kicinski
2025-08-20  2:56 ` [PATCH net-next 05/15] eth: fbnic: use netmem_ref where applicable Jakub Kicinski
2025-08-20 23:22   ` Mina Almasry
2025-08-20  2:56 ` Jakub Kicinski [this message]
2025-08-20  2:56 ` [PATCH net-next 07/15] eth: fbnic: split fbnic_disable() Jakub Kicinski
2025-08-20  2:56 ` [PATCH net-next 08/15] eth: fbnic: split fbnic_flush() Jakub Kicinski
2025-08-20  2:56 ` [PATCH net-next 09/15] eth: fbnic: split fbnic_enable() Jakub Kicinski
2025-08-20  2:56 ` [PATCH net-next 10/15] eth: fbnic: split fbnic_fill() Jakub Kicinski
2025-08-20  2:57 ` [PATCH net-next 11/15] net: page_pool: add helper to pre-check if PP will be unreadable Jakub Kicinski
2025-08-20 11:30   ` Dragos Tatulea
2025-08-20 14:52     ` Jakub Kicinski
2025-08-20 17:45       ` Dragos Tatulea
2025-08-20  2:57 ` [PATCH net-next 12/15] eth: fbnic: allocate unreadable page pool for the payloads Jakub Kicinski
2025-08-20 23:33   ` Mina Almasry
2025-08-21  0:45     ` Jakub Kicinski
2025-08-20  2:57 ` [PATCH net-next 13/15] eth: fbnic: defer page pool recycling activation to queue start Jakub Kicinski
2025-08-20  2:57 ` [PATCH net-next 14/15] eth: fbnic: don't pass NAPI into pp alloc Jakub Kicinski
2025-08-20  2:57 ` [PATCH net-next 15/15] eth: fbnic: support queue ops / zero-copy Rx Jakub Kicinski
2025-08-21  7:51 ` [PATCH net-next 00/15] eth: fbnic: support queue API and " Paolo Abeni
2025-08-21 14:28   ` Jakub Kicinski
2025-08-21 14:53     ` Taehee Yoo
2025-08-21 15:03       ` Jakub Kicinski
2025-08-21 15:22         ` Mina Almasry
2025-08-21 15:42           ` Jakub Kicinski
2025-08-21 15:02     ` Paolo Abeni
2025-08-21 15:20 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250820025704.166248-7-kuba@kernel.org \
    --to=kuba@kernel.org \
    --cc=alexanderduyck@fb.com \
    --cc=almasrymina@google.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=dtatulea@nvidia.com \
    --cc=edumazet@google.com \
    --cc=hawk@kernel.org \
    --cc=horms@kernel.org \
    --cc=ilias.apalodimas@linaro.org \
    --cc=michael.chan@broadcom.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@fomichev.me \
    --cc=tariqt@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.