2017-06-01 08:16:05

by Jia-Ju Bai

[permalink] [raw]
Subject: [PATCH] qlcnic: Fix a sleep-in-atomic bug in qlcnic_82xx_hw_write_wx_2M and qlcnic_82xx_hw_read_wx_2M

The driver may sleep under a write spin lock, and the function
call path is:
qlcnic_82xx_hw_write_wx_2M (acquire the lock by write_lock_irqsave)
crb_win_lock
qlcnic_pcie_sem_lock
usleep_range
qlcnic_82xx_hw_read_wx_2M (acquire the lock by write_lock_irqsave)
crb_win_lock
qlcnic_pcie_sem_lock
usleep_range

To fix it, the usleep_range is replaced with udelay.

Signed-off-by: Jia-Ju Bai <[email protected]>
---
drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c
index 838cc0c..7848cf0 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c
@@ -341,7 +341,7 @@ static void qlcnic_write_window_reg(u32 addr, void __iomem *bar0, u32 data)
}
return -EIO;
}
- usleep_range(1000, 1500);
+ udelay(1200);
}

if (id_reg)
--
1.7.9.5



2017-06-01 15:42:33

by David Miller

[permalink] [raw]
Subject: Re: [PATCH] qlcnic: Fix a sleep-in-atomic bug in qlcnic_82xx_hw_write_wx_2M and qlcnic_82xx_hw_read_wx_2M

From: Jia-Ju Bai <[email protected]>
Date: Thu, 1 Jun 2017 16:18:10 +0800

> The driver may sleep under a write spin lock, and the function
> call path is:
> qlcnic_82xx_hw_write_wx_2M (acquire the lock by write_lock_irqsave)
> crb_win_lock
> qlcnic_pcie_sem_lock
> usleep_range
> qlcnic_82xx_hw_read_wx_2M (acquire the lock by write_lock_irqsave)
> crb_win_lock
> qlcnic_pcie_sem_lock
> usleep_range
>
> To fix it, the usleep_range is replaced with udelay.
>
> Signed-off-by: Jia-Ju Bai <[email protected]>

Applied.