Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp2232689pxy; Tue, 3 Aug 2021 00:42:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1yLXv/6UevULIyYhqU6kC/t92WNOXOD0FiNdyToT+h0lUqe8xYyJVAKVPxQZ6/pPN6qcJ X-Received: by 2002:a17:906:394:: with SMTP id b20mr19308312eja.462.1627976553167; Tue, 03 Aug 2021 00:42:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627976553; cv=none; d=google.com; s=arc-20160816; b=jGTwjZHR19G8WyaTK/KfPVQF/r8ltemtUe0Ul/5Pedq15ogv52f7pD2Q+IcSUc6Qz7 NQzYduUyOfijJ7NIRcVpAOU/FvRK+a2EqEF9D3E3VnzP30iy1KhFnCohLhSFxhnrRp4r 8fKKg7Lg12nd1EtHsD8pXvjBYsj3ty6T9eTm8EleJwVoIQAr61kUm3tuJ+DarQZbB1w1 NJ9GRqsLtQABNEnxInFmf3akaV3oK1dxmwe3K97XvjFT6e4XaqfdZV9GhypxjcIsuf/+ PE7tF83lEPHl1bWaPKqcXutt4I3HsFLOAWkjQrFwVuJxZca4w/BYMXeFhGLJ9wxq5akt mwJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature:dkim-signature; bh=cgOa2hYCzUhkzA5o+v8md7JL/JoOvkhgxW1hqHyI39s=; b=DhEcUFcXRlxJZxJGSWtQxlVdbQwwoOQAukao/6NWaBI6zuEshYFRFi09guriAAmGjz qWUWTSqoPVfB1PLKKgqP4Xgx7oyVVWDn60RG7NDUlBjG1XqMRMn838AA42frlOnXONsc QNYpdaOhF4fT4Cppf+nCwd0dqbQFLTemb4DnudK6kD46LDY6rLhGUiAr49OOtp57ZZVl RWeFo982fHMe58BoOWQC04An/MhH8z5hui/l1t/7cDkVgoMOOiutQSthPedLhe8EAWUh O2EZdqdwUBQxl03+4FPbLrc0QHkO/gSw8Y7oGMUhqddE+vLj8bMAqfLaa4YlZfUzFTdf SGyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=GWdBVFHt; dkim=neutral (no key) header.i=@suse.de header.b=uIXpxfNL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d18si11917709ejy.659.2021.08.03.00.42.08; Tue, 03 Aug 2021 00:42:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=GWdBVFHt; dkim=neutral (no key) header.i=@suse.de header.b=uIXpxfNL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234137AbhHCHlC (ORCPT + 99 others); Tue, 3 Aug 2021 03:41:02 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:37260 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234082AbhHCHlC (ORCPT ); Tue, 3 Aug 2021 03:41:02 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id B787E2207D; Tue, 3 Aug 2021 07:40:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1627976450; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=cgOa2hYCzUhkzA5o+v8md7JL/JoOvkhgxW1hqHyI39s=; b=GWdBVFHtdj6usslVn+rJCIORJC6ccdbjbaeT2m22sp47kU+JZZe8/Dx+2/rMPLdFkHt3MA UuIzkhEnTOkudhwkxdsKVcbM9uFp0nl+UCTbfQbjzrxkqf46lxzN1CcoAgocoqC+eMTafM /pYpsGZRTbpELwKLPAMWFwwPkl+YPwk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1627976450; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=cgOa2hYCzUhkzA5o+v8md7JL/JoOvkhgxW1hqHyI39s=; b=uIXpxfNLscdavhW0rkVpJ8hFabhjX7mE/eJ/z2P5b0Fzgxjv8vG2xF85S5qnSPsCdEKPxD 8UTVCMIBzpL4KPAw== Received: from alsa1.suse.de (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 8F119A3BC9; Tue, 3 Aug 2021 07:40:50 +0000 (UTC) Date: Tue, 03 Aug 2021 09:40:50 +0200 Message-ID: From: Takashi Iwai To: Salah Triki Cc: Jaroslav Kysela , Takashi Iwai , Pavel Skripkin , Kai-Heng Feng , Mark Brown , Joe Perches , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] sound: usb: get lock before calling usb_enable_autosuspend() In-Reply-To: <20210802225339.GA1461793@pc> References: <20210802225339.GA1461793@pc> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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 >