* [PATCH] ALSA: dmaengine: increment buffer pointer atomically
@ 2022-09-26 16:58 ` Eugeniu Rosca
0 siblings, 0 replies; 4+ messages in thread
From: Eugeniu Rosca @ 2022-09-26 16:58 UTC (permalink / raw)
To: Lars-Peter Clausen, Vinod Koul, Mark Brown, Jaroslav Kysela,
Takashi Iwai, alsa-devel, linux-kernel
Cc: Jiada Wang, Dean Jenkins, Eugeniu Rosca, Andreas Pape, Eugeniu Rosca
From: Andreas Pape <apape@de.adit-jv.com>
Setting pointer and afterwards checking for wraparound leads
to the possibility of returning the inconsistent pointer position.
This patch increments buffer pointer atomically to avoid this issue.
Fixes: e7f73a1613567a ("ASoC: Add dmaengine PCM helper functions")
Signed-off-by: Andreas Pape <apape@de.adit-jv.com>
Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com>
---
sound/core/pcm_dmaengine.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/sound/core/pcm_dmaengine.c b/sound/core/pcm_dmaengine.c
index 5b2ca028f5aa..494ec0c207fa 100644
--- a/sound/core/pcm_dmaengine.c
+++ b/sound/core/pcm_dmaengine.c
@@ -133,12 +133,14 @@ EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_set_config_from_dai_data);
static void dmaengine_pcm_dma_complete(void *arg)
{
+ unsigned int new_pos;
struct snd_pcm_substream *substream = arg;
struct dmaengine_pcm_runtime_data *prtd = substream_to_prtd(substream);
- prtd->pos += snd_pcm_lib_period_bytes(substream);
- if (prtd->pos >= snd_pcm_lib_buffer_bytes(substream))
- prtd->pos = 0;
+ new_pos = prtd->pos + snd_pcm_lib_period_bytes(substream);
+ if (new_pos >= snd_pcm_lib_buffer_bytes(substream))
+ new_pos = 0;
+ prtd->pos = new_pos;
snd_pcm_period_elapsed(substream);
}
--
2.37.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] ALSA: dmaengine: increment buffer pointer atomically
@ 2022-09-26 16:58 ` Eugeniu Rosca
0 siblings, 0 replies; 4+ messages in thread
From: Eugeniu Rosca @ 2022-09-26 16:58 UTC (permalink / raw)
To: Lars-Peter Clausen, Vinod Koul, Mark Brown, Jaroslav Kysela,
Takashi Iwai, alsa-devel, linux-kernel
Cc: Jiada Wang, Dean Jenkins, Andreas Pape, Eugeniu Rosca, Eugeniu Rosca
From: Andreas Pape <apape@de.adit-jv.com>
Setting pointer and afterwards checking for wraparound leads
to the possibility of returning the inconsistent pointer position.
This patch increments buffer pointer atomically to avoid this issue.
Fixes: e7f73a1613567a ("ASoC: Add dmaengine PCM helper functions")
Signed-off-by: Andreas Pape <apape@de.adit-jv.com>
Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com>
---
sound/core/pcm_dmaengine.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/sound/core/pcm_dmaengine.c b/sound/core/pcm_dmaengine.c
index 5b2ca028f5aa..494ec0c207fa 100644
--- a/sound/core/pcm_dmaengine.c
+++ b/sound/core/pcm_dmaengine.c
@@ -133,12 +133,14 @@ EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_set_config_from_dai_data);
static void dmaengine_pcm_dma_complete(void *arg)
{
+ unsigned int new_pos;
struct snd_pcm_substream *substream = arg;
struct dmaengine_pcm_runtime_data *prtd = substream_to_prtd(substream);
- prtd->pos += snd_pcm_lib_period_bytes(substream);
- if (prtd->pos >= snd_pcm_lib_buffer_bytes(substream))
- prtd->pos = 0;
+ new_pos = prtd->pos + snd_pcm_lib_period_bytes(substream);
+ if (new_pos >= snd_pcm_lib_buffer_bytes(substream))
+ new_pos = 0;
+ prtd->pos = new_pos;
snd_pcm_period_elapsed(substream);
}
--
2.37.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] ALSA: dmaengine: increment buffer pointer atomically
2022-09-26 16:58 ` Eugeniu Rosca
@ 2022-09-27 6:55 ` Takashi Iwai
-1 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2022-09-27 6:55 UTC (permalink / raw)
To: Eugeniu Rosca
Cc: Lars-Peter Clausen, Vinod Koul, Mark Brown, Jaroslav Kysela,
Takashi Iwai, alsa-devel, linux-kernel, Jiada Wang, Dean Jenkins,
Andreas Pape, Eugeniu Rosca
On Mon, 26 Sep 2022 18:58:13 +0200,
Eugeniu Rosca wrote:
>
> From: Andreas Pape <apape@de.adit-jv.com>
>
> Setting pointer and afterwards checking for wraparound leads
> to the possibility of returning the inconsistent pointer position.
>
> This patch increments buffer pointer atomically to avoid this issue.
>
> Fixes: e7f73a1613567a ("ASoC: Add dmaengine PCM helper functions")
> Signed-off-by: Andreas Pape <apape@de.adit-jv.com>
> Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com>
Thanks, applied.
Takashi
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ALSA: dmaengine: increment buffer pointer atomically
@ 2022-09-27 6:55 ` Takashi Iwai
0 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2022-09-27 6:55 UTC (permalink / raw)
To: Eugeniu Rosca
Cc: alsa-devel, Lars-Peter Clausen, Eugeniu Rosca, Jiada Wang,
linux-kernel, Takashi Iwai, Dean Jenkins, Vinod Koul, Mark Brown,
Andreas Pape
On Mon, 26 Sep 2022 18:58:13 +0200,
Eugeniu Rosca wrote:
>
> From: Andreas Pape <apape@de.adit-jv.com>
>
> Setting pointer and afterwards checking for wraparound leads
> to the possibility of returning the inconsistent pointer position.
>
> This patch increments buffer pointer atomically to avoid this issue.
>
> Fixes: e7f73a1613567a ("ASoC: Add dmaengine PCM helper functions")
> Signed-off-by: Andreas Pape <apape@de.adit-jv.com>
> Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com>
Thanks, applied.
Takashi
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-09-27 6:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-26 16:58 [PATCH] ALSA: dmaengine: increment buffer pointer atomically Eugeniu Rosca
2022-09-26 16:58 ` Eugeniu Rosca
2022-09-27 6:55 ` Takashi Iwai
2022-09-27 6:55 ` Takashi Iwai
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.