2020-12-23 18:58:52

by Charles Keepax

[permalink] [raw]
Subject: [PATCH] net: macb: Correct usage of MACB_CAPS_CLK_HW_CHG flag on Zynq

A new flag MACB_CAPS_CLK_HW_CHG was added and all callers of
macb_set_tx_clk were gated on the presence of this flag.

if (!bp->tx_clk || !(bp->caps & MACB_CAPS_CLK_HW_CHG))

However the flag was not added to anything other than the new
sama7g5_gem, turning that function call into a no op for all other
systems. This breaks the networking on Zynq.

This patch adds that flag to Zynq config, it is probably needed on other
systems as well but it is hard to know that without having access to
those systems, so I guess we just have to wait to see who else spots
breakage here.

Fixes: daafa1d33cc9 ("net: macb: add capability to not set the clock rate")
Signed-off-by: Charles Keepax <[email protected]>
---
drivers/net/ethernet/cadence/macb_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index d5d910916c2e8..590116b236ef7 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -4536,7 +4536,7 @@ static const struct macb_config zynqmp_config = {

static const struct macb_config zynq_config = {
.caps = MACB_CAPS_GIGABIT_MODE_AVAILABLE | MACB_CAPS_NO_GIGABIT_HALF |
- MACB_CAPS_NEEDS_RSTONUBR,
+ MACB_CAPS_NEEDS_RSTONUBR | MACB_CAPS_CLK_HW_CHG,
.dma_burst_length = 16,
.clk_init = macb_clk_init,
.init = macb_init,
--
2.11.0


2020-12-23 19:28:31

by Andrew Lunn

[permalink] [raw]
Subject: Re: [PATCH] net: macb: Correct usage of MACB_CAPS_CLK_HW_CHG flag on Zynq

On Wed, Dec 23, 2020 at 06:41:44PM +0000, Charles Keepax wrote:
> A new flag MACB_CAPS_CLK_HW_CHG was added and all callers of
> macb_set_tx_clk were gated on the presence of this flag.
>
> if (!bp->tx_clk || !(bp->caps & MACB_CAPS_CLK_HW_CHG))
>
> However the flag was not added to anything other than the new
> sama7g5_gem, turning that function call into a no op for all other
> systems. This breaks the networking on Zynq.

I'm not sure this is the correct fix. I think the original patch might
be broken. Look at the commit message wording:

The patch adds a new
capability so that macb_set_tx_clock() to not be called for IPs having
this capability

So MACB_CAPS_CLK_HW_CHG disables something, not enables it. So i
suspect this if statement is wrong and needs fixing.

Andrew

2020-12-23 19:43:46

by Charles Keepax

[permalink] [raw]
Subject: Re: [PATCH] net: macb: Correct usage of MACB_CAPS_CLK_HW_CHG flag on Zynq

On Wed, Dec 23, 2020 at 08:24:41PM +0100, Andrew Lunn wrote:
> On Wed, Dec 23, 2020 at 06:41:44PM +0000, Charles Keepax wrote:
> > A new flag MACB_CAPS_CLK_HW_CHG was added and all callers of
> > macb_set_tx_clk were gated on the presence of this flag.
> >
> > if (!bp->tx_clk || !(bp->caps & MACB_CAPS_CLK_HW_CHG))
> >
> > However the flag was not added to anything other than the new
> > sama7g5_gem, turning that function call into a no op for all other
> > systems. This breaks the networking on Zynq.
>
> I'm not sure this is the correct fix. I think the original patch might
> be broken. Look at the commit message wording:
>
> The patch adds a new
> capability so that macb_set_tx_clock() to not be called for IPs having
> this capability
>
> So MACB_CAPS_CLK_HW_CHG disables something, not enables it. So i
> suspect this if statement is wrong and needs fixing.

Hmm... good spot, hopefully the original author can comment. The
flag name reads to me as clock rate can change, the commit message
definitely implies the opposite.

So it really depends if this function was intended to be skipped
for the sama7g5 gem or emac.

Thanks,
Charles