mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Martin Povišer" <povik+lin@cutebit.org>
To: Jacob Procee <sn125164@gmail.com>
Cc: Vinod Koul <vkoul@kernel.org>, Frank Li <Frank.Li@kernel.org>,
	Sven Peter <sven@kernel.org>, Janne Grunau <j@jannau.net>,
	Neal Gompa <neal@gompa.dev>,
	asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
	dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] dmaengine: apple-admac: Fix position one period ahead at period boundary
Date: Mon, 2 Nov 2026 17:40:09 +0100	[thread overview]
Message-ID: <774174DF-C530-4BA5-93D5-879D3D4E27D9@cutebit.org> (raw)
In-Reply-To: <03f2dae1-453b-42ce-a3fa-e444906bb1bc@gmail.com>


> On 2. 11. 2026, at 10:45, Jacob Procee <sn125164@gmail.com> wrote:
> 
> On 10/30/26 08:35, Jacob Procee wrote:
>> Thanks for the ack and the extra background info. I would love to take a
>> look at a race-free version of admac_cyclic_read_residue() as a separate
>> follow-up patch; v2 of this fix follows shortly.
> Hello Martin,
> 
> I looked into this using REG_DESC_RING. It only contains descriptors
> that the hardware hasn't fetched yet, and its read slot is effectively
> the hardware's fetch pointer.
> 
> Unfortunately, it isn't updated atomically with the residue reload
> either. Across 1.49 M reads, I hit 126 period boundaries. In 4 cases,
> DESC_RING still showed the old state even though the residue had already
> reloaded. In another case, DESC_RING had advanced while the residue was
> still 0 and no report had been posted. So I don't see a way to get a
> consistent, retry-free read from these registers.
> 
> One could make the retry check more comprehensive by using three
> counters: outstanding = queued + playing + reported, with playing being
> 1 unless the residue is 0. This would also catch the reverse ordering,
> where the report is posted after the descriptor is loaded, which the v2
> check doesn't cover.
> 
> However, I left the debug module running overnight (10.65 h, with music
> playing through the speakers), and never observed that reverse ordering.
> There were no XRuns or backward steps. The speaker channel had 96.6 M
> reads and 15,483 boundary hits; the second channel had 29.3 M reads and
> 86 hits.
> 
> All 1,498 snapshots that failed the three-counter check were explained
> by read skew: 822 where DESC_RING was read before the fetch while the
> residue was already full, and 676 where it was read after the fetch
> while the residue was still 0. The positions returned to ALSA never
> stepped backwards.
> 
> Given that the more complicated check would only handle a case I haven't
> observed, I'd prefer to stick with the simpler v2 retry.
> 
> Unless you know something about the hardware ordering that these traces
> wouldn't show, I'd prefer to stick with the simpler v2 retry.
> 
> Kind regards,
> Jacob

Hi Jacob,

I don’t think it’s worth doing the more complicated check either. Your v2 patch looks to be good enough given the available information. Perhaps there’s a way to do the residue read race free by involving additional features of the block incl. registers the driver currently ignores but until someone discovers it I support going with your patch.

Best regards,
Martin


      reply	other threads:[~2026-11-02 16:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-29 10:59 Jacob Procee
2026-10-29 15:02 ` Frank Li
2026-10-29 15:15 ` Sasha Finkelstein
2026-10-29 16:10 ` Martin Povišer
2026-10-30  7:35   ` Jacob Procee
2026-11-02  9:45     ` Jacob Procee
2026-11-02 16:40       ` Martin Povišer [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=774174DF-C530-4BA5-93D5-879D3D4E27D9@cutebit.org \
    --to=povik+lin@cutebit.org \
    --cc=Frank.Li@kernel.org \
    --cc=asahi@lists.linux.dev \
    --cc=dmaengine@vger.kernel.org \
    --cc=j@jannau.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=neal@gompa.dev \
    --cc=sn125164@gmail.com \
    --cc=sven@kernel.org \
    --cc=vkoul@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

all inboxes | Powered by JetHome®