Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Intel-wired-lan] [PATCH RFC net-next] e1000e: Fix real-time violations on link up
@ 2024-10-11 19:54 Gerhard Engleder
  2024-10-12 18:42 ` Andrew Lunn
  0 siblings, 1 reply; 4+ messages in thread
From: Gerhard Engleder @ 2024-10-11 19:54 UTC (permalink / raw)
  To: anthony.l.nguyen, przemyslaw.kitszel, davem, edumazet, kuba,
	pabeni
  Cc: Gerhard Engleder, netdev, intel-wired-lan, Gerhard Engleder

From: Gerhard Engleder <eg@keba.com>

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.

Signed-off-by: Gerhard Engleder <eg@keba.com>
---
 drivers/net/ethernet/intel/e1000e/mac.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/e1000e/mac.c b/drivers/net/ethernet/intel/e1000e/mac.c
index d7df2a0ed629..f4693d355886 100644
--- a/drivers/net/ethernet/intel/e1000e/mac.c
+++ b/drivers/net/ethernet/intel/e1000e/mac.c
@@ -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
 }
 
 /**
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Intel-wired-lan] [PATCH RFC net-next] e1000e: Fix real-time violations on link up
  2024-10-11 19:54 [Intel-wired-lan] [PATCH RFC net-next] e1000e: Fix real-time violations on link up Gerhard Engleder
@ 2024-10-12 18:42 ` Andrew Lunn
  2024-10-14 17:59   ` Gerhard Engleder
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Lunn @ 2024-10-12 18:42 UTC (permalink / raw)
  To: Gerhard Engleder
  Cc: przemyslaw.kitszel, Gerhard Engleder, edumazet, netdev,
	anthony.l.nguyen, intel-wired-lan, kuba, pabeni, davem

On Fri, Oct 11, 2024 at 09:54:12PM +0200, Gerhard Engleder wrote:
> From: Gerhard Engleder <eg@keba.com>
> 
> 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.
> 
> Signed-off-by: Gerhard Engleder <eg@keba.com>
> ---
>  drivers/net/ethernet/intel/e1000e/mac.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/intel/e1000e/mac.c b/drivers/net/ethernet/intel/e1000e/mac.c
> index d7df2a0ed629..f4693d355886 100644
> --- a/drivers/net/ethernet/intel/e1000e/mac.c
> +++ b/drivers/net/ethernet/intel/e1000e/mac.c
> @@ -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

#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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Intel-wired-lan] [PATCH RFC net-next] e1000e: Fix real-time violations on link up
  2024-10-12 18:42 ` Andrew Lunn
@ 2024-10-14 17:59   ` Gerhard Engleder
  2024-10-15 13:41     ` Lifshits, Vitaly
  0 siblings, 1 reply; 4+ messages in thread
From: Gerhard Engleder @ 2024-10-14 17:59 UTC (permalink / raw)
  To: Andrew Lunn, anthony.l.nguyen, przemyslaw.kitszel
  Cc: netdev, Gerhard Engleder, edumazet, intel-wired-lan, kuba, pabeni,
	davem

On 12.10.24 20:42, Andrew Lunn wrote:
> On Fri, Oct 11, 2024 at 09:54:12PM +0200, Gerhard Engleder wrote:
>> From: Gerhard Engleder <eg@keba.com>
>>
>> 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.
>>
>> Signed-off-by: Gerhard Engleder <eg@keba.com>
>> ---
>>   drivers/net/ethernet/intel/e1000e/mac.c | 8 +++++++-
>>   1 file changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/ethernet/intel/e1000e/mac.c b/drivers/net/ethernet/intel/e1000e/mac.c
>> index d7df2a0ed629..f4693d355886 100644
>> --- a/drivers/net/ethernet/intel/e1000e/mac.c
>> +++ b/drivers/net/ethernet/intel/e1000e/mac.c
>> @@ -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
> 
> #ifdef FOO is generally not liked because it reduces the effectiveness
> of build testing.
> 
> Two suggestions:
> 
> 	if (IS_ENABLED(CONFIG_PREEMPT_RT))
> 		e1e_flush();

I will do that.

> 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.

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Intel-wired-lan] [PATCH RFC net-next] e1000e: Fix real-time violations on link up
  2024-10-14 17:59   ` Gerhard Engleder
@ 2024-10-15 13:41     ` Lifshits, Vitaly
  0 siblings, 0 replies; 4+ messages in thread
From: Lifshits, Vitaly @ 2024-10-15 13:41 UTC (permalink / raw)
  To: intel-wired-lan


On 10/14/2024 8:59 PM, Gerhard Engleder wrote:
> On 12.10.24 20:42, Andrew Lunn wrote:
>> On Fri, Oct 11, 2024 at 09:54:12PM +0200, Gerhard Engleder wrote:
>>> From: Gerhard Engleder <eg@keba.com>
>>>
>>> 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.
>>>
>>> Signed-off-by: Gerhard Engleder <eg@keba.com>
>>> ---
>>>   drivers/net/ethernet/intel/e1000e/mac.c | 8 +++++++-
>>>   1 file changed, 7 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/net/ethernet/intel/e1000e/mac.c 
>>> b/drivers/net/ethernet/intel/e1000e/mac.c
>>> index d7df2a0ed629..f4693d355886 100644
>>> --- a/drivers/net/ethernet/intel/e1000e/mac.c
>>> +++ b/drivers/net/ethernet/intel/e1000e/mac.c
>>> @@ -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
>>
>> #ifdef FOO is generally not liked because it reduces the effectiveness
>> of build testing.
>>
>> Two suggestions:
>>
>>     if (IS_ENABLED(CONFIG_PREEMPT_RT))
>>         e1e_flush();
>
> I will do that.
>
>> 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.


>>
>> 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.


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

>
> Thank you for your feedback Andrew!
>
> Any comments from Intel driver maintainers?
>
> Gerhard


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-10-15 13:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-11 19:54 [Intel-wired-lan] [PATCH RFC net-next] e1000e: Fix real-time violations on link up Gerhard Engleder
2024-10-12 18:42 ` Andrew Lunn
2024-10-14 17:59   ` Gerhard Engleder
2024-10-15 13:41     ` Lifshits, Vitaly

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox