From: Petr Hodina <[email protected]>

Apply NO_PURGE unconditionally on Sony Yoshino (msm8998) and Tama
(sdm845) phones, regardless of which UFS chip is fitted:

- Units across batches ship with a mix of Samsung, SK Hynix, and
  Toshiba UFS parts, so a single per-model quirk-table row can't
  cover the whole population.
- Those chips consistently leave iProductName and
  iProductRevisionLevel blank in the UFS device descriptor, which
  defeats the model/revision string match the quirk table relies on.
- The spec-version fallback (wspecversion < 0x210) has an off-by-one
  gap for these devices: they report UFS spec version 0x210 (UFS 2.1)
  exactly, which the strict "<" comparison doesn't catch.

Gate NO_PURGE on the DT root compatible instead, which is reliable
regardless of which UFS chip a given unit shipped with.

Signed-off-by: Petr Hodina <[email protected]>
---
 drivers/ufs/ufs-uclass.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/drivers/ufs/ufs-uclass.c b/drivers/ufs/ufs-uclass.c
index 3cc4fd6bde3..f88949bffd3 100644
--- a/drivers/ufs/ufs-uclass.c
+++ b/drivers/ufs/ufs-uclass.c
@@ -1880,6 +1880,35 @@ out:
        return err;
 }
 
+/*
+ * Platforms whose bootloader / RPMB layout overlaps the UFS LUN0
+ * provisioning region and cannot tolerate UNMAP/PURGE.
+ * Any erase command issued against the boot LU bricks the device. The quirk
+ * has to apply regardless of which UFS supplier is fitted (Samsung, SK Hynix
+ * or Toshiba)
+ */
+static const char * const ufs_no_purge_platforms[] = {
+       /* Sony Yoshino (msm8998): XZ1 / XZ1 Compact / XZ Premium */
+       "sony,xperia-lilac",
+       "sony,xperia-maple",
+       "sony,xperia-poplar",
+       /* Sony Tama (sdm845): XZ2 / XZ2 Compact / XZ3 */
+       "sony,akari-row",
+       "sony,akatsuki-row",
+       "sony,apollo-row",
+       NULL,
+};
+
+static bool ufshcd_platform_needs_no_purge(void)
+{
+       const char * const *p;
+
+       for (p = ufs_no_purge_platforms; *p; p++)
+               if (of_machine_is_compatible(*p))
+                       return true;
+       return false;
+}
+
 /*
  * UFS device quirk table. Entries are matched by manufacturer id, model and
  * fw revision; UFS_ANY_VENDOR / UFS_ANY_MODEL / UFS_ANY_VER act as wildcards.
@@ -1916,6 +1945,10 @@ static void ufshcd_fixup_dev_quirks(struct ufs_hba *hba,
        if (dev_desc->wspecversion < UFS_PURGE_SPEC_VER)
                hba->dev_quirks |= UFS_DEVICE_QUIRK_NO_PURGE;
 
+       /* Platform-driven NO_PURGE */
+       if (ufshcd_platform_needs_no_purge())
+               hba->dev_quirks |= UFS_DEVICE_QUIRK_NO_PURGE;
+
        for (f = ufs_fixups; f->quirk; f++) {
                if ((f->wmanufacturerid == dev_desc->wmanufacturerid ||
                     f->wmanufacturerid == UFS_ANY_VENDOR) &&

-- 
2.55.0


Reply via email to