lan743x: clean up software_isr function
Subsystems (3)
PATCH 1/2 lan743x: clean up software_isr function
From: Sven Van Asbroeck <[email protected]>
For no apparent reason, this function reads the INT_STS register, and checks if the software interrupt bit is set. These things have already been carried out by this function's only caller.
Clean up by removing the redundant code.
---
Tree: git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git # f9e425e99b07
To: Bryan Whitehead <[email protected]>
To: Jakub Kicinski <[email protected]>
To: "David S. Miller" <[email protected]>
Cc: Andrew Lunn <[email protected]>
Cc: Microchip Linux Driver Support <[email protected]>
Cc: [email protected]
Cc: [email protected]
drivers/net/ethernet/microchip/lan743x_main.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/net/ethernet/microchip/lan743x_main.c +4 -9
@@ -140,18 +140,13 @@ static int lan743x_csr_init(struct lan743x_adapter *adapter)return result; } -static void lan743x_intr_software_isr (void *context) +static void lan743x_intr_software_isr (struct lan743x_adapter *adapter) { -struct lan743x_adapter *adapter = context;struct lan743x_intr *intr = &adapter->intr; -u32 int_sts; - int_sts =lan743x_csr_read (adapter,INT_STS ); -if (int_sts &INT_BIT_SW_GP_ ) { -/* disable the interrupt to prevent repeated re-triggering */ -lan743x_csr_write (adapter,INT_EN_CLR ,INT_BIT_SW_GP_ ); - intr->software_isr_flag =1 ; - } +/* disable the interrupt to prevent repeated re-triggering */ +lan743x_csr_write (adapter,INT_EN_CLR ,INT_BIT_SW_GP_ ); + intr->software_isr_flag =1 ; }static void lan743x_tx_isr (void *context,u32 int_sts,u32 flags)
Signature · 1 line
2.17.1
PATCH 2/2 lan743x: replace polling loop by wait_event_timeout()
From: Sven Van Asbroeck <[email protected]>
The driver's ISR sends a 'software interrupt' event to the probe() thread using the following method:
- probe(): write 0 to flag, enable s/w interrupt
- probe(): poll on flag, relax using usleep_range()
- ISR : write 1 to flag
Replace with wake_up() / wait_event_timeout(). Besides being easier to get right, this abstraction has better timing and memory consistency properties.
---
To: Bryan Whitehead <[email protected]>
To: Jakub Kicinski <[email protected]>
To: "David S. Miller" <[email protected]>
Cc: Andrew Lunn <[email protected]>
Cc: Microchip Linux Driver Support <[email protected]>
Cc: [email protected]
Cc: [email protected]
drivers/net/ethernet/microchip/lan743x_main.c | 28 +++++++++---------- drivers/net/ethernet/microchip/lan743x_main.h | 3 +- 2 files changed, 15 insertions(+), 16 deletions(-)
drivers/net/ethernet/microchip/lan743x_main.c +13 -15
@@ -146,7 +146,8 @@ static void lan743x_intr_software_isr(struct lan743x_adapter *adapter)/* disable the interrupt to prevent repeated re-triggering */ lan743x_csr_write (adapter,INT_EN_CLR ,INT_BIT_SW_GP_ ); - intr->software_isr_flag =1 ; + intr->software_isr_flag = true; +wake_up (&intr->software_isr_wq); }static void lan743x_tx_isr (void *context,u32 int_sts,u32 flags)
@@ -344,27 +345,22 @@ static irqreturn_t lan743x_intr_entry_isr(int irq, void *ptr)static int lan743x_intr_test_isr (struct lan743x_adapter *adapter) {struct lan743x_intr *intr = &adapter->intr; -int result = -ENODEV ; -int timeout =10 ; +int ret; - intr->software_isr_flag =0 ; + intr->software_isr_flag = false; -/* enable interrupt */ +/* enable and activate test interrupt */ lan743x_csr_write (adapter,INT_EN_SET ,INT_BIT_SW_GP_ ); - -/* activate interrupt here */ lan743x_csr_write (adapter,INT_SET ,INT_BIT_SW_GP_ ); -while ((timeout >0 ) && (!(intr->software_isr_flag))) { -usleep_range (1000 ,20000 ); - timeout--; - } -if (intr->software_isr_flag) - result =0 ; + ret =wait_event_timeout (intr->software_isr_wq, + intr->software_isr_flag, +msecs_to_jiffies (200 )); -/* disable interrupts */ +/* disable test interrupt */ lan743x_csr_write (adapter,INT_EN_CLR ,INT_BIT_SW_GP_ ); -return result; + +return ret >0 ?0 : -ENODEV ; } static int lan743x_intr_register_isr(struct lan743x_adapter *adapter,
@@ -538,6 +534,8 @@ static int lan743x_intr_open(struct lan743x_adapter *adapter) flags |=LAN743X_VECTOR_FLAG_SOURCE_ENABLE_R2C ; } +init_waitqueue_head (&intr->software_isr_wq); + ret = lan743x_intr_register_isr(adapter, 0, flags, INT_BIT_ALL_RX_ | INT_BIT_ALL_TX_ | INT_BIT_ALL_OTHER_,
drivers/net/ethernet/microchip/lan743x_main.h +2 -1
@@ -616,7 +616,8 @@ struct lan743x_intr {int number_of_vectors;bool using_vectors; -int software_isr_flag; +bool software_isr_flag; +wait_queue_head_t software_isr_wq; };#define LAN743X_MAX_FRAME_SIZE (9 * 1024)
Signature · 1 line
2.17.1
Quoted 10 lines · On Mon, 23 Nov 2020 14:15:28 -0500 Sven Van Asbroeck wrote:
From: Sven Van Asbroeck <[email protected]>
For no apparent reason, this function reads the
INT_STSregister, and checks if the software interrupt bit is set. These things have already been carried out by this function's only caller.Clean up by removing the redundant code.
Signed-off-by Sven Van Asbroeck <[email protected]>
Applied both, thank you!
Quoted 2 lines · Jakub Kicinski
Applied both, thank you!
Thank you Jakub !