Hi all,
Any comments to the patch in [1]?
Should I change anything?
[1]
http://mailman.alsa-project.org/pipermail/alsa-devel/2018-July/138319.html
Best regards
*Timo Wischer*
*A*dvanced *D*river *I*nformation *T*echnology GmbH
Engineering Software Base (ADITG/ESB)
Robert-Bosch-Str. 200
31139 Hildesheim
Germany
Tel. +49 5121 49 6938
Fax +49 5121 49 6999
twischer@xxxxxxxxxxxxxx
ADIT is a joint venture company of Robert Bosch GmbH/Robert Bosch Car
Multimedia GmbH and DENSO Corporation
Sitz: Hildesheim, Registergericht: Amtsgericht Hildesheim HRB 3438
Geschäftsführung: Wilhelm Grabow, Ken Yaguchi
On 07/19/2018 12:29 PM, twischer@xxxxxxxxxxxxxx wrote:
From: Andreas Pape <apape@xxxxxxxxxxxxxx>
Setting pointer and afterwards check for wrap around leads
to the possibility of returning the inconsistent pointer position.
This patch increments buffer pointer atomically to avoid this issue.
Signed-off-by: Andreas Pape <apape@xxxxxxxxxxxxxx>
Since commit: b7ae6f3 dmaengine implementation has been moved
from ASoC to ALSA core. So change goes to sound/soc/soc-dmaengine-pcm.c,
apply to sound/core/pcm_dmaengine.c now
cherry picked from ADIT v3.14 e2f803f("ALSA: SOC: DMA: increment buffer pointer atomically")
Signed-off-by: Veeraiyan Chidambaram <veeraiyan.chidambaram@xxxxxxxxxxxx>
(cherry picked from ADIT v4.1 commit 9e7eff10a38157db75f12e032fc378d3104a2812)
Signed-off-by: Takashi Sakamoto <takashi.sakamoto@xxxxxxxxxxxxxxxx>
(cherry picked from ADIT v4.9 commit 66c00aa1e7cd3b077fc2e5a45a4594b86246cf78)
Signed-off-by: Jiada Wang <jiada_wang@xxxxxxxxxx>
Signed-off-by: Timo Wischer <twischer@xxxxxxxxxxxxxx>
---
v1 can be found in
http://mailman.alsa-project.org/pipermail/alsa-devel/2016-November/115277.html
diff --git a/sound/core/pcm_dmaengine.c b/sound/core/pcm_dmaengine.c
index 8eb58c7..0a7ed85 100644
--- a/sound/core/pcm_dmaengine.c
+++ b/sound/core/pcm_dmaengine.c
@@ -139,12 +139,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 = READ_ONCE(prtd->pos) + snd_pcm_lib_period_bytes(substream);
+ if (new_pos >= snd_pcm_lib_buffer_bytes(substream))
+ new_pos = 0;
+ WRITE_ONCE(prtd->pos, new_pos);
snd_pcm_period_elapsed(substream);
}
@@ -235,7 +237,7 @@ EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_trigger);
snd_pcm_uframes_t snd_dmaengine_pcm_pointer_no_residue(struct snd_pcm_substream *substream)
{
struct dmaengine_pcm_runtime_data *prtd = substream_to_prtd(substream);
- return bytes_to_frames(substream->runtime, prtd->pos);
+ return bytes_to_frames(substream->runtime, READ_ONCE(prtd->pos));
}
EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_pointer_no_residue);
_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel