ufs: qcom: Fix probe failure on SM8550 SoC due to broken LSDBS field
Subsystems (4)
v3 cover ufs: qcom: Fix probe failure on SM8550 SoC due to broken LSDBS field
Hi,
This series fixes the probe failure on the Qcom SM8550 SoC due to the broken LSDBS field in the host controller capabilities register.
Please consider this series for v6.11 as it fixes a regression.
---
Changes in v3:
- Dropped the patch that renamed LSDB field
- Changed the comment for the quirk and also fixed the UFSHCI version in description
- Collected review tag
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Changed SDBS to LSDBS as per the final version of UFSHCI 4.0 spec
- Moved the quirk check to assignment
- Used correct fixes tag in patch 3/3
- Added tested-by tags
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Manivannan Sadhasivam (2):
ufs: core: Add a quirk for handling broken LSDBS field in controller capabilities register
ufs: qcom: Add UFSHCD_QUIRK_BROKEN_LSDBS_CAP for SM8550 SoC
drivers/ufs/core/ufshcd.c | 6 +++++- drivers/ufs/host/ufs-qcom.c | 6 +++++- include/ufs/ufshcd.h | 8 ++++++++ 3 files changed, 18 insertions(+), 2 deletions(-)
---
base-commit: 7c626ce4bae1ac14f60076d00eafe71af30450ba
change-id: 20240814-ufs-bug-fix-4427fb01b860
Best regards,
Signature · 1 line
Manivannan Sadhasivam <[email protected]>
PATCH v3 1/2 ufs: core: Add a quirk for handling broken LSDBS field in controller capabilities register
'Legacy Queue & Single Doorbell Support (LSDBS)' field in the controller capabilities register is supposed to report whether the legacy single doorbell mode is supported in the controller or not. But some controllers report '1' in this field which corresponds to 'LSDB not supported', but they indeed support LSDB. So let's add a quirk to handle those controllers.
If the quirk is enabled by the controller driver, then LSDBS register field will be ignored and legacy single doorbell mode is assumed to be enabled always.
--- drivers/ufs/core/ufshcd.c | 6 +++++- include/ufs/ufshcd.h | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-)
drivers/ufs/core/ufshcd.c +5 -1
@@ -2426,7 +2426,11 @@ static inline int ufshcd_hba_capabilities(struct ufs_hba *hba)* 0h: legacy single doorbell support is available * 1h: indicate that legacy single doorbell support has been removed */ - hba->lsdb_sup = !FIELD_GET (MASK_LSDB_SUPPORT , hba->capabilities); +if (!(hba->quirks &UFSHCD_QUIRK_BROKEN_LSDBS_CAP )) + hba->lsdb_sup = !FIELD_GET (MASK_LSDB_SUPPORT , hba->capabilities); +else + hba->lsdb_sup = true; +if (!hba->mcq_sup)return 0 ;
include/ufs/ufshcd.h +8 -0
@@ -676,6 +676,14 @@ enum ufshcd_quirks {* the standard best practice for managing keys). */ UFSHCD_QUIRK_KEYS_IN_PRDT =1 <<24 , + +/* +* This quirk indicates that the controller reports the value 1 (not +* supported) in the Legacy Single DoorBell Support (LSDBS) bit of the +* Controller Capabilities register although it supports the legacy +* single doorbell mode. +*/ + UFSHCD_QUIRK_BROKEN_LSDBS_CAP = 1 << 25, }; enum ufshcd_caps {
Signature · 1 line
2.25.1
Re: [PATCH v3 1/2] ufs: core: Add a quirk for handling broken LSDBS field in controller capabilities register
Quoted 9 lines · On 8/15/24 11:25 PM, Manivannan Sadhasivam via B4 Relay wrote:
'Legacy Queue & Single Doorbell Support (LSDBS)' field in the controller capabilities register is supposed to report whether the legacy single doorbell mode is supported in the controller or not. But some controllers report '1' in this field which corresponds to 'LSDB not supported', but they indeed support LSDB. So let's add a quirk to handle those controllers.
If the quirk is enabled by the controller driver, then LSDBS register field will be ignored and legacy single doorbell mode is assumed to be enabled always.
PATCH v3 2/2 ufs: qcom: Add UFSHCD_QUIRK_BROKEN_LSDBS_CAP for SM8550 SoC
In reply to Manivannan SadhasivamSM8550 SoC has the UFSHCI 4.0 compliant UFS controller and only supports legacy single doorbell mode without MCQ. But due to a hardware bug, it reports 1 in the 'Legacy Queue & Single Doorbell Support (LSDBS)' field of the Controller Capabilities register. This field is supposed to read as 0 if legacy single doorbell mode is supported and 1 otherwise.
Starting with commit 0c60eb0cc320 ("scsi: ufs: core: Check LSDBS cap when !mcq"), ufshcd driver is now relying on the LSDBS field to decide when to use the legacy doorbell mode if MCQ is not supported. And this ends up breaking UFS on SM8550:
ufshcd-qcom 1d84000.ufs: ufshcd_init: failed to initialize (legacy doorbell mode not supported) ufshcd-qcom 1d84000.ufs: error -EINVAL: Initialization failed with error -22
So use the UFSHCD_QUIRK_BROKEN_LSDBS_CAP quirk for SM8550 SoC so that the ufshcd driver could use legacy doorbell mode correctly.
--- drivers/ufs/host/ufs-qcom.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/ufs/host/ufs-qcom.c +5 -1
@@ -857,6 +857,9 @@ 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" )) + hba->quirks |=UFSHCD_QUIRK_BROKEN_LSDBS_CAP ; }static void ufs_qcom_set_phy_gear (struct ufs_qcom_host *host)
@@ -1847,7 +1850,8 @@ static void ufs_qcom_remove(struct platform_device *pdev) }static const struct of_device_id ufs_qcom_of_match[]__maybe_unused = { - { .compatible ="qcom,ufshc" }, + { .compatible ="qcom,ufshc" }, + { .compatible ="qcom,sm8550-ufshc" }, {}, };MODULE_DEVICE_TABLE (of, ufs_qcom_of_match);
Signature · 1 line
2.25.1
Martin K. Petersen
AppliedQuoted 6 lines · Manivannan Sadhasivam
This series fixes the probe failure on the Qcom SM8550 SoC due to the broken LSDBS field in the host controller capabilities register.
Please consider this series for v6.11 as it fixes a regression.
Applied to 6.11/scsi-fixes, thanks!
[1/2] ufs: core: Add a quirk for handling broken LSDBS field in controller capabilities register
https://git.kernel.org/mkp/scsi/c/cd06b713a688 [2/2] ufs: qcom: Add UFSHCD_QUIRK_BROKEN_LSDBS_CAP for SM8550 SoC https://git.kernel.org/mkp/scsi/c/ea593e028a9c
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering