[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <nmkpcss5pymkjitcf2o3pwu3r2rbu3kfy2ubtkpmktw6worj5p@rk5aljx6slwi>
Date: Wed, 6 Dec 2023 17:58:40 -0600
From: Andrew Halaney <ahalaney@...hat.com>
To: Alexandre Torgue <alexandre.torgue@...s.st.com>,
Jose Abreu <joabreu@...opsys.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Maxime Coquelin <mcoquelin.stm32@...il.com>
Cc: netdev@...r.kernel.org, linux-stm32@...md-mailman.stormreply.com,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
Subject: Re: [PATCH net-next v2] net: stmmac: don't create a MDIO bus if
unnecessary
On Wed, Dec 06, 2023 at 05:46:09PM -0600, Andrew Halaney wrote:
> The stmmac_dt_phy() function, which parses the devicetree node of the
> MAC and ultimately causes MDIO bus allocation, misinterprets what
> fixed-link means in relation to the MAC's MDIO bus. This results in
> a MDIO bus being created in situations it need not be.
>
> Currently a MDIO bus is created if the description is either:
>
> 1. Not fixed-link
> 2. fixed-link but contains a MDIO bus as well
>
> The "1" case above isn't always accurate. If there's a phy-handle,
> it could be referencing a phy on another MDIO controller's bus[1]. In
> this case currently the MAC will make a MDIO bus and scan it all
> anyways unnecessarily.
>
> There's also a lot of upstream devicetrees[2] that expect a MDIO bus to
> be created and scanned for a phy. This case can also be inferred from
> the platform description by not having a phy-handle && not being
> fixed-link. This hits case "1" in the current driver's logic.
>
> Let's improve the logic to create a MDIO bus if either:
>
> - Devicetree contains a MDIO bus
> - !fixed-link && !phy-handle (legacy handling)
>
> Below upstream devicetree snippets can be found that explain some of
> the cases above more concretely.
>
> Here's[0] a devicetree example where the MAC is both fixed-link and
> driving a switch on MDIO (case "2" above). This needs a MDIO bus to
> be created:
>
> &fec1 {
> phy-mode = "rmii";
>
> fixed-link {
> speed = <100>;
> full-duplex;
> };
>
> mdio1: mdio {
> switch0: switch0@0 {
> compatible = "marvell,mv88e6190";
> pinctrl-0 = <&pinctrl_gpio_switch0>;
> };
> };
> };
>
> Here's[1] an example where there is no MDIO bus or fixed-link for
> the ethernet1 MAC, so no MDIO bus should be created since ethernet0
> is the MDIO master for ethernet1's phy:
>
> ðernet0 {
> phy-mode = "sgmii";
> phy-handle = <&sgmii_phy0>;
>
> mdio {
> compatible = "snps,dwmac-mdio";
> sgmii_phy0: phy@8 {
> compatible = "ethernet-phy-id0141.0dd4";
> reg = <0x8>;
> device_type = "ethernet-phy";
> };
>
> sgmii_phy1: phy@a {
> compatible = "ethernet-phy-id0141.0dd4";
> reg = <0xa>;
> device_type = "ethernet-phy";
> };
> };
> };
>
> ðernet1 {
> phy-mode = "sgmii";
> phy-handle = <&sgmii_phy1>;
> };
>
> Finally there's descriptions like this[2] which don't describe the
> MDIO bus but expect it to be created and the whole address space
> scanned for a phy since there's no phy-handle or fixed-link described:
>
> &gmac {
> phy-supply = <&vcc_lan>;
> phy-mode = "rmii";
> snps,reset-gpio = <&gpio3 RK_PB4 GPIO_ACTIVE_HIGH>;
> snps,reset-active-low;
> snps,reset-delays-us = <0 10000 1000000>;
> };
>
> [0] https://elixir.bootlin.com/linux/v6.5-rc5/source/arch/arm/boot/dts/nxp/vf/vf610-zii-ssmb-dtu.dts
> [1] https://elixir.bootlin.com/linux/v6.6-rc5/source/arch/arm64/boot/dts/qcom/sa8775p-ride.dts
> [2] https://elixir.bootlin.com/linux/v6.6-rc5/source/arch/arm64/boot/dts/rockchip/rk3368-r88.dts#L164
>
> Co-developed-by: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
> Signed-off-by: Andrew Halaney <ahalaney@...hat.com>
> ---
Gah, I failed to describe my changes since Bart's v1 when picking this
up with b4 to make v2. Whoops!
Changes since v1:
- Handle the fixed-link + mdio case (Andrew Lunn)
- Reworded commit message
- Handle the "legacy" case still mentioned in the commit
- Bit further refactoring of the function
Powered by blists - more mailing lists