From: Richard Cochran <richardcochran@gmail.com>
To: Antoine Tenart <antoine.tenart@bootlin.com>
Cc: davem@davemloft.net, alexandre.belloni@bootlin.com,
UNGLinuxDriver@microchip.com, ralf@linux-mips.org,
paul.burton@mips.com, jhogan@kernel.org, netdev@vger.kernel.org,
linux-mips@vger.kernel.org, thomas.petazzoni@bootlin.com,
allan.nielsen@microchip.com
Subject: Re: [PATCH net-next 8/8] net: mscc: PTP Hardware Clock (PHC) support
Date: Fri, 5 Jul 2019 09:47:36 -0700 [thread overview]
Message-ID: <20190705164736.x6dy2oc6jo5db65v@localhost> (raw)
In-Reply-To: <20190701100327.6425-9-antoine.tenart@bootlin.com>
On Mon, Jul 01, 2019 at 12:03:27PM +0200, Antoine Tenart wrote:
> +void ocelot_get_hwtimestamp(struct ocelot *ocelot, struct timespec64 *ts)
> +{
> + /* Read current PTP time to get seconds */
> + u32 val = ocelot_read_rix(ocelot, PTP_PIN_CFG, TOD_ACC_PIN);
This register is protected by ocelot->ptp_clock_lock from other code
paths, but not in this one!
> + val &= ~(PTP_PIN_CFG_SYNC | PTP_PIN_CFG_ACTION_MASK | PTP_PIN_CFG_DOM);
> + val |= PTP_PIN_CFG_ACTION(PTP_PIN_ACTION_SAVE);
> + ocelot_write_rix(ocelot, val, PTP_PIN_CFG, TOD_ACC_PIN);
> + ts->tv_sec = ocelot_read_rix(ocelot, PTP_PIN_TOD_SEC_LSB, TOD_ACC_PIN);
...
> +}
> +static int ocelot_init_timestamp(struct ocelot *ocelot)
> +{
> + ocelot->ptp_info = ocelot_ptp_clock_info;
> +
> + ocelot->ptp_clock = ptp_clock_register(&ocelot->ptp_info, ocelot->dev);
> + if (IS_ERR(ocelot->ptp_clock))
> + return PTR_ERR(ocelot->ptp_clock);
You need to handle the NULL case:
ptp_clock_register() - register a PTP hardware clock driver
@info: Structure describing the new clock.
@parent: Pointer to the parent device of the new clock.
Returns a valid pointer on success or PTR_ERR on failure. If PHC
support is missing at the configuration level, this function
returns NULL, and drivers are expected to gracefully handle that
case separately.
> +
> + ocelot_write(ocelot, SYS_PTP_CFG_PTP_STAMP_WID(30), SYS_PTP_CFG);
> + ocelot_write(ocelot, 0xffffffff, ANA_TABLES_PTP_ID_LOW);
> + ocelot_write(ocelot, 0xffffffff, ANA_TABLES_PTP_ID_HIGH);
> +
> + ocelot_write(ocelot, PTP_CFG_MISC_PTP_EN, PTP_CFG_MISC);
> +
> + return 0;
> +}
Thanks,
Richard
next prev parent reply other threads:[~2019-07-05 16:47 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-01 10:03 [PATCH net-next 0/8] net: mscc: PTP Hardware Clock (PHC) support Antoine Tenart
2019-07-01 10:03 ` [PATCH net-next 1/8] Documentation/bindings: net: ocelot: document the PTP bank Antoine Tenart
2019-07-01 13:52 ` Andrew Lunn
2019-07-05 13:30 ` Antoine Tenart
2019-07-05 14:45 ` Andrew Lunn
2019-07-05 16:39 ` Antoine Tenart
2019-07-01 10:03 ` [PATCH net-next 2/8] MIPS: dts: mscc: describe the PTP register range Antoine Tenart
2019-07-01 10:03 ` [PATCH net-next 3/8] Documentation/bindings: net: ocelot: document the PTP ready IRQ Antoine Tenart
2019-07-01 13:54 ` Andrew Lunn
2019-07-01 10:03 ` [PATCH net-next 4/8] MIPS: dts: mscc: describe the PTP ready interrupt Antoine Tenart
2019-07-01 10:03 ` [PATCH net-next 5/8] net: mscc: describe the PTP register range Antoine Tenart
2019-07-01 10:03 ` [PATCH net-next 6/8] net: mscc: improve the frame header parsing readability Antoine Tenart
2019-07-01 10:03 ` [PATCH net-next 7/8] net: mscc: remove the frame_info cpuq member Antoine Tenart
2019-07-01 10:03 ` [PATCH net-next 8/8] net: mscc: PTP Hardware Clock (PHC) support Antoine Tenart
2019-07-01 15:12 ` Willem de Bruijn
2019-07-01 15:54 ` Eric Dumazet
2019-07-05 7:49 ` Antoine Tenart
2019-07-05 7:47 ` Antoine Tenart
2019-07-04 12:48 ` kbuild test robot
2019-07-05 16:47 ` Richard Cochran [this message]
2019-07-05 17:16 ` Antoine Tenart
2019-07-05 21:58 ` 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=20190705164736.x6dy2oc6jo5db65v@localhost \
--to=richardcochran@gmail.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=alexandre.belloni@bootlin.com \
--cc=allan.nielsen@microchip.com \
--cc=antoine.tenart@bootlin.com \
--cc=davem@davemloft.net \
--cc=jhogan@kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=paul.burton@mips.com \
--cc=ralf@linux-mips.org \
--cc=thomas.petazzoni@bootlin.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;
as well as URLs for NNTP newsgroup(s).