linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Levi Pearson <levipearson@gmail.com>
To: Richard Cochran <richardcochran@gmail.com>
Cc: Brandon Streiff <brandon.streiff@ni.com>,
	Linux Kernel Network Developers <netdev@vger.kernel.org>,
	linux-kernel@vger.kernel.org,
	"David S. Miller" <davem@davemloft.net>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Andrew Lunn <andrew@lunn.ch>,
	Vivien Didelot <vivien.didelot@savoirfairelinux.com>,
	Erik Hons <erik.hons@ni.com>
Subject: Re: [PATCH net-next RFC 4/9] net: dsa: mv88e6xxx: add support for event capture
Date: Mon, 9 Oct 2017 16:08:50 -0600	[thread overview]
Message-ID: <CAEYbN3TpMVPVapmLNCPj69pxP9b_1y8VizS3XvccskcWOrpwEw@mail.gmail.com> (raw)
In-Reply-To: <20171008150634.hb7nxwbbmi5xff7m@localhost>

On Sun, Oct 8, 2017 at 9:06 AM, Richard Cochran
<richardcochran@gmail.com> wrote:

>> +static int mv88e6xxx_ptp_enable_perout(struct mv88e6xxx_chip *chip,
>> +                                    struct ptp_clock_request *rq, int on)
>> +{
>> +     struct timespec ts;
>> +     u64 ns;
>> +     int pin;
>> +     int err;
>> +
>> +     pin = ptp_find_pin(chip->ptp_clock, PTP_PF_PEROUT, rq->extts.index);
>> +
>> +     if (pin < 0)
>> +             return -EBUSY;
>> +
>> +     ts.tv_sec = rq->perout.period.sec;
>> +     ts.tv_nsec = rq->perout.period.nsec;
>> +     ns = timespec_to_ns(&ts);
>> +
>> +     if (ns > U32_MAX)
>> +             return -ERANGE;
>> +
>> +     mutex_lock(&chip->reg_lock);
>> +
>> +     err = mv88e6xxx_config_periodic_trig(chip, (u32)ns, 0);
>
> Here you ignore the phase of the signal given in the trq->perout.start
> field.  That is not what the user expects.  For periodic outputs where
> the phase cannot be set, we really would need a new ioctl.
>
> However, in this case, you should just drop this functionality.  I
> understand that this works with your adjustable external oscillator,
> but we cannot support that in mainline (at least, not yet).

I've been working with this patchset and just came across this
limitation as well. The periodic timer output is the basis of the Qbv
t0 timer in devices that support Qbv, and setting this up with the
correct start time is pretty important in that context. The hardware
does support setting a start time, but it must be specified according
to the cycle count of the free-running timer rather than a nanosecond
value. I think this can be worked out from the values stored in the
timecounter struct and I'm writing some code for it now, but if you've
already written something I'd be happy to integrate that instead.

Another issue related to this is that while the free-running counter
in the hardware can't be easily adjusted, the periodic event generator
*can* be finely adjusted (via picosecond and sub-picosecond
accumulators) to correct for drift between the local clock and the PTP
grandmaster time. So to be semantically correct, this needs to be both
started at the right time *and* it needs to have the periodic
corrections made so that the fine correction parameters in the
hardware keep it adjusted to be synchronous with PTP grandmaster time.

So, taking this functionality out in the first pass seems like a good
move for Brandon to take, but I'm working on a complete implementation
for it. I think I've got a handle on how to do it, but if you have any
suggestions, I'm open to them.


Levi

  reply	other threads:[~2017-10-09 22:08 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-28 15:25 [PATCH net-next RFC 0/9] net: dsa: PTP timestamping for mv88e6xxx Brandon Streiff
2017-09-28 15:25 ` [PATCH net-next RFC 1/9] net: dsa: mv88e6xxx: add accessors for PTP/TAI registers Brandon Streiff
2017-09-28 16:29   ` Vivien Didelot
2017-10-08 14:32   ` Richard Cochran
2017-09-28 15:25 ` [PATCH net-next RFC 2/9] net: dsa: mv88e6xxx: expose switch time as a PTP hardware clock Brandon Streiff
2017-09-28 16:56   ` Andrew Lunn
2017-09-29 15:28     ` Brandon Streiff
2017-10-08 11:59       ` Richard Cochran
2017-09-28 17:03   ` Andrew Lunn
2017-09-29 15:17     ` Brandon Streiff
2017-10-08 12:07       ` Richard Cochran
2017-10-08 14:52   ` Richard Cochran
2017-09-28 15:25 ` [PATCH net-next RFC 3/9] net: dsa: mv88e6xxx: add support for GPIO configuration Brandon Streiff
2017-09-28 17:45   ` Florian Fainelli
2017-09-28 18:01     ` Andrew Lunn
2017-09-28 19:57       ` Vivien Didelot
2017-09-29 15:30       ` Brandon Streiff
2017-09-28 15:25 ` [PATCH net-next RFC 4/9] net: dsa: mv88e6xxx: add support for event capture Brandon Streiff
2017-10-08 15:06   ` Richard Cochran
2017-10-09 22:08     ` Levi Pearson [this message]
2017-10-10  1:53       ` Richard Cochran
2017-09-28 15:25 ` [PATCH net-next RFC 5/9] net: dsa: forward hardware timestamping ioctls to switch driver Brandon Streiff
2017-09-28 17:25   ` Florian Fainelli
2017-10-08 13:12     ` Richard Cochran
2017-09-28 19:31   ` Vivien Didelot
2017-09-28 15:25 ` [PATCH net-next RFC 6/9] net: dsa: forward timestamping callbacks to switch drivers Brandon Streiff
2017-09-28 17:40   ` Florian Fainelli
2017-09-29 15:30     ` Brandon Streiff
2017-09-28 15:25 ` [PATCH net-next RFC 7/9] ptp: add offset for reserved field to header Brandon Streiff
2017-09-28 15:25 ` [PATCH net-next RFC 8/9] net: dsa: mv88e6xxx: add rx/tx timestamping support Brandon Streiff
2017-10-08 14:24   ` Richard Cochran
2017-10-08 15:12   ` Richard Cochran
2017-10-08 15:29   ` Richard Cochran
2017-09-28 15:25 ` [PATCH net-next RFC 9/9] net: dsa: mv88e6xxx: add workaround for 6341 timestamping Brandon Streiff
2017-09-28 17:36 ` [PATCH net-next RFC 0/9] net: dsa: PTP timestamping for mv88e6xxx Andrew Lunn
2017-09-28 17:51   ` Florian Fainelli
2017-09-29 15:34   ` Brandon Streiff
2017-09-29  9:43 ` Richard Cochran
2017-10-08 15:38   ` Richard Cochran
2017-11-06 14:55     ` Richard Cochran
2017-11-06 15:04       ` Andrew Lunn
2017-11-07 18:15         ` Richard Cochran
2017-11-07 18:13       ` Richard Cochran
2017-11-07 20:56         ` Brandon Streiff
2017-11-08  0:09           ` Andrew Lunn
2017-11-08  3:02           ` Andrew Lunn
2017-11-08  3:23             ` Richard Cochran
2017-12-04  1:13               ` 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=CAEYbN3TpMVPVapmLNCPj69pxP9b_1y8VizS3XvccskcWOrpwEw@mail.gmail.com \
    --to=levipearson@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=brandon.streiff@ni.com \
    --cc=davem@davemloft.net \
    --cc=erik.hons@ni.com \
    --cc=f.fainelli@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=richardcochran@gmail.com \
    --cc=vivien.didelot@savoirfairelinux.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).