From: Richard Cochran <richardcochran@gmail.com>
To: Michael Walle <michael@walle.cc>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Andrew Lunn <andrew@lunn.ch>,
Florian Fainelli <f.fainelli@gmail.com>,
Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
"David S . Miller" <davem@davemloft.net>
Subject: Re: [RFC PATCH v2 2/2] net: phy: at803x: add PTP support for AR8031
Date: Sun, 1 Mar 2020 04:22:11 -0800 [thread overview]
Message-ID: <20200301122211.GA32253@localhost> (raw)
In-Reply-To: <20200228180226.22986-3-michael@walle.cc>
On Fri, Feb 28, 2020 at 07:02:26PM +0100, Michael Walle wrote:
> +static int at8031_rtc_adjust(struct phy_device *phydev, s64 delta)
> +{
> + struct timespec64 ts = ns_to_timespec64(delta);
> + int ret;
Here the 'ts' is written in multiple steps,
> + ret = phy_write_mmd(phydev, MDIO_MMD_PCS,
> + AT8031_MMD3_RTC_OFFSET_SEC_2,
> + (ts.tv_sec >> 32) & 0xffff);
> + if (ret)
> + return ret;
> +
> + ret = phy_write_mmd(phydev, MDIO_MMD_PCS,
> + AT8031_MMD3_RTC_OFFSET_SEC_1,
> + (ts.tv_sec >> 16) & 0xffff);
> + if (ret)
> + return ret;
> +
> + ret = phy_write_mmd(phydev, MDIO_MMD_PCS,
> + AT8031_MMD3_RTC_OFFSET_SEC_0,
> + ts.tv_sec & 0xffff);
> + if (ret)
> + return ret;
> +
> + ret = phy_write_mmd(phydev, MDIO_MMD_PCS,
> + AT8031_MMD3_RTC_OFFSET_NSEC_1,
> + (ts.tv_nsec >> 16) & 0xffff);
> + if (ret)
> + return ret;
> +
> + ret = phy_write_mmd(phydev, MDIO_MMD_PCS,
> + AT8031_MMD3_RTC_OFFSET_NSEC_0,
> + ts.tv_nsec & 0xffff);
> + if (ret)
> + return ret;
> +
> + return phy_write_mmd(phydev, MDIO_MMD_PCS, AT8031_MMD3_RTC_ADJUST,
> + AT8031_RTC_ADJUST);
> +}
...
> +static int at8031_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
> +{
> + struct at803x_priv *priv =
> + container_of(ptp, struct at803x_priv, ptp_info);
> + struct phy_device *phydev = priv->phydev;
> +
> + return at8031_rtc_adjust(phydev, delta);
> +}
... and here there is no locking. You would need a mutex here and
elsewhere to prevent multiple readers/writers from accessing the
device registers asynchronously.
(I know this is a just a RFC and that there are bigger problems with
the HW, but just saying.)
Thanks,
Richard
next prev parent reply other threads:[~2020-03-01 12:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-28 18:02 [RFC PATCH v2 0/2] AT8031 PHY timestamping support Michael Walle
2020-02-28 18:02 ` [RFC PATCH v2 1/2] net: phy: let the driver register its own IRQ handler Michael Walle
2020-02-28 18:02 ` [RFC PATCH v2 2/2] net: phy: at803x: add PTP support for AR8031 Michael Walle
2020-03-01 12:22 ` Richard Cochran [this message]
2020-02-28 18:15 ` [RFC PATCH v2 0/2] AT8031 PHY timestamping support Richard Cochran
2020-02-28 19:43 ` Michael Walle
2020-02-29 14:48 ` Richard Cochran
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=20200301122211.GA32253@localhost \
--to=richardcochran@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=michael@walle.cc \
--cc=netdev@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).