LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] sound: usb: get lock before calling usb_enable_autosuspend()
@ 2021-08-02 22:53 Salah Triki
2021-08-03 7:40 ` Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: Salah Triki @ 2021-08-02 22:53 UTC (permalink / raw)
To: Jaroslav Kysela, Takashi Iwai, Pavel Skripkin, Kai-Heng Feng,
Mark Brown, Joe Perches
Cc: alsa-devel, linux-kernel
Based on the documentation of usb_enable_autosuspend(), the
caller must hold udev's device lock.
Signed-off-by: Salah Triki <salah.triki@gmail.com>
---
sound/usb/card.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/sound/usb/card.c b/sound/usb/card.c
index 2f6a62416c05..9290ba0acd5f 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -907,8 +907,13 @@ static void usb_audio_disconnect(struct usb_interface *intf)
}
}
- if (chip->quirk_type & QUIRK_SETUP_DISABLE_AUTOSUSPEND)
- usb_enable_autosuspend(interface_to_usbdev(intf));
+ if (chip->quirk_type & QUIRK_SETUP_DISABLE_AUTOSUSPEND) {
+ struct usb_device *udev = interface_to_usbdev(intf);
+
+ usb_lock_device(udev);
+ usb_enable_autosuspend(udev);
+ usb_unlock_device(udev);
+ }
chip->num_interfaces--;
if (chip->num_interfaces <= 0) {
--
2.25.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] sound: usb: get lock before calling usb_enable_autosuspend()
2021-08-02 22:53 [PATCH] sound: usb: get lock before calling usb_enable_autosuspend() Salah Triki
@ 2021-08-03 7:40 ` Takashi Iwai
0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2021-08-03 7:40 UTC (permalink / raw)
To: Salah Triki
Cc: Jaroslav Kysela, Takashi Iwai, Pavel Skripkin, Kai-Heng Feng,
Mark Brown, Joe Perches, alsa-devel, linux-kernel
On Tue, 03 Aug 2021 00:53:39 +0200,
Salah Triki wrote:
>
> Based on the documentation of usb_enable_autosuspend(), the
> caller must hold udev's device lock.
The device lock is already held in the caller side (in the driver
core), hence this change will lead to a deadlock.
thanks,
Takashi
>
> Signed-off-by: Salah Triki <salah.triki@gmail.com>
> ---
> sound/usb/card.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/sound/usb/card.c b/sound/usb/card.c
> index 2f6a62416c05..9290ba0acd5f 100644
> --- a/sound/usb/card.c
> +++ b/sound/usb/card.c
> @@ -907,8 +907,13 @@ static void usb_audio_disconnect(struct usb_interface *intf)
> }
> }
>
> - if (chip->quirk_type & QUIRK_SETUP_DISABLE_AUTOSUSPEND)
> - usb_enable_autosuspend(interface_to_usbdev(intf));
> + if (chip->quirk_type & QUIRK_SETUP_DISABLE_AUTOSUSPEND) {
> + struct usb_device *udev = interface_to_usbdev(intf);
> +
> + usb_lock_device(udev);
> + usb_enable_autosuspend(udev);
> + usb_unlock_device(udev);
> + }
>
> chip->num_interfaces--;
> if (chip->num_interfaces <= 0) {
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-08-03 7:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-02 22:53 [PATCH] sound: usb: get lock before calling usb_enable_autosuspend() Salah Triki
2021-08-03 7:40 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).