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 <jaegeuk@google.com>
Change-Id: Ic66077b3c42e63a5496a1d0c107bad8ae3601f3c
This commit is contained in:
Jaegeuk Kim
2021-02-23 22:41:27 -08:00
parent 42b8f4b026
commit f2b125b149
5 changed files with 49 additions and 46 deletions

View File

@@ -28,6 +28,7 @@
#include <trace/hooks/mm.h>
#include <trace/hooks/preemptirq.h>
#include <trace/hooks/ftrace_dump.h>
#include <trace/hooks/ufshcd.h>
/*
* 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);

View File

@@ -9,6 +9,8 @@
#include "ufs.h"
#include "ufs-sysfs.h"
#include <trace/hooks/ufshcd.h>
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)

View File

@@ -28,6 +28,9 @@
#define CREATE_TRACE_POINTS
#include <trace/events/ufs.h>
#undef CREATE_TRACE_POINTS
#include <trace/hooks/ufshcd.h>
#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);

View File

@@ -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[];
/*

View File

@@ -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 <linux/tracepoint.h>
#include <trace/hooks/vendor_hooks.h>
/*
* 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 <trace/define_trace.h>