Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp5222681ybl; Tue, 27 Aug 2019 01:03:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqwt7IHQlWen0XnkTzzKJeb7LMsDxppQbycjlHm/Zwg2lXhPFNh1F1DAuyZhj/YIc2pp7t1O X-Received: by 2002:a63:c006:: with SMTP id h6mr19912556pgg.290.1566893025064; Tue, 27 Aug 2019 01:03:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566893025; cv=none; d=google.com; s=arc-20160816; b=vdw7wnV4NiXvswdz5tWAkox+P/kwpH8nkpdSIvf5kJHsSd41dNFYELsEzgCpkNtrK1 dlk/OIGtTtjjeidCQMfmfk6DNAfKrkuZkIwe2CM2M9TwrGJzAtFJgC0wG7aejaEdJbIE vzqMO6Ooej8pH3tkz222U3UP2vtgBWcdJhb9XadngNSWbJEyy5Akbpltm7D3n+ky6QT7 l6w6nLVTCoflnSTIKzTR80eii7gbeVHzZqj6zM2lB3ZopGLG78O7p9xDTMgCX7zyrHIY YbMmfq/QUWqCPYMHOSzdz3DVE6yIuUwG0tzD1xQxuG044PEoOi/OyvN/lCY28C6JufAy B+WA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pfJQS0LCd7BKP2aSKKxn/g/Z053MwkPzjbgkkoNC1JY=; b=Xp+3WXVS3C1i3lvZ/qpOnOSw9yEX39AAeWyUqQ0jrr16yS2UlUH3bjHV268CpLH6MS uJyK1W5KcKAiOHeW+lEgwC5XVNWwNAX2FrHpHmUxMJA+GJNAtJ1xie5bBy0EvApWJ4LD /DG6EaUfhRVMm3xp6d67zOFaKKDmWW2BW0wu23f08z6en4WrnSwrTJ8iJ5Xovj4sXJKo GKgiPs00wGW2Q8NkB621c1bnUE9g5D98mtvpFBMfIxXyulrdc+wYYBLcTEa0szN8O1wV a2ynsj2niMTX+u7RPdH7dkVG2jARUuF8ywQ/sWNSUughE50At7Q89KlNSbJRnSJjGFD8 prcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="PR58BmR/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s3si11268567pgn.467.2019.08.27.01.03.30; Tue, 27 Aug 2019 01:03:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="PR58BmR/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730433AbfH0ICW (ORCPT + 99 others); Tue, 27 Aug 2019 04:02:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:58836 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731863AbfH0ICE (ORCPT ); Tue, 27 Aug 2019 04:02:04 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E3FCF20828; Tue, 27 Aug 2019 08:02:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566892923; bh=6abIy+WU9xfUE0ZIkiK0oS8B9mSv4+iueYbcm3+7bpg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PR58BmR/Ex4ZfQ8ypHTCczaQpRo4OjH/08W+IKIynmmMRgXXzL87UybUzXUf3z47L OMP6bpV2demUWMAa0x1h9hP1+KOQxa8y00AVfurQfwpwKLoiqEDJy5w44bEncL5eL9 W5X9HQxuKTUj7PUU2JgSXvTa+Z6XWVuvHjmXvYKk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Charles Keepax , Mark Brown , Sasha Levin Subject: [PATCH 5.2 018/162] ASoC: dapm: Fix handling of custom_stop_condition on DAPM graph walks Date: Tue, 27 Aug 2019 09:49:06 +0200 Message-Id: <20190827072738.963720616@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190827072738.093683223@linuxfoundation.org> References: <20190827072738.093683223@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 8dd26dff00c0636b1d8621acaeef3f6f3a39dd77 ] DPCM uses snd_soc_dapm_dai_get_connected_widgets to build a list of the widgets connected to a specific front end DAI so it can search through this list for available back end DAIs. The custom_stop_condition was added to is_connected_ep to facilitate this list not containing more widgets than is necessary. Doing so both speeds up the DPCM handling as less widgets need to be searched and avoids issues with CODEC to CODEC links as these would be confused with back end DAIs if they appeared in the list of available widgets. custom_stop_condition was implemented by aborting the graph walk when the condition is triggered, however there is an issue with this approach. Whilst walking the graph is_connected_ep should update the endpoints cache on each widget, if the walk is aborted the number of attached end points is unknown for that sub-graph. When the stop condition triggered, the original patch ignored the triggering widget and returned zero connected end points; a later patch updated this to set the triggering widget's cache to 1 and return that. Both of these approaches result in inaccurate values being stored in various end point caches as the values propagate back through the graph, which can result in later issues with widgets powering/not powering unexpectedly. As the original goal was to reduce the size of the widget list passed to the DPCM code, the simplest solution is to limit the functionality of the custom_stop_condition to the widget list. This means the rest of the graph will still be processed resulting in correct end point caches, but only widgets up to the stop condition will be added to the returned widget list. Fixes: 6742064aef7f ("ASoC: dapm: support user-defined stop condition in dai_get_connected_widgets") Fixes: 5fdd022c2026 ("ASoC: dpcm: play nice with CODEC<->CODEC links") Fixes: 09464974eaa8 ("ASoC: dapm: Fix to return correct path list in is_connected_ep.") Signed-off-by: Charles Keepax Link: https://lore.kernel.org/r/20190718084333.15598-1-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/soc-dapm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index c91df5a9c8406..835ce1ff188d9 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -1156,8 +1156,8 @@ static __always_inline int is_connected_ep(struct snd_soc_dapm_widget *widget, list_add_tail(&widget->work_list, list); if (custom_stop_condition && custom_stop_condition(widget, dir)) { - widget->endpoints[dir] = 1; - return widget->endpoints[dir]; + list = NULL; + custom_stop_condition = NULL; } if ((widget->is_ep & SND_SOC_DAPM_DIR_TO_EP(dir)) && widget->connected) { @@ -1194,8 +1194,8 @@ static __always_inline int is_connected_ep(struct snd_soc_dapm_widget *widget, * * Optionally, can be supplied with a function acting as a stopping condition. * This function takes the dapm widget currently being examined and the walk - * direction as an arguments, it should return true if the walk should be - * stopped and false otherwise. + * direction as an arguments, it should return true if widgets from that point + * in the graph onwards should not be added to the widget list. */ static int is_connected_output_ep(struct snd_soc_dapm_widget *widget, struct list_head *list, -- 2.20.1