aie2_populate_range() takes mmap_read_lock() only around hmm_range_fault(). It keeps a single HMM_RANGE_DEFAULT_TIMEOUT deadline for the populate pass and retries -EBUSY until that deadline expires.
Use hmm_range_fault_unlocked_timeout() instead. The HMM helper now owns the mmap lock and refreshes mapp->range.notifier_seq for its internal retries. Pass the remaining jiffies from the existing deadline to HMM, while preserving the driver's existing outer loop for interval invalidation retries and for selecting the next invalid mapping. Keep returning -ETIME when the retry budget expires, matching the driver's existing timeout error convention. Signed-off-by: Stanislav Kinsburskii <[email protected]> --- drivers/accel/amdxdna/aie2_ctx.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/drivers/accel/amdxdna/aie2_ctx.c b/drivers/accel/amdxdna/aie2_ctx.c index e9fbd8c14364..412f812d7c2c 100644 --- a/drivers/accel/amdxdna/aie2_ctx.c +++ b/drivers/accel/amdxdna/aie2_ctx.c @@ -1031,22 +1031,11 @@ static int aie2_populate_range(struct amdxdna_gem_obj *abo) return -EFAULT; } - mapp->range.notifier_seq = mmu_interval_read_begin(&mapp->notifier); - mmap_read_lock(mm); - ret = hmm_range_fault(&mapp->range); - mmap_read_unlock(mm); + ret = hmm_range_fault_unlocked_timeout(&mapp->range, + max_t(long, timeout - jiffies, 1)); if (ret) { - if (time_after(jiffies, timeout)) { + if (ret == -EBUSY) ret = -ETIME; - goto put_mm; - } - - if (ret == -EBUSY) { - amdxdna_umap_put(mapp); - mmput(mm); - goto again; - } - goto put_mm; }
