All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Cássio Gabriel Monteiro Pires" <cassiogabrielcontato@gmail.com>
To: Takashi Iwai <tiwai@suse.de>
Cc: Mark Brown <broonie@kernel.org>, Vinod Koul <vkoul@kernel.org>,
	Jaroslav Kysela <perex@perex.cz>,
	linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] ALSA: compress: Propagate real pointer errors in avail paths
Date: Wed, 15 Apr 2026 16:29:31 -0300	[thread overview]
Message-ID: <64413e7d-cd98-433a-90db-ad9f9854df56@gmail.com> (raw)
In-Reply-To: <87cy00fgp7.wl-tiwai@suse.de>


[-- Attachment #1.1: Type: text/plain, Size: 3046 bytes --]



On 4/15/26 11:20, Takashi Iwai wrote:
> On Tue, 14 Apr 2026 19:45:52 +0200,
> Cássio Gabriel Monteiro Pires wrote:
>>
>> On 4/14/26 13:53, Mark Brown wrote:
>>> On Tue, Apr 14, 2026 at 01:47:54PM -0300, Cássio Gabriel wrote:
>>>
>>>> Commit 61327f3d817c ("ALSA: compress: Pay attention if drivers
>>>> error out retrieving pointers") made snd_compr_update_tstamp()
>>>> return driver pointer() failures, but snd_compr_calc_avail()
>>>> still ignores that status and continues with stale runtime
>>>> counters.
>>>
>>>> The fallback for an unsupported pointer callback remains
>>>> intentional, so keep ignoring -EOPNOTSUPP there. Propagate
>>>> real pointer-refresh failures instead.
>>>
>>>> -static size_t snd_compr_calc_avail(struct snd_compr_stream *stream,
>>>> -				   struct snd_compr_avail64 *avail)
>>>> +static int snd_compr_calc_avail(struct snd_compr_stream *stream,
>>>> +				struct snd_compr_avail64 *avail)
>>>>  {
>>>> +	int ret;
>>>> +
>>>>  	memset(avail, 0, sizeof(*avail));
>>>> -	snd_compr_update_tstamp(stream, &avail->tstamp);
>>>> -	/* Still need to return avail even if tstamp can't be filled in */
>>>> +	ret = snd_compr_update_tstamp(stream, &avail->tstamp);
>>>> +	if (ret < 0 && ret != -EOPNOTSUPP)
>>>> +		return ret;
>>>> +	/* Still need to return avail when no timestamp is available */
>>>
>>> It's not clear to me that the intent there is to only ignore in the case
>>> where we fail to update due to the operation not being supported rather
>>> than to also ignore any other runtime errors we might encounter (eg, due
>>> to the stream configuration).
>>
>> Cool, thanks for replying!
>>
>> I rechecked the current tree, and the hard-failure class does exist:
>> wm_adsp_compr_pointer() can return -EIO and switch the stream to
>> XRUN when dsp->fatal_error, !buf, or buf->error, so that is a
>> real in-tree case where pointer() failure means the stream itself is
>> broken rather than timestamp data simply being unavailable.
>>
>> That said, I agree this does not fully justify the generic change as I
>> sent it. In particular, SNDRV_COMPRESS_AVAIL and poll() both recheck
>> the stream state after the pointer refresh, and there are other drivers
>> such as SOF where pointer() can return -EBUSY for a not-ready case,
>> which is not the same class as the wm_adsp -EIO/XRUN path.
>>
>> I also agree that the current patch is too broad because it uses the raw pointer()
>> errno as the policy boundary for avail handling, and that conflates hard
>> stream-failure cases such as wm_adsp's -EIO/XRUN transition with
>> other conditions like SOF's -EBUSY not-ready return. I can rework patch
>> 2 so the behavior is based on a better-defined failure condition instead
>> of treating every non-EOPNOTSUPP return as fatal for avail.
>>
>> WDYT?
> 
> IMO, keeping the behavior could be safer for now.
> The erroneous timestamp can be identified by zeros, at least.

That sounds right, I'll drop this change for now.

-- 
Thanks,
Cássio


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

      reply	other threads:[~2026-04-15 19:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-14 16:47 [PATCH 0/2] ALSA: compress: clean up pointer errno handling and fix avail errors Cássio Gabriel
2026-04-14 16:47 ` [PATCH 1/2] ALSA: compress: Use EOPNOTSUPP for missing pointer callbacks Cássio Gabriel
2026-04-14 16:47 ` [PATCH 2/2] ALSA: compress: Propagate real pointer errors in avail paths Cássio Gabriel
2026-04-14 16:53   ` Mark Brown
2026-04-14 17:45     ` Cássio Gabriel Monteiro Pires
2026-04-15 14:20       ` Takashi Iwai
2026-04-15 19:29         ` Cássio Gabriel Monteiro Pires [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=64413e7d-cd98-433a-90db-ad9f9854df56@gmail.com \
    --to=cassiogabrielcontato@gmail.com \
    --cc=broonie@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.de \
    --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 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.