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: Bard Liao X-Patchwork-Id: 130349 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp969892vqx; Thu, 3 Aug 2023 00:29:43 -0700 (PDT) X-Google-Smtp-Source: APBJJlGCaJFChx0F6gb+BELXPcdEqGJACXLn0Veah7vL7M1OpFkNdq3I3Oh5sYBfwxG8q/tBNYYA X-Received: by 2002:a2e:bc84:0:b0:2b6:a882:129c with SMTP id h4-20020a2ebc84000000b002b6a882129cmr10886759ljf.0.1691047783334; Thu, 03 Aug 2023 00:29:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691047783; cv=none; d=google.com; s=arc-20160816; b=QCaPAXkv1YMHxJFyLQu8yOrZPtgh1RogV20OyGnFABsRvu+Tq28j8sGaryfkvv7ko5 Pzmnhbhr1u0kDET30tI78SF3fKcYZNiGPnU48I+Re3cqxofHm0eeQ+AcFF0McRW61Twm y3J0CKi0TRjK9nzQktnXoHOUa8hI6HWcf6e+YlMRYlv9g9SiQs6MbelQUb8fUllR2Ny2 XWbO9TJi3T9pIust9aLLC70RNk38NMIWQcgEReNW1Bn5XQJb89fJL1bl2dPIwUWGbosC DTPKymWVM+D6MUDMXFj1rA1+vQ1qcZEtVKkgCDubTic4hs0kL1VtReNfBzBcb+4Nstzh xDHg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=X3iEXL5jip2omsdoQe52wqlIJ6NsJTQgwiyhObqZmIw=; fh=8u11NBAqs6tBqEdG193rH6ku+1A1BgUApUzqlumcBwY=; b=TYnTmDEmZG263sgVTwKD7V4XBrwYG+GHZBmg+nau4vd5IkioiBug9KEKoQ8eCcuN4I Y0Jzvn+3MpnSraTgOuCIVLrhTXxy87krtsSw6nFDBN4VfCuYYt4bBjV4GLgMNtxO3Ukq ct9IOLV/ntx+GAQdPaBUCihVFpuW3mviaSUp4PwER/MBZRS/KUpzvXoai8+4cgJCU8Xp FTPBcc7mZHnvUJK7XWk4sshaPsdnRBrW6SSwfCMF69LZTHMrbYybqboZG+kgDAwSDcU/ czrA7isluOME0Hc89pPrK8+m2nMkI2fQN7VAZHjwebRkrWDA3YD5zFb1PjuoxkmwMSNm 9OSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IWsZMFcm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p2-20020a170906838200b00988da9cd05csi1077006ejx.23.2023.08.03.00.29.18; Thu, 03 Aug 2023 00:29:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IWsZMFcm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229547AbjHCGZC (ORCPT + 99 others); Thu, 3 Aug 2023 02:25:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232377AbjHCGY6 (ORCPT ); Thu, 3 Aug 2023 02:24:58 -0400 Received: from mgamail.intel.com (unknown [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB3F51724 for ; Wed, 2 Aug 2023 23:24:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691043895; x=1722579895; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=W+Eg75sBaZEQWO5+zNepejl6stQbwCVziILn+2POhMQ=; b=IWsZMFcmSwwS/yoiI3VOdPbh3xyQRWA3JZ+E+6LnKDjZfrQTGJMnyh31 CNAmaDSHRbbbH2Uwkci1JBPY1fLUGeNbnXJen/u/Ka6GkaBmXoycZR0sK mfNrUroFUcMWseSMvaePgEmMk3KXVl9VDTz2+jUype6MhVVLZieyB192r 7wmKxpBH93RGFa6rQzFq/1+7oHgP7QshQxmkK8JYVL08SjiOwpD3ncuVf ZNLA1XEEEEKh9EGpuiNzMlK2Mk4Viak0L1x4V3ee/6Nna3HG5FKZTTNbh 59SCrrOrSK3l2ctHpwJKeaRiDUEV88mRWaNmJSkEe2D+Uii9+ypwkqkMf A==; X-IronPort-AV: E=McAfee;i="6600,9927,10790"; a="350075275" X-IronPort-AV: E=Sophos;i="6.01,251,1684825200"; d="scan'208";a="350075275" 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 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773192120436938538 X-GMAIL-MSGID: 1773192120436938538 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 Tested-by: Charles Keepax --- 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: Bard Liao X-Patchwork-Id: 130330 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp958142vqx; Thu, 3 Aug 2023 00:01:48 -0700 (PDT) X-Google-Smtp-Source: APBJJlFx2vAAgIIgCH5a9k6jmANuw2DldVs0Vz/1RrR9YO7pfuw7Ee2isXuQ1BzcbhaBbrFD+nI0 X-Received: by 2002:aa7:c6d7:0:b0:522:1d47:2d81 with SMTP id b23-20020aa7c6d7000000b005221d472d81mr6987046eds.17.1691046107969; Thu, 03 Aug 2023 00:01:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691046107; cv=none; d=google.com; s=arc-20160816; b=gw/Up1yt0SlxV+1gkDVtqHa0ts2k6KOgcU2wHwsB+s/BvUFdtFCyb19e3trtMnpYIH sUCHyOJP3IYrFE2oCc3l3FbbCmRUM/KT/MPd+QHF+kXnujrqNVVuxLX+ex3Wyzu7ztiN undX8Rvf9MELWTt+G1vqg81B+0vpE54FQewDyVYDfClKKUAYSVn9W9vjdG4cFEGTH0dv kdgLNy05qBRZJLbjU6EepfKcDhVPz0V4DB3Kb3/CCDyvs1vZx480Snse5x0PnmnQhBht Dnj1n0lWhdW2XMf+2EdMRY6XYYMe7lsFek3nnNeHjy8cvWiP/5n9kAB6KhkkhJvpyr2J 7u7w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Vmwj2imKZun0/fb0mNOBK0V2Qjlxc5q7fLpcQu6d1OQ=; fh=8u11NBAqs6tBqEdG193rH6ku+1A1BgUApUzqlumcBwY=; b=WuBJCRcOw6cb4oIhwbYVoRmcYf7pptC6XtAAtNbxGqxrZfQMGJoNGi052kV8nwZi/u 9TUZArTFDzyAiv5ixTMjmbBRnJ2NPUG35PUhl1UMDyl+gbadCvhzbml8YZOUbvincwTd YCiF3H0Gs7Iqk57ijXo8sXVWdP4rxh9JH6daG9UIXPr3Wp7C8w42rjJIbj7dbv5JTwKj VbDvVduSKzDRAOLJ/fTDC3F+xH4y/C+eIZRqQO3clV80wexO8XMyk+SjCm6ey+dCIhtg GeZdRFNG3Mionr48AnKtLeuFEW6hM/pGNtlE48J8/9WT/ohlZodmfhjQ/FfbhB7qyuwy b2aQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FuVk6Fcz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l27-20020a056402345b00b0052026a148cesi2245792edc.44.2023.08.03.00.01.21; Thu, 03 Aug 2023 00:01:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FuVk6Fcz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233212AbjHCGZR (ORCPT + 99 others); Thu, 3 Aug 2023 02:25:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233250AbjHCGZF (ORCPT ); Thu, 3 Aug 2023 02:25:05 -0400 Received: from mgamail.intel.com (unknown [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19CF630D2 for ; Wed, 2 Aug 2023 23:25:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691043903; x=1722579903; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vGIa0chkbTg20wwAn5D+PJYLJpAtUvruvhIslT2Po64=; b=FuVk6Fcz1N773jST5g9oa6AGJ4zuVIiCu2ydTwXkpnnZDWGN2J2cDrff /4kbN96UTf0Z+06LW8dU/d+Qc7aYuZamWnOxzVbreni6EUQO14opbzxgx elpw1d3Zpsz8WUs1SfHHXaAeWlSwGc8FDOdSzeX72w473FjnZJxAHO0Q9 e6zN/T9WlPrru90AXvsGONBJoMOBjJZ4vMKBTwv0A3NGJavgDnetYXL+z rKvPTTLM/ZwP78o5nwY3iFv0kpIUKS1w23MK7WOiJpqx0EJ4Yhv4pAYE1 OX0pllHEV6n30VaCKmzFzGts0Pz3mOYRxkaPWdVKQ5l8lo6qj5jxtb5jg A==; X-IronPort-AV: E=McAfee;i="6600,9927,10790"; a="350075340" X-IronPort-AV: E=Sophos;i="6.01,251,1684825200"; d="scan'208";a="350075340" 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 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773190363424290788 X-GMAIL-MSGID: 1773190363424290788 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;