Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3517576pxf; Mon, 15 Mar 2021 11:18:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwciBSzcqjnaLP7sGPdLbwJ/eUzCRK12SeNG2S3a8AGo8YZTTwCFXojS0yLhnn4P4PPHQqB X-Received: by 2002:a17:906:f896:: with SMTP id lg22mr24562113ejb.124.1615832303677; Mon, 15 Mar 2021 11:18:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832303; cv=none; d=google.com; s=arc-20160816; b=UFDqZD85l00zcxT6dlxin/NVy42x8Gh/wQc1oMFd3U2WubiVuspHgItVD74oDmQ466 5hD02SDP1MXWk3f4KW//0EuQr8n0LffknHCC7xWi6uETx6pC2YTR1H2X0jX/LKQZ81QR +2+eCv+fkW9dsjXkYJuGHQu/2p605dHEiaOF27C/AU0aE9IFSicgayoafDolN+A67iJx /7EZWJrDLy3+VOSecn+Qz0Z7L2s84EwTW3+22v74CQG8bAl1dzpeVIo0eB4JaLeLgfrf HRkpY6Qf409BYHpEKIkTInP3Xb43MPYWJeCwj6/VvH468cb1jm2C721OKRnYvVuu68CL ldIw== 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=bFjuTL3cF1SwfnibNBz0hqqtYZsbhr0GRqP6ZUBVXtthesj/yE3j21QH5eIl1PSrL6 jKHPmScdWakeDv7CyPCEXZn2Lw9+Hfe8K2uQJLTm0QKWANqOYaGqWA4haOpH2K83vuiE FxbuRS27QLI47GgcAPe3VkvOhFU9OvNBXgUew5XYRWHsFSvWiMVzv6LF7UvLtuTipWL+ VGlrHNRfPH1pVwza1jC7s6vaUIDdrr0eOxsY+XNS2d/gZVqT0HWsQBMkOPXh7Q90Rx2c ftFwE+AsuTf/6yiN0EyRAJbi5q5qY2EjYtf8wUDHGmhgKzvhFErSRd7l+d14IxEP86ih xMVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tQpIEuGK; 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 z17si11109428ejc.207.2021.03.15.11.18.01; Mon, 15 Mar 2021 11:18: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=tQpIEuGK; 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 S236823AbhCOOQt (ORCPT + 99 others); Mon, 15 Mar 2021 10:16:49 -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 S231265AbhCON7R (ORCPT ); Mon, 15 Mar 2021 09:59:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B345564F23; Mon, 15 Mar 2021 13:58:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816739; bh=qJ6QJ2Eug/caeEXe+T5TRyjcVE0TEXz068KRnTtgibc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tQpIEuGKBmzFAjX5f4OpPRxs0t5autx4WwK6OsVpZMM6Gdj65KUYZltSXV4qH7LTh v3otvvdEQ20CvNdtw3uyoQztJMYQgStkp4+tuTf2sUseK4/DYPcJlPs346vsJkLxXZ 5BXYFuqtP1YCz0KymADLCWh9gwqKfftUS2P4nvRk= 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 4.19 038/120] media: usbtv: Fix deadlock on suspend Date: Mon, 15 Mar 2021 14:56:29 +0100 Message-Id: <20210315135721.246503670@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135720.002213995@linuxfoundation.org> References: <20210315135720.002213995@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; } }