[PATCH] drm/i915/gt: Handle errors for i915_gem_object_trylock

From: Jiasheng Jiang
Date: Wed Mar 02 2022 - 01:20:02 EST


As the potential failure of the i915_gem_object_trylock(),
it should be better to check it and return error if fails.

Fixes: 94ce0d65076c ("drm/i915/gt: Setup a default migration context on the GT")
Signed-off-by: Jiasheng Jiang <jiasheng@xxxxxxxxxxx>
---
drivers/gpu/drm/i915/gt/selftest_migrate.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/gt/selftest_migrate.c b/drivers/gpu/drm/i915/gt/selftest_migrate.c
index fa4293d2944f..79c6c68f7316 100644
--- a/drivers/gpu/drm/i915/gt/selftest_migrate.c
+++ b/drivers/gpu/drm/i915/gt/selftest_migrate.c
@@ -465,7 +465,11 @@ create_init_lmem_internal(struct intel_gt *gt, size_t sz, bool try_lmem)
return obj;
}

- i915_gem_object_trylock(obj, NULL);
+ if (!i915_gem_object_trylock(obj, NULL)) {
+ i915_gem_object_put(obj);
+ return ERR_PTR(-EBUSY);
+ }
+
err = i915_gem_object_pin_pages(obj);
if (err) {
i915_gem_object_unlock(obj);
--
2.25.1