From patchwork Wed Dec 11 17:40:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam via B4 Relay X-Patchwork-Id: 849364 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 04A151FF1B3; Wed, 11 Dec 2024 17:40:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733938828; cv=none; b=ndvC7vpt9PpDnR9iqHCuP2JB7I7W3mXKsuIyayKwmkbETS2hbIsEWmvQ4OSJU/fYIDMmCD6jyocD4NlBlBiAgxlpZlaHHe/q8Ro9CLn0HmMpfo8LXKSAvOloQkm5WjrEDYruFpuJ11oxIM1rvYzdlW7PiaZMIs4SqRNPLbHA7BE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733938828; c=relaxed/simple; bh=3k0q1XEcUSyKHQJRn4GKxORS+BV0NNL35gUNoUKMCy4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nPT7l9rL4I65Ha11k2I2+jJ+Zi36w6uIi77xa4LsO6qyUTY9imcH4sNf6TnhqQwesG4XC4roEtS21qlB5hOjV6mRrSQnrkf0nA8bk4aL1jana9yyIx+MVREgaiguB4hLDqK0pdeHIssVt4GZkhjKXm2Kc4b3paUQ85gTCKsq88A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cPFkEAaJ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cPFkEAaJ" Received: by smtp.kernel.org (Postfix) with ESMTPS id 932EDC4CEDE; Wed, 11 Dec 2024 17:40:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733938827; bh=3k0q1XEcUSyKHQJRn4GKxORS+BV0NNL35gUNoUKMCy4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=cPFkEAaJk7nLxnslCaRSvCBNSpxTvl/t9DiuyLYAWQ/vgBJFIHnd1PLxdwTN9NIw/ aB+SqbUqFg9zSrRJBdoCjtROmmcHSzG/rikOZDp8AdxUSpP9CbUOlvGdO406QOnlHq inDFDw/UZQUFK0y9htkeZ+Tuyj9JXABOjqZB6B3oZuXFgURCgOwx6bJnLZEvBwSYjs BeRZXrhKL2edQT6f6btiPAUMki9lz1NWapPY9RKmS3xDGGnMZqeFkFnkbkpzsE1eoT P3B8YMBqQwC8xiVqrhDHSqJi5t5ZNgtE8MEetFNfZeDNRQrWPwlYTeskkHaIOoIHQo sjAfwVD2Pz3+g== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D331E77183; Wed, 11 Dec 2024 17:40:27 +0000 (UTC) From: Manivannan Sadhasivam via B4 Relay Date: Wed, 11 Dec 2024 23:10:17 +0530 Subject: [PATCH 2/3] scsi: ufs: qcom: Allow passing platform specific OF data Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241211-ufs-qcom-suspend-fix-v1-2-83ebbde76b1c@linaro.org> References: <20241211-ufs-qcom-suspend-fix-v1-0-83ebbde76b1c@linaro.org> In-Reply-To: <20241211-ufs-qcom-suspend-fix-v1-0-83ebbde76b1c@linaro.org> To: Alim Akhtar , Avri Altman , Bart Van Assche , "James E.J. Bottomley" , "Martin K. Petersen" , Abel Vesa , Bjorn Andersson , Neil Armstrong , Konrad Dybcio Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Amit Pundir , Nitin Rawat , Manivannan Sadhasivam X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2482; i=manivannan.sadhasivam@linaro.org; h=from:subject:message-id; bh=TFkKFPCprg+VLs+jengdDmwzP7O4f4NdtmgSXUOvHXg=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBnWc6JREq2V30RWfjRk7uJybqSzedDsUAgtCvv9 N6LjYU1MeyJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCZ1nOiQAKCRBVnxHm/pHO 9dJoB/wLM6GbS/vR2YaQXyHWje6tCbpXvfcDPcjstz6ETBuJpFIDpkaNJCW79jY0/EhpBxtcZ7h eMsBTWAS6mfPcmehVsaqCGJIirbvLhoBNkRPXyWkilYDIJjDFnLR7miTq7LVJiihXSDgSUk44dX ETM0AwnMcPJIuVM9ab6jR9m4k5BlfkNWavJhdzv60XOaXnzPPsZjoNCrOrI/xHeyOHV9QrTSOru aBjiBlN7i1j+cb36hWIXdnWxNA/smkY0rAPnMmb5+cteOQSNBiJEh9cqzj80YsyZLflmZQG+04y 3mDuIBqUluadY/kmz2Ps/VSveuO8DJNBNamVNL76NQXa0cSP X-Developer-Key: i=manivannan.sadhasivam@linaro.org; a=openpgp; fpr=C668AEC3C3188E4C611465E7488550E901166008 X-Endpoint-Received: by B4 Relay for manivannan.sadhasivam@linaro.org/default with auth_id=185 X-Original-From: Manivannan Sadhasivam Reply-To: manivannan.sadhasivam@linaro.org From: Manivannan Sadhasivam In order to allow platform specific flags and configurations, introduce the platform specific OF data and move the existing quirk UFSHCD_QUIRK_BROKEN_LSDBS_CAP for SM8550 and SM8650 SoCs. Signed-off-by: Manivannan Sadhasivam --- drivers/ufs/host/ufs-qcom.c | 13 +++++++++---- drivers/ufs/host/ufs-qcom.h | 4 ++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c index 32b0c74437de..35ae8c8fc301 100644 --- a/drivers/ufs/host/ufs-qcom.c +++ b/drivers/ufs/host/ufs-qcom.c @@ -871,6 +871,7 @@ static u32 ufs_qcom_get_ufs_hci_version(struct ufs_hba *hba) */ static void ufs_qcom_advertise_quirks(struct ufs_hba *hba) { + const struct ufs_qcom_drvdata *drvdata = of_device_get_match_data(hba->dev); struct ufs_qcom_host *host = ufshcd_get_variant(hba); if (host->hw_ver.major == 0x2) @@ -879,9 +880,8 @@ static void ufs_qcom_advertise_quirks(struct ufs_hba *hba) if (host->hw_ver.major > 0x3) hba->quirks |= UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH; - if (of_device_is_compatible(hba->dev->of_node, "qcom,sm8550-ufshc") || - of_device_is_compatible(hba->dev->of_node, "qcom,sm8650-ufshc")) - hba->quirks |= UFSHCD_QUIRK_BROKEN_LSDBS_CAP; + if (drvdata && drvdata->quirks) + hba->quirks |= drvdata->quirks; } static void ufs_qcom_set_phy_gear(struct ufs_qcom_host *host) @@ -1864,9 +1864,14 @@ static void ufs_qcom_remove(struct platform_device *pdev) platform_device_msi_free_irqs_all(hba->dev); } +static const struct ufs_qcom_drvdata ufs_qcom_sm8550_drvdata = { + .quirks = UFSHCD_QUIRK_BROKEN_LSDBS_CAP, +}; + static const struct of_device_id ufs_qcom_of_match[] __maybe_unused = { { .compatible = "qcom,ufshc" }, - { .compatible = "qcom,sm8550-ufshc" }, + { .compatible = "qcom,sm8550-ufshc", .data = &ufs_qcom_sm8550_drvdata }, + { .compatible = "qcom,sm8650-ufshc", .data = &ufs_qcom_sm8550_drvdata }, {}, }; MODULE_DEVICE_TABLE(of, ufs_qcom_of_match); diff --git a/drivers/ufs/host/ufs-qcom.h b/drivers/ufs/host/ufs-qcom.h index b9de170983c9..e85cc6fc072e 100644 --- a/drivers/ufs/host/ufs-qcom.h +++ b/drivers/ufs/host/ufs-qcom.h @@ -217,6 +217,10 @@ struct ufs_qcom_host { bool esi_enabled; }; +struct ufs_qcom_drvdata { + unsigned int quirks; +}; + static inline u32 ufs_qcom_get_debug_reg_offset(struct ufs_qcom_host *host, u32 reg) { From patchwork Wed Dec 11 17:40:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam via B4 Relay X-Patchwork-Id: 849365 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 020161FECD6; Wed, 11 Dec 2024 17:40:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733938828; cv=none; b=eW82S+7mopailZu5GpajYMJ0LoorijwRe63Q6EkReSJcfQ8dfawWPwI/odEAUefw0yY5bC1c6168YWLffCZoVTm/ymyDb7g50zBD1yQR/8VFDaUrRjOXnZzjEzkNlU6JtOsD7UgVfuugD2cFg3cKWoJuLqbxH/u4kNizxqZrqWM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733938828; c=relaxed/simple; bh=//XpFKTWinzR8Hvtule+Stbus3QCr5X6Hs7xeTCg8MA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=J7AWDa+4yiVttBSpGrQzVc/YKmPgs0nDNKWDoy9TPu+qLUTZQTnM2dfJ1YriDk2IxutynYZJT9ikcNKJU2Dj6fUYg3BCI7FvizdFhMVcXeAcgnYexroLacNUhWZyL4nSh5iPbvVgLfVssR6ItodOqcIQPAC7KKb1WY++fnshDeI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lEPgyLsJ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lEPgyLsJ" Received: by smtp.kernel.org (Postfix) with ESMTPS id 9D975C4CEE1; Wed, 11 Dec 2024 17:40:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733938827; bh=//XpFKTWinzR8Hvtule+Stbus3QCr5X6Hs7xeTCg8MA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=lEPgyLsJtiho+ts6uvjqZDgX8yDjdRJ+5oaWMTkG0HBh6mGEnKMP7Z8aZDIu2IVgX csd1LzpqMGYr2zNlJf2+Eu2w0IEM5qC/qu5W4dwKdCtNkorISBjp9S1zByp4pH1S2w /0fKuFYQGUUGQFSBLPG0666efRaLPWOCTI1vwGRqzu9GzgnIQ3rqJ1jIAcn3iwG/5p fA+QHYGQ5z8ye8VgXMQrf/xgL1ijLOes+dfI5/rx526AweCFIx8vGM8XQ9hsNQzK7X vG2sly2MJoul1mpXNFhnFXdXwDwUvxSgWCfUgS4v3pCmFE9dACWv0xv+HZ5JG0vAiX JBJewxtZwsT/w== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90856E7717D; Wed, 11 Dec 2024 17:40:27 +0000 (UTC) From: Manivannan Sadhasivam via B4 Relay Date: Wed, 11 Dec 2024 23:10:18 +0530 Subject: [PATCH 3/3] scsi: ufs: qcom: Power down the controller/device during system suspend for SM8550/SM8650 SoCs Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241211-ufs-qcom-suspend-fix-v1-3-83ebbde76b1c@linaro.org> References: <20241211-ufs-qcom-suspend-fix-v1-0-83ebbde76b1c@linaro.org> In-Reply-To: <20241211-ufs-qcom-suspend-fix-v1-0-83ebbde76b1c@linaro.org> To: Alim Akhtar , Avri Altman , Bart Van Assche , "James E.J. Bottomley" , "Martin K. Petersen" , Abel Vesa , Bjorn Andersson , Neil Armstrong , Konrad Dybcio Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Amit Pundir , Nitin Rawat , Manivannan Sadhasivam , stable@vger.kernel.org X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=3031; i=manivannan.sadhasivam@linaro.org; h=from:subject:message-id; bh=m5hbLz2BGZb5dhnCo0YRsTuGrLlxs9RKo35x8MdorCc=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBnWc6Jug+g5MxE/VtEK2FjzQbk0JDLOIwfZX5Tl Vf22pIM+W+JATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCZ1nOiQAKCRBVnxHm/pHO 9ZaeCACitOr4/p3gF5QRQdrXLl85xxdiyVtcay3Km0nrxGt/olEHn09g41akBMRRYCz7KRxHV+o 8ZCk+K7D5TAoKrro2bSxB2+4HOnj+e+1fMcIk0g5kXGR2SEH3duAHwDFIG1lLnaZ+X8yZTG5IXq ClAFlu1QUyMWm5dS/HVj8U3+ozYaBH4j/dBkTfU2zKr2n3JSlFOKfYdFvU1o9IXaFIbQLYwMbv9 nAvAAimgyWBXS3549KJVEn0GSekNDL+lWYbdv1ltewh8mRNpUTSHoRezXW/s8IvwOF2/PnXIGU5 jsRrfks0BFX/Ol+usp5F+KPrcHrJYJsgO56/SyZqQC6hOsVF X-Developer-Key: i=manivannan.sadhasivam@linaro.org; a=openpgp; fpr=C668AEC3C3188E4C611465E7488550E901166008 X-Endpoint-Received: by B4 Relay for manivannan.sadhasivam@linaro.org/default with auth_id=185 X-Original-From: Manivannan Sadhasivam Reply-To: manivannan.sadhasivam@linaro.org From: Manivannan Sadhasivam SM8550 and SM8650 SoCs doesn't support UFS PHY retention. So once these SoCs reaches the low power state (CX power collapse) during system suspend, all the PHY hardware state gets lost. This leads to the UFS resume failure: ufshcd-qcom 1d84000.ufs: ufshcd_uic_hibern8_exit: hibern8 exit failed. ret = 5 ufshcd-qcom 1d84000.ufs: __ufshcd_wl_resume: hibern8 exit failed 5 ufs_device_wlun 0:0:0:49488: ufshcd_wl_resume failed: 5 ufs_device_wlun 0:0:0:49488: PM: dpm_run_callback(): scsi_bus_resume+0x0/0x84 returns 5 ufs_device_wlun 0:0:0:49488: PM: failed to resume async: error 5 With the default system suspend level of UFS_PM_LVL_3, the power domain for UFS PHY needs to be kept always ON to retain the state. But this would prevent these SoCs from reaching the CX power collapse state, leading to poor power saving during system suspend. So to fix this issue without affecting the power saving, set 'ufs_qcom_drvdata::no_phy_retention' to true which sets 'hba->spm_lvl' to UFS_PM_LVL_5 to allow both the controller and device (in turn the PHY) to be powered down during system suspend for these SoCs by default. Cc: stable@vger.kernel.org # 6.3 Fixes: 35cf1aaab169 ("arm64: dts: qcom: sm8550: Add UFS host controller and phy nodes") Fixes: 10e024671295 ("arm64: dts: qcom: sm8650: add interconnect dependent device nodes") Reported-by: Neil Armstrong Signed-off-by: Manivannan Sadhasivam --- drivers/ufs/host/ufs-qcom.c | 5 +++++ drivers/ufs/host/ufs-qcom.h | 1 + 2 files changed, 6 insertions(+) diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c index 35ae8c8fc301..edf62430cabe 100644 --- a/drivers/ufs/host/ufs-qcom.c +++ b/drivers/ufs/host/ufs-qcom.c @@ -1069,6 +1069,7 @@ static int ufs_qcom_init(struct ufs_hba *hba) struct device *dev = hba->dev; struct ufs_qcom_host *host; struct ufs_clk_info *clki; + const struct ufs_qcom_drvdata *drvdata = of_device_get_match_data(hba->dev); host = devm_kzalloc(dev, sizeof(*host), GFP_KERNEL); if (!host) @@ -1148,6 +1149,9 @@ static int ufs_qcom_init(struct ufs_hba *hba) dev_warn(dev, "%s: failed to configure the testbus %d\n", __func__, err); + if (drvdata && drvdata->no_phy_retention) + hba->spm_lvl = UFS_PM_LVL_5; + return 0; out_variant_clear: @@ -1866,6 +1870,7 @@ static void ufs_qcom_remove(struct platform_device *pdev) static const struct ufs_qcom_drvdata ufs_qcom_sm8550_drvdata = { .quirks = UFSHCD_QUIRK_BROKEN_LSDBS_CAP, + .no_phy_retention = true, }; static const struct of_device_id ufs_qcom_of_match[] __maybe_unused = { diff --git a/drivers/ufs/host/ufs-qcom.h b/drivers/ufs/host/ufs-qcom.h index e85cc6fc072e..5a7b2fe4a7c9 100644 --- a/drivers/ufs/host/ufs-qcom.h +++ b/drivers/ufs/host/ufs-qcom.h @@ -219,6 +219,7 @@ struct ufs_qcom_host { struct ufs_qcom_drvdata { unsigned int quirks; + bool no_phy_retention; }; static inline u32