All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Oltean <olteanv@gmail.com>
To: Mark Brown <broonie@kernel.org>
Cc: h.feurstein@gmail.com, mlichvar@redhat.com,
	richardcochran@gmail.com, andrew@lunn.ch, f.fainelli@gmail.com,
	linux-spi@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH v2 0/4] Deterministic SPI latency with NXP DSPI driver
Date: Mon, 9 Sep 2019 15:08:26 +0100	[thread overview]
Message-ID: <CA+h21hocjvF_-cvGEgank3_tgVBfCQLtp2seLguOCp0S=cx9Jw@mail.gmail.com> (raw)
In-Reply-To: <20190909100618.GC2036@sirena.org.uk>

Hi Mark,

On 09/09/2019, Mark Brown <broonie@kernel.org> wrote:
> On Thu, Sep 05, 2019 at 04:01:10AM +0300, Vladimir Oltean wrote:
>
>> This patchset proposes an interface from the SPI subsystem for
>> software timestamping SPI transfers. There is a default implementation
>> provided in the core, as well as a mechanism for SPI slave drivers to
>> check which byte was in fact timestamped post-facto. The patchset also
>> adds the first user of this interface (the NXP DSPI driver in TCFQ mode).
>
> I think this is about as good as we're going to get but we're
> very near the merge window now so I'll leave this until after the
> merge window is done in case there's more review comments before
> applying.  I need to reread the implementation code a bit as
> well, it looked fine on a first scan through but it's possible I
> might spot something later.
>

There's one thing I still don't like, and that is the fact that the
delay for sending one SPI word is so low, I can't actually capture it
precisely with a "pre" and a "post" system clock timestamp. What
actually happens is that I'm actually measuring the timing of the (too
loose) CPU loop. Normally that's not bad, because the guarantee that
the transfer happened between "pre" and "post" is still kept. But I'm
introducing a false jitter in the delays I'm reporting ("post" -
"pre") that does not actually depend upon the hardware phenomenon, but
on the CPU frequency :) At maximum CPU frequency (performance
governor) the reported latency is always constant, but still larger
than the SPI transfer time. In fact it's constant exactly _because_
the CPU frequency is constant. When the CPU goes at lower frequencies,
user space gets confused about the varying delay and my control loop
doesn't keep lock as well.
So in fact I wonder whether I'm using the PTP system timestamping API
properly. One idea I had was to just timestamp the write to the TX
FIFO, and add a constant delay based on bytes_per_word * (NSEC_PER_SEC
/ speed_hz). IMHO that correction should logically be applied to both
"pre" and "post". Then say that the "post" is equal to the "pre". But
that would mean I'm reporting a delay of zero, and losing the
guarantee that the transfer actually happens between the reported
"pre" and "post". On the other hand, introducing a static correction
option could potentially help with the drivers that just get notified
of a DMA completion.
The other idea was to just push the PTP system timestamping all the
way into regmap_write, and just minimize the governor effect by making
sure the timestamped area of code is really short. I don't really
know.

      reply	other threads:[~2019-09-09 14:08 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-05  1:01 [PATCH v2 0/4] Deterministic SPI latency with NXP DSPI driver Vladimir Oltean
2019-09-05  1:01 ` [PATCH v2 1/4] spi: Use an abbreviated pointer to ctlr->cur_msg in __spi_pump_messages Vladimir Oltean
2019-09-05 17:39   ` Applied "spi: Use an abbreviated pointer to ctlr->cur_msg in __spi_pump_messages" to the spi tree Mark Brown
2019-09-05 17:39     ` Mark Brown
2019-09-05  1:01 ` [PATCH v2 2/4] spi: Add a PTP system timestamp to the transfer structure Vladimir Oltean
2019-10-08 10:52   ` Applied "spi: Add a PTP system timestamp to the transfer structure" to the spi tree Mark Brown
2019-10-08 10:52     ` Mark Brown
2019-10-08 12:58     ` Vladimir Oltean
2019-10-08 16:42       ` Mark Brown
2019-10-09 22:13         ` Jakub Kicinski
2019-10-09 22:57           ` Vladimir Oltean
2019-10-08 18:09   ` Mark Brown
2019-10-08 18:09     ` Mark Brown
2019-09-05  1:01 ` [PATCH v2 3/4] spi: spi-fsl-dspi: Implement the PTP system timestamping for TCFQ mode Vladimir Oltean
2019-10-08 10:52   ` Applied "spi: spi-fsl-dspi: Implement the PTP system timestamping for TCFQ mode" to the spi tree Mark Brown
2019-10-08 10:52     ` Mark Brown
2019-09-05  1:01 ` [PATCH v2 4/4] spi: spi-fsl-dspi: Always use the TCFQ devices in poll mode Vladimir Oltean
2019-10-08 10:52   ` Applied "spi: spi-fsl-dspi: Always use the TCFQ devices in poll mode" to the spi tree Mark Brown
2019-10-08 10:52     ` Mark Brown
2019-09-09 10:06 ` [PATCH v2 0/4] Deterministic SPI latency with NXP DSPI driver Mark Brown
2019-09-09 14:08   ` Vladimir Oltean [this message]

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='CA+h21hocjvF_-cvGEgank3_tgVBfCQLtp2seLguOCp0S=cx9Jw@mail.gmail.com' \
    --to=olteanv@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=broonie@kernel.org \
    --cc=f.fainelli@gmail.com \
    --cc=h.feurstein@gmail.com \
    --cc=linux-spi@vger.kernel.org \
    --cc=mlichvar@redhat.com \
    --cc=netdev@vger.kernel.org \
    --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 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.