@@ -799,6 +799,7 @@ static int rswitch_poll(struct napi_struct *napi, int budget)
799799 struct net_device * ndev = napi -> dev ;
800800 struct rswitch_private * priv ;
801801 struct rswitch_device * rdev ;
802+ unsigned long flags ;
802803 int quota = budget ;
803804
804805 rdev = netdev_priv (ndev );
@@ -816,10 +817,12 @@ static int rswitch_poll(struct napi_struct *napi, int budget)
816817
817818 netif_wake_subqueue (ndev , 0 );
818819
819- napi_complete (napi );
820-
821- rswitch_enadis_data_irq (priv , rdev -> tx_queue -> index , true);
822- rswitch_enadis_data_irq (priv , rdev -> rx_queue -> index , true);
820+ if (napi_complete_done (napi , budget - quota )) {
821+ spin_lock_irqsave (& priv -> lock , flags );
822+ rswitch_enadis_data_irq (priv , rdev -> tx_queue -> index , true);
823+ rswitch_enadis_data_irq (priv , rdev -> rx_queue -> index , true);
824+ spin_unlock_irqrestore (& priv -> lock , flags );
825+ }
823826
824827out :
825828 return budget - quota ;
@@ -835,8 +838,10 @@ static void rswitch_queue_interrupt(struct net_device *ndev)
835838 struct rswitch_device * rdev = netdev_priv (ndev );
836839
837840 if (napi_schedule_prep (& rdev -> napi )) {
841+ spin_lock (& rdev -> priv -> lock );
838842 rswitch_enadis_data_irq (rdev -> priv , rdev -> tx_queue -> index , false);
839843 rswitch_enadis_data_irq (rdev -> priv , rdev -> rx_queue -> index , false);
844+ spin_unlock (& rdev -> priv -> lock );
840845 __napi_schedule (& rdev -> napi );
841846 }
842847}
@@ -1440,14 +1445,17 @@ static void rswitch_ether_port_deinit_all(struct rswitch_private *priv)
14401445static int rswitch_open (struct net_device * ndev )
14411446{
14421447 struct rswitch_device * rdev = netdev_priv (ndev );
1448+ unsigned long flags ;
14431449
14441450 phy_start (ndev -> phydev );
14451451
14461452 napi_enable (& rdev -> napi );
14471453 netif_start_queue (ndev );
14481454
1455+ spin_lock_irqsave (& rdev -> priv -> lock , flags );
14491456 rswitch_enadis_data_irq (rdev -> priv , rdev -> tx_queue -> index , true);
14501457 rswitch_enadis_data_irq (rdev -> priv , rdev -> rx_queue -> index , true);
1458+ spin_unlock_irqrestore (& rdev -> priv -> lock , flags );
14511459
14521460 if (bitmap_empty (rdev -> priv -> opened_ports , RSWITCH_NUM_PORTS ))
14531461 iowrite32 (GWCA_TS_IRQ_BIT , rdev -> priv -> addr + GWTSDIE );
@@ -1461,6 +1469,7 @@ static int rswitch_stop(struct net_device *ndev)
14611469{
14621470 struct rswitch_device * rdev = netdev_priv (ndev );
14631471 struct rswitch_gwca_ts_info * ts_info , * ts_info2 ;
1472+ unsigned long flags ;
14641473
14651474 netif_tx_stop_all_queues (ndev );
14661475 bitmap_clear (rdev -> priv -> opened_ports , rdev -> port , 1 );
@@ -1476,8 +1485,10 @@ static int rswitch_stop(struct net_device *ndev)
14761485 kfree (ts_info );
14771486 }
14781487
1488+ spin_lock_irqsave (& rdev -> priv -> lock , flags );
14791489 rswitch_enadis_data_irq (rdev -> priv , rdev -> tx_queue -> index , false);
14801490 rswitch_enadis_data_irq (rdev -> priv , rdev -> rx_queue -> index , false);
1491+ spin_unlock_irqrestore (& rdev -> priv -> lock , flags );
14811492
14821493 phy_stop (ndev -> phydev );
14831494 napi_disable (& rdev -> napi );
@@ -1887,6 +1898,7 @@ static int renesas_eth_sw_probe(struct platform_device *pdev)
18871898 priv = devm_kzalloc (& pdev -> dev , sizeof (* priv ), GFP_KERNEL );
18881899 if (!priv )
18891900 return - ENOMEM ;
1901+ spin_lock_init (& priv -> lock );
18901902
18911903 attr = soc_device_match (rswitch_soc_no_speed_change );
18921904 if (attr )
0 commit comments