Netdev List
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: oscmaes92@gmail.com
Cc: Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com,
	andrew@lunn.ch
Subject: Re: [PATCH net] pcnet32: stop holding device spin lock during napi_complete_done
Date: Mon,  1 Jun 2026 19:44:28 -0700	[thread overview]
Message-ID: <20260602024428.1664921-1-kuba@kernel.org> (raw)
In-Reply-To: <20260528140320.5556-1-oscmaes92@gmail.com>

This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
---
pcnet32: stop holding device spin lock during napi_complete_done

This commit removes the lp->lock spinlock hold around napi_complete_done()
to avoid a potential deadlock with pcnet32_start_xmit() if a GRO flush
were to occur.

> diff --git a/drivers/net/ethernet/amd/pcnet32.c b/drivers/net/ethernet/amd/pcnet32.c
> index 911808ab13a79..4f3076d4ea34e 100644
> --- a/drivers/net/ethernet/amd/pcnet32.c
> +++ b/drivers/net/ethernet/amd/pcnet32.c
> @@ -1407,8 +1407,10 @@ static int pcnet32_poll(struct napi_struct *napi, int budget)
>  		pcnet32_restart(dev, CSR0_START);
>  		netif_wake_queue(dev);
>  	}
> +	spin_unlock_irqrestore(&lp->lock, flags);
>  
>  	if (work_done < budget && napi_complete_done(napi, work_done)) {
> +		spin_lock_irqsave(&lp->lock, flags);

[Severity: High]
Does dropping the spinlock before napi_complete_done() introduce a race
condition with shared IRQs that breaks NAPI interrupt mitigation?

If napi_complete_done() clears the NAPIF_STATE_SCHED bit, marking the
NAPI poll as complete, a shared IRQ could fire on another CPU.

If pcnet32_interrupt() then acquires lp->lock and checks csr0 without
checking the INTR bit, could it process pending events and successfully
call napi_schedule_prep()?

If pcnet32_interrupt() schedules NAPI and releases the lock, this code
would then resume, re-acquire lp->lock, and unconditionally unmask
device interrupts.

This could leave the system in a state where NAPI is scheduled but
hardware interrupts are enabled, resulting in an interrupt storm on
every subsequent packet.

>  		/* clear interrupt masks */
>  		val = lp->a->read_csr(ioaddr, CSR3);
>  		val &= 0x00ff;
> @@ -1416,9 +1418,9 @@ static int pcnet32_poll(struct napi_struct *napi, int budget)
>  
>  		/* Set interrupt enable. */
>  		lp->a->write_csr(ioaddr, CSR0, CSR0_INTEN);
> +		spin_unlock_irqrestore(&lp->lock, flags);
>  	}
>  
> -	spin_unlock_irqrestore(&lp->lock, flags);
>  	return work_done;
>  }
-- 
pw-bot: cr

  parent reply	other threads:[~2026-06-02  2:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-28 14:03 [PATCH net] pcnet32: stop holding device spin lock during napi_complete_done Oscar Maes
2026-05-28 14:55 ` Alexander Lobakin
2026-05-28 17:07   ` Oscar Maes
2026-05-29 15:21     ` Alexander Lobakin
2026-06-02  2:44 ` Jakub Kicinski [this message]
2026-06-02 16:41   ` Oscar Maes
2026-06-02 18:34     ` Jakub Kicinski
2026-06-02 18:40 ` 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=20260602024428.1664921-1-kuba@kernel.org \
    --to=kuba@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=edumazet@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=oscmaes92@gmail.com \
    --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