Subject: Re: [PATCH v2] net: ks8851: Fix deadlock with the SPI chip variant

From: Jakub Kicinski <[email-masked]>
Date: Fri, 5 Jul 2024 17:39:31 -0700

On Thu,  4 Jul 2024 19:47:56 +0200 Ronald Wahl wrote:
> --- a/drivers/net/ethernet/micrel/ks8851_spi.c
> +++ b/drivers/net/ethernet/micrel/ks8851_spi.c
> @@ -385,7 +385,7 @@ static netdev_tx_t ks8851_start_xmit_spi(struct sk_buff *skb,
>  	netif_dbg(ks, tx_queued, ks->netdev,
>  		  "%s: skb %p, %d@%p\n", __func__, skb, skb->len, skb->data);
> 
> -	spin_lock(&ks->statelock);
> +	spin_lock_bh(&ks->statelock);
> 
>  	if (ks->queued_len + needed > ks->tx_space) {
>  		netif_stop_queue(dev);
> @@ -395,7 +395,7 @@ static netdev_tx_t ks8851_start_xmit_spi(struct sk_buff *skb,
>  		skb_queue_tail(&ks->txq, skb);
>  	}
> 
> -	spin_unlock(&ks->statelock);
> +	spin_unlock_bh(&ks->statelock);

this one probably can stay as spin_lock() since networking stack only
calls xmit in BH context. But I see 2 other spin_lock(statelock) in the
driver which I'm not as sure about. Any taking of this lock has to be
_bh() unless you're sure the caller is already in BH.