net: tundra: tsi108: use spin_lock_irqsave instead of spin_lock_irq in IRQ context [Linux 4.4.192]

This Linux kernel change "net: tundra: tsi108: use spin_lock_irqsave instead of spin_lock_irq in IRQ context" is included in the Linux 4.4.192 release. This change is authored by Fuqian Huang <huangfq.daxian [at] gmail.com> on Fri Aug 9 13:35:39 2019 +0800. The commit for this change in Linux stable tree is e040f07 (patch) which is from upstream commit 8c25d08. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream 8c25d08.

net: tundra: tsi108: use spin_lock_irqsave instead of spin_lock_irq in IRQ context

[ Upstream commit 8c25d0887a8bd0e1ca2074ac0c6dff173787a83b ]

As spin_unlock_irq will enable interrupts.
Function tsi108_stat_carry is called from interrupt handler tsi108_irq.
Interrupts are enabled in interrupt handler.
Use spin_lock_irqsave/spin_unlock_irqrestore instead of spin_(un)lock_irq
in IRQ context to avoid this.

Signed-off-by: Fuqian Huang <huangfq.daxian@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>

There are 5 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/net/ethernet/tundra/tsi108_eth.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/tundra/tsi108_eth.c b/drivers/net/ethernet/tundra/tsi108_eth.c
index 520cf50..93fe0da 100644
--- a/drivers/net/ethernet/tundra/tsi108_eth.c
+++ b/drivers/net/ethernet/tundra/tsi108_eth.c
@@ -379,9 +379,10 @@ static void tsi108_check_phy(struct net_device *dev)
 static void tsi108_stat_carry(struct net_device *dev)
 {
    struct tsi108_prv_data *data = netdev_priv(dev);
+   unsigned long flags;
    u32 carry1, carry2;

-   spin_lock_irq(&data->misclock);
+   spin_lock_irqsave(&data->misclock, flags);

    carry1 = TSI_READ(TSI108_STAT_CARRY1);
    carry2 = TSI_READ(TSI108_STAT_CARRY2);
@@ -449,7 +450,7 @@ static void tsi108_stat_carry(struct net_device *dev)
                  TSI108_STAT_TXPAUSEDROP_CARRY,
                  &data->tx_pause_drop);

-   spin_unlock_irq(&data->misclock);
+   spin_unlock_irqrestore(&data->misclock, flags);
 }

 /* Read a stat counter atomically with respect to carries.

Leave a Reply

Your email address will not be published. Required fields are marked *