1 From stable+bounces-192877-greg=kroah.com@vger.kernel.org Mon Nov 10 01:48:04 2025
2 From: Sasha Levin <sashal@kernel.org>
3 Date: Sun, 9 Nov 2025 19:47:48 -0500
4 Subject: scsi: ufs: core: Add a quirk for handling broken LSDBS field in controller capabilities register
5 To: stable@vger.kernel.org
6 Cc: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>, Amit Pundir <amit.pundir@linaro.org>, Bart Van Assche <bvanassche@acm.org>, "Martin K. Petersen" <martin.petersen@oracle.com>, Sasha Levin <sashal@kernel.org>
7 Message-ID: <20251110004750.555028-6-sashal@kernel.org>
9 From: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
11 [ Upstream commit cd06b713a6880997ca5aecac8e33d5f9c541749e ]
13 'Legacy Queue & Single Doorbell Support (LSDBS)' field in the controller
14 capabilities register is supposed to report whether the legacy single
15 doorbell mode is supported in the controller or not. But some controllers
16 report '1' in this field which corresponds to 'LSDB not supported', but
17 they indeed support LSDB. So let's add a quirk to handle those controllers.
19 If the quirk is enabled by the controller driver, then LSDBS register field
20 will be ignored and legacy single doorbell mode is assumed to be enabled
23 Tested-by: Amit Pundir <amit.pundir@linaro.org>
24 Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
25 Link: https://lore.kernel.org/r/20240816-ufs-bug-fix-v3-1-e6fe0e18e2a3@linaro.org
26 Reviewed-by: Bart Van Assche <bvanassche@acm.org>
27 Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
28 Stable-dep-of: d968e99488c4 ("scsi: ufs: ufs-pci: Set UFSHCD_QUIRK_PERFORM_LINK_STARTUP_ONCE for Intel ADL")
29 Signed-off-by: Sasha Levin <sashal@kernel.org>
30 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
32 drivers/ufs/core/ufshcd.c | 6 +++++-
33 include/ufs/ufshcd.h | 8 ++++++++
34 2 files changed, 13 insertions(+), 1 deletion(-)
36 --- a/drivers/ufs/core/ufshcd.c
37 +++ b/drivers/ufs/core/ufshcd.c
38 @@ -2368,7 +2368,11 @@ static inline int ufshcd_hba_capabilitie
39 * 0h: legacy single doorbell support is available
40 * 1h: indicate that legacy single doorbell support has been removed
42 - hba->lsdb_sup = !FIELD_GET(MASK_LSDB_SUPPORT, hba->capabilities);
43 + if (!(hba->quirks & UFSHCD_QUIRK_BROKEN_LSDBS_CAP))
44 + hba->lsdb_sup = !FIELD_GET(MASK_LSDB_SUPPORT, hba->capabilities);
46 + hba->lsdb_sup = true;
51 --- a/include/ufs/ufshcd.h
52 +++ b/include/ufs/ufshcd.h
53 @@ -670,6 +670,14 @@ enum ufshcd_quirks {
54 * the standard best practice for managing keys).
56 UFSHCD_QUIRK_KEYS_IN_PRDT = 1 << 24,
59 + * This quirk indicates that the controller reports the value 1 (not
60 + * supported) in the Legacy Single DoorBell Support (LSDBS) bit of the
61 + * Controller Capabilities register although it supports the legacy
62 + * single doorbell mode.
64 + UFSHCD_QUIRK_BROKEN_LSDBS_CAP = 1 << 25,