Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3512647pxf; Mon, 15 Mar 2021 11:11:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzet+X6wX94OvuvY2QdvgEGNbqQ8hDV5jnZ10sIiK/kgGibeMA9s6u/8bbCi7equz8iDU3Z X-Received: by 2002:a05:6402:4405:: with SMTP id y5mr12495226eda.32.1615831883269; Mon, 15 Mar 2021 11:11:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615831883; cv=none; d=google.com; s=arc-20160816; b=el8LXRVHkKw+Acpma1/clAdJTSxzXnhZb+JvP9NWn52AUBrWFqYl4Cq5nAy44GkA1p rvIQ6IAeHi5C0GLbAvUmIWfa/G23jJEQKi3Sho7VFRRy+Yye90XbRvGkCwyZUuqRUJPA H2V1hv5Me57TCxANiKV0cHdzCrrvYRt8bwj5QenD0e9oHTroUHgKZuDbEZwLRsfx3pPS fo6kV3Av6SRqFpcLAutjmvMOL2EqPexGNip9DBeDAYOeOe3WmZh3kpqx8W6C5VWWyIY3 fdkIHQignD2mcQPbRRvhzQ16OeLaMp/WtmzJhs0Zqny6P187+0EYmUTVOhYxKMfnDwbJ 9CtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LATQ3oxtJk7BXCDGNG/n5bE1ufh0y9pHcIsnVw8ObU0=; b=v6aE2UdPexrelKy+OMSw4TmPGuopD8VjTMHH8uB/SpiyyjRefwAWnFj9i0CjYqcFeE Fstn7fKaL3O01SECar4mkHsQdE/CzXksVQhUKz73hW9DYFLcz6gDP4gY8IwZvSUb9t+x ML5p8XR64I43DilQlDm0EfYAgN7vBwvhbCCH2vurYLPVsNJXXefnF8HFg/UV1gTtYFsU 10G5O8y399VscP4hws0w7p/FKkxBD+49J4cPNiOnZHvK/N6Cvkusehi8aD3tu2lHoAUo S80QVO4HgkBxFPpXnlNMmDGsvNRoCnAnp21d+ef06bDZm8uuGTft1QMHfoirFuPXwoaP jvbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Yqr5/NxI"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qw16si10626682ejb.673.2021.03.15.11.10.52; Mon, 15 Mar 2021 11:11:23 -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=@linuxfoundation.org header.s=korg header.b="Yqr5/NxI"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235186AbhCOOLL (ORCPT + 99 others); Mon, 15 Mar 2021 10:11:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:37500 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231460AbhCON6W (ORCPT ); Mon, 15 Mar 2021 09:58:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id ED17A64F09; Mon, 15 Mar 2021 13:58:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816700; bh=qJ6QJ2Eug/caeEXe+T5TRyjcVE0TEXz068KRnTtgibc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yqr5/NxIyCIVa258IcLAbK/UIBkq+q7lik8EMYyi2a8V2m+C7wKrkrVDfqS2wK63x Cl2RdfbKcxXpm1zhMi7QlHyK2AER1eHlLastmKuLeUIuEb97Ti89okE9cXlqapyCgW vYaSpt5pGoD+q+b4u7z6AhEnhyxyd1SdNdESzMZk= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maxim Mikityanskiy , Hans Verkuil , Mauro Carvalho Chehab Subject: [PATCH 5.4 055/168] media: usbtv: Fix deadlock on suspend Date: Mon, 15 Mar 2021 14:54:47 +0100 Message-Id: <20210315135552.166965723@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135550.333963635@linuxfoundation.org> References: <20210315135550.333963635@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Maxim Mikityanskiy commit 8a7e27fd5cd696ba564a3f62cedef7269cfd0723 upstream. usbtv doesn't support power management, so on system suspend the .disconnect callback of the driver is called. The teardown sequence includes a call to snd_card_free. Its implementation waits until the refcount of the sound card device drops to zero, however, if its file is open, snd_card_file_add takes a reference, which can't be dropped during the suspend, because the userspace processes are already frozen at this point. snd_card_free waits for completion forever, leading to a hang on suspend. This commit fixes this deadlock condition by replacing snd_card_free with snd_card_free_when_closed, that doesn't wait until all references are released, allowing suspend to progress. Fixes: 63ddf68de52e ("[media] usbtv: add audio support") Signed-off-by: Maxim Mikityanskiy Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/media/usb/usbtv/usbtv-audio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/media/usb/usbtv/usbtv-audio.c +++ b/drivers/media/usb/usbtv/usbtv-audio.c @@ -399,7 +399,7 @@ void usbtv_audio_free(struct usbtv *usbt cancel_work_sync(&usbtv->snd_trigger); if (usbtv->snd && usbtv->udev) { - snd_card_free(usbtv->snd); + snd_card_free_when_closed(usbtv->snd); usbtv->snd = NULL; } }