r8169: fix rtl8125b dmar pte write access not set error
PATCH 1/1 r8169: fix rtl8125b dmar pte write access not set error
When close device, rx will be enabled if wol is enabeld. When open device it will cause rx to dma to wrong address after pci_set_master().
In this patch, driver will disable tx/rx when close device. If wol is eanbled only enable rx filter and disable rxdv_gate to let hardware can receive packet to fifo but not to dma it.
--- drivers/net/ethernet/realtek/r8169_main.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/net/ethernet/realtek/r8169_main.c +7 -7
@@ -2239,6 +2239,9 @@ static void rtl_wol_enable_rx(struct rtl8169_private *tp)if (tp->mac_version >=RTL_GIGA_MAC_VER_25 )RTL_W32 (tp, RxConfig,RTL_R32 (tp, RxConfig) | AcceptBroadcast | AcceptMulticast | AcceptMyPhys); + +if (tp->mac_version >=RTL_GIGA_MAC_VER_40 ) +RTL_W32 (tp,MISC ,RTL_R32 (tp,MISC ) & ~RXDV_GATED_EN ); }static void rtl_prepare_power_down (struct rtl8169_private *tp)
@@ -3981,7 +3984,7 @@ static void rtl8169_tx_clear(struct rtl8169_private *tp)netdev_reset_queue (tp->dev); } -static void rtl8169_cleanup (struct rtl8169_private *tp,bool going_down) +static void rtl8169_cleanup (struct rtl8169_private *tp) {napi_disable (&tp->napi);
@@ -3993,9 +3996,6 @@ static void rtl8169_cleanup(struct rtl8169_private *tp, bool going_down)rtl_rx_close (tp); -if (going_down && tp->dev->wol_enabled) - goto no_reset; -switch (tp->mac_version) {case RTL_GIGA_MAC_VER_28 :case RTL_GIGA_MAC_VER_31 :
@@ -4016,7 +4016,7 @@ static void rtl8169_cleanup(struct rtl8169_private *tp, bool going_down) }rtl_hw_reset (tp); -no_reset: +rtl8169_tx_clear (tp);rtl8169_init_ring_indexes (tp); }
@@ -4027,7 +4027,7 @@ static void rtl_reset_work(struct rtl8169_private *tp)netif_stop_queue (tp->dev); -rtl8169_cleanup (tp, false); +rtl8169_cleanup (tp);for (i =0 ; i <NUM_RX_DESC ; i++)rtl8169_mark_to_asic (tp->RxDescArray + i);
@@ -4715,7 +4715,7 @@ static void rtl8169_down(struct rtl8169_private *tp)pci_clear_master (tp->pci_dev);rtl_pci_commit (tp); -rtl8169_cleanup (tp, true); +rtl8169_cleanup (tp);rtl_disable_exit_l1 (tp);rtl_prepare_power_down (tp); }
Signature · 1 line
2.25.1
Heiner Kallweit
maintainerQuoted 3 lines · Chunhao Lin
When close device, rx will be enabled if wol is enabeld. When open device it will cause rx to dma to wrong address after
pci_set_master().
Hi Hau,
I never experienced this problem. Is it an edge case that can occur under specific circumstances?
Quoted 15 lines
In this patch, driver will disable tx/rx when close device. If wol is eanbled only enable rx filter and disable
rxdv_gateto let hardware can receive packet to fifo but not to dma it.Fixes 120068481405 ("r8169: fix failing WoL")Signed-off-by Chunhao Lin <[email protected]>--- drivers/net/ethernet/realtek/r8169_main.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)drivers/net/ethernet/realtek/r8169_main.c +0
-0
drivers/net/ethernet/realtek/r8169_main.c static void rtl_wol_enable_rx(struct rtl8169_private *tp) · line 2244
Quoted 6 lines
drivers/net/ethernet/realtek/r8169_main.c +3
-0@@ -2239,6 +2239,9 @@ static void rtl_wol_enable_rx(struct rtl8169_private *tp)if (tp->mac_version >=RTL_GIGA_MAC_VER_25 )RTL_W32 (tp, RxConfig,RTL_R32 (tp, RxConfig) | AcceptBroadcast | AcceptMulticast | AcceptMyPhys); + +if (tp->mac_version >=RTL_GIGA_MAC_VER_40 ) +RTL_W32 (tp,MISC ,RTL_R32 (tp,MISC ) & ~RXDV_GATED_EN );
In the commit title you reference RTL8125b only, but the actual change affects all chip versions from RTL8168g. So either title or patch need to be adjusted. Is the actual issue restricted to RTL8125b (hw issue?) or can it occur on all chip versions that use RXDV_GATED_EN?
Quoted 13 lines
drivers/net/ethernet/realtek/r8169_main.c +1
-1}static void rtl_prepare_power_down (struct rtl8169_private *tp)@@ -3981,7 +3984,7 @@ static void rtl8169_tx_clear(struct rtl8169_private *tp)netdev_reset_queue (tp->dev); } -static void rtl8169_cleanup (struct rtl8169_private *tp,bool going_down) +static void rtl8169_cleanup (struct rtl8169_private *tp) {napi_disable (&tp->napi);
drivers/net/ethernet/realtek/r8169_main.c static void rtl8169_cleanup(struct rtl8169_private *tp, bool going_down) · line 3998
Quoted 6 lines
drivers/net/ethernet/realtek/r8169_main.c +0
-3@@ -3993,9 +3996,6 @@ static void rtl8169_cleanup(struct rtl8169_private *tp, bool going_down)rtl_rx_close (tp); -if (going_down && tp->dev->wol_enabled) - goto no_reset; -
Here you change the behavior for various other chip versions too. This should not be done in a fix, even if it should be safe.
Quoted 30 lines
drivers/net/ethernet/realtek/r8169_main.c +3
-3switch (tp->mac_version) {case RTL_GIGA_MAC_VER_28 :case RTL_GIGA_MAC_VER_31 :@@ -4016,7 +4016,7 @@ static void rtl8169_cleanup(struct rtl8169_private *tp, bool going_down) }rtl_hw_reset (tp); -no_reset: +rtl8169_tx_clear (tp);rtl8169_init_ring_indexes (tp); }@@ -4027,7 +4027,7 @@ static void rtl_reset_work(struct rtl8169_private *tp)netif_stop_queue (tp->dev); -rtl8169_cleanup (tp, false); +rtl8169_cleanup (tp);for (i =0 ; i <NUM_RX_DESC ; i++)rtl8169_mark_to_asic (tp->RxDescArray + i);@@ -4715,7 +4715,7 @@ static void rtl8169_down(struct rtl8169_private *tp)pci_clear_master (tp->pci_dev);rtl_pci_commit (tp); -rtl8169_cleanup (tp, true); +rtl8169_cleanup (tp);rtl_disable_exit_l1 (tp);rtl_prepare_power_down (tp); }
Quoted 9 lines · Chunhao Lin
Quoted 3 lines
When close device, rx will be enabled if wol is enabeld. When open device it will cause rx to dma to wrong address after
pci_set_master().Hi Hau,
I never experienced this problem. Is it an edge case that can occur under specific circumstances?
This issue is happen on google chromebook with IOMMU enabled. Because rx is enabled when wol is enabled, so I think there is a chance that the packet receive in device close will be dma to invalid memory address when device is open.
------Please consider the environment before printing this e-mail.
Heiner Kallweit
maintainerQuoted 65 lines · Chunhao Lin
When close device, rx will be enabled if wol is enabeld. When open device it will cause rx to dma to wrong address after
pci_set_master().In this patch, driver will disable tx/rx when close device. If wol is eanbled only enable rx filter and disable
rxdv_gateto let hardware can receive packet to fifo but not to dma it.Fixes 120068481405 ("r8169: fix failing WoL")Signed-off-by Chunhao Lin <[email protected]>--- drivers/net/ethernet/realtek/r8169_main.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)drivers/net/ethernet/realtek/r8169_main.c +6
-6@@ -2239,6 +2239,9 @@ static void rtl_wol_enable_rx(struct rtl8169_private *tp)if (tp->mac_version >=RTL_GIGA_MAC_VER_25 )RTL_W32 (tp, RxConfig,RTL_R32 (tp, RxConfig) | AcceptBroadcast | AcceptMulticast | AcceptMyPhys); + +if (tp->mac_version >=RTL_GIGA_MAC_VER_40 ) +RTL_W32 (tp,MISC ,RTL_R32 (tp,MISC ) & ~RXDV_GATED_EN ); }static void rtl_prepare_power_down (struct rtl8169_private *tp)@@ -3981,7 +3984,7 @@ static void rtl8169_tx_clear(struct rtl8169_private *tp)netdev_reset_queue (tp->dev); } -static void rtl8169_cleanup (struct rtl8169_private *tp,bool going_down) +static void rtl8169_cleanup (struct rtl8169_private *tp) {napi_disable (&tp->napi);@@ -3993,9 +3996,6 @@ static void rtl8169_cleanup(struct rtl8169_private *tp, bool going_down)rtl_rx_close (tp); -if (going_down && tp->dev->wol_enabled) - goto no_reset; -switch (tp->mac_version) {case RTL_GIGA_MAC_VER_28 :case RTL_GIGA_MAC_VER_31 :@@ -4016,7 +4016,7 @@ static void rtl8169_cleanup(struct rtl8169_private *tp, bool going_down) }rtl_hw_reset (tp); -no_reset: +rtl8169_tx_clear (tp);rtl8169_init_ring_indexes (tp); }@@ -4027,7 +4027,7 @@ static void rtl_reset_work(struct rtl8169_private *tp)netif_stop_queue (tp->dev); -rtl8169_cleanup (tp, false); +rtl8169_cleanup (tp);for (i =0 ; i <NUM_RX_DESC ; i++)rtl8169_mark_to_asic (tp->RxDescArray + i);
drivers/net/ethernet/realtek/r8169_main.c static void rtl8169_down(struct rtl8169_private *tp) · line 4721
Quoted 8 lines
drivers/net/ethernet/realtek/r8169_main.c +1
-1@@ -4715,7 +4715,7 @@ static void rtl8169_down(struct rtl8169_private *tp)pci_clear_master (tp->pci_dev);rtl_pci_commit (tp); -rtl8169_cleanup (tp, true); +rtl8169_cleanup (tp);rtl_disable_exit_l1 (tp);rtl_prepare_power_down (tp); }
Hi Hau,
I think the following simple change should also fix the issue. DMA is enabled only after the chip has been reset in rtl_reset_work(). This should ensure that there are no stale RX DMA descriptors any longer. Could you please test it?
drivers/net/ethernet/realtek/r8169_main.c +1 -1
@@ -4610,13 +4610,13 @@ static void rtl8169_down(struct rtl8169_private *tp)static void rtl8169_up (struct rtl8169_private *tp) { -pci_set_master (tp->pci_dev);phy_init_hw (tp->phydev);phy_resume (tp->phydev);rtl8169_init_phy (tp);napi_enable (&tp->napi);set_bit (RTL_FLAG_TASK_ENABLED , tp->wk.flags);rtl_reset_work (tp); +pci_set_master (tp->pci_dev);phy_start (tp->phydev); }
Signature · 1 line
2.38.0
Quoted 28 lines
I think the following simple change should also fix the issue. DMA is enabled only after the chip has been reset in
rtl_reset_work(). This should ensure that there are no stale RX DMA descriptors any longer. Could you please test it?drivers/net/ethernet/realtek/r8169_main.c +1
-2@@ -4610,13 +4610,13 @@ static void rtl8169_down(struct rtl8169_private *tp)static void rtl8169_up (struct rtl8169_private *tp) { -pci_set_master (tp->pci_dev);phy_init_hw (tp->phydev);phy_resume (tp->phydev);rtl8169_init_phy (tp);napi_enable (&tp->napi);set_bit (RTL_FLAG_TASK_ENABLED , tp->wk.flags);rtl_reset_work (tp); +pci_set_master (tp->pci_dev);phy_start (tp->phydev); } --
Quoted 2 lines
2.38.0
This can fix the issue. But it will cause another error message " rtl_rxtx_empty_cond == 0 (loop: 42, delay: 100)". Because if rx is enabled, packet will be move to fifo. When driver check if fifo is empty on device open, hardware will not dma this packet because bus master is disabled, fifo will always not empty.
So it might be better to disable txrx when close device.
------Please consider the environment before printing this e-mail.
Heiner Kallweit
maintainerQuoted 18 lines · Chunhao Lin
When close device, rx will be enabled if wol is enabeld. When open device it will cause rx to dma to wrong address after
pci_set_master().In this patch, driver will disable tx/rx when close device. If wol is eanbled only enable rx filter and disable
rxdv_gateto let hardware can receive packet to fifo but not to dma it.Fixes 120068481405 ("r8169: fix failing WoL")Signed-off-by Chunhao Lin <[email protected]>--- drivers/net/ethernet/realtek/r8169_main.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)drivers/net/ethernet/realtek/r8169_main.c +0
-0
drivers/net/ethernet/realtek/r8169_main.c static void rtl_wol_enable_rx(struct rtl8169_private *tp) · line 2244
Quoted 6 lines
drivers/net/ethernet/realtek/r8169_main.c +3
-0@@ -2239,6 +2239,9 @@ static void rtl_wol_enable_rx(struct rtl8169_private *tp)if (tp->mac_version >=RTL_GIGA_MAC_VER_25 )RTL_W32 (tp, RxConfig,RTL_R32 (tp, RxConfig) | AcceptBroadcast | AcceptMulticast | AcceptMyPhys); + +if (tp->mac_version >=RTL_GIGA_MAC_VER_40 ) +RTL_W32 (tp,MISC ,RTL_R32 (tp,MISC ) & ~RXDV_GATED_EN );
Wouldn't this be sufficient? Why is the change to rtl8169_cleanup() needed?
Quoted 49 lines
drivers/net/ethernet/realtek/r8169_main.c +4
-7}static void rtl_prepare_power_down (struct rtl8169_private *tp)@@ -3981,7 +3984,7 @@ static void rtl8169_tx_clear(struct rtl8169_private *tp)netdev_reset_queue (tp->dev); } -static void rtl8169_cleanup (struct rtl8169_private *tp,bool going_down) +static void rtl8169_private (struct rtl8169_private *tp) {napi_disable (&tp->napi);@@ -3993,9 +3996,6 @@ static void rtl8169_cleanup(struct rtl8169_private *tp, bool going_down)rtl_rx_close (tp); -if (going_down && tp->dev->wol_enabled) - goto no_reset; -switch (tp->mac_version) {case RTL_GIGA_MAC_VER_28 :case RTL_GIGA_MAC_VER_31 :@@ -4016,7 +4016,7 @@ static void rtl8169_cleanup(struct rtl8169_private *tp, bool going_down) }rtl_hw_reset (tp); -no_reset: +rtl8169_tx_clear (tp);rtl8169_init_ring_indexes (tp); }@@ -4027,7 +4027,7 @@ static void rtl_reset_work(struct rtl8169_private *tp)netif_stop_queue (tp->dev); -rtl8169_cleanup (tp, false); +rtl8169_cleanup (tp);for (i =0 ; i <NUM_RX_DESC ; i++)rtl8169_mark_to_asic (tp->RxDescArray + i);@@ -4715,7 +4715,7 @@ static void rtl8169_down(struct rtl8169_private *tp)pci_clear_master (tp->pci_dev);rtl_pci_commit (tp); -rtl8169_cleanup (tp, true); +rtl8169_cleanup (tp);rtl_disable_exit_l1 (tp);rtl_prepare_power_down (tp); }
Heiner Kallweit
maintainerQuoted 18 lines · Chunhao Lin
When close device, rx will be enabled if wol is enabeld. When open device it will cause rx to dma to wrong address after
pci_set_master().In this patch, driver will disable tx/rx when close device. If wol is eanbled only enable rx filter and disable
rxdv_gateto let hardware can receive packet to fifo but not to dma it.Fixes 120068481405 ("r8169: fix failing WoL")Signed-off-by Chunhao Lin <[email protected]>--- drivers/net/ethernet/realtek/r8169_main.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)drivers/net/ethernet/realtek/r8169_main.c +0
-0
drivers/net/ethernet/realtek/r8169_main.c static void rtl_wol_enable_rx(struct rtl8169_private *tp) · line 2244
Quoted 6 lines
drivers/net/ethernet/realtek/r8169_main.c +3
-0@@ -2239,6 +2239,9 @@ static void rtl_wol_enable_rx(struct rtl8169_private *tp)if (tp->mac_version >=RTL_GIGA_MAC_VER_25 )RTL_W32 (tp, RxConfig,RTL_R32 (tp, RxConfig) | AcceptBroadcast | AcceptMulticast | AcceptMyPhys); + +if (tp->mac_version >=RTL_GIGA_MAC_VER_40 ) +RTL_W32 (tp,MISC ,RTL_R32 (tp,MISC ) & ~RXDV_GATED_EN );
Is this correct anyway? Supposedly you want to set this bit to disable DMA.
Quoted 22 lines · Chunhao Lin
drivers/net/ethernet/realtek/r8169_main.c static void rtl_wol_enable_rx(struct
Quoted 19 lines
When close device, rx will be enabled if wol is enabeld. When open device it will cause rx to dma to wrong address after
pci_set_master().In this patch, driver will disable tx/rx when close device. If wol is eanbled only enable rx filter and disable
rxdv_gateto let hardware can receive packet to fifo but not to dma it.Fixes 120068481405 ("r8169: fix failing WoL")Signed-off-by Chunhao Lin <[email protected]>--- drivers/net/ethernet/realtek/r8169_main.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)drivers/net/ethernet/realtek/r8169_main.c +0
-0@@ -2239,6 +2239,9 @@ static void rtl_wol_enable_rx(struct
rtl8169_private*tp)
Quoted 9 lines
drivers/net/ethernet/realtek/r8169_main.c static void rtl_wol_enable_rx(struct rtl8169_private *tp) · line 2244
Quoted 6 lines
drivers/net/ethernet/realtek/r8169_main.c +3
-0if (tp->mac_version >=RTL_GIGA_MAC_VER_25 )RTL_W32 (tp, RxConfig,RTL_R32 (tp, RxConfig) | AcceptBroadcast | AcceptMulticast | AcceptMyPhys); + +if (tp->mac_version >=RTL_GIGA_MAC_VER_40 ) +RTL_W32 (tp,MISC ,RTL_R32 (tp,MISC ) & ~RXDV_GATED_EN );Is this correct anyway? Supposedly you want to set this bit to disable DMA.
If wol is enabled, driver need to disable hardware rxdv_gate for receiving packets.
------Please consider the environment before printing this e-mail.
Heiner Kallweit
maintainerQuoted 31 lines · Hau
Quoted 22 lines · Chunhao Lin
drivers/net/ethernet/realtek/r8169_main.c static void rtl_wol_enable_rx(struct
Quoted 19 lines
When close device, rx will be enabled if wol is enabeld. When open device it will cause rx to dma to wrong address after
pci_set_master().In this patch, driver will disable tx/rx when close device. If wol is eanbled only enable rx filter and disable
rxdv_gateto let hardware can receive packet to fifo but not to dma it.Fixes 120068481405 ("r8169: fix failing WoL")Signed-off-by Chunhao Lin <[email protected]>--- drivers/net/ethernet/realtek/r8169_main.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)drivers/net/ethernet/realtek/r8169_main.c +0
-0@@ -2239,6 +2239,9 @@ static void rtl_wol_enable_rx(struct
rtl8169_private*tp)Quoted 9 lines
drivers/net/ethernet/realtek/r8169_main.c static void rtl_wol_enable_rx(struct rtl8169_private *tp) · line 2244
Quoted 6 lines
drivers/net/ethernet/realtek/r8169_main.c +3
-0if (tp->mac_version >=RTL_GIGA_MAC_VER_25 )RTL_W32 (tp, RxConfig,RTL_R32 (tp, RxConfig) | AcceptBroadcast | AcceptMulticast | AcceptMyPhys); + +if (tp->mac_version >=RTL_GIGA_MAC_VER_40 ) +RTL_W32 (tp,MISC ,RTL_R32 (tp,MISC ) & ~RXDV_GATED_EN );Is this correct anyway? Supposedly you want to set this bit to disable DMA.
Quoted 2 lines
If wol is enabled, driver need to disable hardware
rxdv_gatefor receiving packets.
OK, I see. But why disable it here? I see no scenario where rxdv_gate would be enabled when we get here.
Quoted 32 lines · Hau
Quoted 31 lines
Quoted 31 lines · Chunhao Lin
drivers/net/ethernet/realtek/r8169_main.c static void rtl_wol_enable_rx(struct
Quoted 19 lines
When close device, rx will be enabled if wol is enabeld. When open device it will cause rx to dma to wrong address after
pci_set_master().In this patch, driver will disable tx/rx when close device. If wol is eanbled only enable rx filter and disable
rxdv_gateto let hardware can receive packet to fifo but not to dma it.Fixes 120068481405 ("r8169: fix failing WoL")Signed-off-by Chunhao Lin <[email protected]>--- drivers/net/ethernet/realtek/r8169_main.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)drivers/net/ethernet/realtek/r8169_main.c +0
-0@@ -2239,6 +2239,9 @@ static void rtl_wol_enable_rx(struct
rtl8169_private*tp)drivers/net/ethernet/realtek/r8169_main.c static void rtl_wol_enable_rx(struct rtl8169_private *tp) · line 2244
Quoted 6 lines
drivers/net/ethernet/realtek/r8169_main.c +3
-0if (tp->mac_version >=RTL_GIGA_MAC_VER_25 )RTL_W32 (tp, RxConfig,RTL_R32 (tp, RxConfig) | AcceptBroadcast | AcceptMulticast | AcceptMyPhys); + +if (tp->mac_version >=RTL_GIGA_MAC_VER_40 ) +RTL_W32 (tp,MISC ,RTL_R32 (tp,MISC ) & ~RXDV_GATED_EN );Is this correct anyway? Supposedly you want to set this bit to disable DMA.
Quoted 6 lines
Quoted 1 line
If wol is enabled, driver need to disable hardware
rxdv_gatefor receivingpackets.
Quoted 1 line
OK, I see. But why disable it here? I see no scenario where
rxdv_gatewould be enabled when we get here.
rxdv_gate will be enabled in rtl8169_cleanup(). When suspend or close and wol is enabled driver will call rtl8169_down() -> rtl8169_cleanup()-> rtl_prepare_power_down()-> rtl_wol_enable_rx(). So disabled rxdv_gate in rtl_wol_enable_rx() for receiving packets.
------Please consider the environment before printing this e-mail.
Heiner Kallweit
maintainerQuoted 33 lines · Hau
Quoted 33 lines · Hau
Quoted 32 lines
Quoted 22 lines · Chunhao Lin
drivers/net/ethernet/realtek/r8169_main.c static void rtl_wol_enable_rx(struct
Quoted 19 lines
When close device, rx will be enabled if wol is enabeld. When open device it will cause rx to dma to wrong address after
pci_set_master().In this patch, driver will disable tx/rx when close device. If wol is eanbled only enable rx filter and disable
rxdv_gateto let hardware can receive packet to fifo but not to dma it.Fixes 120068481405 ("r8169: fix failing WoL")Signed-off-by Chunhao Lin <[email protected]>--- drivers/net/ethernet/realtek/r8169_main.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)drivers/net/ethernet/realtek/r8169_main.c +0
-0@@ -2239,6 +2239,9 @@ static void rtl_wol_enable_rx(struct
rtl8169_private*tp)Quoted 9 lines
drivers/net/ethernet/realtek/r8169_main.c static void rtl_wol_enable_rx(struct rtl8169_private *tp) · line 2244
Quoted 6 lines
drivers/net/ethernet/realtek/r8169_main.c +3
-0if (tp->mac_version >=RTL_GIGA_MAC_VER_25 )RTL_W32 (tp, RxConfig,RTL_R32 (tp, RxConfig) | AcceptBroadcast | AcceptMulticast | AcceptMyPhys); + +if (tp->mac_version >=RTL_GIGA_MAC_VER_40 ) +RTL_W32 (tp,MISC ,RTL_R32 (tp,MISC ) & ~RXDV_GATED_EN );Is this correct anyway? Supposedly you want to set this bit to disable DMA.
If wol is enabled, driver need to disable hardware
rxdv_gatefor receiving
Quoted 9 lines
Quoted 5 lines
packets.
Quoted 1 line
OK, I see. But why disable it here? I see no scenario where
rxdv_gatewould be enabled when we get here.
rxdv_gatewill be enabled inrtl8169_cleanup(). When suspend or close and wol is enabled driver will callrtl8169_down()-> rtl8169_cleanup()-> rtl_prepare_power_down()->rtl_wol_enable_rx(). So disabledrxdv_gateinrtl_wol_enable_rx()for receiving packets.
rtl8169_cleanup() skips the call to rtl_enable_rxdvgate() when being called from rtl8169_down() and wol is enabled. This means rxdv gate is still disabled.
Quoted 42 lines · Hau
Quoted 23 lines
Quoted 23 lines · Hau
Quoted 22 lines
Quoted 22 lines · Chunhao Lin
drivers/net/ethernet/realtek/r8169_main.c static void rtl_wol_enable_rx(struct
Quoted 19 lines
When close device, rx will be enabled if wol is enabeld. When open device it will cause rx to dma to wrong address after
pci_set_master().In this patch, driver will disable tx/rx when close device. If wol is eanbled only enable rx filter and disable
rxdv_gateto let hardware can receive packet to fifo but not to dma it.Fixes 120068481405 ("r8169: fix failing WoL")Signed-off-by Chunhao Lin <[email protected]>--- drivers/net/ethernet/realtek/r8169_main.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)drivers/net/ethernet/realtek/r8169_main.c +0
-0@@ -2239,6 +2239,9 @@ static void rtl_wol_enable_rx(struct
rtl8169_private*tp)Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/net/ethernet/realtek/r8169_main.c static void rtl_wol_enable_rx(struct rtl8169_private *tp)
Quoted 6 lines
drivers/net/ethernet/realtek/r8169_main.c +3
-0if (tp->mac_version >=RTL_GIGA_MAC_VER_25 )RTL_W32 (tp, RxConfig,RTL_R32 (tp, RxConfig) | AcceptBroadcast | AcceptMulticast | AcceptMyPhys); + +if (tp->mac_version >=RTL_GIGA_MAC_VER_40 ) + RTL_W32(tp, MISC, RTL_R32(tp, MISC) &~RXDV_GATED_EN);
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Is this correct anyway? Supposedly you want to set this bit to disable
DMA.
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
If wol is enabled, driver need to disable hardware
rxdv_gatefor receivingpackets.
Quoted 1 line
OK, I see. But why disable it here? I see no scenario where
rxdv_gatewould be enabled when we get here.
Quoted 9 lines
Quoted 2 lines
rxdv_gatewill be enabled inrtl8169_cleanup(). When suspend or close and wol is enabled driver will callrtl8169_down()-> rtl8169_cleanup()->rtl_prepare_power_down()->
rtl_wol_enable_rx().Quoted 2 lines
So disabled
rxdv_gateinrtl_wol_enable_rx()for receiving packets.
rtl8169_cleanup()skips the call tortl_enable_rxdvgate()when being called fromrtl8169_down()and wol is enabled. This means rxdv gate is still disabled.
Yes, it will keep rxdv_gate disable. But it will also keep tx/rx on. If OS have an unexpected reboot hardware may dma to invalid memory address. If possible I prefer to keep tx/rx off when exit driver control.
------Please consider the environment before printing this e-mail.
Heiner Kallweit
maintainerQuoted 47 lines · Hau
Quoted 47 lines · Hau
Quoted 23 lines
Quoted 23 lines · Hau
Quoted 22 lines
Quoted 22 lines · Chunhao Lin
drivers/net/ethernet/realtek/r8169_main.c static void rtl_wol_enable_rx(struct
Quoted 19 lines
When close device, rx will be enabled if wol is enabeld. When open device it will cause rx to dma to wrong address after
pci_set_master().In this patch, driver will disable tx/rx when close device. If wol is eanbled only enable rx filter and disable
rxdv_gateto let hardware can receive packet to fifo but not to dma it.Fixes 120068481405 ("r8169: fix failing WoL")Signed-off-by Chunhao Lin <[email protected]>--- drivers/net/ethernet/realtek/r8169_main.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)drivers/net/ethernet/realtek/r8169_main.c +0
-0@@ -2239,6 +2239,9 @@ static void rtl_wol_enable_rx(struct
rtl8169_private*tp)Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/net/ethernet/realtek/r8169_main.c static void rtl_wol_enable_rx(struct · line 2244
Quoted 6 lines
drivers/net/ethernet/realtek/r8169_main.c +3
-0if (tp->mac_version >=RTL_GIGA_MAC_VER_25 )RTL_W32 (tp, RxConfig,RTL_R32 (tp, RxConfig) | AcceptBroadcast | AcceptMulticast | AcceptMyPhys); + +if (tp->mac_version >=RTL_GIGA_MAC_VER_40 ) + RTL_W32(tp, MISC, RTL_R32(tp, MISC) &~RXDV_GATED_EN);
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Is this correct anyway? Supposedly you want to set this bit to disable
DMA.
Quoted 10 lines
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
If wol is enabled, driver need to disable hardware
rxdv_gatefor receivingpackets.
Quoted 1 line
OK, I see. But why disable it here? I see no scenario where
rxdv_gatewould be enabled when we get here.
rxdv_gatewill be enabled inrtl8169_cleanup(). When suspend or close and wol is enabled driver will callrtl8169_down()-> rtl8169_cleanup()->rtl_prepare_power_down()->
rtl_wol_enable_rx().Quoted 2 lines
So disabled
rxdv_gateinrtl_wol_enable_rx()for receiving packets.
Quoted 8 lines
Quoted 4 lines
rtl8169_cleanup()skips the call tortl_enable_rxdvgate()when being called fromrtl8169_down()and wol is enabled. This means rxdv gate is still disabled.Yes, it will keep
rxdv_gatedisable. But it will also keep tx/rx on. If OS have an unexpected reboot hardware may dma to invalid memory address. If possible I prefer to keep tx/rx off when exit driver control.
When you say "keep tx/rx off", do you refer to the rxconfig bits in register RxConfig, or to CmdTxEnb and CmdRxEnb in ChipCmd?
If we talk about the first option, then my guess would be:
According to rtl_wol_enable_rx() the rx config bits are required for WoL to work on certain chip versions. With the introduction of rxdvgate this changed and setting these bits isn't needed any longer.
I tested on RTL8168h and WoL worked w/o the Accept bits set in RxConfig. Please confirm or correct my understanding.
static void rtl_wol_enable_rx(struct rtl8169_private *tp)
{
if (tp->mac_version >= RTL_GIGA_MAC_VER_25)
RTL_W32(tp, RxConfig, RTL_R32(tp, RxConfig) |
AcceptBroadcast | AcceptMulticast | AcceptMyPhys);
}Quoted 71 lines · Hau
Quoted 6 lines
Quoted 6 lines · Hau
Quoted 5 lines
Quoted 5 lines · Hau
Quoted 4 lines
Quoted 4 lines · Chunhao Lin
Quoted 2 lines
When close device, rx will be enabled if wol is enabeld. When open device it will cause rx to dma to wrong address after
pci_set_master().Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
drivers/net/ethernet/realtek/r8169_main.c static void rtl_wol_enable_rx(struct
Quoted 17 lines
In this patch, driver will disable tx/rx when close device. If wol is eanbled only enable rx filter and disable
rxdv_gateto let hardware can receive packet to fifo but not to dma it.Fixes 120068481405 ("r8169: fix failing WoL")Signed-off-by Chunhao Lin <[email protected]>--- drivers/net/ethernet/realtek/r8169_main.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)drivers/net/ethernet/realtek/r8169_main.c +0
-0@@ -2239,6 +2239,9 @@ static void rtl_wol_enable_rx(struct
rtl8169_private*tp)Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/net/ethernet/realtek/r8169_main.c static void rtl_wol_enable_rx(struct · line 2241
Quoted 3 lines
drivers/net/ethernet/realtek/r8169_main.c +0
-0if (tp->mac_version >=RTL_GIGA_MAC_VER_25 ) RTL_W32(tp, RxConfig, RTL_R32(tp, RxConfig) | AcceptBroadcast | AcceptMulticast |AcceptMyPhys);
Quoted 22 lines
Quoted 22 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/net/ethernet/realtek/r8169_main.c static void rtl_wol_enable_rx(struct · line 2244
Quoted 3 lines
drivers/net/ethernet/realtek/r8169_main.c +3
-0+ +if (tp->mac_version >=RTL_GIGA_MAC_VER_40 ) + RTL_W32(tp, MISC, RTL_R32(tp, MISC) &~RXDV_GATED_EN);
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Is this correct anyway? Supposedly you want to set this bit to disable
DMA.
Quoted 11 lines
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
If wol is enabled, driver need to disable hardware
rxdv_gatefor receivingpackets.
Quoted 1 line
OK, I see. But why disable it here? I see no scenario where
rxdv_gatewould be enabled when we get here.
rxdv_gatewill be enabled inrtl8169_cleanup(). When suspend or close and wol is enabled driver will callrtl8169_down()-> rtl8169_cleanup()->rtl_prepare_power_down()->
rtl_wol_enable_rx().Quoted 2 lines
So disabled
rxdv_gateinrtl_wol_enable_rx()for receiving packets.Quoted 8 lines
Quoted 4 lines
rtl8169_cleanup()skips the call tortl_enable_rxdvgate()when being called fromrtl8169_down()and wol is enabled. This means rxdv gate is still disabled.Yes, it will keep
rxdv_gatedisable. But it will also keep tx/rx on. If OS have an unexpected reboot hardware may dma to invalid memory address. If possible I prefer to keep tx/rx off when exit driver control.When you say "keep tx/rx off", do you refer to the rxconfig bits in register RxConfig, or to CmdTxEnb and CmdRxEnb in ChipCmd?
If we talk about the first option, then my guess would be:
According tortl_wol_enable_rx()the rx config bits are required for WoL to work on certain chip versions. With the introduction of rxdvgate this changed and setting these bits isn't needed any longer.
I tested on RTL8168h and WoL worked w/o the Accept bits set in RxConfig. Please confirm or correct my understanding.
Quoted 7 lines
static void rtl_wol_enable_rx(struct rtl8169_private *tp) { if (tp->mac_version >= RTL_GIGA_MAC_VER_25) RTL_W32(tp, RxConfig, RTL_R32(tp, RxConfig) | AcceptBroadcast | AcceptMulticast |AcceptMyPhys); }
We expect wol packet should be filtered by Accept bits set in RxConfig. But for magic packet wakeup it seems it does not perform as expected. We need some time to figure this out. Once we have any update we will let you know.
------Please consider the environment before printing this e-mail.
Quoted 72 lines · Hau
Quoted 6 lines
Quoted 6 lines · Hau
Quoted 5 lines
Quoted 5 lines · Hau
Quoted 4 lines
Quoted 4 lines · Chunhao Lin
Quoted 2 lines
When close device, rx will be enabled if wol is enabeld. When open device it will cause rx to dma to wrong address after
pci_set_master().Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
drivers/net/ethernet/realtek/r8169_main.c static void rtl_wol_enable_rx(struct
Quoted 17 lines
In this patch, driver will disable tx/rx when close device. If wol is eanbled only enable rx filter and disable
rxdv_gateto let hardware can receive packet to fifo but not to dma it.Fixes 120068481405 ("r8169: fix failing WoL")Signed-off-by Chunhao Lin <[email protected]>--- drivers/net/ethernet/realtek/r8169_main.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)drivers/net/ethernet/realtek/r8169_main.c +0
-0@@ -2239,6 +2239,9 @@ static void rtl_wol_enable_rx(struct
rtl8169_private*tp)Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/net/ethernet/realtek/r8169_main.c static void rtl_wol_enable_rx(struct · line 2241
Quoted 3 lines
drivers/net/ethernet/realtek/r8169_main.c +0
-0if (tp->mac_version >=RTL_GIGA_MAC_VER_25 ) RTL_W32(tp, RxConfig, RTL_R32(tp, RxConfig) | AcceptBroadcast | AcceptMulticast |AcceptMyPhys);
Quoted 22 lines
Quoted 22 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/net/ethernet/realtek/r8169_main.c static void rtl_wol_enable_rx(struct · line 2244
Quoted 3 lines
drivers/net/ethernet/realtek/r8169_main.c +3
-0+ +if (tp->mac_version >=RTL_GIGA_MAC_VER_40 ) + RTL_W32(tp, MISC, RTL_R32(tp, MISC) &~RXDV_GATED_EN);
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Is this correct anyway? Supposedly you want to set this bit to disable
DMA.
Quoted 11 lines
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
If wol is enabled, driver need to disable hardware
rxdv_gatefor receivingpackets.
Quoted 1 line
OK, I see. But why disable it here? I see no scenario where
rxdv_gatewould be enabled when we get here.
rxdv_gatewill be enabled inrtl8169_cleanup(). When suspend or close and wol is enabled driver will callrtl8169_down()-> rtl8169_cleanup()->rtl_prepare_power_down()->
rtl_wol_enable_rx().Quoted 2 lines
So disabled
rxdv_gateinrtl_wol_enable_rx()for receiving packets.Quoted 8 lines
Quoted 4 lines
rtl8169_cleanup()skips the call tortl_enable_rxdvgate()when being called fromrtl8169_down()and wol is enabled. This means rxdv gate is still disabled.Yes, it will keep
rxdv_gatedisable. But it will also keep tx/rx on. If OS have an unexpected reboot hardware may dma to invalid memory address. If possible I prefer to keep tx/rx off when exit driver control.When you say "keep tx/rx off", do you refer to the rxconfig bits in register RxConfig, or to CmdTxEnb and CmdRxEnb in ChipCmd?
If we talk about the first option, then my guess would be:
According tortl_wol_enable_rx()the rx config bits are required for WoL to work on certain chip versions. With the introduction of rxdvgate this changed and setting these bits isn't needed any longer.
I tested on RTL8168h and WoL worked w/o the Accept bits set in RxConfig. Please confirm or correct my understanding.
Quoted 7 lines
static void rtl_wol_enable_rx(struct rtl8169_private *tp) { if (tp->mac_version >= RTL_GIGA_MAC_VER_25) RTL_W32(tp, RxConfig, RTL_R32(tp, RxConfig) | AcceptBroadcast | AcceptMulticast |AcceptMyPhys); }
When enter d3cold hardware will pull pcie reset to low. If pcie reset is pulled low hardware will set rcr acpt_phy/mar/brd . That is why you still get wol worked w/o set rcr. Although hardware will set rcr bits when pcie reset is pull low. But there is no pcie reset when hardware enter d3hot. So driver still needs to set rcr bits when hardware go to d3 state.
------Please consider the environment before printing this e-mail.