mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 18:41:58 +09:00
net: lan743x: Don't sleep in atomic context
commit7a8227b2e7upstream. dev_set_rx_mode() grabs a spin_lock, and the lan743x implementation proceeds subsequently to go to sleep using readx_poll_timeout(). Introduce a helper wrapping the readx_poll_timeout_atomic() function and use it to replace the calls to readx_polL_timeout(). Fixes:23f0703c12("lan743x: Add main source files for new lan743x driver") Cc: stable@vger.kernel.org Cc: Bryan Whitehead <bryan.whitehead@microchip.com> Cc: UNGLinuxDriver@microchip.com Signed-off-by: Moritz Fischer <moritzf@google.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Link: https://lore.kernel.org/r/20230627035000.1295254-1-moritzf@google.com Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
5a45ed1ae3
commit
4b5ab640aa
@@ -144,6 +144,18 @@ static int lan743x_csr_light_reset(struct lan743x_adapter *adapter)
|
|||||||
!(data & HW_CFG_LRST_), 100000, 10000000);
|
!(data & HW_CFG_LRST_), 100000, 10000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int lan743x_csr_wait_for_bit_atomic(struct lan743x_adapter *adapter,
|
||||||
|
int offset, u32 bit_mask,
|
||||||
|
int target_value, int udelay_min,
|
||||||
|
int udelay_max, int count)
|
||||||
|
{
|
||||||
|
u32 data;
|
||||||
|
|
||||||
|
return readx_poll_timeout_atomic(LAN743X_CSR_READ_OP, offset, data,
|
||||||
|
target_value == !!(data & bit_mask),
|
||||||
|
udelay_max, udelay_min * count);
|
||||||
|
}
|
||||||
|
|
||||||
static int lan743x_csr_wait_for_bit(struct lan743x_adapter *adapter,
|
static int lan743x_csr_wait_for_bit(struct lan743x_adapter *adapter,
|
||||||
int offset, u32 bit_mask,
|
int offset, u32 bit_mask,
|
||||||
int target_value, int usleep_min,
|
int target_value, int usleep_min,
|
||||||
@@ -746,8 +758,8 @@ static int lan743x_dp_write(struct lan743x_adapter *adapter,
|
|||||||
u32 dp_sel;
|
u32 dp_sel;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (lan743x_csr_wait_for_bit(adapter, DP_SEL, DP_SEL_DPRDY_,
|
if (lan743x_csr_wait_for_bit_atomic(adapter, DP_SEL, DP_SEL_DPRDY_,
|
||||||
1, 40, 100, 100))
|
1, 40, 100, 100))
|
||||||
return -EIO;
|
return -EIO;
|
||||||
dp_sel = lan743x_csr_read(adapter, DP_SEL);
|
dp_sel = lan743x_csr_read(adapter, DP_SEL);
|
||||||
dp_sel &= ~DP_SEL_MASK_;
|
dp_sel &= ~DP_SEL_MASK_;
|
||||||
@@ -758,8 +770,9 @@ static int lan743x_dp_write(struct lan743x_adapter *adapter,
|
|||||||
lan743x_csr_write(adapter, DP_ADDR, addr + i);
|
lan743x_csr_write(adapter, DP_ADDR, addr + i);
|
||||||
lan743x_csr_write(adapter, DP_DATA_0, buf[i]);
|
lan743x_csr_write(adapter, DP_DATA_0, buf[i]);
|
||||||
lan743x_csr_write(adapter, DP_CMD, DP_CMD_WRITE_);
|
lan743x_csr_write(adapter, DP_CMD, DP_CMD_WRITE_);
|
||||||
if (lan743x_csr_wait_for_bit(adapter, DP_SEL, DP_SEL_DPRDY_,
|
if (lan743x_csr_wait_for_bit_atomic(adapter, DP_SEL,
|
||||||
1, 40, 100, 100))
|
DP_SEL_DPRDY_,
|
||||||
|
1, 40, 100, 100))
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user