From eef88095dcfbadcfa0fbfeeed505c3b3cfe2a40f Mon Sep 17 00:00:00 2001 From: Konstantin Vyshetsky Date: Mon, 3 Oct 2022 15:07:14 -0700 Subject: [PATCH] ANDROID: scsi: ufs: add complete init vendor hook Currently the core UFS driver does not have a vops to notify when the device is operational. This commit introduces a hook, which serves to notify device completing initialization and is ready to accept I/O. This is required by the FIPS140-2 [1] self integrity test of inline encryption engine, which must run whenever the host controller is reset. The code requires sleeping while waiting for I/O to complete and allocating some memory dynamically, which requires the vendor hook to be restricted. [1] https://csrc.nist.gov/publications/detail/fips/140/2/final Bug: 185809932 Signed-off-by: Konstantin Vyshetsky (cherry picked from commit e774e4eca69ce8ab60df04b27f524b586ab74f17) (cherry picked from https://android-review.googlesource.com/q/commit:c0f24579002c3fb0e404f223f8574c7f4fdac200) Merged-In: I6f476f9c2e2b50574d2898c3f1ef6b648d92df24 Change-Id: I6f476f9c2e2b50574d2898c3f1ef6b648d92df24 --- drivers/android/vendor_hooks.c | 1 + drivers/ufs/core/ufshcd.c | 2 ++ include/trace/hooks/ufshcd.h | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index a3ee24e3ce6a..20b3b02b7db4 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -136,6 +136,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ftrace_format_check); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ftrace_dump_buffer); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ufs_fill_prdt); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_ufs_reprogram_all_keys); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_ufs_complete_init); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ufs_prepare_command); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ufs_update_sysfs); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ufs_send_command); diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 0d0fdbdbbdc4..dfac1da43c03 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -8882,6 +8882,8 @@ static int ufshcd_probe_hba(struct ufs_hba *hba, bool init_dev_params) ufshcd_auto_hibern8_enable(hba); ufshpb_toggle_state(hba, HPB_RESET, HPB_PRESENT); + + trace_android_rvh_ufs_complete_init(hba); out: spin_lock_irqsave(hba->host->host_lock, flags); if (ret) diff --git a/include/trace/hooks/ufshcd.h b/include/trace/hooks/ufshcd.h index 97d59f6cb028..b7c691858346 100644 --- a/include/trace/hooks/ufshcd.h +++ b/include/trace/hooks/ufshcd.h @@ -23,6 +23,10 @@ DECLARE_RESTRICTED_HOOK(android_rvh_ufs_reprogram_all_keys, TP_PROTO(struct ufs_hba *hba, int *err), TP_ARGS(hba, err), 1); +DECLARE_RESTRICTED_HOOK(android_rvh_ufs_complete_init, + TP_PROTO(struct ufs_hba *hba), + TP_ARGS(hba), 1); + DECLARE_HOOK(android_vh_ufs_prepare_command, TP_PROTO(struct ufs_hba *hba, struct request *rq, struct ufshcd_lrb *lrbp, int *err),