stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* request for 4.4-stable: 552165bcf7060 ("drivers: net: cpsw: fix parsing of phy-handle DT property in dual_emac config")
@ 2018-09-12 11:54 SZ Lin (林上智)
  2018-09-17 11:45 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: SZ Lin (林上智) @ 2018-09-12 11:54 UTC (permalink / raw)
  To: stable

[-- Attachment #1: Type: text/plain, Size: 214 bytes --]

Hi,

This patch is not marked for 4.4-stable, but it's already in 4.9 and 4.14 stable. 

Please apply to 4.4-stable.

This patch fixed parsing of phy-handle DT property in dual_emac config.

--
SZ Lin (林上智) 

[-- Attachment #2: 0001-drivers-net-cpsw-fix-parsing-of-phy-handle-DT-proper.patch --]
[-- Type: text/x-diff, Size: 3905 bytes --]

>From 2123cdb99d4b7528fb0aa504ac873b66e386a243 Mon Sep 17 00:00:00 2001
From: David Rivshin <drivshin@allworx.com>
Date: Wed, 27 Apr 2016 21:25:25 -0400
Subject: [PATCH] drivers: net: cpsw: fix parsing of phy-handle DT property in
 dual_emac config

commit 552165bcf7060b998b4a9b5b86110b6a5e04dfd9 upstream

Commit 9e42f715264ff158478fa30eaed847f6e131366b ("drivers: net: cpsw: add
phy-handle parsing") saved the "phy-handle" phandle into a new cpsw_priv
field. However, phy connections are per-slave, so the phy_node field should
be in cpsw_slave_data rather than cpsw_priv.

This would go unnoticed in a single emac configuration. But in dual_emac
mode, the last "phy-handle" property parsed for either slave would be used
by both of them, causing them both to refer to the same phy_device.

Fixes: 9e42f715264f ("drivers: net: cpsw: add phy-handle parsing")
Signed-off-by: David Rivshin <drivshin@allworx.com>
Tested-by: Nicolas Chauvet <kwizart@gmail.com>
Tested-by: Andrew Goodbody <andrew.goodbody@cambrionix.com>
Reviewed-by: Mugunthan V N <mugunthanvnm@ti.com>
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: SZ Lin (林上智) <sz.lin@moxa.com>
---
 drivers/net/ethernet/ti/cpsw.c | 13 ++++++-------
 drivers/net/ethernet/ti/cpsw.h |  1 +
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index c69b0bdd891d..c21c80a228d9 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -371,7 +371,6 @@ struct cpsw_priv {
 	spinlock_t			lock;
 	struct platform_device		*pdev;
 	struct net_device		*ndev;
-	struct device_node		*phy_node;
 	struct napi_struct		napi_rx;
 	struct napi_struct		napi_tx;
 	struct device			*dev;
@@ -1165,8 +1164,8 @@ static void cpsw_slave_open(struct cpsw_slave *slave, struct cpsw_priv *priv)
 		cpsw_ale_add_mcast(priv->ale, priv->ndev->broadcast,
 				   1 << slave_port, 0, 0, ALE_MCAST_FWD_2);
 
-	if (priv->phy_node)
-		slave->phy = of_phy_connect(priv->ndev, priv->phy_node,
+	if (slave->data->phy_node)
+		slave->phy = of_phy_connect(priv->ndev, slave->data->phy_node,
 				 &cpsw_adjust_link, 0, slave->data->phy_if);
 	else
 		slave->phy = phy_connect(priv->ndev, slave->data->phy_id,
@@ -1957,12 +1956,11 @@ static void cpsw_slave_init(struct cpsw_slave *slave, struct cpsw_priv *priv,
 	slave->port_vlan = data->dual_emac_res_vlan;
 }
 
-static int cpsw_probe_dt(struct cpsw_priv *priv,
+static int cpsw_probe_dt(struct cpsw_platform_data *data,
 			 struct platform_device *pdev)
 {
 	struct device_node *node = pdev->dev.of_node;
 	struct device_node *slave_node;
-	struct cpsw_platform_data *data = &priv->data;
 	int i = 0, ret;
 	u32 prop;
 
@@ -2050,7 +2048,8 @@ static int cpsw_probe_dt(struct cpsw_priv *priv,
 		if (strcmp(slave_node->name, "slave"))
 			continue;
 
-		priv->phy_node = of_parse_phandle(slave_node, "phy-handle", 0);
+		slave_data->phy_node = of_parse_phandle(slave_node,
+							"phy-handle", 0);
 		parp = of_get_property(slave_node, "phy_id", &lenp);
 		if (of_phy_is_fixed_link(slave_node)) {
 			struct device_node *phy_node;
@@ -2291,7 +2290,7 @@ static int cpsw_probe(struct platform_device *pdev)
 	/* Select default pin state */
 	pinctrl_pm_select_default_state(&pdev->dev);
 
-	if (cpsw_probe_dt(priv, pdev)) {
+	if (cpsw_probe_dt(&priv->data, pdev)) {
 		dev_err(&pdev->dev, "cpsw: platform data missing\n");
 		ret = -ENODEV;
 		goto clean_runtime_disable_ret;
diff --git a/drivers/net/ethernet/ti/cpsw.h b/drivers/net/ethernet/ti/cpsw.h
index 442a7038e660..e50afd1b2eda 100644
--- a/drivers/net/ethernet/ti/cpsw.h
+++ b/drivers/net/ethernet/ti/cpsw.h
@@ -18,6 +18,7 @@
 #include <linux/phy.h>
 
 struct cpsw_slave_data {
+	struct device_node *phy_node;
 	char		phy_id[MII_BUS_ID_SIZE];
 	int		phy_if;
 	u8		mac_addr[ETH_ALEN];
-- 
2.19.0


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

* Re: request for 4.4-stable: 552165bcf7060 ("drivers: net: cpsw: fix parsing of phy-handle DT property in dual_emac config")
  2018-09-12 11:54 request for 4.4-stable: 552165bcf7060 ("drivers: net: cpsw: fix parsing of phy-handle DT property in dual_emac config") SZ Lin (林上智)
@ 2018-09-17 11:45 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2018-09-17 11:45 UTC (permalink / raw)
  To: SZ Lin (林上智); +Cc: stable

On Wed, Sep 12, 2018 at 07:54:59PM +0800, SZ Lin (林上智) wrote:
> Hi,
> 
> This patch is not marked for 4.4-stable, but it's already in 4.9 and 4.14 stable. 
> 
> Please apply to 4.4-stable.
> 
> This patch fixed parsing of phy-handle DT property in dual_emac config.

Now applied, thanks.

greg k-h

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

end of thread, other threads:[~2018-09-17 17:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-12 11:54 request for 4.4-stable: 552165bcf7060 ("drivers: net: cpsw: fix parsing of phy-handle DT property in dual_emac config") SZ Lin (林上智)
2018-09-17 11:45 ` Greg KH

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