Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: lan743x: Don't sleep in atomic context

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: 23f0703c125b ("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>

authored by

Moritz Fischer and committed by
Paolo Abeni
7a8227b2 3a8a670e

+17 -4
+17 -4
drivers/net/ethernet/microchip/lan743x_main.c
··· 144 144 !(data & HW_CFG_LRST_), 100000, 10000000); 145 145 } 146 146 147 + static int lan743x_csr_wait_for_bit_atomic(struct lan743x_adapter *adapter, 148 + int offset, u32 bit_mask, 149 + int target_value, int udelay_min, 150 + int udelay_max, int count) 151 + { 152 + u32 data; 153 + 154 + return readx_poll_timeout_atomic(LAN743X_CSR_READ_OP, offset, data, 155 + target_value == !!(data & bit_mask), 156 + udelay_max, udelay_min * count); 157 + } 158 + 147 159 static int lan743x_csr_wait_for_bit(struct lan743x_adapter *adapter, 148 160 int offset, u32 bit_mask, 149 161 int target_value, int usleep_min, ··· 748 736 u32 dp_sel; 749 737 int i; 750 738 751 - if (lan743x_csr_wait_for_bit(adapter, DP_SEL, DP_SEL_DPRDY_, 752 - 1, 40, 100, 100)) 739 + if (lan743x_csr_wait_for_bit_atomic(adapter, DP_SEL, DP_SEL_DPRDY_, 740 + 1, 40, 100, 100)) 753 741 return -EIO; 754 742 dp_sel = lan743x_csr_read(adapter, DP_SEL); 755 743 dp_sel &= ~DP_SEL_MASK_; ··· 760 748 lan743x_csr_write(adapter, DP_ADDR, addr + i); 761 749 lan743x_csr_write(adapter, DP_DATA_0, buf[i]); 762 750 lan743x_csr_write(adapter, DP_CMD, DP_CMD_WRITE_); 763 - if (lan743x_csr_wait_for_bit(adapter, DP_SEL, DP_SEL_DPRDY_, 764 - 1, 40, 100, 100)) 751 + if (lan743x_csr_wait_for_bit_atomic(adapter, DP_SEL, 752 + DP_SEL_DPRDY_, 753 + 1, 40, 100, 100)) 765 754 return -EIO; 766 755 } 767 756