Home Home > GIT Browse > openSUSE-15.1
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2019-01-10 20:43:30 +0100
committerTakashi Iwai <tiwai@suse.de>2019-01-11 08:35:13 +0100
commit24fe4ebf59d0a9ac9ac3b847dd7317e43e9c93de (patch)
treea19e9525f9aa25f97e9f899f61a0f98b785d48d6
parente92afec55f6053984b215f87e2892994c1f406cb (diff)
ALSA: rawmidi: A lightweight function to discard pending bytes
(bsc#1121278).
-rw-r--r--patches.drivers/ALSA-rawmidi-A-lightweight-function-to-discard-pendi.patch100
-rw-r--r--series.conf1
2 files changed, 101 insertions, 0 deletions
diff --git a/patches.drivers/ALSA-rawmidi-A-lightweight-function-to-discard-pendi.patch b/patches.drivers/ALSA-rawmidi-A-lightweight-function-to-discard-pendi.patch
new file mode 100644
index 0000000000..bbdd4c73e8
--- /dev/null
+++ b/patches.drivers/ALSA-rawmidi-A-lightweight-function-to-discard-pendi.patch
@@ -0,0 +1,100 @@
+From 6aea5702e27ebc85747d6e4943a0c378e1752be0 Mon Sep 17 00:00:00 2001
+From: Takashi Iwai <tiwai@suse.de>
+Date: Thu, 13 Sep 2018 08:20:43 +0200
+Subject: [PATCH] ALSA: rawmidi: A lightweight function to discard pending bytes
+Git-commit: 6aea5702e27ebc85747d6e4943a0c378e1752be0
+Patch-mainline: v4.20-rc1
+References: bsc#1121278
+
+For discarding the pending bytes on rawmidi, we process with a loop of
+snd_rawmidi_transmit() which is just a waste of CPU power.
+Implement a lightweight API function to discard the pending bytes and
+the proceed the ring buffer instantly, and use it instead of open
+codes.
+
+Signed-off-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ include/sound/rawmidi.h | 1 +
+ sound/core/rawmidi.c | 22 ++++++++++++++++++++++
+ sound/core/seq/seq_virmidi.c | 4 +---
+ sound/usb/midi.c | 3 +--
+ 4 files changed, 25 insertions(+), 5 deletions(-)
+
+diff --git a/include/sound/rawmidi.h b/include/sound/rawmidi.h
+index 6665cb29e1a2..3b5a061132b6 100644
+--- a/include/sound/rawmidi.h
++++ b/include/sound/rawmidi.h
+@@ -171,6 +171,7 @@ int __snd_rawmidi_transmit_peek(struct snd_rawmidi_substream *substream,
+ unsigned char *buffer, int count);
+ int __snd_rawmidi_transmit_ack(struct snd_rawmidi_substream *substream,
+ int count);
++int snd_rawmidi_proceed(struct snd_rawmidi_substream *substream);
+
+ /* main midi functions */
+
+diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c
+index 08d5662039e3..ee601d7f0926 100644
+--- a/sound/core/rawmidi.c
++++ b/sound/core/rawmidi.c
+@@ -1236,6 +1236,28 @@ int snd_rawmidi_transmit(struct snd_rawmidi_substream *substream,
+ }
+ EXPORT_SYMBOL(snd_rawmidi_transmit);
+
++/**
++ * snd_rawmidi_proceed - Discard the all pending bytes and proceed
++ * @substream: rawmidi substream
++ *
++ * Return: the number of discarded bytes
++ */
++int snd_rawmidi_proceed(struct snd_rawmidi_substream *substream)
++{
++ struct snd_rawmidi_runtime *runtime = substream->runtime;
++ unsigned long flags;
++ int count = 0;
++
++ spin_lock_irqsave(&runtime->lock, flags);
++ if (runtime->avail < runtime->buffer_size) {
++ count = runtime->buffer_size - runtime->avail;
++ __snd_rawmidi_transmit_ack(substream, count);
++ }
++ spin_unlock_irqrestore(&runtime->lock, flags);
++ return count;
++}
++EXPORT_SYMBOL(snd_rawmidi_proceed);
++
+ static long snd_rawmidi_kernel_write1(struct snd_rawmidi_substream *substream,
+ const unsigned char __user *userbuf,
+ const unsigned char *kernelbuf,
+diff --git a/sound/core/seq/seq_virmidi.c b/sound/core/seq/seq_virmidi.c
+index cb988efd1ed0..e5a40795914a 100644
+--- a/sound/core/seq/seq_virmidi.c
++++ b/sound/core/seq/seq_virmidi.c
+@@ -149,9 +149,7 @@ static void snd_vmidi_output_work(struct work_struct *work)
+ /* discard the outputs in dispatch mode unless subscribed */
+ if (vmidi->seq_mode == SNDRV_VIRMIDI_SEQ_DISPATCH &&
+ !(vmidi->rdev->flags & SNDRV_VIRMIDI_SUBSCRIBE)) {
+- char buf[32];
+- while (snd_rawmidi_transmit(substream, buf, sizeof(buf)) > 0)
+- ; /* ignored */
++ snd_rawmidi_proceed(substream);
+ return;
+ }
+
+diff --git a/sound/usb/midi.c b/sound/usb/midi.c
+index dcfc546d81b9..b737f0ec77d0 100644
+--- a/sound/usb/midi.c
++++ b/sound/usb/midi.c
+@@ -1175,8 +1175,7 @@ static void snd_usbmidi_output_trigger(struct snd_rawmidi_substream *substream,
+ if (port->ep->umidi->disconnected) {
+ /* gobble up remaining bytes to prevent wait in
+ * snd_rawmidi_drain_output */
+- while (!snd_rawmidi_transmit_empty(substream))
+- snd_rawmidi_transmit_ack(substream, 1);
++ snd_rawmidi_proceed(substream);
+ return;
+ }
+ tasklet_schedule(&port->ep->tasklet);
+--
+2.20.1
+
diff --git a/series.conf b/series.conf
index 0de7f1a94b..c48da27b2f 100644
--- a/series.conf
+++ b/series.conf
@@ -40545,6 +40545,7 @@
patches.drivers/ALSA-hda-ca0132-Remove-input-select-enum-for-ZxR.patch
patches.drivers/ALSA-hda-ca0132-Add-ZxR-600-ohm-gain-control.patch
patches.drivers/ALSA-hda-ca0132-Add-ZxR-exit-commands.patch
+ patches.drivers/ALSA-rawmidi-A-lightweight-function-to-discard-pendi.patch
patches.drivers/ALSA-hda-sigmatel-Disable-automute-for-Elo-VuPoint.patch
patches.drivers/ALSA-usb-audio-update-quirk-for-B-W-PX-to-remove-mic.patch
patches.drivers/ALSA-usb-audio-Add-custom-mixer-status-quirks-for-RM.patch