Re: [PATCH] net/qla3xxx: fix schedule while atomic in ql_sem_spinlock

From: David Miller
Date: Wed May 19 2021 - 15:26:11 EST


From: Zheyu Ma <zheyuma97@xxxxxxxxx>
Date: Wed, 19 May 2021 06:49:14 +0000

> When calling the 'ql_sem_spinlock', the driver has already acquired the
> spin lock, so the driver should not call 'ssleep' in atomic context.
>
> This bug can be fixed by unlocking before calling 'ssleep'.
...
> diff --git a/drivers/net/ethernet/qlogic/qla3xxx.c b/drivers/net/ethernet/qlogic/qla3xxx.c
> index 214e347097a7..af7c142a066f 100644
> --- a/drivers/net/ethernet/qlogic/qla3xxx.c
> +++ b/drivers/net/ethernet/qlogic/qla3xxx.c
> @@ -114,7 +114,9 @@ static int ql_sem_spinlock(struct ql3_adapter *qdev,
> value = readl(&port_regs->CommonRegs.semaphoreReg);
> if ((value & (sem_mask >> 16)) == sem_bits)
> return 0;
> + spin_unlock_irq(&qdev->hw_lock);
> ssleep(1);
> + spin_lock_irq(&qdev->hw_lock);
> } while (--seconds);
> return -1;
> }

Are you sure dropping the lock like this dos not introduce a race condition?

Thank you.