alsa/0025-pcm-dmix-Allow-disabling-x86-optimizations.patch
OBS User mrdocs 6977966888 Accepting request 483406 from home:tiwai:branches:multimedia:libs
- Backport upstream fix patches, including the deadlock fix for
  aplay/arecord (boo#1031525):
  0001-ucm-Add-ATTRIBUTE_UNUSED-for-unused-parameters-of-ex.patch
  0002-ucm-parser-needs-limits.h.patch
  0003-pcm-direct-allow-users-to-configure-different-period.patch
  0004-pcm-dshare-enable-silence.patch
  0005-pcm-rate-fix-the-hw_ptr-update-until-the-boundary-av.patch
  0006-plugin-dynamically-update-avail_min-on-slave.patch
  0007-rate-dynamic-update-avail_min-on-slave.patch
  0008-topology-fix-unused-const-variable-warning.patch
  0009-seq-improve-documentation-about-new-get-pid-card-fun.patch
  0010-pcm-direct-returning-semop-error-code-for-semaphore-.patch
  0011-pcm-direct-Fix-for-sync-issue-on-xrun-recover.patch
  0012-pcm-direct-check-state-before-enter-poll-on-timer.patch
  0013-pcm-direct-don-t-return-bogus-buffer-levels-in-xrun-.patch
  0014-conf-ucm-broxton-add-broxton-rt298-conf-files.patch
  0015-pcm-direct-Fix-deadlock-in-poll_descriptors.patch
  0016-ucm-Assure-the-user-input-card-name-not-to-exceed-ma.patch
  0017-ucm-Load-device-specific-configuration-file-based-on.patch
  0018-ucm-Add-command-get-_file-to-get-the-config-file-nam.patch
  0019-topology-Fix-incorrect-license-in-source-comments.patch
  0020-conf-cards-add-support-for-pistachio-card.patch
  0021-pcm-multi-Drop-the-fixed-slave_map-in-snd_pcm_multi_.patch
  0022-conf-Add-card-config-for-Intel-HDMI-DP-LPE-audio.patch
  0023-pcm-Avoid-lock-for-snd_pcm_nonblock.patch
  0024-pcm-Disable-locking-in-async-mode.patch
  0025-pcm-dmix-Allow-disabling-x86-optimizations.patch
  0026-pcm-dmix_rewind-corrupts-application-pointer-fix.patch
  0027-pcm-direct-fix-race-on-clearing-timer-events.patch
  0028-pcm-file-Enable-file-writing-for-capture-path.patch

OBS-URL: https://build.opensuse.org/request/show/483406
OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/alsa?expand=0&rev=210
2017-03-29 22:55:12 +00:00

153 lines
4.5 KiB
Diff

From 22eca6468b4aea47c783770ec0739d1e13bf3bfc Mon Sep 17 00:00:00 2001
From: Takashi Iwai <tiwai@suse.de>
Date: Fri, 10 Feb 2017 12:16:12 +0100
Subject: [PATCH 25/43] pcm: dmix: Allow disabling x86 optimizations
The dmix plugin has some optimized implementations for x86 using the
direct memory accesses, which was rather the original version, in
addition to the "generic" implementation using the semaphore
blocking. The x86 implementation relies on the memory coherency *and*
the fast read/write on it.
For other architectures, this has been always disabled just because of
memory coherency. But, the recent LPE audio development revealed
that, even on x86 platforms, the read/write performance might become
extremely bad when the buffer is marked as uncached. Some drivers
already know the buffer is uncached, we need to switch to the generic
mode in such a case.
This patch introduces yet another flag to dmix configuration,
direct_memory_access, that indicates whether the x86-specific
optimization can be used or not. Each driver can set the flag in its
cards config namespace, and the default dmix config refers to it.
As of this patch, only HDMI LPE Audio driver sets it.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
src/conf/cards/HdmiLpeAudio.conf | 3 +++
src/conf/pcm/dmix.conf | 15 +++++++++++++++
src/pcm/pcm_direct.c | 8 ++++++++
src/pcm/pcm_direct.h | 2 ++
src/pcm/pcm_dmix.c | 1 +
src/pcm/pcm_dmix_i386.c | 5 +++++
src/pcm/pcm_dmix_x86_64.c | 5 +++++
7 files changed, 39 insertions(+)
--- a/src/conf/cards/HdmiLpeAudio.conf
+++ b/src/conf/cards/HdmiLpeAudio.conf
@@ -20,6 +20,9 @@ HdmiLpeAudio.pcm.front.0 {
}
}
+# uncached memory reads have a high penalty
+HdmiLpeAudio.dmix.direct_memory_access false
+
# default with dmix+softvol
HdmiLpeAudio.pcm.default {
@args [ CARD ]
--- a/src/conf/pcm/dmix.conf
+++ b/src/conf/pcm/dmix.conf
@@ -49,6 +49,21 @@ pcm.!dmix {
@func refer
name defaults.pcm.ipc_perm
}
+ direct_memory_access {
+ @func refer
+ name {
+ @func concat
+ strings [
+ "cards."
+ {
+ @func card_driver
+ card $CARD
+ }
+ ".dmix.direct_memory_access"
+ ]
+ }
+ default true
+ }
slave {
pcm {
type hw
--- a/src/pcm/pcm_direct.c
+++ b/src/pcm/pcm_direct.c
@@ -1861,6 +1861,7 @@ int snd_pcm_direct_parse_open_conf(snd_c
rec->slowptr = 1;
rec->max_periods = 0;
rec->var_periodsize = 1;
+ rec->direct_memory_access = 1;
/* read defaults */
if (snd_config_search(root, "defaults.pcm.dmix_max_periods", &n) >= 0) {
@@ -1974,6 +1975,13 @@ int snd_pcm_direct_parse_open_conf(snd_c
rec->var_periodsize = err;
continue;
}
+ if (strcmp(id, "direct_memory_access") == 0) {
+ err = snd_config_get_bool(n);
+ if (err < 0)
+ return err;
+ rec->direct_memory_access = err;
+ continue;
+ }
SNDERR("Unknown field %s", id);
return -EINVAL;
}
--- a/src/pcm/pcm_direct.h
+++ b/src/pcm/pcm_direct.h
@@ -159,6 +159,7 @@ struct snd_pcm_direct {
unsigned int channels; /* client's channels */
unsigned int *bindings;
unsigned int recoveries; /* mirror of executed recoveries on slave */
+ int direct_memory_access; /* use arch-optimized buffer RW */
union {
struct {
int shmid_sum; /* IPC global sum ring buffer memory identification */
@@ -340,6 +341,7 @@ struct snd_pcm_direct_open_conf {
int slowptr;
int max_periods;
int var_periodsize;
+ int direct_memory_access;
snd_config_t *slave;
snd_config_t *bindings;
};
--- a/src/pcm/pcm_dmix.c
+++ b/src/pcm/pcm_dmix.c
@@ -1065,6 +1065,7 @@ int snd_pcm_dmix_open(snd_pcm_t **pcmp,
dmix->max_periods = opts->max_periods;
dmix->var_periodsize = opts->var_periodsize;
dmix->sync_ptr = snd_pcm_dmix_sync_ptr;
+ dmix->direct_memory_access = opts->direct_memory_access;
retry:
if (first_instance) {
--- a/src/pcm/pcm_dmix_i386.c
+++ b/src/pcm/pcm_dmix_i386.c
@@ -87,6 +87,11 @@ static void mix_select_callbacks(snd_pcm
{
static int smp = 0, mmx = 0, cmov = 0;
+ if (!dmix->direct_memory_access) {
+ generic_mix_select_callbacks(dmix);
+ return;
+ }
+
if (!((1ULL<< dmix->shmptr->s.format) & i386_dmix_supported_format)) {
generic_mix_select_callbacks(dmix);
return;
--- a/src/pcm/pcm_dmix_x86_64.c
+++ b/src/pcm/pcm_dmix_x86_64.c
@@ -70,6 +70,11 @@ static void mix_select_callbacks(snd_pcm
{
static int smp = 0;
+ if (!dmix->direct_memory_access) {
+ generic_mix_select_callbacks(dmix);
+ return;
+ }
+
if (!((1ULL<< dmix->shmptr->s.format) & x86_64_dmix_supported_format)) {
generic_mix_select_callbacks(dmix);
return;