Command parser batch buffer copy
Subsystems (3)
v4 cover Command parser batch buffer copy
From: Brad Volkin <[email protected]>
This is v4 of the series I sent here:
http://lists.freedesktop.org/archives/intel-gfx/2014-November/054733.html
This version incorporates most of the feedback from v3. The couple of things that I missed (mostly for timing reasons) are:
* Move 'pending_read_domains |= I915_GEM_DOMAIN_COMMAND' after the parser
* Maybe remove the memsets from the batch copy function
* Today's feedback from Chris and Daniel r.e. madv
I'd suggest that the first two could be small follow up patches, and the madv changes I did based on Daniel's earlier comments were pulled into a separate patch that could be rewritten or modified as needed.
Brad Volkin (7):
drm/i915: Implement a framework for batch buffer pools drm/i915: Use batch pools with the command parser drm/i915: Add a batch pool debugfs file
drm/i915: Add batch pool details to i915_gem_objects debugfs drm/i915: Use batch length instead of object size in command parser drm/i915: Mark shadow batch buffers as purgeable drm/i915: Tidy up execbuffer command parsing code
Documentation/DocBook/drm.tmpl | 5 + drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/i915_cmd_parser.c | 97 ++++++++++++++---- drivers/gpu/drm/i915/i915_debugfs.c | 86 ++++++++++++++-- drivers/gpu/drm/i915/i915_dma.c | 1 + drivers/gpu/drm/i915/i915_drv.h | 24 +++++ drivers/gpu/drm/i915/i915_gem.c | 3 + drivers/gpu/drm/i915/i915_gem_batch_pool.c | 152 +++++++++++++++++++++++++++++ drivers/gpu/drm/i915/i915_gem_execbuffer.c | 105 ++++++++++++++++---- 9 files changed, 430 insertions(+), 44 deletions(-) create mode 100644 drivers/gpu/drm/i915/i915_gem_batch_pool.c
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 1/7 drm/i915: Implement a framework for batch buffer pools
From: Brad Volkin <[email protected]>
This adds a small module for managing a pool of batch buffers. The only current use case is for the command parser, as described in the kerneldoc in the patch. The code is simple, but separating it out makes it easier to change the underlying algorithms and to extend to future use cases should they arise.
The interface is simple: init to create an empty pool, fini to clean it up, get to obtain a new buffer. Note that all buffers are expected to be inactive before cleaning up the pool.
Locking is currently based on the caller holding the struct_mutex. We already do that in the places where we will use the batch pool for the command parser.
v2:
- s/BUG_ON/WARN_ON/ for locking assertions
- Remove the cap on pool size
- Switch from alloc/free to init/fini
v3:
- Idiomatic looping structure in _fini
- Correct handling of purged objects
- Don't return a buffer that's too much larger than needed
v4:
- Rebased to latest -nightly
v5:
- Remove _put() function and clean up comments to match
--- Documentation/DocBook/drm.tmpl | 5 + drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/i915_drv.h | 15 +++ drivers/gpu/drm/i915/i915_gem.c | 1 + drivers/gpu/drm/i915/i915_gem_batch_pool.c | 152 +++++++++++++++++++++++++++++ 5 files changed, 174 insertions(+) create mode 100644 drivers/gpu/drm/i915/i915_gem_batch_pool.c
Documentation/DocBook/drm.tmpl +5 -0
@@ -3989,6 +3989,11 @@ int num_ioctls;</synopsis> !Idrivers/gpu/drm/i915/i915_cmd_parser.c </sect2> <sect2> + <title>Batchbuffer Pools</title> +!Pdrivers/gpu/drm/i915/i915_gem_batch_pool.c batch pool +!Idrivers/gpu/drm/i915/i915_gem_batch_pool.c + </sect2> + <sect2> <title>Logical Rings, Logical Ring Contexts and Execlists</title> !Pdrivers/gpu/drm/i915/intel_lrc.c Logical Rings, Logical Ring Contexts and Execlists !Idrivers/gpu/drm/i915/intel_lrc.c
drivers/gpu/drm/i915/Makefile +1 -0
@@ -19,6 +19,7 @@ i915-$(CONFIG_DEBUG_FS) += i915_debugfs.o # GEM code i915-y += i915_cmd_parser.o \ + i915_gem_batch_pool.o \ i915_gem_context.o \ i915_gem_render_state.o \ i915_gem_debug.o \
drivers/gpu/drm/i915/i915_drv.h +15 -0
@@ -1134,6 +1134,12 @@ struct intel_l3_parity {int which_slice; }; +struct i915_gem_batch_pool { +struct drm_device *dev; +struct list_head active_list; +struct list_head inactive_list; +}; +struct i915_gem_mm {/** Memory allocator for GTT stolen memory */ struct drm_mm stolen;
@@ -1865,6 +1871,8 @@ struct drm_i915_gem_object {/** Used in execbuf to temporarily hold a ref */ struct list_head obj_exec_link; +struct list_head batch_pool_list; +/** * This is set if the object is on the active lists (has pending * rendering and so a non-zero seqno), and is not set if it i s on
@@ -2829,6 +2837,13 @@ void i915_destroy_error_state(struct drm_device *dev);void i915_get_extra_instdone (struct drm_device *dev,uint32_t *instdone);const char *i915_cache_level_str (struct drm_i915_private *i915,int type); +/* i915_gem_batch_pool.c */ +void i915_gem_batch_pool_init (struct drm_device *dev, +struct i915_gem_batch_pool *pool); +void i915_gem_batch_pool_fini (struct i915_gem_batch_pool *pool); +struct drm_i915_gem_object * +i915_gem_batch_pool_get (struct i915_gem_batch_pool *pool,size_t size); +/* i915_cmd_parser.c */ int i915_cmd_parser_get_version (void );int i915_cmd_parser_init_ring (struct intel_engine_cs *ring);
drivers/gpu/drm/i915/i915_gem.c +1 -0
@@ -4352,6 +4352,7 @@ void i915_gem_object_init(struct drm_i915_gem_object *obj,INIT_LIST_HEAD (&obj->ring_list);INIT_LIST_HEAD (&obj->obj_exec_link);INIT_LIST_HEAD (&obj->vma_list); +INIT_LIST_HEAD (&obj->batch_pool_list); obj->ops = ops;
drivers/gpu/drm/i915/i915_gem_batch_pool.c new file +152 -0
152 lines not on this page · raw message
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v4 1/7] drm/i915: Implement a framework for batch buffer pools
Quoted 256 lines · On Fri, Nov 07, 2014 at 02:22:01PM -0800, [email protected] wrote:
From: Brad Volkin <[email protected]>
This adds a small module for managing a pool of batch buffers. The only current use case is for the command parser, as described in the kerneldoc in the patch. The code is simple, but separating it out makes it easier to change the underlying algorithms and to extend to future use cases should they arise.
The interface is simple: init to create an empty pool, fini to clean it up, get to obtain a new buffer. Note that all buffers are expected to be inactive before cleaning up the pool.
Locking is currently based on the caller holding the
struct_mutex. We already do that in the places where we will use the batch pool for the command parser.v2:
- s/BUG_ON/WARN_ON/ for locking assertions
- Remove the cap on pool size
- Switch from alloc/free to init/finiv3:
- Idiomatic looping structure in_fini
- Correct handling of purged objects
- Don't return a buffer that's too much larger than neededv4:
- Rebased to latest -nightlyv5:
- Remove_put()function and clean up comments to matchSigned-off-by Brad Volkin <[email protected]>--- Documentation/DocBook/drm.tmpl | 5 + drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/i915_drv.h | 15 +++ drivers/gpu/drm/i915/i915_gem.c | 1 + drivers/gpu/drm/i915/i915_gem_batch_pool.c | 152 +++++++++++++++++++++++++++++ 5 files changed, 174 insertions(+) create mode 100644 drivers/gpu/drm/i915/i915_gem_batch_pool.cDocumentation/DocBook/drm.tmpl +5
-0@@ -3989,6 +3989,11 @@ int num_ioctls;</synopsis> !Idrivers/gpu/drm/i915/i915_cmd_parser.c </sect2> <sect2> + <title>Batchbuffer Pools</title> +!Pdrivers/gpu/drm/i915/i915_gem_batch_pool.c batch pool +!Idrivers/gpu/drm/i915/i915_gem_batch_pool.c + </sect2> + <sect2> <title>Logical Rings, Logical Ring Contexts and Execlists</title> !Pdrivers/gpu/drm/i915/intel_lrc.c Logical Rings, Logical Ring Contexts and Execlists !Idrivers/gpu/drm/i915/intel_lrc.cdrivers/gpu/drm/i915/Makefile +1
-0@@ -19,6 +19,7 @@ i915-$(CONFIG_DEBUG_FS) += i915_debugfs.o # GEM code i915-y += i915_cmd_parser.o \ + i915_gem_batch_pool.o \ i915_gem_context.o \ i915_gem_render_state.o \ i915_gem_debug.o \drivers/gpu/drm/i915/i915_drv.h +15
-0@@ -1134,6 +1134,12 @@ struct intel_l3_parity {int which_slice; }; +struct i915_gem_batch_pool { +struct drm_device *dev; +struct list_head active_list; +struct list_head inactive_list; +}; +struct i915_gem_mm {/** Memory allocator for GTT stolen memory */ struct drm_mm stolen;@@ -1865,6 +1871,8 @@ struct drm_i915_gem_object {/** Used in execbuf to temporarily hold a ref */ struct list_head obj_exec_link; +struct list_head batch_pool_list; +/** * This is set if the object is on the active lists (has pending * rendering and so a non-zero seqno), and is not set if it i s on @@ -2829,6 +2837,13 @@ void i915_destroy_error_state(struct drm_device *dev);void i915_get_extra_instdone (struct drm_device *dev,uint32_t *instdone);const char *i915_cache_level_str (struct drm_i915_private *i915,int type); +/* i915_gem_batch_pool.c */ +void i915_gem_batch_pool_init (struct drm_device *dev, +struct i915_gem_batch_pool *pool); +void i915_gem_batch_pool_fini (struct i915_gem_batch_pool *pool); +struct drm_i915_gem_object * +i915_gem_batch_pool_get (struct i915_gem_batch_pool *pool,size_t size); +/* i915_cmd_parser.c */ int i915_cmd_parser_get_version (void );int i915_cmd_parser_init_ring (struct intel_engine_cs *ring);drivers/gpu/drm/i915/i915_gem.c +1
-0@@ -4352,6 +4352,7 @@ void i915_gem_object_init(struct drm_i915_gem_object *obj,INIT_LIST_HEAD (&obj->ring_list);INIT_LIST_HEAD (&obj->obj_exec_link);INIT_LIST_HEAD (&obj->vma_list); +INIT_LIST_HEAD (&obj->batch_pool_list); obj->ops = ops;drivers/gpu/drm/i915/i915_gem_batch_pool.c new file +128
-0@@ -0,0 +1,152 @@ +/* +* Copyright © 2014 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +* IN THE SOFTWARE. +* +*/ + +#include "i915_drv.h" + +/** +* DOC: batch pool +* +* In order to submit batch buffers as 'secure', the software command parser +* must ensure that a batch buffer cannot be modified after parsing. It does +* this by copying the user provided batch buffer contents to a kernel owned +* buffer from which the hardware will actually execute, and by carefully +* managing the address space bindings for such buffers. +* +* The batch pool framework provides a mechanism for the driver to manage a +* set of scratch buffers to use for this purpose. The framework can be +* extended to support other uses cases should they arise. +*/ + +/** +* i915_gem_batch_pool_init() - initialize a batch buffer pool +* @dev: the drm device +* @pool: the batch buffer pool +*/ +void i915_gem_batch_pool_init (struct drm_device *dev, +struct i915_gem_batch_pool *pool) +{ + pool->dev = dev; +INIT_LIST_HEAD (&pool->active_list); +INIT_LIST_HEAD (&pool->inactive_list); +} + +/** +* i915_gem_batch_pool_fini() - clean up a batch buffer pool +* @pool: the pool to clean up +* +* Note: Callers must hold the struct_mutex. +*/ +void i915_gem_batch_pool_fini (struct i915_gem_batch_pool *pool) +{ +WARN_ON (!mutex_is_locked (&pool->dev->struct_mutex)); + +while (!list_empty (&pool->active_list)) { +struct drm_i915_gem_object *obj = +list_first_entry (&pool->active_list, + struct drm_i915_gem_object, + batch_pool_list); + +WARN_ON (obj->active); + +list_del_init (&obj->batch_pool_list); +drm_gem_object_unreference (&obj->base); + } + +while (!list_empty (&pool->inactive_list)) { +struct drm_i915_gem_object *obj = +list_first_entry (&pool->inactive_list, + struct drm_i915_gem_object, + batch_pool_list); + +list_del_init (&obj->batch_pool_list); +drm_gem_object_unreference (&obj->base); + } +} + +/** +* i915_gem_batch_pool_get() - select a buffer from the pool +* @pool: the batch buffer pool +* @size: the minimum desired size of the returned buffer +* +* Finds or allocates a batch buffer in the pool with at least the requested +* size. The caller is responsible for any domain, active/inactive, or +* purgeability management for the returned buffer. +* +* Note: Callers must hold the struct_mutex +* +* Return: the selected batch buffer object +*/ +struct drm_i915_gem_object * +i915_gem_batch_pool_get (struct i915_gem_batch_pool *pool, +size_t size) +{ +struct drm_i915_gem_object *obj =NULL ; +struct drm_i915_gem_object *tmp, *next; +bool was_purged; + +WARN_ON (!mutex_is_locked (&pool->dev->struct_mutex)); + +list_for_each_entry_safe (tmp, next, + &pool->active_list, batch_pool_list) { +if (!tmp->active) +list_move_tail (&tmp->batch_pool_list, + &pool->inactive_list); + } + + do { + was_purged = false; + + list_for_each_entry(tmp, &pool->inactive_list, batch_pool_list) { + /* + * Select a buffer that is at least as big as needed + * but not 'too much' bigger. A better way to do this + * might be to bucket the pool objects based on size. + */ + if (tmp->base.size >= size && + tmp->base.size <= (2 * size)) { + obj = tmp;
drivers/gpu/drm/i915/i915_gem_batch_pool.c line 138
Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_batch_pool.c new file +10
-0+break ; + } + } + +if (obj && obj->madv == __I915_MADV_PURGED) { + was_purged = true; +list_del (&obj->batch_pool_list); +drm_gem_object_unreference (&obj->base); + obj =NULL ; + }
Minor issue: We should move the purged check into the loop so that purge buffer structs get released even when they're too small/big. Otherwise we'll have a good chance to hang onto gobloads of structs forever. -Daniel
Quoted 21 lines
drivers/gpu/drm/i915/i915_gem_batch_pool.c new file +14
-0+ }while (was_purged); + +if (!obj) { + obj =i915_gem_alloc_object (pool->dev, size); +if (!obj) +return ERR_PTR (-ENOMEM ); + +list_add_tail (&obj->batch_pool_list, &pool->inactive_list); + } + +list_move_tail (&obj->batch_pool_list, &pool->active_list); + +return obj; +}Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v4 1/7] drm/i915: Implement a framework for batch buffer pools
Quoted 11 lines · Daniel Vetter
drivers/gpu/drm/i915/i915_gem_batch_pool.c line 138
Quoted 6 lines · On Fri, Nov 07, 2014 at 02:22:01PM -0800, [email protected] wrote:
drivers/gpu/drm/i915/i915_gem_batch_pool.c new file +6
-0+if (obj && obj->madv == __I915_MADV_PURGED) { + was_purged = true; +list_del (&obj->batch_pool_list); +drm_gem_object_unreference (&obj->base); + obj =NULL ; + }Minor issue: We should move the purged check into the loop so that purge buffer structs get released even when they're too small/big. Otherwise we'll have a good chance to hang onto gobloads of structs forever.
I mentioned that we should do the purge of structs in our oom-notifier as well to be safe.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v4 1/7] drm/i915: Implement a framework for batch buffer pools
Quoted 9 lines · Chris Wilson
Quoted 8 lines · Daniel Vetter
Quoted 6 lines · On Fri, Nov 07, 2014 at 02:22:01PM -0800, [email protected] wrote:
drivers/gpu/drm/i915/i915_gem_batch_pool.c new file +6
-0+if (obj && obj->madv == __I915_MADV_PURGED) { + was_purged = true; +list_del (&obj->batch_pool_list); +drm_gem_object_unreference (&obj->base); + obj =NULL ; + }
Quoted 6 lines
Quoted 3 lines
Minor issue: We should move the purged check into the loop so that purge buffer structs get released even when they're too small/big. Otherwise we'll have a good chance to hang onto gobloads of structs forever.
I mentioned that we should do the purge of structs in our oom-notifier as well to be safe.
Given that we don't purge the sturcts for userspace purged objects (we could just clear everything but the idr slot and mark it specially) I don't think we need this here. At least not until we have this for userspace bos since there's lots more of those I think. -Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v4 1/7] drm/i915: Implement a framework for batch buffer pools
Quoted 14 lines · Daniel Vetter
Quoted 13 lines · Chris Wilson
Quoted 11 lines · Daniel Vetter
drivers/gpu/drm/i915/i915_gem_batch_pool.c line 138
Quoted 6 lines · On Fri, Nov 07, 2014 at 02:22:01PM -0800, [email protected] wrote:
drivers/gpu/drm/i915/i915_gem_batch_pool.c new file +6
-0+if (obj && obj->madv == __I915_MADV_PURGED) { + was_purged = true; +list_del (&obj->batch_pool_list); +drm_gem_object_unreference (&obj->base); + obj =NULL ; + }Minor issue: We should move the purged check into the loop so that purge buffer structs get released even when they're too small/big. Otherwise we'll have a good chance to hang onto gobloads of structs forever.
Quoted 7 lines
Quoted 2 lines
I mentioned that we should do the purge of structs in our oom-notifier as well to be safe.
Given that we don't purge the sturcts for userspace purged objects (we could just clear everything but the idr slot and mark it specially) I don't think we need this here. At least not until we have this for userspace bos since there's lots more of those I think.
Well discarding userspace purged objects requires a special zombie handle, but these pure in-kernel structs we have complete control over and so are much simpler to clean up.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v4 1/7] drm/i915: Implement a framework for batch buffer pools
Hi Daniel, Chris
Quoted 11 lines · Chris Wilson
Quoted 10 lines · Daniel Vetter
Quoted 9 lines · Chris Wilson
Quoted 8 lines · Daniel Vetter
Quoted 6 lines · On Fri, Nov 07, 2014 at 02:22:01PM -0800, [email protected] wrote:
drivers/gpu/drm/i915/i915_gem_batch_pool.c new file +6
-0+if (obj && obj->madv == __I915_MADV_PURGED) { + was_purged = true; +list_del (&obj->batch_pool_list); +drm_gem_object_unreference (&obj->base); + obj =NULL ; + }
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Minor issue: We should move the purged check into the loop so that purge buffer structs get released even when they're too small/big. Otherwise we'll have a good chance to hang onto gobloads of structs forever.
I mentioned that we should do the purge of structs in our oom-notifier as well to be safe.
I understand Daniel's suggestion to move the purge check into the loop (will do that) but I'm not familiar w/ the oom-notifier at all and so don't know how to do what Chris is asking w/ out ramping up. Is it not critical, follow up type work or is it absolutely necessary to have before merge? It sounded like the first.
Thx,
Mike
Quoted 11 lines
Quoted 5 lines
Given that we don't purge the sturcts for userspace purged objects (we could just clear everything but the idr slot and mark it specially) I don't think we need this here. At least not until we have this for userspace bos since there's lots more of those I think.
Well discarding userspace purged objects requires a special zombie handle, but these pure in-kernel structs we have complete control over and so are much simpler to clean up.
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v4 1/7] drm/i915: Implement a framework for batch buffer pools
Quoted 18 lines · Michael H. Nguyen
Hi Daniel, Chris
Quoted 15 lines · Chris Wilson
Quoted 14 lines · Daniel Vetter
Quoted 13 lines · Chris Wilson
Quoted 11 lines · Daniel Vetter
drivers/gpu/drm/i915/i915_gem_batch_pool.c line 138
Quoted 6 lines · On Fri, Nov 07, 2014 at 02:22:01PM -0800, [email protected] wrote:
drivers/gpu/drm/i915/i915_gem_batch_pool.c new file +6
-0+if (obj && obj->madv == __I915_MADV_PURGED) { + was_purged = true; +list_del (&obj->batch_pool_list); +drm_gem_object_unreference (&obj->base); + obj =NULL ; + }Minor issue: We should move the purged check into the loop so that purge buffer structs get released even when they're too small/big. Otherwise we'll have a good chance to hang onto gobloads of structs forever.
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
I mentioned that we should do the purge of structs in our oom-notifier as well to be safe.
I understand Daniel's suggestion to move the purge check into the loop (will do that) but I'm not familiar w/ the oom-notifier at all and so don't know how to do what Chris is asking w/ out ramping up. Is it not critical, follow up type work or is it absolutely necessary to have before merge? It sounded like the first.
Imo the oom integration isn't critical and we can do that if we ever have a workload where this matters. And my gut suspicion is that mostly we'll get away with normal shrinking as already implemented. -Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v4 1/7] drm/i915: Implement a framework for batch buffer pools
In reply to [email protected]Quoted 6 lines · On Fri, Nov 07, 2014 at 02:22:01PM -0800, [email protected] wrote:
drivers/gpu/drm/i915/i915_gem_batch_pool.c new file +6
-0+struct drm_i915_gem_object * +i915_gem_batch_pool_get (struct i915_gem_batch_pool *pool, +size_t size) +{ +struct drm_i915_gem_object *obj =NULL ; +struct drm_i915_gem_object *tmp, *next;
drivers/gpu/drm/i915/i915_gem_batch_pool.c line 115
Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_batch_pool.c new file +10
-0+bool was_purged; + +WARN_ON (!mutex_is_locked (&pool->dev->struct_mutex)); + +list_for_each_entry_safe (tmp, next, + &pool->active_list, batch_pool_list) { +if (!tmp->active) +list_move_tail (&tmp->batch_pool_list, + &pool->inactive_list); + }
So we don't need two lists then?
Quoted 13 lines
drivers/gpu/drm/i915/i915_gem_batch_pool.c new file +13
-0+ do { + was_purged = false; + + list_for_each_entry(tmp, &pool->inactive_list, batch_pool_list) { + /* + * Select a buffer that is at least as big as needed + * but not 'too much' bigger. A better way to do this + * might be to bucket the pool objects based on size. + */ + if (tmp->base.size >= size && + tmp->base.size <= (2 * size)) { + obj = tmp; + break;
drivers/gpu/drm/i915/i915_gem_batch_pool.c line 139
Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_batch_pool.c new file +10
-0+ } + } + +if (obj && obj->madv == __I915_MADV_PURGED) { + was_purged = true; +list_del (&obj->batch_pool_list); +drm_gem_object_unreference (&obj->base); + obj =NULL ; + } + }while (was_purged);
You stop searching if you find an inactive buffer too big or too small?
drivers/gpu/drm/i915/i915_gem_batch_pool.c line 144
Quoted 5 lines
drivers/gpu/drm/i915/i915_gem_batch_pool.c new file +5
-0+ +if (!obj) { + obj =i915_gem_alloc_object (pool->dev, size); +if (!obj) +return ERR_PTR (-ENOMEM );
Grag pages and set the madv here, don't ever worry about it again later.
drivers/gpu/drm/i915/i915_gem_batch_pool.c line 146
Quoted 1 line
drivers/gpu/drm/i915/i915_gem_batch_pool.c new file +1
-0+list_add_tail (&obj->batch_pool_list, &pool->inactive_list);
Redundant.
Quoted 6 lines
drivers/gpu/drm/i915/i915_gem_batch_pool.c new file +6
-0+ } + +list_move_tail (&obj->batch_pool_list, &pool->active_list); + +return obj; +}
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 2/7 drm/i915: Use batch pools with the command parser
In reply to [email protected]From: Brad Volkin <[email protected]>
This patch sets up all of the tracking and copying necessary to use batch pools with the command parser and dispatches the copied (shadow) batch to the hardware.
After this patch, the parser is in 'enabling' mode.
Note that performance takes a hit from the copy in some cases and will likely need some work. At a rough pass, the memcpy appears to be the bottleneck. Without having done a deeper analysis, two ideas that come to mind are:
1) Copy sections of the batch at a time, as they are reached by parsing. Might improve cache locality.
2) Copy only up to the userspace-supplied batch length and memset the rest of the buffer. Reduces the number of reads.
v2:
- Remove setting the capacity of the pool
- One global pool instead of per-ring pools
- Replace batch_obj with shadow_batch_obj and hook into eb->vmas
- Memset any space in the shadow batch beyond what gets copied
- Rebased on execlist prep refactoring
v3:
- Rebase on chained batch handling
- Squash in setting the secure dispatch flag
- Add a note about the interaction w/secure dispatch pinning
- Check for request->batch_obj == NULL in i915_gem_free_request
v4:
- Fix read domains for shadow_batch_obj
- Remove the set_to_gtt_domain call from i915_parse_cmds
- ggtt_pin/unpin in the parser block to simplify error handling
- Check USES_FULL_PPGTT before setting DISPATCH_SECURE flag
- Remove i915_gem_batch_pool_put calls
--- drivers/gpu/drm/i915/i915_cmd_parser.c | 79 +++++++++++++++++++++++------- drivers/gpu/drm/i915/i915_dma.c | 1 + drivers/gpu/drm/i915/i915_drv.h | 8 +++ drivers/gpu/drm/i915/i915_gem.c | 2 + drivers/gpu/drm/i915/i915_gem_execbuffer.c | 49 ++++++++++++++++-- 5 files changed, 117 insertions(+), 22 deletions(-)
drivers/gpu/drm/i915/i915_cmd_parser.c +62 -17
@@ -838,6 +838,56 @@ finish:return (u32 *)addr; } +/* Returns a vmap'd pointer to dest_obj, which the caller must unmap */ +static u32 *copy_batch (struct drm_i915_gem_object *dest_obj, +struct drm_i915_gem_object *src_obj) +{ +int ret =0 ; +int needs_clflush =0 ; +u32 *src_addr, *dest_addr =NULL ; + + ret =i915_gem_obj_prepare_shmem_read (src_obj, &needs_clflush); +if (ret) { +DRM_DEBUG_DRIVER ("CMD: failed to prep read\n" ); +return ERR_PTR (ret); + } + + src_addr =vmap_batch (src_obj); +if (!src_addr) { +DRM_DEBUG_DRIVER ("CMD: Failed to vmap batch\n" ); + ret = -ENOMEM ; + goto unpin_src; + } + +if (needs_clflush) +drm_clflush_virt_range ((char *)src_addr, src_obj->base.size); + + ret =i915_gem_object_set_to_cpu_domain (dest_obj, true); +if (ret) { +DRM_DEBUG_DRIVER ("CMD: Failed to set batch CPU domain\n" ); + goto unmap_src; + } + + dest_addr =vmap_batch (dest_obj); +if (!dest_addr) { +DRM_DEBUG_DRIVER ("CMD: Failed to vmap shadow batch\n" ); + ret = -ENOMEM ; + goto unmap_src; + } + +memcpy (dest_addr, src_addr, src_obj->base.size); +if (dest_obj->base.size > src_obj->base.size) +memset ((u8 *)dest_addr + src_obj->base.size,0 , + dest_obj->base.size - src_obj->base.size); + +unmap_src: +vunmap (src_addr); +unpin_src: +i915_gem_object_unpin_pages (src_obj); + +return ret ?ERR_PTR (ret) : dest_addr; +} +/** * i915_needs_cmd_parser() - should a given ring use software command parsing? * @ring: the ring in question
@@ -954,6 +1004,7 @@ static bool check_cmd(const struct intel_engine_cs *ring,* i915_parse_cmds() - parse a submitted batch buffer for privilege violations * @ring: the ring on which the batch is to execute * @batch_obj: the batch buffer in question +* @shadow_batch_obj: copy of the batch buffer in question * @batch_start_offset: byte offset in the batch at which execution starts * @is_master: is the submitting process the drm master? *
@@ -965,32 +1016,28 @@ static bool check_cmd(const struct intel_engine_cs *ring,*/ int i915_parse_cmds (struct intel_engine_cs *ring,struct drm_i915_gem_object *batch_obj, +struct drm_i915_gem_object *shadow_batch_obj,u32 batch_start_offset,bool is_master) {int ret =0 ;u32 *cmd, *batch_base, *batch_end;struct drm_i915_cmd_descriptor default_desc = {0 }; -int needs_clflush =0 ;bool oacontrol_set = false;/* OACONTROL tracking. See check_cmd() */ - ret =i915_gem_obj_prepare_shmem_read (batch_obj, &needs_clflush); -if (ret) { -DRM_DEBUG_DRIVER ("CMD: failed to prep read\n" ); -return ret; + batch_base =copy_batch (shadow_batch_obj, batch_obj); +if (IS_ERR (batch_base)) { +DRM_DEBUG_DRIVER ("CMD: Failed to copy batch\n" ); +return PTR_ERR (batch_base); } - batch_base =vmap_batch (batch_obj); -if (!batch_base) { -DRM_DEBUG_DRIVER ("CMD: Failed to vmap batch\n" ); -i915_gem_object_unpin_pages (batch_obj); -return -ENOMEM ; - } - -if (needs_clflush) -drm_clflush_virt_range ((char *)batch_base, batch_obj->base.size); - cmd = batch_base + (batch_start_offset /sizeof (*cmd)); + +/* +* We use the source object's size because the shadow object is as +* large or larger and copy_batch() will write MI_NOPs to the extra +* space. Parsing should be faster in some cases this way. +*/ batch_end = cmd + (batch_obj->base.size /sizeof (*batch_end));while (cmd < batch_end) {
@@ -1052,8 +1099,6 @@ int i915_parse_cmds(struct intel_engine_cs *ring,vunmap (batch_base); -i915_gem_object_unpin_pages (batch_obj); -return ret; }
drivers/gpu/drm/i915/i915_dma.c +1 -0
@@ -1891,6 +1891,7 @@ int i915_driver_unload(struct drm_device *dev)mutex_lock (&dev->struct_mutex);i915_gem_cleanup_ringbuffer (dev); +i915_gem_batch_pool_fini (&dev_priv->mm.batch_pool);i915_gem_context_fini (dev);mutex_unlock (&dev->struct_mutex);i915_gem_cleanup_stolen (dev);
drivers/gpu/drm/i915/i915_drv.h +8 -0
@@ -1153,6 +1153,13 @@ struct i915_gem_mm {*/ struct list_head unbound_list; +/* +* A pool of objects to use as shadow copies of client batch buffers +* when the command parser is enabled. Prevents the client from +* modifying the batch contents after software parsing. +*/ +struct i915_gem_batch_pool batch_pool; +/** Usable portion of the GTT for GEM */ unsigned long stolen_base;/* limited to low memory (32-bit) */
@@ -2851,6 +2858,7 @@ void i915_cmd_parser_fini_ring(struct intel_engine_cs *ring);bool i915_needs_cmd_parser (struct intel_engine_cs *ring);int i915_parse_cmds (struct intel_engine_cs *ring,struct drm_i915_gem_object *batch_obj, +struct drm_i915_gem_object *shadow_batch_obj,u32 batch_start_offset,bool is_master);
drivers/gpu/drm/i915/i915_gem.c +2 -0
@@ -5034,6 +5034,8 @@ i915_gem_load(struct drm_device *dev) dev_priv->mm.oom_notifier.notifier_call = i915_gem_shrinker_oom;register_oom_notifier (&dev_priv->mm.oom_notifier); +i915_gem_batch_pool_init (dev, &dev_priv->mm.batch_pool); +mutex_init (&dev_priv->fb_tracking.lock); }
drivers/gpu/drm/i915/i915_gem_execbuffer.c +44 -5
72 lines not on this page · raw message
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v4 2/7] drm/i915: Use batch pools with the command parser
Quoted 75 lines · On Fri, Nov 07, 2014 at 02:22:02PM -0800, [email protected] wrote:
From: Brad Volkin <[email protected]>
This patch sets up all of the tracking and copying necessary to use batch pools with the command parser and dispatches the copied (shadow) batch to the hardware.
After this patch, the parser is in 'enabling' mode.
Note that performance takes a hit from the copy in some cases and will likely need some work. At a rough pass, the memcpy appears to be the bottleneck. Without having done a deeper analysis, two ideas that come to mind are:
1) Copy sections of the batch at a time, as they are reached by parsing. Might improve cache locality.
2) Copy only up to the userspace-supplied batch length and memset the rest of the buffer. Reduces the number of reads.v2:
- Remove setting the capacity of the pool
- One global pool instead of per-ring pools
- Replacebatch_objwithshadow_batch_objand hook intoeb->vmas
- Memset any space in the shadow batch beyond what gets copied
- Rebased on execlist prep refactoringv3:
- Rebase on chained batch handling
- Squash in setting the secure dispatch flag
- Add a note about the interaction w/secure dispatch pinning
- Check forrequest->batch_obj== NULL ini915_gem_free_requestv4:
- Fix read domains forshadow_batch_obj
- Remove theset_to_gtt_domaincall fromi915_parse_cmds
- ggtt_pin/unpin in the parser block to simplify error handling
- CheckUSES_FULL_PPGTTbefore settingDISPATCH_SECUREflag
- Removei915_gem_batch_pool_putcallsSigned-off-by Brad Volkin <[email protected]>--- drivers/gpu/drm/i915/i915_cmd_parser.c | 79 +++++++++++++++++++++++------- drivers/gpu/drm/i915/i915_dma.c | 1 + drivers/gpu/drm/i915/i915_drv.h | 8 +++ drivers/gpu/drm/i915/i915_gem.c | 2 + drivers/gpu/drm/i915/i915_gem_execbuffer.c | 49 ++++++++++++++++-- 5 files changed, 117 insertions(+), 22 deletions(-)drivers/gpu/drm/i915/i915_cmd_parser.c +21
-0@@ -838,6 +838,56 @@ finish:return (u32 *)addr; } +/* Returns a vmap'd pointer to dest_obj, which the caller must unmap */ +static u32 *copy_batch (struct drm_i915_gem_object *dest_obj, +struct drm_i915_gem_object *src_obj) +{ +int ret =0 ; +int needs_clflush =0 ; +u32 *src_addr, *dest_addr =NULL ; + + ret =i915_gem_obj_prepare_shmem_read (src_obj, &needs_clflush); +if (ret) { +DRM_DEBUG_DRIVER ("CMD: failed to prep read\n" ); +return ERR_PTR (ret); + } + + src_addr =vmap_batch (src_obj); +if (!src_addr) { +DRM_DEBUG_DRIVER ("CMD: Failed to vmap batch\n" ); + ret = -ENOMEM ; + goto unpin_src; + } +
drivers/gpu/drm/i915/i915_cmd_parser.c finish: · line 871
Quoted 10 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +10
-0+if (needs_clflush) +drm_clflush_virt_range ((char *)src_addr, src_obj->base.size); + + ret =i915_gem_object_set_to_cpu_domain (dest_obj, true); +if (ret) { +DRM_DEBUG_DRIVER ("CMD: Failed to set batch CPU domain\n" ); + goto unmap_src; + } + + dest_addr =vmap_batch (dest_obj);
Considering that this does a straightforward copy (if we ignore the highly dubious memset), any chance of a kmap_atomic(); copy_page(); loop? (Modulo first/last pages which may not be aligned.) -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 3/7 drm/i915: Add a batch pool debugfs file
In reply to [email protected]From: Brad Volkin <[email protected]>
It provides some useful information about the buffers in the global command parser batch pool.
v2: rebase on global pool instead of per-ring pools
v3: rebase
--- drivers/gpu/drm/i915/i915_debugfs.c | 41 +++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
drivers/gpu/drm/i915/i915_debugfs.c +41 -0
@@ -582,6 +582,46 @@ static int i915_gem_pageflip_info(struct seq_file *m, void *data)return 0 ; } +static int i915_gem_batch_pool_info (struct seq_file *m,void *data) +{ +struct drm_info_node *node = m->private; +struct drm_device *dev = node->minor->dev; +struct drm_i915_private *dev_priv = dev->dev_private; +struct drm_i915_gem_object *obj; +int count =0 ; +int ret; + + ret =mutex_lock_interruptible (&dev->struct_mutex); +if (ret) +return ret; + +seq_puts (m,"active:\n" ); +list_for_each_entry (obj, + &dev_priv->mm.batch_pool.active_list, + batch_pool_list) { +seq_puts (m," " ); +describe_obj (m, obj); +seq_putc (m,'\n' ); + count++; + } + +seq_puts (m,"inactive:\n" ); +list_for_each_entry (obj, + &dev_priv->mm.batch_pool.inactive_list, + batch_pool_list) { +seq_puts (m," " ); +describe_obj (m, obj); +seq_putc (m,'\n' ); + count++; + } + +seq_printf (m,"total: %d\n" , count); + +mutex_unlock (&dev->struct_mutex); + +return 0 ; +} +static int i915_gem_request_info (struct seq_file *m,void *data) {struct drm_info_node *node = m->private;
@@ -4262,6 +4302,7 @@ static const struct drm_info_list i915_debugfs_list[] = { {"i915_gem_hws_blt", i915_hws_info, 0, (void *)BCS}, {"i915_gem_hws_bsd", i915_hws_info, 0, (void *)VCS}, {"i915_gem_hws_vebox", i915_hws_info, 0, (void *)VECS}, + {"i915_gem_batch_pool", i915_gem_batch_pool_info, 0}, {"i915_frequency_info", i915_frequency_info, 0}, {"i915_drpc_info", i915_drpc_info, 0}, {"i915_emon_status", i915_emon_status, 0},
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 4/7 drm/i915: Add batch pool details to i915_gem_objects debugfs
In reply to [email protected]From: Brad Volkin <[email protected]>
To better account for the potentially large memory consumption of the batch pool.
--- drivers/gpu/drm/i915/i915_debugfs.c | 45 +++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 9 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +36 -9
@@ -360,6 +360,38 @@ static int per_file_stats(int id, void *ptr, void *data)return 0 ; } +#define print_file_stats (m, name, stats) \ + seq_printf(m, "%s: %u objects, %zu bytes (%zu active, %zu inactive, %zu global, %zu shared, %zu unbound)\n", \ + name, \ + stats.count, \ + stats.total, \ + stats.active, \ + stats.inactive, \ + stats.global, \ + stats.shared, \ + stats.unbound) + +static void print_batch_pool_stats (struct seq_file *m, +struct drm_i915_private *dev_priv) +{ +struct drm_i915_gem_object *obj; +struct file_stats stats; + +memset (&stats,0 ,sizeof (stats)); + +list_for_each_entry (obj, + &dev_priv->mm.batch_pool.active_list, + batch_pool_list) +per_file_stats (0 , obj, &stats); + +list_for_each_entry (obj, + &dev_priv->mm.batch_pool.inactive_list, + batch_pool_list) +per_file_stats (0 , obj, &stats); + +print_file_stats (m,"batch pool" , stats); +} +#define count_vmas (list, member) do { \ list_for_each_entry(vma, list, member) { \ size += i915_gem_obj_ggtt_size(vma->obj); \
@@ -442,6 +474,9 @@ static int i915_gem_object_info(struct seq_file *m, void* data) dev_priv->gtt.mappable_end - dev_priv->gtt.base.start);seq_putc (m,'\n' ); +print_batch_pool_stats (m, dev_priv); + +seq_putc (m,'\n' );list_for_each_entry_reverse (file, &dev->filelist, lhead) {struct file_stats stats;struct task_struct *task;
@@ -459,15 +494,7 @@ static int i915_gem_object_info(struct seq_file *m, void* data)*/ rcu_read_lock (); task =pid_task (file->pid,PIDTYPE_PID ); -seq_printf (m,"%s: %u objects, %zu bytes (%zu active, %zu inactive, %zu global, %zu shared, %zu unbound)\n" , - task ? task->comm :"<unknown>" , - stats.count, - stats.total, - stats.active, - stats.inactive, - stats.global, - stats.shared, - stats.unbound); +print_file_stats (m, task ? task->comm :"<unknown>" , stats);rcu_read_unlock (); }
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 5/7 drm/i915: Use batch length instead of object size in command parser
In reply to [email protected]From: Brad Volkin <[email protected]>
Previously we couldn't trust the user-supplied batch length because it came directly from userspace (i.e. untrusted code). It would have affected what commands software parsed without regard to what hardware would actually execute, leaving a potential hole.
With the parser now copying the user supplied batch buffer and writing MI_NOP commands to any space after the copied region, we can safely use the batch length input. This should be a performance win as the actual batch length is frequently much smaller than the allocated object size.
v2: Fix handling of non-zero batch_start_offset
--- drivers/gpu/drm/i915/i915_cmd_parser.c | 48 ++++++++++++++++++++---------- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/i915_gem_execbuffer.c | 1 + 3 files changed, 34 insertions(+), 16 deletions(-)
drivers/gpu/drm/i915/i915_cmd_parser.c +32 -16
@@ -840,11 +840,19 @@ finish:/* Returns a vmap'd pointer to dest_obj, which the caller must unmap */ static u32 *copy_batch (struct drm_i915_gem_object *dest_obj, -struct drm_i915_gem_object *src_obj) +struct drm_i915_gem_object *src_obj, +u32 batch_start_offset, +u32 batch_len) {int ret =0 ;int needs_clflush =0 ; -u32 *src_addr, *dest_addr =NULL ; +u32 *src_base, *dest_base =NULL ; +u32 *src_addr, *dest_addr; +u32 offset = batch_start_offset /sizeof (*dest_addr); +u32 end = batch_start_offset + batch_len; + +if (end > dest_obj->base.size || end > src_obj->base.size) +return ERR_PTR (-E2BIG ); ret =i915_gem_obj_prepare_shmem_read (src_obj, &needs_clflush);if (ret) {
@@ -852,15 +860,17 @@ static u32 *copy_batch(struct drm_i915_gem_object *dest_obj,return ERR_PTR (ret); } - src_addr =vmap_batch (src_obj); -if (!src_addr) { + src_base =vmap_batch (src_obj); +if (!src_base) {DRM_DEBUG_DRIVER ("CMD: Failed to vmap batch\n" ); ret = -ENOMEM ; goto unpin_src; } + src_addr = src_base + offset; +if (needs_clflush) -drm_clflush_virt_range ((char *)src_addr, src_obj->base.size); +drm_clflush_virt_range ((char *)src_addr, batch_len); ret =i915_gem_object_set_to_cpu_domain (dest_obj, true);if (ret) {
@@ -868,24 +878,27 @@ static u32 *copy_batch(struct drm_i915_gem_object *dest_obj, goto unmap_src; } - dest_addr =vmap_batch (dest_obj); -if (!dest_addr) { + dest_base =vmap_batch (dest_obj); +if (!dest_base) {DRM_DEBUG_DRIVER ("CMD: Failed to vmap shadow batch\n" ); ret = -ENOMEM ; goto unmap_src; } -memcpy (dest_addr, src_addr, src_obj->base.size); -if (dest_obj->base.size > src_obj->base.size) -memset ((u8 *)dest_addr + src_obj->base.size,0 , - dest_obj->base.size - src_obj->base.size); + dest_addr = dest_base + offset; + +if (batch_start_offset !=0 ) +memset ((u8 *)dest_base,0 , batch_start_offset); + +memcpy (dest_addr, src_addr, batch_len); +memset ((u8 *)dest_addr + batch_len,0 , dest_obj->base.size - end); unmap_src: -vunmap (src_addr); +vunmap (src_base); unpin_src:i915_gem_object_unpin_pages (src_obj); -return ret ?ERR_PTR (ret) : dest_addr; +return ret ?ERR_PTR (ret) : dest_base; }/**
@@ -1006,6 +1019,7 @@ static bool check_cmd(const struct intel_engine_cs *ring,* @batch_obj: the batch buffer in question * @shadow_batch_obj: copy of the batch buffer in question * @batch_start_offset: byte offset in the batch at which execution starts +* @batch_len: length of the commands in batch_obj * @is_master: is the submitting process the drm master? * * Parses the specified batch buffer looking for privilege violations as
@@ -1018,6 +1032,7 @@ int i915_parse_cmds(struct intel_engine_cs *ring,struct drm_i915_gem_object *batch_obj, struct drm_i915_gem_object *shadow_batch_obj, u32 batch_start_offset, + u32 batch_len, bool is_master) { int ret = 0;
@@ -1025,7 +1040,8 @@ int i915_parse_cmds(struct intel_engine_cs *ring,struct drm_i915_cmd_descriptor default_desc = {0 };bool oacontrol_set = false;/* OACONTROL tracking. See check_cmd() */ - batch_base =copy_batch (shadow_batch_obj, batch_obj); + batch_base =copy_batch (shadow_batch_obj, batch_obj, + batch_start_offset, batch_len);if (IS_ERR (batch_base)) {DRM_DEBUG_DRIVER ("CMD: Failed to copy batch\n" );return PTR_ERR (batch_base);
@@ -1034,11 +1050,11 @@ int i915_parse_cmds(struct intel_engine_cs *ring, cmd = batch_base + (batch_start_offset /sizeof (*cmd));/* -* We use the source object's size because the shadow object is as +* We use the batch length as size because the shadow object is as * large or larger and copy_batch() will write MI_NOPs to the extra * space. Parsing should be faster in some cases this way. */ - batch_end = cmd + (batch_obj->base.size /sizeof (*batch_end)); + batch_end = cmd + (batch_len /sizeof (*batch_end));while (cmd < batch_end) {const struct drm_i915_cmd_descriptor *desc;
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -2860,6 +2860,7 @@ int i915_parse_cmds(struct intel_engine_cs *ring,struct drm_i915_gem_object *batch_obj, struct drm_i915_gem_object *shadow_batch_obj, u32 batch_start_offset, + u32 batch_len, bool is_master);/* i915_suspend.c */
drivers/gpu/drm/i915/i915_gem_execbuffer.c +1 -0
@@ -1381,6 +1381,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, batch_obj, shadow_batch_obj, args->batch_start_offset, + args->batch_len, file->is_master);i915_gem_object_ggtt_unpin (shadow_batch_obj);
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 6/7 drm/i915: Mark shadow batch buffers as purgeable
In reply to [email protected]From: Brad Volkin <[email protected]>
By adding a new exec_entry flag, we cleanly mark the shadow objects as purgeable after they are on the active list.
--- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem_execbuffer.c +10 -1
@@ -37,6 +37,7 @@#define __EXEC_OBJECT_HAS_FENCE (1<<30)#define __EXEC_OBJECT_NEEDS_MAP (1<<29)#define __EXEC_OBJECT_NEEDS_BIAS (1<<28) +#define __EXEC_OBJECT_PURGEABLE (1<<27)#define BATCH_OFFSET_BIAS (256*1024)
@@ -223,7 +224,12 @@ i915_gem_execbuffer_unreserve_vma(struct i915_vma *vma)if (entry->flags & __EXEC_OBJECT_HAS_PIN) vma->pin_count--; - entry->flags &= ~(__EXEC_OBJECT_HAS_FENCE | __EXEC_OBJECT_HAS_PIN); +if (entry->flags & __EXEC_OBJECT_PURGEABLE) + obj->madv =I915_MADV_DONTNEED ; + + entry->flags &= ~(__EXEC_OBJECT_HAS_FENCE | + __EXEC_OBJECT_HAS_PIN | + __EXEC_OBJECT_PURGEABLE); }static void eb_destroy (struct eb_vmas *eb)
@@ -1373,6 +1379,8 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, goto err; } + shadow_batch_obj->madv =I915_MADV_WILLNEED ; + ret =i915_gem_obj_ggtt_pin (shadow_batch_obj,4096 ,0 );if (ret) goto err;
@@ -1396,6 +1404,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, vma =i915_gem_obj_to_ggtt (shadow_batch_obj); vma->exec_entry = &shadow_exec_entry; + vma->exec_entry->flags = __EXEC_OBJECT_PURGEABLE;drm_gem_object_reference (&shadow_batch_obj->base);list_add_tail (&vma->exec_list, &eb->vmas);
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v4 6/7] drm/i915: Mark shadow batch buffers as purgeable
Quoted 37 lines · On Fri, Nov 07, 2014 at 02:22:06PM -0800, [email protected] wrote:
From: Brad Volkin <[email protected]>
By adding a new
exec_entryflag, we cleanly mark the shadow objects as purgeable after they are on the active list.Signed-off-by Brad Volkin <[email protected]>--- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/i915_gem_execbuffer.c +7
-1@@ -37,6 +37,7 @@#define __EXEC_OBJECT_HAS_FENCE (1<<30)#define __EXEC_OBJECT_NEEDS_MAP (1<<29)#define __EXEC_OBJECT_NEEDS_BIAS (1<<28) +#define __EXEC_OBJECT_PURGEABLE (1<<27)#define BATCH_OFFSET_BIAS (256*1024)@@ -223,7 +224,12 @@ i915_gem_execbuffer_unreserve_vma(struct i915_vma *vma)if (entry->flags & __EXEC_OBJECT_HAS_PIN) vma->pin_count--; - entry->flags &= ~(__EXEC_OBJECT_HAS_FENCE | __EXEC_OBJECT_HAS_PIN); +if (entry->flags & __EXEC_OBJECT_PURGEABLE) + obj->madv =I915_MADV_DONTNEED ; + + entry->flags &= ~(__EXEC_OBJECT_HAS_FENCE | + __EXEC_OBJECT_HAS_PIN | + __EXEC_OBJECT_PURGEABLE); }static void eb_destroy (struct eb_vmas *eb)
drivers/gpu/drm/i915/i915_gem_execbuffer.c i915_gem_do_execbuffer(struct drm_device *dev, void *data, · line 1383
Quoted 5 lines
drivers/gpu/drm/i915/i915_gem_execbuffer.c +2
-0@@ -1373,6 +1379,8 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, goto err; } + shadow_batch_obj->madv =I915_MADV_WILLNEED ; +
Imo this hunk should be int the pool _get function so that all the purgeable/willneed handling is in one place.
-Daniel
Quoted 18 lines
drivers/gpu/drm/i915/i915_gem_execbuffer.c +1
-0ret =i915_gem_obj_ggtt_pin (shadow_batch_obj,4096 ,0 );if (ret) goto err;@@ -1396,6 +1404,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, vma =i915_gem_obj_to_ggtt (shadow_batch_obj); vma->exec_entry = &shadow_exec_entry; + vma->exec_entry->flags = __EXEC_OBJECT_PURGEABLE;drm_gem_object_reference (&shadow_batch_obj->base);list_add_tail (&vma->exec_list, &eb->vmas);Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 7/7 drm/i915: Tidy up execbuffer command parsing code
In reply to [email protected]From: Brad Volkin <[email protected]>
Move it to a separate function since the main do_execbuffer function already has so much going on.
--- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 136 +++++++++++++++++------------ 1 file changed, 79 insertions(+), 57 deletions(-)
drivers/gpu/drm/i915/i915_gem_execbuffer.c +79 -57
@@ -1026,6 +1026,75 @@ i915_reset_gen7_sol_offsets(struct drm_device *dev,return 0 ; } +static struct drm_i915_gem_object * +i915_gem_execbuffer_parse (struct intel_engine_cs *ring, +struct drm_i915_gem_exec_object2 *shadow_exec_entry, +struct eb_vmas *eb, +struct drm_i915_gem_object *batch_obj, +u32 batch_start_offset, +u32 batch_len, +bool is_master, +u32 *flags) +{ +struct drm_i915_private *dev_priv =to_i915 (batch_obj->base.dev); +struct drm_i915_gem_object *shadow_batch_obj; +int ret; + + shadow_batch_obj =i915_gem_batch_pool_get (&dev_priv->mm.batch_pool, + batch_obj->base.size); +if (IS_ERR (shadow_batch_obj)) +return shadow_batch_obj; + + shadow_batch_obj->madv =I915_MADV_WILLNEED ; + + ret =i915_gem_obj_ggtt_pin (shadow_batch_obj,4096 ,0 ); +if (ret) + goto err; + + ret =i915_parse_cmds (ring, + batch_obj, + shadow_batch_obj, + batch_start_offset, + batch_len, + is_master); +i915_gem_object_ggtt_unpin (shadow_batch_obj); + +if (ret) { +if (ret == -EACCES ) +return batch_obj; + }else { +struct i915_vma *vma; + +memset (shadow_exec_entry,0 ,sizeof (*shadow_exec_entry)); + + vma =i915_gem_obj_to_ggtt (shadow_batch_obj); + vma->exec_entry = shadow_exec_entry; + vma->exec_entry->flags = __EXEC_OBJECT_PURGEABLE; +drm_gem_object_reference (&shadow_batch_obj->base); +list_add_tail (&vma->exec_list, &eb->vmas); + + shadow_batch_obj->base.pending_read_domains = + batch_obj->base.pending_read_domains; + +/* +* Set the DISPATCH_SECURE bit to remove the NON_SECURE +* bit from MI_BATCH_BUFFER_START commands issued in the +* dispatch_execbuffer implementations. We specifically +* don't want that set when the command parser is +* enabled. +* +* FIXME: with aliasing ppgtt, buffers that should only +* be in ggtt still end up in the aliasing ppgtt. remove +* this check when that is fixed. +*/ +if (USES_FULL_PPGTT (dev)) + *flags |=I915_DISPATCH_SECURE ; + } + +err: +return ret ?ERR_PTR (ret) : shadow_batch_obj; +} + int i915_gem_ringbuffer_submission(struct drm_device *dev, struct drm_file *file, struct intel_engine_cs *ring,
@@ -1242,7 +1311,6 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,struct drm_i915_private *dev_priv = dev->dev_private;struct eb_vmas *eb;struct drm_i915_gem_object *batch_obj; -struct drm_i915_gem_object *shadow_batch_obj =NULL ;struct drm_i915_gem_exec_object2 shadow_exec_entry;struct intel_engine_cs *ring;struct intel_context *ctx;
@@ -1369,63 +1437,17 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, batch_obj->base.pending_read_domains |=I915_GEM_DOMAIN_COMMAND ;if (i915_needs_cmd_parser (ring)) { - shadow_batch_obj = -i915_gem_batch_pool_get (&dev_priv->mm.batch_pool, - batch_obj->base.size); -if (IS_ERR (shadow_batch_obj)) { - ret =PTR_ERR (shadow_batch_obj); -/* Don't try to clean up the obj in the error path */ - shadow_batch_obj =NULL ; - goto err; - } - - shadow_batch_obj->madv =I915_MADV_WILLNEED ; - - ret =i915_gem_obj_ggtt_pin (shadow_batch_obj,4096 ,0 ); -if (ret) + batch_obj =i915_gem_execbuffer_parse (ring, + &shadow_exec_entry, + eb, + batch_obj, + args->batch_start_offset, + args->batch_len, + file->is_master, + &flags); +if (IS_ERR (batch_obj)) { + ret =PTR_ERR (batch_obj); goto err; - - ret =i915_parse_cmds (ring, - batch_obj, - shadow_batch_obj, - args->batch_start_offset, - args->batch_len, - file->is_master); -i915_gem_object_ggtt_unpin (shadow_batch_obj); - -if (ret) { -if (ret != -EACCES ) - goto err; - }else { -struct i915_vma *vma; - -memset (&shadow_exec_entry,0 , -sizeof (shadow_exec_entry)); - - vma =i915_gem_obj_to_ggtt (shadow_batch_obj); - vma->exec_entry = &shadow_exec_entry; - vma->exec_entry->flags = __EXEC_OBJECT_PURGEABLE; -drm_gem_object_reference (&shadow_batch_obj->base); -list_add_tail (&vma->exec_list, &eb->vmas); - - shadow_batch_obj->base.pending_read_domains = - batch_obj->base.pending_read_domains; - - batch_obj = shadow_batch_obj; - -/* -* Set the DISPATCH_SECURE bit to remove the NON_SECURE -* bit from MI_BATCH_BUFFER_START commands issued in the -* dispatch_execbuffer implementations. We specifically -* don't want that set when the command parser is -* enabled. -* -* FIXME: with aliasing ppgtt, buffers that should only -* be in ggtt still end up in the aliasing ppgtt. remove -* this check when that is fixed. -*/ -if (USES_FULL_PPGTT (dev)) - flags |=I915_DISPATCH_SECURE ; } }
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v4 7/7] drm/i915: Tidy up execbuffer command
-------------------------------------Summary-------------------------------------
Platform: baseline_drm_intel_nightly_pass_rate->patch_applied_pass_rate
BYT: pass/total=348/348->348/348
PNV: pass/total=325/328->324/328
ILK: pass/total=329/330->330/330
IVB: pass/total=538/546->534/546
SNB: pass/total=531/541->532/541
HSW: pass/total=476/487->471/487
BDW: pass/total=430/435->430/435
-------------------------------------Detailed-------------------------------------test_platform: test_suite, test_case, result_with_drm_intel_nightly(count, machine_id...)...->result_with_patch_applied(count, machine_id)...
PNV: Intel_gpu_tools, igt_gem_concurrent_blit_cpu-rcs-early-read-interruptible, DMESG_WARN(1, M25)PASS(6, M23M25) -> DMESG_WARN(1, M23)PASS(3, M23)
ILK: Intel_gpu_tools, igt_kms_flip_flip-vs-panning-vs-hang, DMESG_WARN(1, M26)PASS(6, M6) -> PASS(4, M6)
IVB: Intel_gpu_tools, igt_gem_exec_parse_cmd-crossing-page, FAIL(3, M34)PASS(1, M4) -> FAIL(1, M34)PASS(3, M34)
IVB: Intel_gpu_tools, igt_gem_madvise_dontneed-before-exec, FAIL(3, M34)PASS(1, M4) -> FAIL(1, M34)PASS(3, M34)
IVB: Intel_gpu_tools, igt_kms_pipe_crc_basic_hang-read-crc-pipe-B, PASS(4, M4M34) -> TIMEOUT(1, M34)PASS(3, M34)
IVB: Intel_gpu_tools, igt_kms_pipe_crc_basic_hang-read-crc-pipe-C, PASS(4, M4M34) -> TIMEOUT(1, M34)PASS(3, M34)
SNB: Intel_gpu_tools, igt_kms_cursor_crc_cursor-256x256-random, DMESG_WARN(1, M22)PASS(6, M35) -> PASS(4, M35)
HSW: Intel_gpu_tools, igt_gem_bad_reloc_negative-reloc, NSPT(1, M39)PASS(3, M39) -> NSPT(2, M39)PASS(2, M39)
HSW: Intel_gpu_tools, igt_gem_bad_reloc_negative-reloc-lut, PASS(4, M39) -> NSPT(1, M39)PASS(3, M39)
HSW: Intel_gpu_tools, igt_gem_exec_parse_cmd-crossing-page, FAIL(3, M39)PASS(1, M39) -> FAIL(1, M39)PASS(3, M39)
HSW: Intel_gpu_tools, igt_gem_madvise_dontneed-before-exec, FAIL(3, M39)PASS(1, M39) -> FAIL(1, M39)PASS(3, M39)
HSW: Intel_gpu_tools, igt_gem_reset_stats_close-pending-fork-reverse-render, PASS(4, M39) -> NO_RESULT(1, M39)PASS(3, M39)
HSW: Intel_gpu_tools, igt_kms_cursor_crc_cursor-128x128-onscreen, DMESG_WARN(2, M39)PASS(5, M19M39) -> PASS(4, M39)
HSW: Intel_gpu_tools, igt_kms_cursor_crc_cursor-256x256-offscreen, DMESG_WARN(1, M39)PASS(6, M19M39) -> DMESG_WARN(1, M39)PASS(3, M39)
HSW: Intel_gpu_tools, igt_kms_cursor_crc_cursor-256x256-onscreen, PASS(4, M39) -> DMESG_WARN(3, M39)PASS(1, M39)
HSW: Intel_gpu_tools, igt_kms_cursor_crc_cursor-64x64-offscreen, DMESG_WARN(2, M39)PASS(2, M39) -> DMESG_WARN(4, M39)
HSW: Intel_gpu_tools, igt_kms_cursor_crc_cursor-64x64-sliding, DMESG_WARN(1, M39)PASS(3, M39) -> DMESG_WARN(1, M39)PASS(3, M39)
HSW: Intel_gpu_tools, igt_kms_flip_dpms-vs-vblank-race, DMESG_WARN(2, M39)PASS(5, M19M39) -> PASS(4, M39)
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v4 7/7] drm/i915: Tidy up execbuffer command parsing code
In reply to [email protected]Quoted 32 lines · On Fri, Nov 07, 2014 at 02:22:07PM -0800, [email protected] wrote:
From: Brad Volkin <[email protected]>
Move it to a separate function since the main
do_execbufferfunction already has so much going on.Signed-off-by Brad Volkin <[email protected]>--- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 136 +++++++++++++++++------------ 1 file changed, 79 insertions(+), 57 deletions(-)drivers/gpu/drm/i915/i915_gem_execbuffer.c +14
-0@@ -1026,6 +1026,75 @@ i915_reset_gen7_sol_offsets(struct drm_device *dev,return 0 ; } +static struct drm_i915_gem_object * +i915_gem_execbuffer_parse (struct intel_engine_cs *ring, +struct drm_i915_gem_exec_object2 *shadow_exec_entry, +struct eb_vmas *eb, +struct drm_i915_gem_object *batch_obj, +u32 batch_start_offset, +u32 batch_len, +bool is_master, +u32 *flags) +{ +struct drm_i915_private *dev_priv =to_i915 (batch_obj->base.dev); +struct drm_i915_gem_object *shadow_batch_obj; +int ret; +
drivers/gpu/drm/i915/i915_gem_execbuffer.c i915_reset_gen7_sol_offsets(struct drm_device *dev, · line 1052
Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_execbuffer.c +10
-0+ shadow_batch_obj =i915_gem_batch_pool_get (&dev_priv->mm.batch_pool, + batch_obj->base.size); +if (IS_ERR (shadow_batch_obj)) +return shadow_batch_obj; + + shadow_batch_obj->madv =I915_MADV_WILLNEED ; + + ret =i915_gem_obj_ggtt_pin (shadow_batch_obj,4096 ,0 ); +if (ret) + goto err;
Pardon? This feels an implementation issue of i915_parse_cmds() and should be resolved there. Presumably you are not actually reading back through the GTT? That would be insane...
drivers/gpu/drm/i915/i915_gem_execbuffer.c i915_reset_gen7_sol_offsets(struct drm_device *dev, · line 1060
Quoted 7 lines
drivers/gpu/drm/i915/i915_gem_execbuffer.c +7
-0+ ret =i915_parse_cmds (ring, + batch_obj, + shadow_batch_obj, + batch_start_offset, + batch_len, + is_master); +i915_gem_object_ggtt_unpin (shadow_batch_obj);
Yet pin+unpin around the parser seems to serve no other purpose. -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v4 7/7] drm/i915: Tidy up execbuffer command parsing code
Hi Chris,
Quoted 30 lines
Quoted 15 lines
drivers/gpu/drm/i915/i915_gem_execbuffer.c +14
-0+static struct drm_i915_gem_object * +i915_gem_execbuffer_parse (struct intel_engine_cs *ring, +struct drm_i915_gem_exec_object2 *shadow_exec_entry, +struct eb_vmas *eb, +struct drm_i915_gem_object *batch_obj, +u32 batch_start_offset, +u32 batch_len, +bool is_master, +u32 *flags) +{ +struct drm_i915_private *dev_priv =to_i915 (batch_obj->base.dev); +struct drm_i915_gem_object *shadow_batch_obj; +int ret; +drivers/gpu/drm/i915/i915_gem_execbuffer.c i915_reset_gen7_sol_offsets(struct drm_device *dev, · line 1052
Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_execbuffer.c +10
-0+ shadow_batch_obj =i915_gem_batch_pool_get (&dev_priv->mm.batch_pool, + batch_obj->base.size); +if (IS_ERR (shadow_batch_obj)) +return shadow_batch_obj; + + shadow_batch_obj->madv =I915_MADV_WILLNEED ; + + ret =i915_gem_obj_ggtt_pin (shadow_batch_obj,4096 ,0 ); +if (ret) + goto err;Pardon? This feels an implementation issue of
i915_parse_cmds()and should be resolved there. Presumably you are not actually reading back through the GTT? That would be insane...
Quoted 9 lines
drivers/gpu/drm/i915/i915_gem_execbuffer.c i915_reset_gen7_sol_offsets(struct drm_device *dev, · line 1060
Quoted 7 lines
drivers/gpu/drm/i915/i915_gem_execbuffer.c +7
-0+ ret =i915_parse_cmds (ring, + batch_obj, + shadow_batch_obj, + batch_start_offset, + batch_len, + is_master); +i915_gem_object_ggtt_unpin (shadow_batch_obj);Yet pin+unpin around the parser seems to serve no other purpose.
Are you suggesting to remove the pin/unpin calls? If so, isn't pinning needed to ensure the backing store pages are available in vmap_batch()? i.e. obj->pages->sgl is populated w/ physical pages.
Or, are you suggesting to move the pin/unpin calls inside i915_parse_cmds() ?
Thx,
Mike
Quoted 2 lines
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v4 7/7] drm/i915: Tidy up execbuffer command parsing code
Quoted 41 lines · Michael H. Nguyen
Hi Chris,
Quoted 30 lines
Quoted 15 lines
drivers/gpu/drm/i915/i915_gem_execbuffer.c +14
-0+static struct drm_i915_gem_object * +i915_gem_execbuffer_parse (struct intel_engine_cs *ring, +struct drm_i915_gem_exec_object2 *shadow_exec_entry, +struct eb_vmas *eb, +struct drm_i915_gem_object *batch_obj, +u32 batch_start_offset, +u32 batch_len, +bool is_master, +u32 *flags) +{ +struct drm_i915_private *dev_priv =to_i915 (batch_obj->base.dev); +struct drm_i915_gem_object *shadow_batch_obj; +int ret; +drivers/gpu/drm/i915/i915_gem_execbuffer.c i915_reset_gen7_sol_offsets(struct drm_device *dev, · line 1052
Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_execbuffer.c +10
-0+ shadow_batch_obj =i915_gem_batch_pool_get (&dev_priv->mm.batch_pool, + batch_obj->base.size); +if (IS_ERR (shadow_batch_obj)) +return shadow_batch_obj; + + shadow_batch_obj->madv =I915_MADV_WILLNEED ; + + ret =i915_gem_obj_ggtt_pin (shadow_batch_obj,4096 ,0 ); +if (ret) + goto err;Pardon? This feels an implementation issue of
i915_parse_cmds()and should be resolved there. Presumably you are not actually reading back through the GTT? That would be insane...Quoted 9 lines
drivers/gpu/drm/i915/i915_gem_execbuffer.c i915_reset_gen7_sol_offsets(struct drm_device *dev, · line 1060
Quoted 7 lines
drivers/gpu/drm/i915/i915_gem_execbuffer.c +7
-0+ ret =i915_parse_cmds (ring, + batch_obj, + shadow_batch_obj, + batch_start_offset, + batch_len, + is_master); +i915_gem_object_ggtt_unpin (shadow_batch_obj);Yet pin+unpin around the parser seems to serve no other purpose.
Quoted 6 lines
Are you suggesting to remove the pin/unpin calls? If so, isn't pinning needed to ensure the backing store pages are available in
vmap_batch()? i.e.obj->pages->sglis populated w/ physical pages.Or, are you suggesting to move the pin/unpin calls inside
i915_parse_cmds()?
Yeah please push them down into the cmd parser around the part that copies/checks the shadow batch. If we ever change the way we do that copy/parsing (likely due to performance issues on vlv) then we also might need to change the type of pinning. So better to keep things together. -Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 8 lines · On Fri, Nov 07, 2014 at 02:22:00PM -0800, [email protected] wrote:
From: Brad Volkin <[email protected]>
This is v4 of the series I sent here:
http://lists.freedesktop.org/archives/intel-gfx/2014-November/054733.htmlThis version incorporates most of the feedback from v3. The couple of things that I missed (mostly for timing reasons) are:
* Move 'pending_read_domains|=I915_GEM_DOMAIN_COMMAND' after the parser
Yeah, I think that should still be resolved before merging. I spotted a few minor things in other patches, too. But besides that I think this is ready for final review (by someone else, just to diffuse knowledge better) and then merging.
Quoted 1 line
* Maybe remove the memsets from the batch copy function
Imo that's part of the larger "don't make the copy suck on vlv" task. Since vpg cares about that most, I hope it'll happen as a follow-up.
Quoted 1 line
* Today's feedback from Chris and Daniel r.e. madv
Hm, I think that was just kerneldoc + shrinker integration? Imo with the reording in the batch pool code to clean up purged buffers we should be good enough (I hope) wrt shrinking. Kerneldoc as a follow-up would still be great ofc.
Quoted 3 lines
I'd suggest that the first two could be small follow up patches, and the madv changes I did based on Daniel's earlier comments were pulled into a separate patch that could be rewritten or modified as needed.
tbh I didn't see anything that looked functionally wrong ... The exec entry flag is definitely safer&cleaner to make sure we don't have ordering issues with some other allocation which might steal the buffer before it's marked active. Also no clues from my mails, so what have you thought of here?
-Daniel
Quoted 29 lines
Brad Volkin (7):
drm/i915: Implement a framework for batch buffer pools drm/i915: Use batch pools with the command parser drm/i915: Add a batch pool debugfs file
drm/i915: Add batch pool details toi915_gem_objectsdebugfs drm/i915: Use batch length instead of object size in command parser drm/i915: Mark shadow batch buffers as purgeable drm/i915: Tidy up execbuffer command parsing codeDocumentation/DocBook/drm.tmpl | 5 + drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/i915_cmd_parser.c | 97 ++++++++++++++---- drivers/gpu/drm/i915/i915_debugfs.c | 86 ++++++++++++++-- drivers/gpu/drm/i915/i915_dma.c | 1 + drivers/gpu/drm/i915/i915_drv.h | 24 +++++ drivers/gpu/drm/i915/i915_gem.c | 3 + drivers/gpu/drm/i915/i915_gem_batch_pool.c | 152 +++++++++++++++++++++++++++++ drivers/gpu/drm/i915/i915_gem_execbuffer.c | 105 ++++++++++++++++---- 9 files changed, 430 insertions(+), 44 deletions(-) create mode 100644 drivers/gpu/drm/i915/i915_gem_batch_pool.cSignature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx