From: Sasha Levin Date: Mon, 4 Nov 2019 16:02:15 +0000 (-0500) Subject: fixes for 4.19 X-Git-Tag: v4.4.199~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=457cbcc6e135ff27c4d480a15b94ae4c3f8f4a93;p=thirdparty%2Fkernel%2Fstable-queue.git fixes for 4.19 Signed-off-by: Sasha Levin --- diff --git a/queue-4.19/alsa-timer-fix-mutex-deadlock-at-releasing-card.patch b/queue-4.19/alsa-timer-fix-mutex-deadlock-at-releasing-card.patch new file mode 100644 index 00000000000..5c54bb441ba --- /dev/null +++ b/queue-4.19/alsa-timer-fix-mutex-deadlock-at-releasing-card.patch @@ -0,0 +1,133 @@ +From 3bce624323e44126bf03a73651276aa9b07ff178 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 30 Oct 2019 22:42:57 +0100 +Subject: ALSA: timer: Fix mutex deadlock at releasing card + +From: Takashi Iwai + +[ Upstream commit a39331867335d4a94b6165e306265c9e24aca073 ] + +When a card is disconnected while in use, the system waits until all +opened files are closed then releases the card. This is done via +put_device() of the card device in each device release code. + +The recently reported mutex deadlock bug happens in this code path; +snd_timer_close() for the timer device deals with the global +register_mutex and it calls put_device() there. When this timer +device is the last one, the card gets freed and it eventually calls +snd_timer_free(), which has again the protection with the global +register_mutex -- boom. + +Basically put_device() call itself is race-free, so a relative simple +workaround is to move this put_device() call out of the mutex. For +achieving that, in this patch, snd_timer_close_locked() got a new +argument to store the card device pointer in return, and each caller +invokes put_device() with the returned object after the mutex unlock. + +Reported-and-tested-by: Kirill A. Shutemov +Cc: +Signed-off-by: Takashi Iwai +Signed-off-by: Sasha Levin +--- + sound/core/timer.c | 24 +++++++++++++++++------- + 1 file changed, 17 insertions(+), 7 deletions(-) + +diff --git a/sound/core/timer.c b/sound/core/timer.c +index 316794eb44017..ec74705f003b8 100644 +--- a/sound/core/timer.c ++++ b/sound/core/timer.c +@@ -240,7 +240,8 @@ static int snd_timer_check_master(struct snd_timer_instance *master) + return 0; + } + +-static int snd_timer_close_locked(struct snd_timer_instance *timeri); ++static int snd_timer_close_locked(struct snd_timer_instance *timeri, ++ struct device **card_devp_to_put); + + /* + * open a timer instance +@@ -252,6 +253,7 @@ int snd_timer_open(struct snd_timer_instance **ti, + { + struct snd_timer *timer; + struct snd_timer_instance *timeri = NULL; ++ struct device *card_dev_to_put = NULL; + int err; + + mutex_lock(®ister_mutex); +@@ -275,7 +277,7 @@ int snd_timer_open(struct snd_timer_instance **ti, + list_add_tail(&timeri->open_list, &snd_timer_slave_list); + err = snd_timer_check_slave(timeri); + if (err < 0) { +- snd_timer_close_locked(timeri); ++ snd_timer_close_locked(timeri, &card_dev_to_put); + timeri = NULL; + } + goto unlock; +@@ -327,7 +329,7 @@ int snd_timer_open(struct snd_timer_instance **ti, + timeri = NULL; + + if (timer->card) +- put_device(&timer->card->card_dev); ++ card_dev_to_put = &timer->card->card_dev; + module_put(timer->module); + goto unlock; + } +@@ -337,12 +339,15 @@ int snd_timer_open(struct snd_timer_instance **ti, + timer->num_instances++; + err = snd_timer_check_master(timeri); + if (err < 0) { +- snd_timer_close_locked(timeri); ++ snd_timer_close_locked(timeri, &card_dev_to_put); + timeri = NULL; + } + + unlock: + mutex_unlock(®ister_mutex); ++ /* put_device() is called after unlock for avoiding deadlock */ ++ if (card_dev_to_put) ++ put_device(card_dev_to_put); + *ti = timeri; + return err; + } +@@ -352,7 +357,8 @@ EXPORT_SYMBOL(snd_timer_open); + * close a timer instance + * call this with register_mutex down. + */ +-static int snd_timer_close_locked(struct snd_timer_instance *timeri) ++static int snd_timer_close_locked(struct snd_timer_instance *timeri, ++ struct device **card_devp_to_put) + { + struct snd_timer *timer = NULL; + struct snd_timer_instance *slave, *tmp; +@@ -404,7 +410,7 @@ static int snd_timer_close_locked(struct snd_timer_instance *timeri) + timer->hw.close(timer); + /* release a card refcount for safe disconnection */ + if (timer->card) +- put_device(&timer->card->card_dev); ++ *card_devp_to_put = &timer->card->card_dev; + module_put(timer->module); + } + +@@ -416,14 +422,18 @@ static int snd_timer_close_locked(struct snd_timer_instance *timeri) + */ + int snd_timer_close(struct snd_timer_instance *timeri) + { ++ struct device *card_dev_to_put = NULL; + int err; + + if (snd_BUG_ON(!timeri)) + return -ENXIO; + + mutex_lock(®ister_mutex); +- err = snd_timer_close_locked(timeri); ++ err = snd_timer_close_locked(timeri, &card_dev_to_put); + mutex_unlock(®ister_mutex); ++ /* put_device() is called after unlock for avoiding deadlock */ ++ if (card_dev_to_put) ++ put_device(card_dev_to_put); + return err; + } + EXPORT_SYMBOL(snd_timer_close); +-- +2.20.1 + diff --git a/queue-4.19/alsa-timer-simplify-error-path-in-snd_timer_open.patch b/queue-4.19/alsa-timer-simplify-error-path-in-snd_timer_open.patch new file mode 100644 index 00000000000..b117b43d279 --- /dev/null +++ b/queue-4.19/alsa-timer-simplify-error-path-in-snd_timer_open.patch @@ -0,0 +1,130 @@ +From 7e143128f8d1bba6d902e9cdb9b1714b297accdc Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 28 Mar 2019 17:11:10 +0100 +Subject: ALSA: timer: Simplify error path in snd_timer_open() + +From: Takashi Iwai + +[ Upstream commit 41672c0c24a62699d20aab53b98d843b16483053 ] + +Just a minor refactoring to use the standard goto for error paths in +snd_timer_open() instead of open code. The first mutex_lock() is +moved to the beginning of the function to make the code clearer. + +Signed-off-by: Takashi Iwai +Signed-off-by: Sasha Levin +--- + sound/core/timer.c | 39 ++++++++++++++++++++------------------- + 1 file changed, 20 insertions(+), 19 deletions(-) + +diff --git a/sound/core/timer.c b/sound/core/timer.c +index 61a0cec6e1f66..316794eb44017 100644 +--- a/sound/core/timer.c ++++ b/sound/core/timer.c +@@ -254,19 +254,20 @@ int snd_timer_open(struct snd_timer_instance **ti, + struct snd_timer_instance *timeri = NULL; + int err; + ++ mutex_lock(®ister_mutex); + if (tid->dev_class == SNDRV_TIMER_CLASS_SLAVE) { + /* open a slave instance */ + if (tid->dev_sclass <= SNDRV_TIMER_SCLASS_NONE || + tid->dev_sclass > SNDRV_TIMER_SCLASS_OSS_SEQUENCER) { + pr_debug("ALSA: timer: invalid slave class %i\n", + tid->dev_sclass); +- return -EINVAL; ++ err = -EINVAL; ++ goto unlock; + } +- mutex_lock(®ister_mutex); + timeri = snd_timer_instance_new(owner, NULL); + if (!timeri) { +- mutex_unlock(®ister_mutex); +- return -ENOMEM; ++ err = -ENOMEM; ++ goto unlock; + } + timeri->slave_class = tid->dev_sclass; + timeri->slave_id = tid->device; +@@ -277,13 +278,10 @@ int snd_timer_open(struct snd_timer_instance **ti, + snd_timer_close_locked(timeri); + timeri = NULL; + } +- mutex_unlock(®ister_mutex); +- *ti = timeri; +- return err; ++ goto unlock; + } + + /* open a master instance */ +- mutex_lock(®ister_mutex); + timer = snd_timer_find(tid); + #ifdef CONFIG_MODULES + if (!timer) { +@@ -294,25 +292,26 @@ int snd_timer_open(struct snd_timer_instance **ti, + } + #endif + if (!timer) { +- mutex_unlock(®ister_mutex); +- return -ENODEV; ++ err = -ENODEV; ++ goto unlock; + } + if (!list_empty(&timer->open_list_head)) { + timeri = list_entry(timer->open_list_head.next, + struct snd_timer_instance, open_list); + if (timeri->flags & SNDRV_TIMER_IFLG_EXCLUSIVE) { +- mutex_unlock(®ister_mutex); +- return -EBUSY; ++ err = -EBUSY; ++ timeri = NULL; ++ goto unlock; + } + } + if (timer->num_instances >= timer->max_instances) { +- mutex_unlock(®ister_mutex); +- return -EBUSY; ++ err = -EBUSY; ++ goto unlock; + } + timeri = snd_timer_instance_new(owner, timer); + if (!timeri) { +- mutex_unlock(®ister_mutex); +- return -ENOMEM; ++ err = -ENOMEM; ++ goto unlock; + } + /* take a card refcount for safe disconnection */ + if (timer->card) +@@ -321,16 +320,16 @@ int snd_timer_open(struct snd_timer_instance **ti, + timeri->slave_id = slave_id; + + if (list_empty(&timer->open_list_head) && timer->hw.open) { +- int err = timer->hw.open(timer); ++ err = timer->hw.open(timer); + if (err) { + kfree(timeri->owner); + kfree(timeri); ++ timeri = NULL; + + if (timer->card) + put_device(&timer->card->card_dev); + module_put(timer->module); +- mutex_unlock(®ister_mutex); +- return err; ++ goto unlock; + } + } + +@@ -341,6 +340,8 @@ int snd_timer_open(struct snd_timer_instance **ti, + snd_timer_close_locked(timeri); + timeri = NULL; + } ++ ++ unlock: + mutex_unlock(®ister_mutex); + *ti = timeri; + return err; +-- +2.20.1 + diff --git a/queue-4.19/alsa-usb-audio-add-dsd-support-for-gustard-u16-x26-u.patch b/queue-4.19/alsa-usb-audio-add-dsd-support-for-gustard-u16-x26-u.patch new file mode 100644 index 00000000000..00ab25bbaa3 --- /dev/null +++ b/queue-4.19/alsa-usb-audio-add-dsd-support-for-gustard-u16-x26-u.patch @@ -0,0 +1,36 @@ +From 5af0053be26bce2006cdeddaf9c6f0fca93dd6b7 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 24 Oct 2019 12:27:14 +0200 +Subject: ALSA: usb-audio: Add DSD support for Gustard U16/X26 USB Interface + +From: Justin Song + +[ Upstream commit e2995b95a914bbc6b5352be27d5d5f33ec802d2c ] + +This patch adds native DSD support for Gustard U16/X26 USB Interface. +Tested using VID and fp->dsd_raw method. + +Signed-off-by: Justin Song +Cc: +Link: https://lore.kernel.org/r/CA+9XP1ipsFn+r3bCBKRinQv-JrJ+EHOGBdZWZoMwxFv0R8Y1MQ@mail.gmail.com +Signed-off-by: Takashi Iwai +Signed-off-by: Sasha Levin +--- + sound/usb/quirks.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c +index 28035c59cb37c..c102c0377ad91 100644 +--- a/sound/usb/quirks.c ++++ b/sound/usb/quirks.c +@@ -1434,6 +1434,7 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip, + case 0x23ba: /* Playback Designs */ + case 0x25ce: /* Mytek devices */ + case 0x278b: /* Rotel? */ ++ case 0x292b: /* Gustard/Ess based devices */ + case 0x2ab6: /* T+A devices */ + case 0x3842: /* EVGA */ + case 0xc502: /* HiBy devices */ +-- +2.20.1 + diff --git a/queue-4.19/alsa-usb-audio-dsd-auto-detection-for-playback-desig.patch b/queue-4.19/alsa-usb-audio-dsd-auto-detection-for-playback-desig.patch new file mode 100644 index 00000000000..3ff7e927d79 --- /dev/null +++ b/queue-4.19/alsa-usb-audio-dsd-auto-detection-for-playback-desig.patch @@ -0,0 +1,49 @@ +From afde2fdfe3d602675befdd3c0724f5ad8518a0e7 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 28 Aug 2019 00:08:46 +0300 +Subject: ALSA: usb-audio: DSD auto-detection for Playback Designs + +From: Jussi Laako + +[ Upstream commit eb7505d52a2f8b0cfc3fd7146d8cb2dab5a73f0d ] + +Add DSD support auto-detection for newer Playback Designs devices. Older +device generations have a different USB interface implementation. + +Keep the auto-detection VID whitelist sorted. + +Signed-off-by: Jussi Laako +Signed-off-by: Takashi Iwai +Signed-off-by: Sasha Levin +--- + sound/usb/quirks.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c +index e5dde06c31a6f..0a8a0978a2dba 100644 +--- a/sound/usb/quirks.c ++++ b/sound/usb/quirks.c +@@ -1343,7 +1343,8 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip, + struct usb_interface *iface; + + /* Playback Designs */ +- if (USB_ID_VENDOR(chip->usb_id) == 0x23ba) { ++ if (USB_ID_VENDOR(chip->usb_id) == 0x23ba && ++ USB_ID_PRODUCT(chip->usb_id) < 0x0110) { + switch (fp->altsetting) { + case 1: + fp->dsd_dop = true; +@@ -1431,8 +1432,9 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip, + * from XMOS/Thesycon + */ + switch (USB_ID_VENDOR(chip->usb_id)) { +- case 0x20b1: /* XMOS based devices */ + case 0x152a: /* Thesycon devices */ ++ case 0x20b1: /* XMOS based devices */ ++ case 0x23ba: /* Playback Designs */ + case 0x25ce: /* Mytek devices */ + case 0x2ab6: /* T+A devices */ + case 0x3842: /* EVGA */ +-- +2.20.1 + diff --git a/queue-4.19/alsa-usb-audio-update-dsd-support-quirks-for-oppo-an.patch b/queue-4.19/alsa-usb-audio-update-dsd-support-quirks-for-oppo-an.patch new file mode 100644 index 00000000000..5973a8246ea --- /dev/null +++ b/queue-4.19/alsa-usb-audio-update-dsd-support-quirks-for-oppo-an.patch @@ -0,0 +1,59 @@ +From e06481590dc2ccbfad356687931c8c3cf5ede00d Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 28 Aug 2019 00:08:47 +0300 +Subject: ALSA: usb-audio: Update DSD support quirks for Oppo and Rotel + +From: Jussi Laako + +[ Upstream commit 0067e154b11e236d62a7a8205f321b097c21a35b ] + +Oppo has issued firmware updates that change alt setting used for DSD +support. However, these devices seem to support auto-detection, so +support is moved from explicit whitelisting to auto-detection. + +Also Rotel devices have USB interfaces that support DSD with +auto-detection. + +Signed-off-by: Jussi Laako +Signed-off-by: Takashi Iwai +Signed-off-by: Sasha Levin +--- + sound/usb/quirks.c | 6 ++---- + 1 file changed, 2 insertions(+), 4 deletions(-) + +diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c +index 0a8a0978a2dba..28035c59cb37c 100644 +--- a/sound/usb/quirks.c ++++ b/sound/usb/quirks.c +@@ -1361,9 +1361,6 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip, + /* XMOS based USB DACs */ + switch (chip->usb_id) { + case USB_ID(0x1511, 0x0037): /* AURALiC VEGA */ +- case USB_ID(0x22d9, 0x0416): /* OPPO HA-1 */ +- case USB_ID(0x22d9, 0x0436): /* OPPO Sonica */ +- case USB_ID(0x22d9, 0x0461): /* OPPO UDP-205 */ + case USB_ID(0x2522, 0x0012): /* LH Labs VI DAC Infinity */ + case USB_ID(0x2772, 0x0230): /* Pro-Ject Pre Box S2 Digital */ + if (fp->altsetting == 2) +@@ -1377,7 +1374,6 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip, + case USB_ID(0x16d0, 0x0733): /* Furutech ADL Stratos */ + case USB_ID(0x16d0, 0x09db): /* NuPrime Audio DAC-9 */ + case USB_ID(0x1db5, 0x0003): /* Bryston BDA3 */ +- case USB_ID(0x22d9, 0x0426): /* OPPO HA-2 */ + case USB_ID(0x22e1, 0xca01): /* HDTA Serenade DSD */ + case USB_ID(0x249c, 0x9326): /* M2Tech Young MkIII */ + case USB_ID(0x2616, 0x0106): /* PS Audio NuWave DAC */ +@@ -1434,8 +1430,10 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip, + switch (USB_ID_VENDOR(chip->usb_id)) { + case 0x152a: /* Thesycon devices */ + case 0x20b1: /* XMOS based devices */ ++ case 0x22d9: /* Oppo */ + case 0x23ba: /* Playback Designs */ + case 0x25ce: /* Mytek devices */ ++ case 0x278b: /* Rotel? */ + case 0x2ab6: /* T+A devices */ + case 0x3842: /* EVGA */ + case 0xc502: /* HiBy devices */ +-- +2.20.1 + diff --git a/queue-4.19/series b/queue-4.19/series index b741bd32767..87b7f89d2f0 100644 --- a/queue-4.19/series +++ b/queue-4.19/series @@ -142,3 +142,8 @@ nfc-pn533-fix-use-after-free-and-memleaks.patch bonding-fix-potential-null-deref-in-bond_update_slave_arr.patch net-usb-sr9800-fix-uninitialized-local-variable.patch sch_netem-fix-rcu-splat-in-netem_enqueue.patch +alsa-timer-simplify-error-path-in-snd_timer_open.patch +alsa-timer-fix-mutex-deadlock-at-releasing-card.patch +alsa-usb-audio-dsd-auto-detection-for-playback-desig.patch +alsa-usb-audio-update-dsd-support-quirks-for-oppo-an.patch +alsa-usb-audio-add-dsd-support-for-gustard-u16-x26-u.patch