One correction to my previous mail before it confuses anyone: in the v4 respin I ended up holding the drm_dev_enter() section across the whole per-VMA migration loop, including the svm_migrate_copy_done() fence wait — not just the submit as I described. That also prevents sched entity teardown from slipping in between submit and wait, which is the rest of the race window. The AMDGPU_FENCE_JIFFIES_TIMEOUT bound is then what keeps drm_dev_unplug() from blocking on our exit for more than ~500ms when the device dies electrically before removal runs.
Verified that shape on the MI50/TB3 repro: drain completes, removal finishes, no warnings. Olivier
