@@ -613,6 +613,7 @@ struct rtl8169_private {
613
613
struct work_struct work ;
614
614
} wk ;
615
615
616
+ spinlock_t config25_lock ;
616
617
spinlock_t mac_ocp_lock ;
617
618
618
619
unsigned supports_gmii :1 ;
@@ -677,6 +678,28 @@ static void rtl_pci_commit(struct rtl8169_private *tp)
677
678
RTL_R8 (tp , ChipCmd );
678
679
}
679
680
681
+ static void rtl_mod_config2 (struct rtl8169_private * tp , u8 clear , u8 set )
682
+ {
683
+ unsigned long flags ;
684
+ u8 val ;
685
+
686
+ spin_lock_irqsave (& tp -> config25_lock , flags );
687
+ val = RTL_R8 (tp , Config2 );
688
+ RTL_W8 (tp , Config2 , (val & ~clear ) | set );
689
+ spin_unlock_irqrestore (& tp -> config25_lock , flags );
690
+ }
691
+
692
+ static void rtl_mod_config5 (struct rtl8169_private * tp , u8 clear , u8 set )
693
+ {
694
+ unsigned long flags ;
695
+ u8 val ;
696
+
697
+ spin_lock_irqsave (& tp -> config25_lock , flags );
698
+ val = RTL_R8 (tp , Config5 );
699
+ RTL_W8 (tp , Config5 , (val & ~clear ) | set );
700
+ spin_unlock_irqrestore (& tp -> config25_lock , flags );
701
+ }
702
+
680
703
static bool rtl_is_8125 (struct rtl8169_private * tp )
681
704
{
682
705
return tp -> mac_version >= RTL_GIGA_MAC_VER_61 ;
@@ -1363,6 +1386,7 @@ static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts)
1363
1386
{ WAKE_MAGIC , Config3 , MagicPacket }
1364
1387
};
1365
1388
unsigned int i , tmp = ARRAY_SIZE (cfg );
1389
+ unsigned long flags ;
1366
1390
u8 options ;
1367
1391
1368
1392
rtl_unlock_config_regs (tp );
@@ -1381,12 +1405,14 @@ static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts)
1381
1405
r8168_mac_ocp_modify (tp , 0xc0b6 , BIT (0 ), 0 );
1382
1406
}
1383
1407
1408
+ spin_lock_irqsave (& tp -> config25_lock , flags );
1384
1409
for (i = 0 ; i < tmp ; i ++ ) {
1385
1410
options = RTL_R8 (tp , cfg [i ].reg ) & ~cfg [i ].mask ;
1386
1411
if (wolopts & cfg [i ].opt )
1387
1412
options |= cfg [i ].mask ;
1388
1413
RTL_W8 (tp , cfg [i ].reg , options );
1389
1414
}
1415
+ spin_unlock_irqrestore (& tp -> config25_lock , flags );
1390
1416
1391
1417
switch (tp -> mac_version ) {
1392
1418
case RTL_GIGA_MAC_VER_02 ... RTL_GIGA_MAC_VER_06 :
@@ -1398,10 +1424,10 @@ static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts)
1398
1424
case RTL_GIGA_MAC_VER_34 :
1399
1425
case RTL_GIGA_MAC_VER_37 :
1400
1426
case RTL_GIGA_MAC_VER_39 ... RTL_GIGA_MAC_VER_63 :
1401
- options = RTL_R8 (tp , Config2 ) & ~PME_SIGNAL ;
1402
1427
if (wolopts )
1403
- options |= PME_SIGNAL ;
1404
- RTL_W8 (tp , Config2 , options );
1428
+ rtl_mod_config2 (tp , 0 , PME_SIGNAL );
1429
+ else
1430
+ rtl_mod_config2 (tp , PME_SIGNAL , 0 );
1405
1431
break ;
1406
1432
default :
1407
1433
break ;
@@ -2704,8 +2730,8 @@ static void rtl_hw_aspm_clkreq_enable(struct rtl8169_private *tp, bool enable)
2704
2730
{
2705
2731
/* Don't enable ASPM in the chip if OS can't control ASPM */
2706
2732
if (enable && tp -> aspm_manageable ) {
2707
- RTL_W8 (tp , Config5 , RTL_R8 ( tp , Config5 ) | ASPM_en );
2708
- RTL_W8 (tp , Config2 , RTL_R8 ( tp , Config2 ) | ClkReqEn );
2733
+ rtl_mod_config5 (tp , 0 , ASPM_en );
2734
+ rtl_mod_config2 (tp , 0 , ClkReqEn );
2709
2735
2710
2736
switch (tp -> mac_version ) {
2711
2737
case RTL_GIGA_MAC_VER_46 ... RTL_GIGA_MAC_VER_48 :
@@ -2728,8 +2754,8 @@ static void rtl_hw_aspm_clkreq_enable(struct rtl8169_private *tp, bool enable)
2728
2754
break ;
2729
2755
}
2730
2756
2731
- RTL_W8 (tp , Config2 , RTL_R8 ( tp , Config2 ) & ~ ClkReqEn );
2732
- RTL_W8 (tp , Config5 , RTL_R8 ( tp , Config5 ) & ~ ASPM_en );
2757
+ rtl_mod_config2 (tp , ClkReqEn , 0 );
2758
+ rtl_mod_config5 (tp , ASPM_en , 0 );
2733
2759
}
2734
2760
2735
2761
udelay (10 );
@@ -2890,7 +2916,7 @@ static void rtl_hw_start_8168e_1(struct rtl8169_private *tp)
2890
2916
RTL_W32 (tp , MISC , RTL_R32 (tp , MISC ) | TXPLA_RST );
2891
2917
RTL_W32 (tp , MISC , RTL_R32 (tp , MISC ) & ~TXPLA_RST );
2892
2918
2893
- RTL_W8 (tp , Config5 , RTL_R8 ( tp , Config5 ) & ~ Spi_en );
2919
+ rtl_mod_config5 (tp , Spi_en , 0 );
2894
2920
}
2895
2921
2896
2922
static void rtl_hw_start_8168e_2 (struct rtl8169_private * tp )
@@ -2923,7 +2949,7 @@ static void rtl_hw_start_8168e_2(struct rtl8169_private *tp)
2923
2949
2924
2950
RTL_W8 (tp , DLLPR , RTL_R8 (tp , DLLPR ) | PFM_EN );
2925
2951
RTL_W32 (tp , MISC , RTL_R32 (tp , MISC ) | PWM_EN );
2926
- RTL_W8 (tp , Config5 , RTL_R8 ( tp , Config5 ) & ~ Spi_en );
2952
+ rtl_mod_config5 (tp , Spi_en , 0 );
2927
2953
2928
2954
rtl_hw_aspm_clkreq_enable (tp , true);
2929
2955
}
@@ -2946,7 +2972,7 @@ static void rtl_hw_start_8168f(struct rtl8169_private *tp)
2946
2972
RTL_W8 (tp , MCU , RTL_R8 (tp , MCU ) & ~NOW_IS_OOB );
2947
2973
RTL_W8 (tp , DLLPR , RTL_R8 (tp , DLLPR ) | PFM_EN );
2948
2974
RTL_W32 (tp , MISC , RTL_R32 (tp , MISC ) | PWM_EN );
2949
- RTL_W8 (tp , Config5 , RTL_R8 ( tp , Config5 ) & ~ Spi_en );
2975
+ rtl_mod_config5 (tp , Spi_en , 0 );
2950
2976
2951
2977
rtl8168_config_eee_mac (tp );
2952
2978
}
@@ -5203,6 +5229,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
5203
5229
tp -> eee_adv = -1 ;
5204
5230
tp -> ocp_base = OCP_STD_PHY_BASE ;
5205
5231
5232
+ spin_lock_init (& tp -> config25_lock );
5206
5233
spin_lock_init (& tp -> mac_ocp_lock );
5207
5234
5208
5235
dev -> tstats = devm_netdev_alloc_pcpu_stats (& pdev -> dev ,
0 commit comments