From 0d213c592161e4b24b4731fa92dce096c41c4670 Mon Sep 17 00:00:00 2001 From: Jaegeuk Kim Date: Tue, 23 Feb 2021 22:41:27 -0800 Subject: [PATCH] ANDROID: scsi: ufs: replace variants with android vendor hooks This converts the existing android-specific hooks to official vendor hooks. Per not-restricted hooks, vendor body should not enter into sleep mode by mutex or similar. Bug: 181359082 Signed-off-by: Jaegeuk Kim Change-Id: Ic66077b3c42e63a5496a1d0c107bad8ae3601f3c --- drivers/android/vendor_hooks.c | 5 +++++ drivers/scsi/ufs/ufs-sysfs.c | 8 +++---- drivers/scsi/ufs/ufshcd.c | 9 +++++--- drivers/scsi/ufs/ufshcd.h | 38 ---------------------------------- include/trace/hooks/ufshcd.h | 35 +++++++++++++++++++++++++++++++ 5 files changed, 49 insertions(+), 46 deletions(-) create mode 100644 include/trace/hooks/ufshcd.h diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index e68177ff431f..75f2272daf2c 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -37,6 +37,7 @@ #include #include #include +#include /* * Export tracepoints that act as a bare tracehook (ie: have no trace event @@ -159,3 +160,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_check_preempt_wakeup); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rmqueue); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_pagecache_get_page); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_enable_thermal_genl_check); +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); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ufs_compl_command); diff --git a/drivers/scsi/ufs/ufs-sysfs.c b/drivers/scsi/ufs/ufs-sysfs.c index 97dcd9c3befa..2d6ae922ba16 100644 --- a/drivers/scsi/ufs/ufs-sysfs.c +++ b/drivers/scsi/ufs/ufs-sysfs.c @@ -9,6 +9,8 @@ #include "ufs.h" #include "ufs-sysfs.h" +#include + static const char *ufschd_uic_link_state_to_string( enum uic_link_state state) { @@ -875,11 +877,7 @@ void ufs_sysfs_add_nodes(struct ufs_hba *hba) return; } - ret = ufshcd_vops_update_sysfs(hba); - if (ret) - dev_err(hba->dev, - "%s: vops sysfs groups update failed (err = %d)\n", - __func__, ret); + trace_android_vh_ufs_update_sysfs(hba); } void ufs_sysfs_remove_nodes(struct device *dev) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index a69ee7ae2a75..01e5a1ebfa13 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -28,6 +28,9 @@ #define CREATE_TRACE_POINTS #include +#undef CREATE_TRACE_POINTS +#include + #define UFSHCD_ENABLE_INTRS (UTP_TRANSFER_REQ_COMPL |\ UTP_TASK_REQ_COMPL |\ UFSHCD_ERROR_MASK) @@ -1978,7 +1981,7 @@ void ufshcd_send_command(struct ufs_hba *hba, unsigned int task_tag) lrbp->issue_time_stamp = ktime_get(); lrbp->compl_time_stamp = ktime_set(0, 0); ufshcd_vops_setup_xfer_req(hba, task_tag, (lrbp->cmd ? true : false)); - ufshcd_vops_send_command(hba, lrbp); + trace_android_vh_ufs_send_command(hba, lrbp); ufshcd_add_command_trace(hba, task_tag, "send"); ufshcd_clk_scaling_start_busy(hba); __set_bit(task_tag, &hba->outstanding_reqs); @@ -2590,7 +2593,7 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) lrbp->lun = ufshcd_scsi_to_upiu_lun(cmd->device->lun); lrbp->intr_cmd = !ufshcd_is_intr_aggr_allowed(hba) ? true : false; - err = ufshcd_vops_prepare_command(hba, cmd->request, lrbp); + trace_android_vh_ufs_prepare_command(hba, cmd->request, lrbp, &err); if (err) { lrbp->cmd = NULL; ufshcd_release(hba); @@ -5023,7 +5026,7 @@ static void __ufshcd_transfer_req_compl(struct ufs_hba *hba, lrbp->compl_time_stamp = ktime_get(); cmd = lrbp->cmd; if (cmd) { - ufshcd_vops_compl_command(hba, lrbp); + trace_android_vh_ufs_compl_command(hba, lrbp); ufshcd_add_command_trace(hba, index, "complete"); result = ufshcd_transfer_rsp_status(hba, lrbp); scsi_dma_unmap(cmd); diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index cd8b9091e7b9..69662508dd01 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -293,10 +293,6 @@ struct ufs_pwr_mode_info { * @program_key: program or evict an inline encryption key * @fill_prdt: called after initializing the standard PRDT fields so that any * variant-specific PRDT fields can be initialized too - * @prepare_command: called when receiving a request in the first place - * @update_sysfs: adds vendor-specific sysfs entries - * @send_command: adds vendor-specific work when sending a command - * @compl_command: adds vendor-specific work when completing a command */ struct ufs_hba_variant_ops { const char *name; @@ -334,11 +330,6 @@ struct ufs_hba_variant_ops { const union ufs_crypto_cfg_entry *cfg, int slot); int (*fill_prdt)(struct ufs_hba *hba, struct ufshcd_lrb *lrbp, unsigned int segments); - int (*prepare_command)(struct ufs_hba *hba, - struct request *rq, struct ufshcd_lrb *lrbp); - int (*update_sysfs)(struct ufs_hba *hba); - void (*send_command)(struct ufs_hba *hba, struct ufshcd_lrb *lrbp); - void (*compl_command)(struct ufs_hba *hba, struct ufshcd_lrb *lrbp); }; /* clock gating state */ @@ -1284,35 +1275,6 @@ static inline int ufshcd_vops_fill_prdt(struct ufs_hba *hba, return 0; } -static inline int ufshcd_vops_prepare_command(struct ufs_hba *hba, - struct request *rq, struct ufshcd_lrb *lrbp) -{ - if (hba->vops && hba->vops->prepare_command) - return hba->vops->prepare_command(hba, rq, lrbp); - return 0; -} - -static inline int ufshcd_vops_update_sysfs(struct ufs_hba *hba) -{ - if (hba->vops && hba->vops->update_sysfs) - return hba->vops->update_sysfs(hba); - return 0; -} - -static inline void ufshcd_vops_send_command(struct ufs_hba *hba, - struct ufshcd_lrb *lrbp) -{ - if (hba->vops && hba->vops->send_command) - hba->vops->send_command(hba, lrbp); -} - -static inline void ufshcd_vops_compl_command(struct ufs_hba *hba, - struct ufshcd_lrb *lrbp) -{ - if (hba->vops && hba->vops->compl_command) - hba->vops->compl_command(hba, lrbp); -} - extern struct ufs_pm_lvl_states ufs_pm_lvl_states[]; /* diff --git a/include/trace/hooks/ufshcd.h b/include/trace/hooks/ufshcd.h new file mode 100644 index 000000000000..51629c0ae40c --- /dev/null +++ b/include/trace/hooks/ufshcd.h @@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM ufshcd +#define TRACE_INCLUDE_PATH trace/hooks +#if !defined(_TRACE_HOOK_UFSHCD_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_HOOK_UFSHCD_H +#include +#include +/* + * Following tracepoints are not exported in tracefs and provide a + * mechanism for vendor modules to hook and extend functionality + */ +struct ufs_hba; +struct request; +struct ufshcd_lrb; +DECLARE_HOOK(android_vh_ufs_prepare_command, + TP_PROTO(struct ufs_hba *hba, struct request *rq, + struct ufshcd_lrb *lrbp, int *err), + TP_ARGS(hba, rq, lrbp, err)); + +DECLARE_HOOK(android_vh_ufs_update_sysfs, + TP_PROTO(struct ufs_hba *hba), + TP_ARGS(hba)); + +DECLARE_HOOK(android_vh_ufs_send_command, + TP_PROTO(struct ufs_hba *hba, struct ufshcd_lrb *lrbp), + TP_ARGS(hba, lrbp)); + +DECLARE_HOOK(android_vh_ufs_compl_command, + TP_PROTO(struct ufs_hba *hba, struct ufshcd_lrb *lrbp), + TP_ARGS(hba, lrbp)); + +#endif /* _TRACE_HOOK_UFSHCD_H */ +/* This part must be outside protection */ +#include