linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] dsa: register every port with of_platform
@ 2021-07-23 11:05 Ansuel Smith
  2021-07-23 11:13 ` Michael Walle
  0 siblings, 1 reply; 5+ messages in thread
From: Ansuel Smith @ 2021-07-23 11:05 UTC (permalink / raw)
  To: Andrew Lunn, Vivien Didelot, Florian Fainelli, Vladimir Oltean,
	David S. Miller, Jakub Kicinski, netdev, linux-kernel
  Cc: Ansuel Smith

The declaration of a different mac-addr using the nvmem framework is
currently broken. The dsa code uses the generic of_get_mac_address where
the nvmem function requires the device node to be registered in the
of_platform to be found by of_find_device_by_node. Register every port
in the of_platform so they can correctly found and a custom mac-addr can
correctly be declared using a nvmem-cell declared in the dts.

An example of this would be a device that use a specific mac-addr for the
wan port and declare the source of that with a nvmem-cell.
In the current state, nvmem will always fail to find the declared cell
but registering the devicenode with the of_platform doesn't look correct
to me so am I missing something? Is this not supported? (declaring nvmem
cell for the mac-addrs in the port node) In theory it should since
of_get_mac_address supports exactly that.

If I'm not missing something, I see this as the only solution or change
the logic of how the function in of_get_mac_address find the cell.

I hope someone take care of this as currently the function doesn't work
most of the time, if this workaround is not used. Since mtd now actually
supports declaring of nvmem cells, we are starting to adopt this new
implementation and we found this problem.
Also a mediatek drivert suffer of the same problem where it does declare
special mac port without using the of_platform (and so requires manual
registration using the function in this patch) with the compatible 
"mediatek,eth-mac"

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
---
 net/dsa/dsa2.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index b71e87909f0e..30b1df69ace6 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -14,6 +14,7 @@
 #include <linux/rtnetlink.h>
 #include <linux/of.h>
 #include <linux/of_net.h>
+#include <linux/of_platform.h>
 #include <net/devlink.h>
 
 #include "dsa_priv.h"
@@ -392,6 +393,7 @@ static int dsa_port_setup(struct dsa_port *dp)
 
 		break;
 	case DSA_PORT_TYPE_USER:
+		of_platform_device_create(dp->dn, NULL, NULL);
 		of_get_mac_address(dp->dn, dp->mac);
 		err = dsa_slave_create(dp);
 		if (err)
-- 
2.31.1


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

* Re: [RFC] dsa: register every port with of_platform
  2021-07-23 11:05 [RFC] dsa: register every port with of_platform Ansuel Smith
@ 2021-07-23 11:13 ` Michael Walle
  2021-07-23 11:18   ` Ansuel Smith
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Walle @ 2021-07-23 11:13 UTC (permalink / raw)
  To: ansuelsmth
  Cc: andrew, davem, f.fainelli, kuba, linux-kernel, netdev, olteanv,
	vivien.didelot, Michael Walle

> The declaration of a different mac-addr using the nvmem framework is
> currently broken. The dsa code uses the generic of_get_mac_address where
> the nvmem function requires the device node to be registered in the
> of_platform to be found by of_find_device_by_node. Register every port

Which tree are you on? This should be fixed with

f10843e04a07  of: net: fix of_get_mac_addr_nvmem() for non-platform devices

-michael

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

* Re: [RFC] dsa: register every port with of_platform
  2021-07-23 11:13 ` Michael Walle
@ 2021-07-23 11:18   ` Ansuel Smith
  2021-07-23 11:25     ` Michael Walle
  0 siblings, 1 reply; 5+ messages in thread
From: Ansuel Smith @ 2021-07-23 11:18 UTC (permalink / raw)
  To: Michael Walle
  Cc: andrew, davem, f.fainelli, kuba, linux-kernel, netdev, olteanv,
	vivien.didelot

On Fri, Jul 23, 2021 at 01:13:28PM +0200, Michael Walle wrote:
> > The declaration of a different mac-addr using the nvmem framework is
> > currently broken. The dsa code uses the generic of_get_mac_address where
> > the nvmem function requires the device node to be registered in the
> > of_platform to be found by of_find_device_by_node. Register every port
> 
> Which tree are you on? This should be fixed with
> 
> f10843e04a07  of: net: fix of_get_mac_addr_nvmem() for non-platform devices
> 
> -michael

Thx a lot for the hint. So yes I missed that the problem was already
fixed. Sorry for the mess. Any idea if that will be backported?


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

* Re: [RFC] dsa: register every port with of_platform
  2021-07-23 11:18   ` Ansuel Smith
@ 2021-07-23 11:25     ` Michael Walle
  2021-07-23 11:30       ` Ansuel Smith
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Walle @ 2021-07-23 11:25 UTC (permalink / raw)
  To: Ansuel Smith
  Cc: andrew, davem, f.fainelli, kuba, linux-kernel, netdev, olteanv,
	vivien.didelot

Am 2021-07-23 13:18, schrieb Ansuel Smith:
> On Fri, Jul 23, 2021 at 01:13:28PM +0200, Michael Walle wrote:
>> > The declaration of a different mac-addr using the nvmem framework is
>> > currently broken. The dsa code uses the generic of_get_mac_address where
>> > the nvmem function requires the device node to be registered in the
>> > of_platform to be found by of_find_device_by_node. Register every port
>> 
>> Which tree are you on? This should be fixed with
>> 
>> f10843e04a07  of: net: fix of_get_mac_addr_nvmem() for non-platform 
>> devices
>> 
>> -michael
> 
> Thx a lot for the hint. So yes I missed that the problem was already
> fixed. Sorry for the mess. Any idea if that will be backported?

I didn't include a Fixes tag, so it won't be automatically
backported. Also I'm not sure if it qualifies for the stable trees
because no in-tree users seem to be affected, no?

-michael

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

* Re: [RFC] dsa: register every port with of_platform
  2021-07-23 11:25     ` Michael Walle
@ 2021-07-23 11:30       ` Ansuel Smith
  0 siblings, 0 replies; 5+ messages in thread
From: Ansuel Smith @ 2021-07-23 11:30 UTC (permalink / raw)
  To: Michael Walle
  Cc: andrew, davem, f.fainelli, kuba, linux-kernel, netdev, olteanv,
	vivien.didelot

On Fri, Jul 23, 2021 at 01:25:02PM +0200, Michael Walle wrote:
> Am 2021-07-23 13:18, schrieb Ansuel Smith:
> > On Fri, Jul 23, 2021 at 01:13:28PM +0200, Michael Walle wrote:
> > > > The declaration of a different mac-addr using the nvmem framework is
> > > > currently broken. The dsa code uses the generic of_get_mac_address where
> > > > the nvmem function requires the device node to be registered in the
> > > > of_platform to be found by of_find_device_by_node. Register every port
> > > 
> > > Which tree are you on? This should be fixed with
> > > 
> > > f10843e04a07  of: net: fix of_get_mac_addr_nvmem() for non-platform
> > > devices
> > > 
> > > -michael
> > 
> > Thx a lot for the hint. So yes I missed that the problem was already
> > fixed. Sorry for the mess. Any idea if that will be backported?
> 
> I didn't include a Fixes tag, so it won't be automatically
> backported. Also I'm not sure if it qualifies for the stable trees
> because no in-tree users seem to be affected, no?
> 
> -michael

Also the patch seems very large. Anyway again thx a lot for the work and
the quick hint. Time to backport to 5.10 and 5.4 for openwrt.


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

end of thread, other threads:[~2021-07-23 11:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-23 11:05 [RFC] dsa: register every port with of_platform Ansuel Smith
2021-07-23 11:13 ` Michael Walle
2021-07-23 11:18   ` Ansuel Smith
2021-07-23 11:25     ` Michael Walle
2021-07-23 11:30       ` Ansuel Smith

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