mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] igb: Fix extts capture value format for 82580/i354/i350
@ 2023-05-31  9:08 Yuezhen Luan
  2023-05-31 22:01 ` Simon Horman
  2023-06-01  5:33 ` [Intel-wired-lan] " Paul Menzel
  0 siblings, 2 replies; 5+ messages in thread
From: Yuezhen Luan @ 2023-05-31  9:08 UTC (permalink / raw)
  To: jesse.brandeburg, anthony.l.nguyen, davem, edumazet, kuba, pabeni
  Cc: intel-wired-lan, netdev, linux-kernel, jacob.e.keller, Yuezhen Luan

82580/i354/i350 features circle-counter-like timestamp registers
that are different with newer i210. The EXTTS capture value in
AUXTSMPx should be converted from raw circle counter value to
timestamp value in resolution of 1 nanosec by the driver.

Signed-off-by: Yuezhen Luan <eggcar.luan@gmail.com>
---
 drivers/net/ethernet/intel/igb/igb_main.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index 58872a4c2..187daa8ef 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -6947,6 +6947,7 @@ static void igb_extts(struct igb_adapter *adapter, int tsintr_tt)
 	struct e1000_hw *hw = &adapter->hw;
 	struct ptp_clock_event event;
 	struct timespec64 ts;
+	unsigned long flags;
 
 	if (pin < 0 || pin >= IGB_N_SDP)
 		return;
@@ -6954,9 +6955,12 @@ static void igb_extts(struct igb_adapter *adapter, int tsintr_tt)
 	if (hw->mac.type == e1000_82580 ||
 	    hw->mac.type == e1000_i354 ||
 	    hw->mac.type == e1000_i350) {
-		s64 ns = rd32(auxstmpl);
+		u64 ns = rd32(auxstmpl);
 
-		ns += ((s64)(rd32(auxstmph) & 0xFF)) << 32;
+		ns += ((u64)(rd32(auxstmph) & 0xFF)) << 32;
+		spin_lock_irqsave(&adapter->tc, ns);
+		ns = timecounter_cyc2time(&adapter->tc, ns);
+		spin_unlock_irqrestore(&adapter->tc, ns);
 		ts = ns_to_timespec64(ns);
 	} else {
 		ts.tv_nsec = rd32(auxstmpl);
-- 
2.34.1


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

* Re: [PATCH] igb: Fix extts capture value format for 82580/i354/i350
  2023-05-31  9:08 [PATCH] igb: Fix extts capture value format for 82580/i354/i350 Yuezhen Luan
@ 2023-05-31 22:01 ` Simon Horman
  2023-06-01  5:33 ` [Intel-wired-lan] " Paul Menzel
  1 sibling, 0 replies; 5+ messages in thread
From: Simon Horman @ 2023-05-31 22:01 UTC (permalink / raw)
  To: Yuezhen Luan
  Cc: jesse.brandeburg, anthony.l.nguyen, davem, edumazet, kuba,
	pabeni, intel-wired-lan, netdev, linux-kernel, jacob.e.keller

On Wed, May 31, 2023 at 09:08:05AM +0000, Yuezhen Luan wrote:
> 82580/i354/i350 features circle-counter-like timestamp registers
> that are different with newer i210. The EXTTS capture value in
> AUXTSMPx should be converted from raw circle counter value to
> timestamp value in resolution of 1 nanosec by the driver.
> 
> Signed-off-by: Yuezhen Luan <eggcar.luan@gmail.com>
> ---
>  drivers/net/ethernet/intel/igb/igb_main.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
> index 58872a4c2..187daa8ef 100644
> --- a/drivers/net/ethernet/intel/igb/igb_main.c
> +++ b/drivers/net/ethernet/intel/igb/igb_main.c
> @@ -6947,6 +6947,7 @@ static void igb_extts(struct igb_adapter *adapter, int tsintr_tt)
>  	struct e1000_hw *hw = &adapter->hw;
>  	struct ptp_clock_event event;
>  	struct timespec64 ts;
> +	unsigned long flags;
>  
>  	if (pin < 0 || pin >= IGB_N_SDP)
>  		return;
> @@ -6954,9 +6955,12 @@ static void igb_extts(struct igb_adapter *adapter, int tsintr_tt)
>  	if (hw->mac.type == e1000_82580 ||
>  	    hw->mac.type == e1000_i354 ||
>  	    hw->mac.type == e1000_i350) {
> -		s64 ns = rd32(auxstmpl);
> +		u64 ns = rd32(auxstmpl);
>  
> -		ns += ((s64)(rd32(auxstmph) & 0xFF)) << 32;
> +		ns += ((u64)(rd32(auxstmph) & 0xFF)) << 32;
> +		spin_lock_irqsave(&adapter->tc, ns);
> +		ns = timecounter_cyc2time(&adapter->tc, ns);
> +		spin_unlock_irqrestore(&adapter->tc, ns);

Hi Yuezhen Luan,

unfortunately this doesn't compile because the arguments to
spin_lock_irqsave/spin_unlock_irqrestore are wrong.

>  		ts = ns_to_timespec64(ns);
>  	} else {
>  		ts.tv_nsec = rd32(auxstmpl);

-- 
pw-bot: cr


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

* Re: [Intel-wired-lan] [PATCH] igb: Fix extts capture value format for 82580/i354/i350
  2023-05-31  9:08 [PATCH] igb: Fix extts capture value format for 82580/i354/i350 Yuezhen Luan
  2023-05-31 22:01 ` Simon Horman
@ 2023-06-01  5:33 ` Paul Menzel
       [not found]   ` <CACMC4jY=c8kBwxRjLL++ro=Zz1O54h5Y6ADU6x+46pgN8XhkpA@mail.gmail.com>
  1 sibling, 1 reply; 5+ messages in thread
From: Paul Menzel @ 2023-06-01  5:33 UTC (permalink / raw)
  To: Yuezhen Luan
  Cc: jesse.brandeburg, anthony.l.nguyen, davem, edumazet, kuba,
	pabeni, netdev, intel-wired-lan, linux-kernel

Dear Yuezhen,


Thank you very much for your patch.

Am 31.05.23 um 11:08 schrieb Yuezhen Luan:
> 82580/i354/i350 features circle-counter-like timestamp registers
> that are different with newer i210. The EXTTS capture value in
> AUXTSMPx should be converted from raw circle counter value to
> timestamp value in resolution of 1 nanosec by the driver.

It’d be great, if you added a paragraph how to reproduce the issue.

> Signed-off-by: Yuezhen Luan <eggcar.luan@gmail.com>
> ---
>   drivers/net/ethernet/intel/igb/igb_main.c | 8 ++++++--
>   1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
> index 58872a4c2..187daa8ef 100644
> --- a/drivers/net/ethernet/intel/igb/igb_main.c
> +++ b/drivers/net/ethernet/intel/igb/igb_main.c
> @@ -6947,6 +6947,7 @@ static void igb_extts(struct igb_adapter *adapter, int tsintr_tt)
>   	struct e1000_hw *hw = &adapter->hw;
>   	struct ptp_clock_event event;
>   	struct timespec64 ts;
> +	unsigned long flags;

I do not see the variable *flags* being used.

>   
>   	if (pin < 0 || pin >= IGB_N_SDP)
>   		return;
> @@ -6954,9 +6955,12 @@ static void igb_extts(struct igb_adapter *adapter, int tsintr_tt)
>   	if (hw->mac.type == e1000_82580 ||
>   	    hw->mac.type == e1000_i354 ||
>   	    hw->mac.type == e1000_i350) {
> -		s64 ns = rd32(auxstmpl);
> +		u64 ns = rd32(auxstmpl);
>   
> -		ns += ((s64)(rd32(auxstmph) & 0xFF)) << 32;
> +		ns += ((u64)(rd32(auxstmph) & 0xFF)) << 32;
> +		spin_lock_irqsave(&adapter->tc, ns);
> +		ns = timecounter_cyc2time(&adapter->tc, ns);
> +		spin_unlock_irqrestore(&adapter->tc, ns);
>   		ts = ns_to_timespec64(ns);
>   	} else {
>   		ts.tv_nsec = rd32(auxstmpl);


Kind regards,

Paul

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

* Re: [Intel-wired-lan] [PATCH] igb: Fix extts capture value format for 82580/i354/i350
       [not found]   ` <CACMC4jY=c8kBwxRjLL++ro=Zz1O54h5Y6ADU6x+46pgN8XhkpA@mail.gmail.com>
@ 2023-06-01  6:14     ` Paul Menzel
  0 siblings, 0 replies; 5+ messages in thread
From: Paul Menzel @ 2023-06-01  6:14 UTC (permalink / raw)
  To: Egg Car
  Cc: jesse.brandeburg, anthony.l.nguyen, davem, edumazet, kuba,
	pabeni, netdev, intel-wired-lan, linux-kernel


Dear Egg,


Thank you for your reply.

Am 01.06.23 um 07:55 schrieb egg car:

>> It’d be great, if you added a paragraph how to reproduce the
>> issue.
> 
> I have tested an i350 NIC with a 1PPS signal input to a SDP pin,
> running 'ts2phc' program from linuxptp project, and found that the
> 1PPS timestamps reading out are raw register value in resolution of
> 1ns and a maximum range of 2^40 ns, thus about 1099 s. It was
> supposed to be in TAI timestamp format.
> 
> Sorry I'm new to kernel development, should I make a new patch to add
> a paragraph in the commit information?

There is no hard rule about it, but I would appreciate it. In the end,
it’s the maintainers’ decision. You can amend the commit, and then 
regenerate the patch with `git format-patch -1 -v2`. Below the --- line 
you can add a short change-log, what you changed between the patch 
iterations.

>> I do not see the variable *flags* being used.
> 
> This patch has a typo, please ignore this one, I have submitted a new one
> that fixed this.

I have not seen this yet.

> I have tested the patch on a Ubuntu server 22.04 machine with kernel 
> version 5.19.17, then I generated the patch in the 'net-queue'
> development repo. I just handwritten the changes in the dev repo,
> made a silly mistake.
> 
> Apolot8ze for that, I'll be more careful next time.
No problem. This has happened to all of us. Congratulations on your 
first(?) Linux kernel contribution. Glad to have you and I am looking 
forward to your next improvements.


Kind regards,

Paul

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

* [PATCH] igb: Fix extts capture value format for 82580/i354/i350
@ 2023-06-01  1:59 Yuezhen Luan
  0 siblings, 0 replies; 5+ messages in thread
From: Yuezhen Luan @ 2023-06-01  1:59 UTC (permalink / raw)
  To: jesse.brandeburg, anthony.l.nguyen, davem, edumazet, kuba, pabeni
  Cc: intel-wired-lan, netdev, linux-kernel, jacob.e.keller, Yuezhen Luan

82580/i354/i350 features circle-counter-like timestamp registers
that are different with newer i210. The EXTTS capture value in
AUXTSMPx should be converted from raw circle counter value to
timestamp value in resolution of 1 nanosec by the driver.

Signed-off-by: Yuezhen Luan <eggcar.luan@gmail.com>
---
 drivers/net/ethernet/intel/igb/igb_main.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index 58872a4c2..bb3db387d 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -6947,6 +6947,7 @@ static void igb_extts(struct igb_adapter *adapter, int tsintr_tt)
 	struct e1000_hw *hw = &adapter->hw;
 	struct ptp_clock_event event;
 	struct timespec64 ts;
+	unsigned long flags;
 
 	if (pin < 0 || pin >= IGB_N_SDP)
 		return;
@@ -6954,9 +6955,12 @@ static void igb_extts(struct igb_adapter *adapter, int tsintr_tt)
 	if (hw->mac.type == e1000_82580 ||
 	    hw->mac.type == e1000_i354 ||
 	    hw->mac.type == e1000_i350) {
-		s64 ns = rd32(auxstmpl);
+		u64 ns = rd32(auxstmpl);
 
-		ns += ((s64)(rd32(auxstmph) & 0xFF)) << 32;
+		ns += ((u64)(rd32(auxstmph) & 0xFF)) << 32;
+		spin_lock_irqsave(&adapter->tmreg_lock, flags);
+		ns = timecounter_cyc2time(&adapter->tc, ns);
+		spin_unlock_irqrestore(&adapter->tmreg_lock, flags);
 		ts = ns_to_timespec64(ns);
 	} else {
 		ts.tv_nsec = rd32(auxstmpl);
-- 
2.34.1


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

end of thread, other threads:[~2023-06-01  6:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-31  9:08 [PATCH] igb: Fix extts capture value format for 82580/i354/i350 Yuezhen Luan
2023-05-31 22:01 ` Simon Horman
2023-06-01  5:33 ` [Intel-wired-lan] " Paul Menzel
     [not found]   ` <CACMC4jY=c8kBwxRjLL++ro=Zz1O54h5Y6ADU6x+46pgN8XhkpA@mail.gmail.com>
2023-06-01  6:14     ` Paul Menzel
2023-06-01  1:59 Yuezhen Luan

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

all inboxes | Powered by JetHome®