Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1998071ybi; Thu, 18 Jul 2019 01:45:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqxVEDyssVKAvLADQ7I3+M7aJl0AAV7Wys1CP0hwwa7lQsCugCPK8RND1PWnYTwa3rBXPZ2J X-Received: by 2002:a63:3dc9:: with SMTP id k192mr6823418pga.428.1563439532566; Thu, 18 Jul 2019 01:45:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563439532; cv=none; d=google.com; s=arc-20160816; b=UFrmQy+AoRoKWRhEdQiOn1l3P9HFQLMJG/0IVQ6a+DlzAkP64jHQS0NwY/VJ5+EA0B l3gYFnYPhLP6YaXwBMsH7X+DO2HV452pOLq6RkXHDgfwVmKUEdG3E70PinSv9soTxOXc 1SJ2EcfmZ7P8jCaruM0r+nV3FGUf4Ls/YaoR2OEuzyfkSTBqQ5kPTz3Bq/eXQLGs9a0T i5ZfjbpuMMAyOUNFG62oVxncNSWcabifqMGO7Q/IGC5xUwp0llYkcB3+/pERr1yZklKZ jOdUvyXUHqfZJ0RoGtE3AtqJAYtdtg/BFO/ObZz01EqImCegXPx/p1Je1TnVnoUCo/DL kK7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=/OC4Bf1UT1nbfu+roN/Ki/gJPZkSbh9rEE7y4hVgUI4=; b=0sm5vmbUoix3fUQpVBuYVyMGCluicksXAlfTBKhGn2khxOtUmuZoEWirJKiabuatfu 9zjhK3TnmtuZJ/gjWv1bVAgHGLCC8xLiTQtxQCp7CFJ7W1SEnv1qgPCZeT/14ZoIksrD /kZLhRcJy7E/+/25GrX39oM6sCFUJgcjQHzmlGxqzp9fReYGQnaOzkP+3+RCxYMSwXNJ DyOcruww9sgKrycbZ7zeZ0+9NFZA0cQokJ3u6QJkb6ihk51Tx4jOSgRpdnmCnJXnZ9hA gYJW43TQ5RcSYz30UG3VjfZ0BMpbnvcKYAHKjHZE3KVR//Fium28uL6aDoeN/rCkVRUy 3dEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=SVJp5g+2; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=opensource.cirrus.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h12si1574408pjq.63.2019.07.18.01.45.16; Thu, 18 Jul 2019 01:45:32 -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=@cirrus.com header.s=PODMain02222019 header.b=SVJp5g+2; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=opensource.cirrus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389607AbfGRInp (ORCPT + 99 others); Thu, 18 Jul 2019 04:43:45 -0400 Received: from mx0a-001ae601.pphosted.com ([67.231.149.25]:47352 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2389515AbfGRIno (ORCPT ); Thu, 18 Jul 2019 04:43:44 -0400 Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6I8ZOCa026173; Thu, 18 Jul 2019 03:43:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=PODMain02222019; bh=/OC4Bf1UT1nbfu+roN/Ki/gJPZkSbh9rEE7y4hVgUI4=; b=SVJp5g+2hLPvSLla4SWIxu28jDfBToeqZusMlaYaoK3i2jVfLJr3u84x329hiTm57FBf IMKZJekQQ7Yf4fChIxaEUgVXhp6ni/iEdHMEOSjxOAaq5/lDgi2WkOV/8ShhMhmFgu0C +oquahUN+QjlhxzSYxqqom+hz0p6eN3CX95CtZ6wMoNFxFYFdg6tw5PONKQNFJ8AJDCp uS7JvX7fZbHATYj5QVdF3vmyQlp1c/WM7wc1BgodhXAjJ34Eczi2dI795VPfL/qrRf+B ig/QToPa5rjyfRqhd9a/Wm+PlD4oTXTGqLeDghv3ptAmBSKU1Oz4rNZLw9yBzv0KY49V RA== Authentication-Results: ppops.net; spf=fail smtp.mailfrom=ckeepax@opensource.cirrus.com Received: from ediex01.ad.cirrus.com ([87.246.76.36]) by mx0a-001ae601.pphosted.com with ESMTP id 2tt7xd8wjs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Thu, 18 Jul 2019 03:43:35 -0500 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1591.10; Thu, 18 Jul 2019 09:43:33 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.1591.10 via Frontend Transport; Thu, 18 Jul 2019 09:43:33 +0100 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id B09832A1; Thu, 18 Jul 2019 09:43:33 +0100 (BST) From: Charles Keepax To: CC: , , , Subject: [PATCH] ASoC: dapm: Fix handling of custom_stop_condition on DAPM graph walks Date: Thu, 18 Jul 2019 09:43:33 +0100 Message-ID: <20190718084333.15598-1-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-SPF-Result: fail X-Proofpoint-SPF-Record: v=spf1 include:spf-001ae601.pphosted.com include:spf.protection.outlook.com -all X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=940 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1907180099 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 f013b24c050a1..f73882cf0031d 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -1157,8 +1157,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) { @@ -1195,8 +1195,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.11.0