netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH resubmit 2] net: fec: Fix FEC_ECR_EN1588 being cleared on link-down
@ 2024-06-11  8:04 Csókás, Bence
  2024-06-12 19:16 ` Andrew Lunn
  2024-06-13 15:12 ` Jakub Kicinski
  0 siblings, 2 replies; 5+ messages in thread
From: Csókás, Bence @ 2024-06-11  8:04 UTC (permalink / raw)
  To: Frank Li, David S. Miller, imx, netdev, linux-kernel
  Cc: Csókás, Bence, Richard Cochran, Wei Fang, Shenwei Wang,
	Clark Wang, Eric Dumazet, Jakub Kicinski, Paolo Abeni

FEC_ECR_EN1588 bit gets cleared after MAC reset in `fec_stop()`, which
makes all 1588 functionality shut down, and all the extended registers
disappear, on link-down, making the adapter fall back to compatibility
"dumb mode". However, some functionality needs to be retained (e.g. PPS)
even without link.

Fixes: 6605b730c061 ("FEC: Add time stamping code and a PTP hardware clock")
Cc: Richard Cochran <richardcochran@gmail.com>

Signed-off-by: Csókás, Bence <csokas.bence@prolan.hu>
---
 drivers/net/ethernet/freescale/fec_main.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 881ece735dcf..fb19295529a2 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -1361,6 +1361,12 @@ fec_stop(struct net_device *ndev)
 		writel(FEC_ECR_ETHEREN, fep->hwp + FEC_ECNTRL);
 		writel(rmii_mode, fep->hwp + FEC_R_CNTRL);
 	}
+
+	if (fep->bufdesc_ex) {
+		val = readl(fep->hwp + FEC_ECNTRL);
+		val |= FEC_ECR_EN1588;
+		writel(val, fep->hwp + FEC_ECNTRL);
+	}
 }
 
 static void
-- 
2.34.1



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

* Re: [PATCH resubmit 2] net: fec: Fix FEC_ECR_EN1588 being cleared on link-down
  2024-06-11  8:04 [PATCH resubmit 2] net: fec: Fix FEC_ECR_EN1588 being cleared on link-down Csókás, Bence
@ 2024-06-12 19:16 ` Andrew Lunn
  2024-06-13 15:12 ` Jakub Kicinski
  1 sibling, 0 replies; 5+ messages in thread
From: Andrew Lunn @ 2024-06-12 19:16 UTC (permalink / raw)
  To: Csókás, Bence
  Cc: Frank Li, David S. Miller, imx, netdev, linux-kernel,
	Richard Cochran, Wei Fang, Shenwei Wang, Clark Wang, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni

On Tue, Jun 11, 2024 at 10:04:05AM +0200, Csókás, Bence wrote:
> FEC_ECR_EN1588 bit gets cleared after MAC reset in `fec_stop()`, which
> makes all 1588 functionality shut down, and all the extended registers
> disappear, on link-down, making the adapter fall back to compatibility
> "dumb mode". However, some functionality needs to be retained (e.g. PPS)
> even without link.
> 
> Fixes: 6605b730c061 ("FEC: Add time stamping code and a PTP hardware clock")
> Cc: Richard Cochran <richardcochran@gmail.com>
> 
> Signed-off-by: Csókás, Bence <csokas.bence@prolan.hu>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH resubmit 2] net: fec: Fix FEC_ECR_EN1588 being cleared on link-down
  2024-06-11  8:04 [PATCH resubmit 2] net: fec: Fix FEC_ECR_EN1588 being cleared on link-down Csókás, Bence
  2024-06-12 19:16 ` Andrew Lunn
@ 2024-06-13 15:12 ` Jakub Kicinski
  2024-06-14  7:59   ` Csókás Bence
  1 sibling, 1 reply; 5+ messages in thread
From: Jakub Kicinski @ 2024-06-13 15:12 UTC (permalink / raw)
  To: Csókás, Bence
  Cc: Frank Li, David S. Miller, imx, netdev, linux-kernel,
	Richard Cochran, Wei Fang, Shenwei Wang, Clark Wang, Eric Dumazet,
	Paolo Abeni

On Tue, 11 Jun 2024 10:04:05 +0200 Csókás, Bence wrote:
> +	if (fep->bufdesc_ex) {
> +		val = readl(fep->hwp + FEC_ECNTRL);
> +		val |= FEC_ECR_EN1588;
> +		writel(val, fep->hwp + FEC_ECNTRL);

FEC_ECNTRL gets written multiple times in this function,
including with 0, and then you RMW it to add this flag.

Is this intentional? It really seems like you should be
adding this flag more consistently or making sure its
not cleared, rather than appending "add it back" at the 
end of the function...
-- 
pw-bot: cr

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

* Re: [PATCH resubmit 2] net: fec: Fix FEC_ECR_EN1588 being cleared on link-down
  2024-06-13 15:12 ` Jakub Kicinski
@ 2024-06-14  7:59   ` Csókás Bence
  2024-06-15  1:27     ` Jakub Kicinski
  0 siblings, 1 reply; 5+ messages in thread
From: Csókás Bence @ 2024-06-14  7:59 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Frank Li, David S. Miller, imx, netdev, linux-kernel,
	Richard Cochran, Wei Fang, Shenwei Wang, Clark Wang, Eric Dumazet,
	Paolo Abeni

On 6/13/24 17:12, Jakub Kicinski wrote:
> On Tue, 11 Jun 2024 10:04:05 +0200 Csókás, Bence wrote:
>> +	if (fep->bufdesc_ex) {
>> +		val = readl(fep->hwp + FEC_ECNTRL);
>> +		val |= FEC_ECR_EN1588;
>> +		writel(val, fep->hwp + FEC_ECNTRL);
> 
> FEC_ECNTRL gets written multiple times in this function,
> including with 0, and then you RMW it to add this flag.
> 
> Is this intentional? It really seems like you should be
> adding this flag more consistently or making sure its
> not cleared, rather than appending "add it back" at the
> end of the function...

It only writes 0 if WOL is disabled AND the device has the MULTI_QUEUES 
quirk. Otherwise, we either write FEC_ECR_RESET, which resets the device 
(and the HW changes ECNTRL to its reset value), OR we RMW set the WOL 
sleep bits. And then, if some more quirks are set, we set ETHEREN.

So I think RMW is the safest route here, instead of trying to keep track 
of all these different branches, re-read ECNTRL after reset etc.

Bence


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

* Re: [PATCH resubmit 2] net: fec: Fix FEC_ECR_EN1588 being cleared on link-down
  2024-06-14  7:59   ` Csókás Bence
@ 2024-06-15  1:27     ` Jakub Kicinski
  0 siblings, 0 replies; 5+ messages in thread
From: Jakub Kicinski @ 2024-06-15  1:27 UTC (permalink / raw)
  To: Csókás Bence
  Cc: Frank Li, David S. Miller, imx, netdev, linux-kernel,
	Richard Cochran, Wei Fang, Shenwei Wang, Clark Wang, Eric Dumazet,
	Paolo Abeni

On Fri, 14 Jun 2024 09:59:16 +0200 Csókás Bence wrote:
> It only writes 0 if WOL is disabled AND the device has the MULTI_QUEUES 
> quirk. Otherwise, we either write FEC_ECR_RESET, which resets the device 
> (and the HW changes ECNTRL to its reset value), OR we RMW set the WOL 
> sleep bits. And then, if some more quirks are set, we set ETHEREN.
> 
> So I think RMW is the safest route here, instead of trying to keep track 
> of all these different branches, re-read ECNTRL after reset etc.

Okay, just resend without the empty line between tags then.

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

end of thread, other threads:[~2024-06-15  1:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-11  8:04 [PATCH resubmit 2] net: fec: Fix FEC_ECR_EN1588 being cleared on link-down Csókás, Bence
2024-06-12 19:16 ` Andrew Lunn
2024-06-13 15:12 ` Jakub Kicinski
2024-06-14  7:59   ` Csókás Bence
2024-06-15  1:27     ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).