@@ -3560,6 +3560,11 @@ debugfs_to_reg_name_v3_hw(int off, int base_off,
3560
3560
return NULL ;
3561
3561
}
3562
3562
3563
+ static bool debugfs_dump_is_generated_v3_hw (void * p )
3564
+ {
3565
+ return p ? true : false;
3566
+ }
3567
+
3563
3568
static void debugfs_print_reg_v3_hw (u32 * regs_val , struct seq_file * s ,
3564
3569
const struct hisi_sas_debugfs_reg * reg )
3565
3570
{
@@ -3585,6 +3590,9 @@ static int debugfs_global_v3_hw_show(struct seq_file *s, void *p)
3585
3590
{
3586
3591
struct hisi_sas_debugfs_regs * global = s -> private ;
3587
3592
3593
+ if (!debugfs_dump_is_generated_v3_hw (global -> data ))
3594
+ return - EPERM ;
3595
+
3588
3596
debugfs_print_reg_v3_hw (global -> data , s ,
3589
3597
& debugfs_global_reg );
3590
3598
@@ -3596,6 +3604,9 @@ static int debugfs_axi_v3_hw_show(struct seq_file *s, void *p)
3596
3604
{
3597
3605
struct hisi_sas_debugfs_regs * axi = s -> private ;
3598
3606
3607
+ if (!debugfs_dump_is_generated_v3_hw (axi -> data ))
3608
+ return - EPERM ;
3609
+
3599
3610
debugfs_print_reg_v3_hw (axi -> data , s ,
3600
3611
& debugfs_axi_reg );
3601
3612
@@ -3607,6 +3618,9 @@ static int debugfs_ras_v3_hw_show(struct seq_file *s, void *p)
3607
3618
{
3608
3619
struct hisi_sas_debugfs_regs * ras = s -> private ;
3609
3620
3621
+ if (!debugfs_dump_is_generated_v3_hw (ras -> data ))
3622
+ return - EPERM ;
3623
+
3610
3624
debugfs_print_reg_v3_hw (ras -> data , s ,
3611
3625
& debugfs_ras_reg );
3612
3626
@@ -3619,6 +3633,9 @@ static int debugfs_port_v3_hw_show(struct seq_file *s, void *p)
3619
3633
struct hisi_sas_debugfs_port * port = s -> private ;
3620
3634
const struct hisi_sas_debugfs_reg * reg_port = & debugfs_port_reg ;
3621
3635
3636
+ if (!debugfs_dump_is_generated_v3_hw (port -> data ))
3637
+ return - EPERM ;
3638
+
3622
3639
debugfs_print_reg_v3_hw (port -> data , s , reg_port );
3623
3640
3624
3641
return 0 ;
@@ -3674,6 +3691,9 @@ static int debugfs_cq_v3_hw_show(struct seq_file *s, void *p)
3674
3691
struct hisi_sas_debugfs_cq * debugfs_cq = s -> private ;
3675
3692
int slot ;
3676
3693
3694
+ if (!debugfs_dump_is_generated_v3_hw (debugfs_cq -> complete_hdr ))
3695
+ return - EPERM ;
3696
+
3677
3697
for (slot = 0 ; slot < HISI_SAS_QUEUE_SLOTS ; slot ++ )
3678
3698
debugfs_cq_show_slot_v3_hw (s , slot , debugfs_cq );
3679
3699
@@ -3695,8 +3715,12 @@ static void debugfs_dq_show_slot_v3_hw(struct seq_file *s, int slot,
3695
3715
3696
3716
static int debugfs_dq_v3_hw_show (struct seq_file * s , void * p )
3697
3717
{
3718
+ struct hisi_sas_debugfs_dq * debugfs_dq = s -> private ;
3698
3719
int slot ;
3699
3720
3721
+ if (!debugfs_dump_is_generated_v3_hw (debugfs_dq -> hdr ))
3722
+ return - EPERM ;
3723
+
3700
3724
for (slot = 0 ; slot < HISI_SAS_QUEUE_SLOTS ; slot ++ )
3701
3725
debugfs_dq_show_slot_v3_hw (s , slot , s -> private );
3702
3726
@@ -3710,6 +3734,9 @@ static int debugfs_iost_v3_hw_show(struct seq_file *s, void *p)
3710
3734
struct hisi_sas_iost * iost = debugfs_iost -> iost ;
3711
3735
int i , max_command_entries = HISI_SAS_MAX_COMMANDS ;
3712
3736
3737
+ if (!debugfs_dump_is_generated_v3_hw (iost ))
3738
+ return - EPERM ;
3739
+
3713
3740
for (i = 0 ; i < max_command_entries ; i ++ , iost ++ ) {
3714
3741
__le64 * data = & iost -> qw0 ;
3715
3742
@@ -3729,6 +3756,9 @@ static int debugfs_iost_cache_v3_hw_show(struct seq_file *s, void *p)
3729
3756
int i , tab_idx ;
3730
3757
__le64 * iost ;
3731
3758
3759
+ if (!debugfs_dump_is_generated_v3_hw (iost_cache ))
3760
+ return - EPERM ;
3761
+
3732
3762
for (i = 0 ; i < HISI_SAS_IOST_ITCT_CACHE_NUM ; i ++ , iost_cache ++ ) {
3733
3763
/*
3734
3764
* Data struct of IOST cache:
@@ -3752,6 +3782,9 @@ static int debugfs_itct_v3_hw_show(struct seq_file *s, void *p)
3752
3782
struct hisi_sas_debugfs_itct * debugfs_itct = s -> private ;
3753
3783
struct hisi_sas_itct * itct = debugfs_itct -> itct ;
3754
3784
3785
+ if (!debugfs_dump_is_generated_v3_hw (itct ))
3786
+ return - EPERM ;
3787
+
3755
3788
for (i = 0 ; i < HISI_SAS_MAX_ITCT_ENTRIES ; i ++ , itct ++ ) {
3756
3789
__le64 * data = & itct -> qw0 ;
3757
3790
@@ -3771,6 +3804,9 @@ static int debugfs_itct_cache_v3_hw_show(struct seq_file *s, void *p)
3771
3804
int i , tab_idx ;
3772
3805
__le64 * itct ;
3773
3806
3807
+ if (!debugfs_dump_is_generated_v3_hw (itct_cache ))
3808
+ return - EPERM ;
3809
+
3774
3810
for (i = 0 ; i < HISI_SAS_IOST_ITCT_CACHE_NUM ; i ++ , itct_cache ++ ) {
3775
3811
/*
3776
3812
* Data struct of ITCT cache:
@@ -3788,28 +3824,27 @@ static int debugfs_itct_cache_v3_hw_show(struct seq_file *s, void *p)
3788
3824
}
3789
3825
DEFINE_SHOW_ATTRIBUTE (debugfs_itct_cache_v3_hw );
3790
3826
3791
- static void debugfs_create_files_v3_hw (struct hisi_hba * hisi_hba )
3827
+ static void debugfs_create_files_v3_hw (struct hisi_hba * hisi_hba , int index )
3792
3828
{
3793
3829
u64 * debugfs_timestamp ;
3794
- int dump_index = hisi_hba -> debugfs_dump_index ;
3795
3830
struct dentry * dump_dentry ;
3796
3831
struct dentry * dentry ;
3797
3832
char name [256 ];
3798
3833
int p ;
3799
3834
int c ;
3800
3835
int d ;
3801
3836
3802
- snprintf (name , 256 , "%d" , dump_index );
3837
+ snprintf (name , 256 , "%d" , index );
3803
3838
3804
3839
dump_dentry = debugfs_create_dir (name , hisi_hba -> debugfs_dump_dentry );
3805
3840
3806
- debugfs_timestamp = & hisi_hba -> debugfs_timestamp [dump_index ];
3841
+ debugfs_timestamp = & hisi_hba -> debugfs_timestamp [index ];
3807
3842
3808
3843
debugfs_create_u64 ("timestamp" , 0400 , dump_dentry ,
3809
3844
debugfs_timestamp );
3810
3845
3811
3846
debugfs_create_file ("global" , 0400 , dump_dentry ,
3812
- & hisi_hba -> debugfs_regs [dump_index ][DEBUGFS_GLOBAL ],
3847
+ & hisi_hba -> debugfs_regs [index ][DEBUGFS_GLOBAL ],
3813
3848
& debugfs_global_v3_hw_fops );
3814
3849
3815
3850
/* Create port dir and files */
@@ -3818,7 +3853,7 @@ static void debugfs_create_files_v3_hw(struct hisi_hba *hisi_hba)
3818
3853
snprintf (name , 256 , "%d" , p );
3819
3854
3820
3855
debugfs_create_file (name , 0400 , dentry ,
3821
- & hisi_hba -> debugfs_port_reg [dump_index ][p ],
3856
+ & hisi_hba -> debugfs_port_reg [index ][p ],
3822
3857
& debugfs_port_v3_hw_fops );
3823
3858
}
3824
3859
@@ -3828,7 +3863,7 @@ static void debugfs_create_files_v3_hw(struct hisi_hba *hisi_hba)
3828
3863
snprintf (name , 256 , "%d" , c );
3829
3864
3830
3865
debugfs_create_file (name , 0400 , dentry ,
3831
- & hisi_hba -> debugfs_cq [dump_index ][c ],
3866
+ & hisi_hba -> debugfs_cq [index ][c ],
3832
3867
& debugfs_cq_v3_hw_fops );
3833
3868
}
3834
3869
@@ -3838,32 +3873,32 @@ static void debugfs_create_files_v3_hw(struct hisi_hba *hisi_hba)
3838
3873
snprintf (name , 256 , "%d" , d );
3839
3874
3840
3875
debugfs_create_file (name , 0400 , dentry ,
3841
- & hisi_hba -> debugfs_dq [dump_index ][d ],
3876
+ & hisi_hba -> debugfs_dq [index ][d ],
3842
3877
& debugfs_dq_v3_hw_fops );
3843
3878
}
3844
3879
3845
3880
debugfs_create_file ("iost" , 0400 , dump_dentry ,
3846
- & hisi_hba -> debugfs_iost [dump_index ],
3881
+ & hisi_hba -> debugfs_iost [index ],
3847
3882
& debugfs_iost_v3_hw_fops );
3848
3883
3849
3884
debugfs_create_file ("iost_cache" , 0400 , dump_dentry ,
3850
- & hisi_hba -> debugfs_iost_cache [dump_index ],
3885
+ & hisi_hba -> debugfs_iost_cache [index ],
3851
3886
& debugfs_iost_cache_v3_hw_fops );
3852
3887
3853
3888
debugfs_create_file ("itct" , 0400 , dump_dentry ,
3854
- & hisi_hba -> debugfs_itct [dump_index ],
3889
+ & hisi_hba -> debugfs_itct [index ],
3855
3890
& debugfs_itct_v3_hw_fops );
3856
3891
3857
3892
debugfs_create_file ("itct_cache" , 0400 , dump_dentry ,
3858
- & hisi_hba -> debugfs_itct_cache [dump_index ],
3893
+ & hisi_hba -> debugfs_itct_cache [index ],
3859
3894
& debugfs_itct_cache_v3_hw_fops );
3860
3895
3861
3896
debugfs_create_file ("axi" , 0400 , dump_dentry ,
3862
- & hisi_hba -> debugfs_regs [dump_index ][DEBUGFS_AXI ],
3897
+ & hisi_hba -> debugfs_regs [index ][DEBUGFS_AXI ],
3863
3898
& debugfs_axi_v3_hw_fops );
3864
3899
3865
3900
debugfs_create_file ("ras" , 0400 , dump_dentry ,
3866
- & hisi_hba -> debugfs_regs [dump_index ][DEBUGFS_RAS ],
3901
+ & hisi_hba -> debugfs_regs [index ][DEBUGFS_RAS ],
3867
3902
& debugfs_ras_v3_hw_fops );
3868
3903
}
3869
3904
@@ -4645,22 +4680,34 @@ static void debugfs_release_v3_hw(struct hisi_hba *hisi_hba, int dump_index)
4645
4680
int i ;
4646
4681
4647
4682
devm_kfree (dev , hisi_hba -> debugfs_iost_cache [dump_index ].cache );
4683
+ hisi_hba -> debugfs_iost_cache [dump_index ].cache = NULL ;
4648
4684
devm_kfree (dev , hisi_hba -> debugfs_itct_cache [dump_index ].cache );
4685
+ hisi_hba -> debugfs_itct_cache [dump_index ].cache = NULL ;
4649
4686
devm_kfree (dev , hisi_hba -> debugfs_iost [dump_index ].iost );
4687
+ hisi_hba -> debugfs_iost [dump_index ].iost = NULL ;
4650
4688
devm_kfree (dev , hisi_hba -> debugfs_itct [dump_index ].itct );
4689
+ hisi_hba -> debugfs_itct [dump_index ].itct = NULL ;
4651
4690
4652
- for (i = 0 ; i < hisi_hba -> queue_count ; i ++ )
4691
+ for (i = 0 ; i < hisi_hba -> queue_count ; i ++ ) {
4653
4692
devm_kfree (dev , hisi_hba -> debugfs_dq [dump_index ][i ].hdr );
4693
+ hisi_hba -> debugfs_dq [dump_index ][i ].hdr = NULL ;
4694
+ }
4654
4695
4655
- for (i = 0 ; i < hisi_hba -> queue_count ; i ++ )
4696
+ for (i = 0 ; i < hisi_hba -> queue_count ; i ++ ) {
4656
4697
devm_kfree (dev ,
4657
4698
hisi_hba -> debugfs_cq [dump_index ][i ].complete_hdr );
4699
+ hisi_hba -> debugfs_cq [dump_index ][i ].complete_hdr = NULL ;
4700
+ }
4658
4701
4659
- for (i = 0 ; i < DEBUGFS_REGS_NUM ; i ++ )
4702
+ for (i = 0 ; i < DEBUGFS_REGS_NUM ; i ++ ) {
4660
4703
devm_kfree (dev , hisi_hba -> debugfs_regs [dump_index ][i ].data );
4704
+ hisi_hba -> debugfs_regs [dump_index ][i ].data = NULL ;
4705
+ }
4661
4706
4662
- for (i = 0 ; i < hisi_hba -> n_phy ; i ++ )
4707
+ for (i = 0 ; i < hisi_hba -> n_phy ; i ++ ) {
4663
4708
devm_kfree (dev , hisi_hba -> debugfs_port_reg [dump_index ][i ].data );
4709
+ hisi_hba -> debugfs_port_reg [dump_index ][i ].data = NULL ;
4710
+ }
4664
4711
}
4665
4712
4666
4713
static const struct hisi_sas_debugfs_reg * debugfs_reg_array_v3_hw [DEBUGFS_REGS_NUM ] = {
@@ -4787,8 +4834,6 @@ static int debugfs_snapshot_regs_v3_hw(struct hisi_hba *hisi_hba)
4787
4834
debugfs_snapshot_itct_reg_v3_hw (hisi_hba );
4788
4835
debugfs_snapshot_iost_reg_v3_hw (hisi_hba );
4789
4836
4790
- debugfs_create_files_v3_hw (hisi_hba );
4791
-
4792
4837
debugfs_snapshot_restore_v3_hw (hisi_hba );
4793
4838
hisi_hba -> debugfs_dump_index ++ ;
4794
4839
@@ -4872,6 +4917,17 @@ static void debugfs_bist_init_v3_hw(struct hisi_hba *hisi_hba)
4872
4917
hisi_hba -> debugfs_bist_linkrate = SAS_LINK_RATE_1_5_GBPS ;
4873
4918
}
4874
4919
4920
+ static void debugfs_dump_init_v3_hw (struct hisi_hba * hisi_hba )
4921
+ {
4922
+ int i ;
4923
+
4924
+ hisi_hba -> debugfs_dump_dentry =
4925
+ debugfs_create_dir ("dump" , hisi_hba -> debugfs_dir );
4926
+
4927
+ for (i = 0 ; i < hisi_sas_debugfs_dump_count ; i ++ )
4928
+ debugfs_create_files_v3_hw (hisi_hba , i );
4929
+ }
4930
+
4875
4931
static void debugfs_exit_v3_hw (struct hisi_hba * hisi_hba )
4876
4932
{
4877
4933
debugfs_remove_recursive (hisi_hba -> debugfs_dir );
@@ -4892,8 +4948,7 @@ static void debugfs_init_v3_hw(struct hisi_hba *hisi_hba)
4892
4948
/* create bist structures */
4893
4949
debugfs_bist_init_v3_hw (hisi_hba );
4894
4950
4895
- hisi_hba -> debugfs_dump_dentry =
4896
- debugfs_create_dir ("dump" , hisi_hba -> debugfs_dir );
4951
+ debugfs_dump_init_v3_hw (hisi_hba );
4897
4952
4898
4953
debugfs_phy_down_cnt_init_v3_hw (hisi_hba );
4899
4954
debugfs_fifo_init_v3_hw (hisi_hba );
0 commit comments