net: phy: broadcom: stub c45 read/write for 54810

Message ID 1691796578-846-1-git-send-email-justin.chen@broadcom.com
State New
Headers
Series net: phy: broadcom: stub c45 read/write for 54810 |

Commit Message

Justin Chen Aug. 11, 2023, 11:29 p.m. UTC
  The 54810 does not support c45. The mmd_phy_indirect accesses return
arbirtary values leading to odd behavior like saying it supports EEE
when it doesn't. We also see that reading/writing these non-existent
MMD registers leads to phy instability in some cases.

Signed-off-by: Justin Chen <justin.chen@broadcom.com>
---
 drivers/net/phy/broadcom.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
  

Comments

Florian Fainelli Aug. 11, 2023, 11:40 p.m. UTC | #1
On 8/11/2023 4:29 PM, Justin Chen wrote:
> The 54810 does not support c45. The mmd_phy_indirect accesses return
> arbirtary values leading to odd behavior like saying it supports EEE
> when it doesn't. We also see that reading/writing these non-existent
> MMD registers leads to phy instability in some cases.
> 
> Signed-off-by: Justin Chen <justin.chen@broadcom.com>

Thanks for submitting this fix, I would be tempted to slap a:

Fixes: b14995ac2527 ("net: phy: broadcom: Add BCM54810 PHY entry")

so we get it back ported to stable trees where appropriate. It is not 
clear whether we should return -EINVAL vs. -EOPNOTSUPP which may more 
clearly indicate the inability to support MMD registers?
  
Justin Chen Aug. 11, 2023, 11:47 p.m. UTC | #2
On Fri, Aug 11, 2023 at 4:40 PM Florian Fainelli
<florian.fainelli@broadcom.com> wrote:
>
>
>
> On 8/11/2023 4:29 PM, Justin Chen wrote:
> > The 54810 does not support c45. The mmd_phy_indirect accesses return
> > arbirtary values leading to odd behavior like saying it supports EEE
> > when it doesn't. We also see that reading/writing these non-existent
> > MMD registers leads to phy instability in some cases.
> >
> > Signed-off-by: Justin Chen <justin.chen@broadcom.com>
>
> Thanks for submitting this fix, I would be tempted to slap a:
>
> Fixes: b14995ac2527 ("net: phy: broadcom: Add BCM54810 PHY entry")
>
> so we get it back ported to stable trees where appropriate. It is not
> clear whether we should return -EINVAL vs. -EOPNOTSUPP which may more
> clearly indicate the inability to support MMD registers?

Hmm agreed EOPNOTSUPP seems better here. Will submit v2 with fixes tag
if there are no objections to this patch.

Thanks,
Justin

> --
> Florian
  
Florian Fainelli Aug. 11, 2023, 11:54 p.m. UTC | #3
On 8/11/2023 4:47 PM, Justin Chen wrote:
> On Fri, Aug 11, 2023 at 4:40 PM Florian Fainelli
> <florian.fainelli@broadcom.com> wrote:
>>
>>
>>
>> On 8/11/2023 4:29 PM, Justin Chen wrote:
>>> The 54810 does not support c45. The mmd_phy_indirect accesses return
>>> arbirtary values leading to odd behavior like saying it supports EEE
>>> when it doesn't. We also see that reading/writing these non-existent
>>> MMD registers leads to phy instability in some cases.
>>>
>>> Signed-off-by: Justin Chen <justin.chen@broadcom.com>
>>
>> Thanks for submitting this fix, I would be tempted to slap a:
>>
>> Fixes: b14995ac2527 ("net: phy: broadcom: Add BCM54810 PHY entry")
>>
>> so we get it back ported to stable trees where appropriate. It is not
>> clear whether we should return -EINVAL vs. -EOPNOTSUPP which may more
>> clearly indicate the inability to support MMD registers?
> 
> Hmm agreed EOPNOTSUPP seems better here. Will submit v2 with fixes tag
> if there are no objections to this patch.

Since this is a fix, you will want to use [PATCH net] as the subject 
prefix per:

https://www.kernel.org/doc/Documentation/networking/netdev-FAQ.txt

and wait 24hrs in case someone provides additional review that you can 
incorporate in your v2.
  
Andrew Lunn Aug. 12, 2023, 2:23 p.m. UTC | #4
> Hmm agreed EOPNOTSUPP seems better here.

I was thinking the same.

  Andrew
  

Patch

diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c
index 59cae0d808aa..8cc39427ce78 100644
--- a/drivers/net/phy/broadcom.c
+++ b/drivers/net/phy/broadcom.c
@@ -542,6 +542,17 @@  static int bcm54xx_resume(struct phy_device *phydev)
 	return bcm54xx_config_init(phydev);
 }
 
+static int bcm54810_read_mmd(struct phy_device *phydev, int devnum, u16 regnum)
+{
+	return -EINVAL;
+}
+
+static int bcm54810_write_mmd(struct phy_device *phydev, int devnum, u16 regnum,
+			      u16 val)
+{
+	return -EINVAL;
+}
+
 static int bcm54811_config_init(struct phy_device *phydev)
 {
 	int err, reg;
@@ -1103,6 +1114,8 @@  static struct phy_driver broadcom_drivers[] = {
 	.get_strings	= bcm_phy_get_strings,
 	.get_stats	= bcm54xx_get_stats,
 	.probe		= bcm54xx_phy_probe,
+	.read_mmd	= bcm54810_read_mmd,
+	.write_mmd	= bcm54810_write_mmd,
 	.config_init    = bcm54xx_config_init,
 	.config_aneg    = bcm5481_config_aneg,
 	.config_intr    = bcm_phy_config_intr,