From: David Laight <david.laight.linux@gmail.com>
To: Mark Brown <broonie@kernel.org>
Cc: "Peter Collingbourne" <peter@pcc.me.uk>,
"Jani Nikula" <jani.nikula@intel.com>,
"Ville Syrjälä" <ville.syrjala@linux.intel.com>,
"Christophe Kerello" <christophe.kerello@foss.st.com>,
"Patrice Chotard" <patrice.chotard@foss.st.com>,
"Boris Brezillon" <boris.brezillon@collabora.com>,
linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org,
"Simona Vetter" <simona.vetter@ffwll.ch>,
"Randy Dunlap" <rdunlap@infradead.org>
Subject: Re: [PATCH v2] iopoll: use udelay() for initial polling
Date: Sat, 30 May 2026 11:20:25 +0100 [thread overview]
Message-ID: <20260530112025.66897837@pumpkin> (raw)
In-Reply-To: <19509a36-cf7b-4f2b-a25c-2c1293c19b6c@sirena.org.uk>
On Fri, 29 May 2026 22:56:23 +0100
Mark Brown <broonie@kernel.org> wrote:
> On Fri, May 29, 2026 at 12:20:16PM +0100, David Laight wrote:
>
> > I think I remember someone saying that the spi hardware interface normally
> > generates an interrupt when the request completes?
> > So for spi this is only fall-back code for a few systems.
>
> For something like spi-mem I'd expect to have interrupt support, we go
> all the way down to fully bitbanged though. You also often have
> copybreak cutoffs for smaller transfers (and quicker operations) where
> it's more efficient to poll for completion than use an interrupt, or
> PIO rather than DMA.
I do wonder about copybreak cutoffs especially for systems with iommu
(which has started including x86 systems).
Many years ago a colleague got a figure of ~1200 bytes for a sparc sbus card.
I suspect that the iommu setup code has got more complex (and slower)
since then and the memory copies faster (especially if you can do overlong
aligned copies that include the required data).
For spi-mem writes (max size is probably 256 bytes) that take 100s of us
it is best the sleep (for timer or isr).
spi-mem reads are another matter since the only delays are those needed
to bit-bang the physical device - which might be at over 100MHz and 4
(or even 8) data bits at a time.
Possibly worth using DMA for the data (to avoid leisurely PCIe reads)
but polling (ideally host memory) for completion to avoid the cost
of the ISR as well as avoiding context switches.
For the much slower smbus and i2c you pretty much always want to
offload the 'bit bang' to hardware and wait for an interrupts.
(I've seen ethernet drivers 'bugger' the system by repeatedly reading
the phy status - that could be done 1 bit every timer interrupt.)
>
> > The code has this comment:
> > /* Wait for the write - typically 0.6ms (max 5ms).
> > * In spite of the datasheet values, I'm seeing 200us writes. */
> > It waits 200us and then polls every 50us for 2 seconds.
FWIW I wrote the comment, the code below it, and the logic on the fpga
that converts the PCIe slave cycles into signals to the memory chip.
What I/we never resolved was why some chips/boards failed to act on
the 'read status' command issued after the first delay.
> You can also get fun with things like contention on shared buses.
Indeed - and in places you don't realise.
In some cases repeated reads of a slow device can restrict bus throughput
enough to make DMA requests underrun (eg trying to use an LCD panel on
a SA1100/SA1101 strongarm system).
-- David
prev parent reply other threads:[~2026-05-30 10:20 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-19 10:24 [PATCH v2] iopoll: use udelay() for initial polling Peter Collingbourne
2026-05-19 18:35 ` David Laight
2026-05-20 7:38 ` Peter Collingbourne
2026-05-20 13:29 ` Ville Syrjälä
2026-05-21 5:59 ` Peter Collingbourne
2026-05-21 7:03 ` Jani Nikula
2026-05-22 14:50 ` Mark Brown
2026-05-29 5:59 ` Peter Collingbourne
2026-05-29 11:20 ` David Laight
2026-05-29 21:56 ` Mark Brown
2026-05-30 10:20 ` David Laight [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=20260530112025.66897837@pumpkin \
--to=david.laight.linux@gmail.com \
--cc=boris.brezillon@collabora.com \
--cc=broonie@kernel.org \
--cc=christophe.kerello@foss.st.com \
--cc=jani.nikula@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=patrice.chotard@foss.st.com \
--cc=peter@pcc.me.uk \
--cc=rdunlap@infradead.org \
--cc=simona.vetter@ffwll.ch \
--cc=ville.syrjala@linux.intel.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.