From: Andrew Lunn <andrew@lunn.ch>
To: Shenghao Yang <me@shenghaoyang.info>
Cc: netdev@vger.kernel.org, f.fainelli@gmail.com, olteanv@gmail.com,
pavana.sharma@digi.com, ashkan.boldaji@digi.com,
kabel@kernel.org
Subject: Re: [PATCH net 2/3] net: dsa: mv88e6xxx: read cycle counter period from hardware
Date: Mon, 30 Sep 2024 17:31:46 +0200 [thread overview]
Message-ID: <36b11f88-f5d2-41a2-877e-e231c2985f30@lunn.ch> (raw)
In-Reply-To: <20240929101949.723658-3-me@shenghaoyang.info>
> +static const struct mv88e6xxx_cc_coeffs *
> +mv88e6xxx_cc_coeff_get(struct mv88e6xxx_chip *chip)
> +{
> + u16 period_ps;
> + int err;
> +
> + err = mv88e6xxx_tai_read(chip, MV88E6XXX_TAI_CLOCK_PERIOD, &period_ps, 1);
> + if (err) {
> + dev_warn(chip->dev, "failed to read cycle counter period");
> + return chip->info->ops->ptp_ops->default_cc_coeffs;
> + }
> +
> + switch (period_ps) {
> + case 8000:
> + return &mv88e6xxx_cc_8ns_coeffs;
> + case 10000:
> + return &mv88e6xxx_cc_10ns_coeffs;
> + default:
> + dev_warn(chip->dev, "unexpected cycle counter period of %u ps",
> + period_ps);
> + return chip->info->ops->ptp_ops->default_cc_coeffs;
This chip mv88e6xxx_cc_coeffs vs ptp_ops mv88e6xxx_cc_coeffs all seems
a bit messy.
The mv88e6xxx_tai_read() MV88E6XXX_TAI_CLOCK_PERIOD is not going to
fail, except for the hardware is dead. There is nothing you can do
about that, so return the error code and let the probe fail.
What you are more worried about is if the value you get back is not
what you expect. It is not 8000 or 10000. I would do a dev_err() and
return -ENODEV, and let the probe fail. The datasheets suggests this
should not happen. But if it does, we should get reports from users
that PTP is issuing an error and the switch is not probing. We can
then fix the problem.
You can then drop mv88e6xxx_cc_coeffs from ptp_ops.
Andrew
---
pw-bot: cr
next prev parent reply other threads:[~2024-09-30 15:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-29 10:19 [PATCH net 0/3] net: dsa: mv88e6xxx: fix MV88E6393X PHC frequency on internal clock Shenghao Yang
2024-09-29 10:19 ` [PATCH net 1/3] net: dsa: mv88e6xxx: group cycle counter coefficients Shenghao Yang
2024-09-30 15:14 ` Andrew Lunn
2024-09-29 10:19 ` [PATCH net 2/3] net: dsa: mv88e6xxx: read cycle counter period from hardware Shenghao Yang
2024-09-30 15:31 ` Andrew Lunn [this message]
2024-10-05 11:17 ` Shenghao Yang
2024-10-01 4:17 ` kernel test robot
2024-09-29 10:19 ` [PATCH net 3/3] net: dsa: mv88e6xxx: support 4000ps cycle counter period Shenghao Yang
2024-10-01 7:32 ` kernel test robot
2024-09-30 14:51 ` [PATCH net 0/3] net: dsa: mv88e6xxx: fix MV88E6393X PHC frequency on internal clock 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=36b11f88-f5d2-41a2-877e-e231c2985f30@lunn.ch \
--to=andrew@lunn.ch \
--cc=ashkan.boldaji@digi.com \
--cc=f.fainelli@gmail.com \
--cc=kabel@kernel.org \
--cc=me@shenghaoyang.info \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pavana.sharma@digi.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.