From patchwork Thu Aug 3 06:52:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liao, Bard" X-Patchwork-Id: 710287 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 03152C001E0 for ; Thu, 3 Aug 2023 06:28:03 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 3A6CF20C; Thu, 3 Aug 2023 08:27:11 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 3A6CF20C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1691044081; bh=W+Eg75sBaZEQWO5+zNepejl6stQbwCVziILn+2POhMQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=UiEEJHse1OFNHz5JiiEnKwoAGYsmDe19zyu6Njk2rFui8QlxLFdt4N+5sD7Xp+3Ui glG9bhxGQ1WX+SKtupUnUmYaCzj2eCzETtRXp5vWPHE6iJ9AEaYWHIEkL9XE3Sg4Yi Gu0sTovbY71+45+uAZg0HWfCjEphR5pL+6Bk6qvI= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 73190F802BE; Thu, 3 Aug 2023 08:26:38 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id E6737F8025A; Thu, 3 Aug 2023 08:26:37 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 78BC4F8025A; Thu, 3 Aug 2023 08:25:03 +0200 (CEST) Received: from mgamail.intel.com (unknown [192.55.52.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id E7382F8015B for ; Thu, 3 Aug 2023 08:24:55 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E7382F8015B Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=lVaS7XZO DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691043897; x=1722579897; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=W+Eg75sBaZEQWO5+zNepejl6stQbwCVziILn+2POhMQ=; b=lVaS7XZOFJhaVBBu9TPVH0DcfJ4wEK14Fodt0MCZ4vctFYpEO//KkP6s bgF+DlhYc5lb29kQdZThs2Q+MihU2lE0RyKq1oyNNxxX2bpRzuUZPVfSt va+fttx1Jbh9Gn7Pq8g7YK1fwSmEKhZaW2z6o0fL00VPkHNx/WxhHvi+l 8BT0s6u9ZO4md2SrEHzEZXYR9wSr2IgFuc/x0BWNH00vbhuuDk3yzyx3S LUIDn0rjSkoZ487noQYb8L1SrFnhaGdtO10blVk4guq63zLZo+e5TSTNF 5LzgZUXNpeiF5+rw19RNvc0mehkRZDzShrNj7HDFVB9xvpnA3cAQteRJX Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10790"; a="350075276" X-IronPort-AV: E=Sophos;i="6.01,251,1684825200"; d="scan'208";a="350075276" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Aug 2023 23:24:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10790"; a="1060117891" X-IronPort-AV: E=Sophos;i="6.01,251,1684825200"; d="scan'208";a="1060117891" Received: from bard-ubuntu.sh.intel.com ([10.239.185.57]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Aug 2023 23:23:59 -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 1/2] soundwire: intel_auxdevice: enable pm_runtime earlier on startup Date: Thu, 3 Aug 2023 14:52:19 +0800 Message-Id: <20230803065220.3823269-2-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230803065220.3823269-1-yung-chuan.liao@linux.intel.com> References: <20230803065220.3823269-1-yung-chuan.liao@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: A46Z7VN5YIFIQRGFGOGDXDCZU27UX4OD X-Message-ID-Hash: A46Z7VN5YIFIQRGFGOGDXDCZU27UX4OD X-MailFrom: yung-chuan.liao@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Pierre-Louis Bossart As soon as the bus starts, physical peripheral devices may report as ATTACHED and set their status with pm_runtime_set_active() in their update_status()/io_init(). This is problematic with the existing code, since the parent pm_runtime status is changed to "active" after starting the bus. This creates a time window where the pm_runtime framework can report an issue, e.g. "rt711 sdw:0:025d:0711:00: runtime PM trying to activate child device sdw:0:025d:0711:00 but parent (sdw-master-0) is not active" This patch enables runtime_pm earlier to make sure the auxiliary device is pm_runtime active after powering-up, but before starting the bus. This problem was exposed by recent changes in the timing of the bus reset, but was present in this driver since we introduced pm_runtime support. Closes: https://github.com/thesofproject/linux/issues/4328 Signed-off-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Reviewed-by: Rander Wang Signed-off-by: Bard Liao --- drivers/soundwire/intel_auxdevice.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/soundwire/intel_auxdevice.c b/drivers/soundwire/intel_auxdevice.c index 0daa6ca9a224..f51c776eeeff 100644 --- a/drivers/soundwire/intel_auxdevice.c +++ b/drivers/soundwire/intel_auxdevice.c @@ -248,13 +248,6 @@ int intel_link_startup(struct auxiliary_device *auxdev) sdw_intel_debugfs_init(sdw); - /* start bus */ - ret = sdw_intel_start_bus(sdw); - if (ret) { - dev_err(dev, "bus start failed: %d\n", ret); - goto err_power_up; - } - /* Enable runtime PM */ if (!(link_flags & SDW_INTEL_MASTER_DISABLE_PM_RUNTIME)) { pm_runtime_set_autosuspend_delay(dev, @@ -266,6 +259,13 @@ int intel_link_startup(struct auxiliary_device *auxdev) pm_runtime_enable(dev); } + /* start bus */ + ret = sdw_intel_start_bus(sdw); + if (ret) { + dev_err(dev, "bus start failed: %d\n", ret); + goto err_pm_runtime; + } + clock_stop_quirks = sdw->link_res->clock_stop_quirks; if (clock_stop_quirks & SDW_INTEL_CLK_STOP_NOT_ALLOWED) { /* @@ -293,12 +293,17 @@ int intel_link_startup(struct auxiliary_device *auxdev) * with a delay. A more complete solution would require the * definition of Master properties. */ - if (!(link_flags & SDW_INTEL_MASTER_DISABLE_PM_RUNTIME_IDLE)) + if (!(link_flags & SDW_INTEL_MASTER_DISABLE_PM_RUNTIME_IDLE)) { + pm_runtime_mark_last_busy(dev); pm_runtime_idle(dev); + } sdw->startup_done = true; return 0; +err_pm_runtime: + if (!(link_flags & SDW_INTEL_MASTER_DISABLE_PM_RUNTIME)) + pm_runtime_disable(dev); err_power_up: sdw_intel_link_power_down(sdw); err_init: From patchwork Thu Aug 3 06:52:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liao, Bard" X-Patchwork-Id: 709601 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D8652C0015E for ; Thu, 3 Aug 2023 06:28:21 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 9AA2F82B; Thu, 3 Aug 2023 08:27:29 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9AA2F82B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1691044099; bh=vGIa0chkbTg20wwAn5D+PJYLJpAtUvruvhIslT2Po64=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=L3xqmM7Rr39v9I+tZVU3haJ0TUvisJ9oyP4WIFQ273LE7/6PGs5caYFNNpj99wNso MiNQYorn2YV8rxEVz4RlEpmMYwM+PNGyyz42z4VW5lW3jYEt0Z9Qf7hm84H0s6qnjy Mha06UkpKmShVV5ZbfYtzGPVoqG0FylxgVWv43Fk= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1A829F80557; Thu, 3 Aug 2023 08:26:40 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 6B0C0F80548; Thu, 3 Aug 2023 08:26:40 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 37545F80551; Thu, 3 Aug 2023 08:25:10 +0200 (CEST) Received: from mgamail.intel.com (unknown [192.55.52.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id D338BF80548 for ; Thu, 3 Aug 2023 08:25:04 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D338BF80548 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=BN/+tVug DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691043906; x=1722579906; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vGIa0chkbTg20wwAn5D+PJYLJpAtUvruvhIslT2Po64=; b=BN/+tVug3zmsEL2EsTSnf9/QdfACK5ecQ9LZB4W/M+GD1xIQEkBkjEpA rr372EbmPUHngMvosN32k1aTzh/90dEfXEWcm/sIQv6CSZ8fyl9lsy+T3 5XyTba5YLfVC2AL/MIAlYIRNjYFiGp7aciS99cqbIEPFb5/vLv79lPzTJ H0b13sZAniv5ktVqmJsFlU/AVqLqWI1Hf+uM2o5dAKg5rpW7/qa8GhmOz iy2QcTFCsQz87DmESZcqvyhijBQMTvL4l5iqBQdUhwM63doN1BwbJj8eA tdJtZHVf55QKTb9C/cxGq6xcnZOxzPR3ExbRwKf4wfoiTjpSbc9ZSLiZE Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10790"; a="350075341" X-IronPort-AV: E=Sophos;i="6.01,251,1684825200"; d="scan'208";a="350075341" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Aug 2023 23:24:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10790"; a="1060117900" X-IronPort-AV: E=Sophos;i="6.01,251,1684825200"; d="scan'208";a="1060117900" Received: from bard-ubuntu.sh.intel.com ([10.239.185.57]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Aug 2023 23:24:00 -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 2/2] soundWire: intel_auxdevice: resume 'sdw-master' on startup and system resume Date: Thu, 3 Aug 2023 14:52:20 +0800 Message-Id: <20230803065220.3823269-3-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230803065220.3823269-1-yung-chuan.liao@linux.intel.com> References: <20230803065220.3823269-1-yung-chuan.liao@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: M624DYPI76SALD3SH65ZJ5JWISIDGGNW X-Message-ID-Hash: M624DYPI76SALD3SH65ZJ5JWISIDGGNW X-MailFrom: yung-chuan.liao@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Pierre-Louis Bossart The SoundWire bus is handled with a dedicated device, which is placed between the Intel auxiliary device and peripheral devices, e.g. soundwire_intel.link.0/sdw-master-0/sdw:0:025d:0711:01 The functionality of this 'sdw-master' device is limited, specifically for pm_runtime the ASoC framework will not rely on pm_runtime_get_sync() since it does not register any components. It will only change status thanks to the parent-child relationship which guarantees that the 'sdw-master' device will be pm_runtime resumed before any peripheral device. However on startup and system resume it's possible that only the auxiliary device is pm_runtime active, and the peripheral will only become active during its io_init routine, leading to another occurrence of the error reported by the pm_runtime framework: rt711 sdw:0:025d:0711:00: runtime PM trying to activate child device sdw:0:025d:0711:00 but parent (sdw-master-0) is not active This patch suggests aligning the sdw-master device status to that of the auxiliary device. The difference between the two is completely notional and their pm_status shouldn't be different during the startup and system resume steps. This problem was exposed by recent changes in the timing of the bus reset, but was present in this driver since we introduced pm_runtime support. Closes: https://github.com/thesofproject/linux/issues/4328 Signed-off-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Reviewed-by: Rander Wang Signed-off-by: Bard Liao Tested-by: Charles Keepax --- drivers/soundwire/intel_auxdevice.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/soundwire/intel_auxdevice.c b/drivers/soundwire/intel_auxdevice.c index f51c776eeeff..91c86b46a5a1 100644 --- a/drivers/soundwire/intel_auxdevice.c +++ b/drivers/soundwire/intel_auxdevice.c @@ -257,6 +257,8 @@ int intel_link_startup(struct auxiliary_device *auxdev) pm_runtime_set_active(dev); pm_runtime_enable(dev); + + pm_runtime_resume(bus->dev); } /* start bus */ @@ -294,6 +296,7 @@ int intel_link_startup(struct auxiliary_device *auxdev) * definition of Master properties. */ if (!(link_flags & SDW_INTEL_MASTER_DISABLE_PM_RUNTIME_IDLE)) { + pm_runtime_mark_last_busy(bus->dev); pm_runtime_mark_last_busy(dev); pm_runtime_idle(dev); } @@ -557,6 +560,8 @@ static int __maybe_unused intel_resume(struct device *dev) pm_runtime_mark_last_busy(dev); pm_runtime_enable(dev); + pm_runtime_resume(bus->dev); + link_flags = md_flags >> (bus->link_id * 8); if (!(link_flags & SDW_INTEL_MASTER_DISABLE_PM_RUNTIME_IDLE)) @@ -592,6 +597,7 @@ static int __maybe_unused intel_resume(struct device *dev) * counters and delay the pm_runtime suspend by several * seconds, by when all enumeration should be complete. */ + pm_runtime_mark_last_busy(bus->dev); pm_runtime_mark_last_busy(dev); return 0;