public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Salah Triki <salah.triki@gmail.com>
Cc: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	Pavel Skripkin <paskripkin@gmail.com>,
	Kai-Heng Feng <kai.heng.feng@canonical.com>,
	Mark Brown <broonie@kernel.org>, Joe Perches <joe@perches.com>,
	alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sound: usb: get lock before calling  usb_enable_autosuspend()
Date: Tue, 03 Aug 2021 09:40:50 +0200	[thread overview]
Message-ID: <s5hsfzrvuv1.wl-tiwai@suse.de> (raw)
In-Reply-To: <20210802225339.GA1461793@pc>

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
> 

      reply	other threads:[~2021-08-03  7:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s5hsfzrvuv1.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=joe@perches.com \
    --cc=kai.heng.feng@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paskripkin@gmail.com \
    --cc=perex@perex.cz \
    --cc=salah.triki@gmail.com \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox