@@ -558,8 +558,7 @@ static int experimental_iopoll_q_cnt;
558558module_param (experimental_iopoll_q_cnt , int , 0444 );
559559MODULE_PARM_DESC (experimental_iopoll_q_cnt , "number of queues to be used as poll mode, def=0" );
560560
561- static void debugfs_work_handler_v3_hw (struct work_struct * work );
562- static void debugfs_snapshot_regs_v3_hw (struct hisi_hba * hisi_hba );
561+ static int debugfs_snapshot_regs_v3_hw (struct hisi_hba * hisi_hba );
563562
564563static u32 hisi_sas_read32 (struct hisi_hba * hisi_hba , u32 off )
565564{
@@ -3388,7 +3387,6 @@ hisi_sas_shost_alloc_pci(struct pci_dev *pdev)
33883387 hisi_hba = shost_priv (shost );
33893388
33903389 INIT_WORK (& hisi_hba -> rst_work , hisi_sas_rst_work_handler );
3391- INIT_WORK (& hisi_hba -> debugfs_work , debugfs_work_handler_v3_hw );
33923390 hisi_hba -> hw = & hisi_sas_v3_hw ;
33933391 hisi_hba -> pci_dev = pdev ;
33943392 hisi_hba -> dev = dev ;
@@ -3860,47 +3858,13 @@ static void debugfs_create_files_v3_hw(struct hisi_hba *hisi_hba)
38603858 & debugfs_ras_v3_hw_fops );
38613859}
38623860
3863- static void debugfs_snapshot_regs_v3_hw (struct hisi_hba * hisi_hba )
3864- {
3865- int debugfs_dump_index = hisi_hba -> debugfs_dump_index ;
3866- struct device * dev = hisi_hba -> dev ;
3867- u64 timestamp = local_clock ();
3868-
3869- if (debugfs_dump_index >= hisi_sas_debugfs_dump_count ) {
3870- dev_warn (dev , "dump count exceeded!\n" );
3871- return ;
3872- }
3873-
3874- do_div (timestamp , NSEC_PER_MSEC );
3875- hisi_hba -> debugfs_timestamp [debugfs_dump_index ] = timestamp ;
3876-
3877- debugfs_snapshot_prepare_v3_hw (hisi_hba );
3878-
3879- debugfs_snapshot_global_reg_v3_hw (hisi_hba );
3880- debugfs_snapshot_port_reg_v3_hw (hisi_hba );
3881- debugfs_snapshot_axi_reg_v3_hw (hisi_hba );
3882- debugfs_snapshot_ras_reg_v3_hw (hisi_hba );
3883- debugfs_snapshot_cq_reg_v3_hw (hisi_hba );
3884- debugfs_snapshot_dq_reg_v3_hw (hisi_hba );
3885- debugfs_snapshot_itct_reg_v3_hw (hisi_hba );
3886- debugfs_snapshot_iost_reg_v3_hw (hisi_hba );
3887-
3888- debugfs_create_files_v3_hw (hisi_hba );
3889-
3890- debugfs_snapshot_restore_v3_hw (hisi_hba );
3891- hisi_hba -> debugfs_dump_index ++ ;
3892- }
3893-
38943861static ssize_t debugfs_trigger_dump_v3_hw_write (struct file * file ,
38953862 const char __user * user_buf ,
38963863 size_t count , loff_t * ppos )
38973864{
38983865 struct hisi_hba * hisi_hba = file -> f_inode -> i_private ;
38993866 char buf [8 ];
39003867
3901- if (hisi_hba -> debugfs_dump_index >= hisi_sas_debugfs_dump_count )
3902- return - EFAULT ;
3903-
39043868 if (count > 8 )
39053869 return - EFAULT ;
39063870
@@ -3910,7 +3874,12 @@ static ssize_t debugfs_trigger_dump_v3_hw_write(struct file *file,
39103874 if (buf [0 ] != '1' )
39113875 return - EFAULT ;
39123876
3913- queue_work (hisi_hba -> wq , & hisi_hba -> debugfs_work );
3877+ down (& hisi_hba -> sem );
3878+ if (debugfs_snapshot_regs_v3_hw (hisi_hba )) {
3879+ up (& hisi_hba -> sem );
3880+ return - EFAULT ;
3881+ }
3882+ up (& hisi_hba -> sem );
39143883
39153884 return count ;
39163885}
@@ -4661,14 +4630,6 @@ static void debugfs_fifo_init_v3_hw(struct hisi_hba *hisi_hba)
46614630 }
46624631}
46634632
4664- static void debugfs_work_handler_v3_hw (struct work_struct * work )
4665- {
4666- struct hisi_hba * hisi_hba =
4667- container_of (work , struct hisi_hba , debugfs_work );
4668-
4669- debugfs_snapshot_regs_v3_hw (hisi_hba );
4670- }
4671-
46724633static void debugfs_release_v3_hw (struct hisi_hba * hisi_hba , int dump_index )
46734634{
46744635 struct device * dev = hisi_hba -> dev ;
@@ -4703,7 +4664,7 @@ static int debugfs_alloc_v3_hw(struct hisi_hba *hisi_hba, int dump_index)
47034664{
47044665 const struct hisi_sas_hw * hw = hisi_hba -> hw ;
47054666 struct device * dev = hisi_hba -> dev ;
4706- int p , c , d , r , i ;
4667+ int p , c , d , r ;
47074668 size_t sz ;
47084669
47094670 for (r = 0 ; r < DEBUGFS_REGS_NUM ; r ++ ) {
@@ -4783,11 +4744,48 @@ static int debugfs_alloc_v3_hw(struct hisi_hba *hisi_hba, int dump_index)
47834744
47844745 return 0 ;
47854746fail :
4786- for (i = 0 ; i < hisi_sas_debugfs_dump_count ; i ++ )
4787- debugfs_release_v3_hw (hisi_hba , i );
4747+ debugfs_release_v3_hw (hisi_hba , dump_index );
47884748 return - ENOMEM ;
47894749}
47904750
4751+ static int debugfs_snapshot_regs_v3_hw (struct hisi_hba * hisi_hba )
4752+ {
4753+ int debugfs_dump_index = hisi_hba -> debugfs_dump_index ;
4754+ struct device * dev = hisi_hba -> dev ;
4755+ u64 timestamp = local_clock ();
4756+
4757+ if (debugfs_dump_index >= hisi_sas_debugfs_dump_count ) {
4758+ dev_warn (dev , "dump count exceeded!\n" );
4759+ return - EINVAL ;
4760+ }
4761+
4762+ if (debugfs_alloc_v3_hw (hisi_hba , debugfs_dump_index )) {
4763+ dev_warn (dev , "failed to alloc memory\n" );
4764+ return - ENOMEM ;
4765+ }
4766+
4767+ do_div (timestamp , NSEC_PER_MSEC );
4768+ hisi_hba -> debugfs_timestamp [debugfs_dump_index ] = timestamp ;
4769+
4770+ debugfs_snapshot_prepare_v3_hw (hisi_hba );
4771+
4772+ debugfs_snapshot_global_reg_v3_hw (hisi_hba );
4773+ debugfs_snapshot_port_reg_v3_hw (hisi_hba );
4774+ debugfs_snapshot_axi_reg_v3_hw (hisi_hba );
4775+ debugfs_snapshot_ras_reg_v3_hw (hisi_hba );
4776+ debugfs_snapshot_cq_reg_v3_hw (hisi_hba );
4777+ debugfs_snapshot_dq_reg_v3_hw (hisi_hba );
4778+ debugfs_snapshot_itct_reg_v3_hw (hisi_hba );
4779+ debugfs_snapshot_iost_reg_v3_hw (hisi_hba );
4780+
4781+ debugfs_create_files_v3_hw (hisi_hba );
4782+
4783+ debugfs_snapshot_restore_v3_hw (hisi_hba );
4784+ hisi_hba -> debugfs_dump_index ++ ;
4785+
4786+ return 0 ;
4787+ }
4788+
47914789static void debugfs_phy_down_cnt_init_v3_hw (struct hisi_hba * hisi_hba )
47924790{
47934791 struct dentry * dir = debugfs_create_dir ("phy_down_cnt" ,
@@ -4865,10 +4863,15 @@ static void debugfs_bist_init_v3_hw(struct hisi_hba *hisi_hba)
48654863 hisi_hba -> debugfs_bist_linkrate = SAS_LINK_RATE_1_5_GBPS ;
48664864}
48674865
4866+ static void debugfs_exit_v3_hw (struct hisi_hba * hisi_hba )
4867+ {
4868+ debugfs_remove_recursive (hisi_hba -> debugfs_dir );
4869+ hisi_hba -> debugfs_dir = NULL ;
4870+ }
4871+
48684872static void debugfs_init_v3_hw (struct hisi_hba * hisi_hba )
48694873{
48704874 struct device * dev = hisi_hba -> dev ;
4871- int i ;
48724875
48734876 hisi_hba -> debugfs_dir = debugfs_create_dir (dev_name (dev ),
48744877 hisi_sas_debugfs_dir );
@@ -4885,19 +4888,6 @@ static void debugfs_init_v3_hw(struct hisi_hba *hisi_hba)
48854888
48864889 debugfs_phy_down_cnt_init_v3_hw (hisi_hba );
48874890 debugfs_fifo_init_v3_hw (hisi_hba );
4888-
4889- for (i = 0 ; i < hisi_sas_debugfs_dump_count ; i ++ ) {
4890- if (debugfs_alloc_v3_hw (hisi_hba , i )) {
4891- debugfs_remove_recursive (hisi_hba -> debugfs_dir );
4892- dev_dbg (dev , "failed to init debugfs!\n" );
4893- break ;
4894- }
4895- }
4896- }
4897-
4898- static void debugfs_exit_v3_hw (struct hisi_hba * hisi_hba )
4899- {
4900- debugfs_remove_recursive (hisi_hba -> debugfs_dir );
49014891}
49024892
49034893static int
0 commit comments