Takashi Iwai
4f7fd72c0e
- 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
108 lines
3.7 KiB
Diff
108 lines
3.7 KiB
Diff
From 4759865c861c708ce4a68fc08060fc820628ccaf Mon Sep 17 00:00:00 2001
|
|
From: Takashi Iwai <tiwai@suse.de>
|
|
Date: Fri, 19 Jun 2020 18:57:05 +0200
|
|
Subject: [PATCH 05/32] pcm: dmix: make lockless operation optional
|
|
|
|
The recently reported (but a long-standing) bug about the
|
|
unconditional semaphore usage in the dmix implies that basically we've
|
|
had no problem with the locking in the practical usages over years.
|
|
Although the lockless operation has a clear merit, it's a much higher
|
|
CPU usage (especially on some uncached pages), and it might lead to a
|
|
potential deadlock in theory (which is hard to reproduce at will,
|
|
though).
|
|
|
|
This patch introduces a new configure option "--enable-lockless-dmix"
|
|
or "--disable-lockless-dmix" to let user choose the default dmix
|
|
operation mode. The usage of the lockless mixing has been already
|
|
conditionally enabled via asoundrc and card config
|
|
"direct_memory_access", so we just need to set the default value based
|
|
on it.
|
|
|
|
In this patch, the default is set off to the lockless mixing, i.e. the
|
|
generic mixing is chosen. It makes more sense from the performance
|
|
POV. For any users who still require the lockless operation, it can
|
|
be enabled either via configure option or the asoundrc.
|
|
|
|
The magic number used in the shmem is also changed depending on the
|
|
operation mode. It's just for safety, not to conflict both operation
|
|
modes with each other.
|
|
|
|
Reviewed-by: Jaroslav Kysela <perex@perex.cz>
|
|
Signed-off-by: Takashi Iwai <tiwai@suse.de>
|
|
---
|
|
configure.ac | 13 +++++++++++++
|
|
src/pcm/pcm_direct.c | 16 +++++++++++++---
|
|
2 files changed, 26 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/configure.ac b/configure.ac
|
|
index 93a54c909d1d..01357fb9310f 100644
|
|
--- a/configure.ac
|
|
+++ b/configure.ac
|
|
@@ -629,6 +629,19 @@ if test "$build_pcm_mmap_emul" = "yes"; then
|
|
AC_DEFINE([BUILD_PCM_PLUGIN_MMAP_EMUL], "1", [Build PCM mmap-emul plugin])
|
|
fi
|
|
|
|
+if test "$build_pcm_dmix" = "yes"; then
|
|
+AC_MSG_CHECKING(for default lockless dmix)
|
|
+AC_ARG_ENABLE(lockless-dmix,
|
|
+ AS_HELP_STRING([--enable-lockless-dmix],
|
|
+ [use lockless dmix as default on x86]),
|
|
+ lockless_dmix="$enableval", lockless_dmix="no")
|
|
+if test "$lockless_dmix" = "yes"; then
|
|
+ AC_MSG_RESULT(yes)
|
|
+ AC_DEFINE([LOCKLESS_DMIX_DEFAULT], "1", [Lockless dmix as default])
|
|
+else
|
|
+ AC_MSG_RESULT(no)
|
|
+fi
|
|
+fi
|
|
|
|
dnl Create PCM plugin symbol list for static library
|
|
rm -f "$srcdir"/src/pcm/pcm_symbols_list.c
|
|
diff --git a/src/pcm/pcm_direct.c b/src/pcm/pcm_direct.c
|
|
index 665340954cf3..19c5a811262f 100644
|
|
--- a/src/pcm/pcm_direct.c
|
|
+++ b/src/pcm/pcm_direct.c
|
|
@@ -82,7 +82,13 @@ int snd_pcm_direct_semaphore_create_or_connect(snd_pcm_direct_t *dmix)
|
|
return 0;
|
|
}
|
|
|
|
-#define SND_PCM_DIRECT_MAGIC (0xa15ad300 + sizeof(snd_pcm_direct_share_t))
|
|
+static unsigned int snd_pcm_direct_magic(snd_pcm_direct_t *dmix)
|
|
+{
|
|
+ if (!dmix->direct_memory_access)
|
|
+ return 0xa15ad300 + sizeof(snd_pcm_direct_share_t);
|
|
+ else
|
|
+ return 0xb15ad300 + sizeof(snd_pcm_direct_share_t);
|
|
+}
|
|
|
|
/*
|
|
* global shared memory area
|
|
@@ -132,10 +138,10 @@ retryget:
|
|
buf.shm_perm.gid = dmix->ipc_gid;
|
|
shmctl(dmix->shmid, IPC_SET, &buf);
|
|
}
|
|
- dmix->shmptr->magic = SND_PCM_DIRECT_MAGIC;
|
|
+ dmix->shmptr->magic = snd_pcm_direct_magic(dmix);
|
|
return 1;
|
|
} else {
|
|
- if (dmix->shmptr->magic != SND_PCM_DIRECT_MAGIC) {
|
|
+ if (dmix->shmptr->magic != snd_pcm_direct_magic(dmix)) {
|
|
snd_pcm_direct_shm_discard(dmix);
|
|
return -EINVAL;
|
|
}
|
|
@@ -1892,7 +1898,11 @@ int snd_pcm_direct_parse_open_conf(snd_config_t *root, snd_config_t *conf,
|
|
rec->slowptr = 1;
|
|
rec->max_periods = 0;
|
|
rec->var_periodsize = 0;
|
|
+#ifdef LOCKLESS_DMIX_DEFAULT
|
|
rec->direct_memory_access = 1;
|
|
+#else
|
|
+ rec->direct_memory_access = 0;
|
|
+#endif
|
|
rec->hw_ptr_alignment = SND_PCM_HW_PTR_ALIGNMENT_AUTO;
|
|
rec->tstamp_type = -1;
|
|
|
|
--
|
|
2.16.4
|
|
|