netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Oltean <olteanv@gmail.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, andrew@lunn.ch, vivien.didelot@gmail.com,
	f.fainelli@gmail.com, joakim.tjernlund@infinera.com,
	madalin.bucur@oss.nxp.com, fido_max@inbox.ru,
	linux-kernel@vger.kernel.org
Subject: [PATCH net 2/2] dpaa_eth: fix usage as DSA master, try 4
Date: Tue, 16 Jun 2020 17:41:18 +0300	[thread overview]
Message-ID: <20200616144118.3902244-3-olteanv@gmail.com> (raw)
In-Reply-To: <20200616144118.3902244-1-olteanv@gmail.com>

From: Vladimir Oltean <vladimir.oltean@nxp.com>

The dpaa-eth driver probes on compatible string for the MAC node, and
the fman/mac.c driver allocates a dpaa-ethernet platform device that
triggers the probing of the dpaa-eth net device driver.

All of this is fine, but the problem is that the struct device of the
dpaa_eth net_device is 2 parents away from the MAC which can be
referenced via of_node. So of_find_net_device_by_node can't find it, and
DSA switches won't be able to probe on top of FMan ports.

It would be a bit silly to modify a core function
(of_find_net_device_by_node) to look for dev->parent->parent->of_node
just for one driver. We're just 1 step away from implementing full
recursion.

On T1040, the /sys/class/net/eth0 symlink currently points to:

../../devices/platform/ffe000000.soc/ffe400000.fman/ffe4e6000.ethernet/net/eth0

which pretty much illustrates the problem. The closest of_node we've got
is the "fsl,fman-memac" at /soc@ffe000000/fman@400000/ethernet@e6000,
which is what we'd like to be able to reference from DSA as host port.

For of_find_net_device_by_node to find the eth0 port, we would need the
parent of the eth0 net_device to not be the "dpaa-ethernet" platform
device, but to point 1 level higher, aka the "fsl,fman-memac" node
directly. The new sysfs path would look like this:

../../devices/platform/ffe000000.soc/ffe400000.fman/ffe4e6000.ethernet/dpaa-ethernet.0/net/eth0

Actually this has worked before, through the SET_NETDEV_DEV mechanism,
which sets the parent of the net_device as the parent of the platform
device. But the device which was set as sysfs parent was inadvertently
changed through commit 060ad66f9795 ("dpaa_eth: change DMA device"),
which did not take into consideration the effect it would have upon
of_find_net_device_by_node. So restore the old sysfs parent to make that
work correctly.

Fixes: 060ad66f9795 ("dpaa_eth: change DMA device")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
index c4416a5f8816..2972244e6eb0 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
@@ -2914,7 +2914,7 @@ static int dpaa_eth_probe(struct platform_device *pdev)
 	}
 
 	/* Do this here, so we can be verbose early */
-	SET_NETDEV_DEV(net_dev, dev);
+	SET_NETDEV_DEV(net_dev, dev->parent);
 	dev_set_drvdata(dev, net_dev);
 
 	priv = netdev_priv(net_dev);
-- 
2.25.1


  parent reply	other threads:[~2020-06-16 14:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-16 14:41 [PATCH net 0/2] Reapply DSA fix for dpaa-eth with proper Fixes: tag Vladimir Oltean
2020-06-16 14:41 ` [PATCH net 1/2] Revert "dpaa_eth: fix usage as DSA master, try 3" Vladimir Oltean
2020-06-16 14:41 ` Vladimir Oltean [this message]
2020-06-16 14:51   ` [PATCH net 2/2] dpaa_eth: fix usage as DSA master, try 4 Joakim Tjernlund
2020-06-16 14:56     ` Vladimir Oltean
2020-06-16 15:04       ` Joakim Tjernlund
2020-06-16 15:08         ` Vladimir Oltean
2020-06-16 15:12           ` Vladimir Oltean
2020-06-16 15:15             ` Joakim Tjernlund

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200616144118.3902244-3-olteanv@gmail.com \
    --to=olteanv@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=fido_max@inbox.ru \
    --cc=joakim.tjernlund@infinera.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=madalin.bucur@oss.nxp.com \
    --cc=netdev@vger.kernel.org \
    --cc=vivien.didelot@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).