All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/i915: Cleanup i915_gem_request_add_to_client
@ 2016-09-27 12:07 Tvrtko Ursulin
  2016-09-27 12:19 ` Chris Wilson
  2016-09-27 12:49 ` ✓ Fi.CI.BAT: success for " Patchwork
  0 siblings, 2 replies; 6+ messages in thread
From: Tvrtko Ursulin @ 2016-09-27 12:07 UTC (permalink / raw)
  To: Intel-gfx

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Several things we can clean up in this function:

 * Request and file passed in cannot be NULL. There is
   a single caller which makes it impossible so change
   that condition to a GEM_BUG_ON instead of a WARN
   with a return code.

 * Same is true for req->file_priv which is always
   zeroed before this function is called.

 * With the above we can remove the error return
   from the function making it void.

 * dev_private local variable was unused.

 * Call site in i915_gem_do_execbuffer can be
   simplified since there is no error handling any
   longer.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |  7 ++-----
 drivers/gpu/drm/i915/i915_gem_request.c    | 16 +++-------------
 drivers/gpu/drm/i915/i915_gem_request.h    |  4 ++--
 3 files changed, 7 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index 33c85227643d..67f9fbeb29d0 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -1824,9 +1824,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 	 */
 	params->request->batch = params->batch;
 
-	ret = i915_gem_request_add_to_client(params->request, file);
-	if (ret)
-		goto err_request;
+	i915_gem_request_add_to_client(params->request, file);
 
 	/*
 	 * Save assorted stuff away to pass through to *_submission().
@@ -1841,8 +1839,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 	params->ctx                     = ctx;
 
 	ret = execbuf_submit(params, args, &eb->vmas);
-err_request:
-	__i915_add_request(params->request, ret == 0);
+	__i915_add_request(params->request, true);
 
 err_batch_unpin:
 	/*
diff --git a/drivers/gpu/drm/i915/i915_gem_request.c b/drivers/gpu/drm/i915/i915_gem_request.c
index 40978bc12ceb..b03f09567da2 100644
--- a/drivers/gpu/drm/i915/i915_gem_request.c
+++ b/drivers/gpu/drm/i915/i915_gem_request.c
@@ -115,29 +115,19 @@ const struct fence_ops i915_fence_ops = {
 	.timeline_value_str = i915_fence_timeline_value_str,
 };
 
-int i915_gem_request_add_to_client(struct drm_i915_gem_request *req,
-				   struct drm_file *file)
+void i915_gem_request_add_to_client(struct drm_i915_gem_request *req,
+				    struct drm_file *file)
 {
-	struct drm_i915_private *dev_private;
 	struct drm_i915_file_private *file_priv;
 
-	WARN_ON(!req || !file || req->file_priv);
+	GEM_BUG_ON(!req || !file || req->file_priv);
 
-	if (!req || !file)
-		return -EINVAL;
-
-	if (req->file_priv)
-		return -EINVAL;
-
-	dev_private = req->i915;
 	file_priv = file->driver_priv;
 
 	spin_lock(&file_priv->mm.lock);
 	req->file_priv = file_priv;
 	list_add_tail(&req->client_list, &file_priv->mm.request_list);
 	spin_unlock(&file_priv->mm.lock);
-
-	return 0;
 }
 
 static inline void
diff --git a/drivers/gpu/drm/i915/i915_gem_request.h b/drivers/gpu/drm/i915/i915_gem_request.h
index 974bd7bcc801..7fa20f342acf 100644
--- a/drivers/gpu/drm/i915/i915_gem_request.h
+++ b/drivers/gpu/drm/i915/i915_gem_request.h
@@ -155,8 +155,8 @@ static inline bool fence_is_i915(struct fence *fence)
 struct drm_i915_gem_request * __must_check
 i915_gem_request_alloc(struct intel_engine_cs *engine,
 		       struct i915_gem_context *ctx);
-int i915_gem_request_add_to_client(struct drm_i915_gem_request *req,
-				   struct drm_file *file);
+void i915_gem_request_add_to_client(struct drm_i915_gem_request *req,
+				    struct drm_file *file);
 void i915_gem_request_retire_upto(struct drm_i915_gem_request *req);
 
 static inline u32
-- 
2.7.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH] drm/i915: Cleanup i915_gem_request_add_to_client
  2016-09-27 12:07 [PATCH] drm/i915: Cleanup i915_gem_request_add_to_client Tvrtko Ursulin
@ 2016-09-27 12:19 ` Chris Wilson
  2016-09-27 12:35   ` Tvrtko Ursulin
  2016-09-27 12:49 ` ✓ Fi.CI.BAT: success for " Patchwork
  1 sibling, 1 reply; 6+ messages in thread
From: Chris Wilson @ 2016-09-27 12:19 UTC (permalink / raw)
  To: Tvrtko Ursulin; +Cc: Intel-gfx

On Tue, Sep 27, 2016 at 01:07:13PM +0100, Tvrtko Ursulin wrote:
> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> 
> Several things we can clean up in this function:
> 
>  * Request and file passed in cannot be NULL. There is
>    a single caller which makes it impossible so change
>    that condition to a GEM_BUG_ON instead of a WARN
>    with a return code.

And move it next to the single caller since this is a specialised
function that is tied to userspace batches.

And the spinlock here is superfluous.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH] drm/i915: Cleanup i915_gem_request_add_to_client
  2016-09-27 12:19 ` Chris Wilson
@ 2016-09-27 12:35   ` Tvrtko Ursulin
  0 siblings, 0 replies; 6+ messages in thread
From: Tvrtko Ursulin @ 2016-09-27 12:35 UTC (permalink / raw)
  To: Chris Wilson, Tvrtko Ursulin, Intel-gfx


On 27/09/2016 13:19, Chris Wilson wrote:
> On Tue, Sep 27, 2016 at 01:07:13PM +0100, Tvrtko Ursulin wrote:
>> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>>
>> Several things we can clean up in this function:
>>
>>   * Request and file passed in cannot be NULL. There is
>>     a single caller which makes it impossible so change
>>     that condition to a GEM_BUG_ON instead of a WARN
>>     with a return code.
> And move it next to the single caller since this is a specialised
> function that is tied to userspace batches.

I thought about it, so OK, will do that.

> And the spinlock here is superfluous.

Hm why? There are places which iterate the list.

Regards,

Tvrtko

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* ✓ Fi.CI.BAT: success for drm/i915: Cleanup i915_gem_request_add_to_client
  2016-09-27 12:07 [PATCH] drm/i915: Cleanup i915_gem_request_add_to_client Tvrtko Ursulin
  2016-09-27 12:19 ` Chris Wilson
@ 2016-09-27 12:49 ` Patchwork
  1 sibling, 0 replies; 6+ messages in thread
From: Patchwork @ 2016-09-27 12:49 UTC (permalink / raw)
  To: Tvrtko Ursulin; +Cc: intel-gfx

== Series Details ==

Series: drm/i915: Cleanup i915_gem_request_add_to_client
URL   : https://patchwork.freedesktop.org/series/12959/
State : success

== Summary ==

Series 12959v1 drm/i915: Cleanup i915_gem_request_add_to_client
https://patchwork.freedesktop.org/api/1.0/series/12959/revisions/1/mbox/

Test pm_rpm:
        Subgroup basic-pci-d3-state:
                dmesg-warn -> PASS       (fi-skl-6770hq)

fi-bdw-5557u     total:244  pass:229  dwarn:0   dfail:0   fail:0   skip:15 
fi-bsw-n3050     total:244  pass:202  dwarn:0   dfail:0   fail:0   skip:42 
fi-byt-n2820     total:244  pass:208  dwarn:0   dfail:0   fail:1   skip:35 
fi-hsw-4770      total:244  pass:222  dwarn:0   dfail:0   fail:0   skip:22 
fi-hsw-4770r     total:244  pass:222  dwarn:0   dfail:0   fail:0   skip:22 
fi-ilk-650       total:244  pass:182  dwarn:0   dfail:0   fail:2   skip:60 
fi-ivb-3520m     total:244  pass:219  dwarn:0   dfail:0   fail:0   skip:25 
fi-ivb-3770      total:244  pass:207  dwarn:0   dfail:0   fail:0   skip:37 
fi-skl-6260u     total:244  pass:230  dwarn:0   dfail:0   fail:0   skip:14 
fi-skl-6700hq    total:244  pass:222  dwarn:0   dfail:0   fail:0   skip:22 
fi-skl-6700k     total:244  pass:219  dwarn:1   dfail:0   fail:0   skip:24 
fi-skl-6770hq    total:244  pass:228  dwarn:1   dfail:0   fail:1   skip:14 
fi-snb-2520m     total:244  pass:208  dwarn:0   dfail:0   fail:0   skip:36 
fi-snb-2600      total:244  pass:207  dwarn:0   dfail:0   fail:0   skip:37 

Results at /archive/results/CI_IGT_test/Patchwork_2580/

67a915c510e83bc3892361db0d85a94275f05359 drm-intel-nightly: 2016y-09m-27d-11h-21m-20s UTC integration manifest
b83b36a drm/i915: Cleanup i915_gem_request_add_to_client

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH] drm/i915: Cleanup i915_gem_request_add_to_client
  2016-09-27  9:44 [PATCH] " Tvrtko Ursulin
@ 2016-09-28 13:25 ` Joonas Lahtinen
  0 siblings, 0 replies; 6+ messages in thread
From: Joonas Lahtinen @ 2016-09-28 13:25 UTC (permalink / raw)
  To: Tvrtko Ursulin, Intel-gfx

On ti, 2016-09-27 at 10:44 +0100, Tvrtko Ursulin wrote: 
> -int i915_gem_request_add_to_client(struct drm_i915_gem_request *req,
> -				   struct drm_file *file)
> +void i915_gem_request_add_to_client(struct drm_i915_gem_request *req,
> +				    struct drm_file *file)
>  {
> -	struct drm_i915_private *dev_private;
>  	struct drm_i915_file_private *file_priv;
>  
> -	WARN_ON(!req || !file || req->file_priv);
> +	GEM_BUG_ON(!req || !file || req->file_priv);
> 

I might be inclined to drop this completely, we're going to OOPS
anwyway if one of those is null.

Anyway;

Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>

Regards, Joonas
-- 
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* [PATCH] drm/i915: Cleanup i915_gem_request_add_to_client
@ 2016-09-27  9:44 Tvrtko Ursulin
  2016-09-28 13:25 ` Joonas Lahtinen
  0 siblings, 1 reply; 6+ messages in thread
From: Tvrtko Ursulin @ 2016-09-27  9:44 UTC (permalink / raw)
  To: Intel-gfx

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Several things we can clean up in this function:

 * Request and file passed in cannot be NULL. There is
   a single caller which makes it impossible so change
   that condition to a GEM_BUG_ON instead of a WARN
   with a return code.

 * Same is true for req->file_priv which is always
   zeroed before this function is called.

 * With the above we can remove the error return
   from the function making it void.

 * dev_private local variable was unused.

 * Call site in i915_gem_do_execbuffer can be
   simplified since there is no error handling any
   longer.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |  7 ++-----
 drivers/gpu/drm/i915/i915_gem_request.c    | 16 +++-------------
 drivers/gpu/drm/i915/i915_gem_request.h    |  4 ++--
 3 files changed, 7 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index 33c85227643d..67f9fbeb29d0 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -1824,9 +1824,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 	 */
 	params->request->batch = params->batch;
 
-	ret = i915_gem_request_add_to_client(params->request, file);
-	if (ret)
-		goto err_request;
+	i915_gem_request_add_to_client(params->request, file);
 
 	/*
 	 * Save assorted stuff away to pass through to *_submission().
@@ -1841,8 +1839,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 	params->ctx                     = ctx;
 
 	ret = execbuf_submit(params, args, &eb->vmas);
-err_request:
-	__i915_add_request(params->request, ret == 0);
+	__i915_add_request(params->request, true);
 
 err_batch_unpin:
 	/*
diff --git a/drivers/gpu/drm/i915/i915_gem_request.c b/drivers/gpu/drm/i915/i915_gem_request.c
index 40978bc12ceb..b03f09567da2 100644
--- a/drivers/gpu/drm/i915/i915_gem_request.c
+++ b/drivers/gpu/drm/i915/i915_gem_request.c
@@ -115,29 +115,19 @@ const struct fence_ops i915_fence_ops = {
 	.timeline_value_str = i915_fence_timeline_value_str,
 };
 
-int i915_gem_request_add_to_client(struct drm_i915_gem_request *req,
-				   struct drm_file *file)
+void i915_gem_request_add_to_client(struct drm_i915_gem_request *req,
+				    struct drm_file *file)
 {
-	struct drm_i915_private *dev_private;
 	struct drm_i915_file_private *file_priv;
 
-	WARN_ON(!req || !file || req->file_priv);
+	GEM_BUG_ON(!req || !file || req->file_priv);
 
-	if (!req || !file)
-		return -EINVAL;
-
-	if (req->file_priv)
-		return -EINVAL;
-
-	dev_private = req->i915;
 	file_priv = file->driver_priv;
 
 	spin_lock(&file_priv->mm.lock);
 	req->file_priv = file_priv;
 	list_add_tail(&req->client_list, &file_priv->mm.request_list);
 	spin_unlock(&file_priv->mm.lock);
-
-	return 0;
 }
 
 static inline void
diff --git a/drivers/gpu/drm/i915/i915_gem_request.h b/drivers/gpu/drm/i915/i915_gem_request.h
index 974bd7bcc801..7fa20f342acf 100644
--- a/drivers/gpu/drm/i915/i915_gem_request.h
+++ b/drivers/gpu/drm/i915/i915_gem_request.h
@@ -155,8 +155,8 @@ static inline bool fence_is_i915(struct fence *fence)
 struct drm_i915_gem_request * __must_check
 i915_gem_request_alloc(struct intel_engine_cs *engine,
 		       struct i915_gem_context *ctx);
-int i915_gem_request_add_to_client(struct drm_i915_gem_request *req,
-				   struct drm_file *file);
+void i915_gem_request_add_to_client(struct drm_i915_gem_request *req,
+				    struct drm_file *file);
 void i915_gem_request_retire_upto(struct drm_i915_gem_request *req);
 
 static inline u32
-- 
2.7.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

end of thread, other threads:[~2016-09-28 13:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-27 12:07 [PATCH] drm/i915: Cleanup i915_gem_request_add_to_client Tvrtko Ursulin
2016-09-27 12:19 ` Chris Wilson
2016-09-27 12:35   ` Tvrtko Ursulin
2016-09-27 12:49 ` ✓ Fi.CI.BAT: success for " Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2016-09-27  9:44 [PATCH] " Tvrtko Ursulin
2016-09-28 13:25 ` Joonas Lahtinen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.