LKML Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] drm/i915: Fix wrong return value
@ 2020-08-02 11:15 Tianjia Zhang
  2020-08-02 11:40 ` Andi Shyti
  0 siblings, 1 reply; 4+ messages in thread
From: Tianjia Zhang @ 2020-08-02 11:15 UTC (permalink / raw)
  To: jani.nikula, joonas.lahtinen, rodrigo.vivi, airlied, daniel,
	chris, matthew.auld, tvrtko.ursulin, mika.kuoppala, andi.shyti
  Cc: intel-gfx, dri-devel, linux-kernel, tianjia.zhang

In function i915_active_acquire_preallocate_barrier(), not all
paths have the return value set correctly, and in case of memory
allocation failure, a negative error code should be returned.

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
---
 drivers/gpu/drm/i915/i915_active.c            | 4 ++--
 drivers/gpu/drm/i915/selftests/i915_request.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_active.c b/drivers/gpu/drm/i915/i915_active.c
index d960d0be5bd2..cc017e3cc9c5 100644
--- a/drivers/gpu/drm/i915/i915_active.c
+++ b/drivers/gpu/drm/i915/i915_active.c
@@ -758,7 +758,7 @@ int i915_active_acquire_preallocate_barrier(struct i915_active *ref,
 	intel_engine_mask_t tmp, mask = engine->mask;
 	struct llist_node *first = NULL, *last = NULL;
 	struct intel_gt *gt = engine->gt;
-	int err;
+	int err = 0;
 
 	GEM_BUG_ON(i915_active_is_idle(ref));
 
@@ -782,7 +782,7 @@ int i915_active_acquire_preallocate_barrier(struct i915_active *ref,
 		if (!node) {
 			node = kmem_cache_alloc(global.slab_cache, GFP_KERNEL);
 			if (!node) {
-				err = ENOMEM;
+				err = -ENOMEM;
 				goto unwind;
 			}
 
diff --git a/drivers/gpu/drm/i915/selftests/i915_request.c b/drivers/gpu/drm/i915/selftests/i915_request.c
index 6014e8dfcbb1..dda801a87b8a 100644
--- a/drivers/gpu/drm/i915/selftests/i915_request.c
+++ b/drivers/gpu/drm/i915/selftests/i915_request.c
@@ -326,7 +326,7 @@ static int __igt_breadcrumbs_smoketest(void *arg)
 		if (!wait) {
 			i915_sw_fence_commit(submit);
 			heap_fence_put(submit);
-			err = ENOMEM;
+			err = -ENOMEM;
 			break;
 		}
 
-- 
2.26.2


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/i915: Fix wrong return value
  2020-08-02 11:15 [PATCH] drm/i915: Fix wrong return value Tianjia Zhang
@ 2020-08-02 11:40 ` Andi Shyti
  2020-08-02 11:51   ` [Intel-gfx] " Chris Wilson
  0 siblings, 1 reply; 4+ messages in thread
From: Andi Shyti @ 2020-08-02 11:40 UTC (permalink / raw)
  To: Tianjia Zhang
  Cc: jani.nikula, joonas.lahtinen, rodrigo.vivi, airlied, daniel,
	chris, matthew.auld, tvrtko.ursulin, mika.kuoppala, intel-gfx,
	dri-devel, linux-kernel, tianjia.zhang

Hi Tianjia,

> diff --git a/drivers/gpu/drm/i915/i915_active.c b/drivers/gpu/drm/i915/i915_active.c
> index d960d0be5bd2..cc017e3cc9c5 100644
> --- a/drivers/gpu/drm/i915/i915_active.c
> +++ b/drivers/gpu/drm/i915/i915_active.c
> @@ -758,7 +758,7 @@ int i915_active_acquire_preallocate_barrier(struct i915_active *ref,
>  	intel_engine_mask_t tmp, mask = engine->mask;
>  	struct llist_node *first = NULL, *last = NULL;
>  	struct intel_gt *gt = engine->gt;
> -	int err;
> +	int err = 0;

you don't need the initialization here.

Thanks,
Andi

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Intel-gfx] [PATCH] drm/i915: Fix wrong return value
  2020-08-02 11:40 ` Andi Shyti
@ 2020-08-02 11:51   ` Chris Wilson
  2020-08-02 13:18     ` Andi Shyti
  0 siblings, 1 reply; 4+ messages in thread
From: Chris Wilson @ 2020-08-02 11:51 UTC (permalink / raw)
  To: Andi Shyti, Tianjia Zhang
  Cc: dri-devel, airlied, intel-gfx, linux-kernel, tianjia.zhang, matthew.auld

Quoting Andi Shyti (2020-08-02 12:40:44)
> Hi Tianjia,
> 
> > diff --git a/drivers/gpu/drm/i915/i915_active.c b/drivers/gpu/drm/i915/i915_active.c
> > index d960d0be5bd2..cc017e3cc9c5 100644
> > --- a/drivers/gpu/drm/i915/i915_active.c
> > +++ b/drivers/gpu/drm/i915/i915_active.c
> > @@ -758,7 +758,7 @@ int i915_active_acquire_preallocate_barrier(struct i915_active *ref,
> >       intel_engine_mask_t tmp, mask = engine->mask;
> >       struct llist_node *first = NULL, *last = NULL;
> >       struct intel_gt *gt = engine->gt;
> > -     int err;
> > +     int err = 0;
> 
> you don't need the initialization here.

But it's close enough that I can munge the patch inline.
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Intel-gfx] [PATCH] drm/i915: Fix wrong return value
  2020-08-02 11:51   ` [Intel-gfx] " Chris Wilson
@ 2020-08-02 13:18     ` Andi Shyti
  0 siblings, 0 replies; 4+ messages in thread
From: Andi Shyti @ 2020-08-02 13:18 UTC (permalink / raw)
  To: Chris Wilson
  Cc: Tianjia Zhang, dri-devel, airlied, intel-gfx, linux-kernel,
	tianjia.zhang, matthew.auld

> > > diff --git a/drivers/gpu/drm/i915/i915_active.c b/drivers/gpu/drm/i915/i915_active.c
> > > index d960d0be5bd2..cc017e3cc9c5 100644
> > > --- a/drivers/gpu/drm/i915/i915_active.c
> > > +++ b/drivers/gpu/drm/i915/i915_active.c
> > > @@ -758,7 +758,7 @@ int i915_active_acquire_preallocate_barrier(struct i915_active *ref,
> > >       intel_engine_mask_t tmp, mask = engine->mask;
> > >       struct llist_node *first = NULL, *last = NULL;
> > >       struct intel_gt *gt = engine->gt;
> > > -     int err;
> > > +     int err = 0;
> > 
> > you don't need the initialization here.
> 
> But it's close enough that I can munge the patch inline.
> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>

sure... you can also remove it before merging it and it might
also need:

Fixes: d8af05ff38ae7 ("drm/i915: Allow sharing the idle-barrier from other kernel requests)

but, yeah...

Reviewed-by: Andi Shyti <andi.shyti@intel.com>

... as well :)

Andi

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-02 11:15 [PATCH] drm/i915: Fix wrong return value Tianjia Zhang
2020-08-02 11:40 ` Andi Shyti
2020-08-02 11:51   ` [Intel-gfx] " Chris Wilson
2020-08-02 13:18     ` Andi Shyti

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git
	git clone --mirror https://lore.kernel.org/lkml/8 lkml/git/8.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git