linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 net] Add genphy_c45_config_aneg() function to phy-c45.c
@ 2019-08-21 11:00 Marco Hartmann
  2019-08-21 15:37 ` Andrew Lunn
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Marco Hartmann @ 2019-08-21 11:00 UTC (permalink / raw)
  To: andrew, f.fainelli, hkallweit1, davem, netdev, linux-kernel,
	Marco Hartmann, Christian Herber

Commit 34786005eca3 ("net: phy: prevent PHYs w/o Clause 22 regs from calling
genphy_config_aneg") introduced a check that aborts phy_config_aneg()
if the phy is a C45 phy.
This causes phy_state_machine() to call phy_error() so that the phy
ends up in PHY_HALTED state.

Instead of returning -EOPNOTSUPP, call genphy_c45_config_aneg()
(analogous to the C22 case) so that the state machine can run
correctly.

genphy_c45_config_aneg() closely resembles mv3310_config_aneg()
in drivers/net/phy/marvell10g.c, excluding vendor specific
configurations for 1000BaseT.

Fixes: 22b56e827093 ("net: phy: replace genphy_10g_driver with genphy_c45_driver")

Signed-off-by: Marco Hartmann <marco.hartmann@nxp.com>
---
Changes in v2:
- corrected commit message
- reordered variables
---
---
 drivers/net/phy/phy-c45.c | 26 ++++++++++++++++++++++++++
 drivers/net/phy/phy.c     |  2 +-
 include/linux/phy.h       |  1 +
 3 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c
index 58bb25e4af10..7935593debb1 100644
--- a/drivers/net/phy/phy-c45.c
+++ b/drivers/net/phy/phy-c45.c
@@ -523,6 +523,32 @@ int genphy_c45_read_status(struct phy_device *phydev)
 }
 EXPORT_SYMBOL_GPL(genphy_c45_read_status);
 
+/**
+ * genphy_c45_config_aneg - restart auto-negotiation or forced setup
+ * @phydev: target phy_device struct
+ *
+ * Description: If auto-negotiation is enabled, we configure the
+ *   advertising, and then restart auto-negotiation.  If it is not
+ *   enabled, then we force a configuration.
+ */
+int genphy_c45_config_aneg(struct phy_device *phydev)
+{
+	bool changed = false;
+	int ret;
+
+	if (phydev->autoneg == AUTONEG_DISABLE)
+		return genphy_c45_pma_setup_forced(phydev);
+
+	ret = genphy_c45_an_config_aneg(phydev);
+	if (ret < 0)
+		return ret;
+	if (ret > 0)
+		changed = true;
+
+	return genphy_c45_check_and_restart_aneg(phydev, changed);
+}
+EXPORT_SYMBOL_GPL(genphy_c45_config_aneg);
+
 /* The gen10g_* functions are the old Clause 45 stub */
 
 int gen10g_config_aneg(struct phy_device *phydev)
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index f3adea9ef400..74c4e15ebe52 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -507,7 +507,7 @@ static int phy_config_aneg(struct phy_device *phydev)
 	 * allowed to call genphy_config_aneg()
 	 */
 	if (phydev->is_c45 && !(phydev->c45_ids.devices_in_package & BIT(0)))
-		return -EOPNOTSUPP;
+		return genphy_c45_config_aneg(phydev);
 
 	return genphy_config_aneg(phydev);
 }
diff --git a/include/linux/phy.h b/include/linux/phy.h
index d26779f1fb6b..a7ecbe0e55aa 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -1117,6 +1117,7 @@ int genphy_c45_an_disable_aneg(struct phy_device *phydev);
 int genphy_c45_read_mdix(struct phy_device *phydev);
 int genphy_c45_pma_read_abilities(struct phy_device *phydev);
 int genphy_c45_read_status(struct phy_device *phydev);
+int genphy_c45_config_aneg(struct phy_device *phydev);
 
 /* The gen10g_* functions are the old Clause 45 stub */
 int gen10g_config_aneg(struct phy_device *phydev);
-- 
2.7.4


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

* Re: [PATCH v2 net] Add genphy_c45_config_aneg() function to phy-c45.c
  2019-08-21 11:00 [PATCH v2 net] Add genphy_c45_config_aneg() function to phy-c45.c Marco Hartmann
@ 2019-08-21 15:37 ` Andrew Lunn
  2019-08-21 16:55   ` Heiner Kallweit
  2019-08-22 23:15 ` David Miller
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Andrew Lunn @ 2019-08-21 15:37 UTC (permalink / raw)
  To: Marco Hartmann
  Cc: f.fainelli, hkallweit1, davem, netdev, linux-kernel, Christian Herber

On Wed, Aug 21, 2019 at 11:00:46AM +0000, Marco Hartmann wrote:
> Commit 34786005eca3 ("net: phy: prevent PHYs w/o Clause 22 regs from calling
> genphy_config_aneg") introduced a check that aborts phy_config_aneg()
> if the phy is a C45 phy.
> This causes phy_state_machine() to call phy_error() so that the phy
> ends up in PHY_HALTED state.
> 
> Instead of returning -EOPNOTSUPP, call genphy_c45_config_aneg()
> (analogous to the C22 case) so that the state machine can run
> correctly.
> 
> genphy_c45_config_aneg() closely resembles mv3310_config_aneg()
> in drivers/net/phy/marvell10g.c, excluding vendor specific
> configurations for 1000BaseT.

> +/**
> + * genphy_c45_config_aneg - restart auto-negotiation or forced setup
> + * @phydev: target phy_device struct
> + *
> + * Description: If auto-negotiation is enabled, we configure the
> + *   advertising, and then restart auto-negotiation.  If it is not
> + *   enabled, then we force a configuration.
> + */
> +int genphy_c45_config_aneg(struct phy_device *phydev)
> +{
> +	bool changed = false;
> +	int ret;
> +
> +	if (phydev->autoneg == AUTONEG_DISABLE)
> +		return genphy_c45_pma_setup_forced(phydev);
> +
> +	ret = genphy_c45_an_config_aneg(phydev);
> +	if (ret < 0)
> +		return ret;
> +	if (ret > 0)
> +		changed = true;
> +
> +	return genphy_c45_check_and_restart_aneg(phydev, changed);
> +}
> +EXPORT_SYMBOL_GPL(genphy_c45_config_aneg);

The vendor parts for 1000BaseT makes this interesting. Do we expect to
see an C45 PHYs which don't support 1000BaseT? I think that
unlikely. So all C45 PHYs are going to implement their own config_aneg
callback so they can set their vendor registers for 1000BaseT.

> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index f3adea9ef400..74c4e15ebe52 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -507,7 +507,7 @@ static int phy_config_aneg(struct phy_device *phydev)
>  	 * allowed to call genphy_config_aneg()
>  	 */
>  	if (phydev->is_c45 && !(phydev->c45_ids.devices_in_package & BIT(0)))
> -		return -EOPNOTSUPP;
> +		return genphy_c45_config_aneg(phydev);
>  
>  	return genphy_config_aneg(phydev);

So here we should be calling the driver config_aneg function. It can
then call genphy_c45_config_aneg(phydev) to do the generic parts.

Heiner, what do you think?

	Andrew

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

* Re: [PATCH v2 net] Add genphy_c45_config_aneg() function to phy-c45.c
  2019-08-21 15:37 ` Andrew Lunn
@ 2019-08-21 16:55   ` Heiner Kallweit
  0 siblings, 0 replies; 9+ messages in thread
From: Heiner Kallweit @ 2019-08-21 16:55 UTC (permalink / raw)
  To: Andrew Lunn, Marco Hartmann
  Cc: f.fainelli, davem, netdev, linux-kernel, Christian Herber

On 21.08.2019 17:37, Andrew Lunn wrote:
> On Wed, Aug 21, 2019 at 11:00:46AM +0000, Marco Hartmann wrote:
>> Commit 34786005eca3 ("net: phy: prevent PHYs w/o Clause 22 regs from calling
>> genphy_config_aneg") introduced a check that aborts phy_config_aneg()
>> if the phy is a C45 phy.
>> This causes phy_state_machine() to call phy_error() so that the phy
>> ends up in PHY_HALTED state.
>>
>> Instead of returning -EOPNOTSUPP, call genphy_c45_config_aneg()
>> (analogous to the C22 case) so that the state machine can run
>> correctly.
>>
>> genphy_c45_config_aneg() closely resembles mv3310_config_aneg()
>> in drivers/net/phy/marvell10g.c, excluding vendor specific
>> configurations for 1000BaseT.
> 
>> +/**
>> + * genphy_c45_config_aneg - restart auto-negotiation or forced setup
>> + * @phydev: target phy_device struct
>> + *
>> + * Description: If auto-negotiation is enabled, we configure the
>> + *   advertising, and then restart auto-negotiation.  If it is not
>> + *   enabled, then we force a configuration.
>> + */
>> +int genphy_c45_config_aneg(struct phy_device *phydev)
>> +{
>> +	bool changed = false;
>> +	int ret;
>> +
>> +	if (phydev->autoneg == AUTONEG_DISABLE)
>> +		return genphy_c45_pma_setup_forced(phydev);
>> +
>> +	ret = genphy_c45_an_config_aneg(phydev);
>> +	if (ret < 0)
>> +		return ret;
>> +	if (ret > 0)
>> +		changed = true;
>> +
>> +	return genphy_c45_check_and_restart_aneg(phydev, changed);
>> +}
>> +EXPORT_SYMBOL_GPL(genphy_c45_config_aneg);
> 
> The vendor parts for 1000BaseT makes this interesting. Do we expect to
> see an C45 PHYs which don't support 1000BaseT? I think that
> unlikely. So all C45 PHYs are going to implement their own config_aneg
> callback so they can set their vendor registers for 1000BaseT.
> 
>> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
>> index f3adea9ef400..74c4e15ebe52 100644
>> --- a/drivers/net/phy/phy.c
>> +++ b/drivers/net/phy/phy.c
>> @@ -507,7 +507,7 @@ static int phy_config_aneg(struct phy_device *phydev)
>>  	 * allowed to call genphy_config_aneg()
>>  	 */
>>  	if (phydev->is_c45 && !(phydev->c45_ids.devices_in_package & BIT(0)))
>> -		return -EOPNOTSUPP;
>> +		return genphy_c45_config_aneg(phydev);
>>  
>>  	return genphy_config_aneg(phydev);
> 
> So here we should be calling the driver config_aneg function. It can
> then call genphy_c45_config_aneg(phydev) to do the generic parts.
> 
> Heiner, what do you think?
> 
As you say, C45 doesn't cover 1000BaseT, therefore for this mode a
vendor-specific part is needed in the PHY driver always.
That's the reason why genphy_c45_an_config_aneg is meant to be used
within a PHY drivers config_aneg callback implementation, and why
we don't have a generic C45 config_aneg function yet.

Use case for the new function could be cases where 1000BaseT support
isn't needed, and it could serve as a fallback if there's no
dedicated PHY driver yet e.g. for a new chip.

> 	Andrew
> 
Heiner

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

* Re: [PATCH v2 net] Add genphy_c45_config_aneg() function to phy-c45.c
  2019-08-21 11:00 [PATCH v2 net] Add genphy_c45_config_aneg() function to phy-c45.c Marco Hartmann
  2019-08-21 15:37 ` Andrew Lunn
@ 2019-08-22 23:15 ` David Miller
  2019-08-23  6:00   ` Heiner Kallweit
  2019-08-27 22:01 ` David Miller
  2019-08-28  3:20 ` David Miller
  3 siblings, 1 reply; 9+ messages in thread
From: David Miller @ 2019-08-22 23:15 UTC (permalink / raw)
  To: marco.hartmann
  Cc: andrew, f.fainelli, hkallweit1, netdev, linux-kernel, christian.herber

From: Marco Hartmann <marco.hartmann@nxp.com>
Date: Wed, 21 Aug 2019 11:00:46 +0000

> Commit 34786005eca3 ("net: phy: prevent PHYs w/o Clause 22 regs from calling
> genphy_config_aneg") introduced a check that aborts phy_config_aneg()
> if the phy is a C45 phy.
> This causes phy_state_machine() to call phy_error() so that the phy
> ends up in PHY_HALTED state.
> 
> Instead of returning -EOPNOTSUPP, call genphy_c45_config_aneg()
> (analogous to the C22 case) so that the state machine can run
> correctly.
> 
> genphy_c45_config_aneg() closely resembles mv3310_config_aneg()
> in drivers/net/phy/marvell10g.c, excluding vendor specific
> configurations for 1000BaseT.
> 
> Fixes: 22b56e827093 ("net: phy: replace genphy_10g_driver with genphy_c45_driver")
> 
> Signed-off-by: Marco Hartmann <marco.hartmann@nxp.com>

Andrew, Heiner, et al. where are we with this patch?

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

* Re: [PATCH v2 net] Add genphy_c45_config_aneg() function to phy-c45.c
  2019-08-22 23:15 ` David Miller
@ 2019-08-23  6:00   ` Heiner Kallweit
  0 siblings, 0 replies; 9+ messages in thread
From: Heiner Kallweit @ 2019-08-23  6:00 UTC (permalink / raw)
  To: David Miller, marco.hartmann
  Cc: andrew, f.fainelli, netdev, linux-kernel, christian.herber

On 23.08.2019 01:15, David Miller wrote:
> From: Marco Hartmann <marco.hartmann@nxp.com>
> Date: Wed, 21 Aug 2019 11:00:46 +0000
> 
>> Commit 34786005eca3 ("net: phy: prevent PHYs w/o Clause 22 regs from calling
>> genphy_config_aneg") introduced a check that aborts phy_config_aneg()
>> if the phy is a C45 phy.
>> This causes phy_state_machine() to call phy_error() so that the phy
>> ends up in PHY_HALTED state.
>>
>> Instead of returning -EOPNOTSUPP, call genphy_c45_config_aneg()
>> (analogous to the C22 case) so that the state machine can run
>> correctly.
>>
>> genphy_c45_config_aneg() closely resembles mv3310_config_aneg()
>> in drivers/net/phy/marvell10g.c, excluding vendor specific
>> configurations for 1000BaseT.
>>
>> Fixes: 22b56e827093 ("net: phy: replace genphy_10g_driver with genphy_c45_driver")
>>
>> Signed-off-by: Marco Hartmann <marco.hartmann@nxp.com>
> 
> Andrew, Heiner, et al. where are we with this patch?
> 
For me this patch would be ok, even though this generic config_aneg
doesn't support 1000BaseT.
1. The whole genphy_c45 driver doesn't make sense w/o a config_aneg
   callback implementation.
2. It can serve as a temporary fallback for new C45 PHY's that don't
   have a dedicated driver yet.
3. We may have C45 PHYs not supporting 1000BaseT (e.g. T1).

Andrew?

Heiner

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

* Re: [PATCH v2 net] Add genphy_c45_config_aneg() function to phy-c45.c
  2019-08-21 11:00 [PATCH v2 net] Add genphy_c45_config_aneg() function to phy-c45.c Marco Hartmann
  2019-08-21 15:37 ` Andrew Lunn
  2019-08-22 23:15 ` David Miller
@ 2019-08-27 22:01 ` David Miller
  2019-08-27 23:10   ` Andrew Lunn
  2019-08-28  3:20 ` David Miller
  3 siblings, 1 reply; 9+ messages in thread
From: David Miller @ 2019-08-27 22:01 UTC (permalink / raw)
  To: marco.hartmann
  Cc: andrew, f.fainelli, hkallweit1, netdev, linux-kernel, christian.herber

From: Marco Hartmann <marco.hartmann@nxp.com>
Date: Wed, 21 Aug 2019 11:00:46 +0000

> Commit 34786005eca3 ("net: phy: prevent PHYs w/o Clause 22 regs from calling
> genphy_config_aneg") introduced a check that aborts phy_config_aneg()
> if the phy is a C45 phy.
> This causes phy_state_machine() to call phy_error() so that the phy
> ends up in PHY_HALTED state.
> 
> Instead of returning -EOPNOTSUPP, call genphy_c45_config_aneg()
> (analogous to the C22 case) so that the state machine can run
> correctly.
> 
> genphy_c45_config_aneg() closely resembles mv3310_config_aneg()
> in drivers/net/phy/marvell10g.c, excluding vendor specific
> configurations for 1000BaseT.
> 
> Fixes: 22b56e827093 ("net: phy: replace genphy_10g_driver with genphy_c45_driver")
> 
> Signed-off-by: Marco Hartmann <marco.hartmann@nxp.com>

Andrew, gentle ping to respond to Heiner who said:

> For me this patch would be ok, even though this generic config_aneg
> doesn't support 1000BaseT.
> 1. The whole genphy_c45 driver doesn't make sense w/o a config_aneg
>    callback implementation.
> 2. It can serve as a temporary fallback for new C45 PHY's that don't
>    have a dedicated driver yet.
> 3. We may have C45 PHYs not supporting 1000BaseT (e.g. T1).
> 
> Andrew?

Thanks.

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

* Re: [PATCH v2 net] Add genphy_c45_config_aneg() function to phy-c45.c
  2019-08-27 22:01 ` David Miller
@ 2019-08-27 23:10   ` Andrew Lunn
  0 siblings, 0 replies; 9+ messages in thread
From: Andrew Lunn @ 2019-08-27 23:10 UTC (permalink / raw)
  To: David Miller
  Cc: marco.hartmann, f.fainelli, hkallweit1, netdev, linux-kernel,
	christian.herber

On Tue, Aug 27, 2019 at 03:01:03PM -0700, David Miller wrote:
> From: Marco Hartmann <marco.hartmann@nxp.com>
> Date: Wed, 21 Aug 2019 11:00:46 +0000
> 
> > Commit 34786005eca3 ("net: phy: prevent PHYs w/o Clause 22 regs from calling
> > genphy_config_aneg") introduced a check that aborts phy_config_aneg()
> > if the phy is a C45 phy.
> > This causes phy_state_machine() to call phy_error() so that the phy
> > ends up in PHY_HALTED state.
> > 
> > Instead of returning -EOPNOTSUPP, call genphy_c45_config_aneg()
> > (analogous to the C22 case) so that the state machine can run
> > correctly.
> > 
> > genphy_c45_config_aneg() closely resembles mv3310_config_aneg()
> > in drivers/net/phy/marvell10g.c, excluding vendor specific
> > configurations for 1000BaseT.
> > 
> > Fixes: 22b56e827093 ("net: phy: replace genphy_10g_driver with genphy_c45_driver")
> > 
> > Signed-off-by: Marco Hartmann <marco.hartmann@nxp.com>
> 
> Andrew, gentle ping to respond to Heiner who said:

It at least makes it consistent with phy_restart_aneg() and
phy_aneg_done().

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

    Andrew

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

* Re: [PATCH v2 net] Add genphy_c45_config_aneg() function to phy-c45.c
  2019-08-21 11:00 [PATCH v2 net] Add genphy_c45_config_aneg() function to phy-c45.c Marco Hartmann
                   ` (2 preceding siblings ...)
  2019-08-27 22:01 ` David Miller
@ 2019-08-28  3:20 ` David Miller
  2019-08-28  3:22   ` David Miller
  3 siblings, 1 reply; 9+ messages in thread
From: David Miller @ 2019-08-28  3:20 UTC (permalink / raw)
  To: marco.hartmann
  Cc: andrew, f.fainelli, hkallweit1, netdev, linux-kernel, christian.herber

From: Marco Hartmann <marco.hartmann@nxp.com>
Date: Wed, 21 Aug 2019 11:00:46 +0000

> Commit 34786005eca3 ("net: phy: prevent PHYs w/o Clause 22 regs from calling
> genphy_config_aneg") introduced a check that aborts phy_config_aneg()
> if the phy is a C45 phy.
> This causes phy_state_machine() to call phy_error() so that the phy
> ends up in PHY_HALTED state.
> 
> Instead of returning -EOPNOTSUPP, call genphy_c45_config_aneg()
> (analogous to the C22 case) so that the state machine can run
> correctly.
> 
> genphy_c45_config_aneg() closely resembles mv3310_config_aneg()
> in drivers/net/phy/marvell10g.c, excluding vendor specific
> configurations for 1000BaseT.
> 
> Fixes: 22b56e827093 ("net: phy: replace genphy_10g_driver with genphy_c45_driver")
> 
> Signed-off-by: Marco Hartmann <marco.hartmann@nxp.com>
> ---
> Changes in v2:
> - corrected commit message
> - reordered variables

Applied to net-next.

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

* Re: [PATCH v2 net] Add genphy_c45_config_aneg() function to phy-c45.c
  2019-08-28  3:20 ` David Miller
@ 2019-08-28  3:22   ` David Miller
  0 siblings, 0 replies; 9+ messages in thread
From: David Miller @ 2019-08-28  3:22 UTC (permalink / raw)
  To: marco.hartmann
  Cc: andrew, f.fainelli, hkallweit1, netdev, linux-kernel, christian.herber

From: David Miller <davem@davemloft.net>
Date: Tue, 27 Aug 2019 20:20:43 -0700 (PDT)

> Applied to net-next.

My bad, applied to net and queued up for v5.2 -stable.

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

end of thread, other threads:[~2019-08-28  3:22 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-21 11:00 [PATCH v2 net] Add genphy_c45_config_aneg() function to phy-c45.c Marco Hartmann
2019-08-21 15:37 ` Andrew Lunn
2019-08-21 16:55   ` Heiner Kallweit
2019-08-22 23:15 ` David Miller
2019-08-23  6:00   ` Heiner Kallweit
2019-08-27 22:01 ` David Miller
2019-08-27 23:10   ` Andrew Lunn
2019-08-28  3:20 ` David Miller
2019-08-28  3:22   ` David Miller

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