Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2510649rwb; Mon, 3 Oct 2022 01:37:50 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7WLCzpitoS81zlh24vEJbkXIyzE11w8jHGsmV3J53wSTTsjUu+Yrp902M0BkCWNMk8/Nj2 X-Received: by 2002:a65:408b:0:b0:42a:55fb:60b0 with SMTP id t11-20020a65408b000000b0042a55fb60b0mr17913829pgp.431.1664786269988; Mon, 03 Oct 2022 01:37:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664786269; cv=none; d=google.com; s=arc-20160816; b=rQBAdfgwDEtTA0LpDXs7YeuwpBaJH7Lw98xLc1T+vlt1UtOovXSKFVuJ4PtjhHnVVR nVqBcsx2XbkSZfPnAhF0SIY69eCyRfcruDmbPIPjTKEShjhfxzZjXtPj4K7DGa6+sqy1 MWbc1EahZTsoAKJCBhFcaMVEyr0oyZuQZpVKm8e4OHMDCvcSUWxjZejcyheDJuy6WHYS 6uip0H++Nzl+usQIi4zGKuUMuOfd/C7oPvh4OyQuiFa5hfC/gqXhlMVh6CRx8u44vSnh jDPhupW8HranK+LVLPWhebni7kgHsmXLMqTMuAwpOGbWa9q6w/RlOs1qGdN7l5bXFrGW NymQ== 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=GbCo491yZgq6o48206lJpIvQuv0yDJA+90nfxTFNl7U=; b=Aozoo1PvyxGPRWYwJ7mH5i8AQvf2jJqZHO9aHDT9znpw8cw8iq+SSvyUNQYpNHcKYM VWgY2dnF0nbdKGViq1NLLR7ascj16vf7sOdkEgM1W/P2JUYnSoZBML6Xym2juzuZAxNA u/FD0fQkQ/p2CXATRDQfg0+f0kF5iDqCfc88hd6l2l54HUnV7G1QJH+PV1pUQvios003 Isny1+vG13ysc8oKbTGZFfF24pgCcrTs+CwvFm3OpswXYxq3itcBAc4JlR36t+ubsyD6 IYuelJkZeKuVbZLLMYNNHyI170x5/OvQ7q2YheGTGEdftVE7QUiw/vTSdWLYOvQYOLCp ziHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tYxFM0nG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 190-20020a6301c7000000b004412bb6b27asi9155366pgb.55.2022.10.03.01.37.38; Mon, 03 Oct 2022 01:37:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tYxFM0nG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230218AbiJCH2N (ORCPT + 99 others); Mon, 3 Oct 2022 03:28:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231167AbiJCH1T (ORCPT ); Mon, 3 Oct 2022 03:27:19 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A8B843618; Mon, 3 Oct 2022 00:19:00 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 5C94CB80E89; Mon, 3 Oct 2022 07:16:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA046C43148; Mon, 3 Oct 2022 07:16:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781408; bh=r9SMDNYMlc+TY4sI5YWGS0MJ2SeqlzjB8zbPnpwEWPs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tYxFM0nGOKW38lnV0uzovxXsdCCtLwMiyD/L7mLn16GopMdcA2WzWOkBBD5N7syGG sp4ER4frzJ7hSR4/OR+gwzBeSYZOv0v7D6ZipLYl6iawRWvtqpemvOZ/aoPfX6TR6E PndQClD+Sz7bJnE553N6j/nKRUxXWf6E2g4w3iGo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai , Sasha Levin Subject: [PATCH 5.15 01/83] ALSA: hda: Do disconnect jacks at codec unbind Date: Mon, 3 Oct 2022 09:10:26 +0200 Message-Id: <20221003070722.010820864@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070721.971297651@linuxfoundation.org> References: <20221003070721.971297651@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Takashi Iwai [ Upstream commit 37c4fd0db7c961145d9d1909ecab386fdf703c26 ] The HD-audio codec driver remove may happen also at dynamically unbinding during operation, hence it needs manual triggers of snd_device_disconnect() calls, while it's missing for the jack objects that are associated with the codec. This patch adds the manual disconnection call for jacks when the remove happens without card->shutdown (i.e. not under the full removal). Link: https://lore.kernel.org/r/20211117133040.20272-1-tiwai@suse.de Signed-off-by: Takashi Iwai Stable-dep-of: ead3d3c5b54f ("ALSA: hda: Fix hang at HD-audio codec unbinding due to refcount saturation") Signed-off-by: Sasha Levin --- sound/pci/hda/hda_bind.c | 2 ++ sound/pci/hda/hda_jack.c | 11 +++++++++++ sound/pci/hda/hda_jack.h | 1 + 3 files changed, 14 insertions(+) diff --git a/sound/pci/hda/hda_bind.c b/sound/pci/hda/hda_bind.c index 7153bd53e189..c572fb5886d5 100644 --- a/sound/pci/hda/hda_bind.c +++ b/sound/pci/hda/hda_bind.c @@ -14,6 +14,7 @@ #include #include #include "hda_local.h" +#include "hda_jack.h" /* * find a matching codec id @@ -158,6 +159,7 @@ static int hda_codec_driver_remove(struct device *dev) refcount_dec(&codec->pcm_ref); snd_hda_codec_disconnect_pcms(codec); + snd_hda_jack_tbl_disconnect(codec); wait_event(codec->remove_sleep, !refcount_read(&codec->pcm_ref)); snd_power_sync_ref(codec->bus->card); diff --git a/sound/pci/hda/hda_jack.c b/sound/pci/hda/hda_jack.c index f29975e3e98d..7d7786df60ea 100644 --- a/sound/pci/hda/hda_jack.c +++ b/sound/pci/hda/hda_jack.c @@ -158,6 +158,17 @@ snd_hda_jack_tbl_new(struct hda_codec *codec, hda_nid_t nid, int dev_id) return jack; } +void snd_hda_jack_tbl_disconnect(struct hda_codec *codec) +{ + struct hda_jack_tbl *jack = codec->jacktbl.list; + int i; + + for (i = 0; i < codec->jacktbl.used; i++, jack++) { + if (!codec->bus->shutdown && jack->jack) + snd_device_disconnect(codec->card, jack->jack); + } +} + void snd_hda_jack_tbl_clear(struct hda_codec *codec) { struct hda_jack_tbl *jack = codec->jacktbl.list; diff --git a/sound/pci/hda/hda_jack.h b/sound/pci/hda/hda_jack.h index 2abf7aac243a..ff7d289c034b 100644 --- a/sound/pci/hda/hda_jack.h +++ b/sound/pci/hda/hda_jack.h @@ -69,6 +69,7 @@ struct hda_jack_tbl * snd_hda_jack_tbl_get_from_tag(struct hda_codec *codec, unsigned char tag, int dev_id); +void snd_hda_jack_tbl_disconnect(struct hda_codec *codec); void snd_hda_jack_tbl_clear(struct hda_codec *codec); void snd_hda_jack_set_dirty_all(struct hda_codec *codec); -- 2.35.1