Skip to contentSkip to conversation

net: phy: Remove TI DP83822 from DP83848 driver

PATCH Superseded Dan Murphy 3 participants 8 messages Oct 4, 2017 – Oct 6, 2017

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Dan Murphy

author
#0 lore raw

PATCH v2 1/3 net: phy: Remove TI DP83822 from DP83848 driver

Removing the DP83822 device from the DP83848 to
support the TI DP83822 dedicated driver that will
initially support WoL settings.

---

v2 - There was no v1 on this patch this is new.

 drivers/net/phy/dp83848.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/net/phy/dp83848.c +0 -3
index 3de4fe4dda77..3966d43c5146 100644
@@ -20,7 +20,6 @@
 #define TI_DP83620_PHY_ID		0x20005ce0
 #define NS_DP83848C_PHY_ID		0x20005c90
 #define TLK10X_PHY_ID			0x2000a210
-#define TI_DP83822_PHY_ID		0x2000a240
 
 /* Registers */
 #define DP83848_MICR			0x11 /* MII Interrupt Control Register */
@@ -80,7 +79,6 @@ static struct mdio_device_id __maybe_unused dp83848_tbl[] = {
 	{ NS_DP83848C_PHY_ID, 0xfffffff0 },
 	{ TI_DP83620_PHY_ID, 0xfffffff0 },
 	{ TLK10X_PHY_ID, 0xfffffff0 },
-	{ TI_DP83822_PHY_ID, 0xfffffff0 },
 	{ }
 };
 MODULE_DEVICE_TABLE(mdio, dp83848_tbl);
@@ -110,7 +108,6 @@ static struct phy_driver dp83848_driver[] = {
 	DP83848_PHY_DRIVER(NS_DP83848C_PHY_ID, "NS DP83848C 10/100 Mbps PHY"),
 	DP83848_PHY_DRIVER(TI_DP83620_PHY_ID, "TI DP83620 10/100 Mbps PHY"),
 	DP83848_PHY_DRIVER(TLK10X_PHY_ID, "TI TLK10X 10/100 Mbps PHY"),
-	DP83848_PHY_DRIVER(TI_DP83822_PHY_ID, "TI DP83822 10/100 Mbps PHY"),
 };
 module_phy_driver(dp83848_driver);
 
Signature · 1 line
2.14.0
author
#1 lore raw

PATCH v2 2/3 net: phy: DP83822 initial driver submission

Add support for the TI DP83822 10/100Mbit ethernet phy.

The DP83822 provides flexibility to connect to a MAC through a standard MII, RMII or RGMII interface.

Datasheet:
http://www.ti.com/product/DP83822I/datasheet

---

v2 - Updated per comments. Removed unnessary parantheis, called genphy_suspend/ resume routines and then performing WoL changes, reworked sopass storage and reduced the number of phy reads, and moved WOL_SECURE_ON -
https://www.mail-archive.com/[email protected]/msg191392.html

 drivers/net/phy/Kconfig   |   5 +
 drivers/net/phy/Makefile  |   1 +
 drivers/net/phy/dp83822.c | 306 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 312 insertions(+)
 create mode 100644 drivers/net/phy/dp83822.c
drivers/net/phy/Kconfig +5 -0
index cd931cf9dcc2..8e78a482e09e 100644
@@ -277,6 +277,11 @@ config DAVICOM_PHY
 	---help---
 	  Currently supports dm9161e and dm9131
 
+config DP83822_PHY
+	tristate "Texas Instruments DP83822 PHY"
+	---help---
+	  Supports the DP83822 PHY.
+
 config DP83848_PHY
 	tristate "Texas Instruments DP83848 PHY"
 	---help---
drivers/net/phy/Makefile +1 -0
index 416df92fbf4f..df3b82ba8550 100644
@@ -55,6 +55,7 @@ obj-$(CONFIG_CICADA_PHY)	+= cicada.o
 obj-$(CONFIG_CORTINA_PHY)	+= cortina.o
 obj-$(CONFIG_DAVICOM_PHY)	+= davicom.o
 obj-$(CONFIG_DP83640_PHY)	+= dp83640.o
+obj-$(CONFIG_DP83822_PHY)	+= dp83822.o
 obj-$(CONFIG_DP83848_PHY)	+= dp83848.o
 obj-$(CONFIG_DP83867_PHY)	+= dp83867.o
 obj-$(CONFIG_FIXED_PHY)		+= fixed_phy.o
drivers/net/phy/dp83822.c new file +306 -0

306 lines not on this page · raw message

Signature · 1 line
2.14.0
#2 lore raw

RE: [PATCH 2/3 v2] net: phy: DP83822 initial driver submission

Review

Quoted 8 lines
drivers/net/phy/dp83822.c new file +6 -0
+static int dp83822_suspend(struct phy_device *phydev)
+{
+	int value;
+
+	mutex_lock(&phydev->lock);
+	value = phy_read_mmd(phydev, DP83822_DEVADDR,

MII_DP83822_WOL_CFG);

(quoted diff) +1 -0
+	mutex_unlock(&phydev->lock);

Would we need mutex to access phy_read_mmd()?
phy_read_mmd() has mdio_lock for indirect access.

Quoted 18 lines
drivers/net/phy/dp83822.c new file +14 -0
+	if (!(value & DP83822_WOL_EN))
+		genphy_suspend(phydev);
+
+	return 0;
+}
+
+static int dp83822_resume(struct phy_device *phydev)
+{
+	int value;
+
+	genphy_resume(phydev);
+
+	mutex_lock(&phydev->lock);
+	value = phy_read_mmd(phydev, DP83822_DEVADDR,

MII_DP83822_WOL_CFG);

(quoted diff) +2 -0
+
+	phy_write_mmd(phydev, DP83822_DEVADDR,

MII_DP83822_WOL_CFG, value |

drivers/net/phy/dp83822.c line 272

Quoted 3 lines
drivers/net/phy/dp83822.c new file +3 -0
+		      DP83822_WOL_CLR_INDICATION);
+
+	mutex_unlock(&phydev->lock);

Same here.

Woojung

maintainer
#3 lore raw

Re: [PATCH 2/3 v2] net: phy: DP83822 initial driver submission

Quoted 11 lines · On Wed, Oct 04, 2017 at 10:44:36PM +0000, [email protected] wrote:

Review

Quoted 8 lines
drivers/net/phy/dp83822.c new file +6 -0
+static int dp83822_suspend(struct phy_device *phydev)
+{
+	int value;
+
+	mutex_lock(&phydev->lock);
+	value = phy_read_mmd(phydev, DP83822_DEVADDR,

MII_DP83822_WOL_CFG);

(quoted diff) +1 -0
+	mutex_unlock(&phydev->lock);

Would we need mutex to access phy_read_mmd()?
phy_read_mmd() has mdio_lock for indirect access.

Hi Woojung

The mdio lock is not sufficient. It protects against two mdio accesses. But here we need to protect against two phy operations. There is a danger something else tries to access the phy during suspend.

Quoted 2 lines

drivers/net/phy/dp83822.c line 255

Quoted 2 lines
drivers/net/phy/dp83822.c new file +2 -0
+	if (!(value & DP83822_WOL_EN))
+		genphy_suspend(phydev);

Releasing the lock before calling genphy_suspend() is not so nice. Maybe add a version which assumes the lock has already been taken?

Andrew

author
#4 lore raw

Re: [PATCH 2/3 v2] net: phy: DP83822 initial driver submission

Andrew

Quoted 20 lines · Andrew Lunn
Quoted 11 lines · On Wed, Oct 04, 2017 at 10:44:36PM +0000, [email protected] wrote:

Review

Quoted 8 lines
drivers/net/phy/dp83822.c new file +6 -0
+static int dp83822_suspend(struct phy_device *phydev)
+{
+	int value;
+
+	mutex_lock(&phydev->lock);
+	value = phy_read_mmd(phydev, DP83822_DEVADDR,

MII_DP83822_WOL_CFG);

(quoted diff) +1 -0
+	mutex_unlock(&phydev->lock);

Would we need mutex to access phy_read_mmd()?
phy_read_mmd() has mdio_lock for indirect access.

Hi Woojung

The mdio lock is not sufficient. It protects against two mdio accesses. But here we need to protect against two phy operations. There is a danger something else tries to access the phy during suspend.

Quoted 6 lines
Quoted 2 lines

drivers/net/phy/dp83822.c line 255

Quoted 2 lines
drivers/net/phy/dp83822.c new file +2 -0
+	if (!(value & DP83822_WOL_EN))
+		genphy_suspend(phydev);

Releasing the lock before calling genphy_suspend() is not so nice. Maybe add a version which assumes the lock has already been taken?

The marvell driver does not take a lock and calls genphy_suspend/resume so I am wondering if this driver needs to take a lock.

The at803x needs to take the lock because it does not call into the genphy functions.

Dan

Quoted 2 lines

Andrew

Signature · 2 lines
------------------
Dan Murphy
#5 lore raw

RE: [PATCH 2/3 v2] net: phy: DP83822 initial driver submission

In reply to Andrew Lunn
Quoted 12 lines
Quoted 11 lines

Review

Quoted 8 lines
drivers/net/phy/dp83822.c new file +6 -0
+static int dp83822_suspend(struct phy_device *phydev)
+{
+	int value;
+
+	mutex_lock(&phydev->lock);
+	value = phy_read_mmd(phydev, DP83822_DEVADDR,

MII_DP83822_WOL_CFG);

(quoted diff) +1 -0
+	mutex_unlock(&phydev->lock);

Would we need mutex to access phy_read_mmd()?
phy_read_mmd() has mdio_lock for indirect access.

Quoted 6 lines

Hi Woojung

The mdio lock is not sufficient. It protects against two mdio accesses. But here we need to protect against two phy operations. There is a danger something else tries to access the phy during suspend.

Hi Andrew,

Thanks for comment. I have question then.
phy_read_mmd() is protected by bus->mdio_lock around mmd_indirect & mdio_read. While these operation, other phy_read() & phy_write() will be blocked inside mdiobus_read() & mdiobus_write().

Because this phy_read_mmd(.., DP83822_DEVADDR, MII_DP83822_WOL_CFG) is not read-modify-write operation, I think phydev->lock may not be necessary.

Am I missing something?

Quoted 6 lines
Quoted 2 lines

drivers/net/phy/dp83822.c line 255

Quoted 2 lines
drivers/net/phy/dp83822.c new file +2 -0
+	if (!(value & DP83822_WOL_EN))
+		genphy_suspend(phydev);

Releasing the lock before calling genphy_suspend() is not so nice. Maybe add a version which assumes the lock has already been taken?

We can expand genphy_suspend() per setting by phy_driver->set_wol. When genphy_suspend() acts per wol setting, not many phy driver needs to extra work When WOL is enabled.
How do you think?

- Woojung

author
#6 lore raw

Re: [PATCH 2/3 v2] net: phy: DP83822 initial driver submission

In reply to Andrew Lunn

Andrew

Quoted 20 lines · Andrew Lunn
Quoted 11 lines · On Wed, Oct 04, 2017 at 10:44:36PM +0000, [email protected] wrote:

Review

Quoted 8 lines
drivers/net/phy/dp83822.c new file +6 -0
+static int dp83822_suspend(struct phy_device *phydev)
+{
+	int value;
+
+	mutex_lock(&phydev->lock);
+	value = phy_read_mmd(phydev, DP83822_DEVADDR,

MII_DP83822_WOL_CFG);

(quoted diff) +1 -0
+	mutex_unlock(&phydev->lock);

Would we need mutex to access phy_read_mmd()?
phy_read_mmd() has mdio_lock for indirect access.

Hi Woojung

The mdio lock is not sufficient. It protects against two mdio accesses. But here we need to protect against two phy operations. There is a danger something else tries to access the phy during suspend.

Quoted 6 lines
Quoted 2 lines

drivers/net/phy/dp83822.c line 255

Quoted 2 lines
drivers/net/phy/dp83822.c new file +2 -0
+	if (!(value & DP83822_WOL_EN))
+		genphy_suspend(phydev);

Releasing the lock before calling genphy_suspend() is not so nice. Maybe add a version which assumes the lock has already been taken?

The marvell driver does not take a lock and calls genphy_suspend/resume so I am wondering if this driver needs to take a lock.

The at803x needs to take the lock because it does not call into the genphy functions.

I will submit a new version with the lock removed.

Dan

Quoted 2 lines

Andrew

Signature · 2 lines
------------------
Dan Murphy
author
#7 lore raw

PATCH v2 3/3 net: phy: Change error to EINVAL for invalid MAC

In reply to Dan Murphy

Change the return error code to EINVAL if the MAC
address is not valid in the set_wol function.

---

v2 - There was no v1 on this patch this is new.

 drivers/net/phy/at803x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/at803x.c +1 -1
index c1e52b9dc58d..5f93e6add563 100644
@@ -167,7 +167,7 @@ static int at803x_set_wol(struct phy_device *phydev,
 		mac = (const u8 *) ndev->dev_addr;
 
 		if (!is_valid_ether_addr(mac))
-			return -EFAULT;
+			return -EINVAL;
 
 		for (i = 0; i < 3; i++) {
 			phy_write(phydev, AT803X_MMD_ACCESS_CONTROL,
Signature · 1 line
2.14.0