Refine error history and introduce event_notify vop
Subsystems (2)
v4 cover Refine error history and introduce event_notify vop
Hi,
This series refines error history functions, do vop cleanups and introduce a new event_notify vop to allow vendor to get notification of important events.
Changes since v3:
- Fix build warning in patch [8/8]
Changes since v2:
- Add patches for vop cleanups
- Introduce phy_initialization helper and replace direct invoking in ufs-cdns and ufs-dwc by the helper
- Introduce event_notify vop implemntation in ufs-mediatek
Changes since v1:
- Change notify_event() to event_notify() to follow vop naming covention
Stanley Chu (8):
scsi: ufs: Remove unused setup_regulators variant function
scsi: ufs: Introduce phy_initialization helper
scsi: ufs-cdns: Use phy_initialization helper
scsi: ufs-dwc: Use phy_initialization helper
scsi: ufs: Add error history for abort event in UFS Device W-LUN
scsi: ufs: Refine error history functions
scsi: ufs: Introduce event_notify variant function
scsi: ufs-mediatek: Introduce event_notify implementation
drivers/scsi/ufs/cdns-pltfrm.c | 3 +- drivers/scsi/ufs/ufs-mediatek-trace.h | 37 ++++++++ drivers/scsi/ufs/ufs-mediatek.c | 12 +++ drivers/scsi/ufs/ufshcd-dwc.c | 11 +-- drivers/scsi/ufs/ufshcd.c | 132 ++++++++++++++------------ drivers/scsi/ufs/ufshcd.h | 100 +++++++++---------- 6 files changed, 175 insertions(+), 120 deletions(-) create mode 100644 drivers/scsi/ufs/ufs-mediatek-trace.h
Signature · 1 line
2.18.0
PATCH v4 1/8 scsi: ufs: Remove unused setup_regulators variant function
Since setup_regulators variant function is not used by any vendors, simply remove it.
--- drivers/scsi/ufs/ufshcd.c | 10 +--------- drivers/scsi/ufs/ufshcd.h | 10 ---------- 2 files changed, 1 insertion(+), 19 deletions(-)
drivers/scsi/ufs/ufshcd.c +1 -9
@@ -8171,16 +8171,10 @@ static int ufshcd_variant_hba_init(struct ufs_hba *hba) goto out; err =ufshcd_vops_init (hba); -if (err) - goto out; - - err =ufshcd_vops_setup_regulators (hba, true); -if (err) -ufshcd_vops_exit (hba); -out:if (err)dev_err (hba->dev,"%s: variant %s init failed err %d\n" , __func__,ufshcd_get_var_name (hba), err); +out:return err; }
@@ -8189,8 +8183,6 @@ static void ufshcd_variant_hba_exit(struct ufs_hba *hba)if (!hba->vops)return ; -ufshcd_vops_setup_regulators (hba, false); -ufshcd_vops_exit (hba); }
drivers/scsi/ufs/ufshcd.h +0 -10
@@ -277,7 +277,6 @@ struct ufs_pwr_mode_info {* @get_ufs_hci_version: called to get UFS HCI version * @clk_scale_notify: notifies that clks are scaled up/down * @setup_clocks: called before touching any of the controller registers -* @setup_regulators: called before accessing the host controller * @hce_enable_notify: called before and after HCE enable bit is set to allow * variant specific Uni-Pro initialization. * @link_startup_notify: called before and after Link startup is carried out
@@ -307,7 +306,6 @@ struct ufs_hba_variant_ops { enum ufs_notify_change_status);int (*setup_clocks)(struct ufs_hba *,bool ,enum ufs_notify_change_status ); -int (*setup_regulators)(struct ufs_hba *,bool );int (*hce_enable_notify)(struct ufs_hba *,enum ufs_notify_change_status ); int (*link_startup_notify)(struct ufs_hba *,
@@ -1119,14 +1117,6 @@ static inline int ufshcd_vops_setup_clocks(struct ufs_hba *hba, bool on,return 0 ; } -static inline int ufshcd_vops_setup_regulators (struct ufs_hba *hba,bool status) -{ -if (hba->vops && hba->vops->setup_regulators) -return hba->vops->setup_regulators (hba, status); - -return 0 ; -} -static inline int ufshcd_vops_hce_enable_notify (struct ufs_hba *hba,bool status) {
Signature · 1 line
2.18.0
PATCH v4 2/8 scsi: ufs: Introduce phy_initialization helper
In reply to Stanley ChuIntroduce phy_initialization helper since this is the only one variant function without helper.
--- drivers/scsi/ufs/ufshcd.h | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/scsi/ufs/ufshcd.h +8 -0
@@ -1134,6 +1134,14 @@ static inline int ufshcd_vops_link_startup_notify(struct ufs_hba *hba,return 0 ; } +static inline int ufshcd_vops_phy_initialization (struct ufs_hba *hba) +{ +if (hba->vops && hba->vops->phy_initialization) +return hba->vops->phy_initialization (hba); + +return 0 ; +} + static inline int ufshcd_vops_pwr_change_notify(struct ufs_hba *hba, bool status, struct ufs_pa_layer_attr *dev_max_params,
Signature · 1 line
2.18.0
PATCH v4 3/8 scsi: ufs-cdns: Use phy_initialization helper
In reply to Stanley ChuUse phy_initialization helper instead of direct function invoking.
--- drivers/scsi/ufs/cdns-pltfrm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/ufs/cdns-pltfrm.c +1 -2
@@ -221,8 +221,7 @@ static int cdns_ufs_init(struct ufs_hba *hba)return -ENOMEM ;ufshcd_set_variant (hba, host); -if (hba->vops && hba->vops->phy_initialization) - status = hba->vops->phy_initialization (hba); + status =ufshcd_vops_phy_initialization (hba);return status; }
Signature · 1 line
2.18.0
PATCH v4 4/8 scsi: ufs-dwc: Use phy_initialization helper
In reply to Stanley ChuUse phy_initialization helper instead of direct invoking.
--- drivers/scsi/ufs/ufshcd-dwc.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/scsi/ufs/ufshcd-dwc.c +4 -7
@@ -120,13 +120,10 @@ int ufshcd_dwc_link_startup_notify(struct ufs_hba *hba,if (status ==PRE_CHANGE ) {ufshcd_dwc_program_clk_div (hba,DWC_UFS_REG_HCLKDIV_DIV_125 ); -if (hba->vops->phy_initialization) { - err = hba->vops->phy_initialization (hba); -if (err) { -dev_err (hba->dev,"Phy setup failed (%d)\n" , - err); - goto out; - } + err =ufshcd_vops_phy_initialization (hba); +if (err) { +dev_err (hba->dev,"Phy setup failed (%d)\n" , err); + goto out; } }else {/* POST_CHANGE */ err =ufshcd_dwc_link_is_up (hba);
Signature · 1 line
2.18.0
PATCH v4 5/8 scsi: ufs: Add error history for abort event in UFS Device W-LUN
In reply to Stanley ChuAdd error history for abort event in UFS Device W-LUN. Besides, use specified value as parameter of ufshcd_update_reg_hist() to identify the aborted tag or LUNs.
--- drivers/scsi/ufs/ufshcd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/scsi/ufs/ufshcd.c +4 -2
@@ -6738,8 +6738,10 @@ static int ufshcd_abort(struct scsi_cmnd *cmd)* To avoid these unnecessary/illegal step we skip to the last error * handling stage: reset and restore. */ -if (lrbp->lun ==UFS_UPIU_UFS_DEVICE_WLUN ) +if (lrbp->lun ==UFS_UPIU_UFS_DEVICE_WLUN ) { +ufshcd_update_reg_hist (&hba->ufs_stats.task_abort, lrbp->lun);return ufshcd_eh_host_reset_handler (cmd); + }ufshcd_hold (hba, false); reg =ufshcd_readl (hba,REG_UTP_TRANSFER_REQ_DOOR_BELL );
@@ -6763,7 +6765,7 @@ static int ufshcd_abort(struct scsi_cmnd *cmd)*/ scsi_print_command (hba->lrb[tag].cmd);if (!hba->req_abort_count) { -ufshcd_update_reg_hist (&hba->ufs_stats.task_abort,0 ); +ufshcd_update_reg_hist (&hba->ufs_stats.task_abort, tag);ufshcd_print_host_regs (hba);ufshcd_print_host_state (hba);ufshcd_print_pwr_info (hba);
Signature · 1 line
2.18.0
PATCH v4 6/8 scsi: ufs: Refine error history functions
In reply to Stanley ChuNowadays UFS error history does not only have "history of errors" but also have history of some other events which are not defined as errors.
This patch fixes the confused naming of related functions, and change the way for updating and printing history as preparation of next patch.
This patch shall not change any functionality.
--- drivers/scsi/ufs/ufshcd.c | 118 +++++++++++++++++++++----------------- drivers/scsi/ufs/ufshcd.h | 71 ++++++++++------------- 2 files changed, 97 insertions(+), 92 deletions(-)
drivers/scsi/ufs/ufshcd.c +66 -52
@@ -411,20 +411,25 @@ static void ufshcd_print_clk_freqs(struct ufs_hba *hba) } } -static void ufshcd_print_err_hist (struct ufs_hba *hba, -struct ufs_err_reg_hist *err_hist, -char *err_name) +static void ufshcd_print_evt (struct ufs_hba *hba,u32 id, +char *err_name) {int i;bool found = false; +struct ufs_event_hist *e; -for (i =0 ; i <UFS_ERR_REG_HIST_LENGTH ; i++) { -int p = (i + err_hist->pos) %UFS_ERR_REG_HIST_LENGTH ; +if (id >=UFS_EVT_CNT ) +return ; + + e = &hba->ufs_stats.event[id]; -if (err_hist->tstamp[p] ==0 ) +for (i =0 ; i <UFS_EVENT_HIST_LENGTH ; i++) { +int p = (i + e->pos) %UFS_EVENT_HIST_LENGTH ; + +if (e->tstamp[p] ==0 )continue ;dev_err (hba->dev,"%s[%d] = 0x%x at %lld us\n" , err_name, p, - err_hist->reg[p],ktime_to_us (err_hist->tstamp[p])); + e->val[p],ktime_to_us (e->tstamp[p])); found = true; }
@@ -432,26 +437,26 @@ static void ufshcd_print_err_hist(struct ufs_hba *hba,dev_err (hba->dev,"No record of %s\n" , err_name); } -static void ufshcd_print_host_regs (struct ufs_hba *hba) +static void ufshcd_print_evt_hist (struct ufs_hba *hba) {ufshcd_dump_regs (hba,0 ,UFSHCI_REG_SPACE_SIZE ,"host_regs: " ); -ufshcd_print_err_hist (hba, &hba->ufs_stats.pa_err,"pa_err" ); -ufshcd_print_err_hist (hba, &hba->ufs_stats.dl_err,"dl_err" ); -ufshcd_print_err_hist (hba, &hba->ufs_stats.nl_err,"nl_err" ); -ufshcd_print_err_hist (hba, &hba->ufs_stats.tl_err,"tl_err" ); -ufshcd_print_err_hist (hba, &hba->ufs_stats.dme_err,"dme_err" ); -ufshcd_print_err_hist (hba, &hba->ufs_stats.auto_hibern8_err, -"auto_hibern8_err" ); -ufshcd_print_err_hist (hba, &hba->ufs_stats.fatal_err,"fatal_err" ); -ufshcd_print_err_hist (hba, &hba->ufs_stats.link_startup_err, -"link_startup_fail" ); -ufshcd_print_err_hist (hba, &hba->ufs_stats.resume_err,"resume_fail" ); -ufshcd_print_err_hist (hba, &hba->ufs_stats.suspend_err, -"suspend_fail" ); -ufshcd_print_err_hist (hba, &hba->ufs_stats.dev_reset,"dev_reset" ); -ufshcd_print_err_hist (hba, &hba->ufs_stats.host_reset,"host_reset" ); -ufshcd_print_err_hist (hba, &hba->ufs_stats.task_abort,"task_abort" ); +ufshcd_print_evt (hba,UFS_EVT_PA_ERR ,"pa_err" ); +ufshcd_print_evt (hba,UFS_EVT_DL_ERR ,"dl_err" ); +ufshcd_print_evt (hba,UFS_EVT_NL_ERR ,"nl_err" ); +ufshcd_print_evt (hba,UFS_EVT_TL_ERR ,"tl_err" ); +ufshcd_print_evt (hba,UFS_EVT_DME_ERR ,"dme_err" ); +ufshcd_print_evt (hba,UFS_EVT_AUTO_HIBERN8_ERR , +"auto_hibern8_err" ); +ufshcd_print_evt (hba,UFS_EVT_FATAL_ERR ,"fatal_err" ); +ufshcd_print_evt (hba,UFS_EVT_LINK_STARTUP_FAIL , +"link_startup_fail" ); +ufshcd_print_evt (hba,UFS_EVT_RESUME_ERR ,"resume_fail" ); +ufshcd_print_evt (hba,UFS_EVT_SUSPEND_ERR , +"suspend_fail" ); +ufshcd_print_evt (hba,UFS_EVT_DEV_RESET ,"dev_reset" ); +ufshcd_print_evt (hba,UFS_EVT_HOST_RESET ,"host_reset" ); +ufshcd_print_evt (hba,UFS_EVT_ABORT ,"task_abort" );ufshcd_vops_dbg_register_dump (hba); }
@@ -3852,7 +3857,7 @@ static int ufshcd_uic_pwr_ctrl(struct ufs_hba *hba, struct uic_command *cmd)if (ret) {ufshcd_print_host_state (hba);ufshcd_print_pwr_info (hba); -ufshcd_print_host_regs (hba); +ufshcd_print_evt_hist (hba); }spin_lock_irqsave (hba->host->host_lock, flags);
@@ -4464,14 +4469,19 @@ static inline int ufshcd_disable_device_tx_lcc(struct ufs_hba *hba)return ufshcd_disable_tx_lcc (hba, true); } -void ufshcd_update_reg_hist (struct ufs_err_reg_hist *reg_hist, -u32 reg) +void ufshcd_update_evt_hist (struct ufs_hba *hba,u32 id,u32 val) { - reg_hist->reg[reg_hist->pos] = reg; - reg_hist->tstamp[reg_hist->pos] =ktime_get (); - reg_hist->pos = (reg_hist->pos +1 ) %UFS_ERR_REG_HIST_LENGTH ; +struct ufs_event_hist *e; + +if (id >=UFS_EVT_CNT ) +return ; + + e = &hba->ufs_stats.event[id]; + e->val[e->pos] = val; + e->tstamp[e->pos] =ktime_get (); + e->pos = (e->pos +1 ) %UFS_EVENT_HIST_LENGTH ; } -EXPORT_SYMBOL_GPL (ufshcd_update_reg_hist); +EXPORT_SYMBOL_GPL (ufshcd_update_evt_hist);/** * ufshcd_link_startup - Initialize unipro link startup
@@ -4500,7 +4510,8 @@ static int ufshcd_link_startup(struct ufs_hba *hba)/* check if device is detected by inter-connect layer */ if (!ret && !ufshcd_is_device_present (hba)) { -ufshcd_update_reg_hist (&hba->ufs_stats.link_startup_err, +ufshcd_update_evt_hist (hba, +UFS_EVT_LINK_STARTUP_FAIL ,0 );dev_err (hba->dev,"%s: Device not present\n" , __func__); ret = -ENXIO ;
@@ -4513,7 +4524,8 @@ static int ufshcd_link_startup(struct ufs_hba *hba)* succeeds. So reset the local Uni-Pro and try again. */ if (ret &&ufshcd_hba_enable (hba)) { -ufshcd_update_reg_hist (&hba->ufs_stats.link_startup_err, +ufshcd_update_evt_hist (hba, +UFS_EVT_LINK_STARTUP_FAIL , (u32 )ret); goto out; }
@@ -4521,7 +4533,8 @@ static int ufshcd_link_startup(struct ufs_hba *hba)if (ret) {/* failed to get the link up... retire */ -ufshcd_update_reg_hist (&hba->ufs_stats.link_startup_err, +ufshcd_update_evt_hist (hba, +UFS_EVT_LINK_STARTUP_FAIL , (u32 )ret); goto out; }
@@ -4555,7 +4568,7 @@ static int ufshcd_link_startup(struct ufs_hba *hba)dev_err (hba->dev,"link startup failed %d\n" , ret);ufshcd_print_host_state (hba);ufshcd_print_pwr_info (hba); -ufshcd_print_host_regs (hba); +ufshcd_print_evt_hist (hba); }return ret; }
@@ -4910,7 +4923,7 @@ ufshcd_transfer_rsp_status(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)dev_err (hba->dev,"OCS error from controller = %x for tag %d\n" , ocs, lrbp->task_tag); -ufshcd_print_host_regs (hba); +ufshcd_print_evt_hist (hba);ufshcd_print_host_state (hba);break ; }/* end of switch */
@@ -5792,7 +5805,7 @@ static void ufshcd_err_handler(struct work_struct *work)spin_unlock_irqrestore (hba->host->host_lock, flags);ufshcd_print_host_state (hba);ufshcd_print_pwr_info (hba); -ufshcd_print_host_regs (hba); +ufshcd_print_evt_hist (hba);ufshcd_print_tmrs (hba, hba->outstanding_tasks);ufshcd_print_trs (hba, hba->outstanding_reqs, pr_prdt);spin_lock_irqsave (hba->host->host_lock, flags);
@@ -5937,7 +5950,7 @@ static irqreturn_t ufshcd_update_uic_error(struct ufs_hba *hba) reg =ufshcd_readl (hba,REG_UIC_ERROR_CODE_PHY_ADAPTER_LAYER );if ((reg &UIC_PHY_ADAPTER_LAYER_ERROR ) && (reg &UIC_PHY_ADAPTER_LAYER_ERROR_CODE_MASK )) { -ufshcd_update_reg_hist (&hba->ufs_stats.pa_err, reg); +ufshcd_update_evt_hist (hba,UFS_EVT_PA_ERR , reg);/* * To know whether this error is fatal or not, DB timeout * must be checked but this error is handled separately.
@@ -5967,7 +5980,7 @@ static irqreturn_t ufshcd_update_uic_error(struct ufs_hba *hba) reg =ufshcd_readl (hba,REG_UIC_ERROR_CODE_DATA_LINK_LAYER );if ((reg &UIC_DATA_LINK_LAYER_ERROR ) && (reg &UIC_DATA_LINK_LAYER_ERROR_CODE_MASK )) { -ufshcd_update_reg_hist (&hba->ufs_stats.dl_err, reg); +ufshcd_update_evt_hist (hba,UFS_EVT_DL_ERR , reg);if (reg &UIC_DATA_LINK_LAYER_ERROR_PA_INIT ) hba->uic_error |=UFSHCD_UIC_DL_PA_INIT_ERROR ;
@@ -5986,7 +5999,7 @@ static irqreturn_t ufshcd_update_uic_error(struct ufs_hba *hba) reg =ufshcd_readl (hba,REG_UIC_ERROR_CODE_NETWORK_LAYER );if ((reg &UIC_NETWORK_LAYER_ERROR ) && (reg &UIC_NETWORK_LAYER_ERROR_CODE_MASK )) { -ufshcd_update_reg_hist (&hba->ufs_stats.nl_err, reg); +ufshcd_update_evt_hist (hba,UFS_EVT_NL_ERR , reg); hba->uic_error |=UFSHCD_UIC_NL_ERROR ; retval |=IRQ_HANDLED ; }
@@ -5994,7 +6007,7 @@ static irqreturn_t ufshcd_update_uic_error(struct ufs_hba *hba) reg =ufshcd_readl (hba,REG_UIC_ERROR_CODE_TRANSPORT_LAYER );if ((reg &UIC_TRANSPORT_LAYER_ERROR ) && (reg &UIC_TRANSPORT_LAYER_ERROR_CODE_MASK )) { -ufshcd_update_reg_hist (&hba->ufs_stats.tl_err, reg); +ufshcd_update_evt_hist (hba,UFS_EVT_TL_ERR , reg); hba->uic_error |=UFSHCD_UIC_TL_ERROR ; retval |=IRQ_HANDLED ; }
@@ -6002,7 +6015,7 @@ static irqreturn_t ufshcd_update_uic_error(struct ufs_hba *hba) reg =ufshcd_readl (hba,REG_UIC_ERROR_CODE_DME );if ((reg &UIC_DME_ERROR ) && (reg &UIC_DME_ERROR_CODE_MASK )) { -ufshcd_update_reg_hist (&hba->ufs_stats.dme_err, reg); +ufshcd_update_evt_hist (hba,UFS_EVT_DME_ERR , reg); hba->uic_error |=UFSHCD_UIC_DME_ERROR ; retval |=IRQ_HANDLED ; }
@@ -6044,7 +6057,8 @@ static irqreturn_t ufshcd_check_errors(struct ufs_hba *hba)irqreturn_t retval =IRQ_NONE ;if (hba->errors &INT_FATAL_ERRORS ) { -ufshcd_update_reg_hist (&hba->ufs_stats.fatal_err, hba->errors); +ufshcd_update_evt_hist (hba,UFS_EVT_FATAL_ERR , + hba->errors); queue_eh_work = true; }
@@ -6061,7 +6075,7 @@ static irqreturn_t ufshcd_check_errors(struct ufs_hba *hba) __func__, (hba->errors &UIC_HIBERNATE_ENTER ) ?"Enter" :"Exit" , hba->errors, ufshcd_get_upmcrs(hba)); -ufshcd_update_reg_hist (&hba->ufs_stats.auto_hibern8_err, +ufshcd_update_evt_hist (hba,UFS_EVT_AUTO_HIBERN8_ERR , hba->errors);ufshcd_set_link_broken (hba); queue_eh_work = true;
@@ -6602,7 +6616,7 @@ static int ufshcd_eh_device_reset_handler(struct scsi_cmnd *cmd) out: hba->req_abort_count =0 ; -ufshcd_update_reg_hist (&hba->ufs_stats.dev_reset, (u32 )err); +ufshcd_update_evt_hist (hba,UFS_EVT_DEV_RESET , (u32 )err);if (!err) { err =SUCCESS ; }else {
@@ -6739,7 +6753,7 @@ static int ufshcd_abort(struct scsi_cmnd *cmd)* handling stage: reset and restore. */ if (lrbp->lun ==UFS_UPIU_UFS_DEVICE_WLUN ) { -ufshcd_update_reg_hist (&hba->ufs_stats.task_abort, lrbp->lun); +ufshcd_update_evt_hist (hba,UFS_EVT_ABORT , lrbp->lun);return ufshcd_eh_host_reset_handler (cmd); }
@@ -6765,8 +6779,8 @@ static int ufshcd_abort(struct scsi_cmnd *cmd)*/ scsi_print_command (hba->lrb[tag].cmd);if (!hba->req_abort_count) { -ufshcd_update_reg_hist (&hba->ufs_stats.task_abort, tag); -ufshcd_print_host_regs (hba); +ufshcd_update_evt_hist (hba,UFS_EVT_ABORT , tag); +ufshcd_print_evt_hist (hba);ufshcd_print_host_state (hba);ufshcd_print_pwr_info (hba);ufshcd_print_trs (hba,1 << tag, true);
@@ -6849,7 +6863,7 @@ static int ufshcd_host_reset_and_restore(struct ufs_hba *hba) out:if (err)dev_err (hba->dev,"%s: Host init failed %d\n" , __func__, err); -ufshcd_update_reg_hist (&hba->ufs_stats.host_reset, (u32 )err); +ufshcd_update_evt_hist (hba,UFS_EVT_HOST_RESET , (u32 )err);return err; }
@@ -8689,7 +8703,7 @@ static int ufshcd_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op) hba->pm_op_in_progress =0 ;if (ret) -ufshcd_update_reg_hist (&hba->ufs_stats.suspend_err, (u32 )ret); +ufshcd_update_evt_hist (hba,UFS_EVT_SUSPEND_ERR , (u32 )ret);return ret; }
@@ -8813,7 +8827,7 @@ static int ufshcd_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op) out: hba->pm_op_in_progress =0 ;if (ret) -ufshcd_update_reg_hist (&hba->ufs_stats.resume_err, (u32 )ret); +ufshcd_update_evt_hist (hba,UFS_EVT_RESUME_ERR , (u32 )ret);return ret; }
@@ -9265,7 +9279,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) err =ufshcd_hba_enable (hba);if (err) {dev_err (hba->dev,"Host controller enable failed\n" ); -ufshcd_print_host_regs (hba); +ufshcd_print_evt_hist (hba);ufshcd_print_host_state (hba); goto free_tmf_queue; }
drivers/scsi/ufs/ufshcd.h +31 -40
113 lines not on this page · raw message
Signature · 1 line
2.18.0
PATCH v4 7/8 scsi: ufs: Introduce event_notify variant function
In reply to Stanley ChuIntroduce event_notify variant function to allow vendor to get notification of important events and connect to any proprietary debugging facilities.
--- drivers/scsi/ufs/ufshcd.c | 2 ++ drivers/scsi/ufs/ufshcd.h | 11 +++++++++++ 2 files changed, 13 insertions(+)
drivers/scsi/ufs/ufshcd.c +2 -0
@@ -4480,6 +4480,8 @@ void ufshcd_update_evt_hist(struct ufs_hba *hba, u32 id, u32 val) e->val[e->pos] = val; e->tstamp[e->pos] =ktime_get (); e->pos = (e->pos +1 ) %UFS_EVENT_HIST_LENGTH ; + +ufshcd_vops_event_notify (hba, id, &val); }EXPORT_SYMBOL_GPL (ufshcd_update_evt_hist);
drivers/scsi/ufs/ufshcd.h +11 -0
@@ -319,6 +319,7 @@ struct ufs_pwr_mode_info {* @phy_initialization: used to initialize phys * @device_reset: called to issue a reset pulse on the UFS device * @program_key: program or evict an inline encryption key +* @event_notify: called to notify important events */ struct ufs_hba_variant_ops {const char *name;
@@ -353,6 +354,8 @@ struct ufs_hba_variant_ops { void *data);int (*program_key)(struct ufs_hba *hba,const union ufs_crypto_cfg_entry *cfg,int slot); +void (*event_notify)(struct ufs_hba *hba, +enum ufs_event_type evt,void *data); };/* clock gating state */
@@ -1100,6 +1103,14 @@ static inline int ufshcd_vops_clk_scale_notify(struct ufs_hba *hba,return 0 ; } +static inline void ufshcd_vops_event_notify (struct ufs_hba *hba, +enum ufs_event_type evt, +void *data) +{ +if (hba->vops && hba->vops->event_notify) + hba->vops->event_notify (hba, evt, data); +} +static inline int ufshcd_vops_setup_clocks (struct ufs_hba *hba,bool on,enum ufs_notify_change_status status) {
Signature · 1 line
2.18.0
PATCH v4 8/8 scsi: ufs-mediatek: Introduce event_notify implementation
In reply to Stanley ChuIntroduce event_notify implementation on MediaTek UFS platform.
A vendor-specific tracepoint is added that could be used for debugging purpose.
--- drivers/scsi/ufs/ufs-mediatek-trace.h | 37 +++++++++++++++++++++++++++ drivers/scsi/ufs/ufs-mediatek.c | 12 +++++++++ 2 files changed, 49 insertions(+) create mode 100644 drivers/scsi/ufs/ufs-mediatek-trace.h
drivers/scsi/ufs/ufs-mediatek-trace.h new file +37 -0
@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) 2020 MediaTek Inc. +*/ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM ufs_mtk + +#if !defined(_TRACE_EVENT_UFS_MEDIATEK_H) || defined(TRACE_HEADER_MULTI_READ ) +#define _TRACE_EVENT_UFS_MEDIATEK_H + +#include <linux/tracepoint.h> + +TRACE_EVENT (ufs_mtk_event, + TP_PROTO(unsigned int type, unsigned int data), +TP_ARGS (type, data), + +TP_STRUCT__entry ( + __field(unsigned int, type) + __field(unsigned int, data) + ), + +TP_fast_assign ( + __entry->type = type; + __entry->data = data; + ), + +TP_printk ("ufs:event=%u data=%u" , + __entry->type, __entry->data) + ); +#endif + +#undef TRACE_INCLUDE_PATH +#undef TRACE_INCLUDE_FILE +#define TRACE_INCLUDE_PATH . +#define TRACE_INCLUDE_FILE ufs-mediatek-trace +#include <trace/define_trace.h> +
drivers/scsi/ufs/ufs-mediatek.c +12 -0
@@ -24,6 +24,9 @@#include "unipro.h" #include "ufs-mediatek.h" +#define CREATE_TRACE_POINTS +#include "ufs-mediatek-trace.h" +#define ufs_mtk_smc (cmd, val, res) \ arm_smccc_smc(MTK_SIP_UFS_CONTROL, \ cmd, val, 0, 0, 0, 0, 0, &(res))
@@ -1002,6 +1005,14 @@ static void ufs_mtk_fixup_dev_quirks(struct ufs_hba *hba)ufshcd_fixup_dev_quirks (hba, ufs_mtk_dev_fixups); } +static void ufs_mtk_event_notify (struct ufs_hba *hba, +enum ufs_event_type evt,void *data) +{ +unsigned int val = *(u32 *)data; + +trace_ufs_mtk_event (evt, val); +} +/* * struct ufs_hba_mtk_vops - UFS MTK specific variant operations *
@@ -1021,6 +1032,7 @@ static const struct ufs_hba_variant_ops ufs_hba_mtk_vops = { .resume = ufs_mtk_resume, .dbg_register_dump = ufs_mtk_dbg_register_dump, .device_reset = ufs_mtk_device_reset, + .event_notify = ufs_mtk_event_notify, };/**
Signature · 1 line
2.18.0
Hi Stanley,
Will you split this series to 3 separate series:
Phy initialization cleanup, Error history, and event notification? As those 3 aren't really connected?
Please maintain Can's reviewed-by tag for the error history patches, And add mine for the phy initialization, so Martin can pick those.
Thanks,
Avri
Quoted 37 lines
Hi,
This series refines error history functions, do vop cleanups and introduce a newevent_notifyvop to allow vendor to get notification of important events.Changes since v3:
- Fix build warning in patch [8/8]Changes since v2:
- Add patches for vop cleanups
- Introducephy_initializationhelper and replace direct invoking in ufs-cdns
and ufs-dwc by the helper
- Introduceevent_notifyvop implemntation in ufs-mediatekChanges since v1:
- Changenotify_event()toevent_notify()to follow vop naming coventionStanley Chu (8):
scsi: ufs: Remove unusedsetup_regulatorsvariant function
scsi: ufs: Introducephy_initializationhelper
scsi: ufs-cdns: Usephy_initializationhelper
scsi: ufs-dwc: Usephy_initializationhelper
scsi: ufs: Add error history for abort event in UFS Device W-LUN
scsi: ufs: Refine error history functions
scsi: ufs: Introduceevent_notifyvariant function
scsi: ufs-mediatek: Introduceevent_notifyimplementationdrivers/scsi/ufs/cdns-pltfrm.c | 3 +- drivers/scsi/ufs/ufs-mediatek-trace.h | 37 ++++++++ drivers/scsi/ufs/ufs-mediatek.c | 12 +++ drivers/scsi/ufs/ufshcd-dwc.c | 11 +-- drivers/scsi/ufs/ufshcd.c | 132 ++++++++++++++------------ drivers/scsi/ufs/ufshcd.h | 100 +++++++++---------- 6 files changed, 175 insertions(+), 120 deletions(-) create mode 100644 drivers/scsi/ufs/ufs-mediatek-trace.h
Quoted 2 lines
--
2.18.0
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
Quoted 8 lines
Hi Stanley,
Will you split this series to 3 separate series:
Phy initialization cleanup, Error history, and event notification? As those 3 aren't really connected?Please maintain Can's reviewed-by tag for the error history patches, And add mine for the phy initialization, so Martin can pick those.
And for the new event notification vop of course. Sorry.
Thanks,
Avri
Quoted 43 lines
Thanks,
AvriQuoted 39 lines
Hi,
This series refines error history functions, do vop cleanups and introduce a newevent_notifyvop to allow vendor to get notification of important events.Changes since v3:
- Fix build warning in patch [8/8]Changes since v2:
- Add patches for vop cleanups
- Introducephy_initializationhelper and replace direct invoking in ufs-cdns
and ufs-dwc by the helper
- Introduceevent_notifyvop implemntation in ufs-mediatekChanges since v1:
- Changenotify_event()toevent_notify()to follow vop naming coventionStanley Chu (8):
scsi: ufs: Remove unusedsetup_regulatorsvariant function
scsi: ufs: Introducephy_initializationhelper
scsi: ufs-cdns: Usephy_initializationhelper
scsi: ufs-dwc: Usephy_initializationhelper
scsi: ufs: Add error history for abort event in UFS Device W-LUN
scsi: ufs: Refine error history functions
scsi: ufs: Introduceevent_notifyvariant function
scsi: ufs-mediatek: Introduceevent_notifyimplementationdrivers/scsi/ufs/cdns-pltfrm.c | 3 +- drivers/scsi/ufs/ufs-mediatek-trace.h | 37 ++++++++ drivers/scsi/ufs/ufs-mediatek.c | 12 +++ drivers/scsi/ufs/ufshcd-dwc.c | 11 +-- drivers/scsi/ufs/ufshcd.c | 132 ++++++++++++++------------ drivers/scsi/ufs/ufshcd.h | 100 +++++++++---------- 6 files changed, 175 insertions(+), 120 deletions(-) create mode 100644 drivers/scsi/ufs/ufs-mediatek-trace.h--
2.18.0
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
Hi Avri,
Quoted 9 lines · Avri Altman
Quoted 8 lines
Hi Stanley,
Will you split this series to 3 separate series:
Phy initialization cleanup, Error history, and event notification? As those 3 aren't really connected?Please maintain Can's reviewed-by tag for the error history patches, And add mine for the phy initialization, so Martin can pick those.
And for the new event notification vop of course. Sorry.
Thanks for the review!
Sure I would separate it to 2 series
1. Cleanup phy_initialization
2. Error history and event notification since these patches are strongly related
Please review my new posted series and feel free to provide any further suggestion.
Thanks,
Stanley Chu
Quoted 48 lines
Thanks,
AvriQuoted 43 lines
Thanks,
AvriQuoted 39 lines
Hi,
This series refines error history functions, do vop cleanups and introduce a newevent_notifyvop to allow vendor to get notification of important events.Changes since v3:
- Fix build warning in patch [8/8]Changes since v2:
- Add patches for vop cleanups
- Introducephy_initializationhelper and replace direct invoking in ufs-cdns
and ufs-dwc by the helper
- Introduceevent_notifyvop implemntation in ufs-mediatekChanges since v1:
- Changenotify_event()toevent_notify()to follow vop naming coventionStanley Chu (8):
scsi: ufs: Remove unusedsetup_regulatorsvariant function
scsi: ufs: Introducephy_initializationhelper
scsi: ufs-cdns: Usephy_initializationhelper
scsi: ufs-dwc: Usephy_initializationhelper
scsi: ufs: Add error history for abort event in UFS Device W-LUN
scsi: ufs: Refine error history functions
scsi: ufs: Introduceevent_notifyvariant function
scsi: ufs-mediatek: Introduceevent_notifyimplementationdrivers/scsi/ufs/cdns-pltfrm.c | 3 +- drivers/scsi/ufs/ufs-mediatek-trace.h | 37 ++++++++ drivers/scsi/ufs/ufs-mediatek.c | 12 +++ drivers/scsi/ufs/ufshcd-dwc.c | 11 +-- drivers/scsi/ufs/ufshcd.c | 132 ++++++++++++++------------ drivers/scsi/ufs/ufshcd.h | 100 +++++++++---------- 6 files changed, 175 insertions(+), 120 deletions(-) create mode 100644 drivers/scsi/ufs/ufs-mediatek-trace.h--
2.18.0
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek