From c266a1311e74b3ae1047a9d6abd6c6044059995c Mon Sep 17 00:00:00 2001 From: John Stultz Date: Fri, 8 Nov 2019 04:42:58 +0000 Subject: [PATCH] ANDROID: scsi: ufs: Add quirk bit for controllers that don't play well with inline crypto A number of devices (hikey960 and db845c at least) don't work well with the inline crypto enablement, causing them to crash in early boot. In order to allow those boards to continue booting, add a BROKEN_CRYPTO quirk flag that the drivers can enable until we sort out how/if they can be fixed. Bug: 137270441 Change-Id: I9f2c3d75412e0aaa22fe6e7c9929cd18b1efa9ba Signed-off-by: John Stultz Signed-off-by: Satya Tangirala --- drivers/scsi/ufs/ufshcd-crypto.c | 3 ++- drivers/scsi/ufs/ufshcd.h | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/ufs/ufshcd-crypto.c b/drivers/scsi/ufs/ufshcd-crypto.c index acd63ef15be5..1cfd9a327049 100644 --- a/drivers/scsi/ufs/ufshcd-crypto.c +++ b/drivers/scsi/ufs/ufshcd-crypto.c @@ -279,7 +279,8 @@ int ufshcd_hba_init_crypto_spec(struct ufs_hba *hba, hba->caps &= ~UFSHCD_CAP_CRYPTO; /* Return 0 if crypto support isn't present */ - if (!(hba->capabilities & MASK_CRYPTO_SUPPORT)) + if (!(hba->capabilities & MASK_CRYPTO_SUPPORT) || + (hba->quirks & UFSHCD_QUIRK_BROKEN_CRYPTO)) goto out; /* diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index 159c98149474..78ec1c588f1a 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -624,6 +624,12 @@ struct ufs_hba { */ #define UFSHCD_QUIRK_PRDT_BYTE_GRAN UFS_BIT(7) + /* + * This quirk needs to be enabled if the host controller advertises + * inline encryption support but it doesn't work correctly. + */ + #define UFSHCD_QUIRK_BROKEN_CRYPTO UFS_BIT(11) + unsigned int quirks; /* Deviations from standard UFSHCI spec. */ /* Device deviations from standard UFS device spec. */