Netdev List
 help / color / mirror / Atom feed
From: Petr Machata <petrm@nvidia.com>
To: Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	<netdev@vger.kernel.org>
Cc: Ido Schimmel <idosch@nvidia.com>, Petr Machata <petrm@nvidia.com>,
	<mlxsw@nvidia.com>
Subject: [PATCH net-next 1/2] mlxsw: pci: Process EQ in the IRQ handler instead of a tasklet
Date: Mon, 16 Nov 2026 11:16:46 +0100	[thread overview]
Message-ID: <fbd58ae69e81451bbbee01c663c03d2ef72cdbb9.1794823524.git.petrm@nvidia.com> (raw)
In-Reply-To: <cover.1794823524.git.petrm@nvidia.com>

mlxsw_pci_eq_irq_handler() schedules a tasklet, which then reads the EQ and
schedules NAPI instances for the CQs that have pending events. The actual
completion processing itself is done by NAPI.

The EQ processing is bounded by half of the EQ size (see credits in
mlxsw_pci_eq_tasklet()), and all it does is to ring two doorbells and call
napi_schedule(), both of which are safe to do from a hard IRQ context. The
EQ is only re-armed at the end, so the handler cannot be re-entered.

The tasklet therefore does not really serve a useful purpose: neither
structurally, nor with regards to permissible runtime operations, nor with
regards to amount of time spent in IRQ. It is just an extra deferral layer.

Drop the tasklet and do the work directly in the IRQ handler. Change
napi_schedule() to napi_schedule_irqoff() to leverage the fact that
interrupts are already masked.

Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlxsw/pci.c | 31 ++++++++---------------
 1 file changed, 11 insertions(+), 20 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/pci.c b/drivers/net/ethernet/mellanox/mlxsw/pci.c
index dceb69945d26..b2a7f568c74a 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/pci.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/pci.c
@@ -88,9 +88,6 @@ struct mlxsw_pci_queue {
 			struct napi_struct napi;
 			struct page_pool *page_pool;
 		} cq;
-		struct {
-			struct tasklet_struct tasklet;
-		} eq;
 		struct {
 			struct mlxsw_pci_queue *cq;
 		} rdq;
@@ -1111,16 +1108,19 @@ static char *mlxsw_pci_eq_sw_eqe_get(struct mlxsw_pci_queue *q)
 	return elem;
 }
 
-static void mlxsw_pci_eq_tasklet(struct tasklet_struct *t)
+static irqreturn_t mlxsw_pci_eq_irq_handler(int irq, void *dev_id)
 {
 	unsigned long active_cqns[BITS_TO_LONGS(MLXSW_PCI_CQS_MAX)];
-	struct mlxsw_pci_queue *q = from_tasklet(q, t, u.eq.tasklet);
-	struct mlxsw_pci *mlxsw_pci = q->pci;
-	int credits = q->count >> 1;
+	struct mlxsw_pci *mlxsw_pci = dev_id;
+	struct mlxsw_pci_queue *q;
 	u8 cqn, cq_count;
 	int items = 0;
+	int credits;
 	char *eqe;
 
+	q = mlxsw_pci_eq_get(mlxsw_pci);
+	credits = q->count >> 1;
+
 	memset(&active_cqns, 0, sizeof(active_cqns));
 
 	while ((eqe = mlxsw_pci_eq_sw_eqe_get(q))) {
@@ -1132,7 +1132,7 @@ static void mlxsw_pci_eq_tasklet(struct tasklet_struct *t)
 	}
 
 	if (!items)
-		return;
+		return IRQ_HANDLED;
 
 	mlxsw_pci_queue_doorbell_consumer_ring(mlxsw_pci, q);
 	mlxsw_pci_queue_doorbell_arm_consumer_ring(mlxsw_pci, q);
@@ -1140,8 +1140,10 @@ static void mlxsw_pci_eq_tasklet(struct tasklet_struct *t)
 	cq_count = mlxsw_pci->num_cqs;
 	for_each_set_bit(cqn, active_cqns, cq_count) {
 		q = mlxsw_pci_cq_get(mlxsw_pci, cqn);
-		napi_schedule(&q->u.cq.napi);
+		napi_schedule_irqoff(&q->u.cq.napi);
 	}
+
+	return IRQ_HANDLED;
 }
 
 static int mlxsw_pci_eq_init(struct mlxsw_pci *mlxsw_pci, char *mbox,
@@ -1176,7 +1178,6 @@ static int mlxsw_pci_eq_init(struct mlxsw_pci *mlxsw_pci, char *mbox,
 	err = mlxsw_cmd_sw2hw_eq(mlxsw_pci->core, mbox, q->num);
 	if (err)
 		return err;
-	tasklet_setup(&q->u.eq.tasklet, mlxsw_pci_eq_tasklet);
 	mlxsw_pci_queue_doorbell_consumer_ring(mlxsw_pci, q);
 	mlxsw_pci_queue_doorbell_arm_consumer_ring(mlxsw_pci, q);
 	return 0;
@@ -1730,16 +1731,6 @@ static void mlxsw_pci_fw_area_fini(struct mlxsw_pci *mlxsw_pci)
 	kfree(mlxsw_pci->fw_area.items);
 }
 
-static irqreturn_t mlxsw_pci_eq_irq_handler(int irq, void *dev_id)
-{
-	struct mlxsw_pci *mlxsw_pci = dev_id;
-	struct mlxsw_pci_queue *q;
-
-	q = mlxsw_pci_eq_get(mlxsw_pci);
-	tasklet_schedule(&q->u.eq.tasklet);
-	return IRQ_HANDLED;
-}
-
 static int mlxsw_pci_mbox_alloc(struct mlxsw_pci *mlxsw_pci,
 				struct mlxsw_pci_mem_item *mbox)
 {
-- 
2.56.1


  reply	other threads:[~2026-11-16 10:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 10:16 [PATCH net-next 0/2] mlxsw: Fix teardown order of CQ NAPI instances Petr Machata
2026-11-16 10:16 ` Petr Machata [this message]
2026-11-16 10:16 ` [PATCH net-next 2/2] mlxsw: pci: " Petr Machata
2026-11-16 10:21 ` [PATCH net-next 0/2] mlxsw: " netdev-bot+sinfo

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=fbd58ae69e81451bbbee01c663c03d2ef72cdbb9.1794823524.git.petrm@nvidia.com \
    --to=petrm@nvidia.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=mlxsw@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox