Skip to content

Commit 86691d1

Browse files
paolosabatinoigorpecovnik
authored andcommitted
rockchip/64: fix again periodic dma and audio stuttering
1 parent d19444b commit 86691d1

14 files changed

+284
-192
lines changed

patch/kernel/archive/rockchip-6.12/armbian.series

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@
3838
patches.armbian/general-linux-export-mm-trace-rss-stats.patch
3939
patches.armbian/general-pl330-01-fix-periodic-transfers.patch
4040
patches.armbian/general-pl330-02-add-support-for-interleaved-transfers.patch
41-
patches.armbian/general-pl330-03-fix-data-race-on-tx-transfers.patch
4241
patches.armbian/general-pl330-04-bigger-mcode-buffer.patch
4342
patches.armbian/general-pl330-05-fix-unbalanced-power-down.patch
43+
patches.armbian/general-pl330-06-fix-buffer-underruns.patch
4444
patches.armbian/general-rk322x-gpio-ir-driver.patch
4545
patches.armbian/general-rockchip-various-fixes.patch
4646
patches.armbian/ir-keymap-rk322x-box.patch

patch/kernel/archive/rockchip-6.12/patches.armbian/general-pl330-03-fix-data-race-on-tx-transfers.patch

Lines changed: 0 additions & 47 deletions
This file was deleted.
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
From 4acf270a6310f5e2dbadac1d5f21d8e7477fade6 Mon Sep 17 00:00:00 2001
2+
From: Paolo Sabatino <[email protected]>
3+
Date: Sun, 16 Feb 2025 11:15:55 +0100
4+
Subject: [PATCH] pl330: fix buffer underrun with cyclic dma
5+
6+
userspace applications (notably, pulseaudio) were
7+
suffering frequent buffer underruns when cyclic DMA
8+
was handled by controller itself. This patch fixes
9+
the buffer underruns avoiding to juggle with the
10+
descriptor state, keeping it in BUSY state as long
11+
as it is actual transfer is progressing.
12+
---
13+
drivers/dma/pl330.c | 24 ++++++++++++------------
14+
1 file changed, 12 insertions(+), 12 deletions(-)
15+
16+
diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
17+
index 208e2a089a4d..6dac00995765 100644
18+
--- a/drivers/dma/pl330.c
19+
+++ b/drivers/dma/pl330.c
20+
@@ -1737,11 +1737,11 @@ static void dma_pl330_rqcb(struct dma_pl330_desc *desc, enum pl330_op_err err)
21+
if (!pch)
22+
return;
23+
24+
- spin_lock_irqsave(&pch->lock, flags);
25+
-
26+
- desc->status = DONE;
27+
-
28+
- spin_unlock_irqrestore(&pch->lock, flags);
29+
+ if (!desc->cyclic) {
30+
+ spin_lock_irqsave(&pch->lock, flags);
31+
+ desc->status = DONE;
32+
+ spin_unlock_irqrestore(&pch->lock, flags);
33+
+ }
34+
35+
tasklet_schedule(&pch->task);
36+
}
37+
@@ -2256,23 +2256,23 @@ static void pl330_tasklet(struct tasklet_struct *t)
38+
39+
/* Pick up ripe tomatoes */
40+
list_for_each_entry_safe(desc, _dt, &pch->work_list, node) {
41+
- if (desc->status == DONE) {
42+
- if (!desc->cyclic) {
43+
- dma_cookie_complete(&desc->txd);
44+
- list_move_tail(&desc->node, &pch->completed_list);
45+
- } else {
46+
- struct dmaengine_desc_callback cb;
47+
48+
+ if (desc->cyclic) {
49+
+ if (desc->status == BUSY || desc->status == DONE) {
50+
+ struct dmaengine_desc_callback cb;
51+
desc->status = BUSY;
52+
dmaengine_desc_get_callback(&desc->txd, &cb);
53+
-
54+
if (dmaengine_desc_callback_valid(&cb)) {
55+
spin_unlock_irqrestore(&pch->lock, flags);
56+
dmaengine_desc_callback_invoke(&cb, NULL);
57+
spin_lock_irqsave(&pch->lock, flags);
58+
}
59+
}
60+
+ } else if (desc->status == DONE) {
61+
+ dma_cookie_complete(&desc->txd);
62+
+ list_move_tail(&desc->node, &pch->completed_list);
63+
}
64+
+
65+
}
66+
67+
/* Try to submit a req imm. next to the last completed cookie */
68+
--
69+
2.43.0
70+

patch/kernel/archive/rockchip-6.12/series.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@
4646
patches.armbian/general-linux-export-mm-trace-rss-stats.patch
4747
patches.armbian/general-pl330-01-fix-periodic-transfers.patch
4848
patches.armbian/general-pl330-02-add-support-for-interleaved-transfers.patch
49-
patches.armbian/general-pl330-03-fix-data-race-on-tx-transfers.patch
5049
patches.armbian/general-pl330-04-bigger-mcode-buffer.patch
5150
patches.armbian/general-pl330-05-fix-unbalanced-power-down.patch
51+
patches.armbian/general-pl330-06-fix-buffer-underruns.patch
5252
patches.armbian/general-rk322x-gpio-ir-driver.patch
5353
patches.armbian/general-rockchip-various-fixes.patch
5454
patches.armbian/ir-keymap-rk322x-box.patch

patch/kernel/archive/rockchip-6.13/armbian.series

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@
3838
patches.armbian/general-linux-export-mm-trace-rss-stats.patch
3939
patches.armbian/general-pl330-01-fix-periodic-transfers.patch
4040
patches.armbian/general-pl330-02-add-support-for-interleaved-transfers.patch
41-
patches.armbian/general-pl330-03-fix-data-race-on-tx-transfers.patch
4241
patches.armbian/general-pl330-04-bigger-mcode-buffer.patch
4342
patches.armbian/general-pl330-05-fix-unbalanced-power-down.patch
43+
patches.armbian/general-pl330-06-fix-buffer-underruns.patch
4444
patches.armbian/general-rk322x-gpio-ir-driver.patch
4545
patches.armbian/general-rockchip-various-fixes.patch
4646
patches.armbian/ir-keymap-rk322x-box.patch

patch/kernel/archive/rockchip-6.13/patches.armbian/general-pl330-03-fix-data-race-on-tx-transfers.patch

Lines changed: 0 additions & 47 deletions
This file was deleted.
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
From 4acf270a6310f5e2dbadac1d5f21d8e7477fade6 Mon Sep 17 00:00:00 2001
2+
From: Paolo Sabatino <[email protected]>
3+
Date: Sun, 16 Feb 2025 11:15:55 +0100
4+
Subject: [PATCH] pl330: fix buffer underrun with cyclic dma
5+
6+
userspace applications (notably, pulseaudio) were
7+
suffering frequent buffer underruns when cyclic DMA
8+
was handled by controller itself. This patch fixes
9+
the buffer underruns avoiding to juggle with the
10+
descriptor state, keeping it in BUSY state as long
11+
as it is actual transfer is progressing.
12+
---
13+
drivers/dma/pl330.c | 24 ++++++++++++------------
14+
1 file changed, 12 insertions(+), 12 deletions(-)
15+
16+
diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
17+
index 208e2a089a4d..6dac00995765 100644
18+
--- a/drivers/dma/pl330.c
19+
+++ b/drivers/dma/pl330.c
20+
@@ -1737,11 +1737,11 @@ static void dma_pl330_rqcb(struct dma_pl330_desc *desc, enum pl330_op_err err)
21+
if (!pch)
22+
return;
23+
24+
- spin_lock_irqsave(&pch->lock, flags);
25+
-
26+
- desc->status = DONE;
27+
-
28+
- spin_unlock_irqrestore(&pch->lock, flags);
29+
+ if (!desc->cyclic) {
30+
+ spin_lock_irqsave(&pch->lock, flags);
31+
+ desc->status = DONE;
32+
+ spin_unlock_irqrestore(&pch->lock, flags);
33+
+ }
34+
35+
tasklet_schedule(&pch->task);
36+
}
37+
@@ -2256,23 +2256,23 @@ static void pl330_tasklet(struct tasklet_struct *t)
38+
39+
/* Pick up ripe tomatoes */
40+
list_for_each_entry_safe(desc, _dt, &pch->work_list, node) {
41+
- if (desc->status == DONE) {
42+
- if (!desc->cyclic) {
43+
- dma_cookie_complete(&desc->txd);
44+
- list_move_tail(&desc->node, &pch->completed_list);
45+
- } else {
46+
- struct dmaengine_desc_callback cb;
47+
48+
+ if (desc->cyclic) {
49+
+ if (desc->status == BUSY || desc->status == DONE) {
50+
+ struct dmaengine_desc_callback cb;
51+
desc->status = BUSY;
52+
dmaengine_desc_get_callback(&desc->txd, &cb);
53+
-
54+
if (dmaengine_desc_callback_valid(&cb)) {
55+
spin_unlock_irqrestore(&pch->lock, flags);
56+
dmaengine_desc_callback_invoke(&cb, NULL);
57+
spin_lock_irqsave(&pch->lock, flags);
58+
}
59+
}
60+
+ } else if (desc->status == DONE) {
61+
+ dma_cookie_complete(&desc->txd);
62+
+ list_move_tail(&desc->node, &pch->completed_list);
63+
}
64+
+
65+
}
66+
67+
/* Try to submit a req imm. next to the last completed cookie */
68+
--
69+
2.43.0
70+

patch/kernel/archive/rockchip-6.13/series.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@
4646
patches.armbian/general-linux-export-mm-trace-rss-stats.patch
4747
patches.armbian/general-pl330-01-fix-periodic-transfers.patch
4848
patches.armbian/general-pl330-02-add-support-for-interleaved-transfers.patch
49-
patches.armbian/general-pl330-03-fix-data-race-on-tx-transfers.patch
5049
patches.armbian/general-pl330-04-bigger-mcode-buffer.patch
5150
patches.armbian/general-pl330-05-fix-unbalanced-power-down.patch
51+
patches.armbian/general-pl330-06-fix-buffer-underruns.patch
5252
patches.armbian/general-rk322x-gpio-ir-driver.patch
5353
patches.armbian/general-rockchip-various-fixes.patch
5454
patches.armbian/ir-keymap-rk322x-box.patch

0 commit comments

Comments
 (0)