From: Vladimir Oltean <olteanv@gmail.com>
To: Daniel Danzberger <dd@embedd.com>
Cc: woojung.huh@microchip.com, UNGLinuxDriver@microchip.com,
netdev@vger.kernel.org, Andrew Lunn <andrew@lunn.ch>,
Florian Fainelli <f.fainelli@gmail.com>
Subject: Re: [PATCH] net: dsa: microchip: fix NULL pointer dereference on platform init
Date: Wed, 6 Dec 2023 02:37:06 +0200 [thread overview]
Message-ID: <20231206003706.w3azftqx7nopn4go@skbuf> (raw)
In-Reply-To: <52f88c8bf0897f1b97360fd4f94bdfe2e18f6cc0.camel@embedd.com>
On Tue, Dec 05, 2023 at 11:15:58PM +0100, Daniel Danzberger wrote:
> The lan* devices are then bridged together:
>
> root@t2t-ngr421:~# brctl show
> bridge name bridge id STP enabled interfaces
> br-lan 7fff.00139555cfd7 no lan4
> lan2
> lan3
> lan1
Ok, so it forwards traffic because the ports are bridged, not that it
does that by default.
I see in your output that the internal PHY network interfaces are
registered and functional, and now I know how that works.
ksz_mdio_register() is indeed bypassed by the lack of OF as I suspected,
so it's not that function which is responsible for creating the MDIO bus.
But this piece of code from dsa_switch_setup() will kick in:
if (!ds->user_mii_bus && ds->ops->phy_read) {
ds->user_mii_bus = mdiobus_alloc();
if (!ds->user_mii_bus) {
err = -ENOMEM;
goto teardown;
}
dsa_user_mii_bus_init(ds);
dn = of_get_child_by_name(ds->dev->of_node, "mdio");
err = of_mdiobus_register(ds->user_mii_bus, dn);
of_node_put(dn);
if (err < 0)
goto free_user_mii_bus;
}
aka DSA will set up a ds->user_mii_bus which calls into ds->ops->phy_read()
and ds->ops->phy_write() to access the internal PHYs. Although this bus
may be OF-based (if "dn" above is non-NULL), the of_mdiobus_register()
implementation simply calls mdiobus_register() if there is no OF node.
So, surprisingly, there is enough redundancy between DSA mechanisms that
platform_data kinda works.
next prev parent reply other threads:[~2023-12-06 0:37 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-04 15:43 [PATCH] net: dsa: microchip: fix NULL pointer dereference on platform init Daniel Danzberger
2023-12-04 17:43 ` Vladimir Oltean
2023-12-05 8:00 ` Daniel Danzberger
2023-12-05 8:36 ` Vladimir Oltean
2023-12-05 9:08 ` Daniel Danzberger
2023-12-05 9:39 ` Vladimir Oltean
2023-12-05 16:55 ` Vladimir Oltean
2023-12-05 17:33 ` Daniel Danzberger
2023-12-05 18:17 ` Vladimir Oltean
2023-12-05 22:15 ` Daniel Danzberger
2023-12-06 0:37 ` Vladimir Oltean [this message]
2023-12-06 15:26 ` Andrew Lunn
2023-12-06 21:49 ` Vladimir Oltean
2023-12-05 10:12 ` Vladimir Oltean
2023-12-05 11:44 ` Daniel Danzberger
2023-12-05 12:04 ` Vladimir Oltean
2023-12-05 12:42 ` Vladimir Oltean
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=20231206003706.w3azftqx7nopn4go@skbuf \
--to=olteanv@gmail.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew@lunn.ch \
--cc=dd@embedd.com \
--cc=f.fainelli@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=woojung.huh@microchip.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).