From: Chris Packham <Chris.Packham@alliedtelesis.co.nz>
To: Andrew Lunn <andrew@lunn.ch>
Cc: "hkallweit1@gmail.com" <hkallweit1@gmail.com>,
"linux@armlinux.org.uk" <linux@armlinux.org.uk>,
"davem@davemloft.net" <davem@davemloft.net>,
"edumazet@google.com" <edumazet@google.com>,
"kuba@kernel.org" <kuba@kernel.org>,
"pabeni@redhat.com" <pabeni@redhat.com>,
"sander@svanheule.net" <sander@svanheule.net>,
"markus.stockhausen@gmx.de" <markus.stockhausen@gmx.de>,
"daniel@makrotopia.org" <daniel@makrotopia.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: [PATCH net-next v11] net: mdio: Add RTL9300 MDIO driver
Date: Sun, 16 Mar 2025 20:11:29 +0000 [thread overview]
Message-ID: <d260e3d1-20e9-42f6-89b6-e646b8107bc0@alliedtelesis.co.nz> (raw)
In-Reply-To: <bd1d1cb9-a72b-484b-8cfd-7e91179391d2@lunn.ch>
On 15/03/2025 04:26, Andrew Lunn wrote:
>> +static int rtl9300_mdiobus_probe_one(struct device *dev, struct rtl9300_mdio_priv *priv,
>> + struct fwnode_handle *node)
>> +{
>> + struct rtl9300_mdio_chan *chan;
>> + struct fwnode_handle *child;
>> + struct mii_bus *bus;
>> + u32 mdio_bus;
>> + int err;
>> +
>> + err = fwnode_property_read_u32(node, "reg", &mdio_bus);
>> + if (err)
>> + return err;
>> +
>> + /* The MDIO interfaces are either in GPHY (i.e. clause 22) or 10GPHY
>> + * mode (i.e. clause 45).
> I still need more clarification about this. Is this solely about the
> polling? Or does an interface in C22 mode go horribly wrong when asked
> to do a C45 bus transaction?
It's just the polling. I haven't seen any sign of the bus getting into a
bad state when using the wrong transaction type.
>> + bus->name = "Realtek Switch MDIO Bus";
>> + bus->read = rtl9300_mdio_read_c22;
>> + bus->write = rtl9300_mdio_write_c22;
>> + bus->read_c45 = rtl9300_mdio_read_c45;
>> + bus->write_c45 = rtl9300_mdio_write_c45;
> You are providing C45 bus methods, independent of the interface
> mode. So when accessing EEE registers in C45 address space, C45 bus
> transactions are going to be used, even on an MDIO interface using C22
> mode. Does this work? Can you actually do both C22 and C45 bus
> transactions independent of the interface mode?
I'm not actually sure if I can mix transactions but it doesn't seem to
do any harm.
Initially I planned to only supply one of the function pairs depending
on the mode but I left this in because of this:
https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/phy/phy.c#n337
I've written myself a little test app that uses SIOCGMIIREG/SIOCSMIIREG
to exercise the MDIO accesses. It uses SIOCGMIIPHY to look up the MDIO
address of the PHY attached to the netdev but because of that
fallthrough looking up the PHY address for a C45 PHY will fail with
-EOPNOTSUPP.
I've squinted at that code and can't decide if it's a bug or intended.
It seems to be there to validate if the PHY is actually present and will
works for C22 because mii_data->reg_num will come through the ioctl (or
because 0 is a valid register) . It won't work for C45 because
SIOCGMIIPHY has no way of supplying the MMD device.
>
> Andrew
next prev parent reply other threads:[~2025-03-16 20:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-13 23:38 Chris Packham
2025-03-14 15:26 ` Andrew Lunn
2025-03-16 20:11 ` Chris Packham [this message]
2025-03-17 21:27 ` Andrew Lunn
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=d260e3d1-20e9-42f6-89b6-e646b8107bc0@alliedtelesis.co.nz \
--to=chris.packham@alliedtelesis.co.nz \
--cc=andrew@lunn.ch \
--cc=daniel@makrotopia.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=markus.stockhausen@gmx.de \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sander@svanheule.net \
/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
all inboxes | Powered by JetHome®