All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: phy: improve setting advertised modes in phy_probe
@ 2019-04-28 13:03 Heiner Kallweit
  2019-04-28 17:04 ` Andrew Lunn
  0 siblings, 1 reply; 4+ messages in thread
From: Heiner Kallweit @ 2019-04-28 13:03 UTC (permalink / raw)
  To: Andrew Lunn, Florian Fainelli, David Miller; +Cc: netdev

So far we set the advertising bitmap before setting the pause flags
in the supported bitmap. This may cause pause not being advertised.
At least r8169 driver works around this by copying supported ->
advertising on its own. The linkmode bitmaps have been introduced only
recently, therefore the patch wouldn't apply to older versions.
And behavior has been like this for years, therefore I'd consider it
an improvement.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/phy/phy_device.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 2a2aaa5f3..c56897db2 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -2177,7 +2177,6 @@ static int phy_probe(struct device *dev)
 		phydev->is_gigabit_capable = 1;
 
 	of_set_phy_supported(phydev);
-	linkmode_copy(phydev->advertising, phydev->supported);
 
 	/* Get the EEE modes we want to prohibit. We will ask
 	 * the PHY stop advertising these mode later on
@@ -2203,6 +2202,8 @@ static int phy_probe(struct device *dev)
 				 phydev->supported);
 	}
 
+	linkmode_copy(phydev->advertising, phydev->supported);
+
 	/* Set the state to READY by default */
 	phydev->state = PHY_READY;
 
-- 
2.21.0


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

* Re: [PATCH net-next] net: phy: improve setting advertised modes in phy_probe
  2019-04-28 13:03 [PATCH net-next] net: phy: improve setting advertised modes in phy_probe Heiner Kallweit
@ 2019-04-28 17:04 ` Andrew Lunn
  2019-04-28 18:10   ` Heiner Kallweit
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Lunn @ 2019-04-28 17:04 UTC (permalink / raw)
  To: Heiner Kallweit; +Cc: Florian Fainelli, David Miller, netdev

On Sun, Apr 28, 2019 at 03:03:37PM +0200, Heiner Kallweit wrote:
> So far we set the advertising bitmap before setting the pause flags
> in the supported bitmap. This may cause pause not being advertised.

Hi Heiner

Pause requires that the PHY can advertise the pause bits, and that the
MAC supports pause. So by default, we don't advertise pause. The MAC
needs to say it supports pause, by calling one of

void phy_support_sym_pause(struct phy_device *phydev);
void phy_support_asym_pause(struct phy_device *phydev);

These two then copy supported into advertising.

      Andrew

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

* Re: [PATCH net-next] net: phy: improve setting advertised modes in phy_probe
  2019-04-28 17:04 ` Andrew Lunn
@ 2019-04-28 18:10   ` Heiner Kallweit
  2019-04-28 21:21     ` Andrew Lunn
  0 siblings, 1 reply; 4+ messages in thread
From: Heiner Kallweit @ 2019-04-28 18:10 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: Florian Fainelli, David Miller, netdev

On 28.04.2019 19:04, Andrew Lunn wrote:
> On Sun, Apr 28, 2019 at 03:03:37PM +0200, Heiner Kallweit wrote:
>> So far we set the advertising bitmap before setting the pause flags
>> in the supported bitmap. This may cause pause not being advertised.
> 
> Hi Heiner
> 
> Pause requires that the PHY can advertise the pause bits, and that the
> MAC supports pause. So by default, we don't advertise pause. The MAC
> needs to say it supports pause, by calling one of
> 
> void phy_support_sym_pause(struct phy_device *phydev);
> void phy_support_asym_pause(struct phy_device *phydev);
> 
> These two then copy supported into advertising.
> 
Right, missed that. After checking the code a little bit more I think
we still may have few issues with pause settings.

1.
We have functions that copy supported -> advertising, e.g.
phy_set_max_speed(). If such a function is called pause gets advertised
even w/o the MAC calling one of the two functions.

2.
We have PHY's (e.g. KSZ9031) that support sym pause only due to a hw
erratum. If the MAC now calls phy_support_asym_pause() it sets the
asym pause flag in phydev->supported even though the PHY intentionally
disabled it. That's not nice ..

Maybe we should do it differently:
Apply my patch, then both pause modes are initially advertised.
(This also avoids point 3 below)
- remove phy_support_asym_pause()
- phy_support_sym_pause() clears the asym pause bit and doesn't touch
  sym pause bit.
- and we may need something like phy_support_no_pause().

3.
What's with all the existing drivers where the MAC supports pause but
drivers call neither of the two functions?

4.
Calling either of the two functions will be effective after an autoneg
restart only. Do we have to consider this?

>       Andrew
> 
Heiner

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

* Re: [PATCH net-next] net: phy: improve setting advertised modes in phy_probe
  2019-04-28 18:10   ` Heiner Kallweit
@ 2019-04-28 21:21     ` Andrew Lunn
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2019-04-28 21:21 UTC (permalink / raw)
  To: Heiner Kallweit; +Cc: Florian Fainelli, David Miller, netdev

On Sun, Apr 28, 2019 at 08:10:43PM +0200, Heiner Kallweit wrote:
> On 28.04.2019 19:04, Andrew Lunn wrote:
> > On Sun, Apr 28, 2019 at 03:03:37PM +0200, Heiner Kallweit wrote:
> >> So far we set the advertising bitmap before setting the pause flags
> >> in the supported bitmap. This may cause pause not being advertised.
> > 
> > Hi Heiner
> > 
> > Pause requires that the PHY can advertise the pause bits, and that the
> > MAC supports pause. So by default, we don't advertise pause. The MAC
> > needs to say it supports pause, by calling one of
> > 
> > void phy_support_sym_pause(struct phy_device *phydev);
> > void phy_support_asym_pause(struct phy_device *phydev);
> > 
> > These two then copy supported into advertising.
> > 
> Right, missed that. After checking the code a little bit more I think
> we still may have few issues with pause settings.

Hi Heiner

I agree the current state could be improved. We just have to be
careful how we do it. We don't want to introduce regressions. There
are a lot of MAC drivers we have no idea if they support pause or not.
We do get some clues from .set_pauseparam.


> 1.
> We have functions that copy supported -> advertising, e.g.
> phy_set_max_speed(). If such a function is called pause gets advertised
> even w/o the MAC calling one of the two functions.

Yes. I'm not sure supported is the best place to keep this information
about what the PHY can do about pause, because off issues like
this. You also see such copies in a few MAC drivers. So we might want
to move PHY pause capability it into new bits in phydev.

> 2.
> We have PHY's (e.g. KSZ9031) that support sym pause only due to a hw
> erratum. If the MAC now calls phy_support_asym_pause() it sets the
> asym pause flag in phydev->supported even though the PHY intentionally
> disabled it. That's not nice ..

Yes, some validation would be good.
 
> Maybe we should do it differently:
> Apply my patch, then both pause modes are initially advertised.
> (This also avoids point 3 below)
> - remove phy_support_asym_pause()
> - phy_support_sym_pause() clears the asym pause bit and doesn't touch
>   sym pause bit.
> - and we may need something like phy_support_no_pause().

I would prefer to keep with the assumption that the MAC does not
support pause until it tells us it does.
 
> 3.
> What's with all the existing drivers where the MAC supports pause but
> drivers call neither of the two functions?

Apart from .set_pauseparams, we have no way to identify them.

> 4.
> Calling either of the two functions will be effective after an autoneg
> restart only. Do we have to consider this?

The code i've seen does this before calling phy_start(). So i don't
think it is an issue. But we could add in code to see if the phy has
been started, and if so, restart autoneg.

     Andrew

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

end of thread, other threads:[~2019-04-28 21:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-28 13:03 [PATCH net-next] net: phy: improve setting advertised modes in phy_probe Heiner Kallweit
2019-04-28 17:04 ` Andrew Lunn
2019-04-28 18:10   ` Heiner Kallweit
2019-04-28 21:21     ` Andrew Lunn

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.