- Backport upstream fixes: 0001-ucm-substitution-remove-duplicate-allow_empty-assign.patch 0002-ucm-fix-parse_get_safe_name-safe-name-must-be-checke.patch 0003-ucm-substitute-the-merged-tree-completely.patch 0004-ctl-improve-documentation-for-identifier-of-control-.patch 0005-pcm-dmix-make-lockless-operation-optional.patch 0006-pcm-dmix-Fix-semaphore-usage-with-lockless-operation.patch 0007-pcm-iec958-implement-HDMI-HBR-audio-formatting.patch 0008-pcm-iec958-set-channel-status-bits-according-to-rate.patch 0009-conf-pcm-USB-Added-S-PDIF-fix-for-Asus-Xonar-SE.patch 0010-control-ctlparse-fix-enum-values-in-or.patch 0011-conf-USB-Audio-Disable-IEC958-on-Lenovo-ThinkStation.patch 0012-pcm-dmix-fix-access-to-sum-buffer-in-non-interleaved.patch 0014-control-Add-documentation-for-snd_ctl_elem_list_.patch 0015-conf-quote-also-strings-with-and-characters-in-strin.patch 0016-topology-decode-Fix-channel-map-memory-allocation.patch 0017-topology-decode-Fix-infinite-loop-in-decoding-enum-c.patch 0018-topology-decode-Remove-decoding-values-for-enum-cont.patch 0019-topology-decode-Add-enum-control-texts-as-separate-e.patch 0020-topology-decode-Fix-printing-texts-section.patch 0021-topology-decode-Change-declaration-of-enum-decoding-.patch 0022-topology-decode-Fix-decoding-PCM-formats-and-rates.patch 0023-topology-decode-Print-sig_bits-field-in-PCM-capabili.patch 0024-topology-decode-Add-DAI-name-printing.patch 0025-topology-Make-buffer-for-saving-dynamic-size.patch 0026-topology-return-correct-value-in-tplg_save_printf.patch 0027-topology-fix-some-gcc10-warnings-labs-signess.patch 0028-topology-fix-sort_config.patch 0029-topology-fix-the-unaligned-access.patch 0030-topology-improve-the-printf-buffer-management.patch OBS-URL: https://build.opensuse.org/request/show/836375 OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/alsa?expand=0&rev=281
111 lines
3.9 KiB
Diff
111 lines
3.9 KiB
Diff
From d824b461ae807ea436e2df36da9c2212e485e3e6 Mon Sep 17 00:00:00 2001
|
|
From: Takashi Iwai <tiwai@suse.de>
|
|
Date: Fri, 19 Jun 2020 18:40:46 +0200
|
|
Subject: [PATCH 06/32] pcm: dmix: Fix semaphore usage with lockless operation
|
|
|
|
As Maarten Baert recently reported, the current dmix code applies the
|
|
semaphore unnecessarily around mixing streams even when the lockless
|
|
mix operation is used on x86. This was rather introduced mistakenly
|
|
at the commit 267d7c728196 ("Add support of little-endian on
|
|
i386/x86_64 dmix") where the generic dmix code was included on x86,
|
|
too.
|
|
|
|
For achieving the original performance back, this patch changes the
|
|
semaphore handling to be checked at run time instead of statically at
|
|
compile time.
|
|
|
|
Reviewed-by: Jaroslav Kysela <perex@perex.cz>
|
|
Signed-off-by: Takashi Iwai <tiwai@suse.de>
|
|
---
|
|
src/pcm/pcm_direct.h | 1 +
|
|
src/pcm/pcm_dmix.c | 18 +++++++++++-------
|
|
src/pcm/pcm_dmix_generic.c | 2 +-
|
|
src/pcm/pcm_dmix_i386.c | 1 +
|
|
src/pcm/pcm_dmix_x86_64.c | 1 +
|
|
5 files changed, 15 insertions(+), 8 deletions(-)
|
|
|
|
diff --git a/src/pcm/pcm_direct.h b/src/pcm/pcm_direct.h
|
|
index 8a236970a3a1..2150bce15449 100644
|
|
--- a/src/pcm/pcm_direct.h
|
|
+++ b/src/pcm/pcm_direct.h
|
|
@@ -186,6 +186,7 @@ struct snd_pcm_direct {
|
|
mix_areas_32_t *remix_areas_32;
|
|
mix_areas_24_t *remix_areas_24;
|
|
mix_areas_u8_t *remix_areas_u8;
|
|
+ unsigned int use_sem;
|
|
} dmix;
|
|
struct {
|
|
unsigned long long chn_mask;
|
|
diff --git a/src/pcm/pcm_dmix.c b/src/pcm/pcm_dmix.c
|
|
index 843fa3168756..e9343b19a536 100644
|
|
--- a/src/pcm/pcm_dmix.c
|
|
+++ b/src/pcm/pcm_dmix.c
|
|
@@ -292,13 +292,17 @@ static void remix_areas(snd_pcm_direct_t *dmix,
|
|
* the area via semaphore
|
|
*/
|
|
#ifndef DOC_HIDDEN
|
|
-#ifdef NO_CONCURRENT_ACCESS
|
|
-#define dmix_down_sem(dmix) snd_pcm_direct_semaphore_down(dmix, DIRECT_IPC_SEM_CLIENT)
|
|
-#define dmix_up_sem(dmix) snd_pcm_direct_semaphore_up(dmix, DIRECT_IPC_SEM_CLIENT)
|
|
-#else
|
|
-#define dmix_down_sem(dmix)
|
|
-#define dmix_up_sem(dmix)
|
|
-#endif
|
|
+static void dmix_down_sem(snd_pcm_direct_t *dmix)
|
|
+{
|
|
+ if (dmix->u.dmix.use_sem)
|
|
+ snd_pcm_direct_semaphore_down(dmix, DIRECT_IPC_SEM_CLIENT);
|
|
+}
|
|
+
|
|
+static void dmix_up_sem(snd_pcm_direct_t *dmix)
|
|
+{
|
|
+ if (dmix->u.dmix.use_sem)
|
|
+ snd_pcm_direct_semaphore_up(dmix, DIRECT_IPC_SEM_CLIENT);
|
|
+}
|
|
#endif
|
|
|
|
/*
|
|
diff --git a/src/pcm/pcm_dmix_generic.c b/src/pcm/pcm_dmix_generic.c
|
|
index 40c08747a74a..8a5b6f148556 100644
|
|
--- a/src/pcm/pcm_dmix_generic.c
|
|
+++ b/src/pcm/pcm_dmix_generic.c
|
|
@@ -43,7 +43,6 @@ static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
|
|
#ifndef ARCH_ADD
|
|
#define ARCH_ADD(p,a) (*(p) += (a))
|
|
#define ARCH_CMPXCHG(p,a,b) (*(p)) /* fake */
|
|
-#define NO_CONCURRENT_ACCESS /* use semaphore to avoid race */
|
|
#define IS_CONCURRENT 0 /* no race check */
|
|
#endif
|
|
|
|
@@ -530,6 +529,7 @@ static void generic_mix_select_callbacks(snd_pcm_direct_t *dmix)
|
|
dmix->u.dmix.mix_areas_u8 = generic_mix_areas_u8;
|
|
dmix->u.dmix.remix_areas_24 = generic_remix_areas_24;
|
|
dmix->u.dmix.remix_areas_u8 = generic_remix_areas_u8;
|
|
+ dmix->u.dmix.use_sem = 1;
|
|
}
|
|
|
|
#endif
|
|
diff --git a/src/pcm/pcm_dmix_i386.c b/src/pcm/pcm_dmix_i386.c
|
|
index 1ab983a8a373..82a91c5c2897 100644
|
|
--- a/src/pcm/pcm_dmix_i386.c
|
|
+++ b/src/pcm/pcm_dmix_i386.c
|
|
@@ -135,4 +135,5 @@ static void mix_select_callbacks(snd_pcm_direct_t *dmix)
|
|
dmix->u.dmix.mix_areas_24 = smp > 1 ? mix_areas_24_smp: mix_areas_24;
|
|
dmix->u.dmix.remix_areas_24 = smp > 1 ? remix_areas_24_smp: remix_areas_24;
|
|
}
|
|
+ dmix->u.dmix.use_sem = 0;
|
|
}
|
|
diff --git a/src/pcm/pcm_dmix_x86_64.c b/src/pcm/pcm_dmix_x86_64.c
|
|
index 34c40d4e9d1d..4d882bfd01bf 100644
|
|
--- a/src/pcm/pcm_dmix_x86_64.c
|
|
+++ b/src/pcm/pcm_dmix_x86_64.c
|
|
@@ -102,4 +102,5 @@ static void mix_select_callbacks(snd_pcm_direct_t *dmix)
|
|
dmix->u.dmix.remix_areas_32 = smp > 1 ? remix_areas_32_smp : remix_areas_32;
|
|
dmix->u.dmix.mix_areas_24 = smp > 1 ? mix_areas_24_smp : mix_areas_24;
|
|
dmix->u.dmix.remix_areas_24 = smp > 1 ? remix_areas_24_smp : remix_areas_24;
|
|
+ dmix->u.dmix.use_sem = 0;
|
|
}
|
|
--
|
|
2.16.4
|
|
|