Re: [net,PATCH] net: ks8851: Reinstate disabling of BHs around IRQ handler

Nicolai Buchwitz
2026-04-08T10:54:59Z

On 7.4.2026 23:23, Marek Vasut wrote:

> [...]

>
> diff --git a/drivers/net/ethernet/micrel/ks8851_common.c
> b/drivers/net/ethernet/micrel/ks8851_common.c
> index 8048770958d60..dadedea016fac 100644
> --- a/drivers/net/ethernet/micrel/ks8851_common.c
> +++ b/drivers/net/ethernet/micrel/ks8851_common.c
> @@ -316,6 +316,7 @@ static irqreturn_t ks8851_irq(int irq, void *_ks)
> unsigned int status;
> struct sk_buff *skb;
>
> + local_bh_disable();
> ks8851_lock(ks, &flags);

This breaks the SPI variant on non-RT. The SPI path sleeps in
spi_sync() -> wait_for_completion_timeout(), which can't be
done with BH disabled. Confirmed on hardware (KS8851 SPI on
CM4S, PREEMPT non-RT):

BUG: scheduling while atomic: irq/38-eth2/708/0x00000201
...
spi_transfer_one_message+0x518/0x770
__spi_pump_transfer_message+0x1dc/0x5f0
__spi_sync+0x2b4/0x460
spi_sync+0x38/0x68
ks8851_rdfifo_spi+0x60/0xc0
ks8851_irq+0x310/0x3c8

The fix needs to be PAR-specific since the SPI variant doesn't
have the deadlock problem anyway (ks8851_start_xmit_spi doesn't
take the lock).

>
> status = ks8851_rdreg16(ks, KS_ISR);
> @@ -381,6 +382,7 @@ static irqreturn_t ks8851_irq(int irq, void *_ks)
> if (status & IRQ_RXI)
> while ((skb = __skb_dequeue(&rxq)))
> netif_rx(skb);
> + local_bh_enable();
>
> return IRQ_HANDLED;
> }

In order to make this work I would propose something like this (which
works in my SPI setup):

--- a/drivers/net/ethernet/micrel/ks8851_par.c
+++ b/drivers/net/ethernet/micrel/ks8851_par.c
@@ -60,12 +60,14 @@ static void ks8851_lock_par(struct ks8851_net *ks,
unsigned long *flags)
{
struct ks8851_net_par *ksp = to_ks8851_par(ks);

+ local_bh_disable();
spin_lock_irqsave(&ksp->lock, *flags);
}

static void ks8851_unlock_par(struct ks8851_net *ks, unsigned long
*flags)
{
struct ks8851_net_par *ksp = to_ks8851_par(ks);

spin_unlock_irqrestore(&ksp->lock, *flags);
+ local_bh_enable();
}

Tested-by: Nicolai Buchwitz <nb@tipi-net.de> # KS8851 SPI, non-RT
(regression + proposed fix)