kernel_context() returns an error pointer. Use pointer-error conversion functions to evaluate its return value, rather than checking for a '0' return.
Fixes: eb5c10cbbc2f ("drm/i915: Remove I915_USER_PRIORITY_SHIFT") Reported-by: Dan Carpenter dan.carpenter@linaro.org Signed-off-by: Andi Shyti andi.shyti@linux.intel.com Cc: Chris Wilson < chris@chris-wilson.co.uk> Cc: stable@vger.kernel.org # v5.13+ --- drivers/gpu/drm/i915/gt/selftest_execlists.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/i915/gt/selftest_execlists.c b/drivers/gpu/drm/i915/gt/selftest_execlists.c index 736b89a8ecf54..4202df5b8c122 100644 --- a/drivers/gpu/drm/i915/gt/selftest_execlists.c +++ b/drivers/gpu/drm/i915/gt/selftest_execlists.c @@ -1530,8 +1530,8 @@ 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; u32 *map; + int err;
/* * Verify that even without HAS_LOGICAL_RING_PREEMPTION, we can @@ -1539,13 +1539,17 @@ 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 PTR_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);
On 26.05.2023 14:41, Andi Shyti wrote:
kernel_context() returns an error pointer. Use pointer-error conversion functions to evaluate its return value, rather than checking for a '0' return.
Fixes: eb5c10cbbc2f ("drm/i915: Remove I915_USER_PRIORITY_SHIFT") Reported-by: Dan Carpenter dan.carpenter@linaro.org Signed-off-by: Andi Shyti andi.shyti@linux.intel.com Cc: Chris Wilson < chris@chris-wilson.co.uk> Cc: stable@vger.kernel.org # v5.13+
Reviewed-by: Andrzej Hajda andrzej.hajda@intel.com
Regards Andrzej
drivers/gpu/drm/i915/gt/selftest_execlists.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/i915/gt/selftest_execlists.c b/drivers/gpu/drm/i915/gt/selftest_execlists.c index 736b89a8ecf54..4202df5b8c122 100644 --- a/drivers/gpu/drm/i915/gt/selftest_execlists.c +++ b/drivers/gpu/drm/i915/gt/selftest_execlists.c @@ -1530,8 +1530,8 @@ 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; u32 *map;
- int err;
/* * Verify that even without HAS_LOGICAL_RING_PREEMPTION, we can @@ -1539,13 +1539,17 @@ 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 PTR_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)) {
goto err_ctx_hi;err = PTR_ERR(ctx_lo);
- }
- ctx_lo->sched.priority = I915_CONTEXT_MIN_USER_PRIORITY;
obj = i915_gem_object_create_internal(gt->i915, PAGE_SIZE);
-----Original Message----- From: Intel-gfx intel-gfx-bounces@lists.freedesktop.org On Behalf Of Andrzej Hajda Sent: Thursday, June 1, 2023 6:14 PM To: Andi Shyti andi.shyti@linux.intel.com; Intel GFX <intel- gfx@lists.freedesktop.org>; DRI Devel dri-devel@lists.freedesktop.org Cc: Chris Wilson chris@chris-wilson.co.uk; stable@vger.kernel.org; Dan Carpenter dan.carpenter@linaro.org; Andi Shyti andi.shyti@kernel.org Subject: Re: [Intel-gfx] [PATCH] drm/i915/gt: Use the correct error value when kernel_context() fails
On 26.05.2023 14:41, Andi Shyti wrote:
kernel_context() returns an error pointer. Use pointer-error conversion functions to evaluate its return value, rather than checking for a '0' return.
Fixes: eb5c10cbbc2f ("drm/i915: Remove I915_USER_PRIORITY_SHIFT") Reported-by: Dan Carpenter dan.carpenter@linaro.org Signed-off-by: Andi Shyti andi.shyti@linux.intel.com Cc: Chris Wilson < chris@chris-wilson.co.uk> Cc: stable@vger.kernel.org # v5.13+
Reviewed-by: Andrzej Hajda andrzej.hajda@intel.com
Regards Andrzej
drivers/gpu/drm/i915/gt/selftest_execlists.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/i915/gt/selftest_execlists.c b/drivers/gpu/drm/i915/gt/selftest_execlists.c index 736b89a8ecf54..4202df5b8c122 100644 --- a/drivers/gpu/drm/i915/gt/selftest_execlists.c +++ b/drivers/gpu/drm/i915/gt/selftest_execlists.c @@ -1530,8 +1530,8 @@ 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; u32 *map;
- int err;
We could initialize err with 0 and remove err = 0 assignment below but leaving up to you.
/* * Verify that even without HAS_LOGICAL_RING_PREEMPTION, we
can @@
-1539,13 +1539,17 @@ 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 PTR_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)) {
goto err_ctx_hi;err = PTR_ERR(ctx_lo);
- }
Looks fine, Acked-by: Tejas Upadhyay tejas.upadhyay@intel.com
ctx_lo->sched.priority = I915_CONTEXT_MIN_USER_PRIORITY;
obj = i915_gem_object_create_internal(gt->i915, PAGE_SIZE);
Hi Tejas,
@@ -1530,8 +1530,8 @@ 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; u32 *map;
- int err;
We could initialize err with 0 and remove err = 0 assignment below but leaving up to you.
that assignement must be a leftover from previous patches because err is already initialized here:
err = i915_vma_pin(vma, 0, 0, PIN_GLOBAL);
will remove it. Thanks!
/* * Verify that even without HAS_LOGICAL_RING_PREEMPTION, we
can @@
-1539,13 +1539,17 @@ 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 PTR_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)) {
goto err_ctx_hi;err = PTR_ERR(ctx_lo);
- }
Looks fine, Acked-by: Tejas Upadhyay tejas.upadhyay@intel.com
Thank you! Andi
ctx_lo->sched.priority = I915_CONTEXT_MIN_USER_PRIORITY;
obj = i915_gem_object_create_internal(gt->i915, PAGE_SIZE);
linux-stable-mirror@lists.linaro.org