@@ -156,12 +156,28 @@ void i40e_vc_notify_vf_reset(struct i40e_vf *vf)
156
156
* i40e_vc_disable_vf
157
157
* @vf: pointer to the VF info
158
158
*
159
- * Disable the VF through a SW reset
159
+ * Disable the VF through a SW reset.
160
160
**/
161
161
static inline void i40e_vc_disable_vf (struct i40e_vf * vf )
162
162
{
163
+ int i ;
164
+
163
165
i40e_vc_notify_vf_reset (vf );
164
- i40e_reset_vf (vf , false);
166
+
167
+ /* We want to ensure that an actual reset occurs initiated after this
168
+ * function was called. However, we do not want to wait forever, so
169
+ * we'll give a reasonable time and print a message if we failed to
170
+ * ensure a reset.
171
+ */
172
+ for (i = 0 ; i < 20 ; i ++ ) {
173
+ if (i40e_reset_vf (vf , false))
174
+ return ;
175
+ usleep_range (10000 , 20000 );
176
+ }
177
+
178
+ dev_warn (& vf -> pf -> pdev -> dev ,
179
+ "Failed to initiate reset for VF %d after 200 milliseconds\n" ,
180
+ vf -> vf_id );
165
181
}
166
182
167
183
/**
@@ -1051,19 +1067,21 @@ static void i40e_cleanup_reset_vf(struct i40e_vf *vf)
1051
1067
* @vf: pointer to the VF structure
1052
1068
* @flr: VFLR was issued or not
1053
1069
*
1054
- * reset the VF
1070
+ * Returns true if the VF is reset, false otherwise.
1055
1071
**/
1056
- void i40e_reset_vf (struct i40e_vf * vf , bool flr )
1072
+ bool i40e_reset_vf (struct i40e_vf * vf , bool flr )
1057
1073
{
1058
1074
struct i40e_pf * pf = vf -> pf ;
1059
1075
struct i40e_hw * hw = & pf -> hw ;
1060
1076
bool rsd = false;
1061
1077
u32 reg ;
1062
1078
int i ;
1063
1079
1064
- /* If VFs have been disabled, there is no need to reset */
1080
+ /* If the VFs have been disabled, this means something else is
1081
+ * resetting the VF, so we shouldn't continue.
1082
+ */
1065
1083
if (test_and_set_bit (__I40E_VF_DISABLE , pf -> state ))
1066
- return ;
1084
+ return false ;
1067
1085
1068
1086
i40e_trigger_vf_reset (vf , flr );
1069
1087
@@ -1100,6 +1118,8 @@ void i40e_reset_vf(struct i40e_vf *vf, bool flr)
1100
1118
1101
1119
i40e_flush (hw );
1102
1120
clear_bit (__I40E_VF_DISABLE , pf -> state );
1121
+
1122
+ return true;
1103
1123
}
1104
1124
1105
1125
/**
@@ -1111,8 +1131,10 @@ void i40e_reset_vf(struct i40e_vf *vf, bool flr)
1111
1131
* VF, then do all the waiting in one chunk, and finally finish restoring each
1112
1132
* VF after the wait. This is useful during PF routines which need to reset
1113
1133
* all VFs, as otherwise it must perform these resets in a serialized fashion.
1134
+ *
1135
+ * Returns true if any VFs were reset, and false otherwise.
1114
1136
**/
1115
- void i40e_reset_all_vfs (struct i40e_pf * pf , bool flr )
1137
+ bool i40e_reset_all_vfs (struct i40e_pf * pf , bool flr )
1116
1138
{
1117
1139
struct i40e_hw * hw = & pf -> hw ;
1118
1140
struct i40e_vf * vf ;
@@ -1121,11 +1143,11 @@ void i40e_reset_all_vfs(struct i40e_pf *pf, bool flr)
1121
1143
1122
1144
/* If we don't have any VFs, then there is nothing to reset */
1123
1145
if (!pf -> num_alloc_vfs )
1124
- return ;
1146
+ return false ;
1125
1147
1126
1148
/* If VFs have been disabled, there is no need to reset */
1127
1149
if (test_and_set_bit (__I40E_VF_DISABLE , pf -> state ))
1128
- return ;
1150
+ return false ;
1129
1151
1130
1152
/* Begin reset on all VFs at once */
1131
1153
for (v = 0 ; v < pf -> num_alloc_vfs ; v ++ )
@@ -1200,6 +1222,8 @@ void i40e_reset_all_vfs(struct i40e_pf *pf, bool flr)
1200
1222
1201
1223
i40e_flush (hw );
1202
1224
clear_bit (__I40E_VF_DISABLE , pf -> state );
1225
+
1226
+ return true;
1203
1227
}
1204
1228
1205
1229
/**
0 commit comments