Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/xe/vf: Defer fixups if migrated twice fast

If another VF migration happened during post-migration recovery,
then the current worker should be finished to allow the next
one start swiftly and cleanly.

Check for defer in two places: before fixups, and before
sending RESFIX_DONE.

Signed-off-by: Tomasz Lis <tomasz.lis@intel.com>
Reviewed-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20241104213449.1455694-6-tomasz.lis@intel.com
Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>

authored by

Tomasz Lis and committed by
Michal Wajdeczko
abd22020 4be3fca2

+25
+25
drivers/gpu/drm/xe/xe_sriov_vf.c
··· 158 158 } 159 159 160 160 /* 161 + * vf_post_migration_imminent - Check if post-restore recovery is coming. 162 + * @xe: the &xe_device struct instance 163 + * 164 + * Return: True if migration recovery worker will soon be running. Any worker currently 165 + * executing does not affect the result. 166 + */ 167 + static bool vf_post_migration_imminent(struct xe_device *xe) 168 + { 169 + return xe->sriov.vf.migration.gt_flags != 0 || 170 + work_pending(&xe->sriov.vf.migration.worker); 171 + } 172 + 173 + /* 161 174 * Notify all GuCs about resource fixups apply finished. 162 175 */ 163 176 static void vf_post_migration_notify_resfix_done(struct xe_device *xe) ··· 179 166 unsigned int id; 180 167 181 168 for_each_gt(gt, xe, id) { 169 + if (vf_post_migration_imminent(xe)) 170 + goto skip; 182 171 xe_gt_sriov_vf_notify_resfix_done(gt); 183 172 } 173 + return; 174 + 175 + skip: 176 + drm_dbg(&xe->drm, "another recovery imminent, skipping notifications\n"); 184 177 } 185 178 186 179 static void vf_post_migration_recovery(struct xe_device *xe) ··· 196 177 drm_dbg(&xe->drm, "migration recovery in progress\n"); 197 178 xe_pm_runtime_get(xe); 198 179 err = vf_post_migration_requery_guc(xe); 180 + if (vf_post_migration_imminent(xe)) 181 + goto defer; 199 182 if (unlikely(err)) 200 183 goto fail; 201 184 ··· 205 184 vf_post_migration_notify_resfix_done(xe); 206 185 xe_pm_runtime_put(xe); 207 186 drm_notice(&xe->drm, "migration recovery ended\n"); 187 + return; 188 + defer: 189 + xe_pm_runtime_put(xe); 190 + drm_dbg(&xe->drm, "migration recovery deferred\n"); 208 191 return; 209 192 fail: 210 193 xe_pm_runtime_put(xe);