Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4455364ioa; Wed, 27 Apr 2022 04:22:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhnO7Iz1V1Ie7mZHoOodLlwnXxYsCL/3jxCeX1gtSqddwts/5KZi1wOtmwW3qp49w+kJSD X-Received: by 2002:a17:902:9a81:b0:158:b09e:5287 with SMTP id w1-20020a1709029a8100b00158b09e5287mr28242043plp.170.1651058558938; Wed, 27 Apr 2022 04:22:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651058558; cv=none; d=google.com; s=arc-20160816; b=cR+9rIsXiF9XO3cvMvMs4kd5xsh3SFo72BKws3ApUsZbj8a5x6TI+cOaZwiCoRNhLH utZg4xhQdC8accwL1ZYSuQ6OG8vlZyzFYOa36zoY3GVxHSIJ8rn0JXLoVY8XN1PJLYJw AkSxco92qrLkmkHuoyjae9gm7zz0wwltU7h/T8yLkNeit3N8axRU54vE/5WUPV120Zwc +gNlBgs+rRn2pns/MrdXPCa26O7UZFQxOHAidcnMqP+e5yOfl7VsQlSbCkA8F8kKc+1I fHC4tvMJmz+wrBib0Uu7oxcgcI370oFDaFryQTseJnfr4JbHjXeLhfxWNj3CFg2l9jJy XxnQ== 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=EHY/NZyP3+gmQ8mXiTn7zYy+DAj+MBdjrVcEjPE2zMg=; b=XPVqiOtntPXGxq06KkzHzKmCMss1+tPsKT6YNHocsy/mt3DOXHW1qtXsLlvx107rf5 U4VXDE2NCSJYaXO2HkX3xdpoTpVpw5edMTgtMmApHGiJ7G30DflXsSUPwbSYttKBxDaO x/468EFNjr+CKe0LB5q52976tqJhS/EhNHx8/6viWZXOxzVPq2W2h6eGHtfroYI6lvnO qDDvXRSnTbiPyXChgcch/i904ZA63cmb3sWxkT2pu4H5lkGm/3wG19eHPFsbHBRyxZSS ag1y8xiPb1ZUl7W+bXGld2inaiD4ZkOqWTr+PhZ0aviBjG2aRyP9Qn3VIbtQEAxCVsJF 0kqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=E5d8wj8C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id a10-20020a170902b58a00b0015892288d6asi1227329pls.386.2022.04.27.04.22.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 04:22:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=E5d8wj8C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D3378476F20; Wed, 27 Apr 2022 03:16:39 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348650AbiDZJk3 (ORCPT + 99 others); Tue, 26 Apr 2022 05:40:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346597AbiDZJLd (ORCPT ); Tue, 26 Apr 2022 05:11:33 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21D4A18073D; Tue, 26 Apr 2022 01:49:49 -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 6EEB5B81CF2; Tue, 26 Apr 2022 08:49:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D69A4C385A4; Tue, 26 Apr 2022 08:49:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650962977; bh=UWC72dGlqRXg6M7M3WA8IxxrcfepfpHwL+5g3PuDktc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E5d8wj8CJINQvRxmnGUXDGDAkbud3+Nt9iyxhBZDZyH/yfW5id9F60CyPM8S87gQo mShdhonId5OMB+eph8OJDHaQ+SaoaJ8EzYt8ITA8dXQiHRwPYQnB04wIQluTDOAklh mzJZBrjt3miAG2Jmmrwf3aL6kxnnjl4eln1zCUx4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pierre-Louis Bossart , Ranjani Sridharan , =?UTF-8?q?P=C3=A9ter=20Ujfalusi?= , Bard Liao , Mark Brown Subject: [PATCH 5.17 144/146] ASoC: SOF: topology: cleanup dailinks on widget unload Date: Tue, 26 Apr 2022 10:22:19 +0200 Message-Id: <20220426081754.107256382@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220426081750.051179617@linuxfoundation.org> References: <20220426081750.051179617@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=unavailable 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: Pierre-Louis Bossart commit 20744617bdbafe2e7fb7bf5401f616e24bde4471 upstream. We set the cpu_dai capture_ or playback_widget on widget_ready but never clear them, which leads to failures when unloading/reloading a topology in modprobe/rmmod tests BugLink: https://github.com/thesofproject/linux/issues/3535 Fixes: 311ce4fe7637 ("ASoC: SOF: Add support for loading topologies") Signed-off-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Reviewed-by: Péter Ujfalusi Reviewed-by: Bard Liao Link: https://lore.kernel.org/r/20220406191606.254576-1-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- sound/soc/sof/topology.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) --- a/sound/soc/sof/topology.c +++ b/sound/soc/sof/topology.c @@ -1569,6 +1569,46 @@ static int sof_widget_load_buffer(struct return 0; } +static void sof_disconnect_dai_widget(struct snd_soc_component *scomp, + struct snd_soc_dapm_widget *w) +{ + struct snd_soc_card *card = scomp->card; + struct snd_soc_pcm_runtime *rtd; + struct snd_soc_dai *cpu_dai; + int i; + + if (!w->sname) + return; + + list_for_each_entry(rtd, &card->rtd_list, list) { + /* does stream match DAI link ? */ + if (!rtd->dai_link->stream_name || + strcmp(w->sname, rtd->dai_link->stream_name)) + continue; + + switch (w->id) { + case snd_soc_dapm_dai_out: + for_each_rtd_cpu_dais(rtd, i, cpu_dai) { + if (cpu_dai->capture_widget == w) { + cpu_dai->capture_widget = NULL; + break; + } + } + break; + case snd_soc_dapm_dai_in: + for_each_rtd_cpu_dais(rtd, i, cpu_dai) { + if (cpu_dai->playback_widget == w) { + cpu_dai->playback_widget = NULL; + break; + } + } + break; + default: + break; + } + } +} + /* bind PCM ID to host component ID */ static int spcm_bind(struct snd_soc_component *scomp, struct snd_sof_pcm *spcm, int dir) @@ -2449,6 +2489,9 @@ static int sof_widget_unload(struct snd_ kfree(dai->dai_config); list_del(&dai->list); } + + sof_disconnect_dai_widget(scomp, widget); + break; default: break;