Skip to contentSkip to conversation

e1000e: Fix real-time violations on link up

RFC PATCH In review Gerhard Engleder 3 participants 4 messages Oct 11, 2024 – Oct 15, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 e1000e: Fix real-time violations on link up

From: Gerhard Engleder <[email protected]>

Link down and up triggers update of MTA table. This update executes many PCIe writes and a final flush. Thus, PCIe will be blocked until all writes are flushed. As a result, DMA transfers of other targets suffer from delay in the range of 50us. The result are timing violations on real-time systems during link down and up of e1000e.

Execute a flush after every single write. This prevents overloading the interconnect with posted writes. As this also increases the time spent for MTA table update considerable this change is limited to PREEMPT_RT.

---
 drivers/net/ethernet/intel/e1000e/mac.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/e1000e/mac.c +7 -1
index d7df2a0ed629..f4693d355886 100644
@@ -331,9 +331,15 @@ void e1000e_update_mc_addr_list_generic(struct e1000_hw *hw,
 	}
 
 	/* replace the entire MTA table */
-	for (i = hw->mac.mta_reg_count - 1; i >= 0; i--)
+	for (i = hw->mac.mta_reg_count - 1; i >= 0; i--) {
 		E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, hw->mac.mta_shadow[i]);
+#ifdef CONFIG_PREEMPT_RT
+		e1e_flush();
+#endif
+	}
+#ifndef CONFIG_PREEMPT_RT
 	e1e_flush();
+#endif
 }
 
 /**
Signature · 1 line
2.39.2
#1 lore raw
Quoted 25 lines · Gerhard Engleder

From: Gerhard Engleder <[email protected]>

Link down and up triggers update of MTA table. This update executes many PCIe writes and a final flush. Thus, PCIe will be blocked until all writes are flushed. As a result, DMA transfers of other targets suffer from delay in the range of 50us. The result are timing violations on real-time systems during link down and up of e1000e.

Execute a flush after every single write. This prevents overloading the interconnect with posted writes. As this also increases the time spent for MTA table update considerable this change is limited to PREEMPT_RT.

---
 drivers/net/ethernet/intel/e1000e/mac.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/e1000e/mac.c +0 -0
index d7df2a0ed629..f4693d355886 100644
@@ -331,9 +331,15 @@ void e1000e_update_mc_addr_list_generic(struct e1000_hw *hw,
 	}
 
 	/* replace the entire MTA table */

drivers/net/ethernet/intel/e1000e/mac.c void e1000e_update_mc_addr_list_generic(struct e1000_hw *hw, · line 342

Quoted 10 lines
drivers/net/ethernet/intel/e1000e/mac.c +7 -1
-	for (i = hw->mac.mta_reg_count - 1; i >= 0; i--)
+	for (i = hw->mac.mta_reg_count - 1; i >= 0; i--) {
 		E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, hw->mac.mta_shadow[i]);
+#ifdef CONFIG_PREEMPT_RT
+		e1e_flush();
+#endif
+	}
+#ifndef CONFIG_PREEMPT_RT
 	e1e_flush();
+#endif

#ifdef FOO is generally not liked because it reduces the effectiveness of build testing.

Two suggestions:

	if (IS_ENABLED(CONFIG_PREEMPT_RT))
		e1e_flush();

This will then end up as and if (0) or if (1), with the statement following it always being compiled, and then optimised out if not needed.

Alternatively, consider something like:

	if (i % 8)
		e1e_flush()

if there is a reasonable compromise between RT and none RT performance. Given that RT is now fully merged, we might see some distros enable it, so a compromise would probably be better.

Andrew

#2 lore raw
Quoted 40 lines · Andrew Lunn
Quoted 25 lines · Gerhard Engleder

From: Gerhard Engleder <[email protected]>

Link down and up triggers update of MTA table. This update executes many PCIe writes and a final flush. Thus, PCIe will be blocked until all writes are flushed. As a result, DMA transfers of other targets suffer from delay in the range of 50us. The result are timing violations on real-time systems during link down and up of e1000e.

Execute a flush after every single write. This prevents overloading the interconnect with posted writes. As this also increases the time spent for MTA table update considerable this change is limited to PREEMPT_RT.

---
  drivers/net/ethernet/intel/e1000e/mac.c | 8 +++++++-
  1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/e1000e/mac.c +0 -0
index d7df2a0ed629..f4693d355886 100644
@@ -331,9 +331,15 @@ void e1000e_update_mc_addr_list_generic(struct e1000_hw *hw,
  	}
 
  	/* replace the entire MTA table */

drivers/net/ethernet/intel/e1000e/mac.c void e1000e_update_mc_addr_list_generic(struct e1000_hw *hw, · line 342

Quoted 10 lines
drivers/net/ethernet/intel/e1000e/mac.c +7 -1
-	for (i = hw->mac.mta_reg_count - 1; i >= 0; i--)
+	for (i = hw->mac.mta_reg_count - 1; i >= 0; i--) {
  		E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, hw->mac.mta_shadow[i]);
+#ifdef CONFIG_PREEMPT_RT
+		e1e_flush();
+#endif
+	}
+#ifndef CONFIG_PREEMPT_RT
  	e1e_flush();
+#endif

#ifdef FOO is generally not liked because it reduces the effectiveness of build testing.

Quoted 4 lines

Two suggestions:

	if (IS_ENABLED(CONFIG_PREEMPT_RT))
		e1e_flush();

I will do that.

Quoted 4 lines

This will then end up as and if (0) or if (1), with the statement following it always being compiled, and then optimised out if not needed.

Quoted 8 lines

Alternatively, consider something like:

	if (i % 8)
		e1e_flush()

if there is a reasonable compromise between RT and none RT performance. Given that RT is now fully merged, we might see some distros enable it, so a compromise would probably be better.

Yes, read/flush after every posted write is likely too much. I will do some testing how often flush is required.

Thank you for your feedback Andrew!

Any comments from Intel driver maintainers?

Gerhard

#3 lore raw
Quoted 41 lines · Gerhard Engleder
Quoted 40 lines · Andrew Lunn
Quoted 25 lines · Gerhard Engleder

From: Gerhard Engleder <[email protected]>

Link down and up triggers update of MTA table. This update executes many PCIe writes and a final flush. Thus, PCIe will be blocked until all writes are flushed. As a result, DMA transfers of other targets suffer from delay in the range of 50us. The result are timing violations on real-time systems during link down and up of e1000e.

Execute a flush after every single write. This prevents overloading the interconnect with posted writes. As this also increases the time spent for MTA table update considerable this change is limited to PREEMPT_RT.

---
  drivers/net/ethernet/intel/e1000e/mac.c | 8 +++++++-

  1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/e1000e/mac.c +0 -0
index d7df2a0ed629..f4693d355886 100644
@@ -331,9 +331,15 @@ void e1000e_update_mc_addr_list_generic(struct 
 e1000_hw *hw,
       }
         /* replace the entire MTA table */

drivers/net/ethernet/intel/e1000e/mac.c void e1000e_update_mc_addr_list_generic(struct · line 342

Quoted 10 lines
drivers/net/ethernet/intel/e1000e/mac.c +7 -1
-    for (i = hw->mac.mta_reg_count - 1; i >= 0; i--)
+    for (i = hw->mac.mta_reg_count - 1; i >= 0; i--) {
           E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, hw->mac.mta_shadow[i]);
+#ifdef CONFIG_PREEMPT_RT
+        e1e_flush();
+#endif
+    }
+#ifndef CONFIG_PREEMPT_RT
       e1e_flush();
+#endif

#ifdef FOO is generally not liked because it reduces the effectiveness of build testing.

Quoted 10 lines
Quoted 4 lines

Two suggestions:

    if (IS_ENABLED(CONFIG_PREEMPT_RT))
        e1e_flush();

I will do that.

Quoted 3 lines

This will then end up as and if (0) or if (1), with the statement following it always being compiled, and then optimised out if not needed.

I agree with Andrew, this approach is more elegant and won't cause degradation in the performance.

Quoted 6 lines
Quoted 6 lines

Alternatively, consider something like:

    if (i % 8)
        e1e_flush()

Quoted 6 lines
Quoted 3 lines

if there is a reasonable compromise between RT and none RT performance. Given that RT is now fully merged, we might see some distros enable it, so a compromise would probably be better.

Yes, read/flush after every posted write is likely too much. I will do some testing how often flush is required.

I like this approach less, since it might be system-dependent, so that on some systems it will work well and on others it will fail

Quoted 6 lines

Thank you for your feedback Andrew!

Any comments from Intel driver maintainers?

Gerhard