@@ -930,68 +930,63 @@ static void cpt_rxc_teardown(struct rvu *rvu, int blkaddr)
930
930
dev_warn (rvu -> dev , "Poll for RXC zombie count hits hard loop counter\n" );
931
931
}
932
932
933
- #define INPROG_INFLIGHT (reg ) ((reg) & 0x1FF)
934
- #define INPROG_GRB_PARTIAL (reg ) ((reg) & BIT_ULL(31))
935
- #define INPROG_GRB (reg ) (((reg) >> 32) & 0xFF)
936
- #define INPROG_GWB (reg ) (((reg) >> 40) & 0xFF)
933
+ #define INFLIGHT GENMASK_ULL(8, 0)
934
+ #define GRB_CNT GENMASK_ULL(39, 32)
935
+ #define GWB_CNT GENMASK_ULL(47, 40)
936
+ #define XQ_XOR GENMASK_ULL(63, 63)
937
+ #define DQPTR GENMASK_ULL(19, 0)
938
+ #define NQPTR GENMASK_ULL(51, 32)
937
939
938
940
static void cpt_lf_disable_iqueue (struct rvu * rvu , int blkaddr , int slot )
939
941
{
940
- int i = 0 , hard_lp_ctr = 100000 ;
941
- u64 inprog , grp_ptr ;
942
- u16 nq_ptr , dq_ptr ;
942
+ int timeout = 1000000 ;
943
+ u64 inprog , inst_ptr ;
944
+ u64 qsize , pending ;
945
+ int i = 0 ;
943
946
944
947
/* Disable instructions enqueuing */
945
948
rvu_write64 (rvu , blkaddr , CPT_AF_BAR2_ALIASX (slot , CPT_LF_CTL ), 0x0 );
946
949
947
- /* Disable executions in the LF's queue */
948
950
inprog = rvu_read64 (rvu , blkaddr ,
949
951
CPT_AF_BAR2_ALIASX (slot , CPT_LF_INPROG ));
950
- inprog &= ~ BIT_ULL (16 );
952
+ inprog |= BIT_ULL (16 );
951
953
rvu_write64 (rvu , blkaddr ,
952
954
CPT_AF_BAR2_ALIASX (slot , CPT_LF_INPROG ), inprog );
953
955
954
- /* Wait for CPT queue to become execution-quiescent */
956
+ qsize = rvu_read64 (rvu , blkaddr ,
957
+ CPT_AF_BAR2_ALIASX (slot , CPT_LF_Q_SIZE )) & 0x7FFF ;
955
958
do {
956
- inprog = rvu_read64 (rvu , blkaddr ,
957
- CPT_AF_BAR2_ALIASX (slot , CPT_LF_INPROG ));
958
- if (INPROG_GRB_PARTIAL (inprog )) {
959
- i = 0 ;
960
- hard_lp_ctr -- ;
961
- } else {
962
- i ++ ;
963
- }
964
-
965
- grp_ptr = rvu_read64 (rvu , blkaddr ,
966
- CPT_AF_BAR2_ALIASX (slot ,
967
- CPT_LF_Q_GRP_PTR ));
968
- nq_ptr = (grp_ptr >> 32 ) & 0x7FFF ;
969
- dq_ptr = grp_ptr & 0x7FFF ;
970
-
971
- } while (hard_lp_ctr && (i < 10 ) && (nq_ptr != dq_ptr ));
959
+ inst_ptr = rvu_read64 (rvu , blkaddr ,
960
+ CPT_AF_BAR2_ALIASX (slot , CPT_LF_Q_INST_PTR ));
961
+ pending = (FIELD_GET (XQ_XOR , inst_ptr ) * qsize * 40 ) +
962
+ FIELD_GET (NQPTR , inst_ptr ) -
963
+ FIELD_GET (DQPTR , inst_ptr );
964
+ udelay (1 );
965
+ timeout -- ;
966
+ } while ((pending != 0 ) && (timeout != 0 ));
972
967
973
- if (hard_lp_ctr == 0 )
974
- dev_warn (rvu -> dev , "CPT FLR hits hard loop counter \n" );
968
+ if (timeout == 0 )
969
+ dev_warn (rvu -> dev , "TIMEOUT: CPT poll on pending instructions \n" );
975
970
976
- i = 0 ;
977
- hard_lp_ctr = 100000 ;
971
+ timeout = 1000000 ;
972
+ /* Wait for CPT queue to become execution-quiescent */
978
973
do {
979
974
inprog = rvu_read64 (rvu , blkaddr ,
980
975
CPT_AF_BAR2_ALIASX (slot , CPT_LF_INPROG ));
981
976
982
- if ((INPROG_INFLIGHT (inprog ) == 0 ) &&
983
- (INPROG_GWB (inprog ) < 40 ) &&
984
- ((INPROG_GRB (inprog ) == 0 ) ||
985
- (INPROG_GRB ((inprog )) == 40 ))) {
977
+ if ((FIELD_GET (INFLIGHT , inprog ) == 0 ) &&
978
+ (FIELD_GET (GRB_CNT , inprog ) == 0 )) {
986
979
i ++ ;
987
980
} else {
988
981
i = 0 ;
989
- hard_lp_ctr -- ;
982
+ timeout -- ;
990
983
}
991
- } while (hard_lp_ctr && (i < 10 ));
984
+ } while (( timeout != 0 ) && (i < 10 ));
992
985
993
- if (hard_lp_ctr == 0 )
994
- dev_warn (rvu -> dev , "CPT FLR hits hard loop counter\n" );
986
+ if (timeout == 0 )
987
+ dev_warn (rvu -> dev , "TIMEOUT: CPT poll on inflight count\n" );
988
+ /* Wait for 2 us to flush all queue writes to memory */
989
+ udelay (2 );
995
990
}
996
991
997
992
int rvu_cpt_lf_teardown (struct rvu * rvu , u16 pcifunc , int blkaddr , int lf , int slot )
@@ -1001,18 +996,15 @@ int rvu_cpt_lf_teardown(struct rvu *rvu, u16 pcifunc, int blkaddr, int lf, int s
1001
996
if (is_cpt_pf (rvu , pcifunc ) || is_cpt_vf (rvu , pcifunc ))
1002
997
cpt_rxc_teardown (rvu , blkaddr );
1003
998
999
+ mutex_lock (& rvu -> alias_lock );
1004
1000
/* Enable BAR2 ALIAS for this pcifunc. */
1005
1001
reg = BIT_ULL (16 ) | pcifunc ;
1006
- rvu_write64 (rvu , blkaddr , CPT_AF_BAR2_SEL , reg );
1002
+ rvu_bar2_sel_write64 (rvu , blkaddr , CPT_AF_BAR2_SEL , reg );
1007
1003
1008
1004
cpt_lf_disable_iqueue (rvu , blkaddr , slot );
1009
1005
1010
- /* Set group drop to help clear out hardware */
1011
- reg = rvu_read64 (rvu , blkaddr , CPT_AF_BAR2_ALIASX (slot , CPT_LF_INPROG ));
1012
- reg |= BIT_ULL (17 );
1013
- rvu_write64 (rvu , blkaddr , CPT_AF_BAR2_ALIASX (slot , CPT_LF_INPROG ), reg );
1014
-
1015
- rvu_write64 (rvu , blkaddr , CPT_AF_BAR2_SEL , 0 );
1006
+ rvu_bar2_sel_write64 (rvu , blkaddr , CPT_AF_BAR2_SEL , 0 );
1007
+ mutex_unlock (& rvu -> alias_lock );
1016
1008
1017
1009
return 0 ;
1018
1010
}
@@ -1147,7 +1139,7 @@ int rvu_cpt_ctx_flush(struct rvu *rvu, u16 pcifunc)
1147
1139
1148
1140
/* Enable BAR2 ALIAS for this pcifunc. */
1149
1141
reg = BIT_ULL (16 ) | pcifunc ;
1150
- rvu_write64 (rvu , blkaddr , CPT_AF_BAR2_SEL , reg );
1142
+ rvu_bar2_sel_write64 (rvu , blkaddr , CPT_AF_BAR2_SEL , reg );
1151
1143
1152
1144
for (i = 0 ; i < max_ctx_entries ; i ++ ) {
1153
1145
cam_data = rvu_read64 (rvu , blkaddr , CPT_AF_CTX_CAM_DATA (i ));
@@ -1160,7 +1152,7 @@ int rvu_cpt_ctx_flush(struct rvu *rvu, u16 pcifunc)
1160
1152
reg );
1161
1153
}
1162
1154
}
1163
- rvu_write64 (rvu , blkaddr , CPT_AF_BAR2_SEL , 0 );
1155
+ rvu_bar2_sel_write64 (rvu , blkaddr , CPT_AF_BAR2_SEL , 0 );
1164
1156
1165
1157
unlock :
1166
1158
mutex_unlock (& rvu -> rsrc_lock );
0 commit comments