Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp660663rdg; Thu, 12 Oct 2023 18:01:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEvamcn4JyfqblV88bs1aw8RE/q1nxrHcRdpsG90fPRz4ZDTSHSWRajZBNN1qWmuaGEqKuA X-Received: by 2002:a05:6358:260a:b0:143:8d26:ec91 with SMTP id l10-20020a056358260a00b001438d26ec91mr27918050rwc.11.1697158902019; Thu, 12 Oct 2023 18:01:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697158901; cv=none; d=google.com; s=arc-20160816; b=VAXyWai5Fgd9KCGs9/0HekCoH9v6JPSJ9XZplLBc5NwRlcHf1+BNNW+KtYROdYL+H0 j1NGH3LIzLytsflo86yDY1mYmqSdwin0bLJLrHlznS5KnfmGxjcJc9BRqduKq2ivRKst TBtq/fGDh9Ce+Byo2kXUOpMo4MLXyxuKV3NTrQvXjOaX0s0nT+cMsKJQSAgNKxAmdzOe QN5rLS81KqPoGmcwBrePz+424WkoXubxqwxjOK6D1y8bUdSVDKhjiejbPm6CFnw9Zja3 YbPwxvlff4CoBObLf60WcEk2m3RLoua8rxqIjug+1R/S3VKERKsdtsKiuD3YEThDYzwf 7QdQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=a4QbVOiHxf7tAx2WKfNjiRRXDdimsgJ/9m6oBIHBNwg=; fh=V418nF4nYWw8hKRvFrxDWT05jiPy6P8dfDLRoWcHJ4I=; b=TlD9g4BYfOyRdvsqvz3FYGS3ryOtRRo8wixCtk8UVxvkqGCEvyTuB9U7tiYPoJa93D 0UyxZS9kHYRbD/biVWxuXpvy+uKwYe7Q4XEgMzW2kIzJAomuQdXx+XLbOSNUhQgR8QJe qFRLzLREB7dFZLulNfah5xMOxstm9C/NvGghgP0bPViDQDu16Y99wwRXeK2Zxgdk4snP rJuKofGNqQyy+6TpFXtA78Ym7TG9ttl6PEvNq7C4ZNfdeVH/SzKuK27mI1EnjVUpN/ZZ E6Trh2yI+bruhVDPb5yWOKG8/Dkq/WwJnvQVtysMazloH8AbgMa762L88Kq6xU++mFkM DWnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="njhLgN/M"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id j63-20020a638042000000b005aaab9e7bcfsi505752pgd.388.2023.10.12.18.01.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 18:01:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="njhLgN/M"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id D27928065EC0; Thu, 12 Oct 2023 18:01:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229449AbjJMBA7 (ORCPT + 99 others); Thu, 12 Oct 2023 21:00:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229437AbjJMBA7 (ORCPT ); Thu, 12 Oct 2023 21:00:59 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36DADD6 for ; Thu, 12 Oct 2023 18:00:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697158857; x=1728694857; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=A8vxlDAoN4G/XceJuG50VnLiTJyN1JUtwmw+OsBrbOE=; b=njhLgN/MRZMjz7bk5ZQSFQ0gmIxyCQopxWR5R3QcnL3EJkTSK5LGFkc/ kUe3ymxaIyZ8nUQqZSmmb1Qq7EYFvPkxS0CGw6YSaXP5287tO9nDlxa99 IZdVKi/Tjo9q7jqymY35fNkuVk9592aoqENR1BW8nypkjh/M8c0tb8gW9 zFWr5ZQvAdTDFXgw9t82ksU3hjq2PW6AfXvcUPDy4hShyAwPK/T7oK2hH +Iic0VHgkYtSnrYRUmTvRErZaofNn1veODHMwSkNlTyrGEnTmeAxXvtfb EfP55CSqGuO0JwsF8Kaz121P/klO3QSWUVlxM757IFb3U8yDGEy4FdT50 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10861"; a="370147607" X-IronPort-AV: E=Sophos;i="6.03,219,1694761200"; d="scan'208";a="370147607" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Oct 2023 18:00:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10861"; a="870824070" X-IronPort-AV: E=Sophos;i="6.03,219,1694761200"; d="scan'208";a="870824070" Received: from bard-ubuntu.sh.intel.com ([10.239.185.57]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Oct 2023 18:00:53 -0700 From: Bard Liao To: alsa-devel@alsa-project.org, vkoul@kernel.org Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com Subject: [PATCH] soundwire: bus: improve error handling for clock stop prepare/deprepare Date: Fri, 13 Oct 2023 09:08:12 +0800 Message-Id: <20231013010812.114216-1-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 12 Oct 2023 18:01:09 -0700 (PDT) From: Pierre-Louis Bossart The same logic is used for clock stop prepare and deprepare, and having different logs for the two steps helps identify problems. In addition, when the "NotFinished" bit remains set, the error handling is not quite right: a) for the clock stop prepare, the error is handled at the caller level, and the error is ignored: there's no good reason to prevent the pm_runtime suspend from happening. Throwing an error that is later ignored is confusing. b) for the clock stop deprepare, the error is ignored in bus.c and a dev_warn() log shown. Throwing an error is also alarming users for no good reason. For both cases, demoting the error to dev_dbg() makes more sense. Link: https://github.com/thesofproject/linux/issues/4619 Signed-off-by: Pierre-Louis Bossart Reviewed-by: Rander Wang Reviewed-by: Richard Fitzgerald Signed-off-by: Bard Liao --- drivers/soundwire/bus.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c index 1720031f35a3..327ce316fed9 100644 --- a/drivers/soundwire/bus.c +++ b/drivers/soundwire/bus.c @@ -1022,7 +1022,7 @@ static int sdw_slave_clk_stop_prepare(struct sdw_slave *slave, return ret; } -static int sdw_bus_wait_for_clk_prep_deprep(struct sdw_bus *bus, u16 dev_num) +static int sdw_bus_wait_for_clk_prep_deprep(struct sdw_bus *bus, u16 dev_num, bool prepare) { int retry = bus->clk_stop_timeout; int val; @@ -1036,7 +1036,8 @@ static int sdw_bus_wait_for_clk_prep_deprep(struct sdw_bus *bus, u16 dev_num) } val &= SDW_SCP_STAT_CLK_STP_NF; if (!val) { - dev_dbg(bus->dev, "clock stop prep/de-prep done slave:%d\n", + dev_dbg(bus->dev, "clock stop %s done slave:%d\n", + prepare ? "prepare" : "deprepare", dev_num); return 0; } @@ -1045,7 +1046,8 @@ static int sdw_bus_wait_for_clk_prep_deprep(struct sdw_bus *bus, u16 dev_num) retry--; } while (retry); - dev_err(bus->dev, "clock stop prep/de-prep failed slave:%d\n", + dev_dbg(bus->dev, "clock stop %s did not complete for slave:%d\n", + prepare ? "prepare" : "deprepare", dev_num); return -ETIMEDOUT; @@ -1116,7 +1118,7 @@ int sdw_bus_prep_clk_stop(struct sdw_bus *bus) */ if (!simple_clk_stop) { ret = sdw_bus_wait_for_clk_prep_deprep(bus, - SDW_BROADCAST_DEV_NUM); + SDW_BROADCAST_DEV_NUM, true); /* * if there are no Slave devices present and the reply is * Command_Ignored/-ENODATA, we don't need to continue with the @@ -1236,7 +1238,7 @@ int sdw_bus_exit_clk_stop(struct sdw_bus *bus) * state machine */ if (!simple_clk_stop) { - ret = sdw_bus_wait_for_clk_prep_deprep(bus, SDW_BROADCAST_DEV_NUM); + ret = sdw_bus_wait_for_clk_prep_deprep(bus, SDW_BROADCAST_DEV_NUM, false); if (ret < 0) dev_warn(bus->dev, "clock stop deprepare wait failed:%d\n", ret); } -- 2.25.1