Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp2107853rdg; Sun, 13 Aug 2023 09:30:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFaxtvk3gGo9KHsLhSnXFWC/qfA6SfxDMKeAtDimq3zjoPbSU3AGSC8afI0ZYRfRs4DoORB X-Received: by 2002:a17:907:7892:b0:99c:10e8:52d6 with SMTP id ku18-20020a170907789200b0099c10e852d6mr6233563ejc.39.1691944208432; Sun, 13 Aug 2023 09:30:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691944208; cv=none; d=google.com; s=arc-20160816; b=YJxsjCz3BDpOs55Er2i2HfaKFdM/yiyldtyFbwcTynBF2DpDoe0pCeqyxCFpMVBJJi PLIFpbTn6KwDkopIRHDA7B1/WfxDXwKKJOSshMhQUp1EdvDOkefvN7RqLM1nogPM+p2n 5Uzub5fSSrb0gf4mfK0Gq13wT5eExhkXYRw2IkrwJGsnl3joJuYQf5xogLTmNwpT8ODC YIFj1VPu0KPaWtUKNyytOZ9Uqd6IfFhxB8tl6yOon9V+6AsAfLtMsLutIP2vrclOmBye La6RUeIRHAPdzSGjRer+Naq1INS1xP9QrsYa6myHbaGei8CN65PD3H1YyDWTfiTHWpXn L1iw== 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=agn+MycQJITLC7/EA9wNY9JiQ79WObZzF2dge+kt4Yc=; fh=os2HnnaoaYFHKItGDBos/RSrLTeaQ942L4Ik2aTyrT4=; b=GgXd2cju/RLCcnomBUES17BQP+D45U28oHgql4nDmGdSoOOj0bFFgx7OBJPdCRPpZX XCdKuWbXJu92KR/ZlkVks4f1C0MfF9sv60npR2QL+PJM9Hl0LFwi+00e+5VoDQjJLEDk sEyAiggknDNM6vQCjOey7rHOsmIE+zvg59BjJVc7yaHQhiafniaCizCj5bpquOMVBHBu 8sLAhY3k1zYrvJ+rlEWPrx1DwUzr/pUN365nKX1wCvmeo2ErwX1UZEgO/QhYah+fUJgY jVdB1XF8w4iiTlYpQkluO2kVRrULNYxo0lNRoyDyDlEcJqcmXOk567fuAv7gpEOHYT2j hcOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WuF3wV6N; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qx25-20020a170906fcd900b009769ff4d234si7040064ejb.58.2023.08.13.09.29.42; Sun, 13 Aug 2023 09:30:08 -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=@kernel.org header.s=k20201202 header.b=WuF3wV6N; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232568AbjHMQGx (ORCPT + 99 others); Sun, 13 Aug 2023 12:06:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232526AbjHMQGi (ORCPT ); Sun, 13 Aug 2023 12:06:38 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2C0030F8; Sun, 13 Aug 2023 09:06:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 928316383F; Sun, 13 Aug 2023 16:06:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B8E7C433C8; Sun, 13 Aug 2023 16:06:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691942773; bh=BcDOaovPxSnKATfyJYAWa6+oBcykzejHLHK73vkPAqM=; h=From:To:Cc:Subject:Date:From; b=WuF3wV6NekLs+BmCS6sp0cWGbmVHJOmVwWXS8xZYQn032gPpUIg33SzC9hHSPhGNE xVR6XTy9M0il8uFda2s3oQF0Yfac+XJ3CrZiF6+3ip6RUga04fHUc4+ysuLbvK0wdo MzhZlcgF5/pIX+GGiMPGmhJ04YGlqN9depBAga48MFlBQnFqmX6dIPctkkbQICobAg y/l4WepmP/gylaNrGY+y7tLZF5IgjudNa2haywWSF+vqrIYjYwpd3xzLQspUfLg0bA QeN2yKGc2hNuQagNbFlk/8Qwf7rlwfpMYypM7H0EVenat2MbI2r9ZB3Rs9QXH2lHTO 1wdt4frLatIcw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Adrien Thierry , Vinod Koul , Sasha Levin , agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, kishon@kernel.org, linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org Subject: [PATCH AUTOSEL 5.15 01/31] phy: qcom-snps-femto-v2: keep cfg_ahb_clk enabled during runtime suspend Date: Sun, 13 Aug 2023 12:05:34 -0400 Message-Id: <20230813160605.1080385-1-sashal@kernel.org> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 5.15.126 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS 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 From: Adrien Thierry [ Upstream commit 45d89a344eb46db9dce851c28e14f5e3c635c251 ] In the dwc3 core, both system and runtime suspend end up calling dwc3_suspend_common(). From there, what happens for the PHYs depends on the USB mode and whether the controller is entering system or runtime suspend. HOST mode: (1) system suspend on a non-wakeup-capable controller The [1] if branch is taken. dwc3_core_exit() is called, which ends up calling phy_power_off() and phy_exit(). Those two functions decrease the PM runtime count at some point, so they will trigger the PHY runtime sleep (assuming the count is right). (2) runtime suspend / system suspend on a wakeup-capable controller The [1] branch is not taken. dwc3_suspend_common() calls phy_pm_runtime_put_sync(). Assuming the ref count is right, the PHY runtime suspend op is called. DEVICE mode: dwc3_core_exit() is called on both runtime and system sleep unless the controller is already runtime suspended. OTG mode: (1) system suspend : dwc3_core_exit() is called (2) runtime suspend : do nothing In host mode, the code seems to make a distinction between 1) runtime sleep / system sleep for wakeup-capable controller, and 2) system sleep for non-wakeup-capable controller, where phy_power_off() and phy_exit() are only called for the latter. This suggests the PHY is not supposed to be in a fully powered-off state for runtime sleep and system sleep for wakeup-capable controller. Moreover, downstream, cfg_ahb_clk only gets disabled for system suspend. The clocks are disabled by phy->set_suspend() [2] which is only called in the system sleep path through dwc3_core_exit() [3]. With that in mind, don't disable the clocks during the femto PHY runtime suspend callback. The clocks will only be disabled during system suspend for non-wakeup-capable controllers, through dwc3_core_exit(). [1] https://elixir.bootlin.com/linux/v6.4/source/drivers/usb/dwc3/core.c#L1988 [2] https://git.codelinaro.org/clo/la/kernel/msm-5.4/-/blob/LV.AU.1.2.1.r2-05300-gen3meta.0/drivers/usb/phy/phy-msm-snps-hs.c#L524 [3] https://git.codelinaro.org/clo/la/kernel/msm-5.4/-/blob/LV.AU.1.2.1.r2-05300-gen3meta.0/drivers/usb/dwc3/core.c#L1915 Signed-off-by: Adrien Thierry Link: https://lore.kernel.org/r/20230629144542.14906-2-athierry@redhat.com Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c b/drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c index 7e61202aa234e..a107f98c662d5 100644 --- a/drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c +++ b/drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c @@ -122,22 +122,13 @@ static int qcom_snps_hsphy_suspend(struct qcom_snps_hsphy *hsphy) 0, USB2_AUTO_RESUME); } - clk_disable_unprepare(hsphy->cfg_ahb_clk); return 0; } static int qcom_snps_hsphy_resume(struct qcom_snps_hsphy *hsphy) { - int ret; - dev_dbg(&hsphy->phy->dev, "Resume QCOM SNPS PHY, mode\n"); - ret = clk_prepare_enable(hsphy->cfg_ahb_clk); - if (ret) { - dev_err(&hsphy->phy->dev, "failed to enable cfg ahb clock\n"); - return ret; - } - return 0; } -- 2.40.1