All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: Pierluigi Passaro <pierluigi.passaro@gmail.com>,
	hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	eran.m@variscite.com, nate.d@variscite.com,
	francesco.f@variscite.com, pierluigi.p@variscite.com
Subject: Re: [PATCH] net: mdio: force deassert MDIO reset signal
Date: Mon, 16 Jan 2023 00:55:27 +0100	[thread overview]
Message-ID: <Y8SSb+tJsfJ3/DvH@lunn.ch> (raw)
In-Reply-To: <f691f339-9e50-b968-01e1-1821a2f696e7@metafoo.de>

> Specifying the ID as part of the compatible string works for clause 22 PHYs,
> but for clause 45 PHYs it does not work. The code always wants to read the
> ID from the PHY itself. But I do not understand things well enough to tell
> whether that's a fundamental restriction of C45 or just our implementation
> and the implementation can be changed to fix it.
> 
> Do you have some thoughts on this?

Do you have more details about what goes wrong? Which PHY driver is
it? What compatibles do you put into DT for the PHY?

To some extent, the ID is only used to find the driver. A C45 device
has a lot of ID register, and all of them are used by phy_bus_match()
to see if a driver matches. So you need to be careful which ID you
pick, it needs to match the driver.

It is the driver which decides to use C22 or C45 to talk to the PHY.
However, we do have:

static int phy_probe(struct device *dev)
{
...
        else if (phydev->is_c45)
                err = genphy_c45_pma_read_abilities(phydev);
        else
                err = genphy_read_abilities(phydev);

so it could be a C45 PHY probed using an ID does not have
phydev->is_c45 set, and so it looks in the wrong place for the
capabilities. Make sure you also have the compatible
"ethernet-phy-ieee802.3-c45" which i think should cause is_c45 to be
set.

There is no fundamental restriction that i know of here, it probably
just needs somebody to debug it and find where it goes wrong.

Ah!

int fwnode_mdiobus_register_phy(struct mii_bus *bus,
                                struct fwnode_handle *child, u32 addr)
{
...
        rc = fwnode_property_match_string(child, "compatible",
                                          "ethernet-phy-ieee802.3-c45");
        if (rc >= 0)
                is_c45 = true;

        if (is_c45 || fwnode_get_phy_id(child, &phy_id))
                phy = get_phy_device(bus, addr, is_c45);
        else
                phy = phy_device_create(bus, addr, phy_id, 0, NULL);


So compatible "ethernet-phy-ieee802.3-c45" results in is_c45 being set
true. The if (is_c45 || is then true, so it does not need to call
fwnode_get_phy_id(child, &phy_id) so ignores whatever ID is in DT and
asks the PHY.

Try this, totally untested:

diff --git a/drivers/net/mdio/fwnode_mdio.c b/drivers/net/mdio/fwnode_mdio.c
index b782c35c4ac1..13be23f8ac97 100644
--- a/drivers/net/mdio/fwnode_mdio.c
+++ b/drivers/net/mdio/fwnode_mdio.c
@@ -134,10 +134,10 @@ int fwnode_mdiobus_register_phy(struct mii_bus *bus,
        if (rc >= 0)
                is_c45 = true;
 
-       if (is_c45 || fwnode_get_phy_id(child, &phy_id))
+       if (fwnode_get_phy_id (child, &phy_id))
                phy = get_phy_device(bus, addr, is_c45);
        else
-               phy = phy_device_create(bus, addr, phy_id, 0, NULL);
+               phy = phy_device_create(bus, addr, phy_id, is_c45, NULL);
        if (IS_ERR(phy)) {
                rc = PTR_ERR(phy);
                goto clean_mii_ts;


     Andrew

  parent reply	other threads:[~2023-01-15 23:55 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-15 16:10 [PATCH] net: mdio: force deassert MDIO reset signal Pierluigi Passaro
2023-01-15 17:08 ` Andrew Lunn
2023-01-15 18:38   ` Pierluigi Passaro
2023-01-15 19:02     ` Andrew Lunn
2023-01-15 20:34       ` Pierluigi Passaro
2023-01-15 21:58   ` Lars-Peter Clausen
2023-01-15 22:33     ` Pierluigi Passaro
2023-01-15 22:56       ` Lars-Peter Clausen
2023-01-15 23:16         ` Pierluigi Passaro
2023-01-16  0:11       ` Andrew Lunn
2023-01-16  9:44         ` Pierluigi Passaro
2023-01-16 10:21           ` Russell King (Oracle)
2023-01-17 14:01           ` Andrew Lunn
2023-01-17 15:20             ` Pierluigi Passaro
2023-01-15 23:55     ` Andrew Lunn [this message]
2023-01-16  2:21       ` Lars-Peter Clausen
2023-01-16  9:51         ` Pierluigi Passaro
2023-01-17 13:40         ` Andrew Lunn
2023-01-17 13:48           ` Lars-Peter Clausen
2023-01-17 14:13             ` Andrew Lunn
2023-01-16  8:39       ` Pierluigi Passaro
2023-01-17 13:43         ` Andrew Lunn
2023-01-16  8:43 ` kernel test robot
2023-01-16 10:32   ` Pierluigi Passaro
2023-01-16 10:34     ` Russell King (Oracle)
2023-01-16 14:35   ` Pierluigi Passaro
2023-01-17 19:25 kernel test robot
2023-01-17 20:30 ` Dan Carpenter

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=Y8SSb+tJsfJ3/DvH@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=eran.m@variscite.com \
    --cc=francesco.f@variscite.com \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=nate.d@variscite.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pierluigi.p@variscite.com \
    --cc=pierluigi.passaro@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.