From: Nicolo Giuliani via B4 Relay <devnull+nicolo.giuliani6.studio.unibo.it@kernel.org>
To: Andrew Lunn <andrew@lunn.ch>, Vladimir Oltean <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
Richard Cochran <richardcochran@gmail.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Nicolo Giuliani <nicolo.giuliani6@studio.unibo.it>
Subject: [PATCH net] net: dsa: mv88e6xxx: continue without PTP if the TAI period is invalid
Date: Sat, 19 Sep 2026 21:52:07 +0200 [thread overview]
Message-ID: <20260919-send-net-v1-1-4355c72465ee@studio.unibo.it> (raw)
From: Nicolo Giuliani <nicolo.giuliani6@studio.unibo.it>
Since commit 7e3c18097a70 ("net: dsa: mv88e6xxx: read cycle counter
period from hardware"), mv88e6xxx_ptp_setup() reads the TAI clock period
register and fails with -ENODEV if the value is not one of the supported
periods. mv88e6xxx_setup() propagates the error, so the switch does not
probe at all, although it is fully usable without PTP. Before that commit
the register was not read and the probe did not depend on its value.
The 88E6193X on the Sophos XGS 107w reads 0 in that register, so its
probe fails with:
mv88e6xxx ...: unexpected cycle counter period of 0 ps
Treat -ENODEV from mv88e6xxx_ptp_setup() as the absence of a usable PTP
clock: warn, skip the hardware timestamping setup and carry on without
registering a PHC. -ENODEV can only come from mv88e6xxx_cc_coeff_get(),
which runs before ptp_setup changes any state, so there is nothing to
undo, and all other errors still fail the probe.
Without a PHC chip->ptp_clock stays NULL, and the timestamping entry
points dereference it (ptp_clock_index() in get_ts_info,
ptp_schedule_worker() in the rx and tx paths). Make get_ts_info,
port_hwtstamp_set/get and mv88e6xxx_should_tstamp() treat a missing
clock like a chip without ptp_support. Switches that register a PHC are
unaffected.
Fixes: 7e3c18097a70 ("net: dsa: mv88e6xxx: read cycle counter period from hardware")
Assisted-by: LLM
Signed-off-by: Nicolo Giuliani <nicolo.giuliani6@studio.unibo.it>
---
drivers/net/dsa/mv88e6xxx/chip.c | 19 ++++++++++++++-----
drivers/net/dsa/mv88e6xxx/hwtstamp.c | 8 ++++----
2 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 7f68a0c55..2d6de43f2 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -4106,12 +4106,21 @@ static int mv88e6xxx_setup(struct dsa_switch *ds)
/* Setup PTP Hardware Clock and timestamping */
if (chip->info->ptp_support) {
err = mv88e6xxx_ptp_setup(chip);
- if (err)
- goto unlock;
-
- err = mv88e6xxx_hwtstamp_setup(chip);
- if (err)
+ if (err == -ENODEV) {
+ /* The TAI clock period is not one that the driver
+ * supports: run the switch without PTP rather than
+ * failing the whole probe.
+ */
+ dev_warn(chip->dev,
+ "PTP clock unavailable, hardware timestamping disabled\n");
+ err = 0;
+ } else if (err) {
goto unlock;
+ } else {
+ err = mv88e6xxx_hwtstamp_setup(chip);
+ if (err)
+ goto unlock;
+ }
}
err = mv88e6xxx_stats_setup(chip);
diff --git a/drivers/net/dsa/mv88e6xxx/hwtstamp.c b/drivers/net/dsa/mv88e6xxx/hwtstamp.c
index 6e6472a3b..847f9dd44 100644
--- a/drivers/net/dsa/mv88e6xxx/hwtstamp.c
+++ b/drivers/net/dsa/mv88e6xxx/hwtstamp.c
@@ -72,7 +72,7 @@ int mv88e6xxx_get_ts_info(struct dsa_switch *ds, int port,
chip = ds->priv;
ptp_ops = chip->info->ops->ptp_ops;
- if (!chip->info->ptp_support)
+ if (!chip->info->ptp_support || !chip->ptp_clock)
return -EOPNOTSUPP;
info->so_timestamping =
@@ -176,7 +176,7 @@ int mv88e6xxx_port_hwtstamp_set(struct dsa_switch *ds, int port,
struct mv88e6xxx_port_hwtstamp *ps = &chip->port_hwtstamp[port];
int err;
- if (!chip->info->ptp_support)
+ if (!chip->info->ptp_support || !chip->ptp_clock)
return -EOPNOTSUPP;
err = mv88e6xxx_set_hwtstamp_config(chip, port, config);
@@ -195,7 +195,7 @@ int mv88e6xxx_port_hwtstamp_get(struct dsa_switch *ds, int port,
struct mv88e6xxx_chip *chip = ds->priv;
struct mv88e6xxx_port_hwtstamp *ps = &chip->port_hwtstamp[port];
- if (!chip->info->ptp_support)
+ if (!chip->info->ptp_support || !chip->ptp_clock)
return -EOPNOTSUPP;
*config = ps->tstamp_config;
@@ -213,7 +213,7 @@ static struct ptp_header *mv88e6xxx_should_tstamp(struct mv88e6xxx_chip *chip,
struct mv88e6xxx_port_hwtstamp *ps = &chip->port_hwtstamp[port];
struct ptp_header *hdr;
- if (!chip->info->ptp_support)
+ if (!chip->info->ptp_support || !chip->ptp_clock)
return NULL;
hdr = ptp_parse_header(skb, type);
---
base-commit: 6c096bb08de97cdca051fecddad22cac6a1fd275
change-id: 20260919-send-net-97aa5653ac48
Best regards,
--
Nicolo Giuliani <nicolo.giuliani6@studio.unibo.it>
next reply other threads:[~2026-09-19 19:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-19 19:52 Nicolo Giuliani via B4 Relay [this message]
2026-09-20 14:48 ` [PATCH net] net: dsa: mv88e6xxx: continue without PTP if the TAI period is invalid Andrew Lunn
2026-09-20 17:34 ` R: " Nicolò Giuliani - nicolo.giuliani6@studio.unibo.it
2026-09-20 18:58 ` Andrew Lunn
2026-09-20 19:08 ` R: " Nicolò Giuliani - nicolo.giuliani6@studio.unibo.it
2026-09-20 21:21 ` Andrew Lunn
2026-09-21 3:58 ` R: " Nicolò Giuliani - nicolo.giuliani6@studio.unibo.it
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=20260919-send-net-v1-1-4355c72465ee@studio.unibo.it \
--to=devnull+nicolo.giuliani6.studio.unibo.it@kernel.org \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nicolo.giuliani6@studio.unibo.it \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=richardcochran@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox