Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: ufs: ufs-pci: Correct check for RESET DSM

dsm_fns is a bitmap, and it is 0-indexed according to the check in
__intel_dsm function. But common initialization was checking it as if it
was 1-indexed. This patch corrects the discrepancy. This change won't break
any existing calls to the function, since before the change both bits 0 and
1 were checked and needed to be set.

Link: https://lore.kernel.org/r/20220728111748.v3.1.I22460c4f4a9ccf2c96c3f9bb392b409926d80b2f@changeid
Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Daniil Lunev <dlunev@chromium.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Daniil Lunev and committed by
Martin K. Petersen
a1906678 ef4f7e4b

+13 -4
+13 -4
drivers/ufs/host/ufshcd-pci.c
··· 24 24 void (*late_init)(struct ufs_hba *hba); 25 25 }; 26 26 27 - enum { 27 + enum intel_ufs_dsm_func_id { 28 28 INTEL_DSM_FNS = 0, 29 29 INTEL_DSM_RESET = 1, 30 30 }; ··· 41 41 static const guid_t intel_dsm_guid = 42 42 GUID_INIT(0x1A4832A0, 0x7D03, 0x43CA, 43 43 0xB0, 0x20, 0xF6, 0xDC, 0xD1, 0x2A, 0x19, 0x50); 44 + 45 + static bool __intel_dsm_supported(struct intel_host *host, 46 + enum intel_ufs_dsm_func_id fn) 47 + { 48 + return fn < 32 && fn >= 0 && (host->dsm_fns & (1u << fn)); 49 + } 50 + 51 + #define INTEL_DSM_SUPPORTED(host, name) \ 52 + __intel_dsm_supported(host, INTEL_DSM_##name) 44 53 45 54 static int __intel_dsm(struct intel_host *intel_host, struct device *dev, 46 55 unsigned int fn, u32 *result) ··· 80 71 static int intel_dsm(struct intel_host *intel_host, struct device *dev, 81 72 unsigned int fn, u32 *result) 82 73 { 83 - if (fn > 31 || !(intel_host->dsm_fns & (1 << fn))) 74 + if (!__intel_dsm_supported(intel_host, fn)) 84 75 return -EOPNOTSUPP; 85 76 86 77 return __intel_dsm(intel_host, dev, fn, result); ··· 309 300 { 310 301 struct intel_host *host = ufshcd_get_variant(hba); 311 302 312 - if (host->dsm_fns & INTEL_DSM_RESET) { 303 + if (INTEL_DSM_SUPPORTED(host, RESET)) { 313 304 u32 result = 0; 314 305 int err; 315 306 ··· 351 342 return -ENOMEM; 352 343 ufshcd_set_variant(hba, host); 353 344 intel_dsm_init(host, hba->dev); 354 - if (host->dsm_fns & INTEL_DSM_RESET) { 345 + if (INTEL_DSM_SUPPORTED(host, RESET)) { 355 346 if (hba->vops->device_reset) 356 347 hba->caps |= UFSHCD_CAP_DEEPSLEEP; 357 348 } else {