[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211222075832.1732-1-linmq006@gmail.com>
Date: Wed, 22 Dec 2021 07:58:29 +0000
From: Miaoqian Lin <linmq006@...il.com>
To: unlisted-recipients:; (no To-header on input)
Cc: linmq006@...il.com, Jani Nikula <jani.nikula@...ux.intel.com>,
Joonas Lahtinen <joonas.lahtinen@...ux.intel.com>,
Rodrigo Vivi <rodrigo.vivi@...el.com>,
David Airlie <airlied@...ux.ie>,
Daniel Vetter <daniel@...ll.ch>,
Chris Wilson <chris@...is-wilson.co.uk>,
Matthew Brost <matthew.brost@...el.com>,
Andi Shyti <andi.shyti@...el.com>,
Daniele Ceraolo Spurio <daniele.ceraolospurio@...el.com>,
Jason Ekstrand <jason@...kstrand.net>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Lucas De Marchi <lucas.demarchi@...el.com>,
intel-gfx@...ts.freedesktop.org, dri-devel@...ts.freedesktop.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] drm/i915/selftests: Fix NULL vs IS_ERR checking for kernel_context
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 <linmq006@...il.com>
---
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(&c->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
Powered by blists - more mailing lists