Skip to contentSkip to conversation

net: davinci_emac: fix suspend/resume (both a regression and a common clk problem)

PATCH In review Bartosz Golaszewski 2 participants 4 messages Jun 20, 2018 – Jun 21, 2018

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover net: davinci_emac: fix suspend/resume (both a regression and a common clk problem)

From: Bartosz Golaszewski <[email protected]>

Earlier I sent the first patch as a solution to a regression introduced during the v4.16 merge window, but after testing David's common clock series on top of 4.18-rc1 + this patch it turned out that the problem persisted.

This is a follow-up containing the regression fix and an additional patche that makes suspend/resume work with David's changes.

v1 -> v2:
- dropped patch 2/3
- in patch 2/2: check the device's parent's compatible

Bartosz Golaszewski (2):
net: ethernet: fix suspend/resume in davinci_emac
net: davinci_emac: match the mdio device against its compatible if
possible

 drivers/net/ethernet/ti/davinci_emac.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 1/2 net: ethernet: fix suspend/resume in davinci_emac

From: Bartosz Golaszewski <[email protected]>

This patch reverts commit 3243ff2a05ec ("net: ethernet: davinci_emac:
Deduplicate bus_find_device() by name matching") and adds a comment which should stop anyone from reintroducing the same "fix" in the future.

We can't use bus_find_device_by_name() here because the device name is not guaranteed to be 'davinci_mdio'. On some systems it can be 'davinci_mdio.0' so we need to use strncmp() against the first part of the string to correctly match it.

Fixes 3243ff2a05ec ("net: ethernet: davinci_emac: Deduplicate bus_find_device() by name matching")
---
 drivers/net/ethernet/ti/davinci_emac.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/net/ethernet/ti/davinci_emac.c +13 -2
index 06d7c9e4dcda..a1a6445b5a7e 100644
@@ -1385,6 +1385,11 @@ static int emac_devioctl(struct net_device *ndev, struct ifreq *ifrq, int cmd)
 		return -EOPNOTSUPP;
 }
 
+static int match_first_device(struct device *dev, void *data)
+{
+	return !strncmp(dev_name(dev), "davinci_mdio", 12);
+}
+
 /**
  * emac_dev_open - EMAC device open
  * @ndev: The DaVinci EMAC network adapter
@@ -1484,8 +1489,14 @@ static int emac_dev_open(struct net_device *ndev)
 
 	/* use the first phy on the bus if pdata did not give us a phy id */
 	if (!phydev && !priv->phy_id) {
-		phy = bus_find_device_by_name(&mdio_bus_type, NULL,
-					      "davinci_mdio");
+		/* NOTE: we can't use bus_find_device_by_name() here because
+		 * the device name is not guaranteed to be 'davinci_mdio'. On
+		 * some systems it can be 'davinci_mdio.0' so we need to use
+		 * strncmp() against the first part of the string to correctly
+		 * match it.
+		 */
+		phy = bus_find_device(&mdio_bus_type, NULL, NULL,
+				      match_first_device);
 		if (phy) {
 			priv->phy_id = dev_name(phy);
 			if (!priv->phy_id || !*priv->phy_id)
Signature · 1 line
2.17.1
#2 lore raw

PATCH v2 2/2 net: davinci_emac: match the mdio device against its compatible if possible

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

Device tree based systems without of_dev_auxdata will have the mdio device named differently than "davinci_mdio(.0)". In this case use the device's parent's compatible string for matching

---
 drivers/net/ethernet/ti/davinci_emac.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/ethernet/ti/davinci_emac.c +4 -0
index a1a6445b5a7e..f270beebb428 100644
@@ -1387,6 +1387,10 @@ static int emac_devioctl(struct net_device *ndev, struct ifreq *ifrq, int cmd)
 
 static int match_first_device(struct device *dev, void *data)
 {
+	if (dev->parent && dev->parent->of_node)
+		return of_device_is_compatible(dev->parent->of_node,
+					       "ti,davinci_mdio");
+
 	return !strncmp(dev_name(dev), "davinci_mdio", 12);
 }
 
Signature · 1 line
2.17.1
Reviewed-by on the v2 series
#3 lore raw
In reply to Bartosz Golaszewski
Quoted 7 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

Earlier I sent the first patch as a solution to a regression introduced during the v4.16 merge window, but after testing David's common clock series on top of 4.18-rc1 + this patch it turned out that the problem persisted.

Quoted 6 lines

This is a follow-up containing the regression fix and an additional patche that makes suspend/resume work with David's changes.

v1 -> v2:
- dropped patch 2/3
- in patch 2/2: check the device's parent's compatible

Much better:

Quoted 9 lines

Bartosz Golaszewski (2):
net: ethernet: fix suspend/resume in davinci_emac
net: davinci_emac: match the mdio device against its compatible if
possible

 drivers/net/ethernet/ti/davinci_emac.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
Signature · 1 line
Florian