public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Marek Vasut <marex@nabladev.com>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: netdev@vger.kernel.org, stable@vger.kernel.org,
	"David S. Miller" <davem@davemloft.net>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>,
	Nicolai Buchwitz <nb@tipi-net.de>,
	Paolo Abeni <pabeni@redhat.com>,
	Ronald Wahl <ronald.wahl@raritan.com>,
	Yicong Hui <yiconghui@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [net,PATCH v3 1/2] net: ks8851: Reinstate disabling of BHs around IRQ handler
Date: Tue, 14 Apr 2026 16:20:46 +0200	[thread overview]
Message-ID: <2fcfb84f-69f6-493e-94d6-95d85d8000f6@nabladev.com> (raw)
In-Reply-To: <20260414125753.Im6GAIHn@linutronix.de>

On 4/14/26 2:57 PM, Sebastian Andrzej Siewior wrote:
> On 2026-04-14 12:32:52 [+0200], Marek Vasut wrote:
>> If CONFIG_PREEMPT_RT=y is set AND the driver executes ks8851_irq() AND
>> KSZ_ISR register bit IRQ_RXI is set AND ks8851_rx_pkts() detects that
>> there are packets in the RX FIFO, then netdev_alloc_skb_ip_align() is
>> called to allocate SKBs. If netdev_alloc_skb_ip_align() is called with
>> BH enabled, local_bh_enable() at the end of netdev_alloc_skb_ip_align()
>> will call __local_bh_enable_ip(), which will call __do_softirq(), which
>> may trigger net_tx_action() softirq, which may ultimately call the xmit
>> callback ks8851_start_xmit_par(). The ks8851_start_xmit_par() will try
>> to lock struct ks8851_net_par .lock spinlock, which is already locked
>> by ks8851_irq() from which ks8851_start_xmit_par() was called. This
>> leads to a deadlock, which is reported by the kernel, including a trace
>> listed below.
> 
> #1 [received RX packet and a] TX packet has been sent
> #2 Driver enables TX queue via netif_wake_queue() which schedules TX
>     softirq to queue packets for this device.
> #2 After spin_unlock_bh(&ks->statelock) the pending softirqs will be
>     processed
> #3 This deadlocks because of recursive locking via ks8851_net::lock in
>     ks8851_irq() and ks8851_start_xmit_par().
> 
> This is what happens since commit 0913ec336a6c0 ("net: ks8851: Fix
> deadlock with the SPI chip variant"). Before that commit the softirq
> execution will be picked up by netdev_alloc_skb_ip_align() and requires
> PREEMPT_RT and a RX packet in #1 to trigger the deadlock.

Do you want me to add this into the V4 commit message ?

>> Fix the problem by disabling BH around critical sections, including the
>> IRQ handler, thus preventing the net_tx_action() softirq from triggering
>> during these critical sections. The net_tx_action() softirq is triggered
>> at the end of the IRQ handler, once all the other IRQ handler actions have
>> been completed.
>>
>>   __schedule from schedule_rtlock+0x1c/0x34
>>   schedule_rtlock from rtlock_slowlock_locked+0x548/0x904
>>   rtlock_slowlock_locked from rt_spin_lock+0x60/0x9c
>>   rt_spin_lock from ks8851_start_xmit_par+0x74/0x1a8
>>   ks8851_start_xmit_par from netdev_start_xmit+0x20/0x44
>>   netdev_start_xmit from dev_hard_start_xmit+0xd0/0x188
>>   dev_hard_start_xmit from sch_direct_xmit+0xb8/0x25c
>>   sch_direct_xmit from __qdisc_run+0x1f8/0x4ec
>>   __qdisc_run from qdisc_run+0x1c/0x28
>>   qdisc_run from net_tx_action+0x1f0/0x268
>>   net_tx_action from handle_softirqs+0x1a4/0x270
>>   handle_softirqs from __local_bh_enable_ip+0xcc/0xe0
>>   __local_bh_enable_ip from __alloc_skb+0xd8/0x128
>>   __alloc_skb from __netdev_alloc_skb+0x3c/0x19c
>>   __netdev_alloc_skb from ks8851_irq+0x388/0x4d4
>>   ks8851_irq from irq_thread_fn+0x24/0x64
>>   irq_thread_fn from irq_thread+0x178/0x28c
>>   irq_thread from kthread+0x12c/0x138
>>   kthread from ret_from_fork+0x14/0x28
> 
> The backtrace here and the description is based on an older kernel.
> However
I actually did update the backtrace in V3 with the one from current next 
20260413 .

  reply	other threads:[~2026-04-14 14:20 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-14 10:32 [net,PATCH v3 1/2] net: ks8851: Reinstate disabling of BHs around IRQ handler Marek Vasut
2026-04-14 10:32 ` [net,PATCH v3 2/2] net: ks8851: Avoid excess softirq scheduling Marek Vasut
2026-04-14 13:02   ` Sebastian Andrzej Siewior
2026-04-14 12:57 ` [net,PATCH v3 1/2] net: ks8851: Reinstate disabling of BHs around IRQ handler Sebastian Andrzej Siewior
2026-04-14 14:20   ` Marek Vasut [this message]
2026-04-14 14:52     ` Sebastian Andrzej Siewior
2026-04-15 23:14       ` Marek Vasut
2026-04-16  6:21         ` Sebastian Andrzej Siewior
2026-04-16  9:26           ` Marek Vasut
2026-04-16 10:48             ` Sebastian Andrzej Siewior
2026-04-14 15:09   ` Jakub Kicinski
2026-04-14 15:29     ` Jakub Kicinski

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=2fcfb84f-69f6-493e-94d6-95d85d8000f6@nabladev.com \
    --to=marex@nabladev.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=bigeasy@linutronix.de \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nb@tipi-net.de \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=ronald.wahl@raritan.com \
    --cc=stable@vger.kernel.org \
    --cc=yiconghui@gmail.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