[Intel-gfx] [PATCH] drm/i915: Fix documentation for intel_uncore_forcewake_put__locked

2022-12-07 Thread Miaoqian Lin
intel_uncore_forcewake_put__locked() is used to release a reference.

Fixes: a6111f7b6604 ("drm/i915: Reduce locking in execlist command submission")
Signed-off-by: Miaoqian Lin 
---
 drivers/gpu/drm/i915/intel_uncore.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_uncore.c 
b/drivers/gpu/drm/i915/intel_uncore.c
index 5cd423c7b646..acb40543eb32 100644
--- a/drivers/gpu/drm/i915/intel_uncore.c
+++ b/drivers/gpu/drm/i915/intel_uncore.c
@@ -819,9 +819,9 @@ void intel_uncore_forcewake_flush(struct intel_uncore 
*uncore,
 }
 
 /**
- * intel_uncore_forcewake_put__locked - grab forcewake domain references
+ * intel_uncore_forcewake_put__locked - release forcewake domain references
  * @uncore: the intel_uncore structure
- * @fw_domains: forcewake domains to get reference on
+ * @fw_domains: forcewake domains to put references
  *
  * See intel_uncore_forcewake_put(). This variant places the onus
  * on the caller to explicitly handle the dev_priv->uncore.lock spinlock.
-- 
2.25.1



[Intel-gfx] [PATCH v2] drm/i915/selftests: Fix NULL vs IS_ERR checking for kernel_context

2022-01-24 Thread Miaoqian Lin
Since i915_gem_create_context() function return error pointers,
the kernel_context() function does not return null, It returns error
pointers too. Using IS_ERR() to check the return value to fix this.

Signed-off-by: Miaoqian Lin 
---
Changes in v2:
- clean up unneeded initialization of err.
---
 drivers/gpu/drm/i915/gt/selftest_execlists.c | 43 ++--
 1 file changed, 30 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/selftest_execlists.c 
b/drivers/gpu/drm/i915/gt/selftest_execlists.c
index b367ecfa42de..0d453ddcede4 100644
--- a/drivers/gpu/drm/i915/gt/selftest_execlists.c
+++ b/drivers/gpu/drm/i915/gt/selftest_execlists.c
@@ -1531,7 +1531,7 @@ static int live_busywait_preempt(void *arg)
struct drm_i915_gem_object *obj;
struct i915_vma *vma;
enum intel_engine_id id;
-   int err = -ENOMEM;
+   int err;
u32 *map;
 
/*
@@ -1540,13 +1540,16 @@ static int live_busywait_preempt(void *arg)
 */
 
ctx_hi = kernel_context(gt->i915, NULL);
-   if (!ctx_hi)
-   return -ENOMEM;
+   if (IS_ERR(ctx_hi))
+   return IS_ERR(ctx_hi);
+
ctx_hi->sched.priority = I915_CONTEXT_MAX_USER_PRIORITY;
 
ctx_lo = kernel_context(gt->i915, NULL);
-   if (!ctx_lo)
+   if (IS_ERR(ctx_lo)) {
+   err = PTR_ERR(ctx_lo);
goto err_ctx_hi;
+   }
ctx_lo->sched.priority = I915_CONTEXT_MIN_USER_PRIORITY;
 
obj = i915_gem_object_create_internal(gt->i915, PAGE_SIZE);
@@ -1742,13 +1745,17 @@ static int live_preempt(void *arg)
goto err_spin_hi;
 
ctx_hi = kernel_context(gt->i915, NULL);
-   if (!ctx_hi)
+   if (IS_ERR(ctx_hi)) {
+   err = PTR_ERR(ctx_hi);
goto err_spin_lo;
+   }
ctx_hi->sched.priority = I915_CONTEXT_MAX_USER_PRIORITY;
 
ctx_lo = kernel_context(gt->i915, NULL);
-   if (!ctx_lo)
+   if (IS_ERR(ctx_lo)) {
+   err = PTR_ERR(ctx_lo);
goto err_ctx_hi;
+   }
ctx_lo->sched.priority = I915_CONTEXT_MIN_USER_PRIORITY;
 
for_each_engine(engine, gt, id) {
@@ -1834,12 +1841,16 @@ static int live_late_preempt(void *arg)
goto err_spin_hi;
 
ctx_hi = kernel_context(gt->i915, NULL);
-   if (!ctx_hi)
+   if (IS_ERR(ctx_hi)) {
+   err = PTR_ERR(ctx_hi);
goto err_spin_lo;
+   }
 
ctx_lo = kernel_context(gt->i915, NULL);
-   if (!ctx_lo)
+   if (IS_ERR(ctx_lo)) {
+   err = PTR_ERR(ctx_lo);
goto err_ctx_hi;
+   }
 
/* Make sure ctx_lo stays before ctx_hi until we trigger preemption. */
ctx_lo->sched.priority = 1;
@@ -1928,8 +1939,8 @@ struct preempt_client {
 static int preempt_client_init(struct intel_gt *gt, struct preempt_client *c)
 {
c->ctx = kernel_context(gt->i915, NULL);
-   if (!c->ctx)
-   return -ENOMEM;
+   if (IS_ERR(c->ctx))
+   return PTR_ERR(c->ctx);
 
if (igt_spinner_init(>spin, gt))
goto err_ctx;
@@ -3385,13 +3396,17 @@ static int live_preempt_timeout(void *arg)
return -ENOMEM;
 
ctx_hi = kernel_context(gt->i915, NULL);
-   if (!ctx_hi)
+   if (IS_ERR(ctx_hi)) {
+   err = PTR_ERR(ctx_hi);
goto err_spin_lo;
+   }
ctx_hi->sched.priority = I915_CONTEXT_MAX_USER_PRIORITY;
 
ctx_lo = kernel_context(gt->i915, NULL);
-   if (!ctx_lo)
+   if (IS_ERR(ctx_lo)) {
+   err = PTR_ERR(ctx_lo);
goto err_ctx_hi;
+   }
ctx_lo->sched.priority = I915_CONTEXT_MIN_USER_PRIORITY;
 
for_each_engine(engine, gt, id) {
@@ -3683,8 +3698,10 @@ static int live_preempt_smoke(void *arg)
 
for (n = 0; n < smoke.ncontext; n++) {
smoke.contexts[n] = kernel_context(smoke.gt->i915, NULL);
-   if (!smoke.contexts[n])
+   if (IS_ERR(smoke.contexts[n])) {
+   err = PTR_ERR(smoke.contexts[n]);
goto err_ctx;
+   }
}
 
for (n = 0; n < ARRAY_SIZE(phase); n++) {
-- 
2.17.1



[Intel-gfx] [PATCH] drm/i915/selftests: Fix NULL vs IS_ERR checking for kernel_context

2022-01-10 Thread Miaoqian Lin
Since i915_gem_create_context() function return error pointers,
the kernel_context() function does not return null, It returns error
pointers too. Using IS_ERR() to check the return value to fix this.

Signed-off-by: Miaoqian Lin 
---
 drivers/gpu/drm/i915/gt/selftest_execlists.c | 41 ++--
 1 file changed, 29 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/selftest_execlists.c 
b/drivers/gpu/drm/i915/gt/selftest_execlists.c
index b367ecfa42de..eacfe920afed 100644
--- a/drivers/gpu/drm/i915/gt/selftest_execlists.c
+++ b/drivers/gpu/drm/i915/gt/selftest_execlists.c
@@ -1540,13 +1540,16 @@ static int live_busywait_preempt(void *arg)
 */
 
ctx_hi = kernel_context(gt->i915, NULL);
-   if (!ctx_hi)
-   return -ENOMEM;
+   if (IS_ERR(ctx_hi))
+   return IS_ERR(ctx_hi);
+
ctx_hi->sched.priority = I915_CONTEXT_MAX_USER_PRIORITY;
 
ctx_lo = kernel_context(gt->i915, NULL);
-   if (!ctx_lo)
+   if (IS_ERR(ctx_lo)) {
+   err = PTR_ERR(ctx_lo);
goto err_ctx_hi;
+   }
ctx_lo->sched.priority = I915_CONTEXT_MIN_USER_PRIORITY;
 
obj = i915_gem_object_create_internal(gt->i915, PAGE_SIZE);
@@ -1742,13 +1745,17 @@ static int live_preempt(void *arg)
goto err_spin_hi;
 
ctx_hi = kernel_context(gt->i915, NULL);
-   if (!ctx_hi)
+   if (IS_ERR(ctx_hi)) {
+   err = PTR_ERR(ctx_hi);
goto err_spin_lo;
+   }
ctx_hi->sched.priority = I915_CONTEXT_MAX_USER_PRIORITY;
 
ctx_lo = kernel_context(gt->i915, NULL);
-   if (!ctx_lo)
+   if (IS_ERR(ctx_lo)) {
+   err = PTR_ERR(ctx_lo);
goto err_ctx_hi;
+   }
ctx_lo->sched.priority = I915_CONTEXT_MIN_USER_PRIORITY;
 
for_each_engine(engine, gt, id) {
@@ -1834,12 +1841,16 @@ static int live_late_preempt(void *arg)
goto err_spin_hi;
 
ctx_hi = kernel_context(gt->i915, NULL);
-   if (!ctx_hi)
+   if (IS_ERR(ctx_hi)) {
+   err = PTR_ERR(ctx_hi);
goto err_spin_lo;
+   }
 
ctx_lo = kernel_context(gt->i915, NULL);
-   if (!ctx_lo)
+   if (IS_ERR(ctx_lo)) {
+   err = PTR_ERR(ctx_lo);
goto err_ctx_hi;
+   }
 
/* Make sure ctx_lo stays before ctx_hi until we trigger preemption. */
ctx_lo->sched.priority = 1;
@@ -1928,8 +1939,8 @@ struct preempt_client {
 static int preempt_client_init(struct intel_gt *gt, struct preempt_client *c)
 {
c->ctx = kernel_context(gt->i915, NULL);
-   if (!c->ctx)
-   return -ENOMEM;
+   if (IS_ERR(c->ctx))
+   return PTR_ERR(c->ctx);
 
if (igt_spinner_init(>spin, gt))
goto err_ctx;
@@ -3385,13 +3396,17 @@ static int live_preempt_timeout(void *arg)
return -ENOMEM;
 
ctx_hi = kernel_context(gt->i915, NULL);
-   if (!ctx_hi)
+   if (IS_ERR(ctx_hi)) {
+   err = PTR_ERR(ctx_hi);
goto err_spin_lo;
+   }
ctx_hi->sched.priority = I915_CONTEXT_MAX_USER_PRIORITY;
 
ctx_lo = kernel_context(gt->i915, NULL);
-   if (!ctx_lo)
+   if (IS_ERR(ctx_lo)) {
+   err = PTR_ERR(ctx_lo);
goto err_ctx_hi;
+   }
ctx_lo->sched.priority = I915_CONTEXT_MIN_USER_PRIORITY;
 
for_each_engine(engine, gt, id) {
@@ -3683,8 +3698,10 @@ static int live_preempt_smoke(void *arg)
 
for (n = 0; n < smoke.ncontext; n++) {
smoke.contexts[n] = kernel_context(smoke.gt->i915, NULL);
-   if (!smoke.contexts[n])
+   if (IS_ERR(smoke.contexts[n])) {
+   err = PTR_ERR(smoke.contexts[n]);
goto err_ctx;
+   }
}
 
for (n = 0; n < ARRAY_SIZE(phase); n++) {
-- 
2.17.1



[Intel-gfx] [PATCH] drm/i915/selftests: Fix inconsistent object in IS_ERR and PTR_ERR

2021-12-10 Thread Miaoqian Lin
Fix inconsistent object in IS_ERR and PTR_ERR in
igt_dmabuf_import_same_driver and igt_dmabuf_import_same_driver_lmem.
As obj is the return value of __i915_gem_object_create_user,
the proper object to be passed as argument to PTR_ERR is obj.

Signed-off-by: Miaoqian Lin 
---
 drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c 
b/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c
index 4a6bb64c3a35..3cc74b0fed06 100644
--- a/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c
+++ b/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c
@@ -102,7 +102,7 @@ static int igt_dmabuf_import_same_driver_lmem(void *arg)
obj = __i915_gem_object_create_user(i915, PAGE_SIZE, , 1);
if (IS_ERR(obj)) {
pr_err("__i915_gem_object_create_user failed with err=%ld\n",
-  PTR_ERR(dmabuf));
+  PTR_ERR(obj));
err = PTR_ERR(obj);
goto out_ret;
}
@@ -158,7 +158,7 @@ static int igt_dmabuf_import_same_driver(struct 
drm_i915_private *i915,
regions, num_regions);
if (IS_ERR(obj)) {
pr_err("__i915_gem_object_create_user failed with err=%ld\n",
-  PTR_ERR(dmabuf));
+  PTR_ERR(obj));
err = PTR_ERR(obj);
goto out_ret;
}
-- 
2.17.1