mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Valerio Setti <vsetti@baylibre.com>
To: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: Jerome Brunet <jbrunet@baylibre.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
	Takashi Iwai <tiwai@suse.com>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Kevin Hilman <khilman@baylibre.com>,
	Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>,
	Christian Hewitt <christianshewitt@gmail.com>,
	linux-sound@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ASoC: meson: aiu-fifo: prevent sleeping when spinlock is held
Date: Fri, 13 Nov 2026 13:47:50 +0100	[thread overview]
Message-ID: <7a268a4a-692b-4aa4-82b3-a13006e9a3e3@baylibre.com> (raw)
In-Reply-To: <CAFBinCBLK3Ok7QpKUVT5XtOqDafVzGP2Tn1oBj3f=PUQ_DgnwQ@mail.gmail.com>

Hi Martin

On 11/13/26 12:05 AM, Martin Blumenstingl wrote:
> On Wed, Nov 11, 2026 at 11:09 AM Valerio Setti <vsetti@baylibre.com> wrote:
> [...]
>> @@ -37,8 +38,11 @@ snd_pcm_uframes_t aiu_fifo_pointer(struct snd_soc_component *component,
>>          struct aiu_fifo *fifo = snd_soc_dai_dma_data_get_playback(dai);
>>          struct snd_pcm_runtime *runtime = substream->runtime;
>>          unsigned int addr;
>> +       int ret;
>>
>> -       addr = snd_soc_component_read(component, fifo->mem_offset + AIU_MEM_RD);
>> +       ret = regmap_read(component->regmap, fifo->mem_offset + AIU_MEM_RD, &addr);
>> +       if (ret < 0)
>> +               return snd_soc_ret(component->dev, ret, "Failed to read FIFO pointer");
> As far as I understand:
> - snd_pcm_uframes_t is "unsigned long"
> - snd_soc_ret() returns a (signed) int
> 
> Doesn't that lead to a signed to unsigned conversion error (highest
> bit set -> large value)?

That's something that made me thinking a bit as well and the reason why 
I implemented it this way is the following.
'snd_soc_component_read' internally goes into 
'soc_component_read_no_lock' and then to 'regmap_read'. If the latter 
fails then 'return soc_component_ret_reg_rw()' is called and that calls 
'return snd_soc_ret()' internally.

So my goal was to keep the same return value in case of errors.

> axg-fifo simply discards regmap_read's return value.
> That seems odd at first, but knowing that its regmap is MMIO backed
> (same as for AIU) means there can't ever be any error.

That's a good point indeed. I will follow this design then.
Thanks for pointing this out.

-- 
Valerio


      reply	other threads:[~2026-11-13 12:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-11 10:09 Valerio Setti
2026-11-12 23:05 ` Martin Blumenstingl
2026-11-13 12:47   ` Valerio Setti [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=7a268a4a-692b-4aa4-82b3-a13006e9a3e3@baylibre.com \
    --to=vsetti@baylibre.com \
    --cc=broonie@kernel.org \
    --cc=christianshewitt@gmail.com \
    --cc=jbrunet@baylibre.com \
    --cc=khilman@baylibre.com \
    --cc=kuninori.morimoto.gx@renesas.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=martin.blumenstingl@googlemail.com \
    --cc=neil.armstrong@linaro.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.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

all inboxes | Powered by JetHome®