Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3518505pxf; Mon, 15 Mar 2021 11:20:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKWkTZcAXinISWEwQRL9CCTDmDuY//3vh/+J91MtHcEUMugr0YTK8DDFvP8Ii1rUySURg3 X-Received: by 2002:a05:6402:4395:: with SMTP id o21mr30944217edc.22.1615832400964; Mon, 15 Mar 2021 11:20:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832400; cv=none; d=google.com; s=arc-20160816; b=TepNl4/lm2vj18+cHBdBJW/HhrLPZKkYdq0rKchCqcalqTPNWSYT+CVXGfvgpP54/g 35pE4B/Yt7xWi8rPE4YOoUjGFZbPUutnA7/67yqSKj/5kMXzcryuvbpmIodL0fVGEyaa RJJOF6WNmGE5O3gllrkd7YswIZIvm2ETW7NRIiwWfokPYktPZMFWS0dZ34lfbe66GnVd gbAU1amW1ts9HqcIQgoWz4zpc9sfxRtMJccaKHAKoS1IK6JOg2dNnZSpkogTVZmFzwKH YbFXa7m0alRcmZ3PSIlziYIqph01P28m0VAPjVnZm7kbfEEWYULKD8PtSkA5k0iDN//D K5yg== 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=n0iO3mnlANerdvkW6ZB/pZF0J4wWKqda5bHyBNeaRJU=; b=B7guhP49XZ8zpbgp0TrT3w0/VQFw3Ag61OxvhdjPFFFc4CR9utwZOizs8AbSg3fPwe b0GP4GXvlX3WCYcglT7beQbSbioAa+D8Jqq2b3tIu6pXDH+4AVLKTx5A+QXpgdJySgxm 3sAKNqSl/+JwqsEigrJp9SRJ6ql+KOnRGIHrYUxAtsKNd+0e/rIIXAJC+ZP9Livva5Xx fWNdECv8YYzMXPWd0TGVY10TxSjTSjAIfhdIY4khjv1zfQ46VG54oEB1sYGTSqwjEuUX WSdMoh3soSEEli5IkRpYiJ6bEcvj1RcuuIJWncquwaVXYCPtvPVW3rF6TEIb4pJ/2Zyf wPEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dqRYMX1H; 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 b6si12464339eju.321.2021.03.15.11.19.38; Mon, 15 Mar 2021 11:20:00 -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=dqRYMX1H; 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 S232706AbhCOOSb (ORCPT + 99 others); Mon, 15 Mar 2021 10:18:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:36788 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232761AbhCON7l (ORCPT ); Mon, 15 Mar 2021 09:59:41 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 432C364F17; Mon, 15 Mar 2021 13:59:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816766; bh=1+oiQI9T+BEZ7+cq5WdB+SVZL/j02OZ6fOiHXpw0xMY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dqRYMX1HqE3MYE1Ag60mIzD9QSgRHfUEmbWxh/rVrqwPMbNI/nuks7/PLu3NtNLMf 0BhjBwwjZHbhZDVOGop27NnC3o4t6kIHfJk+W6/h4ZxL2qapD86RqCxAziD9+iLcU/ 37vS8B5hFfMGtsQKeV22yr1jnSTapaL4EVE2Eqno= 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.10 102/290] media: usbtv: Fix deadlock on suspend Date: Mon, 15 Mar 2021 14:53:15 +0100 Message-Id: <20210315135545.366669444@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135541.921894249@linuxfoundation.org> References: <20210315135541.921894249@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 @@ -371,7 +371,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; } }