diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index c264c4e07c32..0be1a662038d 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -28,6 +28,7 @@ #include #include #include +#include /* * Export tracepoints that act as a bare tracehook (ie: have no trace event @@ -108,3 +109,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ftrace_oops_exit); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ftrace_size_check); 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_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 662110100ec4..6e362a5424a5 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) { @@ -882,11 +884,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 0c5e09876d57..92f081a26aff 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) @@ -2001,7 +2004,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); @@ -2613,7 +2616,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); @@ -5071,7 +5074,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 393b4e8824b8..c663a4031f24 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -326,10 +326,6 @@ struct ufs_pwr_mode_info { * @event_notify: called to notify important events * @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; @@ -368,11 +364,6 @@ struct ufs_hba_variant_ops { enum ufs_event_type evt, void *data); 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 */ @@ -1287,35 +1278,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