netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] net: phy: Add general dummy stubs for MMD register access
@ 2018-03-20  1:44 Kevin Hao
  2018-03-20  1:44 ` [PATCH v2 1/3] " Kevin Hao
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Kevin Hao @ 2018-03-20  1:44 UTC (permalink / raw)
  To: netdev; +Cc: Andrew Lunn, Florian Fainelli, Claudiu Manoil

v2:
As suggested by Andrew:
  - Add general dummy stubs
  - Also use that for the micrel phy

This patch series fix the Ethernet broken on the mpc8315erdb board introduced
by commit b6b5e8a69118 ("gianfar: Disable EEE autoneg by default").

Kevin Hao (3):
  net: phy: Add general dummy stubs for MMD register access
  net: phy: realtek: Use the dummy stubs for MMD register access for
    rtl8211b
  net: phy: micrel: Use the general dummy stubs for MMD register access

 drivers/net/phy/micrel.c     | 23 ++---------------------
 drivers/net/phy/phy_device.c | 17 +++++++++++++++++
 drivers/net/phy/realtek.c    |  2 ++
 include/linux/phy.h          |  4 ++++
 4 files changed, 25 insertions(+), 21 deletions(-)

-- 
2.9.3

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

* [PATCH v2 1/3] net: phy: Add general dummy stubs for MMD register access
  2018-03-20  1:44 [PATCH v2 0/3] net: phy: Add general dummy stubs for MMD register access Kevin Hao
@ 2018-03-20  1:44 ` Kevin Hao
  2018-03-20  1:44 ` [PATCH v2 2/3] net: phy: realtek: Use the dummy stubs for MMD register access for rtl8211b Kevin Hao
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Kevin Hao @ 2018-03-20  1:44 UTC (permalink / raw)
  To: netdev; +Cc: Andrew Lunn, Florian Fainelli, Claudiu Manoil, Kevin Hao

For some phy devices, even though they don't support the MMD extended
register access, it does have some side effect if we are trying to
read/write the MMD registers via indirect method. So introduce general
dummy stubs for MMD register access which these devices can use to avoid
such side effect.

Fixes: b6b5e8a69118 ("gianfar: Disable EEE autoneg by default")
Signed-off-by: Kevin Hao <haokexin@gmail.com>
---
 drivers/net/phy/phy_device.c | 17 +++++++++++++++++
 include/linux/phy.h          |  4 ++++
 2 files changed, 21 insertions(+)

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index b285323327c4..b070f8fd66fe 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -1666,6 +1666,23 @@ int genphy_config_init(struct phy_device *phydev)
 }
 EXPORT_SYMBOL(genphy_config_init);
 
+/* This is used for the phy device which doesn't support the MMD extended
+ * register access, but it does have side effect when we are trying to access
+ * the MMD register via indirect method.
+ */
+int genphy_read_mmd_unsupported(struct phy_device *phdev, int devad, u16 regnum)
+{
+	return -EOPNOTSUPP;
+}
+EXPORT_SYMBOL(genphy_read_mmd_unsupported);
+
+int genphy_write_mmd_unsupported(struct phy_device *phdev, int devnum,
+				 u16 regnum, u16 val)
+{
+	return -EOPNOTSUPP;
+}
+EXPORT_SYMBOL(genphy_write_mmd_unsupported);
+
 int genphy_suspend(struct phy_device *phydev)
 {
 	return phy_set_bits(phydev, MII_BMCR, BMCR_PDOWN);
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 68127b002c3d..f0b5870a6d40 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -984,6 +984,10 @@ static inline int genphy_no_soft_reset(struct phy_device *phydev)
 {
 	return 0;
 }
+int genphy_read_mmd_unsupported(struct phy_device *phdev, int devad,
+				u16 regnum);
+int genphy_write_mmd_unsupported(struct phy_device *phdev, int devnum,
+				 u16 regnum, u16 val);
 
 /* Clause 45 PHY */
 int genphy_c45_restart_aneg(struct phy_device *phydev);
-- 
2.9.3

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

* [PATCH v2 2/3] net: phy: realtek: Use the dummy stubs for MMD register access for rtl8211b
  2018-03-20  1:44 [PATCH v2 0/3] net: phy: Add general dummy stubs for MMD register access Kevin Hao
  2018-03-20  1:44 ` [PATCH v2 1/3] " Kevin Hao
@ 2018-03-20  1:44 ` Kevin Hao
  2018-03-20  1:44 ` [PATCH v2 3/3] net: phy: micrel: Use the general dummy stubs for MMD register access Kevin Hao
  2018-03-22 15:43 ` [PATCH v2 0/3] net: phy: Add " David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Kevin Hao @ 2018-03-20  1:44 UTC (permalink / raw)
  To: netdev; +Cc: Andrew Lunn, Florian Fainelli, Claudiu Manoil, Kevin Hao

The Ethernet on mpc8315erdb is broken since commit b6b5e8a69118
("gianfar: Disable EEE autoneg by default"). The reason is that
even though the rtl8211b doesn't support the MMD extended registers
access, it does return some random values if we trying to access
the MMD register via indirect method. This makes it seem that the
EEE is supported by this phy device. And the subsequent writing to
the MMD registers does cause the phy malfunction. So use the dummy
stubs for the MMD register access to fix this issue.

Fixes: b6b5e8a69118 ("gianfar: Disable EEE autoneg by default")
Signed-off-by: Kevin Hao <haokexin@gmail.com>
---
 drivers/net/phy/realtek.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
index ee3ca4a2f12b..9f48ecf9c627 100644
--- a/drivers/net/phy/realtek.c
+++ b/drivers/net/phy/realtek.c
@@ -172,6 +172,8 @@ static struct phy_driver realtek_drvs[] = {
 		.flags		= PHY_HAS_INTERRUPT,
 		.ack_interrupt	= &rtl821x_ack_interrupt,
 		.config_intr	= &rtl8211b_config_intr,
+		.read_mmd	= &genphy_read_mmd_unsupported,
+		.write_mmd	= &genphy_write_mmd_unsupported,
 	}, {
 		.phy_id		= 0x001cc914,
 		.name		= "RTL8211DN Gigabit Ethernet",
-- 
2.9.3

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

* [PATCH v2 3/3] net: phy: micrel: Use the general dummy stubs for MMD register access
  2018-03-20  1:44 [PATCH v2 0/3] net: phy: Add general dummy stubs for MMD register access Kevin Hao
  2018-03-20  1:44 ` [PATCH v2 1/3] " Kevin Hao
  2018-03-20  1:44 ` [PATCH v2 2/3] net: phy: realtek: Use the dummy stubs for MMD register access for rtl8211b Kevin Hao
@ 2018-03-20  1:44 ` Kevin Hao
  2018-03-22 15:43 ` [PATCH v2 0/3] net: phy: Add " David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Kevin Hao @ 2018-03-20  1:44 UTC (permalink / raw)
  To: netdev; +Cc: Andrew Lunn, Florian Fainelli, Claudiu Manoil, Kevin Hao

The new general dummy stubs for MMD register access were introduced.
Use that for the codes reuse.

Signed-off-by: Kevin Hao <haokexin@gmail.com>
---
 drivers/net/phy/micrel.c | 23 ++---------------------
 1 file changed, 2 insertions(+), 21 deletions(-)

diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 49be85afbea9..f41b224a9cdb 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -635,25 +635,6 @@ static int ksz8873mll_config_aneg(struct phy_device *phydev)
 	return 0;
 }
 
-/* This routine returns -1 as an indication to the caller that the
- * Micrel ksz9021 10/100/1000 PHY does not support standard IEEE
- * MMD extended PHY registers.
- */
-static int
-ksz9021_rd_mmd_phyreg(struct phy_device *phydev, int devad, u16 regnum)
-{
-	return -1;
-}
-
-/* This routine does nothing since the Micrel ksz9021 does not support
- * standard IEEE MMD extended PHY registers.
- */
-static int
-ksz9021_wr_mmd_phyreg(struct phy_device *phydev, int devad, u16 regnum, u16 val)
-{
-	return -1;
-}
-
 static int kszphy_get_sset_count(struct phy_device *phydev)
 {
 	return ARRAY_SIZE(kszphy_hw_stats);
@@ -946,8 +927,8 @@ static struct phy_driver ksphy_driver[] = {
 	.get_stats	= kszphy_get_stats,
 	.suspend	= genphy_suspend,
 	.resume		= genphy_resume,
-	.read_mmd	= ksz9021_rd_mmd_phyreg,
-	.write_mmd	= ksz9021_wr_mmd_phyreg,
+	.read_mmd	= genphy_read_mmd_unsupported,
+	.write_mmd	= genphy_write_mmd_unsupported,
 }, {
 	.phy_id		= PHY_ID_KSZ9031,
 	.phy_id_mask	= MICREL_PHY_ID_MASK,
-- 
2.9.3

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

* Re: [PATCH v2 0/3] net: phy: Add general dummy stubs for MMD register access
  2018-03-20  1:44 [PATCH v2 0/3] net: phy: Add general dummy stubs for MMD register access Kevin Hao
                   ` (2 preceding siblings ...)
  2018-03-20  1:44 ` [PATCH v2 3/3] net: phy: micrel: Use the general dummy stubs for MMD register access Kevin Hao
@ 2018-03-22 15:43 ` David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2018-03-22 15:43 UTC (permalink / raw)
  To: haokexin; +Cc: netdev, andrew, f.fainelli, claudiu.manoil

From: Kevin Hao <haokexin@gmail.com>
Date: Tue, 20 Mar 2018 09:44:51 +0800

> v2:
> As suggested by Andrew:
>   - Add general dummy stubs
>   - Also use that for the micrel phy
> 
> This patch series fix the Ethernet broken on the mpc8315erdb board introduced
> by commit b6b5e8a69118 ("gianfar: Disable EEE autoneg by default").

Series applied, thank you.

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

end of thread, other threads:[~2018-03-22 15:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-20  1:44 [PATCH v2 0/3] net: phy: Add general dummy stubs for MMD register access Kevin Hao
2018-03-20  1:44 ` [PATCH v2 1/3] " Kevin Hao
2018-03-20  1:44 ` [PATCH v2 2/3] net: phy: realtek: Use the dummy stubs for MMD register access for rtl8211b Kevin Hao
2018-03-20  1:44 ` [PATCH v2 3/3] net: phy: micrel: Use the general dummy stubs for MMD register access Kevin Hao
2018-03-22 15:43 ` [PATCH v2 0/3] net: phy: Add " 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).