Netdev List
 help / color / mirror / Atom feed
From: Tim Menninger <tmenninger@purestorage.com>
To: andrew@lunn.ch, f.fainelli@gmail.com, olteanv@gmail.com,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH] net: dsa: mv88e6xxx: Make *_c45 callbacks agree with phy_*_c45 callbacks
Date: Tue, 16 Jan 2024 19:35:42 +0000	[thread overview]
Message-ID: <20240116193542.711482-1-tmenninger@purestorage.com> (raw)

Set the read_c45 callback in the mii_bus struct in mv88e6xxx only if there
is a non-NULL phy_read_c45 callback on the chip mv88e6xxx_ops. Similarly
for write_c45 and phy_write_c45.

In commit 743a19e38d02 ("net: dsa: mv88e6xxx: Separate C22 and C45 transactions")
the MDIO bus driver split its API to separate C22 and C45 transfers.

In commit 1a136ca2e089 ("net: mdio: scan bus based on bus capabilities for C22 and C45")
we do a C45 mdio bus scan based on existence of the read_c45 callback
rather than checking MDIO bus capabilities then in
commit da099a7fb13d ("net: phy: Remove probe_capabilities") we remove the
probe_capabilities from the mii_bus struct.

The combination of the above results in a scenario (e.g. mv88e6185)
where we take a non-NULL read_c45 callback on the mii_bus struct to mean
we can perform a C45 read and proceed with a C45 MDIO bus scan. The scan
encounters a NULL phy_read_c45 callback in the mv88e6xxx_ops which implies
we can NOT perform a C45 read and fails with EOPNOTSUPP. The read_c45
callback should be NULL if phy_read_c45 is NULL, and similarly for
write_c45 and phy_write_c45.

Fixes: 1a136ca2e089 ("net: mdio: scan bus based on bus capabilities for C22 and C45")
Fixes: da099a7fb13d ("net: phy: Remove probe_capabilities")

Signed-off-by: Tim Menninger <tmenninger@purestorage.com>
---
 drivers/net/dsa/mv88e6xxx/chip.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 383b3c4d6f59..ba972d5427e5 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -3739,8 +3739,10 @@ static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
 
 	bus->read = mv88e6xxx_mdio_read;
 	bus->write = mv88e6xxx_mdio_write;
-	bus->read_c45 = mv88e6xxx_mdio_read_c45;
-	bus->write_c45 = mv88e6xxx_mdio_write_c45;
+	bus->read_c45 = chip->info->ops->phy_read_c45
+		? mv88e6xxx_mdio_read_c45 : NULL;
+	bus->write_c45 = chip->info->ops->phy_write_c45
+		? mv88e6xxx_mdio_write_c45 : NULL;
 	bus->parent = chip->dev;
 	bus->phy_mask = ~GENMASK(chip->info->phy_base_addr +
 				 mv88e6xxx_num_ports(chip) - 1,
-- 
2.34.1


             reply	other threads:[~2024-01-16 19:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-16 19:35 Tim Menninger [this message]
2024-01-16 19:59 ` [PATCH] net: dsa: mv88e6xxx: Make *_c45 callbacks agree with phy_*_c45 callbacks Andrew Lunn
2024-01-16 22:24   ` Tim Menninger
2024-01-16 23:21     ` Andrew Lunn
2024-01-17  1:51       ` Tim Menninger
2024-01-22 12:33         ` Vladimir Oltean
2024-01-22 14:30           ` Andrew Lunn
2024-01-22 15:12             ` Vladimir Oltean
2024-01-22 15:46               ` Tim Menninger
2024-01-23 15:27                 ` Vladimir Oltean
2024-01-29 18:53                   ` Tim Menninger
2024-01-29 18:55                     ` Florian Fainelli

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=20240116193542.711482-1-tmenninger@purestorage.com \
    --to=tmenninger@purestorage.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.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