Full PPGTT minus soft pin
Subsystems (3)
cover Full PPGTT minus soft pin
First, I don't think this whole series is ready for merge yet. It is however ready for a review, and I think a lot of the prep patches in the series could be merged to make my rebasing life a bit easier. I cannot continue ignoring pretty much all emails/bugs as I have for the last month to wrap up this series. The current state is on my IVB, things are pretty stable. I've seen one unexplained hang, but I'm hopeful review might help me uncover/explain.
This patch series introduces the next step in enabling full PPGTT, which is per fd address space/context, and it also contains the previously unmerged patches (some of which have been reworked, modified, or rebased). In regards to the continued VMA changes, I think in these, the delta with regard to the last posting is the bound list was per VM. It is now global. I've also moved the active list to per VM.
Brand new in the series we take the previous series' context per fd (with address space) one step further and actually switch the address spaces when we do context switches. In order to make this happen, the series continues to chip away at removing the notion of an object only ever being bound into one address space via the struct i915_address_space and struct i915_vma data structures which are really abstractions for a page directory, and current mapped ptes respectively. The error state is improved since the last series (though still some work there is probably needed). It also serves to remove the notion of the aliasing PPGTT since in theory everything bound into the GGTT shouldn't benefit from an aliasing PPGTT (fact check).
With every context having it's own address space, and every open DRM fd having it's own context, it's trivial on execbuf to lookup a context and do the pinning in the proper address space. More importantly, it's implicit that a context exists, which made this impossible to do earlier.
*A note on patch ordering:* In order to work this series incrementally, the final patch ordering is admittedly a little bit strange. I'm more than willing to rework these as requested, but I'd really prefer not to do really heavy reordering unless there is a major benefit, or of course to fix bugs.
# What is not in this patch series in the order I think we should handle it (and I acknowledge some of this stuff is non-trivial):
## Review + QA coverage
## Porting to HSW
It shouldn't be too much extra work, if any, to add support. I haven't looked into it yet.
## Better vm/ppgtt info in error state collection
In particular, I want to dump all the PTEs at hang, and at the very least the guilt PTEs. This isn't difficult, and can be done with copypasta from the existing dumper I have.
## User space and the implications
Now that contexts are valid on all rings, userspace should begin emitting the context for all rings if it expects both rings to be able to access both objects in the same offset. The mesa change looks to be just one line which simplies emits the context for batch->is_blit, I doubt libva is using contexts, and SNA seems not to. The plan to support mesa will be to do the detection in libdrm, and go ahead with the simple mesa one liner. I've been using the oneliner if mesa for a while now, but we will need to support old user space in the kernel. So there might be a bit of work even on the kernel side here. We also need some IGT tools test updates. I have messy versions of these locally already.
## Performance data
I think it doesn't preclude preliminary review of the patches since the main goal of PPGTT is really abourt security, correctness, and enabling other things. I will update with some numbers after I work on it a bit more.
## Testing on SNB
If our current code is correct, then I think these patches might work on SNB as is, but it's untested. There is currently no way to disconnect contexts + PPGTT from the whole thing; so if this doesn't work - we'll need rework some of the code. I think it should just entail bringing back aliasing ppgtt, and not doing the address space switch when switching contexts (aliasing ppgtt will have a null switch_mm()).
## Soft pin interface
I'd like to defer the discussion until these patches are merged.
## On demand page table allocation
This is a potentially very useful optimization for at least the following reasons:
* any app using contexts will have an extra set of page tables it isn't using; wasted memory
* Reduce DCLV to reduce pd fetch latency
* Allows Better use of a switch to default context for low memory situations (evicting unused page tables for example)
## Per VMA cache levels/control
There are situations in the code where we have to flush the GPU pipeline in order to change cache levels. This should no longer be the case for unaffected VMs (I think). The same may be true with domain tracking.
## dmabuf/prime integration
I haven't looked into what's missing to support it. If I'm lucky, it just works.
With that, if you haven't already moved on, chanting tl;dr - all comments welcome.
---
Ben Widawsky (65):
drm/i915: Remove extra error state NULL
drm/i915: Extract error buffer capture
drm/i915: make PDE|PTE platform specific
drm/i915: Don't clear gtt with 0 entries
drm/i915: Conditionally use guard page based on PPGTT drm/i915: Use drm_mm for PPGTT PDEs
drm/i915: cleanup context fini
drm/i915: Do a fuller init after reset
drm/i915: Split context enabling from init drm/i915: destroy i915_gem_init_global_gtt drm/i915: Embed PPGTT into the context
drm/i915: Unify PPGTT codepaths on gen6+
drm/i915: Move ppgtt initialization down
drm/i915: Tie context to PPGTT
drm/i915: Really share scratch page
drm/i915: Combine scratch members into a struct drm/i915: Drop dev from pte_encode
drm/i915: Use gtt shortform where possible drm/i915: Move fbc members out of line
drm/i915: Move gtt and ppgtt under address space umbrella drm/i915: Move gtt_mtrr to i915_gtt
drm/i915: Move stolen stuff to i915_gtt
drm/i915: Move aliasing_ppgtt
drm/i915: Put the mm in the parent address space drm/i915: Move active/inactive lists to new mm drm/i915: Create a global list of vms
drm/i915: Remove object's gtt_offset
drm: pre allocate node for create_block
drm/i915: Getter/setter for object attributes drm/i915: Create VMAs (part 1)
drm/i915: Create VMAs (part 2) - kill gtt space drm/i915: Create VMAs (part 3) - plumbing
drm/i915: Create VMAs (part 3.5) - map and fenceable tracking drm/i915: Create VMAs (part 4) - Error capture drm/i915: Create VMAs (part 5) - move mm_list drm/i915: Create VMAs (part 6) - finish error plumbing drm/i915: create an object_is_active()
drm/i915: Move active to vma
drm/i915: Track all VMAs per VM
drm/i915: Defer request freeing
drm/i915: Clean up VMAs before freeing
drm/i915: Replace has_bsd/blt with a mask
drm/i915: Catch missed context unref earlier drm/i915: Add a context open function
drm/i915: Permit contexts on all rings
drm/i915: Fix context fini refcounts
drm/i915: Better reset handling for contexts drm/i915: Create a per file_priv default context drm/i915: Remove ring specificity from contexts drm/i915: Track which ring a context ran on drm/i915: dump error state based on capture drm/i915: PPGTT should take a ppgtt argument drm/i915: USE LRI for switching PP_DIR_BASE drm/i915: Extract mm switching to function drm/i915: Write PDEs at init instead of enable drm/i915: Disallow pin with full ppgtt
drm/i915: Get context early in execbuf
drm/i915: Pass ctx directly to switch/hangstat drm/i915: Actually add the new address spaces drm/i915: Use multiple VMs
drm/i915: Kill now unused ppgtt_{un,}bind
drm/i915: Add PPGTT dumper
drm/i915: Dump all ppgtt
drm/i915: Add debugfs for vma info per vm
drm/i915: Getparam full ppgtt
Chris Wilson (1):
drm: Optionally create mm blocks from top-to-bottom
drivers/gpu/drm/drm_mm.c | 134 +++--- drivers/gpu/drm/i915/i915_debugfs.c | 215 ++++++++-- drivers/gpu/drm/i915/i915_dma.c | 25 +- drivers/gpu/drm/i915/i915_drv.c | 57 ++- drivers/gpu/drm/i915/i915_drv.h | 353 ++++++++++------ drivers/gpu/drm/i915/i915_gem.c | 639 +++++++++++++++++++++-------- drivers/gpu/drm/i915/i915_gem_context.c | 279 +++++++++---- drivers/gpu/drm/i915/i915_gem_debug.c | 11 +- drivers/gpu/drm/i915/i915_gem_evict.c | 64 +-- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 138 ++++--- drivers/gpu/drm/i915/i915_gem_gtt.c | 541 ++++++++++++++---------- drivers/gpu/drm/i915/i915_gem_stolen.c | 87 ++-- drivers/gpu/drm/i915/i915_gem_tiling.c | 21 +- drivers/gpu/drm/i915/i915_irq.c | 197 ++++++--- drivers/gpu/drm/i915/i915_trace.h | 38 +- drivers/gpu/drm/i915/intel_display.c | 40 +- drivers/gpu/drm/i915/intel_drv.h | 7 - drivers/gpu/drm/i915/intel_fb.c | 8 +- drivers/gpu/drm/i915/intel_overlay.c | 26 +- drivers/gpu/drm/i915/intel_pm.c | 65 +-- drivers/gpu/drm/i915/intel_ringbuffer.c | 32 +- drivers/gpu/drm/i915/intel_sprite.c | 8 +- include/drm/drm_mm.h | 147 ++++--- include/uapi/drm/i915_drm.h | 1 + 24 files changed, 2044 insertions(+), 1089 deletions(-)
Signature · 1 line
1.8.3.1
PATCH 1/66 drm/i915: Remove extra error state NULL
Not only was there an extra, but since we now kzalloc the error state, we don't need either.
--- drivers/gpu/drm/i915/i915_irq.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/gpu/drm/i915/i915_irq.c +0 -6
@@ -1926,10 +1926,6 @@ static void i915_capture_error_state(struct drm_device *dev)i915_gem_record_fences (dev, error);i915_gem_record_rings (dev, error); -/* Record buffers on the active and pinned lists. */ - error->active_bo =NULL ; - error->pinned_bo =NULL ; - i =0 ;list_for_each_entry (obj, &dev_priv->mm.active_list, mm_list) i++;
@@ -1939,8 +1935,6 @@ static void i915_capture_error_state(struct drm_device *dev) i++; error->pinned_bo_count = i - error->active_bo_count; - error->active_bo =NULL ; - error->pinned_bo =NULL ;if (i) { error->active_bo =kmalloc (sizeof (*error->active_bo)*i,GFP_ATOMIC );
Signature · 1 line
1.8.3.1
PATCH 2/66 drm/i915: Extract error buffer capture
In reply to Ben WidawskyThis helps when we have per VM buffer capturing.
--- drivers/gpu/drm/i915/i915_irq.c | 69 +++++++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 31 deletions(-)
drivers/gpu/drm/i915/i915_irq.c +38 -31
@@ -1850,6 +1850,42 @@ static void i915_gem_record_rings(struct drm_device *dev, } } +static void i915_gem_capture_buffers (struct drm_i915_private *dev_priv, +struct drm_i915_error_state *error) +{ +struct drm_i915_gem_object *obj; +int i; + + i =0 ; +list_for_each_entry (obj, &dev_priv->mm.active_list, mm_list) + i++; + error->active_bo_count = i; +list_for_each_entry (obj, &dev_priv->mm.bound_list, global_list) +if (obj->pin_count) + i++; + error->pinned_bo_count = i - error->active_bo_count; + +if (i) { + error->active_bo =kmalloc (sizeof (*error->active_bo)*i, +GFP_ATOMIC ); +if (error->active_bo) + error->pinned_bo = + error->active_bo + error->active_bo_count; + } + +if (error->active_bo) + error->active_bo_count = +capture_active_bo (error->active_bo, + error->active_bo_count, + &dev_priv->mm.active_list); + +if (error->pinned_bo) + error->pinned_bo_count = +capture_pinned_bo (error->pinned_bo, + error->pinned_bo_count, + &dev_priv->mm.bound_list); +} +/** * i915_capture_error_state - capture an error record for later analysis * @dev: drm device
@@ -1862,10 +1898,9 @@ static void i915_gem_record_rings(struct drm_device *dev,static void i915_capture_error_state (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; -struct drm_i915_gem_object *obj;struct drm_i915_error_state *error;unsigned long flags; -int i, pipe; +int pipe;spin_lock_irqsave (&dev_priv->gpu_error.lock, flags); error = dev_priv->gpu_error.first_error;
@@ -1923,38 +1958,10 @@ static void i915_capture_error_state(struct drm_device *dev)i915_get_extra_instdone (dev, error->extra_instdone); +i915_gem_capture_buffers (dev_priv, error);i915_gem_record_fences (dev, error);i915_gem_record_rings (dev, error); - i =0 ; -list_for_each_entry (obj, &dev_priv->mm.active_list, mm_list) - i++; - error->active_bo_count = i; -list_for_each_entry (obj, &dev_priv->mm.bound_list, global_list) -if (obj->pin_count) - i++; - error->pinned_bo_count = i - error->active_bo_count; - -if (i) { - error->active_bo =kmalloc (sizeof (*error->active_bo)*i, -GFP_ATOMIC ); -if (error->active_bo) - error->pinned_bo = - error->active_bo + error->active_bo_count; - } - -if (error->active_bo) - error->active_bo_count = -capture_active_bo (error->active_bo, - error->active_bo_count, - &dev_priv->mm.active_list); - -if (error->pinned_bo) - error->pinned_bo_count = -capture_pinned_bo (error->pinned_bo, - error->pinned_bo_count, - &dev_priv->mm.bound_list); -do_gettimeofday (&error->time); error->overlay =intel_overlay_capture_error_state (dev);
Signature · 1 line
1.8.3.1
PATCH 3/66 drm/i915: make PDE|PTE platform specific
In reply to Ben WidawskyNothing outside of i915_gem_gtt.c and more specifically, the relevant gen specific init function should need to know about number of PDEs, or PTEs per PD. Exposing this will only lead to circumventing using the upcoming VM abstraction.
To accomplish this, move the defines into the .c file, rename the PDE define to be GEN6, and make the PTE count less of a magic number.
The remaining code in the global gtt setup is a bit messy, but an upcoming patch will clean that one up.
v2: Don't hardcode number of PDEs (Daniel + Jesse) Reworded commit message to reflect change.
--- drivers/gpu/drm/i915/i915_drv.h | 2 -- drivers/gpu/drm/i915/i915_gem_gtt.c | 9 ++++++--- 2 files changed, 6 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +0 -2
@@ -483,8 +483,6 @@ struct i915_gtt { };#define gtt_total_entries (gtt) ((gtt).total >> PAGE_SHIFT) -#define I915_PPGTT_PD_ENTRIES 512 -#define I915_PPGTT_PT_ENTRIES 1024struct i915_hw_ppgtt {struct drm_device *dev;unsigned num_pd_entries;
drivers/gpu/drm/i915/i915_gem_gtt.c +6 -3
@@ -28,6 +28,9 @@#include "i915_trace.h" #include "intel_drv.h" +#define GEN6_PPGTT_PD_ENTRIES 512 +#define I915_PPGTT_PT_ENTRIES (PAGE_SIZE / sizeof(gen6_gtt_pte_t)) +/* PPGTT stuff */ #define GEN6_GTT_ADDR_ENCODE (addr) ((addr) | (((addr) >> 28) & 0xff0))
@@ -278,7 +281,7 @@ static int gen6_ppgtt_init(struct i915_hw_ppgtt *ppgtt) }else { ppgtt->pte_encode = gen6_pte_encode; } - ppgtt->num_pd_entries =I915_PPGTT_PD_ENTRIES ; + ppgtt->num_pd_entries =GEN6_PPGTT_PD_ENTRIES ; ppgtt->enable = gen6_ppgtt_enable; ppgtt->clear_range = gen6_ppgtt_clear_range; ppgtt->insert_entries = gen6_ppgtt_insert_entries;
@@ -688,7 +691,7 @@ void i915_gem_init_global_gtt(struct drm_device *dev)if (INTEL_INFO (dev)->gen <=7 ) {/* PPGTT pdes are stolen from global gtt ptes, so shrink the * aperture accordingly when using aliasing ppgtt. */ - gtt_size -=I915_PPGTT_PD_ENTRIES *PAGE_SIZE ; + gtt_size -=GEN6_PPGTT_PD_ENTRIES *PAGE_SIZE ; }i915_gem_setup_global_gtt (dev,0 , mappable_size, gtt_size);
@@ -699,7 +702,7 @@ void i915_gem_init_global_gtt(struct drm_device *dev)DRM_ERROR ("Aliased PPGTT setup failed %d\n" , ret);drm_mm_takedown (&dev_priv->mm.gtt_space); - gtt_size +=I915_PPGTT_PD_ENTRIES *PAGE_SIZE ; + gtt_size +=GEN6_PPGTT_PD_ENTRIES *PAGE_SIZE ; }i915_gem_setup_global_gtt (dev,0 , mappable_size, gtt_size); }
Signature · 1 line
1.8.3.1
Re: [PATCH 03/66] drm/i915: make PDE|PTE platform specific
Quoted 8 lines · Ben Widawsky
Nothing outside of
i915_gem_gtt.cand more specifically, the relevant gen specific init function should need to know about number of PDEs, or PTEs per PD. Exposing this will only lead to circumventing using the upcoming VM abstraction.To accomplish this, move the defines into the .c file, rename the PDE define to be GEN6, and make the PTE count less of a magic number.
Quoted 8 lines
The remaining code in the global gtt setup is a bit messy, but an upcoming patch will clean that one up.
v2: Don't hardcode number of PDEs (Daniel + Jesse) Reworded commit message to reflect change.
Reviewed-by Jesse Barnes <[email protected]>Signed-off-by Ben Widawsky <[email protected]>
First 3 patches merged to dinq, thanks.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
PATCH 4/66 drm: Optionally create mm blocks from top-to-bottom
In reply to Ben WidawskyFrom: Chris Wilson <[email protected]>
Clients like i915 needs to segregate cache domains within the GTT which can lead to small amounts of fragmentation. By allocating the uncached buffers from the bottom and the cacheable buffers from the top, we can reduce the amount of wasted space and also optimize allocation of the mappable portion of the GTT to only those buffers that require CPU access through the GTT.
v2 by Ben:
Update callers in i915_gem_object_bind_to_gtt() Turn search flags and allocation flags into separate enums Make checkpatch happy where logical/easy
--- drivers/gpu/drm/drm_mm.c | 122 ++++++++++++++++++--------------- drivers/gpu/drm/i915/i915_gem.c | 4 +- include/drm/drm_mm.h | 148 ++++++++++++++++++++++++---------------- 3 files changed, 161 insertions(+), 113 deletions(-)
drivers/gpu/drm/drm_mm.c +68 -54
@@ -49,7 +49,7 @@#define MM_UNUSED_TARGET 4 -static struct drm_mm_node *drm_mm_kmalloc (struct drm_mm *mm,int atomic) +static struct drm_mm_node *drm_mm_kmalloc (struct drm_mm *mm,bool atomic) {struct drm_mm_node *child;
@@ -105,7 +105,8 @@ EXPORT_SYMBOL(drm_mm_pre_get);static void drm_mm_insert_helper (struct drm_mm_node *hole_node,struct drm_mm_node *node,unsigned long size,unsigned alignment, -unsigned long color) +unsigned long color, +enum drm_mm_allocator_flags flags) {struct drm_mm *mm = hole_node->mm;unsigned long hole_start =drm_mm_hole_node_start (hole_node);
@@ -118,12 +119,22 @@ static void drm_mm_insert_helper(struct drm_mm_node *hole_node,if (mm->color_adjust) mm->color_adjust (hole_node, color, &adj_start, &adj_end); +if (flags &DRM_MM_CREATE_TOP ) + adj_start = adj_end - size; +if (alignment) {unsigned tmp = adj_start % alignment; -if (tmp) - adj_start += alignment - tmp; +if (tmp) { +if (flags &DRM_MM_CREATE_TOP ) + adj_start -= tmp; +else + adj_start += alignment - tmp; + } } +BUG_ON (adj_start < hole_start); +BUG_ON (adj_end > hole_end); +if (adj_start == hole_start) { hole_node->hole_follows =0 ;list_del (&hole_node->hole_stack);
@@ -150,7 +161,7 @@ static void drm_mm_insert_helper(struct drm_mm_node *hole_node,struct drm_mm_node *drm_mm_create_block (struct drm_mm *mm,unsigned long start,unsigned long size, -bool atomic) +enum drm_mm_allocator_flags flags) {struct drm_mm_node *hole, *node;unsigned long end = start + size;
@@ -161,7 +172,7 @@ struct drm_mm_node *drm_mm_create_block(struct drm_mm *mm,if (hole_start > start || hole_end < end)continue ; - node =drm_mm_kmalloc (mm, atomic); + node =drm_mm_kmalloc (mm, flags &DRM_MM_CREATE_ATOMIC );if (unlikely (node ==NULL ))return NULL ;
@@ -196,15 +207,15 @@ struct drm_mm_node *drm_mm_get_block_generic(struct drm_mm_node *hole_node,unsigned long size, unsigned alignment, unsigned long color, - int atomic) + enum drm_mm_allocator_flags flags) { struct drm_mm_node *node; - node =drm_mm_kmalloc (hole_node->mm, atomic); + node =drm_mm_kmalloc (hole_node->mm, flags &DRM_MM_CREATE_ATOMIC );if (unlikely (node ==NULL ))return NULL ; -drm_mm_insert_helper (hole_node, node, size, alignment, color); +drm_mm_insert_helper (hole_node, node, size, alignment, color, flags);return node; }
@@ -217,32 +228,28 @@ EXPORT_SYMBOL(drm_mm_get_block_generic);*/ int drm_mm_insert_node_generic (struct drm_mm *mm,struct drm_mm_node *node,unsigned long size,unsigned alignment, -unsigned long color) +unsigned long color, +enum drm_mm_allocator_flags aflags, +enum drm_mm_search_flags sflags) {struct drm_mm_node *hole_node; hole_node =drm_mm_search_free_generic (mm, size, alignment, - color,0 ); + color, sflags);if (!hole_node)return -ENOSPC ; -drm_mm_insert_helper (hole_node, node, size, alignment, color); +drm_mm_insert_helper (hole_node, node, size, alignment, color, aflags);return 0 ; }EXPORT_SYMBOL (drm_mm_insert_node_generic); -int drm_mm_insert_node (struct drm_mm *mm,struct drm_mm_node *node, -unsigned long size,unsigned alignment) -{ -return drm_mm_insert_node_generic (mm, node, size, alignment,0 ); -} -EXPORT_SYMBOL (drm_mm_insert_node); -static void drm_mm_insert_helper_range (struct drm_mm_node *hole_node,struct drm_mm_node *node,unsigned long size,unsigned alignment,unsigned long color, -unsigned long start,unsigned long end) +unsigned long start,unsigned long end, +enum drm_mm_search_flags flags) {struct drm_mm *mm = hole_node->mm;unsigned long hole_start =drm_mm_hole_node_start (hole_node);
@@ -257,13 +264,20 @@ static void drm_mm_insert_helper_range(struct drm_mm_node *hole_node,if (adj_end > end) adj_end = end; +if (flags &DRM_MM_CREATE_TOP ) + adj_start = adj_end - size; +if (mm->color_adjust) mm->color_adjust (hole_node, color, &adj_start, &adj_end);if (alignment) {unsigned tmp = adj_start % alignment; -if (tmp) - adj_start += alignment - tmp; +if (tmp) { +if (flags &DRM_MM_CREATE_TOP ) + adj_start -= tmp; +else + adj_start += alignment - tmp; + } }if (adj_start == hole_start) {
@@ -280,6 +294,8 @@ static void drm_mm_insert_helper_range(struct drm_mm_node *hole_node,INIT_LIST_HEAD (&node->hole_stack);list_add (&node->node_list, &hole_node->node_list); +BUG_ON (node->start < start); +BUG_ON (node->start < adj_start);BUG_ON (node->start + node->size > adj_end);BUG_ON (node->start + node->size > end);
@@ -290,22 +306,23 @@ static void drm_mm_insert_helper_range(struct drm_mm_node *hole_node, } } -struct drm_mm_node *drm_mm_get_block_range_generic (struct drm_mm_node *hole_node, -unsigned long size, -unsigned alignment, -unsigned long color, -unsigned long start, -unsigned long end, -int atomic) +struct drm_mm_node * +drm_mm_get_block_range_generic (struct drm_mm_node *hole_node, +unsigned long size, +unsigned alignment, +unsigned long color, +unsigned long start, +unsigned long end, +enum drm_mm_allocator_flags flags) {struct drm_mm_node *node; - node =drm_mm_kmalloc (hole_node->mm, atomic); + node =drm_mm_kmalloc (hole_node->mm, flags &DRM_MM_CREATE_ATOMIC );if (unlikely (node ==NULL ))return NULL ;drm_mm_insert_helper_range (hole_node, node, size, alignment, color, - start, end); + start, end, flags);return node; }
@@ -318,31 +335,25 @@ EXPORT_SYMBOL(drm_mm_get_block_range_generic);*/ int drm_mm_insert_node_in_range_generic (struct drm_mm *mm,struct drm_mm_node *node,unsigned long size,unsigned alignment,unsigned long color, -unsigned long start,unsigned long end) +unsigned long start,unsigned long end, +enum drm_mm_allocator_flags aflags, +enum drm_mm_search_flags sflags) {struct drm_mm_node *hole_node; hole_node =drm_mm_search_free_in_range_generic (mm, size, alignment, color, - start, end,0 ); + start, end, sflags);if (!hole_node)return -ENOSPC ;drm_mm_insert_helper_range (hole_node, node, size, alignment, color, - start, end); + start, end, aflags);return 0 ; }EXPORT_SYMBOL (drm_mm_insert_node_in_range_generic); -int drm_mm_insert_node_in_range (struct drm_mm *mm,struct drm_mm_node *node, -unsigned long size,unsigned alignment, -unsigned long start,unsigned long end) -{ -return drm_mm_insert_node_in_range_generic (mm, node, size, alignment,0 , start, end); -} -EXPORT_SYMBOL (drm_mm_insert_node_in_range); -/** * Remove a memory node from the allocator. */
@@ -418,7 +429,7 @@ struct drm_mm_node *drm_mm_search_free_generic(const struct drm_mm *mm,unsigned long size, unsigned alignment, unsigned long color, - bool best_match) + enum drm_mm_search_flags flags) { struct drm_mm_node *entry;struct drm_mm_node *best;
@@ -431,7 +442,8 @@ struct drm_mm_node *drm_mm_search_free_generic(const struct drm_mm *mm, best =NULL ; best_size = ~0UL ; -drm_mm_for_each_hole (entry, mm, adj_start, adj_end) { +__drm_mm_for_each_hole (entry, mm, adj_start, adj_end, + flags &DRM_MM_SEARCH_BELOW ) {if (mm->color_adjust) { mm->color_adjust (entry, color, &adj_start, &adj_end);if (adj_end <= adj_start)
@@ -441,7 +453,7 @@ struct drm_mm_node *drm_mm_search_free_generic(const struct drm_mm *mm,if (!check_free_hole (adj_start, adj_end, size, alignment))continue ; -if (!best_match) +if ((flags &DRM_MM_SEARCH_BEST ) ==0 )return entry;if (entry->size < best_size) {
@@ -454,13 +466,14 @@ struct drm_mm_node *drm_mm_search_free_generic(const struct drm_mm *mm, }EXPORT_SYMBOL (drm_mm_search_free_generic); -struct drm_mm_node *drm_mm_search_free_in_range_generic (const struct drm_mm *mm, -unsigned long size, -unsigned alignment, -unsigned long color, -unsigned long start, -unsigned long end, -bool best_match) +struct drm_mm_node * +drm_mm_search_free_in_range_generic (const struct drm_mm *mm, +unsigned long size, +unsigned alignment, +unsigned long color, +unsigned long start, +unsigned long end, +enum drm_mm_search_flags flags) {struct drm_mm_node *entry;struct drm_mm_node *best;
@@ -473,7 +486,8 @@ struct drm_mm_node *drm_mm_search_free_in_range_generic(const struct drm_mm *mm, best =NULL ; best_size = ~0UL ; -drm_mm_for_each_hole (entry, mm, adj_start, adj_end) { +__drm_mm_for_each_hole (entry, mm, adj_start, adj_end, + flags &DRM_MM_SEARCH_BELOW ) {if (adj_start < start) adj_start = start;if (adj_end > end)
@@ -488,7 +502,7 @@ struct drm_mm_node *drm_mm_search_free_in_range_generic(const struct drm_mm *mm,if (!check_free_hole (adj_start, adj_end, size, alignment))continue ; -if (!best_match) +if ((flags &DRM_MM_SEARCH_BEST ) ==0 )return entry;if (entry->size < best_size) {
drivers/gpu/drm/i915/i915_gem.c +3 -1
@@ -3131,7 +3131,9 @@ i915_gem_object_bind_to_gtt(struct drm_i915_gem_object *obj, search_free: ret =drm_mm_insert_node_in_range_generic (&dev_priv->mm.gtt_space, node, size, alignment, - obj->cache_level,0 , gtt_max); + obj->cache_level,0 , gtt_max, +DRM_MM_CREATE_DEFAULT , +DRM_MM_SEARCH_DEFAULT );if (ret) { ret = i915_gem_evict_something(dev, size, alignment, obj->cache_level,
include/drm/drm_mm.h +90 -58
209 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [PATCH 04/66] drm: Optionally create mm blocks from top-to-bottom
Quoted 9 lines · Ben Widawsky
From: Chris Wilson <[email protected]>
Clients like i915 needs to segregate cache domains within the GTT which can lead to small amounts of fragmentation. By allocating the uncached buffers from the bottom and the cacheable buffers from the top, we can reduce the amount of wasted space and also optimize allocation of the mappable portion of the GTT to only those buffers that require CPU access through the GTT.
Quoted 7 lines
v2 by Ben:
Update callers ini915_gem_object_bind_to_gtt()Turn search flags and allocation flags into separate enums Make checkpatch happy where logical/easySigned-off-by Chris Wilson <[email protected]>Signed-off-by Ben Widawsky <[email protected]>
Since this is a core drm patch it must be cc'ed to dri-devel (and acked by Dave) before I can merge it. Can you please resend?
-Daniel
Quoted 544 lines
--- drivers/gpu/drm/drm_mm.c | 122 ++++++++++++++++++--------------- drivers/gpu/drm/i915/i915_gem.c | 4 +- include/drm/drm_mm.h | 148 ++++++++++++++++++++++++---------------- 3 files changed, 161 insertions(+), 113 deletions(-)drivers/gpu/drm/drm_mm.c +68
-54@@ -49,7 +49,7 @@#define MM_UNUSED_TARGET 4 -static struct drm_mm_node *drm_mm_kmalloc (struct drm_mm *mm,int atomic) +static struct drm_mm_node *drm_mm_kmalloc (struct drm_mm *mm,bool atomic) {struct drm_mm_node *child;@@ -105,7 +105,8 @@ EXPORT_SYMBOL(drm_mm_pre_get);static void drm_mm_insert_helper (struct drm_mm_node *hole_node,struct drm_mm_node *node,unsigned long size,unsigned alignment, -unsigned long color) +unsigned long color, +enum drm_mm_allocator_flags flags) {struct drm_mm *mm = hole_node->mm;unsigned long hole_start =drm_mm_hole_node_start (hole_node);@@ -118,12 +119,22 @@ static void drm_mm_insert_helper(struct drm_mm_node *hole_node,if (mm->color_adjust) mm->color_adjust (hole_node, color, &adj_start, &adj_end); +if (flags &DRM_MM_CREATE_TOP ) + adj_start = adj_end - size; +if (alignment) {unsigned tmp = adj_start % alignment; -if (tmp) - adj_start += alignment - tmp; +if (tmp) { +if (flags &DRM_MM_CREATE_TOP ) + adj_start -= tmp; +else + adj_start += alignment - tmp; + } } +BUG_ON (adj_start < hole_start); +BUG_ON (adj_end > hole_end); +if (adj_start == hole_start) { hole_node->hole_follows =0 ;list_del (&hole_node->hole_stack);@@ -150,7 +161,7 @@ static void drm_mm_insert_helper(struct drm_mm_node *hole_node,struct drm_mm_node *drm_mm_create_block (struct drm_mm *mm,unsigned long start,unsigned long size, -bool atomic) +enum drm_mm_allocator_flags flags) {struct drm_mm_node *hole, *node;unsigned long end = start + size;@@ -161,7 +172,7 @@ struct drm_mm_node *drm_mm_create_block(struct drm_mm *mm,if (hole_start > start || hole_end < end)continue ; - node =drm_mm_kmalloc (mm, atomic); + node =drm_mm_kmalloc (mm, flags &DRM_MM_CREATE_ATOMIC );if (unlikely (node ==NULL ))return NULL ;@@ -196,15 +207,15 @@ struct drm_mm_node *drm_mm_get_block_generic(struct drm_mm_node *hole_node,unsigned long size, unsigned alignment, unsigned long color, - int atomic) + enum drm_mm_allocator_flags flags) { struct drm_mm_node *node; - node =drm_mm_kmalloc (hole_node->mm, atomic); + node =drm_mm_kmalloc (hole_node->mm, flags &DRM_MM_CREATE_ATOMIC );if (unlikely (node ==NULL ))return NULL ; -drm_mm_insert_helper (hole_node, node, size, alignment, color); +drm_mm_insert_helper (hole_node, node, size, alignment, color, flags);return node; }@@ -217,32 +228,28 @@ EXPORT_SYMBOL(drm_mm_get_block_generic);*/ int drm_mm_insert_node_generic (struct drm_mm *mm,struct drm_mm_node *node,unsigned long size,unsigned alignment, -unsigned long color) +unsigned long color, +enum drm_mm_allocator_flags aflags, +enum drm_mm_search_flags sflags) {struct drm_mm_node *hole_node; hole_node =drm_mm_search_free_generic (mm, size, alignment, - color,0 ); + color, sflags);if (!hole_node)return -ENOSPC ; -drm_mm_insert_helper (hole_node, node, size, alignment, color); +drm_mm_insert_helper (hole_node, node, size, alignment, color, aflags);return 0 ; }EXPORT_SYMBOL (drm_mm_insert_node_generic); -int drm_mm_insert_node (struct drm_mm *mm,struct drm_mm_node *node, -unsigned long size,unsigned alignment) -{ -return drm_mm_insert_node_generic (mm, node, size, alignment,0 ); -} -EXPORT_SYMBOL (drm_mm_insert_node); -static void drm_mm_insert_helper_range (struct drm_mm_node *hole_node,struct drm_mm_node *node,unsigned long size,unsigned alignment,unsigned long color, -unsigned long start,unsigned long end) +unsigned long start,unsigned long end, +enum drm_mm_search_flags flags) {struct drm_mm *mm = hole_node->mm;unsigned long hole_start =drm_mm_hole_node_start (hole_node);@@ -257,13 +264,20 @@ static void drm_mm_insert_helper_range(struct drm_mm_node *hole_node,if (adj_end > end) adj_end = end; +if (flags &DRM_MM_CREATE_TOP ) + adj_start = adj_end - size; +if (mm->color_adjust) mm->color_adjust (hole_node, color, &adj_start, &adj_end);if (alignment) {unsigned tmp = adj_start % alignment; -if (tmp) - adj_start += alignment - tmp; +if (tmp) { +if (flags &DRM_MM_CREATE_TOP ) + adj_start -= tmp; +else + adj_start += alignment - tmp; + } }if (adj_start == hole_start) {@@ -280,6 +294,8 @@ static void drm_mm_insert_helper_range(struct drm_mm_node *hole_node,INIT_LIST_HEAD (&node->hole_stack);list_add (&node->node_list, &hole_node->node_list); +BUG_ON (node->start < start); +BUG_ON (node->start < adj_start);BUG_ON (node->start + node->size > adj_end);BUG_ON (node->start + node->size > end);@@ -290,22 +306,23 @@ static void drm_mm_insert_helper_range(struct drm_mm_node *hole_node, } } -struct drm_mm_node *drm_mm_get_block_range_generic (struct drm_mm_node *hole_node, -unsigned long size, -unsigned alignment, -unsigned long color, -unsigned long start, -unsigned long end, -int atomic) +struct drm_mm_node * +drm_mm_get_block_range_generic (struct drm_mm_node *hole_node, +unsigned long size, +unsigned alignment, +unsigned long color, +unsigned long start, +unsigned long end, +enum drm_mm_allocator_flags flags) {struct drm_mm_node *node; - node =drm_mm_kmalloc (hole_node->mm, atomic); + node =drm_mm_kmalloc (hole_node->mm, flags &DRM_MM_CREATE_ATOMIC );if (unlikely (node ==NULL ))return NULL ;drm_mm_insert_helper_range (hole_node, node, size, alignment, color, - start, end); + start, end, flags);return node; }@@ -318,31 +335,25 @@ EXPORT_SYMBOL(drm_mm_get_block_range_generic);*/ int drm_mm_insert_node_in_range_generic (struct drm_mm *mm,struct drm_mm_node *node,unsigned long size,unsigned alignment,unsigned long color, -unsigned long start,unsigned long end) +unsigned long start,unsigned long end, +enum drm_mm_allocator_flags aflags, +enum drm_mm_search_flags sflags) {struct drm_mm_node *hole_node; hole_node =drm_mm_search_free_in_range_generic (mm, size, alignment, color, - start, end,0 ); + start, end, sflags);if (!hole_node)return -ENOSPC ;drm_mm_insert_helper_range (hole_node, node, size, alignment, color, - start, end); + start, end, aflags);return 0 ; }EXPORT_SYMBOL (drm_mm_insert_node_in_range_generic); -int drm_mm_insert_node_in_range (struct drm_mm *mm,struct drm_mm_node *node, -unsigned long size,unsigned alignment, -unsigned long start,unsigned long end) -{ -return drm_mm_insert_node_in_range_generic (mm, node, size, alignment,0 , start, end); -} -EXPORT_SYMBOL (drm_mm_insert_node_in_range); -/** * Remove a memory node from the allocator. */ @@ -418,7 +429,7 @@ struct drm_mm_node *drm_mm_search_free_generic(const struct drm_mm *mm,unsigned long size, unsigned alignment, unsigned long color, - bool best_match) + enum drm_mm_search_flags flags) { struct drm_mm_node *entry;struct drm_mm_node *best;@@ -431,7 +442,8 @@ struct drm_mm_node *drm_mm_search_free_generic(const struct drm_mm *mm, best =NULL ; best_size = ~0UL ; -drm_mm_for_each_hole (entry, mm, adj_start, adj_end) { +__drm_mm_for_each_hole (entry, mm, adj_start, adj_end, + flags &DRM_MM_SEARCH_BELOW ) {if (mm->color_adjust) { mm->color_adjust (entry, color, &adj_start, &adj_end);if (adj_end <= adj_start)@@ -441,7 +453,7 @@ struct drm_mm_node *drm_mm_search_free_generic(const struct drm_mm *mm,if (!check_free_hole (adj_start, adj_end, size, alignment))continue ; -if (!best_match) +if ((flags &DRM_MM_SEARCH_BEST ) ==0 )return entry;if (entry->size < best_size) {@@ -454,13 +466,14 @@ struct drm_mm_node *drm_mm_search_free_generic(const struct drm_mm *mm, }EXPORT_SYMBOL (drm_mm_search_free_generic); -struct drm_mm_node *drm_mm_search_free_in_range_generic (const struct drm_mm *mm, -unsigned long size, -unsigned alignment, -unsigned long color, -unsigned long start, -unsigned long end, -bool best_match) +struct drm_mm_node * +drm_mm_search_free_in_range_generic (const struct drm_mm *mm, +unsigned long size, +unsigned alignment, +unsigned long color, +unsigned long start, +unsigned long end, +enum drm_mm_search_flags flags) {struct drm_mm_node *entry;struct drm_mm_node *best;@@ -473,7 +486,8 @@ struct drm_mm_node *drm_mm_search_free_in_range_generic(const struct drm_mm *mm, best =NULL ; best_size = ~0UL ; -drm_mm_for_each_hole (entry, mm, adj_start, adj_end) { +__drm_mm_for_each_hole (entry, mm, adj_start, adj_end, + flags &DRM_MM_SEARCH_BELOW ) {if (adj_start < start) adj_start = start;if (adj_end > end)@@ -488,7 +502,7 @@ struct drm_mm_node *drm_mm_search_free_in_range_generic(const struct drm_mm *mm,if (!check_free_hole (adj_start, adj_end, size, alignment))continue ; -if (!best_match) +if ((flags &DRM_MM_SEARCH_BEST ) ==0 )return entry;if (entry->size < best_size) {drivers/gpu/drm/i915/i915_gem.c +3
-1@@ -3131,7 +3131,9 @@ i915_gem_object_bind_to_gtt(struct drm_i915_gem_object *obj, search_free: ret =drm_mm_insert_node_in_range_generic (&dev_priv->mm.gtt_space, node, size, alignment, - obj->cache_level,0 , gtt_max); + obj->cache_level,0 , gtt_max, +DRM_MM_CREATE_DEFAULT , +DRM_MM_SEARCH_DEFAULT );if (ret) { ret = i915_gem_evict_something(dev, size, alignment, obj->cache_level,include/drm/drm_mm.h +90
-58@@ -41,6 +41,21 @@#include <linux/seq_file.h> #endif +enum drm_mm_allocator_flags { +DRM_MM_CREATE_DEFAULT =0 , +DRM_MM_CREATE_ATOMIC =1 <<0 , +DRM_MM_CREATE_TOP =1 <<1 , +}; + +enum drm_mm_search_flags { +DRM_MM_SEARCH_DEFAULT =0 , +DRM_MM_SEARCH_BEST =1 <<0 , +DRM_MM_SEARCH_BELOW =1 <<1 , +}; + +#define DRM_MM_BOTTOMUP DRM_MM_CREATE_DEFAULT, DRM_MM_SEARCH_DEFAULT +#define DRM_MM_TOPDOWN DRM_MM_CREATE_TOP, DRM_MM_SEARCH_BELOW +struct drm_mm_node {struct list_head node_list;struct list_head hole_stack;@@ -135,26 +150,37 @@ static inline unsigned long drm_mm_hole_node_end(struct drm_mm_node *hole_node) 1 : 0; \ entry = list_entry(entry->hole_stack.next, struct drm_mm_node, hole_stack)) +#define __drm_mm_for_each_hole (entry, mm, hole_start, hole_end, backwards) \ + for (entry = list_entry((backwards) ? (mm)->hole_stack.prev : (mm)->hole_stack.next, struct drm_mm_node, hole_stack); \ + &entry->hole_stack != &(mm)->hole_stack ? \ + hole_start = drm_mm_hole_node_start(entry), \ + hole_end = drm_mm_hole_node_end(entry), \ + 1 : 0; \ + entry = list_entry((backwards) ? entry->hole_stack.prev : entry->hole_stack.next, struct drm_mm_node, hole_stack)) +/* * Basic range manager support (drm_mm.c) */ -extern struct drm_mm_node *drm_mm_create_block (struct drm_mm *mm, -unsigned long start, -unsigned long size, -bool atomic); -extern struct drm_mm_node *drm_mm_get_block_generic (struct drm_mm_node *node, -unsigned long size, -unsigned alignment, -unsigned long color, -int atomic); -extern struct drm_mm_node *drm_mm_get_block_range_generic ( -struct drm_mm_node *node, -unsigned long size, -unsigned alignment, -unsigned long color, -unsigned long start, -unsigned long end, -int atomic); +extern struct drm_mm_node * +drm_mm_create_block (struct drm_mm *mm, +unsigned long start, +unsigned long size, +enum drm_mm_allocator_flags flags); +extern struct drm_mm_node * +drm_mm_get_block_generic (struct drm_mm_node *node, +unsigned long size, +unsigned alignment, +unsigned long color, +enum drm_mm_allocator_flags flags); +extern struct drm_mm_node * +drm_mm_get_block_range_generic (struct drm_mm_node *node, +unsigned long size, +unsigned alignment, +unsigned long color, +unsigned long start, +unsigned long end, +enum drm_mm_allocator_flags flags); +static inline struct drm_mm_node *drm_mm_get_block (struct drm_mm_node *parent,unsigned long size,unsigned alignment)@@ -165,7 +191,8 @@ static inline struct drm_mm_node *drm_mm_get_block_atomic(struct drm_mm_node *pa unsigned long size, unsigned alignment) { -return drm_mm_get_block_generic (parent, size, alignment,0 ,1 ); +return drm_mm_get_block_generic (parent, size, alignment,0 , +DRM_MM_CREATE_ATOMIC ); } static inline struct drm_mm_node *drm_mm_get_block_range( struct drm_mm_node *parent,@@ -196,39 +223,41 @@ static inline struct drm_mm_node *drm_mm_get_block_atomic_range( unsigned long end) {return drm_mm_get_block_range_generic (parent, size, alignment,0 , - start, end,1 ); + start, end, +DRM_MM_CREATE_ATOMIC ); } -extern int drm_mm_insert_node (struct drm_mm *mm, -struct drm_mm_node *node, -unsigned long size, -unsigned alignment); -extern int drm_mm_insert_node_in_range (struct drm_mm *mm, -struct drm_mm_node *node, -unsigned long size, -unsigned alignment, -unsigned long start, -unsigned long end);extern int drm_mm_insert_node_generic (struct drm_mm *mm,struct drm_mm_node *node,unsigned long size,unsigned alignment, -unsigned long color); -extern int drm_mm_insert_node_in_range_generic (struct drm_mm *mm, -struct drm_mm_node *node, -unsigned long size, -unsigned alignment, -unsigned long color, -unsigned long start, -unsigned long end); +unsigned long color, +enum drm_mm_allocator_flags aflags, +enum drm_mm_search_flags sflags); +#define drm_mm_insert_node (mm, node, size, alignment) \ + drm_mm_insert_node_generic(mm, node, size, alignment, 0, 0) +extern int +drm_mm_insert_node_in_range_generic (struct drm_mm *mm, +struct drm_mm_node *node, +unsigned long size, +unsigned alignment, +unsigned long color, +unsigned long start, +unsigned long end, +enum drm_mm_allocator_flags aflags, +enum drm_mm_search_flags sflags); +#define drm_mm_insert_node_in_range (mm, node, size, alignment, start, end) \ + drm_mm_insert_node_in_range_generic(mm, node, size, alignment, 0, start, end, 0)extern void drm_mm_put_block (struct drm_mm_node *cur);extern void drm_mm_remove_node (struct drm_mm_node *node);extern void drm_mm_replace_node (struct drm_mm_node *old,struct drm_mm_node *new); -extern struct drm_mm_node *drm_mm_search_free_generic (const struct drm_mm *mm, -unsigned long size, -unsigned alignment, -unsigned long color, -bool best_match); + +extern struct drm_mm_node * +drm_mm_search_free_generic (const struct drm_mm *mm, +unsigned long size, +unsigned alignment, +unsigned long color, +enum drm_mm_search_flags flags); extern struct drm_mm_node *drm_mm_search_free_in_range_generic( const struct drm_mm *mm, unsigned long size,@@ -236,13 +265,15 @@ extern struct drm_mm_node *drm_mm_search_free_in_range_generic(unsigned long color, unsigned long start, unsigned long end, - bool best_match); -static inline struct drm_mm_node *drm_mm_search_free (const struct drm_mm *mm, -unsigned long size, -unsigned alignment, -bool best_match) + enum drm_mm_search_flags flags); + +static inline struct drm_mm_node * +drm_mm_search_free (const struct drm_mm *mm, +unsigned long size, +unsigned alignment, +enum drm_mm_search_flags flags) { -return drm_mm_search_free_generic (mm,size, alignment,0 , best_match); +return drm_mm_search_free_generic (mm, size, alignment,0 , flags); } static inline struct drm_mm_node *drm_mm_search_free_in_range( const struct drm_mm *mm,@@ -250,18 +281,19 @@ static inline struct drm_mm_node *drm_mm_search_free_in_range(unsigned alignment, unsigned long start, unsigned long end, - bool best_match) + enum drm_mm_search_flags flags) { return drm_mm_search_free_in_range_generic(mm, size, alignment, 0, -start ,end ,best_match ); +start ,end ,flags ); } -static inline struct drm_mm_node *drm_mm_search_free_color (const struct drm_mm *mm, -unsigned long size, -unsigned alignment, -unsigned long color, -bool best_match) +static inline struct drm_mm_node * +drm_mm_search_free_color (const struct drm_mm *mm, +unsigned long size, +unsigned alignment, +unsigned long color, +enum drm_mm_search_flags flags) { -return drm_mm_search_free_generic (mm,size, alignment, color, best_match); +return drm_mm_search_free_generic (mm, size, alignment, color, flags); } static inline struct drm_mm_node *drm_mm_search_free_in_range_color( const struct drm_mm *mm,@@ -270,10 +302,10 @@ static inline struct drm_mm_node *drm_mm_search_free_in_range_color(unsigned long color, unsigned long start, unsigned long end, - bool best_match) + enum drm_mm_search_flags flags) { return drm_mm_search_free_in_range_generic(mm, size, alignment, color, -start ,end ,best_match ); +start ,end ,flags ); } extern int drm_mm_init(struct drm_mm *mm, unsigned long start,Signature · 6 lines
1.8.3.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 04/66] drm: Optionally create mm blocks from top-to-bottom
Quoted 15 lines · Daniel Vetter
Quoted 14 lines · Ben Widawsky
From: Chris Wilson <[email protected]>
Clients like i915 needs to segregate cache domains within the GTT which can lead to small amounts of fragmentation. By allocating the uncached buffers from the bottom and the cacheable buffers from the top, we can reduce the amount of wasted space and also optimize allocation of the mappable portion of the GTT to only those buffers that require CPU access through the GTT.
v2 by Ben:
Update callers ini915_gem_object_bind_to_gtt()Turn search flags and allocation flags into separate enums Make checkpatch happy where logical/easy
Quoted 5 lines
Quoted 2 lines
Signed-off-by Chris Wilson <[email protected]>Signed-off-by Ben Widawsky <[email protected]>Since this is a core drm patch it must be cc'ed to dri-devel (and acked by Dave) before I can merge it. Can you please resend?
And same review as for Chris' original patch still applies: best_match is unused (and it's better that way, really) so can be garbage collected.
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
PATCH 5/66 drm/i915: Don't clear gtt with 0 entries
In reply to Ben WidawskyThis will help keep the next patch cleaner which will conditionally clear the guard page, and use 0 num_entries when not actually clear space for guard page.
--- drivers/gpu/drm/i915/i915_gem_gtt.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/i915/i915_gem_gtt.c +6 -0
@@ -516,6 +516,9 @@ static void gen6_ggtt_clear_range(struct drm_device *dev,const int max_entries =gtt_total_entries (dev_priv->gtt) - first_entry;int i; +if (num_entries ==0 ) +return ; +if (WARN (num_entries > max_entries,"First entry = %d; Num entries = %d (max=%d)\n" , first_entry, num_entries, max_entries))
@@ -546,6 +549,9 @@ static void i915_ggtt_clear_range(struct drm_device *dev, unsigned int first_entry, unsigned int num_entries) { +if (num_entries ==0 ) +return ; +intel_gtt_clear_range (first_entry, num_entries); }
Signature · 1 line
1.8.3.1
PATCH 6/66 drm/i915: Conditionally use guard page based on PPGTT
In reply to Ben WidawskyThe PPGTT PDEs serve as the guard page (as long as they remain at the top) so we don't need yet another guard page. Note that there is a potential issue if the aliasing PPGTT (and later, the default context) relinquish this part of the GGTT. We should be able to assert that won't happen however.
While there, add some comments for the setup_global_gtt function which started getting complicated.
The reason I've opted not to leave out the guard_page argument is that in order to support dri1, we call the setup function, and I didn't like to have to clear the guard page in more than 1 location.
--- drivers/gpu/drm/i915/i915_drv.h | 3 ++- drivers/gpu/drm/i915/i915_gem.c | 4 ++-- drivers/gpu/drm/i915/i915_gem_gtt.c | 27 ++++++++++++++++++++++----- 3 files changed, 26 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -1
@@ -1852,7 +1852,8 @@ void i915_gem_gtt_unbind_object(struct drm_i915_gem_object *obj);void i915_gem_gtt_finish_object (struct drm_i915_gem_object *obj);void i915_gem_init_global_gtt (struct drm_device *dev);void i915_gem_setup_global_gtt (struct drm_device *dev,unsigned long start, -unsigned long mappable_end,unsigned long end); +unsigned long mappable_end,unsigned long end, +unsigned long guard_size);int i915_gem_gtt_init (struct drm_device *dev);static inline void i915_gem_chipset_flush (struct drm_device *dev) {
drivers/gpu/drm/i915/i915_gem.c +2 -2
@@ -158,8 +158,8 @@ i915_gem_init_ioctl(struct drm_device *dev, void *data,mutex_lock (&dev->struct_mutex);i915_gem_setup_global_gtt (dev, args->gtt_start, args->gtt_end, - args->gtt_end); - dev_priv->gtt.mappable_end = args->gtt_end; + args->gtt_end,PAGE_SIZE ); + dev_priv->gtt.mappable_end = args->gtt_end -PAGE_SIZE ;mutex_unlock (&dev->struct_mutex);return 0 ;
drivers/gpu/drm/i915/i915_gem_gtt.c +22 -5
@@ -613,10 +613,23 @@ static void i915_gtt_color_adjust(struct drm_mm_node *node, *end -=4096 ; } } + +/** +* i915_gem_setup_global_gtt() setup an allocator for the global GTT with the +* given parameters and initialize all PTEs to point to the scratch page. +* +* @dev +* @start - first offset of managed GGTT space +* @mappable_end - Last offset of the aperture mapped region +* @end - Last offset that can be accessed by the allocator +* @guard_size - Size to initialize to scratch after end. (Currently only used +* for prefetching case) +*/ void i915_gem_setup_global_gtt (struct drm_device *dev,unsigned long start,unsigned long mappable_end, -unsigned long end) +unsigned long end, +unsigned long guard_size) {/* Let GEM Manage all of the aperture. *
@@ -634,8 +647,11 @@ void i915_gem_setup_global_gtt(struct drm_device *dev,BUG_ON (mappable_end > end); +if (WARN_ON (guard_size & ~PAGE_MASK )) + guard_size =round_up (guard_size,PAGE_SIZE ); +/* Subtract the guard page ... */ -drm_mm_init (&dev_priv->mm.gtt_space, start, end - start -PAGE_SIZE ); +drm_mm_init (&dev_priv->mm.gtt_space, start, end - start - guard_size);if (!HAS_LLC (dev)) dev_priv->mm.gtt_space.color_adjust = i915_gtt_color_adjust;
@@ -665,7 +681,8 @@ void i915_gem_setup_global_gtt(struct drm_device *dev, }/* And finally clear the reserved guard page */ - dev_priv->gtt.gtt_clear_range (dev, end /PAGE_SIZE -1 ,1 ); + dev_priv->gtt.gtt_clear_range (dev, (end - guard_size) /PAGE_SIZE , + guard_size /PAGE_SIZE ); } static bool
@@ -700,7 +717,7 @@ void i915_gem_init_global_gtt(struct drm_device *dev) gtt_size -=GEN6_PPGTT_PD_ENTRIES *PAGE_SIZE ; } -i915_gem_setup_global_gtt (dev,0 , mappable_size, gtt_size); +i915_gem_setup_global_gtt (dev,0 , mappable_size, gtt_size,0 ); ret =i915_gem_init_aliasing_ppgtt (dev);if (!ret)
@@ -710,7 +727,7 @@ void i915_gem_init_global_gtt(struct drm_device *dev)drm_mm_takedown (&dev_priv->mm.gtt_space); gtt_size +=GEN6_PPGTT_PD_ENTRIES *PAGE_SIZE ; } -i915_gem_setup_global_gtt (dev,0 , mappable_size, gtt_size); +i915_gem_setup_global_gtt (dev,0 , mappable_size, gtt_size,PAGE_SIZE ); }static int setup_scratch_page (struct drm_device *dev)
Signature · 1 line
1.8.3.1
Re: [PATCH 06/66] drm/i915: Conditionally use guard page based on PPGTT
Quoted 111 lines · On Thu, 27 Jun 2013 16:30:07 -0700 Ben Widawsky <[email protected]> wrote:
The PPGTT PDEs serve as the guard page (as long as they remain at the top) so we don't need yet another guard page. Note that there is a potential issue if the aliasing PPGTT (and later, the default context) relinquish this part of the GGTT. We should be able to assert that won't happen however.
While there, add some comments for the
setup_global_gttfunction which started getting complicated.The reason I've opted not to leave out the
guard_pageargument is that in order to support dri1, we call the setup function, and I didn't like to have to clear the guard page in more than 1 location.Signed-off-by Ben Widawsky <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 3 ++- drivers/gpu/drm/i915/i915_gem.c | 4 ++-- drivers/gpu/drm/i915/i915_gem_gtt.c | 27 ++++++++++++++++++++++----- 3 files changed, 26 insertions(+), 8 deletions(-)drivers/gpu/drm/i915/i915_drv.h +2
-1@@ -1852,7 +1852,8 @@ void i915_gem_gtt_unbind_object(struct drm_i915_gem_object *obj);void i915_gem_gtt_finish_object (struct drm_i915_gem_object *obj);void i915_gem_init_global_gtt (struct drm_device *dev);void i915_gem_setup_global_gtt (struct drm_device *dev,unsigned long start, -unsigned long mappable_end,unsigned long end); +unsigned long mappable_end,unsigned long end, +unsigned long guard_size);int i915_gem_gtt_init (struct drm_device *dev);static inline void i915_gem_chipset_flush (struct drm_device *dev) {drivers/gpu/drm/i915/i915_gem.c +2
-2@@ -158,8 +158,8 @@ i915_gem_init_ioctl(struct drm_device *dev, void *data,mutex_lock (&dev->struct_mutex);i915_gem_setup_global_gtt (dev, args->gtt_start, args->gtt_end, - args->gtt_end); - dev_priv->gtt.mappable_end = args->gtt_end; + args->gtt_end,PAGE_SIZE ); + dev_priv->gtt.mappable_end = args->gtt_end -PAGE_SIZE ;mutex_unlock (&dev->struct_mutex);return 0 ;drivers/gpu/drm/i915/i915_gem_gtt.c +21
-4@@ -613,10 +613,23 @@ static void i915_gtt_color_adjust(struct drm_mm_node *node, *end -=4096 ; } } + +/** +* i915_gem_setup_global_gtt() setup an allocator for the global GTT with the +* given parameters and initialize all PTEs to point to the scratch page. +* +* @dev +* @start - first offset of managed GGTT space +* @mappable_end - Last offset of the aperture mapped region +* @end - Last offset that can be accessed by the allocator +* @guard_size - Size to initialize to scratch after end. (Currently only used +* for prefetching case) +*/ void i915_gem_setup_global_gtt (struct drm_device *dev,unsigned long start,unsigned long mappable_end, -unsigned long end) +unsigned long end, +unsigned long guard_size) {/* Let GEM Manage all of the aperture. * @@ -634,8 +647,11 @@ void i915_gem_setup_global_gtt(struct drm_device *dev,BUG_ON (mappable_end > end); +if (WARN_ON (guard_size & ~PAGE_MASK )) + guard_size =round_up (guard_size,PAGE_SIZE ); +/* Subtract the guard page ... */ -drm_mm_init (&dev_priv->mm.gtt_space, start, end - start -PAGE_SIZE ); +drm_mm_init (&dev_priv->mm.gtt_space, start, end - start - guard_size);if (!HAS_LLC (dev)) dev_priv->mm.gtt_space.color_adjust = i915_gtt_color_adjust;@@ -665,7 +681,8 @@ void i915_gem_setup_global_gtt(struct drm_device *dev, }/* And finally clear the reserved guard page */ - dev_priv->gtt.gtt_clear_range (dev, end /PAGE_SIZE -1 ,1 ); + dev_priv->gtt.gtt_clear_range (dev, (end - guard_size) /PAGE_SIZE , + guard_size /PAGE_SIZE ); } static bool@@ -700,7 +717,7 @@ void i915_gem_init_global_gtt(struct drm_device *dev) gtt_size -=GEN6_PPGTT_PD_ENTRIES *PAGE_SIZE ; } -i915_gem_setup_global_gtt (dev,0 , mappable_size, gtt_size); +i915_gem_setup_global_gtt (dev,0 , mappable_size, gtt_size,0 ); ret =i915_gem_init_aliasing_ppgtt (dev);if (!ret)
drivers/gpu/drm/i915/i915_gem_gtt.c void i915_gem_init_global_gtt(struct drm_device *dev) · line 733
Quoted 8 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +1
-1@@ -710,7 +727,7 @@ void i915_gem_init_global_gtt(struct drm_device *dev)drm_mm_takedown (&dev_priv->mm.gtt_space); gtt_size +=GEN6_PPGTT_PD_ENTRIES *PAGE_SIZE ; } -i915_gem_setup_global_gtt (dev,0 , mappable_size, gtt_size); +i915_gem_setup_global_gtt (dev,0 , mappable_size, gtt_size,PAGE_SIZE ); }static int setup_scratch_page (struct drm_device *dev)
Just a nitpick that can be changed with a follow on patch if others
agree: I'd rather see the WARN_ON made a BUG_ON when checking that the guard_size is a multiple of PAGE_SIZE (which, incidentally, is the wrong value to use, but that's also for another cleanup).
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
PATCH 7/66 drm/i915: Use drm_mm for PPGTT PDEs
In reply to Ben WidawskyWhen PPGTT support was originally enabled, it was only designed to support 1 PPGTT. It therefore made sense to simply hide the GGTT space required to enable this from the drm_mm allocator.
Since we intend to support full PPGTT, which means more than 1, and they can be created and destroyed ad hoc it will be required to use the proper allocation techniques we already have.
The first step here is to make the existing single PPGTT use the allocator.
v2: Align PDEs to 64b in GTT
Allocate the node dynamically so we can use drm_mm_put_block Now tested on IGT
Allocate node at the top to avoid fragmentation (Chris)
v3: Use Chris' top down allocator
v4: Embed drm_mm_node into ppgtt struct (Jesse)
Remove hunks which didn't belong (Jesse)
v5: Don't subtract guard page since we now killed the guard page prior to this patch. (Ben)
--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/i915_gem_gtt.c | 45 ++++++++++++++++++++++++------------- 2 files changed, 31 insertions(+), 15 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -484,6 +484,7 @@ struct i915_gtt {#define gtt_total_entries (gtt) ((gtt).total >> PAGE_SHIFT)struct i915_hw_ppgtt { +struct drm_mm_node node;struct drm_device *dev;unsigned num_pd_entries;struct page **pt_pages;
drivers/gpu/drm/i915/i915_gem_gtt.c +30 -15
100 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [PATCH 07/66] drm/i915: Use drm_mm for PPGTT PDEs
Quoted 144 lines · On Thu, 27 Jun 2013 16:30:08 -0700 Ben Widawsky <[email protected]> wrote:
When PPGTT support was originally enabled, it was only designed to support 1 PPGTT. It therefore made sense to simply hide the GGTT space required to enable this from the
drm_mmallocator.Since we intend to support full PPGTT, which means more than 1, and they can be created and destroyed ad hoc it will be required to use the proper allocation techniques we already have.
The first step here is to make the existing single PPGTT use the allocator.
v2: Align PDEs to 64b in GTT
Allocate the node dynamically so we can usedrm_mm_put_blockNow tested on IGT
Allocate node at the top to avoid fragmentation (Chris)v3: Use Chris' top down allocator
v4: Embed
drm_mm_nodeinto ppgtt struct (Jesse)
Remove hunks which didn't belong (Jesse)v5: Don't subtract guard page since we now killed the guard page prior to this patch. (Ben)
Cc Chris Wilson <[email protected]>Reviewed-by Jesse Barnes <[email protected]>Signed-off-by Ben Widawsky <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/i915_gem_gtt.c | 45 ++++++++++++++++++++++++------------- 2 files changed, 31 insertions(+), 15 deletions(-)drivers/gpu/drm/i915/i915_drv.h +1
-0@@ -484,6 +484,7 @@ struct i915_gtt {#define gtt_total_entries (gtt) ((gtt).total >> PAGE_SHIFT)struct i915_hw_ppgtt { +struct drm_mm_node node;struct drm_device *dev;unsigned num_pd_entries;struct page **pt_pages;drivers/gpu/drm/i915/i915_gem_gtt.c +30
-14@@ -247,6 +247,8 @@ static void gen6_ppgtt_cleanup(struct i915_hw_ppgtt *ppgtt) {int i; +drm_mm_remove_node (&ppgtt->node); +if (ppgtt->pt_dma_addr) {for (i =0 ; i < ppgtt->num_pd_entries; i++) pci_unmap_page(ppgtt->dev->pdev,@@ -263,16 +265,27 @@ static void gen6_ppgtt_cleanup(struct i915_hw_ppgtt *ppgtt)static int gen6_ppgtt_init (struct i915_hw_ppgtt *ppgtt) { +#define GEN6_PD_ALIGN (PAGE_SIZE * 16) +#define GEN6_PD_SIZE (GEN6_PPGTT_PD_ENTRIES * PAGE_SIZE)struct drm_device *dev = ppgtt->dev;struct drm_i915_private *dev_priv = dev->dev_private; -unsigned first_pd_entry_in_global_pt;int i;int ret = -ENOMEM ; -/* ppgtt PDEs reside in the global gtt pagetable, which has 512*1024 -* entries. For aliasing ppgtt support we just steal them at the end for -* now. */ - first_pd_entry_in_global_pt =gtt_total_entries (dev_priv->gtt); +/* PPGTT PDEs reside in the GGTT stolen space, and consists of 512 +* entries. The allocator works in address space sizes, so it's +* multiplied by page size. We allocate at the top of the GTT to avoid +* fragmentation. +*/ +BUG_ON (!drm_mm_initialized (&dev_priv->mm.gtt_space)); + ret =drm_mm_insert_node_in_range_generic (&dev_priv->mm.gtt_space, + &ppgtt->node,GEN6_PD_SIZE , +GEN6_PD_ALIGN ,0 , + dev_priv->gtt.mappable_end, + dev_priv->gtt.total, +DRM_MM_TOPDOWN ); +if (ret) +return ret;if (IS_HASWELL (dev)) { ppgtt->pte_encode = hsw_pte_encode;@@ -288,8 +301,10 @@ static int gen6_ppgtt_init(struct i915_hw_ppgtt *ppgtt) ppgtt->cleanup = gen6_ppgtt_cleanup; ppgtt->pt_pages =kzalloc (sizeof (struct page *)*ppgtt->num_pd_entries,GFP_KERNEL ); -if (!ppgtt->pt_pages) +if (!ppgtt->pt_pages) { +drm_mm_remove_node (&ppgtt->node);return -ENOMEM ; + }for (i =0 ; i < ppgtt->num_pd_entries; i++) { ppgtt->pt_pages[i] =alloc_page (GFP_KERNEL );@@ -319,7 +334,11 @@ static int gen6_ppgtt_init(struct i915_hw_ppgtt *ppgtt) ppgtt->clear_range (ppgtt,0 , ppgtt->num_pd_entries*I915_PPGTT_PT_ENTRIES ); - ppgtt->pd_offset = first_pd_entry_in_global_pt *sizeof (gen6_gtt_pte_t); +DRM_DEBUG_DRIVER ("Allocated pde space (%ldM) at GTT entry: %lx\n" , + ppgtt->node.size >>20 , + ppgtt->node.start /PAGE_SIZE ); + ppgtt->pd_offset = + ppgtt->node.start /PAGE_SIZE *sizeof (gen6_gtt_pte_t);return 0 ;@@ -336,6 +355,7 @@ err_pt_alloc:__free_page (ppgtt->pt_pages[i]); }kfree (ppgtt->pt_pages); +drm_mm_remove_node (&ppgtt->node);return ret; }@@ -442,6 +462,9 @@ void i915_gem_restore_gtt_mappings(struct drm_device *dev) dev_priv->gtt.gtt_clear_range (dev, dev_priv->gtt.start /PAGE_SIZE , dev_priv->gtt.total /PAGE_SIZE ); +if (dev_priv->mm.aliasing_ppgtt) +gen6_write_pdes (dev_priv->mm.aliasing_ppgtt); +list_for_each_entry (obj, &dev_priv->mm.bound_list, global_list) {i915_gem_clflush_object (obj);i915_gem_gtt_bind_object (obj, obj->cache_level);@@ -711,21 +734,13 @@ void i915_gem_init_global_gtt(struct drm_device *dev)if (intel_enable_ppgtt (dev) &&HAS_ALIASING_PPGTT (dev)) {int ret; -if (INTEL_INFO (dev)->gen <=7 ) { -/* PPGTT pdes are stolen from global gtt ptes, so shrink the -* aperture accordingly when using aliasing ppgtt. */ - gtt_size -=GEN6_PPGTT_PD_ENTRIES *PAGE_SIZE ; - } -i915_gem_setup_global_gtt (dev,0 , mappable_size, gtt_size,0 ); -
drivers/gpu/drm/i915/i915_gem_gtt.c void i915_gem_init_global_gtt(struct drm_device *dev) · line 746
Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +0
-1ret =i915_gem_init_aliasing_ppgtt (dev);if (!ret)return ;DRM_ERROR ("Aliased PPGTT setup failed %d\n" , ret);drm_mm_takedown (&dev_priv->mm.gtt_space); - gtt_size +=GEN6_PPGTT_PD_ENTRIES *PAGE_SIZE ; }i915_gem_setup_global_gtt (dev,0 , mappable_size, gtt_size,PAGE_SIZE ); }
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
PATCH 8/66 drm/i915: cleanup context fini
In reply to Ben WidawskyWith the introduction of context refcounting we never explicitly ref/unref the backing object. As such, the previous fix was a bit wonky.
Aside from fixing the above, this patch also puts us in good shape for an upcoming patch which allows a failure to occur in between context_init and the first do_switch.
--- drivers/gpu/drm/i915/i915_gem_context.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_gem_context.c +13 -4
@@ -213,7 +213,6 @@ static int create_default_context(struct drm_i915_private *dev_priv)* may not be available. To avoid this we always pin the * default context. */ - dev_priv->ring[RCS ].default_context = ctx; ret =i915_gem_object_pin (ctx->obj,CONTEXT_ALIGN , false, false);if (ret) {DRM_DEBUG_DRIVER ("Couldn't pin %d\n" , ret);
@@ -226,6 +225,8 @@ static int create_default_context(struct drm_i915_private *dev_priv) goto err_unpin; } + dev_priv->ring[RCS ].default_context = ctx; +DRM_DEBUG_DRIVER ("Default HW context loaded\n" );return 0 ;
@@ -281,16 +282,24 @@ void i915_gem_context_fini(struct drm_device *dev)* other code, leading to spurious errors. */ intel_gpu_reset (dev); -i915_gem_object_unpin (dctx->obj); -/* When default context is created and switched to, base object refcount * will be 2 (+1 from object creation and +1 from do_switch()). * i915_gem_context_fini() will be called after gpu_idle() has switched * to default context. So we need to unreference the base object once * to offset the do_switch part, so that i915_gem_context_unreference() * can then free the base object correctly. */ -drm_gem_object_unreference (&dctx->obj->base); +WARN_ON (!dev_priv->ring[RCS ].last_context); +if (dev_priv->ring[RCS ].last_context == dctx) { +/* Fake switch to NULL context */ +WARN_ON (dctx->obj->active); +i915_gem_object_unpin (dctx->obj); +i915_gem_context_unreference (dctx); + } + +i915_gem_object_unpin (dctx->obj);i915_gem_context_unreference (dctx); + dev_priv->ring[RCS ].default_context =NULL ; + dev_priv->ring[RCS ].last_context =NULL ; }static int context_idr_cleanup (int id,void *p,void *data)
Signature · 1 line
1.8.3.1
PATCH 9/66 drm/i915: Do a fuller init after reset
In reply to Ben WidawskyIt's convenient to just call i915_gem_init_hw at reset because we'll be adding new things to that function, and having just one function to call instead of reimplementing it in two places is nice.
In order to accommodate we cleanup ringbuffers in order to bring them back up cleanly. Optionally, we could also teardown/re initialize the default context but this was causing some problems on reset which I wasn't able to fully debug, and is unnecessary with the previous context init/enable split.
This essentially reverts:
commit 8e88a2bd5987178d16d53686197404e149e996d9
Author: Daniel Vetter <[email protected]> Date: Tue Jun 19 18:40:00 2012 +0200
drm/i915: don't call modeset_init_hw in i915_reset
It seems to work for me on ILK now. Perhaps it's due to:
commit 8a5c2ae753c588bcb2a4e38d1c6a39865dbf1ff3
Author: Jesse Barnes <[email protected]> Date: Thu Mar 28 13:57:19 2013 -0700
drm/i915: fix ILK GPU reset for render
--- drivers/gpu/drm/i915/i915_drv.c | 29 ++++++++--------------------- drivers/gpu/drm/i915/i915_gem.c | 2 ++ drivers/gpu/drm/i915/intel_ringbuffer.c | 3 ++- 3 files changed, 12 insertions(+), 22 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +8 -21
@@ -944,30 +944,17 @@ int i915_reset(struct drm_device *dev)*/ if (drm_core_check_feature (dev,DRIVER_MODESET ) || !dev_priv->mm.suspended) { -struct intel_ring_buffer *ring; -int i; - +bool hw_contexts_disabled = dev_priv->hw_contexts_disabled; dev_priv->mm.suspended =0 ; -i915_gem_init_swizzling (dev); - -for_each_ring (ring, dev_priv, i) - ring->init (ring); - -i915_gem_context_init (dev); -if (dev_priv->mm.aliasing_ppgtt) { - ret = dev_priv->mm.aliasing_ppgtt->enable (dev); -if (ret) -i915_gem_cleanup_aliasing_ppgtt (dev); - } - -/* -* It would make sense to re-init all the other hw state, at -* least the rps/rc6/emon init done within modeset_init_hw. For -* some unknown reason, this blows up my ilk, so don't. -*/ - + ret =i915_gem_init_hw (dev); +if (!hw_contexts_disabled && dev_priv->hw_contexts_disabled) +DRM_ERROR ("HW contexts didn't survive reset\n" );mutex_unlock (&dev->struct_mutex); +if (ret) { +DRM_ERROR ("Failed hw init on reset %d\n" , ret); +return ret; + }drm_irq_uninstall (dev);drm_irq_install (dev);
drivers/gpu/drm/i915/i915_gem.c +2 -0
@@ -2274,6 +2274,8 @@ bool i915_gem_reset(struct drm_device *dev)for_each_ring (ring, dev_priv, i) ctx_banned |=i915_gem_reset_ring_lists (dev_priv, ring); +i915_gem_cleanup_ringbuffer (dev); +/* Move everything out of the GPU domains to ensure we do any * necessary invalidation upon reuse. */
drivers/gpu/drm/i915/intel_ringbuffer.c +2 -1
@@ -1353,7 +1353,7 @@ void intel_cleanup_ring_buffer(struct intel_ring_buffer *ring)/* Disable the ring buffer. The ring must be idle at this point */ dev_priv = ring->dev->dev_private; ret =intel_ring_idle (ring); -if (ret) +if (ret && !i915_reset_in_progress (&dev_priv->gpu_error))DRM_ERROR ("failed to quiesce %s whilst cleaning up: %d\n" , ring->name, ret);
@@ -1364,6 +1364,7 @@ void intel_cleanup_ring_buffer(struct intel_ring_buffer *ring)i915_gem_object_unpin (ring->obj);drm_gem_object_unreference (&ring->obj->base); ring->obj =NULL ; + ring->outstanding_lazy_request =0 ;if (ring->cleanup) ring->cleanup (ring);
Signature · 1 line
1.8.3.1
PATCH 10/66 drm/i915: Split context enabling from init
In reply to Ben WidawskyWe **need** to do this for exactly 1 reason, because we want to embed a PPGTT into the context, but we don't want to special case the default context.
To achieve that, we must be able to initialize contexts after the GTT is setup (so we can allocate and pin the default context's BO), but before the PPGTT and rings are initialized. This is because, currently, context initialization requires ring usage. We don't have rings until after the GTT is setup. If we split the enabling part of context initialization, the part requiring the ringbuffer, we can untangle this, and then later embed the PPGTT
Incidentally this allows us to also adhere to the original design of context init/fini in future patches: they were only ever meant to be called at driver load and unload.
v2: Move hw_contexts_disabled test in i915_gem_context_enable() (Chris)
v3: BUG_ON after checking for disabled contexts. Or else it blows up pre gen6 (Ben)
--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/i915_gem.c | 15 ++++++++++++--- drivers/gpu/drm/i915/i915_gem_context.c | 23 ++++++++++++----------- 3 files changed, 25 insertions(+), 14 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -1814,6 +1814,7 @@ void i915_gem_restore_fences(struct drm_device *dev);/* i915_gem_context.c */ void i915_gem_context_init (struct drm_device *dev);void i915_gem_context_fini (struct drm_device *dev); +int i915_gem_context_enable (struct drm_i915_private *dev_priv);void i915_gem_context_close (struct drm_device *dev,struct drm_file *file);int i915_switch_context (struct intel_ring_buffer *ring,struct drm_file *file,int to_id);
drivers/gpu/drm/i915/i915_gem.c +12 -3
@@ -4184,10 +4184,17 @@ i915_gem_init_hw(struct drm_device *dev)return ret;/* -* XXX: There was some w/a described somewhere suggesting loading -* contexts before PPGTT. +* XXX: Contexts should only be initialized once. Doing a switch to the +* default context switch however is something we'd like to do after +* reset or thaw (the latter may not actually be necessary for HW, but +* goes with our code better). Context switching requires rings (for +* the do_switch), but before enabling PPGTT. So don't move this. */ -i915_gem_context_init (dev); +if (i915_gem_context_enable (dev_priv)) { +i915_gem_context_fini (dev); + dev_priv->hw_contexts_disabled = true; + } +if (dev_priv->mm.aliasing_ppgtt) { ret = dev_priv->mm.aliasing_ppgtt->enable (dev);if (ret) {
@@ -4215,6 +4222,8 @@ int i915_gem_init(struct drm_device *dev)i915_gem_init_global_gtt (dev); +i915_gem_context_init (dev); + ret =i915_gem_init_hw (dev);mutex_unlock (&dev->struct_mutex);if (ret) {
drivers/gpu/drm/i915/i915_gem_context.c +12 -11
@@ -219,19 +219,11 @@ static int create_default_context(struct drm_i915_private *dev_priv) goto err_destroy; } - ret =do_switch (ctx); -if (ret) { -DRM_DEBUG_DRIVER ("Switch failed %d\n" , ret); - goto err_unpin; - } - dev_priv->ring[RCS ].default_context = ctx;DRM_DEBUG_DRIVER ("Default HW context loaded\n" );return 0 ; -err_unpin: -i915_gem_object_unpin (ctx->obj); err_destroy:i915_gem_context_unreference (ctx);return ret;
@@ -247,9 +239,10 @@ void i915_gem_context_init(struct drm_device *dev)return ; } -/* If called from reset, or thaw... we've been here already */ -if (dev_priv->hw_contexts_disabled || - dev_priv->ring[RCS ].default_context) +/* Init should only be called once per module load. Eventually the +* restriction on the context_disabled check can be loosened. */ +if (WARN_ON (dev_priv->hw_contexts_disabled || +WARN_ON (dev_priv->ring[RCS ].default_context)))return ; dev_priv->hw_context_size =round_up (get_context_size (dev),4096 );
@@ -302,6 +295,14 @@ void i915_gem_context_fini(struct drm_device *dev) dev_priv->ring[RCS ].last_context =NULL ; } +int i915_gem_context_enable (struct drm_i915_private *dev_priv) +{ +if (dev_priv->hw_contexts_disabled) +return 0 ; +BUG_ON (!dev_priv->ring[RCS ].default_context); +return do_switch (dev_priv->ring[RCS ].default_context); +} +static int context_idr_cleanup (int id,void *p,void *data) {struct i915_hw_context *ctx = p;
Signature · 1 line
1.8.3.1
PATCH 11/66 drm/i915: destroy i915_gem_init_global_gtt
In reply to Ben WidawskyIn continuing to make default context/aliasing PPGTT behave like any other context/PPGTT pair this patch sets us up by moving the context/PPGTT init to a common location.
The resulting code isn't a huge improvement, but that will change in the next patch (at least a bit).
In the process of doing this, make the ppgtt init function a bit more generic
--- drivers/gpu/drm/i915/i915_drv.h | 4 +-- drivers/gpu/drm/i915/i915_gem.c | 36 ++++++++++++++++++--- drivers/gpu/drm/i915/i915_gem_gtt.c | 63 +++++++++---------------------------- 3 files changed, 48 insertions(+), 55 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -2
@@ -1839,20 +1839,20 @@ int i915_gem_context_destroy_ioctl(struct drm_device *dev, void *data, struct drm_file *file);/* i915_gem_gtt.c */ +bool intel_enable_ppgtt (struct drm_device *dev); +int i915_gem_ppgtt_init (struct drm_device *dev,struct i915_hw_ppgtt *ppgtt);void i915_gem_cleanup_aliasing_ppgtt (struct drm_device *dev);void i915_ppgtt_bind_object (struct i915_hw_ppgtt *ppgtt,struct drm_i915_gem_object *obj,enum i915_cache_level cache_level);void i915_ppgtt_unbind_object (struct i915_hw_ppgtt *ppgtt,struct drm_i915_gem_object *obj); -void i915_gem_restore_gtt_mappings (struct drm_device *dev);int __must_check i915_gem_gtt_prepare_object (struct drm_i915_gem_object *obj);void i915_gem_gtt_bind_object (struct drm_i915_gem_object *obj,enum i915_cache_level cache_level);void i915_gem_gtt_unbind_object (struct drm_i915_gem_object *obj);void i915_gem_gtt_finish_object (struct drm_i915_gem_object *obj); -void i915_gem_init_global_gtt (struct drm_device *dev);void i915_gem_setup_global_gtt (struct drm_device *dev,unsigned long start,unsigned long mappable_end,unsigned long end,unsigned long guard_size);
drivers/gpu/drm/i915/i915_gem.c +31 -5
@@ -4209,7 +4209,7 @@ i915_gem_init_hw(struct drm_device *dev)int i915_gem_init (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; -int ret; +int ret = -ENODEV ;mutex_lock (&dev->struct_mutex);
@@ -4220,16 +4220,42 @@ int i915_gem_init(struct drm_device *dev)DRM_DEBUG_DRIVER ("allow wake ack timed out\n" ); } -i915_gem_init_global_gtt (dev); +if (intel_enable_ppgtt (dev) &&HAS_ALIASING_PPGTT (dev)) { +struct i915_hw_ppgtt *ppgtt; + ppgtt =kzalloc (sizeof (*ppgtt),GFP_KERNEL ); +if (!ppgtt) + goto ggtt_only; + + +i915_gem_setup_global_gtt (dev,0 , dev_priv->gtt.mappable_end, + dev_priv->gtt.total,0 ); +i915_gem_context_init (dev); + ret =i915_gem_ppgtt_init (dev, ppgtt); +if (ret) { +kfree (ppgtt); +drm_mm_takedown (&dev_priv->mm.gtt_space); + goto ggtt_only; + } -i915_gem_context_init (dev); + dev_priv->mm.aliasing_ppgtt = ppgtt; + } + +ggtt_only: +if (ret) { +if (intel_enable_ppgtt (dev) &&HAS_ALIASING_PPGTT (dev)) +DRM_DEBUG_DRIVER ("Aliased PPGTT setup fail %d\n" , ret); +i915_gem_setup_global_gtt (dev,0 , dev_priv->gtt.mappable_end, + dev_priv->gtt.total,PAGE_SIZE ); + } ret =i915_gem_init_hw (dev); -mutex_unlock (&dev->struct_mutex);if (ret) {i915_gem_cleanup_aliasing_ppgtt (dev); -return ret; +i915_gem_context_fini (dev); } +mutex_unlock (&dev->struct_mutex); +if (ret) +return ret;/* Allow hardware batchbuffers unless told otherwise, but not for KMS. */ if (!drm_core_check_feature (dev,DRIVER_MODESET ))
drivers/gpu/drm/i915/i915_gem_gtt.c +15 -48
91 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 12/66 drm/i915: Embed PPGTT into the context
In reply to Ben WidawskyMy long term vision is for contexts to have a 1:1 relationship with a PPGTT. Sharing objects between address spaces would work similarly to the flink/dmabuf model if needed.
The only current code to convert is the aliasing PPGTT. The aliasing PPGTT is just the PPGTT for the default context.
The obvious downside is until we actually do PPGTT switches, this wastes a bit of memory. ie. by the end of the series, it's a don't care. The other downside is PPGTT can't work without contexts, which *should* have already been the case except for debugging scenarios. (Note the does break the potential to easily use contexts on GEN5 since I believe our odds of running PPGTT on GEN5 are fairly close to 0)
--- drivers/gpu/drm/i915/i915_drv.h | 2 ++ drivers/gpu/drm/i915/i915_gem.c | 14 ++++++++------ drivers/gpu/drm/i915/i915_gem_gtt.c | 1 - 3 files changed, 10 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -0
@@ -531,6 +531,8 @@ struct i915_hw_context {struct intel_ring_buffer *ring;struct drm_i915_gem_object *obj;struct i915_ctx_hang_stats hang_stats; + +struct i915_hw_ppgtt ppgtt; };enum no_fbc_reason {
drivers/gpu/drm/i915/i915_gem.c +8 -6
@@ -4222,17 +4222,19 @@ int i915_gem_init(struct drm_device *dev)if (intel_enable_ppgtt (dev) &&HAS_ALIASING_PPGTT (dev)) {struct i915_hw_ppgtt *ppgtt; - ppgtt =kzalloc (sizeof (*ppgtt),GFP_KERNEL ); -if (!ppgtt) - goto ggtt_only; -i915_gem_setup_global_gtt (dev,0 , dev_priv->gtt.mappable_end, dev_priv->gtt.total,0 );i915_gem_context_init (dev); +if (dev_priv->hw_contexts_disabled) { +drm_mm_takedown (&dev_priv->mm.gtt_space); + goto ggtt_only; + } + + ppgtt = &dev_priv->ring[RCS ].default_context->ppgtt; + ret =i915_gem_ppgtt_init (dev, ppgtt); -if (ret) { -kfree (ppgtt); +if (ret) {drm_mm_takedown (&dev_priv->mm.gtt_space); goto ggtt_only; }
drivers/gpu/drm/i915/i915_gem_gtt.c +0 -1
@@ -260,7 +260,6 @@ static void gen6_ppgtt_cleanup(struct i915_hw_ppgtt *ppgtt)for (i =0 ; i < ppgtt->num_pd_entries; i++)__free_page (ppgtt->pt_pages[i]);kfree (ppgtt->pt_pages); -kfree (ppgtt); }static int gen6_ppgtt_init (struct i915_hw_ppgtt *ppgtt)
Signature · 1 line
1.8.3.1
PATCH 13/66 drm/i915: Unify PPGTT codepaths on gen6+
In reply to Ben WidawskyThis will allow us to use the same code paths whether or not we have PPGTT actually turned on. It will do all but actually enable the bits that tell the HW to use PPGTT.
This patch also will help tie together contexts and PPGTT in the next patch. That patch wants to disable contexts if there is no PPGTT, and we disable PPGTT on gen6 with VT-D. Since Mesa depends on gen6+ having HW contexts, this is a requirement.
--- drivers/gpu/drm/i915/i915_dma.c | 3 ++- drivers/gpu/drm/i915/i915_gem.c | 6 +++++- drivers/gpu/drm/i915/i915_gem_gtt.c | 4 +++- 3 files changed, 10 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +2 -1
@@ -977,7 +977,8 @@ static int i915_getparam(struct drm_device *dev, void *data, value =HAS_LLC (dev);break ;case I915_PARAM_HAS_ALIASING_PPGTT : - value = dev_priv->mm.aliasing_ppgtt ?1 :0 ; +if (intel_enable_ppgtt (dev) && dev_priv->mm.aliasing_ppgtt) + value =1 ;break ;case I915_PARAM_HAS_WAIT_TIMEOUT : value =1 ;
drivers/gpu/drm/i915/i915_gem.c +5 -1
@@ -4220,7 +4220,11 @@ int i915_gem_init(struct drm_device *dev)DRM_DEBUG_DRIVER ("allow wake ack timed out\n" ); } -if (intel_enable_ppgtt (dev) &&HAS_ALIASING_PPGTT (dev)) { +/* NB: In order to keep the code paths for all platforms with PPGTT the +* same, we run through this next section regardless, but don't actually +* enable the PPGTT via GFX_MODE. +*/ +if (HAS_ALIASING_PPGTT (dev)) {struct i915_hw_ppgtt *ppgtt; i915_gem_setup_global_gtt(dev, 0, dev_priv->gtt.mappable_end,
drivers/gpu/drm/i915/i915_gem_gtt.c +3 -1
@@ -154,7 +154,9 @@ static int gen6_ppgtt_enable(struct drm_device *dev) ecochk =I915_READ (GAM_ECOCHK );I915_WRITE (GAM_ECOCHK , ecochk |ECOCHK_SNB_BIT |ECOCHK_PPGTT_CACHE64B ); -I915_WRITE (GFX_MODE ,_MASKED_BIT_ENABLE (GFX_PPGTT_ENABLE )); +if (intel_enable_ppgtt (dev)) +I915_WRITE (GFX_MODE , +_MASKED_BIT_ENABLE (GFX_PPGTT_ENABLE )); }else if (INTEL_INFO (dev)->gen >=7 ) {uint32_t ecochk, ecobits;
Signature · 1 line
1.8.3.1
PATCH 14/66 drm/i915: Move ppgtt initialization down
In reply to Ben WidawskyThis will allows us to be able to check whether PPGTT was initialized not by the pointer, but by the values of it's function pointers.
This will be used in the next patch in order to determine at context destruction if the PPGTT needs cleanup. It should only occur in error cases.
--- drivers/gpu/drm/i915/i915_gem_gtt.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
drivers/gpu/drm/i915/i915_gem_gtt.c +11 -9
@@ -295,30 +295,26 @@ static int gen6_ppgtt_init(struct i915_hw_ppgtt *ppgtt) }else { ppgtt->pte_encode = gen6_pte_encode; } - ppgtt->num_pd_entries =GEN6_PPGTT_PD_ENTRIES ; - ppgtt->enable = gen6_ppgtt_enable; - ppgtt->clear_range = gen6_ppgtt_clear_range; - ppgtt->insert_entries = gen6_ppgtt_insert_entries; - ppgtt->cleanup = gen6_ppgtt_cleanup; - ppgtt->pt_pages =kzalloc (sizeof (struct page *)*ppgtt->num_pd_entries, + + ppgtt->pt_pages =kzalloc (sizeof (struct page *)*GEN6_PPGTT_PD_ENTRIES ,GFP_KERNEL );if (!ppgtt->pt_pages) {drm_mm_remove_node (&ppgtt->node);return -ENOMEM ; } -for (i =0 ; i < ppgtt->num_pd_entries; i++) { +for (i =0 ; i <GEN6_PPGTT_PD_ENTRIES ; i++) { ppgtt->pt_pages[i] =alloc_page (GFP_KERNEL );if (!ppgtt->pt_pages[i]) goto err_pt_alloc; } - ppgtt->pt_dma_addr =kzalloc (sizeof (dma_addr_t) *ppgtt->num_pd_entries, + ppgtt->pt_dma_addr =kzalloc (sizeof (dma_addr_t) *GEN6_PPGTT_PD_ENTRIES ,GFP_KERNEL );if (!ppgtt->pt_dma_addr) goto err_pt_alloc; -for (i =0 ; i < ppgtt->num_pd_entries; i++) { +for (i =0 ; i <GEN6_PPGTT_PD_ENTRIES ; i++) {dma_addr_t pt_addr; pt_addr = pci_map_page(dev->pdev, ppgtt->pt_pages[i], 0, 4096,
@@ -332,6 +328,12 @@ static int gen6_ppgtt_init(struct i915_hw_ppgtt *ppgtt) ppgtt->pt_dma_addr[i] = pt_addr; } + ppgtt->num_pd_entries =GEN6_PPGTT_PD_ENTRIES ; + ppgtt->enable = gen6_ppgtt_enable; + ppgtt->clear_range = gen6_ppgtt_clear_range; + ppgtt->insert_entries = gen6_ppgtt_insert_entries; + ppgtt->cleanup = gen6_ppgtt_cleanup; + ppgtt->clear_range (ppgtt,0 , ppgtt->num_pd_entries*I915_PPGTT_PT_ENTRIES );
Signature · 1 line
1.8.3.1
PATCH 15/66 drm/i915: Tie context to PPGTT
In reply to Ben WidawskyThis is the second half to the previous patch in that now if PPGTT fails to come up, contexts are disabled, and we don't even try to bring up contexts when we don't have PPGTT support.
NB: PPGTT cleanup is now done in context unreference.
v2: Only cleanup if we set a cleanup vfunc. Don't clean PPGTT up on the failure paths, leave it to unref.
--- drivers/gpu/drm/i915/i915_dma.c | 2 -- drivers/gpu/drm/i915/i915_drv.h | 4 +-- drivers/gpu/drm/i915/i915_gem.c | 49 ++++++++++++--------------------- drivers/gpu/drm/i915/i915_gem_context.c | 8 ++++++ drivers/gpu/drm/i915/i915_gem_gtt.c | 12 -------- 5 files changed, 28 insertions(+), 47 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +0 -2
@@ -1363,7 +1363,6 @@ cleanup_gem:i915_gem_cleanup_ringbuffer (dev);i915_gem_context_fini (dev);mutex_unlock (&dev->struct_mutex); -i915_gem_cleanup_aliasing_ppgtt (dev);drm_mm_takedown (&dev_priv->mm.gtt_space); cleanup_irq:drm_irq_uninstall (dev);
@@ -1748,7 +1747,6 @@ int i915_driver_unload(struct drm_device *dev)i915_gem_cleanup_ringbuffer (dev);i915_gem_context_fini (dev);mutex_unlock (&dev->struct_mutex); -i915_gem_cleanup_aliasing_ppgtt (dev);i915_gem_cleanup_stolen (dev);if (!I915_NEED_GFX_HWS (dev))
drivers/gpu/drm/i915/i915_drv.h +2 -2
@@ -1454,8 +1454,9 @@ struct drm_i915_file_private {#define HAS_LLC (dev) (INTEL_INFO(dev)->has_llc)#define I915_NEED_GFX_HWS (dev) (INTEL_INFO(dev)->need_gfx_hws) -#define HAS_HW_CONTEXTS (dev) (INTEL_INFO(dev)->gen >= 6)#define HAS_ALIASING_PPGTT (dev) (INTEL_INFO(dev)->gen >=6 && !IS_VALLEYVIEW(dev)) +#define HAS_HW_CONTEXTS (dev) (INTEL_INFO(dev)->gen >= 6 && \ + HAS_ALIASING_PPGTT(dev))#define HAS_OVERLAY (dev) (INTEL_INFO(dev)->has_overlay)#define OVERLAY_NEEDS_PHYSICAL (dev) (INTEL_INFO(dev)->overlay_needs_physical)
@@ -1843,7 +1844,6 @@ int i915_gem_context_destroy_ioctl(struct drm_device *dev, void *data,/* i915_gem_gtt.c */ bool intel_enable_ppgtt (struct drm_device *dev);int i915_gem_ppgtt_init (struct drm_device *dev,struct i915_hw_ppgtt *ppgtt); -void i915_gem_cleanup_aliasing_ppgtt (struct drm_device *dev);void i915_ppgtt_bind_object (struct i915_hw_ppgtt *ppgtt,struct drm_i915_gem_object *obj,enum i915_cache_level cache_level);
drivers/gpu/drm/i915/i915_gem.c +18 -31
78 lines not on this page · raw message
drivers/gpu/drm/i915/i915_gem_context.c +8 -0
@@ -129,6 +129,8 @@ void i915_gem_context_free(struct kref *ctx_ref)struct i915_hw_context *ctx =container_of (ctx_ref,typeof (*ctx), ref); +if (ctx->ppgtt.cleanup) + ctx->ppgtt.cleanup (&ctx->ppgtt);drm_gem_object_unreference (&ctx->obj->base);kfree (ctx); }
@@ -167,6 +169,10 @@ create_hw_context(struct drm_device *dev,*/ ctx->ring = &dev_priv->ring[RCS ]; + ret =i915_gem_ppgtt_init (dev, &ctx->ppgtt); +if (ret) + goto err_out; +/* Default context will never have a file_priv */ if (file_priv ==NULL )return ctx;
@@ -220,6 +226,7 @@ static int create_default_context(struct drm_i915_private *dev_priv) } dev_priv->ring[RCS ].default_context = ctx; + dev_priv->mm.aliasing_ppgtt = &ctx->ppgtt;DRM_DEBUG_DRIVER ("Default HW context loaded\n" );return 0 ;
@@ -293,6 +300,7 @@ void i915_gem_context_fini(struct drm_device *dev)i915_gem_context_unreference (dctx); dev_priv->ring[RCS ].default_context =NULL ; dev_priv->ring[RCS ].last_context =NULL ; + dev_priv->mm.aliasing_ppgtt =NULL ; }int i915_gem_context_enable (struct drm_i915_private *dev_priv)
drivers/gpu/drm/i915/i915_gem_gtt.c +0 -12
@@ -379,18 +379,6 @@ int i915_gem_ppgtt_init(struct drm_device *dev, struct i915_hw_ppgtt *ppgtt)return ret; } -void i915_gem_cleanup_aliasing_ppgtt (struct drm_device *dev) -{ -struct drm_i915_private *dev_priv = dev->dev_private; -struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; - -if (!ppgtt) -return ; - - ppgtt->cleanup (ppgtt); - dev_priv->mm.aliasing_ppgtt =NULL ; -} -void i915_ppgtt_bind_object (struct i915_hw_ppgtt *ppgtt,struct drm_i915_gem_object *obj,enum i915_cache_level cache_level)
Signature · 1 line
1.8.3.1
PATCH 16/66 drm/i915: Really share scratch page
In reply to Ben WidawskyA previous patch had set up the ppgtt and ggtt to use the same scratch page, but still kept around both pointers. Kill it, it's not needed and gets in our way for upcoming cleanups.
--- drivers/gpu/drm/i915/i915_drv.h | 1 - drivers/gpu/drm/i915/i915_gem_gtt.c | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +0 -1
@@ -490,7 +490,6 @@ struct i915_hw_ppgtt {struct page **pt_pages;uint32_t pd_offset;dma_addr_t *pt_dma_addr; -dma_addr_t scratch_page_dma_addr;/* pte functions, mirroring the interface of the global gtt. */ void (*clear_range)(struct i915_hw_ppgtt *ppgtt,
drivers/gpu/drm/i915/i915_gem_gtt.c +2 -3
@@ -190,13 +190,14 @@ static void gen6_ppgtt_clear_range(struct i915_hw_ppgtt *ppgtt, unsigned first_entry, unsigned num_entries) { +struct drm_i915_private *dev_priv = ppgtt->dev->dev_private;gen6_gtt_pte_t *pt_vaddr, scratch_pte;unsigned act_pt = first_entry /I915_PPGTT_PT_ENTRIES ;unsigned first_pte = first_entry %I915_PPGTT_PT_ENTRIES ;unsigned last_pte, i; scratch_pte = ppgtt->pte_encode (ppgtt->dev, - ppgtt->scratch_page_dma_addr, + dev_priv->gtt.scratch_page_dma,I915_CACHE_LLC );while (num_entries) {
@@ -365,11 +366,9 @@ err_pt_alloc:int i915_gem_ppgtt_init (struct drm_device *dev,struct i915_hw_ppgtt *ppgtt) { -struct drm_i915_private *dev_priv = dev->dev_private;int ret; ppgtt->dev = dev; - ppgtt->scratch_page_dma_addr = dev_priv->gtt.scratch_page_dma;if (INTEL_INFO (dev)->gen <8 ) ret =gen6_ppgtt_init (ppgtt);
Signature · 1 line
1.8.3.1
PATCH 17/66 drm/i915: Combine scratch members into a struct
In reply to Ben WidawskyThere isn't any special reason to do this other than it makes it obvious that the two members are connected.
--- drivers/gpu/drm/i915/i915_drv.h | 6 ++++-- drivers/gpu/drm/i915/i915_gem_gtt.c | 17 ++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +4 -2
@@ -462,8 +462,10 @@ struct i915_gtt {void __iomem *gsm;bool do_idle_maps; -dma_addr_t scratch_page_dma; -struct page *scratch_page; +struct { +dma_addr_t addr; +struct page *page; + } scratch;/* global gtt ops */ int (*gtt_probe)(struct drm_device *dev, size_t *gtt_total,
drivers/gpu/drm/i915/i915_gem_gtt.c +8 -9
@@ -197,7 +197,7 @@ static void gen6_ppgtt_clear_range(struct i915_hw_ppgtt *ppgtt,unsigned last_pte, i; scratch_pte = ppgtt->pte_encode (ppgtt->dev, - dev_priv->gtt.scratch_page_dma, + dev_priv->gtt.scratch.addr,I915_CACHE_LLC );while (num_entries) {
@@ -527,8 +527,7 @@ static void gen6_ggtt_clear_range(struct drm_device *dev, first_entry, num_entries, max_entries)) num_entries = max_entries; - scratch_pte = dev_priv->gtt.pte_encode (dev, - dev_priv->gtt.scratch_page_dma, + scratch_pte = dev_priv->gtt.pte_encode (dev, dev_priv->gtt.scratch.addr,I915_CACHE_LLC );for (i =0 ; i < num_entries; i++)iowrite32 (scratch_pte, >t_base[i]);
@@ -722,8 +721,8 @@ static int setup_scratch_page(struct drm_device *dev)#else dma_addr =page_to_phys (page);#endif - dev_priv->gtt.scratch_page = page; - dev_priv->gtt.scratch_page_dma = dma_addr; + dev_priv->gtt.scratch.page = page; + dev_priv->gtt.scratch.addr = dma_addr;return 0 ; }
@@ -731,11 +730,11 @@ static int setup_scratch_page(struct drm_device *dev)static void teardown_scratch_page (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; -set_pages_wb (dev_priv->gtt.scratch_page,1 ); -pci_unmap_page (dev->pdev, dev_priv->gtt.scratch_page_dma, +set_pages_wb (dev_priv->gtt.scratch.page,1 ); +pci_unmap_page (dev->pdev, dev_priv->gtt.scratch.addr,PAGE_SIZE ,PCI_DMA_BIDIRECTIONAL ); -put_page (dev_priv->gtt.scratch_page); -__free_page (dev_priv->gtt.scratch_page); +put_page (dev_priv->gtt.scratch.page); +__free_page (dev_priv->gtt.scratch.page); }static inline unsigned int gen6_get_total_gtt_size (u16 snb_gmch_ctl)
Signature · 1 line
1.8.3.1
PATCH 18/66 drm/i915: Drop dev from pte_encode
In reply to Ben WidawskyThe original pte_encode function needed the dev argument so we could do platform specific handling via IS_GENX, etc. With the merging of a pte encoding function there should never been a need to quirk away gen specific details.
The patch doesn't do much but makes the upcoming reworks in gtt/ppgtt/mm slightly (albeit, ever so) easier.
--- drivers/gpu/drm/i915/i915_drv.h | 6 ++---- drivers/gpu/drm/i915/i915_gem_gtt.c | 21 ++++++++------------- 2 files changed, 10 insertions(+), 17 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -4
@@ -479,8 +479,7 @@ struct i915_gtt {struct sg_table *st, unsigned int pg_start, enum i915_cache_level cache_level); -gen6_gtt_pte_t (*pte_encode)(struct drm_device *dev, -dma_addr_t addr, +gen6_gtt_pte_t (*pte_encode)(dma_addr_t addr,enum i915_cache_level level); };#define gtt_total_entries (gtt) ((gtt).total >> PAGE_SHIFT)
@@ -501,8 +500,7 @@ struct i915_hw_ppgtt {struct sg_table *st, unsigned int pg_start, enum i915_cache_level cache_level); -gen6_gtt_pte_t (*pte_encode)(struct drm_device *dev, -dma_addr_t addr, +gen6_gtt_pte_t (*pte_encode)(dma_addr_t addr,enum i915_cache_level level);int (*enable)(struct drm_device *dev);void (*cleanup)(struct i915_hw_ppgtt *ppgtt);
drivers/gpu/drm/i915/i915_gem_gtt.c +8 -13
@@ -45,8 +45,7 @@#define GEN6_PTE_CACHE_LLC_MLC (3 << 1)#define GEN6_PTE_ADDR_ENCODE (addr) GEN6_GTT_ADDR_ENCODE(addr) -static gen6_gtt_pte_t gen6_pte_encode (struct drm_device *dev, -dma_addr_t addr, +static gen6_gtt_pte_t gen6_pte_encode (dma_addr_t addr,enum i915_cache_level level) {gen6_gtt_pte_t pte =GEN6_PTE_VALID ;
@@ -72,8 +71,7 @@ static gen6_gtt_pte_t gen6_pte_encode(struct drm_device *dev,#define BYT_PTE_WRITEABLE (1 << 1)#define BYT_PTE_SNOOPED_BY_CPU_CACHES (1 << 2) -static gen6_gtt_pte_t byt_pte_encode (struct drm_device *dev, -dma_addr_t addr, +static gen6_gtt_pte_t byt_pte_encode (dma_addr_t addr,enum i915_cache_level level) {gen6_gtt_pte_t pte =GEN6_PTE_VALID ;
@@ -90,8 +88,7 @@ static gen6_gtt_pte_t byt_pte_encode(struct drm_device *dev,return pte; } -static gen6_gtt_pte_t hsw_pte_encode (struct drm_device *dev, -dma_addr_t addr, +static gen6_gtt_pte_t hsw_pte_encode (dma_addr_t addr,enum i915_cache_level level) {gen6_gtt_pte_t pte =GEN6_PTE_VALID ;
@@ -196,8 +193,7 @@ static void gen6_ppgtt_clear_range(struct i915_hw_ppgtt *ppgtt,unsigned first_pte = first_entry %I915_PPGTT_PT_ENTRIES ;unsigned last_pte, i; - scratch_pte = ppgtt->pte_encode (ppgtt->dev, - dev_priv->gtt.scratch.addr, + scratch_pte = ppgtt->pte_encode (dev_priv->gtt.scratch.addr,I915_CACHE_LLC );while (num_entries) {
@@ -233,8 +229,7 @@ static void gen6_ppgtt_insert_entries(struct i915_hw_ppgtt *ppgtt,dma_addr_t page_addr; page_addr =sg_page_iter_dma_address (&sg_iter); - pt_vaddr[act_pte] = ppgtt->pte_encode (ppgtt->dev, page_addr, - cache_level); + pt_vaddr[act_pte] = ppgtt->pte_encode (page_addr, cache_level);if (++act_pte ==I915_PPGTT_PT_ENTRIES ) {kunmap_atomic (pt_vaddr); act_pt++;
@@ -486,7 +481,7 @@ static void gen6_ggtt_insert_entries(struct drm_device *dev,for_each_sg_page (st->sgl, &sg_iter, st->nents,0 ) { addr =sg_page_iter_dma_address (&sg_iter); -iowrite32 (dev_priv->gtt.pte_encode (dev, addr, level), +iowrite32 (dev_priv->gtt.pte_encode (addr, level), >t_entries[i]); i++; }
@@ -499,7 +494,7 @@ static void gen6_ggtt_insert_entries(struct drm_device *dev,*/ if (i !=0 )WARN_ON (readl (>t_entries[i-1 ]) - != dev_priv->gtt.pte_encode (dev, addr, level)); + != dev_priv->gtt.pte_encode (addr, level));/* This next bit makes the above posting read even more important. We * want to flush the TLBs only after we're certain all the PTE updates
@@ -527,7 +522,7 @@ static void gen6_ggtt_clear_range(struct drm_device *dev, first_entry, num_entries, max_entries)) num_entries = max_entries; - scratch_pte = dev_priv->gtt.pte_encode (dev, dev_priv->gtt.scratch.addr, + scratch_pte = dev_priv->gtt.pte_encode (dev_priv->gtt.scratch.addr,I915_CACHE_LLC );for (i =0 ; i < num_entries; i++)iowrite32 (scratch_pte, >t_base[i]);
Signature · 1 line
1.8.3.1
PATCH 19/66 drm/i915: Use gtt shortform where possible
In reply to Ben WidawskyJust for compactness.
--- drivers/gpu/drm/i915/i915_gem_gtt.c | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-)
drivers/gpu/drm/i915/i915_gem_gtt.c +15 -21
@@ -841,34 +841,28 @@ int i915_gem_gtt_init(struct drm_device *dev)int ret;if (INTEL_INFO (dev)->gen <=5 ) { - dev_priv->gtt.gtt_probe = i915_gmch_probe; - dev_priv->gtt.gtt_remove = i915_gmch_remove; + gtt->gtt_probe = i915_gmch_probe; + gtt->gtt_remove = i915_gmch_remove; }else { - dev_priv->gtt.gtt_probe = gen6_gmch_probe; - dev_priv->gtt.gtt_remove = gen6_gmch_remove; -if (IS_HASWELL (dev)) { - dev_priv->gtt.pte_encode = hsw_pte_encode; - }else if (IS_VALLEYVIEW (dev)) { - dev_priv->gtt.pte_encode = byt_pte_encode; - }else { - dev_priv->gtt.pte_encode = gen6_pte_encode; - } + gtt->gtt_probe = gen6_gmch_probe; + gtt->gtt_remove = gen6_gmch_remove; +if (IS_HASWELL (dev)) + gtt->pte_encode = hsw_pte_encode; +else if (IS_VALLEYVIEW (dev)) + gtt->pte_encode = byt_pte_encode; +else + gtt->pte_encode = gen6_pte_encode; } - ret = dev_priv->gtt.gtt_probe (dev, &dev_priv->gtt.total, - &dev_priv->gtt.stolen_size, - >t->mappable_base, - >t->mappable_end); + ret = gtt->gtt_probe (dev, >t->total, >t->stolen_size, + >t->mappable_base, >t->mappable_end);if (ret)return ret;/* GMADR is the PCI mmio aperture into the global GTT. */ -DRM_INFO ("Memory usable by graphics device = %zdM\n" , - dev_priv->gtt.total >>20 ); -DRM_DEBUG_DRIVER ("GMADR size = %ldM\n" , - dev_priv->gtt.mappable_end >>20 ); -DRM_DEBUG_DRIVER ("GTT stolen size = %zdM\n" , - dev_priv->gtt.stolen_size >>20 ); +DRM_INFO ("Memory usable by graphics device = %zdM\n" , gtt->total >>20 ); +DRM_DEBUG_DRIVER ("GMADR size = %ldM\n" , gtt->mappable_end >>20 ); +DRM_DEBUG_DRIVER ("GTT stolen size = %zdM\n" , gtt->stolen_size >>20 );return 0 ; }
Signature · 1 line
1.8.3.1
PATCH 20/66 drm/i915: Move fbc members out of line
In reply to Ben Widawsky--- drivers/gpu/drm/i915/i915_debugfs.c | 2 +- drivers/gpu/drm/i915/i915_drv.h | 48 +++++++++++++++++++-------------- drivers/gpu/drm/i915/i915_gem_stolen.c | 20 +++++++------- drivers/gpu/drm/i915/intel_display.c | 6 ++--- drivers/gpu/drm/i915/intel_drv.h | 7 ----- drivers/gpu/drm/i915/intel_pm.c | 49 +++++++++++++++++----------------- 6 files changed, 67 insertions(+), 65 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +1 -1
@@ -1444,7 +1444,7 @@ static int i915_fbc_status(struct seq_file *m, void *unused)seq_printf (m,"FBC enabled\n" ); }else {seq_printf (m,"FBC disabled: " ); -switch (dev_priv->no_fbc_reason) { +switch (dev_priv->fbc.no_fbc_reason) {case FBC_NO_OUTPUT :seq_printf (m,"no outputs" );break ;
drivers/gpu/drm/i915/i915_drv.h +28 -20
68 lines not on this page · raw message
drivers/gpu/drm/i915/i915_gem_stolen.c +10 -10
@@ -120,7 +120,7 @@ static int i915_setup_compression(struct drm_device *dev, int size)if (!compressed_llb) goto err_fb; - dev_priv->compressed_llb = compressed_llb; + dev_priv->fbc.compressed_llb = compressed_llb;I915_WRITE (FBC_CFB_BASE , dev_priv->mm.stolen_base + compressed_fb->start);
@@ -128,8 +128,8 @@ static int i915_setup_compression(struct drm_device *dev, int size) dev_priv->mm.stolen_base + compressed_llb->start); } - dev_priv->compressed_fb = compressed_fb; - dev_priv->cfb_size = size; + dev_priv->fbc.compressed_fb = compressed_fb; + dev_priv->fbc.size = size;DRM_DEBUG_KMS ("reserved %d bytes of contiguous stolen space for FBC\n" , size);
@@ -150,7 +150,7 @@ int i915_gem_stolen_setup_compression(struct drm_device *dev, int size)if (dev_priv->mm.stolen_base ==0 )return -ENODEV ; -if (size < dev_priv->cfb_size) +if (size < dev_priv->fbc.size)return 0 ;/* Release any current block */
@@ -163,16 +163,16 @@ void i915_gem_stolen_cleanup_compression(struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; -if (dev_priv->cfb_size ==0 ) +if (dev_priv->fbc.size ==0 )return ; -if (dev_priv->compressed_fb) -drm_mm_put_block (dev_priv->compressed_fb); +if (dev_priv->fbc.compressed_fb) +drm_mm_put_block (dev_priv->fbc.compressed_fb); -if (dev_priv->compressed_llb) -drm_mm_put_block (dev_priv->compressed_llb); +if (dev_priv->fbc.compressed_llb) +drm_mm_put_block (dev_priv->fbc.compressed_llb); - dev_priv->cfb_size =0 ; + dev_priv->fbc.size =0 ; }void i915_gem_cleanup_stolen (struct drm_device *dev)
drivers/gpu/drm/i915/intel_display.c +3 -3
@@ -3391,7 +3391,7 @@ static void ironlake_crtc_disable(struct drm_crtc *crtc)intel_crtc_wait_for_pending_flips (crtc);drm_vblank_off (dev, pipe); -if (dev_priv->cfb_plane == plane) +if (dev_priv->fbc.plane == plane)intel_disable_fbc (dev);intel_crtc_update_cursor (crtc, false);
@@ -3464,7 +3464,7 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)drm_vblank_off (dev, pipe);/* FBC must be disabled before disabling the plane on HSW. */ -if (dev_priv->cfb_plane == plane) +if (dev_priv->fbc.plane == plane)intel_disable_fbc (dev);hsw_disable_ips (intel_crtc);
@@ -3705,7 +3705,7 @@ static void i9xx_crtc_disable(struct drm_crtc *crtc)intel_crtc_wait_for_pending_flips (crtc);drm_vblank_off (dev, pipe); -if (dev_priv->cfb_plane == plane) +if (dev_priv->fbc.plane == plane)intel_disable_fbc (dev);intel_crtc_dpms_overlay (intel_crtc, false);
drivers/gpu/drm/i915/intel_drv.h +0 -7
@@ -548,13 +548,6 @@ struct intel_unpin_work {bool enable_stall_check; }; -struct intel_fbc_work { -struct delayed_work work; -struct drm_crtc *crtc; -struct drm_framebuffer *fb; -int interval; -}; -int intel_pch_rawclk (struct drm_device *dev); int intel_connector_update_modes(struct drm_connector *connector,
drivers/gpu/drm/i915/intel_pm.c +25 -24
154 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [PATCH 20/66] drm/i915: Move fbc members out of line
Quoted 1 line · Ben Widawsky
Signed-off-by Ben Widawsky <[email protected]>
Merged patches 16-20, thanks.
-Daniel
Quoted 380 lines
--- drivers/gpu/drm/i915/i915_debugfs.c | 2 +- drivers/gpu/drm/i915/i915_drv.h | 48 +++++++++++++++++++-------------- drivers/gpu/drm/i915/i915_gem_stolen.c | 20 +++++++------- drivers/gpu/drm/i915/intel_display.c | 6 ++--- drivers/gpu/drm/i915/intel_drv.h | 7 ----- drivers/gpu/drm/i915/intel_pm.c | 49 +++++++++++++++++----------------- 6 files changed, 67 insertions(+), 65 deletions(-)drivers/gpu/drm/i915/i915_debugfs.c +1
-1@@ -1444,7 +1444,7 @@ static int i915_fbc_status(struct seq_file *m, void *unused)seq_printf (m,"FBC enabled\n" ); }else {seq_printf (m,"FBC disabled: " ); -switch (dev_priv->no_fbc_reason) { +switch (dev_priv->fbc.no_fbc_reason) {case FBC_NO_OUTPUT :seq_printf (m,"no outputs" );break ;drivers/gpu/drm/i915/i915_drv.h +28
-20@@ -534,17 +534,35 @@ struct i915_hw_context {struct i915_hw_ppgtt ppgtt; }; -enum no_fbc_reason { -FBC_NO_OUTPUT ,/* no outputs enabled to compress */ -FBC_STOLEN_TOO_SMALL ,/* not enough space to hold compressed buffers */ -FBC_UNSUPPORTED_MODE ,/* interlace or doublescanned mode */ -FBC_MODE_TOO_LARGE ,/* mode too large for compression */ -FBC_BAD_PLANE ,/* fbc not supported on plane */ -FBC_NOT_TILED ,/* buffer not tiled */ -FBC_MULTIPLE_PIPES ,/* more than one pipe active */ -FBC_MODULE_PARAM , +struct i915_fbc { +unsigned long size; +unsigned int fb_id; +enum plane plane; +int y; + +struct drm_mm_node *compressed_fb; +struct drm_mm_node *compressed_llb; + +struct intel_fbc_work { +struct delayed_work work; +struct drm_crtc *crtc; +struct drm_framebuffer *fb; +int interval; + } *fbc_work; + +enum { +FBC_NO_OUTPUT ,/* no outputs enabled to compress */ +FBC_STOLEN_TOO_SMALL ,/* not enough space for buffers */ +FBC_UNSUPPORTED_MODE ,/* interlace or doublescanned mode */ +FBC_MODE_TOO_LARGE ,/* mode too large for compression */ +FBC_BAD_PLANE ,/* fbc not supported on plane */ +FBC_NOT_TILED ,/* buffer not tiled */ +FBC_MULTIPLE_PIPES ,/* more than one pipe active */ +FBC_MODULE_PARAM , + } no_fbc_reason; }; +enum intel_pch {PCH_NONE =0 ,/* No PCH present */ PCH_IBX ,/* Ibexpeak PCH */ @@ -1064,12 +1082,7 @@ typedef struct drm_i915_private {int num_plane; -unsigned long cfb_size; -unsigned int cfb_fb; -enum plane cfb_plane; -int cfb_y; -struct intel_fbc_work *fbc_work; - +struct i915_fbc fbc;struct intel_opregion opregion;struct intel_vbt_data vbt;@@ -1147,11 +1160,6 @@ typedef struct drm_i915_private {/* Haswell power well */ struct i915_power_well power_well; -enum no_fbc_reason no_fbc_reason; - -struct drm_mm_node *compressed_fb; -struct drm_mm_node *compressed_llb; -struct i915_gpu_error gpu_error;struct drm_i915_gem_object *vlv_pctx;drivers/gpu/drm/i915/i915_gem_stolen.c +10
-10@@ -120,7 +120,7 @@ static int i915_setup_compression(struct drm_device *dev, int size)if (!compressed_llb) goto err_fb; - dev_priv->compressed_llb = compressed_llb; + dev_priv->fbc.compressed_llb = compressed_llb;I915_WRITE (FBC_CFB_BASE , dev_priv->mm.stolen_base + compressed_fb->start);@@ -128,8 +128,8 @@ static int i915_setup_compression(struct drm_device *dev, int size) dev_priv->mm.stolen_base + compressed_llb->start); } - dev_priv->compressed_fb = compressed_fb; - dev_priv->cfb_size = size; + dev_priv->fbc.compressed_fb = compressed_fb; + dev_priv->fbc.size = size;DRM_DEBUG_KMS ("reserved %d bytes of contiguous stolen space for FBC\n" , size);@@ -150,7 +150,7 @@ int i915_gem_stolen_setup_compression(struct drm_device *dev, int size)if (dev_priv->mm.stolen_base ==0 )return -ENODEV ; -if (size < dev_priv->cfb_size) +if (size < dev_priv->fbc.size)return 0 ;/* Release any current block */ @@ -163,16 +163,16 @@ void i915_gem_stolen_cleanup_compression(struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; -if (dev_priv->cfb_size ==0 ) +if (dev_priv->fbc.size ==0 )return ; -if (dev_priv->compressed_fb) -drm_mm_put_block (dev_priv->compressed_fb); +if (dev_priv->fbc.compressed_fb) +drm_mm_put_block (dev_priv->fbc.compressed_fb); -if (dev_priv->compressed_llb) -drm_mm_put_block (dev_priv->compressed_llb); +if (dev_priv->fbc.compressed_llb) +drm_mm_put_block (dev_priv->fbc.compressed_llb); - dev_priv->cfb_size =0 ; + dev_priv->fbc.size =0 ; }void i915_gem_cleanup_stolen (struct drm_device *dev)drivers/gpu/drm/i915/intel_display.c +3
-3@@ -3391,7 +3391,7 @@ static void ironlake_crtc_disable(struct drm_crtc *crtc)intel_crtc_wait_for_pending_flips (crtc);drm_vblank_off (dev, pipe); -if (dev_priv->cfb_plane == plane) +if (dev_priv->fbc.plane == plane)intel_disable_fbc (dev);intel_crtc_update_cursor (crtc, false);@@ -3464,7 +3464,7 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)drm_vblank_off (dev, pipe);/* FBC must be disabled before disabling the plane on HSW. */ -if (dev_priv->cfb_plane == plane) +if (dev_priv->fbc.plane == plane)intel_disable_fbc (dev);hsw_disable_ips (intel_crtc);@@ -3705,7 +3705,7 @@ static void i9xx_crtc_disable(struct drm_crtc *crtc)intel_crtc_wait_for_pending_flips (crtc);drm_vblank_off (dev, pipe); -if (dev_priv->cfb_plane == plane) +if (dev_priv->fbc.plane == plane)intel_disable_fbc (dev);intel_crtc_dpms_overlay (intel_crtc, false);drivers/gpu/drm/i915/intel_drv.h +0
-7@@ -548,13 +548,6 @@ struct intel_unpin_work {bool enable_stall_check; }; -struct intel_fbc_work { -struct delayed_work work; -struct drm_crtc *crtc; -struct drm_framebuffer *fb; -int interval; -}; -int intel_pch_rawclk (struct drm_device *dev); int intel_connector_update_modes(struct drm_connector *connector,drivers/gpu/drm/i915/intel_pm.c +25
-24@@ -86,7 +86,7 @@ static void i8xx_enable_fbc(struct drm_crtc *crtc, unsigned long interval)int plane, i;u32 fbc_ctl, fbc_ctl2; - cfb_pitch = dev_priv->cfb_size /FBC_LL_SIZE ; + cfb_pitch = dev_priv->fbc.size /FBC_LL_SIZE ;if (fb->pitches[0 ] < cfb_pitch) cfb_pitch = fb->pitches[0 ];@@ -325,7 +325,7 @@ static void intel_fbc_work_fn(struct work_struct *__work)struct drm_i915_private *dev_priv = dev->dev_private;mutex_lock (&dev->struct_mutex); -if (work == dev_priv->fbc_work) { +if (work == dev_priv->fbc.fbc_work) {/* Double check that we haven't switched fb without cancelling * the prior work. */ @@ -333,12 +333,12 @@ static void intel_fbc_work_fn(struct work_struct *__work) dev_priv->display.enable_fbc (work->crtc, work->interval); - dev_priv->cfb_plane =to_intel_crtc (work->crtc)->plane; - dev_priv->cfb_fb = work->crtc->fb->base.id; - dev_priv->cfb_y = work->crtc->y; + dev_priv->fbc.plane =to_intel_crtc (work->crtc)->plane; + dev_priv->fbc.fb_id = work->crtc->fb->base.id; + dev_priv->fbc.y = work->crtc->y; } - dev_priv->fbc_work =NULL ; + dev_priv->fbc.fbc_work =NULL ; }mutex_unlock (&dev->struct_mutex);@@ -347,25 +347,25 @@ static void intel_fbc_work_fn(struct work_struct *__work)static void intel_cancel_fbc_work (struct drm_i915_private *dev_priv) { -if (dev_priv->fbc_work ==NULL ) +if (dev_priv->fbc.fbc_work ==NULL )return ;DRM_DEBUG_KMS ("cancelling pending FBC enable\n" );/* Synchronisation is provided by struct_mutex and checking of -* dev_priv->fbc_work, so we can perform the cancellation +* dev_priv->fbc.fbc_work, so we can perform the cancellation * entirely asynchronously. */ -if (cancel_delayed_work (&dev_priv->fbc_work->work)) +if (cancel_delayed_work (&dev_priv->fbc.fbc_work->work))/* tasklet was killed before being run, clean up */ -kfree (dev_priv->fbc_work); +kfree (dev_priv->fbc.fbc_work);/* Mark the work as no longer wanted so that if it does * wake-up (because the work was already running and waiting * for our mutex), it will discover that is no longer * necessary to run. */ - dev_priv->fbc_work =NULL ; + dev_priv->fbc.fbc_work =NULL ; }void intel_enable_fbc (struct drm_crtc *crtc,unsigned long interval)@@ -390,7 +390,7 @@ void intel_enable_fbc(struct drm_crtc *crtc, unsigned long interval) work->interval = interval;INIT_DELAYED_WORK (&work->work, intel_fbc_work_fn); - dev_priv->fbc_work = work; + dev_priv->fbc.fbc_work = work;DRM_DEBUG_KMS ("scheduling delayed FBC enable\n" );@@ -418,7 +418,7 @@ void intel_disable_fbc(struct drm_device *dev)return ; dev_priv->display.disable_fbc (dev); - dev_priv->cfb_plane =-1 ; + dev_priv->fbc.plane =-1 ; }/** @@ -471,7 +471,8 @@ void intel_update_fbc(struct drm_device *dev) !to_intel_crtc(tmp_crtc)->primary_disabled) {if (crtc) {DRM_DEBUG_KMS ("more than one pipe active, disabling compression\n" ); - dev_priv->no_fbc_reason =FBC_MULTIPLE_PIPES ; + dev_priv->fbc.no_fbc_reason = +FBC_MULTIPLE_PIPES ; goto out_disable; } crtc = tmp_crtc;@@ -480,7 +481,7 @@ void intel_update_fbc(struct drm_device *dev)if (!crtc || crtc->fb ==NULL ) {DRM_DEBUG_KMS ("no output, disabling\n" ); - dev_priv->no_fbc_reason =FBC_NO_OUTPUT ; + dev_priv->fbc.no_fbc_reason =FBC_NO_OUTPUT ; goto out_disable; }@@ -498,14 +499,14 @@ void intel_update_fbc(struct drm_device *dev) }if (!enable_fbc) {DRM_DEBUG_KMS ("fbc disabled per module param\n" ); - dev_priv->no_fbc_reason =FBC_MODULE_PARAM ; + dev_priv->fbc.no_fbc_reason =FBC_MODULE_PARAM ; goto out_disable; }if ((crtc->mode.flags &DRM_MODE_FLAG_INTERLACE ) || (crtc->mode.flags &DRM_MODE_FLAG_DBLSCAN )) {DRM_DEBUG_KMS ("mode incompatible with compression, " "disabling\n" ); - dev_priv->no_fbc_reason =FBC_UNSUPPORTED_MODE ; + dev_priv->fbc.no_fbc_reason =FBC_UNSUPPORTED_MODE ; goto out_disable; }@@ -519,13 +520,13 @@ void intel_update_fbc(struct drm_device *dev)if ((crtc->mode.hdisplay > max_hdisplay) || (crtc->mode.vdisplay > max_vdisplay)) {DRM_DEBUG_KMS ("mode too large for compression, disabling\n" ); - dev_priv->no_fbc_reason =FBC_MODE_TOO_LARGE ; + dev_priv->fbc.no_fbc_reason =FBC_MODE_TOO_LARGE ; goto out_disable; }if ((IS_I915GM (dev) ||IS_I945GM (dev) ||IS_HASWELL (dev)) && intel_crtc->plane !=0 ) {DRM_DEBUG_KMS ("plane not 0, disabling compression\n" ); - dev_priv->no_fbc_reason =FBC_BAD_PLANE ; + dev_priv->fbc.no_fbc_reason =FBC_BAD_PLANE ; goto out_disable; }@@ -535,7 +536,7 @@ void intel_update_fbc(struct drm_device *dev)if (obj->tiling_mode !=I915_TILING_X || obj->fence_reg ==I915_FENCE_REG_NONE ) {DRM_DEBUG_KMS ("framebuffer not tiled or fenced, disabling compression\n" ); - dev_priv->no_fbc_reason =FBC_NOT_TILED ; + dev_priv->fbc.no_fbc_reason =FBC_NOT_TILED ; goto out_disable; }@@ -545,7 +546,7 @@ void intel_update_fbc(struct drm_device *dev)if (i915_gem_stolen_setup_compression (dev, intel_fb->obj->base.size)) {DRM_DEBUG_KMS ("framebuffer too large, disabling compression\n" ); - dev_priv->no_fbc_reason =FBC_STOLEN_TOO_SMALL ; + dev_priv->fbc.no_fbc_reason =FBC_STOLEN_TOO_SMALL ; goto out_disable; }@@ -554,9 +555,9 @@ void intel_update_fbc(struct drm_device *dev)* cannot be unpinned (and have its GTT offset and fence revoked) * without first being decoupled from the scanout and FBC disabled. */ -if (dev_priv->cfb_plane == intel_crtc->plane && - dev_priv->cfb_fb == fb->base.id && - dev_priv->cfb_y == crtc->y) +if (dev_priv->fbc.plane == intel_crtc->plane && + dev_priv->fbc.fb_id == fb->base.id && + dev_priv->fbc.y == crtc->y)return ;if (intel_fbc_enabled (dev)) {Signature · 6 lines
1.8.3.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
PATCH 21/66 drm/i915: Move gtt and ppgtt under address space umbrella
In reply to Ben WidawskyThe GTT and PPGTT can be thought of more generally as GPU address spaces. Many of their actions (insert entries), state (LRU lists) and many of their characteristics (size), can be shared. Do that.
Created a i915_gtt_vm helper macro since for now we always want the regular GTT address space. Eventually we'll ween ourselves off of using this except in cases where we obviously want the GGTT (like display).
--- drivers/gpu/drm/i915/i915_debugfs.c | 4 +- drivers/gpu/drm/i915/i915_drv.h | 48 ++++++------ drivers/gpu/drm/i915/i915_gem.c | 8 +- drivers/gpu/drm/i915/i915_gem_gtt.c | 145 +++++++++++++++++++----------------- 4 files changed, 110 insertions(+), 95 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +2 -2
@@ -287,8 +287,8 @@ static int i915_gem_object_info(struct seq_file *m, void* data) count, size);seq_printf (m,"%zu [%lu] gtt total\n" , - dev_priv->gtt.total, - dev_priv->gtt.mappable_end - dev_priv->gtt.start); + i915_gtt_vm->total, + dev_priv->gtt.mappable_end - i915_gtt_vm->start);seq_printf (m,"\n" );list_for_each_entry_reverse (file, &dev->filelist, lhead) {
drivers/gpu/drm/i915/i915_drv.h +26 -22
81 lines not on this page · raw message
drivers/gpu/drm/i915/i915_gem.c +4 -4
@@ -181,7 +181,7 @@ i915_gem_get_aperture_ioctl(struct drm_device *dev, void *data, pinned += obj->gtt_space->size;mutex_unlock (&dev->struct_mutex); - args->aper_size = dev_priv->gtt.total; + args->aper_size = i915_gtt_vm->total; args->aper_available_size = args->aper_size - pinned;return 0 ;
@@ -3083,7 +3083,7 @@ i915_gem_object_bind_to_gtt(struct drm_i915_gem_object *obj,u32 size, fence_size, fence_alignment, unfenced_alignment;bool mappable, fenceable;size_t gtt_max = map_and_fenceable ? - dev_priv->gtt.mappable_end : dev_priv->gtt.total; + dev_priv->gtt.mappable_end : dev_priv->gtt.base.total;int ret; fence_size = i915_gem_get_gtt_size(dev,
@@ -4226,7 +4226,7 @@ int i915_gem_init(struct drm_device *dev)*/ if (HAS_HW_CONTEXTS (dev)) {i915_gem_setup_global_gtt (dev,0 , dev_priv->gtt.mappable_end, - dev_priv->gtt.total,0 ); + i915_gtt_vm->total,0 );i915_gem_context_init (dev);if (dev_priv->hw_contexts_disabled) {drm_mm_takedown (&dev_priv->mm.gtt_space);
@@ -4240,7 +4240,7 @@ ggtt_only:if (HAS_HW_CONTEXTS (dev))DRM_DEBUG_DRIVER ("Context setup failed %d\n" , ret);i915_gem_setup_global_gtt (dev,0 , dev_priv->gtt.mappable_end, - dev_priv->gtt.total,PAGE_SIZE ); + i915_gtt_vm->total,PAGE_SIZE ); } ret =i915_gem_init_hw (dev);
drivers/gpu/drm/i915/i915_gem_gtt.c +78 -67
365 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [PATCH 21/66] drm/i915: Move gtt and ppgtt under address space umbrella
Quoted 9 lines · Ben Widawsky
The GTT and PPGTT can be thought of more generally as GPU address spaces. Many of their actions (insert entries), state (LRU lists) and many of their characteristics (size), can be shared. Do that.
Created a
i915_gtt_vmhelper macro since for now we always want the regular GTT address space. Eventually we'll ween ourselves off of using this except in cases where we obviously want the GGTT (like display).Signed-off-by Ben Widawsky <[email protected]>
The i915_gtt_vm #define is imo too evil. Looks like a local variable, but isn't. I think in most places we should just drop it, in others we should add a real local vm variable. I'll punt for now on this one. -Daniel
Quoted 552 lines
--- drivers/gpu/drm/i915/i915_debugfs.c | 4 +- drivers/gpu/drm/i915/i915_drv.h | 48 ++++++------ drivers/gpu/drm/i915/i915_gem.c | 8 +- drivers/gpu/drm/i915/i915_gem_gtt.c | 145 +++++++++++++++++++----------------- 4 files changed, 110 insertions(+), 95 deletions(-)drivers/gpu/drm/i915/i915_debugfs.c +2
-2@@ -287,8 +287,8 @@ static int i915_gem_object_info(struct seq_file *m, void* data) count, size);seq_printf (m,"%zu [%lu] gtt total\n" , - dev_priv->gtt.total, - dev_priv->gtt.mappable_end - dev_priv->gtt.start); + i915_gtt_vm->total, + dev_priv->gtt.mappable_end - i915_gtt_vm->start);seq_printf (m,"\n" );list_for_each_entry_reverse (file, &dev->filelist, lhead) {drivers/gpu/drm/i915/i915_drv.h +26
-22@@ -442,6 +442,28 @@ enum i915_cache_level {typedef uint32_t gen6_gtt_pte_t ; +struct i915_address_space { +struct drm_device *dev; +unsigned long start;/* Start offset always 0 for dri2 */ +size_t total;/* size addr space maps (ex. 2GB for ggtt) */ + +struct { +dma_addr_t addr; +struct page *page; + } scratch; + +/* FIXME: Need a more generic return type */ +gen6_gtt_pte_t (*pte_encode)(dma_addr_t addr, +enum i915_cache_level level); +void (*clear_range)(struct i915_address_space *i915_mm, +unsigned int first_entry, +unsigned int num_entries); +void (*insert_entries)(struct i915_address_space *i915_mm, +struct sg_table *st, +unsigned int first_entry, +enum i915_cache_level cache_level); +}; +/* The Graphics Translation Table is the way in which GEN hardware translates a * Graphics Virtual Address into a Physical Address. In addition to the normal * collateral associated with any va->pa translations GEN hardware also has a @@ -450,8 +472,7 @@ typedef uint32_t gen6_gtt_pte_t;* the spec. */ struct i915_gtt { -unsigned long start;/* Start offset of used GTT */ -size_t total;/* Total size GTT can map */ +struct i915_address_space base;size_t stolen_size;/* Total size of stolen memory */ unsigned long mappable_end;/* End offset that we can CPU map */ @@ -472,34 +493,17 @@ struct i915_gtt { size_t *stolen, phys_addr_t *mappable_base, unsigned long *mappable_end);void (*gtt_remove)(struct drm_device *dev); -void (*gtt_clear_range)(struct drm_device *dev, -unsigned int first_entry, -unsigned int num_entries); -void (*gtt_insert_entries)(struct drm_device *dev, -struct sg_table *st, -unsigned int pg_start, -enum i915_cache_level cache_level); -gen6_gtt_pte_t (*pte_encode)(dma_addr_t addr, -enum i915_cache_level level); }; -#define gtt_total_entries (gtt) ((gtt).total >> PAGE_SHIFT) +#define i915_gtt_vm ((struct i915_address_space *)&(dev_priv->gtt.base))struct i915_hw_ppgtt { +struct i915_address_space base;struct drm_mm_node node; -struct drm_device *dev;unsigned num_pd_entries;struct page **pt_pages;uint32_t pd_offset;dma_addr_t *pt_dma_addr; -/* pte functions, mirroring the interface of the global gtt. */ -void (*clear_range)(struct i915_hw_ppgtt *ppgtt, -unsigned int first_entry, -unsigned int num_entries); -void (*insert_entries)(struct i915_hw_ppgtt *ppgtt, -struct sg_table *st, -unsigned int pg_start, -enum i915_cache_level cache_level);gen6_gtt_pte_t (*pte_encode)(dma_addr_t addr,enum i915_cache_level level);int (*enable)(struct drm_device *dev);@@ -1123,7 +1127,7 @@ typedef struct drm_i915_private {enum modeset_restore modeset_restore;struct mutex modeset_restore_lock; -struct i915_gtt gtt; +struct i915_gtt gtt;/* VMA representing the global address space */ struct i915_gem_mm mm;drivers/gpu/drm/i915/i915_gem.c +4
-4@@ -181,7 +181,7 @@ i915_gem_get_aperture_ioctl(struct drm_device *dev, void *data, pinned += obj->gtt_space->size;mutex_unlock (&dev->struct_mutex); - args->aper_size = dev_priv->gtt.total; + args->aper_size = i915_gtt_vm->total; args->aper_available_size = args->aper_size - pinned;return 0 ;@@ -3083,7 +3083,7 @@ i915_gem_object_bind_to_gtt(struct drm_i915_gem_object *obj,u32 size, fence_size, fence_alignment, unfenced_alignment;bool mappable, fenceable;size_t gtt_max = map_and_fenceable ? - dev_priv->gtt.mappable_end : dev_priv->gtt.total; + dev_priv->gtt.mappable_end : dev_priv->gtt.base.total;int ret; fence_size = i915_gem_get_gtt_size(dev,@@ -4226,7 +4226,7 @@ int i915_gem_init(struct drm_device *dev)*/ if (HAS_HW_CONTEXTS (dev)) {i915_gem_setup_global_gtt (dev,0 , dev_priv->gtt.mappable_end, - dev_priv->gtt.total,0 ); + i915_gtt_vm->total,0 );i915_gem_context_init (dev);if (dev_priv->hw_contexts_disabled) {drm_mm_takedown (&dev_priv->mm.gtt_space);@@ -4240,7 +4240,7 @@ ggtt_only:if (HAS_HW_CONTEXTS (dev))DRM_DEBUG_DRIVER ("Context setup failed %d\n" , ret);i915_gem_setup_global_gtt (dev,0 , dev_priv->gtt.mappable_end, - dev_priv->gtt.total,PAGE_SIZE ); + i915_gtt_vm->total,PAGE_SIZE ); } ret =i915_gem_init_hw (dev);drivers/gpu/drm/i915/i915_gem_gtt.c +78
-67@@ -102,7 +102,7 @@ static gen6_gtt_pte_t hsw_pte_encode(dma_addr_t addr,static void gen6_write_pdes (struct i915_hw_ppgtt *ppgtt) { -struct drm_i915_private *dev_priv = ppgtt->dev->dev_private; +struct drm_i915_private *dev_priv = ppgtt->base.dev->dev_private;gen6_gtt_pte_t __iomem *pd_addr;uint32_t pd_entry;int i;@@ -183,18 +183,18 @@ static int gen6_ppgtt_enable(struct drm_device *dev) }/* PPGTT support for Sandybdrige/Gen6 and later */ -static void gen6_ppgtt_clear_range (struct i915_hw_ppgtt *ppgtt, +static void gen6_ppgtt_clear_range (struct i915_address_space *vm,unsigned first_entry,unsigned num_entries) { -struct drm_i915_private *dev_priv = ppgtt->dev->dev_private; +struct i915_hw_ppgtt *ppgtt = + container_of(vm, struct i915_hw_ppgtt, base);gen6_gtt_pte_t *pt_vaddr, scratch_pte;unsigned act_pt = first_entry /I915_PPGTT_PT_ENTRIES ;unsigned first_pte = first_entry %I915_PPGTT_PT_ENTRIES ;unsigned last_pte, i; - scratch_pte = ppgtt->pte_encode (dev_priv->gtt.scratch.addr, -I915_CACHE_LLC ); + scratch_pte = vm->pte_encode (vm->scratch.addr,I915_CACHE_LLC );while (num_entries) { last_pte = first_pte + num_entries;@@ -214,11 +214,13 @@ static void gen6_ppgtt_clear_range(struct i915_hw_ppgtt *ppgtt, } } -static void gen6_ppgtt_insert_entries (struct i915_hw_ppgtt *ppgtt, +static void gen6_ppgtt_insert_entries (struct i915_address_space *vm,struct sg_table *pages,unsigned first_entry,enum i915_cache_level cache_level) { +struct i915_hw_ppgtt *ppgtt = + container_of(vm, struct i915_hw_ppgtt, base);gen6_gtt_pte_t *pt_vaddr;unsigned act_pt = first_entry /I915_PPGTT_PT_ENTRIES ;unsigned act_pte = first_entry %I915_PPGTT_PT_ENTRIES ;@@ -229,7 +231,7 @@ static void gen6_ppgtt_insert_entries(struct i915_hw_ppgtt *ppgtt,dma_addr_t page_addr; page_addr =sg_page_iter_dma_address (&sg_iter); - pt_vaddr[act_pte] = ppgtt->pte_encode (page_addr, cache_level); + pt_vaddr[act_pte] = vm->pte_encode (page_addr, cache_level);if (++act_pte ==I915_PPGTT_PT_ENTRIES ) {kunmap_atomic (pt_vaddr); act_pt++;@@ -243,14 +245,14 @@ static void gen6_ppgtt_insert_entries(struct i915_hw_ppgtt *ppgtt,static void gen6_ppgtt_cleanup (struct i915_hw_ppgtt *ppgtt) { +struct i915_address_space *vm = &ppgtt->base;int i;drm_mm_remove_node (&ppgtt->node);if (ppgtt->pt_dma_addr) {for (i =0 ; i < ppgtt->num_pd_entries; i++) -pci_unmap_page (ppgtt->dev->pdev, - ppgtt->pt_dma_addr[i], +pci_unmap_page (vm->dev->pdev, ppgtt->pt_dma_addr[i],4096 ,PCI_DMA_BIDIRECTIONAL ); }@@ -264,7 +266,8 @@ static int gen6_ppgtt_init(struct i915_hw_ppgtt *ppgtt) {#define GEN6_PD_ALIGN (PAGE_SIZE * 16)#define GEN6_PD_SIZE (GEN6_PPGTT_PD_ENTRIES * PAGE_SIZE) -struct drm_device *dev = ppgtt->dev; +struct i915_address_space *vm = &ppgtt->base; +struct drm_device *dev = vm->dev;struct drm_i915_private *dev_priv = dev->dev_private;int i;int ret = -ENOMEM ;@@ -279,21 +282,22 @@ static int gen6_ppgtt_init(struct i915_hw_ppgtt *ppgtt) &ppgtt->node,GEN6_PD_SIZE ,GEN6_PD_ALIGN ,0 , dev_priv->gtt.mappable_end, - dev_priv->gtt.total, + i915_gtt_vm->total, DRM_MM_TOPDOWN);if (ret)return ret;if (IS_HASWELL (dev)) { - ppgtt->pte_encode = hsw_pte_encode; + vm->pte_encode = hsw_pte_encode; }else if (IS_VALLEYVIEW (dev)) { - ppgtt->pte_encode = byt_pte_encode; + vm->pte_encode = byt_pte_encode; }else { - ppgtt->pte_encode = gen6_pte_encode; + vm->pte_encode = gen6_pte_encode; } ppgtt->pt_pages =kzalloc (sizeof (struct page *)*GEN6_PPGTT_PD_ENTRIES ,GFP_KERNEL ); +if (!ppgtt->pt_pages) {drm_mm_remove_node (&ppgtt->node);return -ENOMEM ;@@ -326,12 +330,15 @@ static int gen6_ppgtt_init(struct i915_hw_ppgtt *ppgtt) ppgtt->num_pd_entries =GEN6_PPGTT_PD_ENTRIES ; ppgtt->enable = gen6_ppgtt_enable; - ppgtt->clear_range = gen6_ppgtt_clear_range; - ppgtt->insert_entries = gen6_ppgtt_insert_entries; ppgtt->cleanup = gen6_ppgtt_cleanup; - ppgtt->clear_range (ppgtt,0 , - ppgtt->num_pd_entries*I915_PPGTT_PT_ENTRIES ); + vm->clear_range = gen6_ppgtt_clear_range; + vm->insert_entries = gen6_ppgtt_insert_entries; + vm->start =0 ; + vm->total =GEN6_PPGTT_PD_ENTRIES *I915_PPGTT_PT_ENTRIES *PAGE_SIZE ; + vm->scratch = dev_priv->gtt.base.scratch; + + vm->clear_range (vm,0 , ppgtt->num_pd_entries *I915_PPGTT_PT_ENTRIES ); DRM_DEBUG_DRIVER("Allocated pde space (%ldM) at GTT entry: %lx\n", ppgtt->node.size >> 20,@@ -363,7 +370,7 @@ int i915_gem_ppgtt_init(struct drm_device *dev, struct i915_hw_ppgtt *ppgtt) {int ret; - ppgtt->dev = dev; + ppgtt->base.dev = dev;if (INTEL_INFO (dev)->gen <8 ) ret =gen6_ppgtt_init (ppgtt);@@ -377,17 +384,17 @@ void i915_ppgtt_bind_object(struct i915_hw_ppgtt *ppgtt,struct drm_i915_gem_object *obj, enum i915_cache_level cache_level) { - ppgtt->insert_entries(ppgtt, obj->pages, - obj->gtt_space->start >> PAGE_SHIFT, -cache_level ); + ppgtt->base.insert_entries(&ppgtt->base, obj->pages, + obj->gtt_space->start >> PAGE_SHIFT, +cache_level ); }void i915_ppgtt_unbind_object (struct i915_hw_ppgtt *ppgtt,struct drm_i915_gem_object *obj) { - ppgtt->clear_range (ppgtt, - obj->gtt_space->start >>PAGE_SHIFT , - obj->base.size >>PAGE_SHIFT ); + ppgtt->base.clear_range (&ppgtt->base, + obj->gtt_space->start >>PAGE_SHIFT , + obj->base.size >>PAGE_SHIFT ); }extern int intel_iommu_gfx_mapped;@@ -434,8 +441,9 @@ void i915_gem_restore_gtt_mappings(struct drm_device *dev)struct drm_i915_gem_object *obj;/* First fill our portion of the GTT with scratch pages */ - dev_priv->gtt.gtt_clear_range (dev, dev_priv->gtt.start /PAGE_SIZE , - dev_priv->gtt.total /PAGE_SIZE ); + i915_gtt_vm->clear_range (&dev_priv->gtt.base, + i915_gtt_vm->start /PAGE_SIZE , + i915_gtt_vm->total /PAGE_SIZE );if (dev_priv->mm.aliasing_ppgtt)gen6_write_pdes (dev_priv->mm.aliasing_ppgtt);@@ -467,12 +475,12 @@ int i915_gem_gtt_prepare_object(struct drm_i915_gem_object *obj)* within the global GTT as well as accessible by the GPU through the GMADR * mapped BAR (dev_priv->mm.gtt->gtt). */ -static void gen6_ggtt_insert_entries (struct drm_device *dev, +static void gen6_ggtt_insert_entries (struct i915_address_space *vm,struct sg_table *st,unsigned int first_entry,enum i915_cache_level level) { -struct drm_i915_private *dev_priv = dev->dev_private; +struct drm_i915_private *dev_priv = vm->dev->dev_private;gen6_gtt_pte_t __iomem *gtt_entries = (gen6_gtt_pte_t __iomem *)dev_priv->gtt.gsm + first_entry;int i =0 ;@@ -481,8 +489,7 @@ static void gen6_ggtt_insert_entries(struct drm_device *dev,for_each_sg_page (st->sgl, &sg_iter, st->nents,0 ) { addr =sg_page_iter_dma_address (&sg_iter); -iowrite32 (dev_priv->gtt.pte_encode (addr, level), - >t_entries[i]); +iowrite32 (vm->pte_encode (addr, level), >t_entries[i]); i++; }@@ -493,8 +500,8 @@ static void gen6_ggtt_insert_entries(struct drm_device *dev,* hardware should work, we must keep this posting read for paranoia. */ if (i !=0 ) -WARN_ON (readl (>t_entries[i-1 ]) - != dev_priv->gtt.pte_encode (addr, level)); +WARN_ON (readl (>t_entries[i-1 ]) != + vm->pte_encode (addr, level));/* This next bit makes the above posting read even more important. We * want to flush the TLBs only after we're certain all the PTE updates @@ -504,14 +511,14 @@ static void gen6_ggtt_insert_entries(struct drm_device *dev,POSTING_READ (GFX_FLSH_CNTL_GEN6 ); } -static void gen6_ggtt_clear_range (struct drm_device *dev, +static void gen6_ggtt_clear_range (struct i915_address_space *vm,unsigned int first_entry,unsigned int num_entries) { -struct drm_i915_private *dev_priv = dev->dev_private; +struct drm_i915_private *dev_priv = vm->dev->dev_private;gen6_gtt_pte_t scratch_pte,__iomem *gtt_base = (gen6_gtt_pte_t __iomem *) dev_priv->gtt.gsm + first_entry; -const int max_entries =gtt_total_entries (dev_priv->gtt) - first_entry; +const int max_entries = (vm->total >>PAGE_SHIFT ) - first_entry;int i;if (num_entries ==0 )@@ -522,15 +529,15 @@ static void gen6_ggtt_clear_range(struct drm_device *dev, first_entry, num_entries, max_entries)) num_entries = max_entries; - scratch_pte = dev_priv->gtt.pte_encode (dev_priv->gtt.scratch.addr, -I915_CACHE_LLC ); + scratch_pte = vm->pte_encode (vm->scratch.addr, +I915_CACHE_LLC );for (i =0 ; i < num_entries; i++)iowrite32 (scratch_pte, >t_base[i]);readl (gtt_base); } -static void i915_ggtt_insert_entries (struct drm_device *dev, +static void i915_ggtt_insert_entries (struct i915_address_space *vm,struct sg_table *st,unsigned int pg_start,enum i915_cache_level cache_level)@@ -542,7 +549,7 @@ static void i915_ggtt_insert_entries(struct drm_device *dev, } -static void i915_ggtt_clear_range (struct drm_device *dev, +static void i915_ggtt_clear_range (struct i915_address_space *vm,unsigned int first_entry,unsigned int num_entries) {@@ -559,9 +566,9 @@ void i915_gem_gtt_bind_object(struct drm_i915_gem_object *obj,struct drm_device *dev = obj->base.dev;struct drm_i915_private *dev_priv = dev->dev_private; - dev_priv->gtt.gtt_insert_entries (dev, obj->pages, - obj->gtt_space->start >>PAGE_SHIFT , - cache_level); + i915_gtt_vm->insert_entries (&dev_priv->gtt.base, obj->pages, + obj->gtt_space->start >>PAGE_SHIFT , + cache_level); obj->has_global_gtt_mapping =1 ; }@@ -571,9 +578,9 @@ void i915_gem_gtt_unbind_object(struct drm_i915_gem_object *obj)struct drm_device *dev = obj->base.dev;struct drm_i915_private *dev_priv = dev->dev_private; - dev_priv->gtt.gtt_clear_range (obj->base.dev, - obj->gtt_space->start >>PAGE_SHIFT , - obj->base.size >>PAGE_SHIFT ); + i915_gtt_vm->clear_range (&dev_priv->gtt.base, + obj->gtt_space->start >>PAGE_SHIFT , + obj->base.size >>PAGE_SHIFT ); obj->has_global_gtt_mapping =0 ; }@@ -679,21 +686,21 @@ void i915_gem_setup_global_gtt(struct drm_device *dev, obj->has_global_gtt_mapping =1 ; } - dev_priv->gtt.start = start; - dev_priv->gtt.total = end - start; + i915_gtt_vm->start = start; + i915_gtt_vm->total = end - start;/* Clear any non-preallocated blocks */ drm_mm_for_each_hole (entry, &dev_priv->mm.gtt_space, hole_start, hole_end) {DRM_DEBUG_KMS ("clearing unused GTT space: [%lx, %lx]\n" , hole_start, hole_end); - dev_priv->gtt.gtt_clear_range (dev, hole_start /PAGE_SIZE , - (hole_end-hole_start) /PAGE_SIZE ); + i915_gtt_vm->clear_range (i915_gtt_vm, hole_start /PAGE_SIZE , + (hole_end-hole_start) /PAGE_SIZE ); }/* And finally clear the reserved guard page */ - dev_priv->gtt.gtt_clear_range (dev, (end - guard_size) /PAGE_SIZE , - guard_size /PAGE_SIZE ); + i915_gtt_vm->clear_range (i915_gtt_vm, (end - guard_size) /PAGE_SIZE , + guard_size /PAGE_SIZE ); }static int setup_scratch_page (struct drm_device *dev)@@ -716,8 +723,8 @@ static int setup_scratch_page(struct drm_device *dev)#else dma_addr =page_to_phys (page);#endif - dev_priv->gtt.scratch.page = page; - dev_priv->gtt.scratch.addr = dma_addr; + i915_gtt_vm->scratch.page = page; + i915_gtt_vm->scratch.addr = dma_addr;return 0 ; }@@ -725,11 +732,12 @@ static int setup_scratch_page(struct drm_device *dev)static void teardown_scratch_page (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; -set_pages_wb (dev_priv->gtt.scratch.page,1 ); -pci_unmap_page (dev->pdev, dev_priv->gtt.scratch.addr, + +set_pages_wb (i915_gtt_vm->scratch.page,1 ); +pci_unmap_page (dev->pdev, i915_gtt_vm->scratch.addr,PAGE_SIZE ,PCI_DMA_BIDIRECTIONAL ); -put_page (dev_priv->gtt.scratch.page); -__free_page (dev_priv->gtt.scratch.page); +put_page (i915_gtt_vm->scratch.page); +__free_page (i915_gtt_vm->scratch.page); }static inline unsigned int gen6_get_total_gtt_size (u16 snb_gmch_ctl)@@ -792,8 +800,8 @@ static int gen6_gmch_probe(struct drm_device *dev,if (ret)DRM_ERROR ("Scratch setup failed\n" ); - dev_priv->gtt.gtt_clear_range = gen6_ggtt_clear_range; - dev_priv->gtt.gtt_insert_entries = gen6_ggtt_insert_entries; + i915_gtt_vm->clear_range = gen6_ggtt_clear_range; + i915_gtt_vm->insert_entries = gen6_ggtt_insert_entries;return ret; }@@ -823,8 +831,8 @@ static int i915_gmch_probe(struct drm_device *dev,intel_gtt_get (gtt_total, stolen, mappable_base, mappable_end); dev_priv->gtt.do_idle_maps =needs_idle_maps (dev_priv->dev); - dev_priv->gtt.gtt_clear_range = i915_ggtt_clear_range; - dev_priv->gtt.gtt_insert_entries = i915_ggtt_insert_entries; + i915_gtt_vm->clear_range = i915_ggtt_clear_range; + i915_gtt_vm->insert_entries = i915_ggtt_insert_entries;return 0 ; }@@ -847,20 +855,23 @@ int i915_gem_gtt_init(struct drm_device *dev) gtt->gtt_probe = gen6_gmch_probe; gtt->gtt_remove = gen6_gmch_remove;if (IS_HASWELL (dev)) - gtt->pte_encode = hsw_pte_encode; + gtt->base.pte_encode = hsw_pte_encode;else if (IS_VALLEYVIEW (dev)) - gtt->pte_encode = byt_pte_encode; + gtt->base.pte_encode = byt_pte_encode;else - gtt->pte_encode = gen6_pte_encode; + gtt->base.pte_encode = gen6_pte_encode; } - ret = gtt->gtt_probe (dev, >t->total, >t->stolen_size, + ret = gtt->gtt_probe (dev, >t->base.total, >t->stolen_size, >t->mappable_base, >t->mappable_end);if (ret)return ret; + gtt->base.dev = dev; +/* GMADR is the PCI mmio aperture into the global GTT. */ -DRM_INFO ("Memory usable by graphics device = %zdM\n" , gtt->total >>20 ); +DRM_INFO ("Memory usable by graphics device = %zdM\n" , + gtt->base.total >>20 );DRM_DEBUG_DRIVER ("GMADR size = %ldM\n" , gtt->mappable_end >>20 );DRM_DEBUG_DRIVER ("GTT stolen size = %zdM\n" , gtt->stolen_size >>20 );Signature · 6 lines
1.8.3.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 21/66] drm/i915: Move gtt and ppgtt under address space umbrella
Quoted 9 lines · Daniel Vetter
Quoted 8 lines · Ben Widawsky
The GTT and PPGTT can be thought of more generally as GPU address spaces. Many of their actions (insert entries), state (LRU lists) and many of their characteristics (size), can be shared. Do that.
Created a
i915_gtt_vmhelper macro since for now we always want the regular GTT address space. Eventually we'll ween ourselves off of using this except in cases where we obviously want the GGTT (like display).
Quoted 6 lines
Quoted 1 line
Signed-off-by Ben Widawsky <[email protected]>The
i915_gtt_vm#define is imo too evil. Looks like a local variable, but isn't. I think in most places we should just drop it, in others we should add a real local vm variable. I'll punt for now on this one. -Daniel
It's dropped later in the series. It was a temporary bandaid to make the diffs a bit easier to swallow. I can certainly get rid of it next time around.
Quoted 558 lines
Quoted 553 lines
--- drivers/gpu/drm/i915/i915_debugfs.c | 4 +- drivers/gpu/drm/i915/i915_drv.h | 48 ++++++------ drivers/gpu/drm/i915/i915_gem.c | 8 +- drivers/gpu/drm/i915/i915_gem_gtt.c | 145 +++++++++++++++++++----------------- 4 files changed, 110 insertions(+), 95 deletions(-)drivers/gpu/drm/i915/i915_debugfs.c +2
-2@@ -287,8 +287,8 @@ static int i915_gem_object_info(struct seq_file *m, void* data) count, size);seq_printf (m,"%zu [%lu] gtt total\n" , - dev_priv->gtt.total, - dev_priv->gtt.mappable_end - dev_priv->gtt.start); + i915_gtt_vm->total, + dev_priv->gtt.mappable_end - i915_gtt_vm->start);seq_printf (m,"\n" );list_for_each_entry_reverse (file, &dev->filelist, lhead) {drivers/gpu/drm/i915/i915_drv.h +26
-22@@ -442,6 +442,28 @@ enum i915_cache_level {typedef uint32_t gen6_gtt_pte_t ; +struct i915_address_space { +struct drm_device *dev; +unsigned long start;/* Start offset always 0 for dri2 */ +size_t total;/* size addr space maps (ex. 2GB for ggtt) */ + +struct { +dma_addr_t addr; +struct page *page; + } scratch; + +/* FIXME: Need a more generic return type */ +gen6_gtt_pte_t (*pte_encode)(dma_addr_t addr, +enum i915_cache_level level); +void (*clear_range)(struct i915_address_space *i915_mm, +unsigned int first_entry, +unsigned int num_entries); +void (*insert_entries)(struct i915_address_space *i915_mm, +struct sg_table *st, +unsigned int first_entry, +enum i915_cache_level cache_level); +}; +/* The Graphics Translation Table is the way in which GEN hardware translates a * Graphics Virtual Address into a Physical Address. In addition to the normal * collateral associated with any va->pa translations GEN hardware also has a @@ -450,8 +472,7 @@ typedef uint32_t gen6_gtt_pte_t;* the spec. */ struct i915_gtt { -unsigned long start;/* Start offset of used GTT */ -size_t total;/* Total size GTT can map */ +struct i915_address_space base;size_t stolen_size;/* Total size of stolen memory */ unsigned long mappable_end;/* End offset that we can CPU map */ @@ -472,34 +493,17 @@ struct i915_gtt { size_t *stolen, phys_addr_t *mappable_base, unsigned long *mappable_end);void (*gtt_remove)(struct drm_device *dev); -void (*gtt_clear_range)(struct drm_device *dev, -unsigned int first_entry, -unsigned int num_entries); -void (*gtt_insert_entries)(struct drm_device *dev, -struct sg_table *st, -unsigned int pg_start, -enum i915_cache_level cache_level); -gen6_gtt_pte_t (*pte_encode)(dma_addr_t addr, -enum i915_cache_level level); }; -#define gtt_total_entries (gtt) ((gtt).total >> PAGE_SHIFT) +#define i915_gtt_vm ((struct i915_address_space *)&(dev_priv->gtt.base))struct i915_hw_ppgtt { +struct i915_address_space base;struct drm_mm_node node; -struct drm_device *dev;unsigned num_pd_entries;struct page **pt_pages;uint32_t pd_offset;dma_addr_t *pt_dma_addr; -/* pte functions, mirroring the interface of the global gtt. */ -void (*clear_range)(struct i915_hw_ppgtt *ppgtt, -unsigned int first_entry, -unsigned int num_entries); -void (*insert_entries)(struct i915_hw_ppgtt *ppgtt, -struct sg_table *st, -unsigned int pg_start, -enum i915_cache_level cache_level);gen6_gtt_pte_t (*pte_encode)(dma_addr_t addr,enum i915_cache_level level);int (*enable)(struct drm_device *dev);@@ -1123,7 +1127,7 @@ typedef struct drm_i915_private {enum modeset_restore modeset_restore;struct mutex modeset_restore_lock; -struct i915_gtt gtt; +struct i915_gtt gtt;/* VMA representing the global address space */ struct i915_gem_mm mm;drivers/gpu/drm/i915/i915_gem.c +4
-4@@ -181,7 +181,7 @@ i915_gem_get_aperture_ioctl(struct drm_device *dev, void *data, pinned += obj->gtt_space->size;mutex_unlock (&dev->struct_mutex); - args->aper_size = dev_priv->gtt.total; + args->aper_size = i915_gtt_vm->total; args->aper_available_size = args->aper_size - pinned;return 0 ;@@ -3083,7 +3083,7 @@ i915_gem_object_bind_to_gtt(struct drm_i915_gem_object *obj,u32 size, fence_size, fence_alignment, unfenced_alignment;bool mappable, fenceable;size_t gtt_max = map_and_fenceable ? - dev_priv->gtt.mappable_end : dev_priv->gtt.total; + dev_priv->gtt.mappable_end : dev_priv->gtt.base.total;int ret; fence_size = i915_gem_get_gtt_size(dev,@@ -4226,7 +4226,7 @@ int i915_gem_init(struct drm_device *dev)*/ if (HAS_HW_CONTEXTS (dev)) {i915_gem_setup_global_gtt (dev,0 , dev_priv->gtt.mappable_end, - dev_priv->gtt.total,0 ); + i915_gtt_vm->total,0 );i915_gem_context_init (dev);if (dev_priv->hw_contexts_disabled) {drm_mm_takedown (&dev_priv->mm.gtt_space);@@ -4240,7 +4240,7 @@ ggtt_only:if (HAS_HW_CONTEXTS (dev))DRM_DEBUG_DRIVER ("Context setup failed %d\n" , ret);i915_gem_setup_global_gtt (dev,0 , dev_priv->gtt.mappable_end, - dev_priv->gtt.total,PAGE_SIZE ); + i915_gtt_vm->total,PAGE_SIZE ); } ret =i915_gem_init_hw (dev);drivers/gpu/drm/i915/i915_gem_gtt.c +78
-67@@ -102,7 +102,7 @@ static gen6_gtt_pte_t hsw_pte_encode(dma_addr_t addr,static void gen6_write_pdes (struct i915_hw_ppgtt *ppgtt) { -struct drm_i915_private *dev_priv = ppgtt->dev->dev_private; +struct drm_i915_private *dev_priv = ppgtt->base.dev->dev_private;gen6_gtt_pte_t __iomem *pd_addr;uint32_t pd_entry;int i;@@ -183,18 +183,18 @@ static int gen6_ppgtt_enable(struct drm_device *dev) }/* PPGTT support for Sandybdrige/Gen6 and later */ -static void gen6_ppgtt_clear_range (struct i915_hw_ppgtt *ppgtt, +static void gen6_ppgtt_clear_range (struct i915_address_space *vm,unsigned first_entry,unsigned num_entries) { -struct drm_i915_private *dev_priv = ppgtt->dev->dev_private; +struct i915_hw_ppgtt *ppgtt = + container_of(vm, struct i915_hw_ppgtt, base);gen6_gtt_pte_t *pt_vaddr, scratch_pte;unsigned act_pt = first_entry /I915_PPGTT_PT_ENTRIES ;unsigned first_pte = first_entry %I915_PPGTT_PT_ENTRIES ;unsigned last_pte, i; - scratch_pte = ppgtt->pte_encode (dev_priv->gtt.scratch.addr, -I915_CACHE_LLC ); + scratch_pte = vm->pte_encode (vm->scratch.addr,I915_CACHE_LLC );while (num_entries) { last_pte = first_pte + num_entries;@@ -214,11 +214,13 @@ static void gen6_ppgtt_clear_range(struct i915_hw_ppgtt *ppgtt, } } -static void gen6_ppgtt_insert_entries (struct i915_hw_ppgtt *ppgtt, +static void gen6_ppgtt_insert_entries (struct i915_address_space *vm,struct sg_table *pages,unsigned first_entry,enum i915_cache_level cache_level) { +struct i915_hw_ppgtt *ppgtt = + container_of(vm, struct i915_hw_ppgtt, base);gen6_gtt_pte_t *pt_vaddr;unsigned act_pt = first_entry /I915_PPGTT_PT_ENTRIES ;unsigned act_pte = first_entry %I915_PPGTT_PT_ENTRIES ;@@ -229,7 +231,7 @@ static void gen6_ppgtt_insert_entries(struct i915_hw_ppgtt *ppgtt,dma_addr_t page_addr; page_addr =sg_page_iter_dma_address (&sg_iter); - pt_vaddr[act_pte] = ppgtt->pte_encode (page_addr, cache_level); + pt_vaddr[act_pte] = vm->pte_encode (page_addr, cache_level);if (++act_pte ==I915_PPGTT_PT_ENTRIES ) {kunmap_atomic (pt_vaddr); act_pt++;@@ -243,14 +245,14 @@ static void gen6_ppgtt_insert_entries(struct i915_hw_ppgtt *ppgtt,static void gen6_ppgtt_cleanup (struct i915_hw_ppgtt *ppgtt) { +struct i915_address_space *vm = &ppgtt->base;int i;drm_mm_remove_node (&ppgtt->node);if (ppgtt->pt_dma_addr) {for (i =0 ; i < ppgtt->num_pd_entries; i++) -pci_unmap_page (ppgtt->dev->pdev, - ppgtt->pt_dma_addr[i], +pci_unmap_page (vm->dev->pdev, ppgtt->pt_dma_addr[i],4096 ,PCI_DMA_BIDIRECTIONAL ); }@@ -264,7 +266,8 @@ static int gen6_ppgtt_init(struct i915_hw_ppgtt *ppgtt) {#define GEN6_PD_ALIGN (PAGE_SIZE * 16)#define GEN6_PD_SIZE (GEN6_PPGTT_PD_ENTRIES * PAGE_SIZE) -struct drm_device *dev = ppgtt->dev; +struct i915_address_space *vm = &ppgtt->base; +struct drm_device *dev = vm->dev;struct drm_i915_private *dev_priv = dev->dev_private;int i;int ret = -ENOMEM ;@@ -279,21 +282,22 @@ static int gen6_ppgtt_init(struct i915_hw_ppgtt *ppgtt) &ppgtt->node,GEN6_PD_SIZE ,GEN6_PD_ALIGN ,0 , dev_priv->gtt.mappable_end, - dev_priv->gtt.total, + i915_gtt_vm->total, DRM_MM_TOPDOWN);if (ret)return ret;if (IS_HASWELL (dev)) { - ppgtt->pte_encode = hsw_pte_encode; + vm->pte_encode = hsw_pte_encode; }else if (IS_VALLEYVIEW (dev)) { - ppgtt->pte_encode = byt_pte_encode; + vm->pte_encode = byt_pte_encode; }else { - ppgtt->pte_encode = gen6_pte_encode; + vm->pte_encode = gen6_pte_encode; } ppgtt->pt_pages =kzalloc (sizeof (struct page *)*GEN6_PPGTT_PD_ENTRIES ,GFP_KERNEL ); +if (!ppgtt->pt_pages) {drm_mm_remove_node (&ppgtt->node);return -ENOMEM ;@@ -326,12 +330,15 @@ static int gen6_ppgtt_init(struct i915_hw_ppgtt *ppgtt) ppgtt->num_pd_entries =GEN6_PPGTT_PD_ENTRIES ; ppgtt->enable = gen6_ppgtt_enable; - ppgtt->clear_range = gen6_ppgtt_clear_range; - ppgtt->insert_entries = gen6_ppgtt_insert_entries; ppgtt->cleanup = gen6_ppgtt_cleanup; - ppgtt->clear_range (ppgtt,0 , - ppgtt->num_pd_entries*I915_PPGTT_PT_ENTRIES ); + vm->clear_range = gen6_ppgtt_clear_range; + vm->insert_entries = gen6_ppgtt_insert_entries; + vm->start =0 ; + vm->total =GEN6_PPGTT_PD_ENTRIES *I915_PPGTT_PT_ENTRIES *PAGE_SIZE ; + vm->scratch = dev_priv->gtt.base.scratch; + + vm->clear_range (vm,0 , ppgtt->num_pd_entries *I915_PPGTT_PT_ENTRIES ); DRM_DEBUG_DRIVER("Allocated pde space (%ldM) at GTT entry: %lx\n", ppgtt->node.size >> 20,@@ -363,7 +370,7 @@ int i915_gem_ppgtt_init(struct drm_device *dev, struct i915_hw_ppgtt *ppgtt) {int ret; - ppgtt->dev = dev; + ppgtt->base.dev = dev;if (INTEL_INFO (dev)->gen <8 ) ret =gen6_ppgtt_init (ppgtt);@@ -377,17 +384,17 @@ void i915_ppgtt_bind_object(struct i915_hw_ppgtt *ppgtt,struct drm_i915_gem_object *obj, enum i915_cache_level cache_level) { - ppgtt->insert_entries(ppgtt, obj->pages, - obj->gtt_space->start >> PAGE_SHIFT, -cache_level ); + ppgtt->base.insert_entries(&ppgtt->base, obj->pages, + obj->gtt_space->start >> PAGE_SHIFT, +cache_level ); }void i915_ppgtt_unbind_object (struct i915_hw_ppgtt *ppgtt,struct drm_i915_gem_object *obj) { - ppgtt->clear_range (ppgtt, - obj->gtt_space->start >>PAGE_SHIFT , - obj->base.size >>PAGE_SHIFT ); + ppgtt->base.clear_range (&ppgtt->base, + obj->gtt_space->start >>PAGE_SHIFT , + obj->base.size >>PAGE_SHIFT ); }extern int intel_iommu_gfx_mapped;@@ -434,8 +441,9 @@ void i915_gem_restore_gtt_mappings(struct drm_device *dev)struct drm_i915_gem_object *obj;/* First fill our portion of the GTT with scratch pages */ - dev_priv->gtt.gtt_clear_range (dev, dev_priv->gtt.start /PAGE_SIZE , - dev_priv->gtt.total /PAGE_SIZE ); + i915_gtt_vm->clear_range (&dev_priv->gtt.base, + i915_gtt_vm->start /PAGE_SIZE , + i915_gtt_vm->total /PAGE_SIZE );if (dev_priv->mm.aliasing_ppgtt)gen6_write_pdes (dev_priv->mm.aliasing_ppgtt);@@ -467,12 +475,12 @@ int i915_gem_gtt_prepare_object(struct drm_i915_gem_object *obj)* within the global GTT as well as accessible by the GPU through the GMADR * mapped BAR (dev_priv->mm.gtt->gtt). */ -static void gen6_ggtt_insert_entries (struct drm_device *dev, +static void gen6_ggtt_insert_entries (struct i915_address_space *vm,struct sg_table *st,unsigned int first_entry,enum i915_cache_level level) { -struct drm_i915_private *dev_priv = dev->dev_private; +struct drm_i915_private *dev_priv = vm->dev->dev_private;gen6_gtt_pte_t __iomem *gtt_entries = (gen6_gtt_pte_t __iomem *)dev_priv->gtt.gsm + first_entry;int i =0 ;@@ -481,8 +489,7 @@ static void gen6_ggtt_insert_entries(struct drm_device *dev,for_each_sg_page (st->sgl, &sg_iter, st->nents,0 ) { addr =sg_page_iter_dma_address (&sg_iter); -iowrite32 (dev_priv->gtt.pte_encode (addr, level), - >t_entries[i]); +iowrite32 (vm->pte_encode (addr, level), >t_entries[i]); i++; }@@ -493,8 +500,8 @@ static void gen6_ggtt_insert_entries(struct drm_device *dev,* hardware should work, we must keep this posting read for paranoia. */ if (i !=0 ) -WARN_ON (readl (>t_entries[i-1 ]) - != dev_priv->gtt.pte_encode (addr, level)); +WARN_ON (readl (>t_entries[i-1 ]) != + vm->pte_encode (addr, level));/* This next bit makes the above posting read even more important. We * want to flush the TLBs only after we're certain all the PTE updates @@ -504,14 +511,14 @@ static void gen6_ggtt_insert_entries(struct drm_device *dev,POSTING_READ (GFX_FLSH_CNTL_GEN6 ); } -static void gen6_ggtt_clear_range (struct drm_device *dev, +static void gen6_ggtt_clear_range (struct i915_address_space *vm,unsigned int first_entry,unsigned int num_entries) { -struct drm_i915_private *dev_priv = dev->dev_private; +struct drm_i915_private *dev_priv = vm->dev->dev_private;gen6_gtt_pte_t scratch_pte,__iomem *gtt_base = (gen6_gtt_pte_t __iomem *) dev_priv->gtt.gsm + first_entry; -const int max_entries =gtt_total_entries (dev_priv->gtt) - first_entry; +const int max_entries = (vm->total >>PAGE_SHIFT ) - first_entry;int i;if (num_entries ==0 )@@ -522,15 +529,15 @@ static void gen6_ggtt_clear_range(struct drm_device *dev, first_entry, num_entries, max_entries)) num_entries = max_entries; - scratch_pte = dev_priv->gtt.pte_encode (dev_priv->gtt.scratch.addr, -I915_CACHE_LLC ); + scratch_pte = vm->pte_encode (vm->scratch.addr, +I915_CACHE_LLC );for (i =0 ; i < num_entries; i++)iowrite32 (scratch_pte, >t_base[i]);readl (gtt_base); } -static void i915_ggtt_insert_entries (struct drm_device *dev, +static void i915_ggtt_insert_entries (struct i915_address_space *vm,struct sg_table *st,unsigned int pg_start,enum i915_cache_level cache_level)@@ -542,7 +549,7 @@ static void i915_ggtt_insert_entries(struct drm_device *dev, } -static void i915_ggtt_clear_range (struct drm_device *dev, +static void i915_ggtt_clear_range (struct i915_address_space *vm,unsigned int first_entry,unsigned int num_entries) {@@ -559,9 +566,9 @@ void i915_gem_gtt_bind_object(struct drm_i915_gem_object *obj,struct drm_device *dev = obj->base.dev;struct drm_i915_private *dev_priv = dev->dev_private; - dev_priv->gtt.gtt_insert_entries (dev, obj->pages, - obj->gtt_space->start >>PAGE_SHIFT , - cache_level); + i915_gtt_vm->insert_entries (&dev_priv->gtt.base, obj->pages, + obj->gtt_space->start >>PAGE_SHIFT , + cache_level); obj->has_global_gtt_mapping =1 ; }@@ -571,9 +578,9 @@ void i915_gem_gtt_unbind_object(struct drm_i915_gem_object *obj)struct drm_device *dev = obj->base.dev;struct drm_i915_private *dev_priv = dev->dev_private; - dev_priv->gtt.gtt_clear_range (obj->base.dev, - obj->gtt_space->start >>PAGE_SHIFT , - obj->base.size >>PAGE_SHIFT ); + i915_gtt_vm->clear_range (&dev_priv->gtt.base, + obj->gtt_space->start >>PAGE_SHIFT , + obj->base.size >>PAGE_SHIFT ); obj->has_global_gtt_mapping =0 ; }@@ -679,21 +686,21 @@ void i915_gem_setup_global_gtt(struct drm_device *dev, obj->has_global_gtt_mapping =1 ; } - dev_priv->gtt.start = start; - dev_priv->gtt.total = end - start; + i915_gtt_vm->start = start; + i915_gtt_vm->total = end - start;/* Clear any non-preallocated blocks */ drm_mm_for_each_hole (entry, &dev_priv->mm.gtt_space, hole_start, hole_end) {DRM_DEBUG_KMS ("clearing unused GTT space: [%lx, %lx]\n" , hole_start, hole_end); - dev_priv->gtt.gtt_clear_range (dev, hole_start /PAGE_SIZE , - (hole_end-hole_start) /PAGE_SIZE ); + i915_gtt_vm->clear_range (i915_gtt_vm, hole_start /PAGE_SIZE , + (hole_end-hole_start) /PAGE_SIZE ); }/* And finally clear the reserved guard page */ - dev_priv->gtt.gtt_clear_range (dev, (end - guard_size) /PAGE_SIZE , - guard_size /PAGE_SIZE ); + i915_gtt_vm->clear_range (i915_gtt_vm, (end - guard_size) /PAGE_SIZE , + guard_size /PAGE_SIZE ); }static int setup_scratch_page (struct drm_device *dev)@@ -716,8 +723,8 @@ static int setup_scratch_page(struct drm_device *dev)#else dma_addr =page_to_phys (page);#endif - dev_priv->gtt.scratch.page = page; - dev_priv->gtt.scratch.addr = dma_addr; + i915_gtt_vm->scratch.page = page; + i915_gtt_vm->scratch.addr = dma_addr;return 0 ; }@@ -725,11 +732,12 @@ static int setup_scratch_page(struct drm_device *dev)static void teardown_scratch_page (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; -set_pages_wb (dev_priv->gtt.scratch.page,1 ); -pci_unmap_page (dev->pdev, dev_priv->gtt.scratch.addr, + +set_pages_wb (i915_gtt_vm->scratch.page,1 ); +pci_unmap_page (dev->pdev, i915_gtt_vm->scratch.addr,PAGE_SIZE ,PCI_DMA_BIDIRECTIONAL ); -put_page (dev_priv->gtt.scratch.page); -__free_page (dev_priv->gtt.scratch.page); +put_page (i915_gtt_vm->scratch.page); +__free_page (i915_gtt_vm->scratch.page); }static inline unsigned int gen6_get_total_gtt_size (u16 snb_gmch_ctl)@@ -792,8 +800,8 @@ static int gen6_gmch_probe(struct drm_device *dev,if (ret)DRM_ERROR ("Scratch setup failed\n" ); - dev_priv->gtt.gtt_clear_range = gen6_ggtt_clear_range; - dev_priv->gtt.gtt_insert_entries = gen6_ggtt_insert_entries; + i915_gtt_vm->clear_range = gen6_ggtt_clear_range; + i915_gtt_vm->insert_entries = gen6_ggtt_insert_entries;return ret; }@@ -823,8 +831,8 @@ static int i915_gmch_probe(struct drm_device *dev,intel_gtt_get (gtt_total, stolen, mappable_base, mappable_end); dev_priv->gtt.do_idle_maps =needs_idle_maps (dev_priv->dev); - dev_priv->gtt.gtt_clear_range = i915_ggtt_clear_range; - dev_priv->gtt.gtt_insert_entries = i915_ggtt_insert_entries; + i915_gtt_vm->clear_range = i915_ggtt_clear_range; + i915_gtt_vm->insert_entries = i915_ggtt_insert_entries;return 0 ; }@@ -847,20 +855,23 @@ int i915_gem_gtt_init(struct drm_device *dev) gtt->gtt_probe = gen6_gmch_probe; gtt->gtt_remove = gen6_gmch_remove;if (IS_HASWELL (dev)) - gtt->pte_encode = hsw_pte_encode; + gtt->base.pte_encode = hsw_pte_encode;else if (IS_VALLEYVIEW (dev)) - gtt->pte_encode = byt_pte_encode; + gtt->base.pte_encode = byt_pte_encode;else - gtt->pte_encode = gen6_pte_encode; + gtt->base.pte_encode = gen6_pte_encode; } - ret = gtt->gtt_probe (dev, >t->total, >t->stolen_size, + ret = gtt->gtt_probe (dev, >t->base.total, >t->stolen_size, >t->mappable_base, >t->mappable_end);if (ret)return ret; + gtt->base.dev = dev; +/* GMADR is the PCI mmio aperture into the global GTT. */ -DRM_INFO ("Memory usable by graphics device = %zdM\n" , gtt->total >>20 ); +DRM_INFO ("Memory usable by graphics device = %zdM\n" , + gtt->base.total >>20 );DRM_DEBUG_DRIVER ("GMADR size = %ldM\n" , gtt->mappable_end >>20 );DRM_DEBUG_DRIVER ("GTT stolen size = %zdM\n" , gtt->stolen_size >>20 );Signature · 6 lines
1.8.3.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfxSignature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
Re: [PATCH 21/66] drm/i915: Move gtt and ppgtt under address space umbrella
Quoted 12 lines · Ben Widawsky
Quoted 11 lines · Daniel Vetter
Quoted 9 lines · Ben Widawsky
The GTT and PPGTT can be thought of more generally as GPU address spaces. Many of their actions (insert entries), state (LRU lists) and many of their characteristics (size), can be shared. Do that.
Created a
i915_gtt_vmhelper macro since for now we always want the regular GTT address space. Eventually we'll ween ourselves off of using this except in cases where we obviously want the GGTT (like display).Signed-off-by Ben Widawsky <[email protected]>
Quoted 8 lines
Quoted 4 lines
The
i915_gtt_vm#define is imo too evil. Looks like a local variable, but isn't. I think in most places we should just drop it, in others we should add a real local vm variable. I'll punt for now on this one. -DanielIt's dropped later in the series. It was a temporary bandaid to make the diffs a bit easier to swallow. I can certainly get rid of it next time around
Again I think (hope) that know that we know what this should look like in the end, we can cut some diff churn. So e.g. when you move something from dev_priv->mm to i915_address_space you check each place you touch in the end-state of your branch and
- either add a local variable if the specific function will look up the relevant address_space object itself
- or add the right function argument right away if it gets the address_space passed in from callers.
Equivalently for moving stuff from the gem object to the vma.
Since both address space and vma have pointers to the old place (i.e. drm_device or gem_object) you can add a temporary variable if a functions newly gets an address_space/vma while the conversion is still ongoing. That way we should not end up with needless churn in function signatures, either.
Again I think more foreshadowing here would be really nice, so that's what I'm aiming for with this idea.
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
PATCH 22/66 drm/i915: Move gtt_mtrr to i915_gtt
In reply to Ben Widawskyfor file in ls drivers/gpu/drm/i915/*.c ; do
sed -i "s/mm.gtt_mtrr/gtt.mtrr/" $file;
done
--- drivers/gpu/drm/i915/i915_dma.c | 8 ++++---- drivers/gpu/drm/i915/i915_drv.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +4 -4
@@ -1558,8 +1558,8 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags) goto out_rmmap; } - dev_priv->mm.gtt_mtrr =arch_phys_wc_add (dev_priv->gtt.mappable_base, - aperture_size); + dev_priv->gtt.mtrr =arch_phys_wc_add (dev_priv->gtt.mappable_base, + aperture_size);/* The i915 workqueue is primarily used for batched retirement of * requests (and thus managing bo) once the task has been completed
@@ -1667,7 +1667,7 @@ out_gem_unload:intel_teardown_mchbar (dev);destroy_workqueue (dev_priv->wq); out_mtrrfree: -arch_phys_wc_del (dev_priv->mm.gtt_mtrr); +arch_phys_wc_del (dev_priv->gtt.mtrr);io_mapping_free (dev_priv->gtt.mappable); dev_priv->gtt.gtt_remove (dev); out_rmmap:
@@ -1705,7 +1705,7 @@ int i915_driver_unload(struct drm_device *dev)cancel_delayed_work_sync (&dev_priv->mm.retire_work);io_mapping_free (dev_priv->gtt.mappable); -arch_phys_wc_del (dev_priv->mm.gtt_mtrr); +arch_phys_wc_del (dev_priv->gtt.mtrr);acpi_video_unregister ();
drivers/gpu/drm/i915/i915_drv.h +2 -2
@@ -488,6 +488,8 @@ struct i915_gtt {struct page *page; } scratch; +int mtrr; +/* global gtt ops */ int (*gtt_probe)(struct drm_device *dev, size_t *gtt_total, size_t *stolen, phys_addr_t *mappable_base,
@@ -843,8 +845,6 @@ struct i915_gem_mm {/** Usable portion of the GTT for GEM */ unsigned long stolen_base;/* limited to low memory (32-bit) */ -int gtt_mtrr; -/** PPGTT used for aliasing the PPGTT with the GTT */ struct i915_hw_ppgtt *aliasing_ppgtt;
Signature · 1 line
1.8.3.1
PATCH 23/66 drm/i915: Move stolen stuff to i915_gtt
In reply to Ben WidawskyIt doesn't apply to generic VMA, so it belongs with the gtt.
for file in ls drivers/gpu/drm/i915/*.c ; do
sed -i "s/mm.stolen_base/gtt.stolen_base/" $file;
done
for file in ls drivers/gpu/drm/i915/*.c ; do
sed -i "s/mm.stolen/gtt.stolen/" $file;
done
--- drivers/gpu/drm/i915/i915_drv.h | 8 +++----- drivers/gpu/drm/i915/i915_gem_stolen.c | 32 ++++++++++++++++---------------- drivers/gpu/drm/i915/i915_irq.c | 2 +- drivers/gpu/drm/i915/intel_pm.c | 4 ++-- 4 files changed, 22 insertions(+), 24 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +3 -5
@@ -473,6 +473,9 @@ struct i915_address_space {*/ struct i915_gtt {struct i915_address_space base; + +struct drm_mm stolen; +unsigned long stolen_base;/* limited to low memory (32-bit) */ size_t stolen_size;/* Total size of stolen memory */ unsigned long mappable_end;/* End offset that we can CPU map */
@@ -828,8 +831,6 @@ struct intel_l3_parity { };struct i915_gem_mm { -/** Memory allocator for GTT stolen memory */ -struct drm_mm stolen;/** Memory allocator for GTT */ struct drm_mm gtt_space;/** List of all objects in gtt_space. Used to restore gtt
@@ -842,9 +843,6 @@ struct i915_gem_mm {*/ struct list_head unbound_list; -/** Usable portion of the GTT for GEM */ -unsigned long stolen_base;/* limited to low memory (32-bit) */ -/** PPGTT used for aliasing the PPGTT with the GTT */ struct i915_hw_ppgtt *aliasing_ppgtt;
drivers/gpu/drm/i915/i915_gem_stolen.c +16 -16
@@ -97,10 +97,10 @@ static int i915_setup_compression(struct drm_device *dev, int size)struct drm_mm_node *compressed_fb, *uninitialized_var (compressed_llb );/* Try to over-allocate to reduce reallocations and fragmentation */ - compressed_fb =drm_mm_search_free (&dev_priv->mm.stolen, + compressed_fb =drm_mm_search_free (&dev_priv->gtt.stolen, size <<=1 ,4096 ,0 );if (!compressed_fb) - compressed_fb =drm_mm_search_free (&dev_priv->mm.stolen, + compressed_fb =drm_mm_search_free (&dev_priv->gtt.stolen, size >>=1 ,4096 ,0 );if (compressed_fb) compressed_fb =drm_mm_get_block (compressed_fb, size,4096 );
@@ -112,7 +112,7 @@ static int i915_setup_compression(struct drm_device *dev, int size)else if (IS_GM45 (dev)) {I915_WRITE (DPFC_CB_BASE , compressed_fb->start); }else { - compressed_llb =drm_mm_search_free (&dev_priv->mm.stolen, + compressed_llb =drm_mm_search_free (&dev_priv->gtt.stolen,4096 ,4096 ,0 );if (compressed_llb) compressed_llb = drm_mm_get_block(compressed_llb,
@@ -123,9 +123,9 @@ static int i915_setup_compression(struct drm_device *dev, int size) dev_priv->fbc.compressed_llb = compressed_llb;I915_WRITE (FBC_CFB_BASE , - dev_priv->mm.stolen_base + compressed_fb->start); + dev_priv->gtt.stolen_base + compressed_fb->start);I915_WRITE (FBC_LL_BASE , - dev_priv->mm.stolen_base + compressed_llb->start); + dev_priv->gtt.stolen_base + compressed_llb->start); } dev_priv->fbc.compressed_fb = compressed_fb;
@@ -147,7 +147,7 @@ int i915_gem_stolen_setup_compression(struct drm_device *dev, int size) {struct drm_i915_private *dev_priv = dev->dev_private; -if (dev_priv->mm.stolen_base ==0 ) +if (dev_priv->gtt.stolen_base ==0 )return -ENODEV ;if (size < dev_priv->fbc.size)
@@ -180,7 +180,7 @@ void i915_gem_cleanup_stolen(struct drm_device *dev)struct drm_i915_private *dev_priv = dev->dev_private;i915_gem_stolen_cleanup_compression (dev); -drm_mm_takedown (&dev_priv->mm.stolen); +drm_mm_takedown (&dev_priv->gtt.stolen); }int i915_gem_init_stolen (struct drm_device *dev)
@@ -188,18 +188,18 @@ int i915_gem_init_stolen(struct drm_device *dev)struct drm_i915_private *dev_priv = dev->dev_private;int bios_reserved =0 ; - dev_priv->mm.stolen_base =i915_stolen_to_physical (dev); -if (dev_priv->mm.stolen_base ==0 ) + dev_priv->gtt.stolen_base =i915_stolen_to_physical (dev); +if (dev_priv->gtt.stolen_base ==0 )return 0 ;DRM_DEBUG_KMS ("found %zd bytes of stolen memory at %08lx\n" , - dev_priv->gtt.stolen_size, dev_priv->mm.stolen_base); + dev_priv->gtt.stolen_size, dev_priv->gtt.stolen_base);if (IS_VALLEYVIEW (dev)) bios_reserved =1024 *1024 ;/* top 1M on VLV/BYT */ /* Basic memrange allocator for stolen space */ -drm_mm_init (&dev_priv->mm.stolen,0 , dev_priv->gtt.stolen_size - +drm_mm_init (&dev_priv->gtt.stolen,0 , dev_priv->gtt.stolen_size - bios_reserved);return 0 ;
@@ -234,7 +234,7 @@ i915_pages_create_for_stolen(struct drm_device *dev, sg->offset = offset; sg->length = size; -sg_dma_address (sg) = (dma_addr_t )dev_priv->mm.stolen_base + offset; +sg_dma_address (sg) = (dma_addr_t )dev_priv->gtt.stolen_base + offset;sg_dma_len (sg) = size;return st;
@@ -300,14 +300,14 @@ i915_gem_object_create_stolen(struct drm_device *dev, u32 size)struct drm_i915_gem_object *obj;struct drm_mm_node *stolen; -if (dev_priv->mm.stolen_base ==0 ) +if (dev_priv->gtt.stolen_base ==0 )return NULL ;DRM_DEBUG_KMS ("creating stolen object: size=%x\n" , size);if (size ==0 )return NULL ; - stolen =drm_mm_search_free (&dev_priv->mm.stolen, size,4096 ,0 ); + stolen =drm_mm_search_free (&dev_priv->gtt.stolen, size,4096 ,0 );if (stolen) stolen =drm_mm_get_block (stolen, size,4096 );if (stolen ==NULL )
@@ -331,7 +331,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,struct drm_i915_gem_object *obj;struct drm_mm_node *stolen; -if (dev_priv->mm.stolen_base ==0 ) +if (dev_priv->gtt.stolen_base ==0 )return NULL ; DRM_DEBUG_KMS("creating preallocated stolen object: stolen_offset=%x, gtt_offset=%x, size=%x\n",
@@ -344,7 +344,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,if (WARN_ON (size ==0 ))return NULL ; - stolen =drm_mm_create_block (&dev_priv->mm.stolen, + stolen =drm_mm_create_block (&dev_priv->gtt.stolen, stolen_offset, size, false);if (stolen ==NULL ) {
drivers/gpu/drm/i915/i915_irq.c +1 -1
@@ -1538,7 +1538,7 @@ i915_error_object_create_sized(struct drm_i915_private *dev_priv, }else if (src->stolen) {unsigned long offset; - offset = dev_priv->mm.stolen_base; + offset = dev_priv->gtt.stolen_base; offset += src->stolen->start; offset += i <<PAGE_SHIFT ;
drivers/gpu/drm/i915/intel_pm.c +2 -2
@@ -3464,7 +3464,7 @@ static void valleyview_setup_pctx(struct drm_device *dev)/* BIOS set it up already, grab the pre-alloc'd space */ int pcbr_offset; - pcbr_offset = (pcbr & (~4095 )) - dev_priv->mm.stolen_base; + pcbr_offset = (pcbr & (~4095 )) - dev_priv->gtt.stolen_base; pctx = i915_gem_object_create_stolen_for_preallocated(dev_priv->dev, pcbr_offset, -1,
@@ -3486,7 +3486,7 @@ static void valleyview_setup_pctx(struct drm_device *dev)return ; } - pctx_paddr = dev_priv->mm.stolen_base + pctx->stolen->start; + pctx_paddr = dev_priv->gtt.stolen_base + pctx->stolen->start;I915_WRITE (VLV_PCBR , pctx_paddr); out:
Signature · 1 line
1.8.3.1
Re: [PATCH 23/66] drm/i915: Move stolen stuff to i915_gtt
Quoted 11 lines · Ben Widawsky
It doesn't apply to generic VMA, so it belongs with the gtt.
for file in
ls drivers/gpu/drm/i915/*.c; dosed -i "s/mm.stolen_base/gtt.stolen_base/" $file;done
for file in
ls drivers/gpu/drm/i915/*.c; dosed -i "s/mm.stolen/gtt.stolen/" $file;done
Signed-off-by Ben Widawsky <[email protected]>
Before I keep on merging I'd like to clarify the plan a bit: Afaics the goal is to extract useful stuff shared between global gtt and ppgtt into i915_address_space. But I'm a bit unclear what dev_priv->mm will hold in the end, so I'm not sure whether moving stolen around makes sense.
Can you please elaborate on your plan a bit on how dev_priv->gtt and dev_priv->mm will relate in the end?
Thanks, Daniel
Quoted 205 lines
--- drivers/gpu/drm/i915/i915_drv.h | 8 +++----- drivers/gpu/drm/i915/i915_gem_stolen.c | 32 ++++++++++++++++---------------- drivers/gpu/drm/i915/i915_irq.c | 2 +- drivers/gpu/drm/i915/intel_pm.c | 4 ++-- 4 files changed, 22 insertions(+), 24 deletions(-)drivers/gpu/drm/i915/i915_drv.h +3
-5@@ -473,6 +473,9 @@ struct i915_address_space {*/ struct i915_gtt {struct i915_address_space base; + +struct drm_mm stolen; +unsigned long stolen_base;/* limited to low memory (32-bit) */ size_t stolen_size;/* Total size of stolen memory */ unsigned long mappable_end;/* End offset that we can CPU map */ @@ -828,8 +831,6 @@ struct intel_l3_parity { };struct i915_gem_mm { -/** Memory allocator for GTT stolen memory */ -struct drm_mm stolen;/** Memory allocator for GTT */ struct drm_mm gtt_space;/** List of all objects in gtt_space. Used to restore gtt @@ -842,9 +843,6 @@ struct i915_gem_mm {*/ struct list_head unbound_list; -/** Usable portion of the GTT for GEM */ -unsigned long stolen_base;/* limited to low memory (32-bit) */ -/** PPGTT used for aliasing the PPGTT with the GTT */ struct i915_hw_ppgtt *aliasing_ppgtt;drivers/gpu/drm/i915/i915_gem_stolen.c +16
-16@@ -97,10 +97,10 @@ static int i915_setup_compression(struct drm_device *dev, int size)struct drm_mm_node *compressed_fb, *uninitialized_var (compressed_llb );/* Try to over-allocate to reduce reallocations and fragmentation */ - compressed_fb =drm_mm_search_free (&dev_priv->mm.stolen, + compressed_fb =drm_mm_search_free (&dev_priv->gtt.stolen, size <<=1 ,4096 ,0 );if (!compressed_fb) - compressed_fb =drm_mm_search_free (&dev_priv->mm.stolen, + compressed_fb =drm_mm_search_free (&dev_priv->gtt.stolen, size >>=1 ,4096 ,0 );if (compressed_fb) compressed_fb =drm_mm_get_block (compressed_fb, size,4096 );@@ -112,7 +112,7 @@ static int i915_setup_compression(struct drm_device *dev, int size)else if (IS_GM45 (dev)) {I915_WRITE (DPFC_CB_BASE , compressed_fb->start); }else { - compressed_llb =drm_mm_search_free (&dev_priv->mm.stolen, + compressed_llb =drm_mm_search_free (&dev_priv->gtt.stolen,4096 ,4096 ,0 );if (compressed_llb) compressed_llb = drm_mm_get_block(compressed_llb,@@ -123,9 +123,9 @@ static int i915_setup_compression(struct drm_device *dev, int size) dev_priv->fbc.compressed_llb = compressed_llb;I915_WRITE (FBC_CFB_BASE , - dev_priv->mm.stolen_base + compressed_fb->start); + dev_priv->gtt.stolen_base + compressed_fb->start);I915_WRITE (FBC_LL_BASE , - dev_priv->mm.stolen_base + compressed_llb->start); + dev_priv->gtt.stolen_base + compressed_llb->start); } dev_priv->fbc.compressed_fb = compressed_fb;@@ -147,7 +147,7 @@ int i915_gem_stolen_setup_compression(struct drm_device *dev, int size) {struct drm_i915_private *dev_priv = dev->dev_private; -if (dev_priv->mm.stolen_base ==0 ) +if (dev_priv->gtt.stolen_base ==0 )return -ENODEV ;if (size < dev_priv->fbc.size)@@ -180,7 +180,7 @@ void i915_gem_cleanup_stolen(struct drm_device *dev)struct drm_i915_private *dev_priv = dev->dev_private;i915_gem_stolen_cleanup_compression (dev); -drm_mm_takedown (&dev_priv->mm.stolen); +drm_mm_takedown (&dev_priv->gtt.stolen); }int i915_gem_init_stolen (struct drm_device *dev)@@ -188,18 +188,18 @@ int i915_gem_init_stolen(struct drm_device *dev)struct drm_i915_private *dev_priv = dev->dev_private;int bios_reserved =0 ; - dev_priv->mm.stolen_base =i915_stolen_to_physical (dev); -if (dev_priv->mm.stolen_base ==0 ) + dev_priv->gtt.stolen_base =i915_stolen_to_physical (dev); +if (dev_priv->gtt.stolen_base ==0 )return 0 ;DRM_DEBUG_KMS ("found %zd bytes of stolen memory at %08lx\n" , - dev_priv->gtt.stolen_size, dev_priv->mm.stolen_base); + dev_priv->gtt.stolen_size, dev_priv->gtt.stolen_base);if (IS_VALLEYVIEW (dev)) bios_reserved =1024 *1024 ;/* top 1M on VLV/BYT */ /* Basic memrange allocator for stolen space */ -drm_mm_init (&dev_priv->mm.stolen,0 , dev_priv->gtt.stolen_size - +drm_mm_init (&dev_priv->gtt.stolen,0 , dev_priv->gtt.stolen_size - bios_reserved);return 0 ;@@ -234,7 +234,7 @@ i915_pages_create_for_stolen(struct drm_device *dev, sg->offset = offset; sg->length = size; -sg_dma_address (sg) = (dma_addr_t )dev_priv->mm.stolen_base + offset; +sg_dma_address (sg) = (dma_addr_t )dev_priv->gtt.stolen_base + offset;sg_dma_len (sg) = size;return st;@@ -300,14 +300,14 @@ i915_gem_object_create_stolen(struct drm_device *dev, u32 size)struct drm_i915_gem_object *obj;struct drm_mm_node *stolen; -if (dev_priv->mm.stolen_base ==0 ) +if (dev_priv->gtt.stolen_base ==0 )return NULL ;DRM_DEBUG_KMS ("creating stolen object: size=%x\n" , size);if (size ==0 )return NULL ; - stolen =drm_mm_search_free (&dev_priv->mm.stolen, size,4096 ,0 ); + stolen =drm_mm_search_free (&dev_priv->gtt.stolen, size,4096 ,0 );if (stolen) stolen =drm_mm_get_block (stolen, size,4096 );if (stolen ==NULL )@@ -331,7 +331,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,struct drm_i915_gem_object *obj;struct drm_mm_node *stolen; -if (dev_priv->mm.stolen_base ==0 ) +if (dev_priv->gtt.stolen_base ==0 )return NULL ; DRM_DEBUG_KMS("creating preallocated stolen object: stolen_offset=%x, gtt_offset=%x, size=%x\n",@@ -344,7 +344,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,if (WARN_ON (size ==0 ))return NULL ; - stolen =drm_mm_create_block (&dev_priv->mm.stolen, + stolen =drm_mm_create_block (&dev_priv->gtt.stolen, stolen_offset, size, false);if (stolen ==NULL ) {drivers/gpu/drm/i915/i915_irq.c +1
-1@@ -1538,7 +1538,7 @@ i915_error_object_create_sized(struct drm_i915_private *dev_priv, }else if (src->stolen) {unsigned long offset; - offset = dev_priv->mm.stolen_base; + offset = dev_priv->gtt.stolen_base; offset += src->stolen->start; offset += i <<PAGE_SHIFT ;drivers/gpu/drm/i915/intel_pm.c +2
-2@@ -3464,7 +3464,7 @@ static void valleyview_setup_pctx(struct drm_device *dev)/* BIOS set it up already, grab the pre-alloc'd space */ int pcbr_offset; - pcbr_offset = (pcbr & (~4095 )) - dev_priv->mm.stolen_base; + pcbr_offset = (pcbr & (~4095 )) - dev_priv->gtt.stolen_base; pctx = i915_gem_object_create_stolen_for_preallocated(dev_priv->dev, pcbr_offset, -1,@@ -3486,7 +3486,7 @@ static void valleyview_setup_pctx(struct drm_device *dev)return ; } - pctx_paddr = dev_priv->mm.stolen_base + pctx->stolen->start; + pctx_paddr = dev_priv->gtt.stolen_base + pctx->stolen->start;I915_WRITE (VLV_PCBR , pctx_paddr); out:Signature · 6 lines
1.8.3.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 23/66] drm/i915: Move stolen stuff to i915_gtt
Quoted 18 lines · Daniel Vetter
Quoted 11 lines · Ben Widawsky
It doesn't apply to generic VMA, so it belongs with the gtt.
for file in
ls drivers/gpu/drm/i915/*.c; dosed -i "s/mm.stolen_base/gtt.stolen_base/" $file;done
for file in
ls drivers/gpu/drm/i915/*.c; dosed -i "s/mm.stolen/gtt.stolen/" $file;done
Signed-off-by Ben Widawsky <[email protected]>Before I keep on merging I'd like to clarify the plan a bit: Afaics the goal is to extract useful stuff shared between global gtt and ppgtt into
i915_address_space. But I'm a bit unclear whatdev_priv->mmwill hold in the end, so I'm not sure whether moving stolen around makes sense.
Quoted 5 lines
Can you please elaborate on your plan a bit on how
dev_priv->gttanddev_priv->mmwill relate in the end?Thanks, Daniel
This patch is leftover from when I completely removed mm. In the high level abstraction, the stolen memory belongs to the GTT, so I decided to keep it. There is no other reason for the patch. We can drop it of nobody likes it.
[snip]
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
Re: [PATCH 23/66] drm/i915: Move stolen stuff to i915_gtt
Quoted 22 lines · Ben Widawsky
Quoted 21 lines · Daniel Vetter
Quoted 11 lines · Ben Widawsky
It doesn't apply to generic VMA, so it belongs with the gtt.
for file in
ls drivers/gpu/drm/i915/*.c; dosed -i "s/mm.stolen_base/gtt.stolen_base/" $file;done
for file in
ls drivers/gpu/drm/i915/*.c; dosed -i "s/mm.stolen/gtt.stolen/" $file;done
Signed-off-by Ben Widawsky <[email protected]>Before I keep on merging I'd like to clarify the plan a bit: Afaics the goal is to extract useful stuff shared between global gtt and ppgtt into
i915_address_space. But I'm a bit unclear whatdev_priv->mmwill hold in the end, so I'm not sure whether moving stolen around makes sense.Can you please elaborate on your plan a bit on how
dev_priv->gttanddev_priv->mmwill relate in the end?
Quoted 6 lines
Quoted 2 lines
Thanks, Daniel
This patch is leftover from when I completely removed mm. In the high level abstraction, the stolen memory belongs to the GTT, so I decided to keep it. There is no other reason for the patch. We can drop it of nobody likes it.
I think keeping the stolen allocator in ->mm makes more sense then, since it doesn't stricly have anything to do with managing the global gtt address space. If the linux memory hotplug support wouldn't be so limited we could even hand out that block of RAM to the core page allocator ...
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
PATCH 24/66 drm/i915: Move aliasing_ppgtt
In reply to Ben Widawskyfor file in ls drivers/gpu/drm/i915/*.c ; do
sed -i "s/mm.aliasing/gtt.aliasing/" $file;
done
--- drivers/gpu/drm/i915/i915_debugfs.c | 4 ++-- drivers/gpu/drm/i915/i915_dma.c | 2 +- drivers/gpu/drm/i915/i915_drv.h | 6 +++--- drivers/gpu/drm/i915/i915_gem.c | 12 ++++++------ drivers/gpu/drm/i915/i915_gem_context.c | 4 ++-- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 4 ++-- drivers/gpu/drm/i915/i915_gem_gtt.c | 6 +++--- 7 files changed, 19 insertions(+), 19 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +2 -2
@@ -1816,8 +1816,8 @@ static int i915_ppgtt_info(struct seq_file *m, void *data)seq_printf (m,"PP_DIR_BASE_READ: 0x%08x\n" ,I915_READ (RING_PP_DIR_BASE_READ (ring)));seq_printf (m,"PP_DIR_DCLV: 0x%08x\n" ,I915_READ (RING_PP_DIR_DCLV (ring))); } -if (dev_priv->mm.aliasing_ppgtt) { -struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; +if (dev_priv->gtt.aliasing_ppgtt) { +struct i915_hw_ppgtt *ppgtt = dev_priv->gtt.aliasing_ppgtt;seq_printf (m,"aliasing PPGTT:\n" );seq_printf (m,"pd gtt offset: 0x%08x\n" , ppgtt->pd_offset);
drivers/gpu/drm/i915/i915_dma.c +1 -1
@@ -977,7 +977,7 @@ static int i915_getparam(struct drm_device *dev, void *data, value =HAS_LLC (dev);break ;case I915_PARAM_HAS_ALIASING_PPGTT : -if (intel_enable_ppgtt (dev) && dev_priv->mm.aliasing_ppgtt) +if (intel_enable_ppgtt (dev) && dev_priv->gtt.aliasing_ppgtt) value =1 ;break ;case I915_PARAM_HAS_WAIT_TIMEOUT :
drivers/gpu/drm/i915/i915_drv.h +3 -3
@@ -482,6 +482,9 @@ struct i915_gtt {struct io_mapping *mappable;/* Mapping to our CPU mappable region */ phys_addr_t mappable_base;/* PA of our GMADR */ +/** PPGTT used for aliasing the PPGTT with the GTT */ +struct i915_hw_ppgtt *aliasing_ppgtt; +/** "Graphics Stolen Memory" holds the global PTEs */ void __iomem *gsm;
@@ -843,9 +846,6 @@ struct i915_gem_mm {*/ struct list_head unbound_list; -/** PPGTT used for aliasing the PPGTT with the GTT */ -struct i915_hw_ppgtt *aliasing_ppgtt; -struct shrinker inactive_shrinker;bool shrinker_no_lock_stealing;
drivers/gpu/drm/i915/i915_gem.c +6 -6
@@ -2620,7 +2620,7 @@ i915_gem_object_unbind(struct drm_i915_gem_object *obj)if (obj->has_global_gtt_mapping)i915_gem_gtt_unbind_object (obj);if (obj->has_aliasing_ppgtt_mapping) { -i915_ppgtt_unbind_object (dev_priv->mm.aliasing_ppgtt, obj); +i915_ppgtt_unbind_object (dev_priv->gtt.aliasing_ppgtt, obj); obj->has_aliasing_ppgtt_mapping =0 ; }i915_gem_gtt_finish_object (obj);
@@ -3359,7 +3359,7 @@ int i915_gem_object_set_cache_level(struct drm_i915_gem_object *obj,if (obj->has_global_gtt_mapping)i915_gem_gtt_bind_object (obj, cache_level);if (obj->has_aliasing_ppgtt_mapping) -i915_ppgtt_bind_object (dev_priv->mm.aliasing_ppgtt, +i915_ppgtt_bind_object (dev_priv->gtt.aliasing_ppgtt, obj, cache_level); obj->gtt_space->color = cache_level;
@@ -3668,7 +3668,7 @@ i915_gem_object_pin(struct drm_i915_gem_object *obj,if (ret)return ret; -if (!dev_priv->mm.aliasing_ppgtt) +if (!dev_priv->gtt.aliasing_ppgtt)i915_gem_gtt_bind_object (obj, obj->cache_level); }
@@ -4191,10 +4191,10 @@ i915_gem_init_hw(struct drm_device *dev)* the do_switch), but before enabling PPGTT. So don't move this. */ ret =i915_gem_context_enable (dev_priv); -if (ret || !dev_priv->mm.aliasing_ppgtt) +if (ret || !dev_priv->gtt.aliasing_ppgtt) goto disable_ctx_out; - ret = dev_priv->mm.aliasing_ppgtt->enable (dev); + ret = dev_priv->gtt.aliasing_ppgtt->enable (dev);if (ret) goto disable_ctx_out;
@@ -4236,7 +4236,7 @@ int i915_gem_init(struct drm_device *dev) dev_priv->hw_contexts_disabled = true; ggtt_only: -if (!dev_priv->mm.aliasing_ppgtt) { +if (!dev_priv->gtt.aliasing_ppgtt) {if (HAS_HW_CONTEXTS (dev))DRM_DEBUG_DRIVER ("Context setup failed %d\n" , ret); i915_gem_setup_global_gtt(dev, 0, dev_priv->gtt.mappable_end,
drivers/gpu/drm/i915/i915_gem_context.c +2 -2
@@ -226,7 +226,7 @@ static int create_default_context(struct drm_i915_private *dev_priv) } dev_priv->ring[RCS ].default_context = ctx; - dev_priv->mm.aliasing_ppgtt = &ctx->ppgtt; + dev_priv->gtt.aliasing_ppgtt = &ctx->ppgtt;DRM_DEBUG_DRIVER ("Default HW context loaded\n" );return 0 ;
@@ -300,7 +300,7 @@ void i915_gem_context_fini(struct drm_device *dev)i915_gem_context_unreference (dctx); dev_priv->ring[RCS ].default_context =NULL ; dev_priv->ring[RCS ].last_context =NULL ; - dev_priv->mm.aliasing_ppgtt =NULL ; + dev_priv->gtt.aliasing_ppgtt =NULL ; }int i915_gem_context_enable (struct drm_i915_private *dev_priv)
drivers/gpu/drm/i915/i915_gem_execbuffer.c +2 -2
@@ -429,8 +429,8 @@ i915_gem_execbuffer_reserve_object(struct drm_i915_gem_object *obj, }/* Ensure ppgtt mapping exists if needed */ -if (dev_priv->mm.aliasing_ppgtt && !obj->has_aliasing_ppgtt_mapping) { -i915_ppgtt_bind_object (dev_priv->mm.aliasing_ppgtt, +if (dev_priv->gtt.aliasing_ppgtt && !obj->has_aliasing_ppgtt_mapping) { +i915_ppgtt_bind_object (dev_priv->gtt.aliasing_ppgtt, obj, obj->cache_level); obj->has_aliasing_ppgtt_mapping =1 ;
drivers/gpu/drm/i915/i915_gem_gtt.c +3 -3
@@ -127,7 +127,7 @@ static int gen6_ppgtt_enable(struct drm_device *dev)drm_i915_private_t *dev_priv = dev->dev_private;uint32_t pd_offset;struct intel_ring_buffer *ring; -struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; +struct i915_hw_ppgtt *ppgtt = dev_priv->gtt.aliasing_ppgtt;int i;BUG_ON (ppgtt->pd_offset &0x3f );
@@ -445,8 +445,8 @@ void i915_gem_restore_gtt_mappings(struct drm_device *dev) i915_gtt_vm->start /PAGE_SIZE , i915_gtt_vm->total / PAGE_SIZE); -if (dev_priv->mm.aliasing_ppgtt) -gen6_write_pdes (dev_priv->mm.aliasing_ppgtt); +if (dev_priv->gtt.aliasing_ppgtt) +gen6_write_pdes (dev_priv->gtt.aliasing_ppgtt);list_for_each_entry (obj, &dev_priv->mm.bound_list, global_list) {i915_gem_clflush_object (obj);
Signature · 1 line
1.8.3.1
Re: [PATCH 24/66] drm/i915: Move aliasing_ppgtt
Quoted 3 lines · Ben Widawsky
for file in
ls drivers/gpu/drm/i915/*.c; dosed -i "s/mm.aliasing/gtt.aliasing/" $file;done
Commit message should explain _why_ we do something. Again I'm asking since I'm unclear about how things fit all together and what the different responsibilities are. I think I understand your design here to make both real ppgtt work and keep aliasing ppgtt going, but I'd like you to explain this in your words ;-)
One thing which looks a bit peculiar at the end is that struct i915_hw_ppgtt is actually used as the real ppgtt object (since it subclases i915_address space). My original plan was that we'll add a new
struct i915_ppgtt {
struct i915_address_space base;
struct i915_hw_ppgtt hw_ppgtt;
}To fit into your design the alising ppgtt pointer in dev_priv->gtt would then only point at a hw_ppgtt struct, not the full deal with address space and everything else around attached.
Cheers, Daniel
Quoted 185 lines
Signed-off-by Ben Widawsky <[email protected]>--- drivers/gpu/drm/i915/i915_debugfs.c | 4 ++-- drivers/gpu/drm/i915/i915_dma.c | 2 +- drivers/gpu/drm/i915/i915_drv.h | 6 +++--- drivers/gpu/drm/i915/i915_gem.c | 12 ++++++------ drivers/gpu/drm/i915/i915_gem_context.c | 4 ++-- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 4 ++-- drivers/gpu/drm/i915/i915_gem_gtt.c | 6 +++--- 7 files changed, 19 insertions(+), 19 deletions(-)drivers/gpu/drm/i915/i915_debugfs.c +2
-2@@ -1816,8 +1816,8 @@ static int i915_ppgtt_info(struct seq_file *m, void *data)seq_printf (m,"PP_DIR_BASE_READ: 0x%08x\n" ,I915_READ (RING_PP_DIR_BASE_READ (ring)));seq_printf (m,"PP_DIR_DCLV: 0x%08x\n" ,I915_READ (RING_PP_DIR_DCLV (ring))); } -if (dev_priv->mm.aliasing_ppgtt) { -struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; +if (dev_priv->gtt.aliasing_ppgtt) { +struct i915_hw_ppgtt *ppgtt = dev_priv->gtt.aliasing_ppgtt;seq_printf (m,"aliasing PPGTT:\n" );seq_printf (m,"pd gtt offset: 0x%08x\n" , ppgtt->pd_offset);drivers/gpu/drm/i915/i915_dma.c +1
-1@@ -977,7 +977,7 @@ static int i915_getparam(struct drm_device *dev, void *data, value =HAS_LLC (dev);break ;case I915_PARAM_HAS_ALIASING_PPGTT : -if (intel_enable_ppgtt (dev) && dev_priv->mm.aliasing_ppgtt) +if (intel_enable_ppgtt (dev) && dev_priv->gtt.aliasing_ppgtt) value =1 ;break ;case I915_PARAM_HAS_WAIT_TIMEOUT :drivers/gpu/drm/i915/i915_drv.h +3
-3@@ -482,6 +482,9 @@ struct i915_gtt {struct io_mapping *mappable;/* Mapping to our CPU mappable region */ phys_addr_t mappable_base;/* PA of our GMADR */ +/** PPGTT used for aliasing the PPGTT with the GTT */ +struct i915_hw_ppgtt *aliasing_ppgtt; +/** "Graphics Stolen Memory" holds the global PTEs */ void __iomem *gsm;@@ -843,9 +846,6 @@ struct i915_gem_mm {*/ struct list_head unbound_list; -/** PPGTT used for aliasing the PPGTT with the GTT */ -struct i915_hw_ppgtt *aliasing_ppgtt; -struct shrinker inactive_shrinker;bool shrinker_no_lock_stealing;drivers/gpu/drm/i915/i915_gem.c +6
-6@@ -2620,7 +2620,7 @@ i915_gem_object_unbind(struct drm_i915_gem_object *obj)if (obj->has_global_gtt_mapping)i915_gem_gtt_unbind_object (obj);if (obj->has_aliasing_ppgtt_mapping) { -i915_ppgtt_unbind_object (dev_priv->mm.aliasing_ppgtt, obj); +i915_ppgtt_unbind_object (dev_priv->gtt.aliasing_ppgtt, obj); obj->has_aliasing_ppgtt_mapping =0 ; }i915_gem_gtt_finish_object (obj);@@ -3359,7 +3359,7 @@ int i915_gem_object_set_cache_level(struct drm_i915_gem_object *obj,if (obj->has_global_gtt_mapping)i915_gem_gtt_bind_object (obj, cache_level);if (obj->has_aliasing_ppgtt_mapping) -i915_ppgtt_bind_object (dev_priv->mm.aliasing_ppgtt, +i915_ppgtt_bind_object (dev_priv->gtt.aliasing_ppgtt, obj, cache_level); obj->gtt_space->color = cache_level;@@ -3668,7 +3668,7 @@ i915_gem_object_pin(struct drm_i915_gem_object *obj,if (ret)return ret; -if (!dev_priv->mm.aliasing_ppgtt) +if (!dev_priv->gtt.aliasing_ppgtt)i915_gem_gtt_bind_object (obj, obj->cache_level); }@@ -4191,10 +4191,10 @@ i915_gem_init_hw(struct drm_device *dev)* the do_switch), but before enabling PPGTT. So don't move this. */ ret =i915_gem_context_enable (dev_priv); -if (ret || !dev_priv->mm.aliasing_ppgtt) +if (ret || !dev_priv->gtt.aliasing_ppgtt) goto disable_ctx_out; - ret = dev_priv->mm.aliasing_ppgtt->enable (dev); + ret = dev_priv->gtt.aliasing_ppgtt->enable (dev);if (ret) goto disable_ctx_out;@@ -4236,7 +4236,7 @@ int i915_gem_init(struct drm_device *dev) dev_priv->hw_contexts_disabled = true; ggtt_only: -if (!dev_priv->mm.aliasing_ppgtt) { +if (!dev_priv->gtt.aliasing_ppgtt) {if (HAS_HW_CONTEXTS (dev))DRM_DEBUG_DRIVER ("Context setup failed %d\n" , ret); i915_gem_setup_global_gtt(dev, 0, dev_priv->gtt.mappable_end,drivers/gpu/drm/i915/i915_gem_context.c +2
-2@@ -226,7 +226,7 @@ static int create_default_context(struct drm_i915_private *dev_priv) } dev_priv->ring[RCS ].default_context = ctx; - dev_priv->mm.aliasing_ppgtt = &ctx->ppgtt; + dev_priv->gtt.aliasing_ppgtt = &ctx->ppgtt;DRM_DEBUG_DRIVER ("Default HW context loaded\n" );return 0 ;@@ -300,7 +300,7 @@ void i915_gem_context_fini(struct drm_device *dev)i915_gem_context_unreference (dctx); dev_priv->ring[RCS ].default_context =NULL ; dev_priv->ring[RCS ].last_context =NULL ; - dev_priv->mm.aliasing_ppgtt =NULL ; + dev_priv->gtt.aliasing_ppgtt =NULL ; }int i915_gem_context_enable (struct drm_i915_private *dev_priv)drivers/gpu/drm/i915/i915_gem_execbuffer.c +2
-2@@ -429,8 +429,8 @@ i915_gem_execbuffer_reserve_object(struct drm_i915_gem_object *obj, }/* Ensure ppgtt mapping exists if needed */ -if (dev_priv->mm.aliasing_ppgtt && !obj->has_aliasing_ppgtt_mapping) { -i915_ppgtt_bind_object (dev_priv->mm.aliasing_ppgtt, +if (dev_priv->gtt.aliasing_ppgtt && !obj->has_aliasing_ppgtt_mapping) { +i915_ppgtt_bind_object (dev_priv->gtt.aliasing_ppgtt, obj, obj->cache_level); obj->has_aliasing_ppgtt_mapping =1 ;drivers/gpu/drm/i915/i915_gem_gtt.c +3
-3@@ -127,7 +127,7 @@ static int gen6_ppgtt_enable(struct drm_device *dev)drm_i915_private_t *dev_priv = dev->dev_private;uint32_t pd_offset;struct intel_ring_buffer *ring; -struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; +struct i915_hw_ppgtt *ppgtt = dev_priv->gtt.aliasing_ppgtt;int i;BUG_ON (ppgtt->pd_offset &0x3f );@@ -445,8 +445,8 @@ void i915_gem_restore_gtt_mappings(struct drm_device *dev) i915_gtt_vm->start /PAGE_SIZE , i915_gtt_vm->total / PAGE_SIZE); -if (dev_priv->mm.aliasing_ppgtt) -gen6_write_pdes (dev_priv->mm.aliasing_ppgtt); +if (dev_priv->gtt.aliasing_ppgtt) +gen6_write_pdes (dev_priv->gtt.aliasing_ppgtt);list_for_each_entry (obj, &dev_priv->mm.bound_list, global_list) {i915_gem_clflush_object (obj);Signature · 6 lines
1.8.3.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 24/66] drm/i915: Move aliasing_ppgtt
Quoted 10 lines · Daniel Vetter
Quoted 3 lines · Ben Widawsky
for file in
ls drivers/gpu/drm/i915/*.c; dosed -i "s/mm.aliasing/gtt.aliasing/" $file;done
Commit message should explain _why_ we do something. Again I'm asking since I'm unclear about how things fit all together and what the different responsibilities are. I think I understand your design here to make both real ppgtt work and keep aliasing ppgtt going, but I'd like you to explain this in your words ;-)
That's fair.
Quoted 9 lines
One thing which looks a bit peculiar at the end is that struct
i915_hw_ppgttis actually used as the real ppgtt object (since it subclasesi915_addressspace). My original plan was that we'll add a newstruct i915_ppgtt { struct i915_address_space base; struct i915_hw_ppgtt hw_ppgtt; }
Quoted 5 lines
To fit into your design the alising ppgtt pointer in
dev_priv->gttwould then only point at ahw_ppgttstruct, not the full deal with address space and everything else around attached.Cheers, Daniel
I don't think creating a struct i915_ppgtt is necessary or buys much. We can rename i915_hw_ppgtt to i915_ppgtt, and it accomplishes the same thing. Same for the i915_hw_context for that matter. I wanted to do any sort of renaming after the rest of the series.
Can you explain why we'd want to keep the hw_ppgtt, and ppgtt with the track lists etc. distinct?
Quoted 191 lines
Quoted 186 lines
Signed-off-by Ben Widawsky <[email protected]>--- drivers/gpu/drm/i915/i915_debugfs.c | 4 ++-- drivers/gpu/drm/i915/i915_dma.c | 2 +- drivers/gpu/drm/i915/i915_drv.h | 6 +++--- drivers/gpu/drm/i915/i915_gem.c | 12 ++++++------ drivers/gpu/drm/i915/i915_gem_context.c | 4 ++-- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 4 ++-- drivers/gpu/drm/i915/i915_gem_gtt.c | 6 +++--- 7 files changed, 19 insertions(+), 19 deletions(-)drivers/gpu/drm/i915/i915_debugfs.c +2
-2@@ -1816,8 +1816,8 @@ static int i915_ppgtt_info(struct seq_file *m, void *data)seq_printf (m,"PP_DIR_BASE_READ: 0x%08x\n" ,I915_READ (RING_PP_DIR_BASE_READ (ring)));seq_printf (m,"PP_DIR_DCLV: 0x%08x\n" ,I915_READ (RING_PP_DIR_DCLV (ring))); } -if (dev_priv->mm.aliasing_ppgtt) { -struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; +if (dev_priv->gtt.aliasing_ppgtt) { +struct i915_hw_ppgtt *ppgtt = dev_priv->gtt.aliasing_ppgtt;seq_printf (m,"aliasing PPGTT:\n" );seq_printf (m,"pd gtt offset: 0x%08x\n" , ppgtt->pd_offset);drivers/gpu/drm/i915/i915_dma.c +1
-1@@ -977,7 +977,7 @@ static int i915_getparam(struct drm_device *dev, void *data, value =HAS_LLC (dev);break ;case I915_PARAM_HAS_ALIASING_PPGTT : -if (intel_enable_ppgtt (dev) && dev_priv->mm.aliasing_ppgtt) +if (intel_enable_ppgtt (dev) && dev_priv->gtt.aliasing_ppgtt) value =1 ;break ;case I915_PARAM_HAS_WAIT_TIMEOUT :drivers/gpu/drm/i915/i915_drv.h +3
-3@@ -482,6 +482,9 @@ struct i915_gtt {struct io_mapping *mappable;/* Mapping to our CPU mappable region */ phys_addr_t mappable_base;/* PA of our GMADR */ +/** PPGTT used for aliasing the PPGTT with the GTT */ +struct i915_hw_ppgtt *aliasing_ppgtt; +/** "Graphics Stolen Memory" holds the global PTEs */ void __iomem *gsm;@@ -843,9 +846,6 @@ struct i915_gem_mm {*/ struct list_head unbound_list; -/** PPGTT used for aliasing the PPGTT with the GTT */ -struct i915_hw_ppgtt *aliasing_ppgtt; -struct shrinker inactive_shrinker;bool shrinker_no_lock_stealing;drivers/gpu/drm/i915/i915_gem.c +6
-6@@ -2620,7 +2620,7 @@ i915_gem_object_unbind(struct drm_i915_gem_object *obj)if (obj->has_global_gtt_mapping)i915_gem_gtt_unbind_object (obj);if (obj->has_aliasing_ppgtt_mapping) { -i915_ppgtt_unbind_object (dev_priv->mm.aliasing_ppgtt, obj); +i915_ppgtt_unbind_object (dev_priv->gtt.aliasing_ppgtt, obj); obj->has_aliasing_ppgtt_mapping =0 ; }i915_gem_gtt_finish_object (obj);@@ -3359,7 +3359,7 @@ int i915_gem_object_set_cache_level(struct drm_i915_gem_object *obj,if (obj->has_global_gtt_mapping)i915_gem_gtt_bind_object (obj, cache_level);if (obj->has_aliasing_ppgtt_mapping) -i915_ppgtt_bind_object (dev_priv->mm.aliasing_ppgtt, +i915_ppgtt_bind_object (dev_priv->gtt.aliasing_ppgtt, obj, cache_level); obj->gtt_space->color = cache_level;@@ -3668,7 +3668,7 @@ i915_gem_object_pin(struct drm_i915_gem_object *obj,if (ret)return ret; -if (!dev_priv->mm.aliasing_ppgtt) +if (!dev_priv->gtt.aliasing_ppgtt)i915_gem_gtt_bind_object (obj, obj->cache_level); }@@ -4191,10 +4191,10 @@ i915_gem_init_hw(struct drm_device *dev)* the do_switch), but before enabling PPGTT. So don't move this. */ ret =i915_gem_context_enable (dev_priv); -if (ret || !dev_priv->mm.aliasing_ppgtt) +if (ret || !dev_priv->gtt.aliasing_ppgtt) goto disable_ctx_out; - ret = dev_priv->mm.aliasing_ppgtt->enable (dev); + ret = dev_priv->gtt.aliasing_ppgtt->enable (dev);if (ret) goto disable_ctx_out;@@ -4236,7 +4236,7 @@ int i915_gem_init(struct drm_device *dev) dev_priv->hw_contexts_disabled = true; ggtt_only: -if (!dev_priv->mm.aliasing_ppgtt) { +if (!dev_priv->gtt.aliasing_ppgtt) {if (HAS_HW_CONTEXTS (dev))DRM_DEBUG_DRIVER ("Context setup failed %d\n" , ret); i915_gem_setup_global_gtt(dev, 0, dev_priv->gtt.mappable_end,drivers/gpu/drm/i915/i915_gem_context.c +2
-2@@ -226,7 +226,7 @@ static int create_default_context(struct drm_i915_private *dev_priv) } dev_priv->ring[RCS ].default_context = ctx; - dev_priv->mm.aliasing_ppgtt = &ctx->ppgtt; + dev_priv->gtt.aliasing_ppgtt = &ctx->ppgtt;DRM_DEBUG_DRIVER ("Default HW context loaded\n" );return 0 ;@@ -300,7 +300,7 @@ void i915_gem_context_fini(struct drm_device *dev)i915_gem_context_unreference (dctx); dev_priv->ring[RCS ].default_context =NULL ; dev_priv->ring[RCS ].last_context =NULL ; - dev_priv->mm.aliasing_ppgtt =NULL ; + dev_priv->gtt.aliasing_ppgtt =NULL ; }int i915_gem_context_enable (struct drm_i915_private *dev_priv)drivers/gpu/drm/i915/i915_gem_execbuffer.c +2
-2@@ -429,8 +429,8 @@ i915_gem_execbuffer_reserve_object(struct drm_i915_gem_object *obj, }/* Ensure ppgtt mapping exists if needed */ -if (dev_priv->mm.aliasing_ppgtt && !obj->has_aliasing_ppgtt_mapping) { -i915_ppgtt_bind_object (dev_priv->mm.aliasing_ppgtt, +if (dev_priv->gtt.aliasing_ppgtt && !obj->has_aliasing_ppgtt_mapping) { +i915_ppgtt_bind_object (dev_priv->gtt.aliasing_ppgtt, obj, obj->cache_level); obj->has_aliasing_ppgtt_mapping =1 ;drivers/gpu/drm/i915/i915_gem_gtt.c +3
-3@@ -127,7 +127,7 @@ static int gen6_ppgtt_enable(struct drm_device *dev)drm_i915_private_t *dev_priv = dev->dev_private;uint32_t pd_offset;struct intel_ring_buffer *ring; -struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; +struct i915_hw_ppgtt *ppgtt = dev_priv->gtt.aliasing_ppgtt;int i;BUG_ON (ppgtt->pd_offset &0x3f );@@ -445,8 +445,8 @@ void i915_gem_restore_gtt_mappings(struct drm_device *dev) i915_gtt_vm->start /PAGE_SIZE , i915_gtt_vm->total / PAGE_SIZE); -if (dev_priv->mm.aliasing_ppgtt) -gen6_write_pdes (dev_priv->mm.aliasing_ppgtt); +if (dev_priv->gtt.aliasing_ppgtt) +gen6_write_pdes (dev_priv->gtt.aliasing_ppgtt);list_for_each_entry (obj, &dev_priv->mm.bound_list, global_list) {i915_gem_clflush_object (obj);Signature · 6 lines
1.8.3.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfxSignature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
Re: [PATCH 24/66] drm/i915: Move aliasing_ppgtt
Quoted 14 lines · Ben Widawsky
Quoted 8 lines
One thing which looks a bit peculiar at the end is that struct
i915_hw_ppgttis actually used as the real ppgtt object (since it subclasesi915_addressspace). My original plan was that we'll add a newstruct i915_ppgtt { struct i915_address_space base; struct i915_hw_ppgtt hw_ppgtt; }Quoted 5 lines
To fit into your design the alising ppgtt pointer in
dev_priv->gttwould then only point at ahw_ppgttstruct, not the full deal with address space and everything else around attached.Cheers, Daniel
Quoted 7 lines
I don't think creating a struct
i915_ppgttis necessary or buys much. We can renamei915_hw_ppgtttoi915_ppgtt, and it accomplishes the same thing. Same for thei915_hw_contextfor that matter. I wanted to do any sort of renaming after the rest of the series.Can you explain why we'd want to keep the
hw_ppgtt, and ppgtt with the track lists etc. distinct?
The difference is that for the aliasing ppgtt we don't really need a address space object to track object offsets since those are identical to the ggtt offsets. Hence we only need the hw part of the ppgtt, i.e. writing/clearing ptes.
Full ppgtt otoh need the address space of course.
The above structure layout would allow that. It means that aliasing ppgtt will stick out a bit like a sore thumb but imo that's ok since it really _is_ a bit an odd thing. I've just noticed that you've partially disabled the has_aliasing_ppgtt_mapping logic in your branch, so I wonder a bit how aliasing ppgtt works there. But I guess the simplest approach would be to simply keep that stuff around as-is, with a few twists to wrestle it into the new world: Batches would be executed as if they'd run in the global gtt (i.e. for eviction/binding purposes) with the simple difference that we'd check whether the global gtt has the aliasing_ppgtt pointer set up, and then write the ptes there. Note that unconditionally writing both ppgtt and global gtt ptes isn't too good, since in some virtualized enviroments tracking those separately is a pretty substantial win apparently. -Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 24/66] drm/i915: Move aliasing_ppgtt
Quoted 20 lines · Daniel Vetter
Quoted 19 lines · Ben Widawsky
Quoted 8 lines
One thing which looks a bit peculiar at the end is that struct
i915_hw_ppgttis actually used as the real ppgtt object (since it subclasesi915_addressspace). My original plan was that we'll add a newstruct i915_ppgtt { struct i915_address_space base; struct i915_hw_ppgtt hw_ppgtt; }Quoted 5 lines
To fit into your design the alising ppgtt pointer in
dev_priv->gttwould then only point at ahw_ppgttstruct, not the full deal with address space and everything else around attached.Cheers, Daniel
I don't think creating a struct
i915_ppgttis necessary or buys much. We can renamei915_hw_ppgtttoi915_ppgtt, and it accomplishes the same thing. Same for thei915_hw_contextfor that matter. I wanted to do any sort of renaming after the rest of the series.
Quoted 7 lines
Quoted 2 lines
Can you explain why we'd want to keep the
hw_ppgtt, and ppgtt with the track lists etc. distinct?The difference is that for the aliasing ppgtt we don't really need a address space object to track object offsets since those are identical to the ggtt offsets. Hence we only need the hw part of the ppgtt, i.e. writing/clearing ptes.
I actually did attempt to make the aliasing ppgtt a real address space (so the ggtt was the special case instead of vice versa). It proved too much work, so I dropped it.
Quoted 8 lines
Full ppgtt otoh need the address space of course.
The above structure layout would allow that. It means that aliasing ppgtt will stick out a bit like a sore thumb but imo that's ok since it really _is_ a bit an odd thing. I've just noticed that you've partially disabled the
has_aliasing_ppgtt_mappinglogic in your branch, so I wonder a bit how aliasing ppgtt works there.
It doesn't. The intent was to completely eclipse aliasing PPGTT. If we keep the pin interface (as discussed in the other thread), I am not certain that is still true, though I personally have no issue forcing a performance penalty on users that wish to use that interface.
Quoted 10 lines
But I guess
the simplest approach would be to simply keep that stuff around as-is, with a few twists to wrestle it into the new world: Batches would be executed as if they'd run in the global gtt (i.e. for eviction/binding purposes) with the simple difference that we'd check whether the global gtt has thealiasing_ppgttpointer set up, and then write the ptes there. Note that unconditionally writing both ppgtt and global gtt ptes isn't too good, since in some virtualized enviroments tracking those separately is a pretty substantial win apparently. -Daniel
I'm still not convinced that having distinct i915_ppgtt and i915_hw_ppgtt buys us anything.
Quoted 4 lines
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
Re: [PATCH 24/66] drm/i915: Move aliasing_ppgtt
Quoted 8 lines · Ben Widawsky
Quoted 7 lines
Full ppgtt otoh need the address space of course.
The above structure layout would allow that. It means that aliasing ppgtt will stick out a bit like a sore thumb but imo that's ok since it really _is_ a bit an odd thing. I've just noticed that you've partially disabled the
has_aliasing_ppgtt_mappinglogic in your branch, so I wonder a bit how aliasing ppgtt works there.
Quoted 4 lines
It doesn't. The intent was to completely eclipse aliasing PPGTT. If we keep the pin interface (as discussed in the other thread), I am not certain that is still true, though I personally have no issue forcing a performance penalty on users that wish to use that interface.
Ah, that explains my confusion ;-)
I guess we simply have to be careful to keep this working properly when merging the patches. Like I've said I'm pretty sure that we can keep all the major concepts unchanged and just bolt aliasing ppgtt onto the side like it's done today.
For i915_ppgtt vs. i915_hw_ppgtt I think we can revisite that we the in-depth review of the relevant patches is on the table. -Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
PATCH 25/66 drm/i915: Put the mm in the parent address space
In reply to Ben WidawskyEvery address space should support object allocation. It therefore makes sense to have the allocator be part of the "superclass" which GGTT and PPGTT will derive.
Since our maximum address space size is only 2GB we're not yet able to avoid doing allocation/eviction; but we'd hope one day this becomes almost irrelvant.
--- drivers/gpu/drm/i915/i915_dma.c | 4 ++-- drivers/gpu/drm/i915/i915_drv.h | 3 +-- drivers/gpu/drm/i915/i915_gem.c | 4 ++-- drivers/gpu/drm/i915/i915_gem_evict.c | 10 +++++----- drivers/gpu/drm/i915/i915_gem_gtt.c | 18 +++++++++++------- drivers/gpu/drm/i915/i915_gem_stolen.c | 4 ++-- 6 files changed, 23 insertions(+), 20 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +2 -2
@@ -1363,7 +1363,7 @@ cleanup_gem:i915_gem_cleanup_ringbuffer (dev);i915_gem_context_fini (dev);mutex_unlock (&dev->struct_mutex); -drm_mm_takedown (&dev_priv->mm.gtt_space); +drm_mm_takedown (&i915_gtt_vm->mm); cleanup_irq:drm_irq_uninstall (dev); cleanup_gem_stolen:
@@ -1753,7 +1753,7 @@ int i915_driver_unload(struct drm_device *dev)i915_free_hws (dev); } -drm_mm_takedown (&dev_priv->mm.gtt_space); +drm_mm_takedown (&i915_gtt_vm->mm);if (dev_priv->regs !=NULL )pci_iounmap (dev->pdev, dev_priv->regs);
drivers/gpu/drm/i915/i915_drv.h +1 -2
@@ -443,6 +443,7 @@ enum i915_cache_level {typedef uint32_t gen6_gtt_pte_t ;struct i915_address_space { +struct drm_mm mm;struct drm_device *dev;unsigned long start;/* Start offset always 0 for dri2 */ size_t total;/* size addr space maps (ex. 2GB for ggtt) */
@@ -834,8 +835,6 @@ struct intel_l3_parity { };struct i915_gem_mm { -/** Memory allocator for GTT */ -struct drm_mm gtt_space;/** List of all objects in gtt_space. Used to restore gtt * mappings on resume */ struct list_head bound_list;
drivers/gpu/drm/i915/i915_gem.c +2 -2
@@ -3131,7 +3131,7 @@ i915_gem_object_bind_to_gtt(struct drm_i915_gem_object *obj, } search_free: - ret = drm_mm_insert_node_in_range_generic(&dev_priv->mm.gtt_space, node, + ret = drm_mm_insert_node_in_range_generic(&i915_gtt_vm->mm, node, size, alignment, obj->cache_level, 0, gtt_max, DRM_MM_CREATE_DEFAULT,
@@ -4229,7 +4229,7 @@ int i915_gem_init(struct drm_device *dev) i915_gtt_vm->total, 0);i915_gem_context_init (dev);if (dev_priv->hw_contexts_disabled) { -drm_mm_takedown (&dev_priv->mm.gtt_space); +drm_mm_takedown (&i915_gtt_vm->mm); goto ggtt_only; } }else
drivers/gpu/drm/i915/i915_gem_evict.c +5 -5
@@ -78,12 +78,12 @@ i915_gem_evict_something(struct drm_device *dev, int min_size,INIT_LIST_HEAD (&unwind_list);if (mappable) -drm_mm_init_scan_with_range (&dev_priv->mm.gtt_space, - min_size, alignment, cache_level, -0 , dev_priv->gtt.mappable_end); +drm_mm_init_scan_with_range (&i915_gtt_vm->mm, min_size, + alignment, cache_level,0 , + dev_priv->gtt.mappable_end);else -drm_mm_init_scan (&dev_priv->mm.gtt_space, - min_size, alignment, cache_level); +drm_mm_init_scan (&i915_gtt_vm->mm, min_size, alignment, + cache_level);/* First see if there is a large enough contiguous idle region... */ list_for_each_entry (obj, &dev_priv->mm.inactive_list, mm_list) {
drivers/gpu/drm/i915/i915_gem_gtt.c +11 -7
@@ -249,6 +249,7 @@ static void gen6_ppgtt_cleanup(struct i915_hw_ppgtt *ppgtt)int i;drm_mm_remove_node (&ppgtt->node); +drm_mm_takedown (&ppgtt->base.mm);if (ppgtt->pt_dma_addr) {for (i =0 ; i < ppgtt->num_pd_entries; i++)
@@ -277,8 +278,8 @@ static int gen6_ppgtt_init(struct i915_hw_ppgtt *ppgtt)* multiplied by page size. We allocate at the top of the GTT to avoid * fragmentation. */ -BUG_ON (!drm_mm_initialized (&dev_priv->mm.gtt_space)); - ret = drm_mm_insert_node_in_range_generic(&dev_priv->mm.gtt_space, +BUG_ON (!drm_mm_initialized (&i915_gtt_vm->mm)); + ret = drm_mm_insert_node_in_range_generic(&i915_gtt_vm->mm, &ppgtt->node, GEN6_PD_SIZE, GEN6_PD_ALIGN, 0, dev_priv->gtt.mappable_end,
@@ -377,6 +378,10 @@ int i915_gem_ppgtt_init(struct drm_device *dev, struct i915_hw_ppgtt *ppgtt)else BUG (); +if (!ret) +drm_mm_init (&ppgtt->base.mm, ppgtt->base.start, + ppgtt->base.total); +return ret; }
@@ -668,10 +673,9 @@ void i915_gem_setup_global_gtt(struct drm_device *dev,if (WARN_ON (guard_size & ~PAGE_MASK )) guard_size =round_up (guard_size,PAGE_SIZE ); -/* Subtract the guard page ... */ -drm_mm_init (&dev_priv->mm.gtt_space, start, end - start - guard_size); +drm_mm_init (&i915_gtt_vm->mm, start, end - start - guard_size);if (!HAS_LLC (dev)) - dev_priv->mm.gtt_space.color_adjust = i915_gtt_color_adjust; + i915_gtt_vm->mm.color_adjust = i915_gtt_color_adjust;/* Mark any preallocated objects as occupied */ list_for_each_entry (obj, &dev_priv->mm.bound_list, global_list) {
@@ -679,7 +683,7 @@ void i915_gem_setup_global_gtt(struct drm_device *dev, obj->gtt_offset, obj->base.size);BUG_ON (obj->gtt_space !=I915_GTT_RESERVED ); - obj->gtt_space =drm_mm_create_block (&dev_priv->mm.gtt_space, + obj->gtt_space =drm_mm_create_block (&i915_gtt_vm->mm, obj->gtt_offset, obj->base.size, false);
@@ -690,7 +694,7 @@ void i915_gem_setup_global_gtt(struct drm_device *dev, i915_gtt_vm->total = end - start;/* Clear any non-preallocated blocks */ -drm_mm_for_each_hole (entry, &dev_priv->mm.gtt_space, +drm_mm_for_each_hole (entry, &i915_gtt_vm->mm, hole_start, hole_end) {DRM_DEBUG_KMS ("clearing unused GTT space: [%lx, %lx]\n" , hole_start, hole_end);
drivers/gpu/drm/i915/i915_gem_stolen.c +2 -2
@@ -368,8 +368,8 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,* setting up the GTT space. The actual reservation will occur * later. */ -if (drm_mm_initialized (&dev_priv->mm.gtt_space)) { - obj->gtt_space =drm_mm_create_block (&dev_priv->mm.gtt_space, +if (drm_mm_initialized (&i915_gtt_vm->mm)) { + obj->gtt_space =drm_mm_create_block (&i915_gtt_vm->mm, gtt_offset, size, false);if (obj->gtt_space ==NULL ) {
Signature · 1 line
1.8.3.1
PATCH 26/66 drm/i915: Move active/inactive lists to new mm
In reply to Ben Widawskyfor file in ls drivers/gpu/drm/i915/*.c ; do sed -i "s/dev_priv->mm.inactive_list/i915_gtt_mm-\>inactive_list/" $file; done for file in ls drivers/gpu/drm/i915/*.c ; do sed -i "s/dev_priv->mm.active_list/i915_gtt_mm-\>active_list/" $file; done
I've also opted to move the comments out of line a bit so one can get a better picture of what the various lists do.
v2: Leave the bound list as a global one. (Chris, indirectly)
--- drivers/gpu/drm/i915/i915_debugfs.c | 11 ++++---- drivers/gpu/drm/i915/i915_drv.h | 49 ++++++++++++++-------------------- drivers/gpu/drm/i915/i915_gem.c | 24 +++++++---------- drivers/gpu/drm/i915/i915_gem_debug.c | 2 +- drivers/gpu/drm/i915/i915_gem_evict.c | 10 +++---- drivers/gpu/drm/i915/i915_gem_stolen.c | 2 +- drivers/gpu/drm/i915/i915_irq.c | 6 ++--- 7 files changed, 46 insertions(+), 58 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +6 -5
@@ -158,11 +158,11 @@ static int i915_gem_object_list_info(struct seq_file *m, void *data)switch (list) {case ACTIVE_LIST :seq_printf (m,"Active:\n" ); - head = &dev_priv->mm.active_list; + head = &i915_gtt_vm->active_list;break ;case INACTIVE_LIST :seq_printf (m,"Inactive:\n" ); - head = &dev_priv->mm.inactive_list; + head = &i915_gtt_vm->inactive_list;break ;default :mutex_unlock (&dev->struct_mutex);
@@ -247,12 +247,12 @@ static int i915_gem_object_info(struct seq_file *m, void* data) count, mappable_count, size, mappable_size); size = count = mappable_size = mappable_count =0 ; -count_objects (&dev_priv->mm.active_list, mm_list); +count_objects (&i915_gtt_vm->active_list, mm_list);seq_printf (m," %u [%u] active objects, %zu [%zu] bytes\n" , count, mappable_count, size, mappable_size); size = count = mappable_size = mappable_count =0 ; -count_objects (&dev_priv->mm.inactive_list, mm_list); +count_objects (&i915_gtt_vm->inactive_list, mm_list);seq_printf (m," %u [%u] inactive objects, %zu [%zu] bytes\n" , count, mappable_count, size, mappable_size);
@@ -1977,7 +1977,8 @@ i915_drop_caches_set(void *data, u64 val)i915_gem_retire_requests (dev);if (val &DROP_BOUND ) { -list_for_each_entry_safe (obj, next, &dev_priv->mm.inactive_list, mm_list) +list_for_each_entry_safe (obj, next, &i915_gtt_vm->inactive_list, + mm_list)if (obj->pin_count ==0 ) { ret =i915_gem_object_unbind (obj);if (ret)
drivers/gpu/drm/i915/i915_drv.h +20 -29
68 lines not on this page · raw message
drivers/gpu/drm/i915/i915_gem.c +10 -14
@@ -1706,7 +1706,7 @@ __i915_gem_shrink(struct drm_i915_private *dev_priv, long target, }list_for_each_entry_safe (obj, next, - &dev_priv->mm.inactive_list, + &i915_gtt_vm->inactive_list, mm_list) { if ((i915_gem_object_is_purgeable(obj) || !purgeable_only) && i915_gem_object_unbind(obj) == 0 &&
@@ -1881,7 +1881,7 @@ i915_gem_object_move_to_active(struct drm_i915_gem_object *obj, }/* Move from whatever list we were on to the tail of execution. */ -list_move_tail (&obj->mm_list, &dev_priv->mm.active_list); +list_move_tail (&obj->mm_list, &i915_gtt_vm->active_list);list_move_tail (&obj->ring_list, &ring->active_list); obj->last_read_seqno = seqno;
@@ -1909,7 +1909,7 @@ i915_gem_object_move_to_inactive(struct drm_i915_gem_object *obj)BUG_ON (obj->base.write_domain & ~I915_GEM_GPU_DOMAINS );BUG_ON (!obj->active); -list_move_tail (&obj->mm_list, &dev_priv->mm.inactive_list); +list_move_tail (&obj->mm_list, &i915_gtt_vm->inactive_list);list_del_init (&obj->ring_list); obj->ring =NULL ;
@@ -2279,12 +2279,8 @@ bool i915_gem_reset(struct drm_device *dev)/* Move everything out of the GPU domains to ensure we do any * necessary invalidation upon reuse. */ -list_for_each_entry (obj, - &dev_priv->mm.inactive_list, - mm_list) - { +list_for_each_entry (obj, &i915_gtt_vm->inactive_list, mm_list) obj->base.read_domains &= ~I915_GEM_GPU_DOMAINS ; - }/* The fence registers are invalidated so clear them out */ i915_gem_restore_fences (dev);
@@ -3162,7 +3158,7 @@ search_free: }list_move_tail (&obj->global_list, &dev_priv->mm.bound_list); -list_add_tail (&obj->mm_list, &dev_priv->mm.inactive_list); +list_add_tail (&obj->mm_list, &i915_gtt_vm->inactive_list); obj->gtt_space = node; obj->gtt_offset = node->start;
@@ -3313,7 +3309,7 @@ i915_gem_object_set_to_gtt_domain(struct drm_i915_gem_object *obj, bool write)/* And bump the LRU for this access */ if (i915_gem_object_is_inactive (obj)) -list_move_tail (&obj->mm_list, &dev_priv->mm.inactive_list); +list_move_tail (&obj->mm_list, &i915_gtt_vm->inactive_list);return 0 ; }
@@ -4291,7 +4287,7 @@ i915_gem_entervt_ioctl(struct drm_device *dev, void *data,return ret; } -BUG_ON (!list_empty (&dev_priv->mm.active_list)); +BUG_ON (!list_empty (&i915_gtt_vm->active_list));mutex_unlock (&dev->struct_mutex); ret =drm_irq_install (dev);
@@ -4352,8 +4348,8 @@ i915_gem_load(struct drm_device *dev)SLAB_HWCACHE_ALIGN , NULL); -INIT_LIST_HEAD (&dev_priv->mm.active_list); -INIT_LIST_HEAD (&dev_priv->mm.inactive_list); +INIT_LIST_HEAD (&i915_gtt_vm->active_list); +INIT_LIST_HEAD (&i915_gtt_vm->inactive_list);INIT_LIST_HEAD (&dev_priv->mm.unbound_list);INIT_LIST_HEAD (&dev_priv->mm.bound_list);INIT_LIST_HEAD (&dev_priv->mm.fence_list);
@@ -4652,7 +4648,7 @@ i915_gem_inactive_shrink(struct shrinker *shrinker, struct shrink_control *sc)list_for_each_entry (obj, &dev_priv->mm.unbound_list, global_list)if (obj->pages_pin_count ==0 ) cnt += obj->base.size >>PAGE_SHIFT ; -list_for_each_entry (obj, &dev_priv->mm.inactive_list, global_list) +list_for_each_entry (obj, &i915_gtt_vm->inactive_list, global_list)if (obj->pin_count ==0 && obj->pages_pin_count ==0 ) cnt += obj->base.size >>PAGE_SHIFT ;
drivers/gpu/drm/i915/i915_gem_debug.c +1 -1
@@ -97,7 +97,7 @@ i915_verify_lists(struct drm_device *dev) } } -list_for_each_entry (obj, &dev_priv->mm.inactive_list, list) { +list_for_each_entry (obj, &i915_gtt_vm->inactive_list, list) {if (obj->base.dev != dev || !atomic_read (&obj->base.refcount.refcount)) {DRM_ERROR ("freed inactive %p\n" , obj);
drivers/gpu/drm/i915/i915_gem_evict.c +5 -5
@@ -86,7 +86,7 @@ i915_gem_evict_something(struct drm_device *dev, int min_size, cache_level);/* First see if there is a large enough contiguous idle region... */ -list_for_each_entry (obj, &dev_priv->mm.inactive_list, mm_list) { +list_for_each_entry (obj, &i915_gtt_vm->inactive_list, mm_list) {if (mark_free (obj, &unwind_list)) goto found; }
@@ -95,7 +95,7 @@ i915_gem_evict_something(struct drm_device *dev, int min_size, goto none;/* Now merge in the soon-to-be-expired objects... */ -list_for_each_entry (obj, &dev_priv->mm.active_list, mm_list) { +list_for_each_entry (obj, &i915_gtt_vm->active_list, mm_list) {if (mark_free (obj, &unwind_list)) goto found; }
@@ -158,8 +158,8 @@ i915_gem_evict_everything(struct drm_device *dev)bool lists_empty;int ret; - lists_empty = (list_empty (&dev_priv->mm.inactive_list) && -list_empty (&dev_priv->mm.active_list)); + lists_empty = (list_empty (&i915_gtt_vm->inactive_list) && +list_empty (&i915_gtt_vm->active_list));if (lists_empty)return -ENOSPC ;
@@ -177,7 +177,7 @@ i915_gem_evict_everything(struct drm_device *dev)/* Having flushed everything, unbind() should never raise an error */ list_for_each_entry_safe (obj, next, - &dev_priv->mm.inactive_list, mm_list) + &i915_gtt_vm->inactive_list, mm_list)if (obj->pin_count ==0 )WARN_ON (i915_gem_object_unbind (obj));
drivers/gpu/drm/i915/i915_gem_stolen.c +1 -1
@@ -384,7 +384,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev, obj->has_global_gtt_mapping =1 ;list_add_tail (&obj->global_list, &dev_priv->mm.bound_list); -list_add_tail (&obj->mm_list, &dev_priv->mm.inactive_list); +list_add_tail (&obj->mm_list, &i915_gtt_vm->inactive_list);return obj; }
drivers/gpu/drm/i915/i915_irq.c +3 -3
@@ -1722,7 +1722,7 @@ i915_error_first_batchbuffer(struct drm_i915_private *dev_priv, } seqno = ring->get_seqno (ring, false); -list_for_each_entry (obj, &dev_priv->mm.active_list, mm_list) { +list_for_each_entry (obj, &i915_gtt_vm->active_list, mm_list) {if (obj->ring != ring)continue ;
@@ -1857,7 +1857,7 @@ static void i915_gem_capture_buffers(struct drm_i915_private *dev_priv,int i; i =0 ; -list_for_each_entry (obj, &dev_priv->mm.active_list, mm_list) +list_for_each_entry (obj, &i915_gtt_vm->active_list, mm_list) i++; error->active_bo_count = i;list_for_each_entry (obj, &dev_priv->mm.bound_list, global_list)
@@ -1877,7 +1877,7 @@ static void i915_gem_capture_buffers(struct drm_i915_private *dev_priv, error->active_bo_count =capture_active_bo (error->active_bo, error->active_bo_count, - &dev_priv->mm.active_list); + &i915_gtt_vm->active_list);if (error->pinned_bo) error->pinned_bo_count =
Signature · 1 line
1.8.3.1
Re: [PATCH 26/66] drm/i915: Move active/inactive lists to new mm
Quoted 5 lines · Ben Widawsky
for file in
ls drivers/gpu/drm/i915/*.c; do sed -i "s/dev_priv->mm.inactive_list/i915_gtt_mm-\>inactive_list/" $file; done for file inls drivers/gpu/drm/i915/*.c; do sed -i "s/dev_priv->mm.active_list/i915_gtt_mm-\>active_list/" $file; doneI've also opted to move the comments out of line a bit so one can get a better picture of what the various lists do.
Bikeshed: That makes you now inconsistent with all the other in-detail structure memeber comments we have. And I don't see how it looks better, so I'd vote to keep things as-is with per-member comments.
Quoted 4 lines
v2: Leave the bound list as a global one. (Chris, indirectly)
CC Chris Wilson <[email protected]>Signed-off-by Ben Widawsky <[email protected]>
The real comment though is on the commit message, it fails to explain why we want to move the active/inactive lists from mm/obj to the address space/vma pair. I think I understand, but this should be explained more in-depth.
I think in the first commit which starts moving those lists and execution tracking state you should also mention why some of the state (bound/unbound lists e.g.) are not moved.
Cheers, Daniel
Quoted 325 lines
--- drivers/gpu/drm/i915/i915_debugfs.c | 11 ++++---- drivers/gpu/drm/i915/i915_drv.h | 49 ++++++++++++++-------------------- drivers/gpu/drm/i915/i915_gem.c | 24 +++++++---------- drivers/gpu/drm/i915/i915_gem_debug.c | 2 +- drivers/gpu/drm/i915/i915_gem_evict.c | 10 +++---- drivers/gpu/drm/i915/i915_gem_stolen.c | 2 +- drivers/gpu/drm/i915/i915_irq.c | 6 ++--- 7 files changed, 46 insertions(+), 58 deletions(-)drivers/gpu/drm/i915/i915_debugfs.c +6
-5@@ -158,11 +158,11 @@ static int i915_gem_object_list_info(struct seq_file *m, void *data)switch (list) {case ACTIVE_LIST :seq_printf (m,"Active:\n" ); - head = &dev_priv->mm.active_list; + head = &i915_gtt_vm->active_list;break ;case INACTIVE_LIST :seq_printf (m,"Inactive:\n" ); - head = &dev_priv->mm.inactive_list; + head = &i915_gtt_vm->inactive_list;break ;default :mutex_unlock (&dev->struct_mutex);@@ -247,12 +247,12 @@ static int i915_gem_object_info(struct seq_file *m, void* data) count, mappable_count, size, mappable_size); size = count = mappable_size = mappable_count =0 ; -count_objects (&dev_priv->mm.active_list, mm_list); +count_objects (&i915_gtt_vm->active_list, mm_list);seq_printf (m," %u [%u] active objects, %zu [%zu] bytes\n" , count, mappable_count, size, mappable_size); size = count = mappable_size = mappable_count =0 ; -count_objects (&dev_priv->mm.inactive_list, mm_list); +count_objects (&i915_gtt_vm->inactive_list, mm_list);seq_printf (m," %u [%u] inactive objects, %zu [%zu] bytes\n" , count, mappable_count, size, mappable_size);@@ -1977,7 +1977,8 @@ i915_drop_caches_set(void *data, u64 val)i915_gem_retire_requests (dev);if (val &DROP_BOUND ) { -list_for_each_entry_safe (obj, next, &dev_priv->mm.inactive_list, mm_list) +list_for_each_entry_safe (obj, next, &i915_gtt_vm->inactive_list, + mm_list)if (obj->pin_count ==0 ) { ret =i915_gem_object_unbind (obj);if (ret)drivers/gpu/drm/i915/i915_drv.h +20
-29@@ -448,6 +448,22 @@ struct i915_address_space {unsigned long start;/* Start offset always 0 for dri2 */ size_t total;/* size addr space maps (ex. 2GB for ggtt) */ +/* We use many types of lists for object tracking: +* active_list: List of objects currently involved in rendering. +* Includes buffers having the contents of their GPU caches flushed, not +* necessarily primitives. last_rendering_seqno represents when the +* rendering involved will be completed. A reference is held on the buffer +* while on this list. +* inactive_list: LRU list of objects which are not in the ringbuffer +* objects are ready to unbind but are still mapped. +* last_rendering_seqno is 0 while an object is in this list. +* A reference is not held on the buffer while on this list, +* as merely being GTT-bound shouldn't prevent its being +* freed, and we'll pull it off the list in the free path. +*/ +struct list_head active_list; +struct list_head inactive_list; +struct {dma_addr_t addr;struct page *page;@@ -835,42 +851,17 @@ struct intel_l3_parity { };struct i915_gem_mm { -/** List of all objects in gtt_space. Used to restore gtt -* mappings on resume */ -struct list_head bound_list;/** -* List of objects which are not bound to the GTT (thus -* are idle and not used by the GPU) but still have -* (presumably uncached) pages still attached. +* Lists of objects which are [not] bound to a VM. Unbound objects are +* idle are idle but still have (presumably uncached) pages still +* attached. */ +struct list_head bound_list;struct list_head unbound_list;struct shrinker inactive_shrinker;bool shrinker_no_lock_stealing; -/** -* List of objects currently involved in rendering. -* -* Includes buffers having the contents of their GPU caches -* flushed, not necessarily primitives. last_rendering_seqno -* represents when the rendering involved will be completed. -* -* A reference is held on the buffer while on this list. -*/ -struct list_head active_list; - -/** -* LRU list of objects which are not in the ringbuffer and -* are ready to unbind, but are still in the GTT. -* -* last_rendering_seqno is 0 while an object is in this list. -* -* A reference is not held on the buffer while on this list, -* as merely being GTT-bound shouldn't prevent its being -* freed, and we'll pull it off the list in the free path. -*/ -struct list_head inactive_list; -/** LRU list of objects with fence regs on them. */ struct list_head fence_list;drivers/gpu/drm/i915/i915_gem.c +10
-14@@ -1706,7 +1706,7 @@ __i915_gem_shrink(struct drm_i915_private *dev_priv, long target, }list_for_each_entry_safe (obj, next, - &dev_priv->mm.inactive_list, + &i915_gtt_vm->inactive_list, mm_list) { if ((i915_gem_object_is_purgeable(obj) || !purgeable_only) && i915_gem_object_unbind(obj) == 0 &&@@ -1881,7 +1881,7 @@ i915_gem_object_move_to_active(struct drm_i915_gem_object *obj, }/* Move from whatever list we were on to the tail of execution. */ -list_move_tail (&obj->mm_list, &dev_priv->mm.active_list); +list_move_tail (&obj->mm_list, &i915_gtt_vm->active_list);list_move_tail (&obj->ring_list, &ring->active_list); obj->last_read_seqno = seqno;@@ -1909,7 +1909,7 @@ i915_gem_object_move_to_inactive(struct drm_i915_gem_object *obj)BUG_ON (obj->base.write_domain & ~I915_GEM_GPU_DOMAINS );BUG_ON (!obj->active); -list_move_tail (&obj->mm_list, &dev_priv->mm.inactive_list); +list_move_tail (&obj->mm_list, &i915_gtt_vm->inactive_list);list_del_init (&obj->ring_list); obj->ring =NULL ;@@ -2279,12 +2279,8 @@ bool i915_gem_reset(struct drm_device *dev)/* Move everything out of the GPU domains to ensure we do any * necessary invalidation upon reuse. */ -list_for_each_entry (obj, - &dev_priv->mm.inactive_list, - mm_list) - { +list_for_each_entry (obj, &i915_gtt_vm->inactive_list, mm_list) obj->base.read_domains &= ~I915_GEM_GPU_DOMAINS ; - }/* The fence registers are invalidated so clear them out */ i915_gem_restore_fences (dev);@@ -3162,7 +3158,7 @@ search_free: }list_move_tail (&obj->global_list, &dev_priv->mm.bound_list); -list_add_tail (&obj->mm_list, &dev_priv->mm.inactive_list); +list_add_tail (&obj->mm_list, &i915_gtt_vm->inactive_list); obj->gtt_space = node; obj->gtt_offset = node->start;@@ -3313,7 +3309,7 @@ i915_gem_object_set_to_gtt_domain(struct drm_i915_gem_object *obj, bool write)/* And bump the LRU for this access */ if (i915_gem_object_is_inactive (obj)) -list_move_tail (&obj->mm_list, &dev_priv->mm.inactive_list); +list_move_tail (&obj->mm_list, &i915_gtt_vm->inactive_list);return 0 ; }@@ -4291,7 +4287,7 @@ i915_gem_entervt_ioctl(struct drm_device *dev, void *data,return ret; } -BUG_ON (!list_empty (&dev_priv->mm.active_list)); +BUG_ON (!list_empty (&i915_gtt_vm->active_list));mutex_unlock (&dev->struct_mutex); ret =drm_irq_install (dev);@@ -4352,8 +4348,8 @@ i915_gem_load(struct drm_device *dev)SLAB_HWCACHE_ALIGN , NULL); -INIT_LIST_HEAD (&dev_priv->mm.active_list); -INIT_LIST_HEAD (&dev_priv->mm.inactive_list); +INIT_LIST_HEAD (&i915_gtt_vm->active_list); +INIT_LIST_HEAD (&i915_gtt_vm->inactive_list);INIT_LIST_HEAD (&dev_priv->mm.unbound_list);INIT_LIST_HEAD (&dev_priv->mm.bound_list);INIT_LIST_HEAD (&dev_priv->mm.fence_list);@@ -4652,7 +4648,7 @@ i915_gem_inactive_shrink(struct shrinker *shrinker, struct shrink_control *sc)list_for_each_entry (obj, &dev_priv->mm.unbound_list, global_list)if (obj->pages_pin_count ==0 ) cnt += obj->base.size >>PAGE_SHIFT ; -list_for_each_entry (obj, &dev_priv->mm.inactive_list, global_list) +list_for_each_entry (obj, &i915_gtt_vm->inactive_list, global_list)if (obj->pin_count ==0 && obj->pages_pin_count ==0 ) cnt += obj->base.size >>PAGE_SHIFT ;drivers/gpu/drm/i915/i915_gem_debug.c +1
-1@@ -97,7 +97,7 @@ i915_verify_lists(struct drm_device *dev) } } -list_for_each_entry (obj, &dev_priv->mm.inactive_list, list) { +list_for_each_entry (obj, &i915_gtt_vm->inactive_list, list) {if (obj->base.dev != dev || !atomic_read (&obj->base.refcount.refcount)) {DRM_ERROR ("freed inactive %p\n" , obj);drivers/gpu/drm/i915/i915_gem_evict.c +5
-5@@ -86,7 +86,7 @@ i915_gem_evict_something(struct drm_device *dev, int min_size, cache_level);/* First see if there is a large enough contiguous idle region... */ -list_for_each_entry (obj, &dev_priv->mm.inactive_list, mm_list) { +list_for_each_entry (obj, &i915_gtt_vm->inactive_list, mm_list) {if (mark_free (obj, &unwind_list)) goto found; }@@ -95,7 +95,7 @@ i915_gem_evict_something(struct drm_device *dev, int min_size, goto none;/* Now merge in the soon-to-be-expired objects... */ -list_for_each_entry (obj, &dev_priv->mm.active_list, mm_list) { +list_for_each_entry (obj, &i915_gtt_vm->active_list, mm_list) {if (mark_free (obj, &unwind_list)) goto found; }@@ -158,8 +158,8 @@ i915_gem_evict_everything(struct drm_device *dev)bool lists_empty;int ret; - lists_empty = (list_empty (&dev_priv->mm.inactive_list) && -list_empty (&dev_priv->mm.active_list)); + lists_empty = (list_empty (&i915_gtt_vm->inactive_list) && +list_empty (&i915_gtt_vm->active_list));if (lists_empty)return -ENOSPC ;@@ -177,7 +177,7 @@ i915_gem_evict_everything(struct drm_device *dev)/* Having flushed everything, unbind() should never raise an error */ list_for_each_entry_safe (obj, next, - &dev_priv->mm.inactive_list, mm_list) + &i915_gtt_vm->inactive_list, mm_list)if (obj->pin_count ==0 )WARN_ON (i915_gem_object_unbind (obj));drivers/gpu/drm/i915/i915_gem_stolen.c +1
-1@@ -384,7 +384,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev, obj->has_global_gtt_mapping =1 ;list_add_tail (&obj->global_list, &dev_priv->mm.bound_list); -list_add_tail (&obj->mm_list, &dev_priv->mm.inactive_list); +list_add_tail (&obj->mm_list, &i915_gtt_vm->inactive_list);return obj; }drivers/gpu/drm/i915/i915_irq.c +3
-3@@ -1722,7 +1722,7 @@ i915_error_first_batchbuffer(struct drm_i915_private *dev_priv, } seqno = ring->get_seqno (ring, false); -list_for_each_entry (obj, &dev_priv->mm.active_list, mm_list) { +list_for_each_entry (obj, &i915_gtt_vm->active_list, mm_list) {if (obj->ring != ring)continue ;@@ -1857,7 +1857,7 @@ static void i915_gem_capture_buffers(struct drm_i915_private *dev_priv,int i; i =0 ; -list_for_each_entry (obj, &dev_priv->mm.active_list, mm_list) +list_for_each_entry (obj, &i915_gtt_vm->active_list, mm_list) i++; error->active_bo_count = i;list_for_each_entry (obj, &dev_priv->mm.bound_list, global_list)@@ -1877,7 +1877,7 @@ static void i915_gem_capture_buffers(struct drm_i915_private *dev_priv, error->active_bo_count =capture_active_bo (error->active_bo, error->active_bo_count, - &dev_priv->mm.active_list); + &i915_gtt_vm->active_list);if (error->pinned_bo) error->pinned_bo_count =Signature · 6 lines
1.8.3.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 26/66] drm/i915: Move active/inactive lists to new mm
Quoted 11 lines · Daniel Vetter
Quoted 5 lines · Ben Widawsky
for file in
ls drivers/gpu/drm/i915/*.c; do sed -i "s/dev_priv->mm.inactive_list/i915_gtt_mm-\>inactive_list/" $file; done for file inls drivers/gpu/drm/i915/*.c; do sed -i "s/dev_priv->mm.active_list/i915_gtt_mm-\>active_list/" $file; doneI've also opted to move the comments out of line a bit so one can get a better picture of what the various lists do.
Bikeshed: That makes you now inconsistent with all the other in-detail structure memeber comments we have. And I don't see how it looks better, so I'd vote to keep things as-is with per-member comments.
Initially I moved all the comments (in the original mm destruction I did).
Quoted 11 lines
Quoted 5 lines
v2: Leave the bound list as a global one. (Chris, indirectly)
CC Chris Wilson <[email protected]>Signed-off-by Ben Widawsky <[email protected]>The real comment though is on the commit message, it fails to explain why we want to move the active/inactive lists from mm/obj to the address space/vma pair. I think I understand, but this should be explained more in-depth.
Quoted 5 lines
I think in the first commit which starts moving those lists and execution tracking state you should also mention why some of the state (bound/unbound lists e.g.) are not moved.
Cheers, Daniel
Can I use, "because Chris told me to"? :p
Quoted 331 lines
Quoted 326 lines
--- drivers/gpu/drm/i915/i915_debugfs.c | 11 ++++---- drivers/gpu/drm/i915/i915_drv.h | 49 ++++++++++++++-------------------- drivers/gpu/drm/i915/i915_gem.c | 24 +++++++---------- drivers/gpu/drm/i915/i915_gem_debug.c | 2 +- drivers/gpu/drm/i915/i915_gem_evict.c | 10 +++---- drivers/gpu/drm/i915/i915_gem_stolen.c | 2 +- drivers/gpu/drm/i915/i915_irq.c | 6 ++--- 7 files changed, 46 insertions(+), 58 deletions(-)drivers/gpu/drm/i915/i915_debugfs.c +6
-5@@ -158,11 +158,11 @@ static int i915_gem_object_list_info(struct seq_file *m, void *data)switch (list) {case ACTIVE_LIST :seq_printf (m,"Active:\n" ); - head = &dev_priv->mm.active_list; + head = &i915_gtt_vm->active_list;break ;case INACTIVE_LIST :seq_printf (m,"Inactive:\n" ); - head = &dev_priv->mm.inactive_list; + head = &i915_gtt_vm->inactive_list;break ;default :mutex_unlock (&dev->struct_mutex);@@ -247,12 +247,12 @@ static int i915_gem_object_info(struct seq_file *m, void* data) count, mappable_count, size, mappable_size); size = count = mappable_size = mappable_count =0 ; -count_objects (&dev_priv->mm.active_list, mm_list); +count_objects (&i915_gtt_vm->active_list, mm_list);seq_printf (m," %u [%u] active objects, %zu [%zu] bytes\n" , count, mappable_count, size, mappable_size); size = count = mappable_size = mappable_count =0 ; -count_objects (&dev_priv->mm.inactive_list, mm_list); +count_objects (&i915_gtt_vm->inactive_list, mm_list);seq_printf (m," %u [%u] inactive objects, %zu [%zu] bytes\n" , count, mappable_count, size, mappable_size);@@ -1977,7 +1977,8 @@ i915_drop_caches_set(void *data, u64 val)i915_gem_retire_requests (dev);if (val &DROP_BOUND ) { -list_for_each_entry_safe (obj, next, &dev_priv->mm.inactive_list, mm_list) +list_for_each_entry_safe (obj, next, &i915_gtt_vm->inactive_list, + mm_list)if (obj->pin_count ==0 ) { ret =i915_gem_object_unbind (obj);if (ret)drivers/gpu/drm/i915/i915_drv.h +20
-29@@ -448,6 +448,22 @@ struct i915_address_space {unsigned long start;/* Start offset always 0 for dri2 */ size_t total;/* size addr space maps (ex. 2GB for ggtt) */ +/* We use many types of lists for object tracking: +* active_list: List of objects currently involved in rendering. +* Includes buffers having the contents of their GPU caches flushed, not +* necessarily primitives. last_rendering_seqno represents when the +* rendering involved will be completed. A reference is held on the buffer +* while on this list. +* inactive_list: LRU list of objects which are not in the ringbuffer +* objects are ready to unbind but are still mapped. +* last_rendering_seqno is 0 while an object is in this list. +* A reference is not held on the buffer while on this list, +* as merely being GTT-bound shouldn't prevent its being +* freed, and we'll pull it off the list in the free path. +*/ +struct list_head active_list; +struct list_head inactive_list; +struct {dma_addr_t addr;struct page *page;@@ -835,42 +851,17 @@ struct intel_l3_parity { };struct i915_gem_mm { -/** List of all objects in gtt_space. Used to restore gtt -* mappings on resume */ -struct list_head bound_list;/** -* List of objects which are not bound to the GTT (thus -* are idle and not used by the GPU) but still have -* (presumably uncached) pages still attached. +* Lists of objects which are [not] bound to a VM. Unbound objects are +* idle are idle but still have (presumably uncached) pages still +* attached. */ +struct list_head bound_list;struct list_head unbound_list;struct shrinker inactive_shrinker;bool shrinker_no_lock_stealing; -/** -* List of objects currently involved in rendering. -* -* Includes buffers having the contents of their GPU caches -* flushed, not necessarily primitives. last_rendering_seqno -* represents when the rendering involved will be completed. -* -* A reference is held on the buffer while on this list. -*/ -struct list_head active_list; - -/** -* LRU list of objects which are not in the ringbuffer and -* are ready to unbind, but are still in the GTT. -* -* last_rendering_seqno is 0 while an object is in this list. -* -* A reference is not held on the buffer while on this list, -* as merely being GTT-bound shouldn't prevent its being -* freed, and we'll pull it off the list in the free path. -*/ -struct list_head inactive_list; -/** LRU list of objects with fence regs on them. */ struct list_head fence_list;drivers/gpu/drm/i915/i915_gem.c +10
-14@@ -1706,7 +1706,7 @@ __i915_gem_shrink(struct drm_i915_private *dev_priv, long target, }list_for_each_entry_safe (obj, next, - &dev_priv->mm.inactive_list, + &i915_gtt_vm->inactive_list, mm_list) { if ((i915_gem_object_is_purgeable(obj) || !purgeable_only) && i915_gem_object_unbind(obj) == 0 &&@@ -1881,7 +1881,7 @@ i915_gem_object_move_to_active(struct drm_i915_gem_object *obj, }/* Move from whatever list we were on to the tail of execution. */ -list_move_tail (&obj->mm_list, &dev_priv->mm.active_list); +list_move_tail (&obj->mm_list, &i915_gtt_vm->active_list);list_move_tail (&obj->ring_list, &ring->active_list); obj->last_read_seqno = seqno;@@ -1909,7 +1909,7 @@ i915_gem_object_move_to_inactive(struct drm_i915_gem_object *obj)BUG_ON (obj->base.write_domain & ~I915_GEM_GPU_DOMAINS );BUG_ON (!obj->active); -list_move_tail (&obj->mm_list, &dev_priv->mm.inactive_list); +list_move_tail (&obj->mm_list, &i915_gtt_vm->inactive_list);list_del_init (&obj->ring_list); obj->ring =NULL ;@@ -2279,12 +2279,8 @@ bool i915_gem_reset(struct drm_device *dev)/* Move everything out of the GPU domains to ensure we do any * necessary invalidation upon reuse. */ -list_for_each_entry (obj, - &dev_priv->mm.inactive_list, - mm_list) - { +list_for_each_entry (obj, &i915_gtt_vm->inactive_list, mm_list) obj->base.read_domains &= ~I915_GEM_GPU_DOMAINS ; - }/* The fence registers are invalidated so clear them out */ i915_gem_restore_fences (dev);@@ -3162,7 +3158,7 @@ search_free: }list_move_tail (&obj->global_list, &dev_priv->mm.bound_list); -list_add_tail (&obj->mm_list, &dev_priv->mm.inactive_list); +list_add_tail (&obj->mm_list, &i915_gtt_vm->inactive_list); obj->gtt_space = node; obj->gtt_offset = node->start;@@ -3313,7 +3309,7 @@ i915_gem_object_set_to_gtt_domain(struct drm_i915_gem_object *obj, bool write)/* And bump the LRU for this access */ if (i915_gem_object_is_inactive (obj)) -list_move_tail (&obj->mm_list, &dev_priv->mm.inactive_list); +list_move_tail (&obj->mm_list, &i915_gtt_vm->inactive_list);return 0 ; }@@ -4291,7 +4287,7 @@ i915_gem_entervt_ioctl(struct drm_device *dev, void *data,return ret; } -BUG_ON (!list_empty (&dev_priv->mm.active_list)); +BUG_ON (!list_empty (&i915_gtt_vm->active_list));mutex_unlock (&dev->struct_mutex); ret =drm_irq_install (dev);@@ -4352,8 +4348,8 @@ i915_gem_load(struct drm_device *dev)SLAB_HWCACHE_ALIGN , NULL); -INIT_LIST_HEAD (&dev_priv->mm.active_list); -INIT_LIST_HEAD (&dev_priv->mm.inactive_list); +INIT_LIST_HEAD (&i915_gtt_vm->active_list); +INIT_LIST_HEAD (&i915_gtt_vm->inactive_list);INIT_LIST_HEAD (&dev_priv->mm.unbound_list);INIT_LIST_HEAD (&dev_priv->mm.bound_list);INIT_LIST_HEAD (&dev_priv->mm.fence_list);@@ -4652,7 +4648,7 @@ i915_gem_inactive_shrink(struct shrinker *shrinker, struct shrink_control *sc)list_for_each_entry (obj, &dev_priv->mm.unbound_list, global_list)if (obj->pages_pin_count ==0 ) cnt += obj->base.size >>PAGE_SHIFT ; -list_for_each_entry (obj, &dev_priv->mm.inactive_list, global_list) +list_for_each_entry (obj, &i915_gtt_vm->inactive_list, global_list)if (obj->pin_count ==0 && obj->pages_pin_count ==0 ) cnt += obj->base.size >>PAGE_SHIFT ;drivers/gpu/drm/i915/i915_gem_debug.c +1
-1@@ -97,7 +97,7 @@ i915_verify_lists(struct drm_device *dev) } } -list_for_each_entry (obj, &dev_priv->mm.inactive_list, list) { +list_for_each_entry (obj, &i915_gtt_vm->inactive_list, list) {if (obj->base.dev != dev || !atomic_read (&obj->base.refcount.refcount)) {DRM_ERROR ("freed inactive %p\n" , obj);drivers/gpu/drm/i915/i915_gem_evict.c +5
-5@@ -86,7 +86,7 @@ i915_gem_evict_something(struct drm_device *dev, int min_size, cache_level);/* First see if there is a large enough contiguous idle region... */ -list_for_each_entry (obj, &dev_priv->mm.inactive_list, mm_list) { +list_for_each_entry (obj, &i915_gtt_vm->inactive_list, mm_list) {if (mark_free (obj, &unwind_list)) goto found; }@@ -95,7 +95,7 @@ i915_gem_evict_something(struct drm_device *dev, int min_size, goto none;/* Now merge in the soon-to-be-expired objects... */ -list_for_each_entry (obj, &dev_priv->mm.active_list, mm_list) { +list_for_each_entry (obj, &i915_gtt_vm->active_list, mm_list) {if (mark_free (obj, &unwind_list)) goto found; }@@ -158,8 +158,8 @@ i915_gem_evict_everything(struct drm_device *dev)bool lists_empty;int ret; - lists_empty = (list_empty (&dev_priv->mm.inactive_list) && -list_empty (&dev_priv->mm.active_list)); + lists_empty = (list_empty (&i915_gtt_vm->inactive_list) && +list_empty (&i915_gtt_vm->active_list));if (lists_empty)return -ENOSPC ;@@ -177,7 +177,7 @@ i915_gem_evict_everything(struct drm_device *dev)/* Having flushed everything, unbind() should never raise an error */ list_for_each_entry_safe (obj, next, - &dev_priv->mm.inactive_list, mm_list) + &i915_gtt_vm->inactive_list, mm_list)if (obj->pin_count ==0 )WARN_ON (i915_gem_object_unbind (obj));drivers/gpu/drm/i915/i915_gem_stolen.c +1
-1@@ -384,7 +384,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev, obj->has_global_gtt_mapping =1 ;list_add_tail (&obj->global_list, &dev_priv->mm.bound_list); -list_add_tail (&obj->mm_list, &dev_priv->mm.inactive_list); +list_add_tail (&obj->mm_list, &i915_gtt_vm->inactive_list);return obj; }drivers/gpu/drm/i915/i915_irq.c +3
-3@@ -1722,7 +1722,7 @@ i915_error_first_batchbuffer(struct drm_i915_private *dev_priv, } seqno = ring->get_seqno (ring, false); -list_for_each_entry (obj, &dev_priv->mm.active_list, mm_list) { +list_for_each_entry (obj, &i915_gtt_vm->active_list, mm_list) {if (obj->ring != ring)continue ;@@ -1857,7 +1857,7 @@ static void i915_gem_capture_buffers(struct drm_i915_private *dev_priv,int i; i =0 ; -list_for_each_entry (obj, &dev_priv->mm.active_list, mm_list) +list_for_each_entry (obj, &i915_gtt_vm->active_list, mm_list) i++; error->active_bo_count = i;list_for_each_entry (obj, &dev_priv->mm.bound_list, global_list)@@ -1877,7 +1877,7 @@ static void i915_gem_capture_buffers(struct drm_i915_private *dev_priv, error->active_bo_count =capture_active_bo (error->active_bo, error->active_bo_count, - &dev_priv->mm.active_list); + &i915_gtt_vm->active_list);if (error->pinned_bo) error->pinned_bo_count =Signature · 6 lines
1.8.3.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfxSignature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
Re: [PATCH 26/66] drm/i915: Move active/inactive lists to new mm
Quoted 8 lines · Ben Widawsky
Quoted 7 lines · Daniel Vetter
Quoted 5 lines · Ben Widawsky
for file in
ls drivers/gpu/drm/i915/*.c; do sed -i "s/dev_priv->mm.inactive_list/i915_gtt_mm-\>inactive_list/" $file; done for file inls drivers/gpu/drm/i915/*.c; do sed -i "s/dev_priv->mm.active_list/i915_gtt_mm-\>active_list/" $file; doneI've also opted to move the comments out of line a bit so one can get a better picture of what the various lists do.
Quoted 6 lines
Quoted 4 lines
Bikeshed: That makes you now inconsistent with all the other in-detail structure memeber comments we have. And I don't see how it looks better, so I'd vote to keep things as-is with per-member comments.
Initially I moved all the comments (in the original mm destruction I did).
I mean to keep the per-struct-member comments right next to each individual declaration.
Quoted 10 lines
Quoted 10 lines
Quoted 4 lines
v2: Leave the bound list as a global one. (Chris, indirectly)
CC Chris Wilson <[email protected]>Signed-off-by Ben Widawsky <[email protected]>The real comment though is on the commit message, it fails to explain why we want to move the active/inactive lists from mm/obj to the address space/vma pair. I think I understand, but this should be explained more in-depth.
Quoted 7 lines
Quoted 5 lines
I think in the first commit which starts moving those lists and execution tracking state you should also mention why some of the state (bound/unbound lists e.g.) are not moved.
Cheers, Daniel
Can I use, "because Chris told me to"? :p
I think some high-level explanation should be doable ;-) E.g. when moving the lists around explain that the active/inactive stuff is used by eviction when we run out of address space, so needs to be per-vma and per-address space. Bound/unbound otoh is used by the shrinker which only cares about the amount of memory used and not one bit about in which address space this memory is all used in. Of course to actual kick out an object we need to unbind it from every address space, but for that we have the per-object list of vmas.
-Daniel
Quoted 335 lines
Quoted 332 lines
Quoted 327 lines
--- drivers/gpu/drm/i915/i915_debugfs.c | 11 ++++---- drivers/gpu/drm/i915/i915_drv.h | 49 ++++++++++++++-------------------- drivers/gpu/drm/i915/i915_gem.c | 24 +++++++---------- drivers/gpu/drm/i915/i915_gem_debug.c | 2 +- drivers/gpu/drm/i915/i915_gem_evict.c | 10 +++---- drivers/gpu/drm/i915/i915_gem_stolen.c | 2 +- drivers/gpu/drm/i915/i915_irq.c | 6 ++--- 7 files changed, 46 insertions(+), 58 deletions(-)drivers/gpu/drm/i915/i915_debugfs.c +6
-5@@ -158,11 +158,11 @@ static int i915_gem_object_list_info(struct seq_file *m, void *data)switch (list) {case ACTIVE_LIST :seq_printf (m,"Active:\n" ); - head = &dev_priv->mm.active_list; + head = &i915_gtt_vm->active_list;break ;case INACTIVE_LIST :seq_printf (m,"Inactive:\n" ); - head = &dev_priv->mm.inactive_list; + head = &i915_gtt_vm->inactive_list;break ;default :mutex_unlock (&dev->struct_mutex);@@ -247,12 +247,12 @@ static int i915_gem_object_info(struct seq_file *m, void* data) count, mappable_count, size, mappable_size); size = count = mappable_size = mappable_count =0 ; -count_objects (&dev_priv->mm.active_list, mm_list); +count_objects (&i915_gtt_vm->active_list, mm_list);seq_printf (m," %u [%u] active objects, %zu [%zu] bytes\n" , count, mappable_count, size, mappable_size); size = count = mappable_size = mappable_count =0 ; -count_objects (&dev_priv->mm.inactive_list, mm_list); +count_objects (&i915_gtt_vm->inactive_list, mm_list);seq_printf (m," %u [%u] inactive objects, %zu [%zu] bytes\n" , count, mappable_count, size, mappable_size);@@ -1977,7 +1977,8 @@ i915_drop_caches_set(void *data, u64 val)i915_gem_retire_requests (dev);if (val &DROP_BOUND ) { -list_for_each_entry_safe (obj, next, &dev_priv->mm.inactive_list, mm_list) +list_for_each_entry_safe (obj, next, &i915_gtt_vm->inactive_list, + mm_list)if (obj->pin_count ==0 ) { ret =i915_gem_object_unbind (obj);if (ret)drivers/gpu/drm/i915/i915_drv.h +20
-29@@ -448,6 +448,22 @@ struct i915_address_space {unsigned long start;/* Start offset always 0 for dri2 */ size_t total;/* size addr space maps (ex. 2GB for ggtt) */ +/* We use many types of lists for object tracking: +* active_list: List of objects currently involved in rendering. +* Includes buffers having the contents of their GPU caches flushed, not +* necessarily primitives. last_rendering_seqno represents when the +* rendering involved will be completed. A reference is held on the buffer +* while on this list. +* inactive_list: LRU list of objects which are not in the ringbuffer +* objects are ready to unbind but are still mapped. +* last_rendering_seqno is 0 while an object is in this list. +* A reference is not held on the buffer while on this list, +* as merely being GTT-bound shouldn't prevent its being +* freed, and we'll pull it off the list in the free path. +*/ +struct list_head active_list; +struct list_head inactive_list; +struct {dma_addr_t addr;struct page *page;@@ -835,42 +851,17 @@ struct intel_l3_parity { };struct i915_gem_mm { -/** List of all objects in gtt_space. Used to restore gtt -* mappings on resume */ -struct list_head bound_list;/** -* List of objects which are not bound to the GTT (thus -* are idle and not used by the GPU) but still have -* (presumably uncached) pages still attached. +* Lists of objects which are [not] bound to a VM. Unbound objects are +* idle are idle but still have (presumably uncached) pages still +* attached. */ +struct list_head bound_list;struct list_head unbound_list;struct shrinker inactive_shrinker;bool shrinker_no_lock_stealing; -/** -* List of objects currently involved in rendering. -* -* Includes buffers having the contents of their GPU caches -* flushed, not necessarily primitives. last_rendering_seqno -* represents when the rendering involved will be completed. -* -* A reference is held on the buffer while on this list. -*/ -struct list_head active_list; - -/** -* LRU list of objects which are not in the ringbuffer and -* are ready to unbind, but are still in the GTT. -* -* last_rendering_seqno is 0 while an object is in this list. -* -* A reference is not held on the buffer while on this list, -* as merely being GTT-bound shouldn't prevent its being -* freed, and we'll pull it off the list in the free path. -*/ -struct list_head inactive_list; -/** LRU list of objects with fence regs on them. */ struct list_head fence_list;drivers/gpu/drm/i915/i915_gem.c +10
-14@@ -1706,7 +1706,7 @@ __i915_gem_shrink(struct drm_i915_private *dev_priv, long target, }list_for_each_entry_safe (obj, next, - &dev_priv->mm.inactive_list, + &i915_gtt_vm->inactive_list, mm_list) { if ((i915_gem_object_is_purgeable(obj) || !purgeable_only) && i915_gem_object_unbind(obj) == 0 &&@@ -1881,7 +1881,7 @@ i915_gem_object_move_to_active(struct drm_i915_gem_object *obj, }/* Move from whatever list we were on to the tail of execution. */ -list_move_tail (&obj->mm_list, &dev_priv->mm.active_list); +list_move_tail (&obj->mm_list, &i915_gtt_vm->active_list);list_move_tail (&obj->ring_list, &ring->active_list); obj->last_read_seqno = seqno;@@ -1909,7 +1909,7 @@ i915_gem_object_move_to_inactive(struct drm_i915_gem_object *obj)BUG_ON (obj->base.write_domain & ~I915_GEM_GPU_DOMAINS );BUG_ON (!obj->active); -list_move_tail (&obj->mm_list, &dev_priv->mm.inactive_list); +list_move_tail (&obj->mm_list, &i915_gtt_vm->inactive_list);list_del_init (&obj->ring_list); obj->ring =NULL ;@@ -2279,12 +2279,8 @@ bool i915_gem_reset(struct drm_device *dev)/* Move everything out of the GPU domains to ensure we do any * necessary invalidation upon reuse. */ -list_for_each_entry (obj, - &dev_priv->mm.inactive_list, - mm_list) - { +list_for_each_entry (obj, &i915_gtt_vm->inactive_list, mm_list) obj->base.read_domains &= ~I915_GEM_GPU_DOMAINS ; - }/* The fence registers are invalidated so clear them out */ i915_gem_restore_fences (dev);@@ -3162,7 +3158,7 @@ search_free: }list_move_tail (&obj->global_list, &dev_priv->mm.bound_list); -list_add_tail (&obj->mm_list, &dev_priv->mm.inactive_list); +list_add_tail (&obj->mm_list, &i915_gtt_vm->inactive_list); obj->gtt_space = node; obj->gtt_offset = node->start;@@ -3313,7 +3309,7 @@ i915_gem_object_set_to_gtt_domain(struct drm_i915_gem_object *obj, bool write)/* And bump the LRU for this access */ if (i915_gem_object_is_inactive (obj)) -list_move_tail (&obj->mm_list, &dev_priv->mm.inactive_list); +list_move_tail (&obj->mm_list, &i915_gtt_vm->inactive_list);return 0 ; }@@ -4291,7 +4287,7 @@ i915_gem_entervt_ioctl(struct drm_device *dev, void *data,return ret; } -BUG_ON (!list_empty (&dev_priv->mm.active_list)); +BUG_ON (!list_empty (&i915_gtt_vm->active_list));mutex_unlock (&dev->struct_mutex); ret =drm_irq_install (dev);@@ -4352,8 +4348,8 @@ i915_gem_load(struct drm_device *dev)SLAB_HWCACHE_ALIGN , NULL); -INIT_LIST_HEAD (&dev_priv->mm.active_list); -INIT_LIST_HEAD (&dev_priv->mm.inactive_list); +INIT_LIST_HEAD (&i915_gtt_vm->active_list); +INIT_LIST_HEAD (&i915_gtt_vm->inactive_list);INIT_LIST_HEAD (&dev_priv->mm.unbound_list);INIT_LIST_HEAD (&dev_priv->mm.bound_list);INIT_LIST_HEAD (&dev_priv->mm.fence_list);@@ -4652,7 +4648,7 @@ i915_gem_inactive_shrink(struct shrinker *shrinker, struct shrink_control *sc)list_for_each_entry (obj, &dev_priv->mm.unbound_list, global_list)if (obj->pages_pin_count ==0 ) cnt += obj->base.size >>PAGE_SHIFT ; -list_for_each_entry (obj, &dev_priv->mm.inactive_list, global_list) +list_for_each_entry (obj, &i915_gtt_vm->inactive_list, global_list)if (obj->pin_count ==0 && obj->pages_pin_count ==0 ) cnt += obj->base.size >>PAGE_SHIFT ;drivers/gpu/drm/i915/i915_gem_debug.c +1
-1@@ -97,7 +97,7 @@ i915_verify_lists(struct drm_device *dev) } } -list_for_each_entry (obj, &dev_priv->mm.inactive_list, list) { +list_for_each_entry (obj, &i915_gtt_vm->inactive_list, list) {if (obj->base.dev != dev || !atomic_read (&obj->base.refcount.refcount)) {DRM_ERROR ("freed inactive %p\n" , obj);drivers/gpu/drm/i915/i915_gem_evict.c +5
-5@@ -86,7 +86,7 @@ i915_gem_evict_something(struct drm_device *dev, int min_size, cache_level);/* First see if there is a large enough contiguous idle region... */ -list_for_each_entry (obj, &dev_priv->mm.inactive_list, mm_list) { +list_for_each_entry (obj, &i915_gtt_vm->inactive_list, mm_list) {if (mark_free (obj, &unwind_list)) goto found; }@@ -95,7 +95,7 @@ i915_gem_evict_something(struct drm_device *dev, int min_size, goto none;/* Now merge in the soon-to-be-expired objects... */ -list_for_each_entry (obj, &dev_priv->mm.active_list, mm_list) { +list_for_each_entry (obj, &i915_gtt_vm->active_list, mm_list) {if (mark_free (obj, &unwind_list)) goto found; }@@ -158,8 +158,8 @@ i915_gem_evict_everything(struct drm_device *dev)bool lists_empty;int ret; - lists_empty = (list_empty (&dev_priv->mm.inactive_list) && -list_empty (&dev_priv->mm.active_list)); + lists_empty = (list_empty (&i915_gtt_vm->inactive_list) && +list_empty (&i915_gtt_vm->active_list));if (lists_empty)return -ENOSPC ;@@ -177,7 +177,7 @@ i915_gem_evict_everything(struct drm_device *dev)/* Having flushed everything, unbind() should never raise an error */ list_for_each_entry_safe (obj, next, - &dev_priv->mm.inactive_list, mm_list) + &i915_gtt_vm->inactive_list, mm_list)if (obj->pin_count ==0 )WARN_ON (i915_gem_object_unbind (obj));drivers/gpu/drm/i915/i915_gem_stolen.c +1
-1@@ -384,7 +384,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev, obj->has_global_gtt_mapping =1 ;list_add_tail (&obj->global_list, &dev_priv->mm.bound_list); -list_add_tail (&obj->mm_list, &dev_priv->mm.inactive_list); +list_add_tail (&obj->mm_list, &i915_gtt_vm->inactive_list);return obj; }drivers/gpu/drm/i915/i915_irq.c +3
-3@@ -1722,7 +1722,7 @@ i915_error_first_batchbuffer(struct drm_i915_private *dev_priv, } seqno = ring->get_seqno (ring, false); -list_for_each_entry (obj, &dev_priv->mm.active_list, mm_list) { +list_for_each_entry (obj, &i915_gtt_vm->active_list, mm_list) {if (obj->ring != ring)continue ;@@ -1857,7 +1857,7 @@ static void i915_gem_capture_buffers(struct drm_i915_private *dev_priv,int i; i =0 ; -list_for_each_entry (obj, &dev_priv->mm.active_list, mm_list) +list_for_each_entry (obj, &i915_gtt_vm->active_list, mm_list) i++; error->active_bo_count = i;list_for_each_entry (obj, &dev_priv->mm.bound_list, global_list)@@ -1877,7 +1877,7 @@ static void i915_gem_capture_buffers(struct drm_i915_private *dev_priv, error->active_bo_count =capture_active_bo (error->active_bo, error->active_bo_count, - &dev_priv->mm.active_list); + &i915_gtt_vm->active_list);if (error->pinned_bo) error->pinned_bo_count =Signature · 6 lines
1.8.3.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfxSignature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.chSignature · 1 line
Ben Widawsky, Intel Open Source Technology Center
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 26/66] drm/i915: Move active/inactive lists to new mm
Quoted 13 lines · Daniel Vetter
Quoted 12 lines · Ben Widawsky
Quoted 11 lines · Daniel Vetter
Quoted 5 lines · Ben Widawsky
for file in
ls drivers/gpu/drm/i915/*.c; do sed -i "s/dev_priv->mm.inactive_list/i915_gtt_mm-\>inactive_list/" $file; done for file inls drivers/gpu/drm/i915/*.c; do sed -i "s/dev_priv->mm.active_list/i915_gtt_mm-\>active_list/" $file; doneI've also opted to move the comments out of line a bit so one can get a better picture of what the various lists do.
Bikeshed: That makes you now inconsistent with all the other in-detail structure memeber comments we have. And I don't see how it looks better, so I'd vote to keep things as-is with per-member comments.
Quoted 5 lines
Quoted 2 lines
Initially I moved all the comments (in the original mm destruction I did).
I mean to keep the per-struct-member comments right next to each individual declaration.
I meant, in the initial version I had a big blob where I wrote about all the tracking, and what each list did. It actually was pretty cool, but at that time I was trying to track [un]bound with the vm.
Quoted 19 lines
Quoted 11 lines
Quoted 11 lines
Quoted 5 lines
v2: Leave the bound list as a global one. (Chris, indirectly)
CC Chris Wilson <[email protected]>Signed-off-by Ben Widawsky <[email protected]>The real comment though is on the commit message, it fails to explain why we want to move the active/inactive lists from mm/obj to the address space/vma pair. I think I understand, but this should be explained more in-depth.
Quoted 7 lines
Quoted 5 lines
I think in the first commit which starts moving those lists and execution tracking state you should also mention why some of the state (bound/unbound lists e.g.) are not moved.
Cheers, Daniel
Can I use, "because Chris told me to"? :p
Quoted 9 lines
I think some high-level explanation should be doable ;-) E.g. when moving the lists around explain that the active/inactive stuff is used by eviction when we run out of address space, so needs to be per-vma and per-address space. Bound/unbound otoh is used by the shrinker which only cares about the amount of memory used and not one bit about in which address space this memory is all used in. Of course to actual kick out an object we need to unbind it from every address space, but for that we have the per-object list of vmas.
-Daniel
I was being facetious, but thanks for writing the commit message for me :D
Quoted 341 lines
Quoted 336 lines
Quoted 333 lines
Quoted 328 lines
--- drivers/gpu/drm/i915/i915_debugfs.c | 11 ++++---- drivers/gpu/drm/i915/i915_drv.h | 49 ++++++++++++++-------------------- drivers/gpu/drm/i915/i915_gem.c | 24 +++++++---------- drivers/gpu/drm/i915/i915_gem_debug.c | 2 +- drivers/gpu/drm/i915/i915_gem_evict.c | 10 +++---- drivers/gpu/drm/i915/i915_gem_stolen.c | 2 +- drivers/gpu/drm/i915/i915_irq.c | 6 ++--- 7 files changed, 46 insertions(+), 58 deletions(-)drivers/gpu/drm/i915/i915_debugfs.c +6
-5@@ -158,11 +158,11 @@ static int i915_gem_object_list_info(struct seq_file *m, void *data)switch (list) {case ACTIVE_LIST :seq_printf (m,"Active:\n" ); - head = &dev_priv->mm.active_list; + head = &i915_gtt_vm->active_list;break ;case INACTIVE_LIST :seq_printf (m,"Inactive:\n" ); - head = &dev_priv->mm.inactive_list; + head = &i915_gtt_vm->inactive_list;break ;default :mutex_unlock (&dev->struct_mutex);@@ -247,12 +247,12 @@ static int i915_gem_object_info(struct seq_file *m, void* data) count, mappable_count, size, mappable_size); size = count = mappable_size = mappable_count =0 ; -count_objects (&dev_priv->mm.active_list, mm_list); +count_objects (&i915_gtt_vm->active_list, mm_list);seq_printf (m," %u [%u] active objects, %zu [%zu] bytes\n" , count, mappable_count, size, mappable_size); size = count = mappable_size = mappable_count =0 ; -count_objects (&dev_priv->mm.inactive_list, mm_list); +count_objects (&i915_gtt_vm->inactive_list, mm_list);seq_printf (m," %u [%u] inactive objects, %zu [%zu] bytes\n" , count, mappable_count, size, mappable_size);@@ -1977,7 +1977,8 @@ i915_drop_caches_set(void *data, u64 val)i915_gem_retire_requests (dev);if (val &DROP_BOUND ) { -list_for_each_entry_safe (obj, next, &dev_priv->mm.inactive_list, mm_list) +list_for_each_entry_safe (obj, next, &i915_gtt_vm->inactive_list, + mm_list)if (obj->pin_count ==0 ) { ret =i915_gem_object_unbind (obj);if (ret)drivers/gpu/drm/i915/i915_drv.h +20
-29@@ -448,6 +448,22 @@ struct i915_address_space {unsigned long start;/* Start offset always 0 for dri2 */ size_t total;/* size addr space maps (ex. 2GB for ggtt) */ +/* We use many types of lists for object tracking: +* active_list: List of objects currently involved in rendering. +* Includes buffers having the contents of their GPU caches flushed, not +* necessarily primitives. last_rendering_seqno represents when the +* rendering involved will be completed. A reference is held on the buffer +* while on this list. +* inactive_list: LRU list of objects which are not in the ringbuffer +* objects are ready to unbind but are still mapped. +* last_rendering_seqno is 0 while an object is in this list. +* A reference is not held on the buffer while on this list, +* as merely being GTT-bound shouldn't prevent its being +* freed, and we'll pull it off the list in the free path. +*/ +struct list_head active_list; +struct list_head inactive_list; +struct {dma_addr_t addr;struct page *page;@@ -835,42 +851,17 @@ struct intel_l3_parity { };struct i915_gem_mm { -/** List of all objects in gtt_space. Used to restore gtt -* mappings on resume */ -struct list_head bound_list;/** -* List of objects which are not bound to the GTT (thus -* are idle and not used by the GPU) but still have -* (presumably uncached) pages still attached. +* Lists of objects which are [not] bound to a VM. Unbound objects are +* idle are idle but still have (presumably uncached) pages still +* attached. */ +struct list_head bound_list;struct list_head unbound_list;struct shrinker inactive_shrinker;bool shrinker_no_lock_stealing; -/** -* List of objects currently involved in rendering. -* -* Includes buffers having the contents of their GPU caches -* flushed, not necessarily primitives. last_rendering_seqno -* represents when the rendering involved will be completed. -* -* A reference is held on the buffer while on this list. -*/ -struct list_head active_list; - -/** -* LRU list of objects which are not in the ringbuffer and -* are ready to unbind, but are still in the GTT. -* -* last_rendering_seqno is 0 while an object is in this list. -* -* A reference is not held on the buffer while on this list, -* as merely being GTT-bound shouldn't prevent its being -* freed, and we'll pull it off the list in the free path. -*/ -struct list_head inactive_list; -/** LRU list of objects with fence regs on them. */ struct list_head fence_list;drivers/gpu/drm/i915/i915_gem.c +10
-14@@ -1706,7 +1706,7 @@ __i915_gem_shrink(struct drm_i915_private *dev_priv, long target, }list_for_each_entry_safe (obj, next, - &dev_priv->mm.inactive_list, + &i915_gtt_vm->inactive_list, mm_list) { if ((i915_gem_object_is_purgeable(obj) || !purgeable_only) && i915_gem_object_unbind(obj) == 0 &&@@ -1881,7 +1881,7 @@ i915_gem_object_move_to_active(struct drm_i915_gem_object *obj, }/* Move from whatever list we were on to the tail of execution. */ -list_move_tail (&obj->mm_list, &dev_priv->mm.active_list); +list_move_tail (&obj->mm_list, &i915_gtt_vm->active_list);list_move_tail (&obj->ring_list, &ring->active_list); obj->last_read_seqno = seqno;@@ -1909,7 +1909,7 @@ i915_gem_object_move_to_inactive(struct drm_i915_gem_object *obj)BUG_ON (obj->base.write_domain & ~I915_GEM_GPU_DOMAINS );BUG_ON (!obj->active); -list_move_tail (&obj->mm_list, &dev_priv->mm.inactive_list); +list_move_tail (&obj->mm_list, &i915_gtt_vm->inactive_list);list_del_init (&obj->ring_list); obj->ring =NULL ;@@ -2279,12 +2279,8 @@ bool i915_gem_reset(struct drm_device *dev)/* Move everything out of the GPU domains to ensure we do any * necessary invalidation upon reuse. */ -list_for_each_entry (obj, - &dev_priv->mm.inactive_list, - mm_list) - { +list_for_each_entry (obj, &i915_gtt_vm->inactive_list, mm_list) obj->base.read_domains &= ~I915_GEM_GPU_DOMAINS ; - }/* The fence registers are invalidated so clear them out */ i915_gem_restore_fences (dev);@@ -3162,7 +3158,7 @@ search_free: }list_move_tail (&obj->global_list, &dev_priv->mm.bound_list); -list_add_tail (&obj->mm_list, &dev_priv->mm.inactive_list); +list_add_tail (&obj->mm_list, &i915_gtt_vm->inactive_list); obj->gtt_space = node; obj->gtt_offset = node->start;@@ -3313,7 +3309,7 @@ i915_gem_object_set_to_gtt_domain(struct drm_i915_gem_object *obj, bool write)/* And bump the LRU for this access */ if (i915_gem_object_is_inactive (obj)) -list_move_tail (&obj->mm_list, &dev_priv->mm.inactive_list); +list_move_tail (&obj->mm_list, &i915_gtt_vm->inactive_list);return 0 ; }@@ -4291,7 +4287,7 @@ i915_gem_entervt_ioctl(struct drm_device *dev, void *data,return ret; } -BUG_ON (!list_empty (&dev_priv->mm.active_list)); +BUG_ON (!list_empty (&i915_gtt_vm->active_list));mutex_unlock (&dev->struct_mutex); ret =drm_irq_install (dev);@@ -4352,8 +4348,8 @@ i915_gem_load(struct drm_device *dev)SLAB_HWCACHE_ALIGN , NULL); -INIT_LIST_HEAD (&dev_priv->mm.active_list); -INIT_LIST_HEAD (&dev_priv->mm.inactive_list); +INIT_LIST_HEAD (&i915_gtt_vm->active_list); +INIT_LIST_HEAD (&i915_gtt_vm->inactive_list);INIT_LIST_HEAD (&dev_priv->mm.unbound_list);INIT_LIST_HEAD (&dev_priv->mm.bound_list);INIT_LIST_HEAD (&dev_priv->mm.fence_list);@@ -4652,7 +4648,7 @@ i915_gem_inactive_shrink(struct shrinker *shrinker, struct shrink_control *sc)list_for_each_entry (obj, &dev_priv->mm.unbound_list, global_list)if (obj->pages_pin_count ==0 ) cnt += obj->base.size >>PAGE_SHIFT ; -list_for_each_entry (obj, &dev_priv->mm.inactive_list, global_list) +list_for_each_entry (obj, &i915_gtt_vm->inactive_list, global_list)if (obj->pin_count ==0 && obj->pages_pin_count ==0 ) cnt += obj->base.size >>PAGE_SHIFT ;drivers/gpu/drm/i915/i915_gem_debug.c +1
-1@@ -97,7 +97,7 @@ i915_verify_lists(struct drm_device *dev) } } -list_for_each_entry (obj, &dev_priv->mm.inactive_list, list) { +list_for_each_entry (obj, &i915_gtt_vm->inactive_list, list) {if (obj->base.dev != dev || !atomic_read (&obj->base.refcount.refcount)) {DRM_ERROR ("freed inactive %p\n" , obj);drivers/gpu/drm/i915/i915_gem_evict.c +5
-5@@ -86,7 +86,7 @@ i915_gem_evict_something(struct drm_device *dev, int min_size, cache_level);/* First see if there is a large enough contiguous idle region... */ -list_for_each_entry (obj, &dev_priv->mm.inactive_list, mm_list) { +list_for_each_entry (obj, &i915_gtt_vm->inactive_list, mm_list) {if (mark_free (obj, &unwind_list)) goto found; }@@ -95,7 +95,7 @@ i915_gem_evict_something(struct drm_device *dev, int min_size, goto none;/* Now merge in the soon-to-be-expired objects... */ -list_for_each_entry (obj, &dev_priv->mm.active_list, mm_list) { +list_for_each_entry (obj, &i915_gtt_vm->active_list, mm_list) {if (mark_free (obj, &unwind_list)) goto found; }@@ -158,8 +158,8 @@ i915_gem_evict_everything(struct drm_device *dev)bool lists_empty;int ret; - lists_empty = (list_empty (&dev_priv->mm.inactive_list) && -list_empty (&dev_priv->mm.active_list)); + lists_empty = (list_empty (&i915_gtt_vm->inactive_list) && +list_empty (&i915_gtt_vm->active_list));if (lists_empty)return -ENOSPC ;@@ -177,7 +177,7 @@ i915_gem_evict_everything(struct drm_device *dev)/* Having flushed everything, unbind() should never raise an error */ list_for_each_entry_safe (obj, next, - &dev_priv->mm.inactive_list, mm_list) + &i915_gtt_vm->inactive_list, mm_list)if (obj->pin_count ==0 )WARN_ON (i915_gem_object_unbind (obj));drivers/gpu/drm/i915/i915_gem_stolen.c +1
-1@@ -384,7 +384,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev, obj->has_global_gtt_mapping =1 ;list_add_tail (&obj->global_list, &dev_priv->mm.bound_list); -list_add_tail (&obj->mm_list, &dev_priv->mm.inactive_list); +list_add_tail (&obj->mm_list, &i915_gtt_vm->inactive_list);return obj; }drivers/gpu/drm/i915/i915_irq.c +3
-3@@ -1722,7 +1722,7 @@ i915_error_first_batchbuffer(struct drm_i915_private *dev_priv, } seqno = ring->get_seqno (ring, false); -list_for_each_entry (obj, &dev_priv->mm.active_list, mm_list) { +list_for_each_entry (obj, &i915_gtt_vm->active_list, mm_list) {if (obj->ring != ring)continue ;@@ -1857,7 +1857,7 @@ static void i915_gem_capture_buffers(struct drm_i915_private *dev_priv,int i; i =0 ; -list_for_each_entry (obj, &dev_priv->mm.active_list, mm_list) +list_for_each_entry (obj, &i915_gtt_vm->active_list, mm_list) i++; error->active_bo_count = i;list_for_each_entry (obj, &dev_priv->mm.bound_list, global_list)@@ -1877,7 +1877,7 @@ static void i915_gem_capture_buffers(struct drm_i915_private *dev_priv, error->active_bo_count =capture_active_bo (error->active_bo, error->active_bo_count, - &dev_priv->mm.active_list); + &i915_gtt_vm->active_list);if (error->pinned_bo) error->pinned_bo_count =Signature · 6 lines
1.8.3.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfxSignature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.chSignature · 1 line
Ben Widawsky, Intel Open Source Technology CenterSignature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
PATCH 27/66 drm/i915: Create a global list of vms
In reply to Ben WidawskyAfter we plumb our code to support multiple address spaces (VMs), there are a few situations where we want to be able to traverse the list of all address spaces in the system. Cases like eviction, or error state collection are obvious example.
It's easy enough to test and make sure our list is accurate because we already have a member in place to access our global GTT. By porting that to use our list (which assumes the GGTT is always the first entry) we can verify a decent amount of the code is working correct.
NOTE: to do this, we must initialize the list quite early.
--- drivers/gpu/drm/i915/i915_dma.c | 5 +++++ drivers/gpu/drm/i915/i915_drv.h | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_dma.c +5 -0
@@ -1497,6 +1497,10 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)i915_dump_device_info (dev_priv); +INIT_LIST_HEAD (&dev_priv->vm_list); +INIT_LIST_HEAD (&dev_priv->gtt.base.global_link); +list_add (&dev_priv->gtt.base.global_link, &dev_priv->vm_list); +if (i915_get_bridge_dev (dev)) { ret = -EIO ; goto free_priv;
@@ -1753,6 +1757,7 @@ int i915_driver_unload(struct drm_device *dev)i915_free_hws (dev); } +list_del (&dev_priv->vm_list);drm_mm_takedown (&i915_gtt_vm->mm);if (dev_priv->regs !=NULL )pci_iounmap (dev->pdev, dev_priv->regs);
drivers/gpu/drm/i915/i915_drv.h +6 -1
@@ -445,6 +445,7 @@ typedef uint32_t gen6_gtt_pte_t;struct i915_address_space {struct drm_mm mm;struct drm_device *dev; +struct list_head global_link;unsigned long start;/* Start offset always 0 for dri2 */ size_t total;/* size addr space maps (ex. 2GB for ggtt) */
@@ -519,7 +520,10 @@ struct i915_gtt { unsigned long *mappable_end);void (*gtt_remove)(struct drm_device *dev); }; -#define i915_gtt_vm ((struct i915_address_space *)&(dev_priv->gtt.base)) +#define i915_gtt_vm ((struct i915_address_space *) \ + list_first_entry(&dev_priv->vm_list,\ + struct i915_address_space, \ + global_link))struct i915_hw_ppgtt {struct i915_address_space base;
@@ -1115,6 +1119,7 @@ typedef struct drm_i915_private {enum modeset_restore modeset_restore;struct mutex modeset_restore_lock; +struct list_head vm_list;/* Global list of all address spaces */ struct i915_gtt gtt;/* VMA representing the global address space */ struct i915_gem_mm mm;
Signature · 1 line
1.8.3.1
PATCH 28/66 drm/i915: Remove object's gtt_offset
In reply to Ben Widawskygtt_offset has always been == gtt_space->start. This makes an upcoming change much easier to swallow.
--- drivers/gpu/drm/i915/i915_debugfs.c | 9 +++--- drivers/gpu/drm/i915/i915_drv.h | 7 ---- drivers/gpu/drm/i915/i915_gem.c | 51 ++++++++++++++---------------- drivers/gpu/drm/i915/i915_gem_context.c | 2 +- drivers/gpu/drm/i915/i915_gem_debug.c | 9 +++--- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 13 ++++---- drivers/gpu/drm/i915/i915_gem_gtt.c | 6 ++-- drivers/gpu/drm/i915/i915_gem_stolen.c | 2 +- drivers/gpu/drm/i915/i915_gem_tiling.c | 14 ++++---- drivers/gpu/drm/i915/i915_irq.c | 16 +++++----- drivers/gpu/drm/i915/intel_display.c | 34 ++++++++++++-------- drivers/gpu/drm/i915/intel_fb.c | 8 ++--- drivers/gpu/drm/i915/intel_overlay.c | 23 +++++++------- drivers/gpu/drm/i915/intel_pm.c | 8 ++--- drivers/gpu/drm/i915/intel_ringbuffer.c | 12 +++---- drivers/gpu/drm/i915/intel_sprite.c | 8 +++-- 16 files changed, 112 insertions(+), 110 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +5 -4
@@ -123,8 +123,9 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)if (obj->fence_reg !=I915_FENCE_REG_NONE )seq_printf (m," (fence: %d)" , obj->fence_reg);if (obj->gtt_space !=NULL ) -seq_printf (m," (gtt offset: %08x, size: %08x)" , - obj->gtt_offset, (unsigned int )obj->gtt_space->size); +seq_printf (m," (gtt offset: %08lx, size: %08x)" , + obj->gtt_space->start, + (unsigned int )obj->gtt_space->size);if (obj->stolen)seq_printf (m," (stolen: %08lx)" , obj->stolen->start);if (obj->pin_mappable || obj->fault_mappable) {
@@ -379,12 +380,12 @@ static int i915_gem_pageflip_info(struct seq_file *m, void *data)if (work->old_fb_obj) {struct drm_i915_gem_object *obj = work->old_fb_obj;if (obj) -seq_printf (m,"Old framebuffer gtt_offset 0x%08x\n" , obj->gtt_offset); +seq_printf (m,"Old framebuffer gtt_offset 0x%08lx\n" , obj->gtt_space->start); }if (work->pending_flip_obj) {struct drm_i915_gem_object *obj = work->pending_flip_obj;if (obj) -seq_printf (m,"New framebuffer gtt_offset 0x%08x\n" , obj->gtt_offset); +seq_printf (m,"New framebuffer gtt_offset 0x%08lx\n" , obj->gtt_space->start); } }spin_unlock_irqrestore (&dev->event_lock, flags);
drivers/gpu/drm/i915/i915_drv.h +0 -7
@@ -1324,13 +1324,6 @@ struct drm_i915_gem_object {unsigned long exec_handle;struct drm_i915_gem_exec_object2 *exec_entry; -/** -* Current offset of the object in GTT space. -* -* This is the same as gtt_space->start -*/ -uint32_t gtt_offset; -struct intel_ring_buffer *ring;/** Breadcrumb of last rendering to the buffer. */
drivers/gpu/drm/i915/i915_gem.c +24 -27
149 lines not on this page · raw message
drivers/gpu/drm/i915/i915_gem_context.c +1 -1
@@ -395,7 +395,7 @@ mi_set_context(struct intel_ring_buffer *ring,intel_ring_emit (ring,MI_NOOP );intel_ring_emit (ring,MI_SET_CONTEXT ); - intel_ring_emit(ring, new_context->obj->gtt_offset | + intel_ring_emit(ring, new_context->obj->gtt_space->start | MI_MM_SPACE_GTT | MI_SAVE_EXT_STATE_EN | MI_RESTORE_EXT_STATE_EN |
drivers/gpu/drm/i915/i915_gem_debug.c +5 -4
@@ -128,11 +128,12 @@ i915_gem_object_check_coherency(struct drm_i915_gem_object *obj, int handle)int bad_count =0 ;DRM_INFO ("%s: checking coherency of object %p@0x%08x (%d, %zdkb):\n" , - __func__, obj, obj->gtt_offset, handle, + __func__, obj, obj->gtt_space->start, handle, obj->size /1024 ); - gtt_mapping =ioremap (dev_priv->mm.gtt_base_addr + obj->gtt_offset, - obj->base.size); + gtt_mapping = +ioremap (dev_priv->mm.gtt_base_addr + obj->gtt_space->start, + obj->base.size);if (gtt_mapping ==NULL ) {DRM_ERROR ("failed to map GTT space\n" );return ;
@@ -156,7 +157,7 @@ i915_gem_object_check_coherency(struct drm_i915_gem_object *obj, int handle)if (cpuval != gttval) {DRM_INFO ("incoherent CPU vs GPU at 0x%08x: " "0x%08x vs 0x%08x\n" , - (int )(obj->gtt_offset + + (int )(obj->gtt_space->start + page *PAGE_SIZE + i *4 ), cpuval, gttval);if (bad_count++ >=8 ) {
drivers/gpu/drm/i915/i915_gem_execbuffer.c +7 -6
@@ -188,7 +188,7 @@ i915_gem_execbuffer_relocate_entry(struct drm_i915_gem_object *obj,return -ENOENT ; target_i915_obj =to_intel_bo (target_obj); - target_offset = target_i915_obj->gtt_offset; + target_offset = target_i915_obj->gtt_space->start;/* Sandybridge PPGTT errata: We need a global gtt mapping for MI and * pipe_control writes because the gpu doesn't properly redirect them
@@ -280,7 +280,7 @@ i915_gem_execbuffer_relocate_entry(struct drm_i915_gem_object *obj,return ret;/* Map the page containing the relocation we're going to perform. */ - reloc->offset += obj->gtt_offset; + reloc->offset += obj->gtt_space->start; reloc_page =io_mapping_map_atomic_wc (dev_priv->gtt.mappable, reloc->offset &PAGE_MASK ); reloc_entry = (uint32_t __iomem *)
@@ -436,8 +436,8 @@ i915_gem_execbuffer_reserve_object(struct drm_i915_gem_object *obj, obj->has_aliasing_ppgtt_mapping =1 ; } -if (entry->offset != obj->gtt_offset) { - entry->offset = obj->gtt_offset; +if (entry->offset != obj->gtt_space->start) { + entry->offset = obj->gtt_space->start; *need_reloc = true; }
@@ -539,7 +539,8 @@ i915_gem_execbuffer_reserve(struct intel_ring_buffer *ring, obj->tiling_mode !=I915_TILING_NONE ; need_mappable = need_fence ||need_reloc_mappable (obj); -if ((entry->alignment && obj->gtt_offset & (entry->alignment -1 )) || +if ((entry->alignment && + obj->gtt_space->start & (entry->alignment -1 )) || (need_mappable && !obj->map_and_fenceable)) ret =i915_gem_object_unbind (obj);else
@@ -1071,7 +1072,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, goto err; } - exec_start = batch_obj->gtt_offset + args->batch_start_offset; + exec_start = batch_obj->gtt_space->start + args->batch_start_offset; exec_len = args->batch_len;if (cliprects) {for (i =0 ; i < args->num_cliprects; i++) {
drivers/gpu/drm/i915/i915_gem_gtt.c +3 -3
@@ -679,12 +679,12 @@ void i915_gem_setup_global_gtt(struct drm_device *dev,/* Mark any preallocated objects as occupied */ list_for_each_entry (obj, &dev_priv->mm.bound_list, global_list) { -DRM_DEBUG_KMS ("reserving preallocated space: %x + %zx\n" , - obj->gtt_offset, obj->base.size); +DRM_DEBUG_KMS ("reserving preallocated space: %lx + %zx\n" , + obj->gtt_space->start, obj->base.size);BUG_ON (obj->gtt_space !=I915_GTT_RESERVED ); obj->gtt_space =drm_mm_create_block (&i915_gtt_vm->mm, - obj->gtt_offset, + obj->gtt_space->start, obj->base.size, false); obj->has_global_gtt_mapping =1 ;
drivers/gpu/drm/i915/i915_gem_stolen.c +1 -1
@@ -380,7 +380,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev, }else obj->gtt_space =I915_GTT_RESERVED ; - obj->gtt_offset = gtt_offset; + obj->gtt_space->start = gtt_offset; obj->has_global_gtt_mapping =1 ;list_add_tail (&obj->global_list, &dev_priv->mm.bound_list);
drivers/gpu/drm/i915/i915_gem_tiling.c +7 -7
@@ -268,10 +268,10 @@ i915_gem_object_fence_ok(struct drm_i915_gem_object *obj, int tiling_mode)return true;if (INTEL_INFO (obj->base.dev)->gen ==3 ) { -if (obj->gtt_offset & ~I915_FENCE_START_MASK ) +if (obj->gtt_space->start & ~I915_FENCE_START_MASK )return false; }else { -if (obj->gtt_offset & ~I830_FENCE_START_MASK ) +if (obj->gtt_space->start & ~I830_FENCE_START_MASK )return false; }
@@ -279,7 +279,7 @@ i915_gem_object_fence_ok(struct drm_i915_gem_object *obj, int tiling_mode)if (obj->gtt_space->size != size)return false; -if (obj->gtt_offset & (size -1 )) +if (obj->gtt_space->start & (size -1 ))return false;return true;
@@ -358,9 +358,9 @@ i915_gem_set_tiling(struct drm_device *dev, void *data,* whilst executing a fenced command for an untiled object. */ - obj->map_and_fenceable = - obj->gtt_space ==NULL || - (obj->gtt_offset + obj->base.size <= dev_priv->gtt.mappable_end && + obj->map_and_fenceable = obj->gtt_space ==NULL || + (obj->gtt_space->start + + obj->base.size <= dev_priv->gtt.mappable_end &&i915_gem_object_fence_ok (obj, args->tiling_mode));/* Rebind if we need a change of alignment */
@@ -369,7 +369,7 @@ i915_gem_set_tiling(struct drm_device *dev, void *data,i915_gem_get_gtt_alignment (dev, obj->base.size, args->tiling_mode, false); -if (obj->gtt_offset & (unfenced_alignment -1 )) +if (obj->gtt_space->start & (unfenced_alignment -1 )) ret =i915_gem_object_unbind (obj); }
drivers/gpu/drm/i915/i915_irq.c +8 -8
@@ -1512,7 +1512,7 @@ i915_error_object_create_sized(struct drm_i915_private *dev_priv,if (dst ==NULL )return NULL ; - reloc_offset = src->gtt_offset; + reloc_offset = src->gtt_space->start;for (i =0 ; i < num_pages; i++) {unsigned long flags;void *d;
@@ -1564,7 +1564,7 @@ i915_error_object_create_sized(struct drm_i915_private *dev_priv, reloc_offset +=PAGE_SIZE ; } dst->page_count = num_pages; - dst->gtt_offset = src->gtt_offset; + dst->gtt_offset = src->gtt_space->start;return dst;
@@ -1618,7 +1618,7 @@ static void capture_bo(struct drm_i915_error_buffer *err, err->name = obj->base.name; err->rseqno = obj->last_read_seqno; err->wseqno = obj->last_write_seqno; - err->gtt_offset = obj->gtt_offset; + err->gtt_offset = obj->gtt_space->start; err->read_domains = obj->base.read_domains; err->write_domain = obj->base.write_domain; err->fence_reg = obj->fence_reg;
@@ -1716,8 +1716,8 @@ i915_error_first_batchbuffer(struct drm_i915_private *dev_priv,return NULL ; obj = ring->private; -if (acthd >= obj->gtt_offset && - acthd < obj->gtt_offset + obj->base.size) +if (acthd >= obj->gtt_space->start && + acthd < obj->gtt_space->start + obj->base.size)return i915_error_object_create (dev_priv, obj); }
@@ -1798,7 +1798,7 @@ static void i915_gem_record_active_context(struct intel_ring_buffer *ring,return ;list_for_each_entry (obj, &dev_priv->mm.bound_list, global_list) { -if ((error->ccid &PAGE_MASK ) == obj->gtt_offset) { +if ((error->ccid &PAGE_MASK ) == obj->gtt_space->start) { ering->ctx =i915_error_object_create_sized (dev_priv, obj,1 ); }
@@ -2152,10 +2152,10 @@ static void __always_unused i915_pageflip_stall_check(struct drm_device *dev, inif (INTEL_INFO (dev)->gen >=4 ) {int dspsurf =DSPSURF (intel_crtc->plane); stall_detected =I915_HI_DISPBASE (I915_READ (dspsurf)) == - obj->gtt_offset; + obj->gtt_space->start; }else {int dspaddr =DSPADDR (intel_crtc->plane); - stall_detected =I915_READ (dspaddr) == (obj->gtt_offset + + stall_detected =I915_READ (dspaddr) == (obj->gtt_space->start + crtc->y * crtc->fb->pitches[0 ] + crtc->x * crtc->fb->bits_per_pixel/8 ); }
drivers/gpu/drm/i915/intel_display.c +21 -13
@@ -1942,16 +1942,19 @@ static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb, intel_crtc->dspaddr_offset = linear_offset; } -DRM_DEBUG_KMS ("Writing base %08X %08lX %d %d %d\n" , - obj->gtt_offset, linear_offset, x, y, fb->pitches[0 ]); +DRM_DEBUG_KMS ("Writing base %08lX %08lX %d %d %d\n" , + obj->gtt_space->start, linear_offset, x, y, + fb->pitches[0 ]);I915_WRITE (DSPSTRIDE (plane), fb->pitches[0 ]);if (INTEL_INFO (dev)->gen >=4 ) {I915_MODIFY_DISPBASE (DSPSURF (plane), - obj->gtt_offset + intel_crtc->dspaddr_offset); + obj->gtt_space->start + + intel_crtc->dspaddr_offset);I915_WRITE (DSPTILEOFF (plane), (y <<16 ) | x);I915_WRITE (DSPLINOFF (plane), linear_offset); }else -I915_WRITE (DSPADDR (plane), obj->gtt_offset + linear_offset); +I915_WRITE (DSPADDR (plane), + obj->gtt_space->start + linear_offset);POSTING_READ (reg);return 0 ;
@@ -2031,11 +2034,12 @@ static int ironlake_update_plane(struct drm_crtc *crtc, fb->pitches[0]); linear_offset -= intel_crtc->dspaddr_offset; -DRM_DEBUG_KMS ("Writing base %08X %08lX %d %d %d\n" , - obj->gtt_offset, linear_offset, x, y, fb->pitches[0 ]); +DRM_DEBUG_KMS ("Writing base %08lX %08lX %d %d %d\n" , + obj->gtt_space->start, linear_offset, x, y, + fb->pitches[0 ]);I915_WRITE (DSPSTRIDE (plane), fb->pitches[0 ]);I915_MODIFY_DISPBASE (DSPSURF (plane), - obj->gtt_offset + intel_crtc->dspaddr_offset); + obj->gtt_space->start+intel_crtc->dspaddr_offset);if (IS_HASWELL (dev)) {I915_WRITE (DSPOFFSET (plane), (y <<16 ) | x); }else {
@@ -6554,7 +6558,7 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc, goto fail_unpin; } - addr = obj->gtt_offset; + addr = obj->gtt_space->start; }else {int align =IS_I830 (dev) ?16 *1024 :256 ; ret = i915_gem_attach_phys_object(dev, obj,
@@ -7269,7 +7273,8 @@ static int intel_gen2_queue_flip(struct drm_device *dev,intel_ring_emit (ring,MI_DISPLAY_FLIP |MI_DISPLAY_FLIP_PLANE (intel_crtc->plane));intel_ring_emit (ring, fb->pitches[0 ]); -intel_ring_emit (ring, obj->gtt_offset + intel_crtc->dspaddr_offset); +intel_ring_emit (ring, + obj->gtt_space->start + intel_crtc->dspaddr_offset);intel_ring_emit (ring,0 );/* aux display base address, unused */ intel_mark_page_flip_active (intel_crtc);
@@ -7310,7 +7315,8 @@ static int intel_gen3_queue_flip(struct drm_device *dev,intel_ring_emit (ring,MI_DISPLAY_FLIP_I915 |MI_DISPLAY_FLIP_PLANE (intel_crtc->plane));intel_ring_emit (ring, fb->pitches[0 ]); -intel_ring_emit (ring, obj->gtt_offset + intel_crtc->dspaddr_offset); +intel_ring_emit (ring, + obj->gtt_space->start + intel_crtc->dspaddr_offset);intel_ring_emit (ring,MI_NOOP );intel_mark_page_flip_active (intel_crtc);
@@ -7350,7 +7356,7 @@ static int intel_gen4_queue_flip(struct drm_device *dev, MI_DISPLAY_FLIP_PLANE(intel_crtc->plane));intel_ring_emit (ring, fb->pitches[0 ]);intel_ring_emit (ring, - (obj->gtt_offset + intel_crtc->dspaddr_offset) | + (obj->gtt_space->start + intel_crtc->dspaddr_offset) | obj->tiling_mode);/* XXX Enabling the panel-fitter across page-flip is so far
@@ -7393,7 +7399,8 @@ static int intel_gen6_queue_flip(struct drm_device *dev,intel_ring_emit (ring,MI_DISPLAY_FLIP |MI_DISPLAY_FLIP_PLANE (intel_crtc->plane));intel_ring_emit (ring, fb->pitches[0 ] | obj->tiling_mode); -intel_ring_emit (ring, obj->gtt_offset + intel_crtc->dspaddr_offset); +intel_ring_emit (ring, + obj->gtt_space->start + intel_crtc->dspaddr_offset);/* Contrary to the suggestions in the documentation, * "Enable Panel Fitter" does not seem to be required when page
@@ -7458,7 +7465,8 @@ static int intel_gen7_queue_flip(struct drm_device *dev,intel_ring_emit (ring,MI_DISPLAY_FLIP_I915 | plane_bit);intel_ring_emit (ring, (fb->pitches[0 ] | obj->tiling_mode)); -intel_ring_emit (ring, obj->gtt_offset + intel_crtc->dspaddr_offset); +intel_ring_emit (ring, + obj->gtt_space->start + intel_crtc->dspaddr_offset);intel_ring_emit (ring, (MI_NOOP ));intel_mark_page_flip_active (intel_crtc);
drivers/gpu/drm/i915/intel_fb.c +4 -4
@@ -139,11 +139,11 @@ static int intelfb_create(struct drm_fb_helper *helper, info->apertures->ranges[0 ].base = dev->mode_config.fb_base; info->apertures->ranges[0 ].size = dev_priv->gtt.mappable_end; - info->fix.smem_start = dev->mode_config.fb_base + obj->gtt_offset; + info->fix.smem_start = dev->mode_config.fb_base + obj->gtt_space->start; info->fix.smem_len = size; info->screen_base = -ioremap_wc (dev_priv->gtt.mappable_base + obj->gtt_offset, +ioremap_wc (dev_priv->gtt.mappable_base + obj->gtt_space->start, size);if (!info->screen_base) { ret = -ENOSPC ;
@@ -166,9 +166,9 @@ static int intelfb_create(struct drm_fb_helper *helper,/* Use default scratch pixmap (info->pixmap.flags = FB_PIXMAP_SYSTEM) */ -DRM_DEBUG_KMS ("allocated %dx%d fb: 0x%08x, bo %p\n" , +DRM_DEBUG_KMS ("allocated %dx%d fb: 0x%08lx, bo %p\n" , fb->width, fb->height, - obj->gtt_offset, obj); + obj->gtt_space->start, obj);mutex_unlock (&dev->struct_mutex);
drivers/gpu/drm/i915/intel_overlay.c +11 -12
@@ -196,7 +196,7 @@ intel_overlay_map_regs(struct intel_overlay *overlay) regs = (struct overlay_registers __iomem *)overlay->reg_bo->phys_obj->handle->vaddr; else regs =io_mapping_map_wc (dev_priv->gtt.mappable, - overlay->reg_bo->gtt_offset); + overlay->reg_bo->gtt_space->start);return regs; }
@@ -740,7 +740,7 @@ static int intel_overlay_do_put_image(struct intel_overlay *overlay, swidth = params->src_w; swidthsw =calc_swidthsw (overlay->dev, params->offset_Y, tmp_width); sheight = params->src_h; -iowrite32 (new_bo->gtt_offset + params->offset_Y, ®s->OBUF_0Y); +iowrite32 (new_bo->gtt_space->start + params->offset_Y, ®s->OBUF_0Y); ostride = params->stride_Y;if (params->format &I915_OVERLAY_YUV_PLANAR ) {
@@ -754,8 +754,10 @@ static int intel_overlay_do_put_image(struct intel_overlay *overlay, params->src_w/uv_hscale); swidthsw |=max_t (u32, tmp_U, tmp_V) <<16 ; sheight |= (params->src_h/uv_vscale) <<16 ; -iowrite32 (new_bo->gtt_offset + params->offset_U, ®s->OBUF_0U); -iowrite32 (new_bo->gtt_offset + params->offset_V, ®s->OBUF_0V); +iowrite32 (new_bo->gtt_space->start + params->offset_U, + ®s->OBUF_0U); +iowrite32 (new_bo->gtt_space->start + params->offset_V, + ®s->OBUF_0V); ostride |= params->stride_UV <<16 ; }
@@ -1355,7 +1357,7 @@ void intel_setup_overlay(struct drm_device *dev)DRM_ERROR ("failed to pin overlay register bo\n" ); goto out_free_bo; } - overlay->flip_addr = reg_bo->gtt_offset; + overlay->flip_addr = reg_bo->gtt_space->start; ret =i915_gem_object_set_to_gtt_domain (reg_bo, true);if (ret) {
@@ -1426,18 +1428,15 @@ static struct overlay_registers __iomem * intel_overlay_map_regs_atomic(struct intel_overlay *overlay) {drm_i915_private_t *dev_priv = overlay->dev->dev_private; -struct overlay_registers __iomem *regs;if (OVERLAY_NEEDS_PHYSICAL (overlay->dev))/* Cast to make sparse happy, but it's wc memory anyway, so * equivalent to the wc io mapping on X86. */ - regs = (struct overlay_registers __iomem *) +return (struct overlay_registers __iomem *) overlay->reg_bo->phys_obj->handle->vaddr; -else - regs =io_mapping_map_atomic_wc (dev_priv->gtt.mappable, - overlay->reg_bo->gtt_offset); -return regs; +return io_mapping_map_atomic_wc (dev_priv->gtt.mappable, + overlay->reg_bo->gtt_space->start); } static void intel_overlay_unmap_regs_atomic(struct intel_overlay *overlay,
@@ -1468,7 +1467,7 @@ intel_overlay_capture_error_state(struct drm_device *dev)if (OVERLAY_NEEDS_PHYSICAL (overlay->dev)) error->base = (__force long )overlay->reg_bo->phys_obj->handle->vaddr;else - error->base = overlay->reg_bo->gtt_offset; + error->base = overlay->reg_bo->gtt_space->start; regs =intel_overlay_map_regs_atomic (overlay);if (!regs)
drivers/gpu/drm/i915/intel_pm.c +4 -4
@@ -217,7 +217,7 @@ static void ironlake_enable_fbc(struct drm_crtc *crtc, unsigned long interval) (stall_watermark <<DPFC_RECOMP_STALL_WM_SHIFT ) | (interval << DPFC_RECOMP_TIMER_COUNT_SHIFT));I915_WRITE (ILK_DPFC_FENCE_YOFF , crtc->y); -I915_WRITE (ILK_FBC_RT_BASE , obj->gtt_offset |ILK_FBC_RT_VALID ); +I915_WRITE (ILK_FBC_RT_BASE , obj->gtt_space->start |ILK_FBC_RT_VALID );/* enable it... */ I915_WRITE (ILK_DPFC_CONTROL , dpfc_ctl |DPFC_CTL_EN );
@@ -274,7 +274,7 @@ static void gen7_enable_fbc(struct drm_crtc *crtc, unsigned long interval)struct drm_i915_gem_object *obj = intel_fb->obj;struct intel_crtc *intel_crtc =to_intel_crtc (crtc); -I915_WRITE (IVB_FBC_RT_BASE , obj->gtt_offset); +I915_WRITE (IVB_FBC_RT_BASE , obj->gtt_space->start); I915_WRITE(ILK_DPFC_CONTROL, DPFC_CTL_EN | DPFC_CTL_LIMIT_1X | IVB_DPFC_CTL_FENCE_EN |
@@ -3685,7 +3685,7 @@ static void ironlake_enable_rc6(struct drm_device *dev)intel_ring_emit (ring,MI_SUSPEND_FLUSH |MI_SUSPEND_FLUSH_EN );intel_ring_emit (ring,MI_SET_CONTEXT ); - intel_ring_emit(ring, dev_priv->ips.renderctx->gtt_offset | + intel_ring_emit(ring, dev_priv->ips.renderctx->gtt_space->start | MI_MM_SPACE_GTT | MI_SAVE_EXT_STATE_EN | MI_RESTORE_EXT_STATE_EN |
@@ -3708,7 +3708,7 @@ static void ironlake_enable_rc6(struct drm_device *dev)return ; } -I915_WRITE (PWRCTXA , dev_priv->ips.pwrctx->gtt_offset |PWRCTX_EN ); +I915_WRITE (PWRCTXA , dev_priv->ips.pwrctx->gtt_space->start |PWRCTX_EN );I915_WRITE (RSTDBYCTL ,I915_READ (RSTDBYCTL ) & ~RCX_SW_EXIT ); }
drivers/gpu/drm/i915/intel_ringbuffer.c +6 -6
@@ -424,14 +424,14 @@ static int init_ring_common(struct intel_ring_buffer *ring)* registers with the above sequence (the readback of the HEAD registers * also enforces ordering), otherwise the hw might lose the new ring * register values. */ -I915_WRITE_START (ring, obj->gtt_offset); +I915_WRITE_START (ring, obj->gtt_space->start);I915_WRITE_CTL (ring, ((ring->size -PAGE_SIZE ) &RING_NR_PAGES ) |RING_VALID );/* If the head is still not zero, the ring is dead */ if (wait_for ((I915_READ_CTL (ring) &RING_VALID ) !=0 && -I915_READ_START (ring) == obj->gtt_offset && +I915_READ_START (ring) == obj->gtt_space->start && (I915_READ_HEAD (ring) &HEAD_ADDR ) ==0 ,50 )) { DRM_ERROR("%s initialization failed " "ctl %08x head %08x tail %08x start %08x\n",
@@ -489,7 +489,7 @@ init_pipe_control(struct intel_ring_buffer *ring)if (ret) goto err_unref; - pc->gtt_offset = obj->gtt_offset; + pc->gtt_offset = obj->gtt_space->start; pc->cpu_page =kmap (sg_page (obj->pages->sgl));if (pc->cpu_page ==NULL ) { ret = -ENOMEM ;
@@ -1129,7 +1129,7 @@ i830_dispatch_execbuffer(struct intel_ring_buffer *ring,intel_ring_advance (ring); }else {struct drm_i915_gem_object *obj = ring->private; -u32 cs_offset = obj->gtt_offset; +u32 cs_offset = obj->gtt_space->start;if (len >I830_BATCH_LIMIT )return -ENOSPC ;
@@ -1214,7 +1214,7 @@ static int init_status_page(struct intel_ring_buffer *ring) goto err_unref; } - ring->status_page.gfx_addr = obj->gtt_offset; + ring->status_page.gfx_addr = obj->gtt_space->start; ring->status_page.page_addr =kmap (sg_page (obj->pages->sgl));if (ring->status_page.page_addr ==NULL ) { ret = -ENOMEM ;
@@ -1308,7 +1308,7 @@ static int intel_init_ring_buffer(struct drm_device *dev, goto err_unpin; ring->virtual_start = -ioremap_wc (dev_priv->gtt.mappable_base + obj->gtt_offset, +ioremap_wc (dev_priv->gtt.mappable_base + obj->gtt_space->start, ring->size);if (ring->virtual_start ==NULL ) {DRM_ERROR ("Failed to map ringbuffer.\n" );
drivers/gpu/drm/i915/intel_sprite.c +5 -3
@@ -133,7 +133,7 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_framebuffer *fb,I915_WRITE (SPSIZE (pipe, plane), (crtc_h <<16 ) | crtc_w);I915_WRITE (SPCNTR (pipe, plane), sprctl); -I915_MODIFY_DISPBASE (SPSURF (pipe, plane), obj->gtt_offset + +I915_MODIFY_DISPBASE (SPSURF (pipe, plane), obj->gtt_space->start + sprsurf_offset);POSTING_READ (SPSURF (pipe, plane)); }
@@ -308,7 +308,8 @@ ivb_update_plane(struct drm_plane *plane, struct drm_framebuffer *fb,if (intel_plane->can_scale)I915_WRITE (SPRSCALE (pipe), sprscale);I915_WRITE (SPRCTL (pipe), sprctl); -I915_MODIFY_DISPBASE (SPRSURF (pipe), obj->gtt_offset + sprsurf_offset); +I915_MODIFY_DISPBASE (SPRSURF (pipe), + obj->gtt_space->start + sprsurf_offset);POSTING_READ (SPRSURF (pipe));/* potentially re-enable LP watermarks */
@@ -478,7 +479,8 @@ ilk_update_plane(struct drm_plane *plane, struct drm_framebuffer *fb,I915_WRITE (DVSSIZE (pipe), (crtc_h <<16 ) | crtc_w);I915_WRITE (DVSSCALE (pipe), dvsscale);I915_WRITE (DVSCNTR (pipe), dvscntr); -I915_MODIFY_DISPBASE (DVSSURF (pipe), obj->gtt_offset + dvssurf_offset); +I915_MODIFY_DISPBASE (DVSSURF (pipe), + obj->gtt_space->start + dvssurf_offset);POSTING_READ (DVSSURF (pipe)); }
Signature · 1 line
1.8.3.1
PATCH 29/66 drm: pre allocate node for create_block
In reply to Ben WidawskyFor an upcoming patch where we introduce the i915 VMA, it's ideal to have the drm_mm_node as part of the VMA struct (ie. it's pre-allocated). Part of the conversion to VMAs is to kill off obj->gtt_space. Doing this will break a bunch of code, but amongst them are 2 callers of drm_mm_create_block(), both related to stolen memory.
As a side note, this patch has is able to leverage all the existing drm_mm_put_block because the node is still kzalloc'd. When the aforementioned VMA code comes into play, that too has to change.
--- drivers/gpu/drm/drm_mm.c | 16 +++++----------- drivers/gpu/drm/i915/i915_drv.h | 2 +- drivers/gpu/drm/i915/i915_gem_gtt.c | 20 ++++++++++++++----- drivers/gpu/drm/i915/i915_gem_stolen.c | 35 +++++++++++++++++++++++----------- include/drm/drm_mm.h | 9 ++++----- 5 files changed, 49 insertions(+), 33 deletions(-)
drivers/gpu/drm/drm_mm.c +5 -11
@@ -158,12 +158,10 @@ static void drm_mm_insert_helper(struct drm_mm_node *hole_node, } } -struct drm_mm_node *drm_mm_create_block (struct drm_mm *mm, -unsigned long start, -unsigned long size, -enum drm_mm_allocator_flags flags) +int drm_mm_create_block (struct drm_mm *mm,struct drm_mm_node *node, +unsigned long start,unsigned long size) { -struct drm_mm_node *hole, *node; +struct drm_mm_node *hole;unsigned long end = start + size;unsigned long hole_start;unsigned long hole_end;
@@ -172,10 +170,6 @@ struct drm_mm_node *drm_mm_create_block(struct drm_mm *mm,if (hole_start > start || hole_end < end)continue ; - node =drm_mm_kmalloc (mm, flags &DRM_MM_CREATE_ATOMIC ); -if (unlikely (node ==NULL )) -return NULL ; - node->start = start; node->size = size; node->mm = mm;
@@ -195,11 +189,11 @@ struct drm_mm_node *drm_mm_create_block(struct drm_mm *mm, node->hole_follows =1 ; } -return node; +return 0 ; }WARN (1 ,"no hole found for block 0x%lx + 0x%lx\n" , start, size); -return NULL ; +return -ENOSPC ; }EXPORT_SYMBOL (drm_mm_create_block);
drivers/gpu/drm/i915/i915_drv.h +1 -1
@@ -1197,7 +1197,7 @@ enum hdmi_force_audio { HDMI_AUDIO_ON, /* force turn on HDMI audio */ }; -#define I915_GTT_RESERVED ((struct drm_mm_node *)0x1) +#define I915_GTT_RESERVED 0x1struct drm_i915_gem_object_ops {/* Interface between the GEM object and its backing storage.
drivers/gpu/drm/i915/i915_gem_gtt.c +15 -5
@@ -679,14 +679,24 @@ void i915_gem_setup_global_gtt(struct drm_device *dev,/* Mark any preallocated objects as occupied */ list_for_each_entry (obj, &dev_priv->mm.bound_list, global_list) { +uintptr_t gtt_offset = (uintptr_t )obj->gtt_space; +int ret;DRM_DEBUG_KMS ("reserving preallocated space: %lx + %zx\n" , obj->gtt_space->start, obj->base.size); -BUG_ON (obj->gtt_space !=I915_GTT_RESERVED ); - obj->gtt_space =drm_mm_create_block (&i915_gtt_vm->mm, - obj->gtt_space->start, - obj->base.size, - false); +BUG_ON ((gtt_offset &I915_GTT_RESERVED ) ==0 ); + gtt_offset = gtt_offset & ~I915_GTT_RESERVED ; + obj->gtt_space =kzalloc (sizeof (*obj->gtt_space),GFP_KERNEL ); +if (!obj->gtt_space) { +DRM_ERROR ("Failed to preserve all objects\n" ); +break ; + } + ret =drm_mm_create_block (&i915_gtt_vm->mm, + obj->gtt_space, + gtt_offset, + obj->base.size); +if (ret) +DRM_DEBUG_KMS ("Reservation failed\n" ); obj->has_global_gtt_mapping =1 ; }
drivers/gpu/drm/i915/i915_gem_stolen.c +24 -11
@@ -330,6 +330,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,struct drm_i915_private *dev_priv = dev->dev_private;struct drm_i915_gem_object *obj;struct drm_mm_node *stolen; +int ret;if (dev_priv->gtt.stolen_base ==0 )return NULL ;
@@ -344,11 +345,15 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,if (WARN_ON (size ==0 ))return NULL ; - stolen =drm_mm_create_block (&dev_priv->gtt.stolen, - stolen_offset, size, - false); -if (stolen ==NULL ) { + stolen =kzalloc (sizeof (*stolen),GFP_KERNEL ); +if (!stolen) +return NULL ; + + ret =drm_mm_create_block (&dev_priv->gtt.stolen, stolen, stolen_offset, + size); +if (ret) {DRM_DEBUG_KMS ("failed to allocate stolen space\n" ); +kfree (stolen);return NULL ; }
@@ -369,18 +374,26 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,* later. */ if (drm_mm_initialized (&i915_gtt_vm->mm)) { - obj->gtt_space =drm_mm_create_block (&i915_gtt_vm->mm, - gtt_offset, size, - false); -if (obj->gtt_space ==NULL ) { + obj->gtt_space =kzalloc (sizeof (*obj->gtt_space),GFP_KERNEL ); +if (!obj->gtt_space) { +drm_gem_object_unreference (&obj->base); +return NULL ; + } + ret =drm_mm_create_block (&i915_gtt_vm->mm, obj->gtt_space, + gtt_offset, size); +if (ret) {DRM_DEBUG_KMS ("failed to allocate stolen GTT space\n" );drm_gem_object_unreference (&obj->base); +kfree (obj->gtt_space);return NULL ; } - }else - obj->gtt_space =I915_GTT_RESERVED ; + obj->gtt_space->start = gtt_offset; + }else { +/* NB: Safe because we assert page alignment */ + obj->gtt_space = (struct drm_mm_node *) + ((uintptr_t )gtt_offset |I915_GTT_RESERVED ); + } - obj->gtt_space->start = gtt_offset; obj->has_global_gtt_mapping =1 ;list_add_tail (&obj->global_list, &dev_priv->mm.bound_list);
include/drm/drm_mm.h +4 -5
@@ -161,11 +161,10 @@ static inline unsigned long drm_mm_hole_node_end(struct drm_mm_node *hole_node)/* * Basic range manager support (drm_mm.c) */ -extern struct drm_mm_node * -drm_mm_create_block (struct drm_mm *mm, -unsigned long start, -unsigned long size, -enum drm_mm_allocator_flags flags); +extern int drm_mm_create_block (struct drm_mm *mm, +struct drm_mm_node *node, +unsigned long start, +unsigned long size);extern struct drm_mm_node * drm_mm_get_block_generic(struct drm_mm_node *node, unsigned long size,
Signature · 1 line
1.8.3.1
Re: [PATCH 29/66] drm: pre allocate node for create_block
Quoted 11 lines · Ben Widawsky
For an upcoming patch where we introduce the i915 VMA, it's ideal to have the
drm_mm_nodeas part of the VMA struct (ie. it's pre-allocated). Part of the conversion to VMAs is to kill offobj->gtt_space. Doing this will break a bunch of code, but amongst them are 2 callers ofdrm_mm_create_block(), both related to stolen memory.As a side note, this patch has is able to leverage all the existing
drm_mm_put_blockbecause the node is still kzalloc'd. When the aforementioned VMA code comes into play, that too has to change.Signed-off-by Ben Widawsky <[email protected]>
Same here about cc'ing dri-devel. Furthermore I think it'd be nice to kill the interfaces from drm_mm.c which allocate the drm_mm_node themselves. The last user outside of drm/i915 is ttm, killing that one would also allow us to remove the (racy) preallocation madness.
So if you convert over all of drm/i915 to the preallcoate functions which pass in the drm_mm_node, I'll volunteer myself to fix up ttm. -Daniel
Quoted 193 lines
--- drivers/gpu/drm/drm_mm.c | 16 +++++----------- drivers/gpu/drm/i915/i915_drv.h | 2 +- drivers/gpu/drm/i915/i915_gem_gtt.c | 20 ++++++++++++++----- drivers/gpu/drm/i915/i915_gem_stolen.c | 35 +++++++++++++++++++++++----------- include/drm/drm_mm.h | 9 ++++----- 5 files changed, 49 insertions(+), 33 deletions(-)drivers/gpu/drm/drm_mm.c +5
-11@@ -158,12 +158,10 @@ static void drm_mm_insert_helper(struct drm_mm_node *hole_node, } } -struct drm_mm_node *drm_mm_create_block (struct drm_mm *mm, -unsigned long start, -unsigned long size, -enum drm_mm_allocator_flags flags) +int drm_mm_create_block (struct drm_mm *mm,struct drm_mm_node *node, +unsigned long start,unsigned long size) { -struct drm_mm_node *hole, *node; +struct drm_mm_node *hole;unsigned long end = start + size;unsigned long hole_start;unsigned long hole_end;@@ -172,10 +170,6 @@ struct drm_mm_node *drm_mm_create_block(struct drm_mm *mm,if (hole_start > start || hole_end < end)continue ; - node =drm_mm_kmalloc (mm, flags &DRM_MM_CREATE_ATOMIC ); -if (unlikely (node ==NULL )) -return NULL ; - node->start = start; node->size = size; node->mm = mm;@@ -195,11 +189,11 @@ struct drm_mm_node *drm_mm_create_block(struct drm_mm *mm, node->hole_follows =1 ; } -return node; +return 0 ; }WARN (1 ,"no hole found for block 0x%lx + 0x%lx\n" , start, size); -return NULL ; +return -ENOSPC ; }EXPORT_SYMBOL (drm_mm_create_block);drivers/gpu/drm/i915/i915_drv.h +1
-1@@ -1197,7 +1197,7 @@ enum hdmi_force_audio { HDMI_AUDIO_ON, /* force turn on HDMI audio */ }; -#define I915_GTT_RESERVED ((struct drm_mm_node *)0x1) +#define I915_GTT_RESERVED 0x1struct drm_i915_gem_object_ops {/* Interface between the GEM object and its backing storage. drivers/gpu/drm/i915/i915_gem_gtt.c +15
-5@@ -679,14 +679,24 @@ void i915_gem_setup_global_gtt(struct drm_device *dev,/* Mark any preallocated objects as occupied */ list_for_each_entry (obj, &dev_priv->mm.bound_list, global_list) { +uintptr_t gtt_offset = (uintptr_t )obj->gtt_space; +int ret;DRM_DEBUG_KMS ("reserving preallocated space: %lx + %zx\n" , obj->gtt_space->start, obj->base.size); -BUG_ON (obj->gtt_space !=I915_GTT_RESERVED ); - obj->gtt_space =drm_mm_create_block (&i915_gtt_vm->mm, - obj->gtt_space->start, - obj->base.size, - false); +BUG_ON ((gtt_offset &I915_GTT_RESERVED ) ==0 ); + gtt_offset = gtt_offset & ~I915_GTT_RESERVED ; + obj->gtt_space =kzalloc (sizeof (*obj->gtt_space),GFP_KERNEL ); +if (!obj->gtt_space) { +DRM_ERROR ("Failed to preserve all objects\n" ); +break ; + } + ret =drm_mm_create_block (&i915_gtt_vm->mm, + obj->gtt_space, + gtt_offset, + obj->base.size); +if (ret) +DRM_DEBUG_KMS ("Reservation failed\n" ); obj->has_global_gtt_mapping =1 ; }drivers/gpu/drm/i915/i915_gem_stolen.c +24
-11@@ -330,6 +330,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,struct drm_i915_private *dev_priv = dev->dev_private;struct drm_i915_gem_object *obj;struct drm_mm_node *stolen; +int ret;if (dev_priv->gtt.stolen_base ==0 )return NULL ;@@ -344,11 +345,15 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,if (WARN_ON (size ==0 ))return NULL ; - stolen =drm_mm_create_block (&dev_priv->gtt.stolen, - stolen_offset, size, - false); -if (stolen ==NULL ) { + stolen =kzalloc (sizeof (*stolen),GFP_KERNEL ); +if (!stolen) +return NULL ; + + ret =drm_mm_create_block (&dev_priv->gtt.stolen, stolen, stolen_offset, + size); +if (ret) {DRM_DEBUG_KMS ("failed to allocate stolen space\n" ); +kfree (stolen);return NULL ; }@@ -369,18 +374,26 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,* later. */ if (drm_mm_initialized (&i915_gtt_vm->mm)) { - obj->gtt_space =drm_mm_create_block (&i915_gtt_vm->mm, - gtt_offset, size, - false); -if (obj->gtt_space ==NULL ) { + obj->gtt_space =kzalloc (sizeof (*obj->gtt_space),GFP_KERNEL ); +if (!obj->gtt_space) { +drm_gem_object_unreference (&obj->base); +return NULL ; + } + ret =drm_mm_create_block (&i915_gtt_vm->mm, obj->gtt_space, + gtt_offset, size); +if (ret) {DRM_DEBUG_KMS ("failed to allocate stolen GTT space\n" );drm_gem_object_unreference (&obj->base); +kfree (obj->gtt_space);return NULL ; } - }else - obj->gtt_space =I915_GTT_RESERVED ; + obj->gtt_space->start = gtt_offset; + }else { +/* NB: Safe because we assert page alignment */ + obj->gtt_space = (struct drm_mm_node *) + ((uintptr_t )gtt_offset |I915_GTT_RESERVED ); + } - obj->gtt_space->start = gtt_offset; obj->has_global_gtt_mapping =1 ;list_add_tail (&obj->global_list, &dev_priv->mm.bound_list);include/drm/drm_mm.h +4
-5@@ -161,11 +161,10 @@ static inline unsigned long drm_mm_hole_node_end(struct drm_mm_node *hole_node)/* * Basic range manager support (drm_mm.c) */ -extern struct drm_mm_node * -drm_mm_create_block (struct drm_mm *mm, -unsigned long start, -unsigned long size, -enum drm_mm_allocator_flags flags); +extern int drm_mm_create_block (struct drm_mm *mm, +struct drm_mm_node *node, +unsigned long start, +unsigned long size);extern struct drm_mm_node * drm_mm_get_block_generic(struct drm_mm_node *node, unsigned long size,Signature · 6 lines
1.8.3.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 29/66] drm: pre allocate node for create_block
Quoted 13 lines · Daniel Vetter
Quoted 11 lines · Ben Widawsky
For an upcoming patch where we introduce the i915 VMA, it's ideal to have the
drm_mm_nodeas part of the VMA struct (ie. it's pre-allocated). Part of the conversion to VMAs is to kill offobj->gtt_space. Doing this will break a bunch of code, but amongst them are 2 callers ofdrm_mm_create_block(), both related to stolen memory.As a side note, this patch has is able to leverage all the existing
drm_mm_put_blockbecause the node is still kzalloc'd. When the aforementioned VMA code comes into play, that too has to change.Signed-off-by Ben Widawsky <[email protected]>
Quoted 8 lines
Same here about cc'ing dri-devel. Furthermore I think it'd be nice to kill the interfaces from
drm_mm.cwhich allocate thedrm_mm_nodethemselves. The last user outside of drm/i915 is ttm, killing that one would also allow us to remove the (racy) preallocation madness.So if you convert over all of drm/i915 to the preallcoate functions which pass in the
drm_mm_node, I'll volunteer myself to fix up ttm. -Daniel
I will do that and send it as a separate series.
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
PATCH 30/66 drm/i915: Getter/setter for object attributes
In reply to Ben WidawskyThis will be handy when we add VMs. It's not strictly, necessary, but it will make the code much cleaner.
--- drivers/gpu/drm/i915/i915_debugfs.c | 26 +++++------ drivers/gpu/drm/i915/i915_drv.h | 21 +++++++++ drivers/gpu/drm/i915/i915_gem.c | 69 +++++++++++++++--------------- drivers/gpu/drm/i915/i915_gem_context.c | 2 +- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 20 +++++---- drivers/gpu/drm/i915/i915_gem_gtt.c | 12 +++--- drivers/gpu/drm/i915/i915_gem_tiling.c | 14 +++--- drivers/gpu/drm/i915/i915_irq.c | 16 +++---- drivers/gpu/drm/i915/i915_trace.h | 8 ++-- drivers/gpu/drm/i915/intel_display.c | 22 +++++----- drivers/gpu/drm/i915/intel_fb.c | 6 +-- drivers/gpu/drm/i915/intel_overlay.c | 15 ++++--- drivers/gpu/drm/i915/intel_pm.c | 7 +-- drivers/gpu/drm/i915/intel_ringbuffer.c | 12 +++--- drivers/gpu/drm/i915/intel_sprite.c | 6 +-- 15 files changed, 143 insertions(+), 113 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +14 -12
@@ -122,10 +122,10 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)seq_printf (m," (pinned x %d)" , obj->pin_count);if (obj->fence_reg !=I915_FENCE_REG_NONE )seq_printf (m," (fence: %d)" , obj->fence_reg); -if (obj->gtt_space !=NULL ) -seq_printf (m," (gtt offset: %08lx, size: %08x)" , - obj->gtt_space->start, - (unsigned int )obj->gtt_space->size); +if (i915_gem_obj_bound (obj)) +seq_printf (m," (gtt offset: %08lx, size: %08lx)" , +i915_gem_obj_offset (obj), +i915_gem_obj_size (obj));if (obj->stolen)seq_printf (m," (stolen: %08lx)" , obj->stolen->start);if (obj->pin_mappable || obj->fault_mappable) {
@@ -176,7 +176,7 @@ static int i915_gem_object_list_info(struct seq_file *m, void *data)describe_obj (m, obj);seq_printf (m,"\n" ); total_obj_size += obj->base.size; - total_gtt_size += obj->gtt_space->size; + total_gtt_size +=i915_gem_obj_size (obj); count++; }mutex_unlock (&dev->struct_mutex);
@@ -188,10 +188,10 @@ static int i915_gem_object_list_info(struct seq_file *m, void *data)#define count_objects (list, member) do { \ list_for_each_entry(obj, list, member) { \ - size += obj->gtt_space->size; \ + size += i915_gem_obj_size(obj); \ ++count; \ if (obj->map_and_fenceable) { \ - mappable_size += obj->gtt_space->size; \ + mappable_size += i915_gem_obj_size(obj); \ ++mappable_count; \ } \ } \
@@ -268,11 +268,11 @@ static int i915_gem_object_info(struct seq_file *m, void* data) size = count = mappable_size = mappable_count =0 ;list_for_each_entry (obj, &dev_priv->mm.bound_list, global_list) {if (obj->fault_mappable) { - size += obj->gtt_space->size; + size +=i915_gem_obj_size (obj); ++count; }if (obj->pin_mappable) { - mappable_size += obj->gtt_space->size; + mappable_size +=i915_gem_obj_size (obj); ++mappable_count; }if (obj->madv ==I915_MADV_DONTNEED ) {
@@ -334,7 +334,7 @@ static int i915_gem_gtt_info(struct seq_file *m, void* data)describe_obj (m, obj);seq_printf (m,"\n" ); total_obj_size += obj->base.size; - total_gtt_size += obj->gtt_space->size; + total_gtt_size +=i915_gem_obj_size (obj); count++; }
@@ -380,12 +380,14 @@ static int i915_gem_pageflip_info(struct seq_file *m, void *data)if (work->old_fb_obj) {struct drm_i915_gem_object *obj = work->old_fb_obj;if (obj) -seq_printf (m,"Old framebuffer gtt_offset 0x%08lx\n" , obj->gtt_space->start); +seq_printf (m,"Old framebuffer gtt_offset 0x%08lx\n" , +i915_gem_obj_offset (obj)); }if (work->pending_flip_obj) {struct drm_i915_gem_object *obj = work->pending_flip_obj;if (obj) -seq_printf (m,"New framebuffer gtt_offset 0x%08lx\n" , obj->gtt_space->start); +seq_printf (m,"New framebuffer gtt_offset 0x%08lx\n" , +i915_gem_obj_offset (obj)); } }spin_unlock_irqrestore (&dev->event_lock, flags);
drivers/gpu/drm/i915/i915_drv.h +21 -0
@@ -1349,6 +1349,27 @@ struct drm_i915_gem_object {#define to_intel_bo (x) container_of(x, struct drm_i915_gem_object, base) +static inline unsigned long i915_gem_obj_offset (struct drm_i915_gem_object *o) +{ +return o->gtt_space->start; +} + +static inline bool i915_gem_obj_bound (struct drm_i915_gem_object *o) +{ +return o->gtt_space !=NULL ; +} + +static inline unsigned long i915_gem_obj_size (struct drm_i915_gem_object *o) +{ +return o->gtt_space->size; +} + +static inline void i915_gem_obj_set_color (struct drm_i915_gem_object *o, +enum i915_cache_level color) +{ + o->gtt_space->color = color; +} +/** * Request queue structure. *
drivers/gpu/drm/i915/i915_gem.c +35 -34
221 lines not on this page · raw message
drivers/gpu/drm/i915/i915_gem_context.c +1 -1
@@ -395,7 +395,7 @@ mi_set_context(struct intel_ring_buffer *ring,intel_ring_emit (ring,MI_NOOP );intel_ring_emit (ring,MI_SET_CONTEXT ); - intel_ring_emit(ring, new_context->obj->gtt_space->start | + intel_ring_emit(ring, i915_gem_obj_offset(new_context->obj) | MI_MM_SPACE_GTT | MI_SAVE_EXT_STATE_EN | MI_RESTORE_EXT_STATE_EN |
drivers/gpu/drm/i915/i915_gem_execbuffer.c +11 -9
@@ -188,7 +188,7 @@ i915_gem_execbuffer_relocate_entry(struct drm_i915_gem_object *obj,return -ENOENT ; target_i915_obj =to_intel_bo (target_obj); - target_offset = target_i915_obj->gtt_space->start; + target_offset =i915_gem_obj_offset (target_i915_obj);/* Sandybridge PPGTT errata: We need a global gtt mapping for MI and * pipe_control writes because the gpu doesn't properly redirect them
@@ -280,7 +280,7 @@ i915_gem_execbuffer_relocate_entry(struct drm_i915_gem_object *obj,return ret;/* Map the page containing the relocation we're going to perform. */ - reloc->offset += obj->gtt_space->start; + reloc->offset +=i915_gem_obj_offset (obj); reloc_page =io_mapping_map_atomic_wc (dev_priv->gtt.mappable, reloc->offset &PAGE_MASK ); reloc_entry = (uint32_t __iomem *)
@@ -436,8 +436,8 @@ i915_gem_execbuffer_reserve_object(struct drm_i915_gem_object *obj, obj->has_aliasing_ppgtt_mapping =1 ; } -if (entry->offset != obj->gtt_space->start) { - entry->offset = obj->gtt_space->start; +if (entry->offset !=i915_gem_obj_offset (obj)) { + entry->offset =i915_gem_obj_offset (obj); *need_reloc = true; }
@@ -458,7 +458,7 @@ i915_gem_execbuffer_unreserve_object(struct drm_i915_gem_object *obj) {struct drm_i915_gem_exec_object2 *entry; -if (!obj->gtt_space) +if (!i915_gem_obj_bound (obj))return ; entry = obj->exec_entry;
@@ -528,11 +528,13 @@ i915_gem_execbuffer_reserve(struct intel_ring_buffer *ring,/* Unbind any ill-fitting objects or pin. */ list_for_each_entry (obj, objects, exec_list) {struct drm_i915_gem_exec_object2 *entry = obj->exec_entry; +unsigned long obj_offset;bool need_fence, need_mappable; -if (!obj->gtt_space) +if (!i915_gem_obj_bound (obj))continue ; + obj_offset =i915_gem_obj_offset (obj); need_fence = has_fenced_gpu_access && entry->flags & EXEC_OBJECT_NEEDS_FENCE &&
@@ -540,7 +542,7 @@ i915_gem_execbuffer_reserve(struct intel_ring_buffer *ring, need_mappable = need_fence ||need_reloc_mappable (obj);if ((entry->alignment && - obj->gtt_space->start & (entry->alignment -1 )) || + obj_offset & (entry->alignment -1 )) || (need_mappable && !obj->map_and_fenceable)) ret =i915_gem_object_unbind (obj);else
@@ -551,7 +553,7 @@ i915_gem_execbuffer_reserve(struct intel_ring_buffer *ring,/* Bind fresh objects */ list_for_each_entry (obj, objects, exec_list) { -if (obj->gtt_space) +if (i915_gem_obj_bound (obj))continue ; ret =i915_gem_execbuffer_reserve_object (obj, ring, need_relocs);
@@ -1072,7 +1074,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, goto err; } - exec_start = batch_obj->gtt_space->start + args->batch_start_offset; + exec_start =i915_gem_obj_offset (batch_obj) + args->batch_start_offset; exec_len = args->batch_len;if (cliprects) {for (i =0 ; i < args->num_cliprects; i++) {
drivers/gpu/drm/i915/i915_gem_gtt.c +7 -5
@@ -390,7 +390,7 @@ void i915_ppgtt_bind_object(struct i915_hw_ppgtt *ppgtt, enum i915_cache_level cache_level) { ppgtt->base.insert_entries (&ppgtt->base, obj->pages, - obj->gtt_space->start >>PAGE_SHIFT , +i915_gem_obj_offset (obj) >>PAGE_SHIFT , cache_level); }
@@ -398,7 +398,7 @@ void i915_ppgtt_unbind_object(struct i915_hw_ppgtt *ppgtt, struct drm_i915_gem_object *obj) { ppgtt->base.clear_range (&ppgtt->base, - obj->gtt_space->start >>PAGE_SHIFT , +i915_gem_obj_offset (obj) >>PAGE_SHIFT , obj->base.size >>PAGE_SHIFT ); }
@@ -570,9 +570,10 @@ void i915_gem_gtt_bind_object(struct drm_i915_gem_object *obj, {struct drm_device *dev = obj->base.dev;struct drm_i915_private *dev_priv = dev->dev_private; +unsigned long obj_offset =i915_gem_obj_offset (obj); i915_gtt_vm->insert_entries (&dev_priv->gtt.base, obj->pages, - obj->gtt_space->start >>PAGE_SHIFT , + obj_offset >>PAGE_SHIFT , cache_level); obj->has_global_gtt_mapping =1 ;
@@ -582,9 +583,10 @@ void i915_gem_gtt_unbind_object(struct drm_i915_gem_object *obj) {struct drm_device *dev = obj->base.dev;struct drm_i915_private *dev_priv = dev->dev_private; +unsigned long obj_offset =i915_gem_obj_offset (obj); i915_gtt_vm->clear_range (&dev_priv->gtt.base, - obj->gtt_space->start >>PAGE_SHIFT , + obj_offset >>PAGE_SHIFT , obj->base.size >>PAGE_SHIFT ); obj->has_global_gtt_mapping =0 ;
@@ -682,7 +684,7 @@ void i915_gem_setup_global_gtt(struct drm_device *dev,uintptr_t gtt_offset = (uintptr_t )obj->gtt_space;int ret;DRM_DEBUG_KMS ("reserving preallocated space: %lx + %zx\n" , - obj->gtt_space->start, obj->base.size); +i915_gem_obj_offset (obj), obj->base.size);BUG_ON ((gtt_offset &I915_GTT_RESERVED ) ==0 ); gtt_offset = gtt_offset & ~I915_GTT_RESERVED ;
drivers/gpu/drm/i915/i915_gem_tiling.c +7 -7
@@ -268,18 +268,18 @@ i915_gem_object_fence_ok(struct drm_i915_gem_object *obj, int tiling_mode)return true;if (INTEL_INFO (obj->base.dev)->gen ==3 ) { -if (obj->gtt_space->start & ~I915_FENCE_START_MASK ) +if (i915_gem_obj_offset (obj) & ~I915_FENCE_START_MASK )return false; }else { -if (obj->gtt_space->start & ~I830_FENCE_START_MASK ) +if (i915_gem_obj_offset (obj) & ~I830_FENCE_START_MASK )return false; } size =i915_gem_get_gtt_size (obj->base.dev, obj->base.size, tiling_mode); -if (obj->gtt_space->size != size) +if (i915_gem_obj_size (obj) != size)return false; -if (obj->gtt_space->start & (size -1 )) +if (i915_gem_obj_offset (obj) & (size -1 ))return false;return true;
@@ -358,8 +358,8 @@ i915_gem_set_tiling(struct drm_device *dev, void *data,* whilst executing a fenced command for an untiled object. */ - obj->map_and_fenceable = obj->gtt_space ==NULL || - (obj->gtt_space->start + + obj->map_and_fenceable = !i915_gem_obj_bound (obj) || + (i915_gem_obj_offset (obj) + obj->base.size <= dev_priv->gtt.mappable_end &&i915_gem_object_fence_ok (obj, args->tiling_mode));
@@ -369,7 +369,7 @@ i915_gem_set_tiling(struct drm_device *dev, void *data,i915_gem_get_gtt_alignment (dev, obj->base.size, args->tiling_mode, false); -if (obj->gtt_space->start & (unfenced_alignment -1 )) +if (i915_gem_obj_offset (obj) & (unfenced_alignment -1 )) ret =i915_gem_object_unbind (obj); }
drivers/gpu/drm/i915/i915_irq.c +8 -8
@@ -1512,7 +1512,7 @@ i915_error_object_create_sized(struct drm_i915_private *dev_priv,if (dst ==NULL )return NULL ; - reloc_offset = src->gtt_space->start; + reloc_offset =i915_gem_obj_offset (src);for (i =0 ; i < num_pages; i++) {unsigned long flags;void *d;
@@ -1564,7 +1564,7 @@ i915_error_object_create_sized(struct drm_i915_private *dev_priv, reloc_offset +=PAGE_SIZE ; } dst->page_count = num_pages; - dst->gtt_offset = src->gtt_space->start; + dst->gtt_offset =i915_gem_obj_offset (src);return dst;
@@ -1618,7 +1618,7 @@ static void capture_bo(struct drm_i915_error_buffer *err, err->name = obj->base.name; err->rseqno = obj->last_read_seqno; err->wseqno = obj->last_write_seqno; - err->gtt_offset = obj->gtt_space->start; + err->gtt_offset =i915_gem_obj_offset (obj); err->read_domains = obj->base.read_domains; err->write_domain = obj->base.write_domain; err->fence_reg = obj->fence_reg;
@@ -1716,8 +1716,8 @@ i915_error_first_batchbuffer(struct drm_i915_private *dev_priv,return NULL ; obj = ring->private; -if (acthd >= obj->gtt_space->start && - acthd < obj->gtt_space->start + obj->base.size) +if (acthd >=i915_gem_obj_offset (obj) && + acthd <i915_gem_obj_offset (obj) + obj->base.size)return i915_error_object_create (dev_priv, obj); }
@@ -1798,7 +1798,7 @@ static void i915_gem_record_active_context(struct intel_ring_buffer *ring,return ;list_for_each_entry (obj, &dev_priv->mm.bound_list, global_list) { -if ((error->ccid &PAGE_MASK ) == obj->gtt_space->start) { +if ((error->ccid &PAGE_MASK ) ==i915_gem_obj_offset (obj)) { ering->ctx =i915_error_object_create_sized (dev_priv, obj,1 ); }
@@ -2152,10 +2152,10 @@ static void __always_unused i915_pageflip_stall_check(struct drm_device *dev, inif (INTEL_INFO (dev)->gen >=4 ) {int dspsurf =DSPSURF (intel_crtc->plane); stall_detected =I915_HI_DISPBASE (I915_READ (dspsurf)) == - obj->gtt_space->start; +i915_gem_obj_offset (obj); }else {int dspaddr =DSPADDR (intel_crtc->plane); - stall_detected =I915_READ (dspaddr) == (obj->gtt_space->start + + stall_detected =I915_READ (dspaddr) == (i915_gem_obj_offset (obj) + crtc->y * crtc->fb->pitches[0 ] + crtc->x * crtc->fb->bits_per_pixel/8 ); }
drivers/gpu/drm/i915/i915_trace.h +4 -4
@@ -46,8 +46,8 @@ TRACE_EVENT(i915_gem_object_bind,TP_fast_assign ( __entry->obj = obj; - __entry->offset = obj->gtt_space->start; - __entry->size = obj->gtt_space->size; + __entry->offset =i915_gem_obj_offset (obj); + __entry->size =i915_gem_obj_size (obj); __entry->mappable = mappable; ),
@@ -68,8 +68,8 @@ TRACE_EVENT(i915_gem_object_unbind,TP_fast_assign ( __entry->obj = obj; - __entry->offset = obj->gtt_space->start; - __entry->size = obj->gtt_space->size; + __entry->offset =i915_gem_obj_offset (obj); + __entry->size =i915_gem_obj_size (obj); ), TP_printk("obj=%p, offset=%08x size=%x",
drivers/gpu/drm/i915/intel_display.c +11 -11
@@ -1943,18 +1943,18 @@ static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb, }DRM_DEBUG_KMS ("Writing base %08lX %08lX %d %d %d\n" , - obj->gtt_space->start, linear_offset, x, y, +i915_gem_obj_offset (obj), linear_offset, x, y, fb->pitches[0 ]);I915_WRITE (DSPSTRIDE (plane), fb->pitches[0 ]);if (INTEL_INFO (dev)->gen >=4 ) {I915_MODIFY_DISPBASE (DSPSURF (plane), - obj->gtt_space->start + +i915_gem_obj_offset (obj) + intel_crtc->dspaddr_offset);I915_WRITE (DSPTILEOFF (plane), (y <<16 ) | x);I915_WRITE (DSPLINOFF (plane), linear_offset); }else I915_WRITE (DSPADDR (plane), - obj->gtt_space->start + linear_offset); +i915_gem_obj_offset (obj) + linear_offset);POSTING_READ (reg);return 0 ;
@@ -2035,11 +2035,11 @@ static int ironlake_update_plane(struct drm_crtc *crtc, linear_offset -= intel_crtc->dspaddr_offset;DRM_DEBUG_KMS ("Writing base %08lX %08lX %d %d %d\n" , - obj->gtt_space->start, linear_offset, x, y, +i915_gem_obj_offset (obj), linear_offset, x, y, fb->pitches[0 ]);I915_WRITE (DSPSTRIDE (plane), fb->pitches[0 ]);I915_MODIFY_DISPBASE (DSPSURF (plane), - obj->gtt_space->start+intel_crtc->dspaddr_offset); +i915_gem_obj_offset (obj)+intel_crtc->dspaddr_offset);if (IS_HASWELL (dev)) {I915_WRITE (DSPOFFSET (plane), (y <<16 ) | x); }else {
@@ -6558,7 +6558,7 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc, goto fail_unpin; } - addr = obj->gtt_space->start; + addr =i915_gem_obj_offset (obj); }else {int align =IS_I830 (dev) ?16 *1024 :256 ; ret = i915_gem_attach_phys_object(dev, obj,
@@ -7274,7 +7274,7 @@ static int intel_gen2_queue_flip(struct drm_device *dev, MI_DISPLAY_FLIP_PLANE(intel_crtc->plane));intel_ring_emit (ring, fb->pitches[0 ]);intel_ring_emit (ring, - obj->gtt_space->start + intel_crtc->dspaddr_offset); +i915_gem_obj_offset (obj) + intel_crtc->dspaddr_offset);intel_ring_emit (ring,0 );/* aux display base address, unused */ intel_mark_page_flip_active (intel_crtc);
@@ -7316,7 +7316,7 @@ static int intel_gen3_queue_flip(struct drm_device *dev, MI_DISPLAY_FLIP_PLANE(intel_crtc->plane));intel_ring_emit (ring, fb->pitches[0 ]);intel_ring_emit (ring, - obj->gtt_space->start + intel_crtc->dspaddr_offset); +i915_gem_obj_offset (obj) + intel_crtc->dspaddr_offset);intel_ring_emit (ring,MI_NOOP );intel_mark_page_flip_active (intel_crtc);
@@ -7356,7 +7356,7 @@ static int intel_gen4_queue_flip(struct drm_device *dev, MI_DISPLAY_FLIP_PLANE(intel_crtc->plane));intel_ring_emit (ring, fb->pitches[0 ]);intel_ring_emit (ring, - (obj->gtt_space->start + intel_crtc->dspaddr_offset) | + (i915_gem_obj_offset (obj) + intel_crtc->dspaddr_offset) | obj->tiling_mode);/* XXX Enabling the panel-fitter across page-flip is so far
@@ -7400,7 +7400,7 @@ static int intel_gen6_queue_flip(struct drm_device *dev, MI_DISPLAY_FLIP_PLANE(intel_crtc->plane));intel_ring_emit (ring, fb->pitches[0 ] | obj->tiling_mode);intel_ring_emit (ring, - obj->gtt_space->start + intel_crtc->dspaddr_offset); +i915_gem_obj_offset (obj) + intel_crtc->dspaddr_offset);/* Contrary to the suggestions in the documentation, * "Enable Panel Fitter" does not seem to be required when page
@@ -7466,7 +7466,7 @@ static int intel_gen7_queue_flip(struct drm_device *dev,intel_ring_emit (ring,MI_DISPLAY_FLIP_I915 | plane_bit);intel_ring_emit (ring, (fb->pitches[0 ] | obj->tiling_mode));intel_ring_emit (ring, - obj->gtt_space->start + intel_crtc->dspaddr_offset); +i915_gem_obj_offset (obj) + intel_crtc->dspaddr_offset);intel_ring_emit (ring, (MI_NOOP ));intel_mark_page_flip_active (intel_crtc);
drivers/gpu/drm/i915/intel_fb.c +3 -3
@@ -139,11 +139,11 @@ static int intelfb_create(struct drm_fb_helper *helper, info->apertures->ranges[0 ].base = dev->mode_config.fb_base; info->apertures->ranges[0 ].size = dev_priv->gtt.mappable_end; - info->fix.smem_start = dev->mode_config.fb_base + obj->gtt_space->start; + info->fix.smem_start = dev->mode_config.fb_base +i915_gem_obj_offset (obj); info->fix.smem_len = size; info->screen_base = -ioremap_wc (dev_priv->gtt.mappable_base + obj->gtt_space->start, +ioremap_wc (dev_priv->gtt.mappable_base +i915_gem_obj_offset (obj), size);if (!info->screen_base) { ret = -ENOSPC ;
@@ -168,7 +168,7 @@ static int intelfb_create(struct drm_fb_helper *helper,DRM_DEBUG_KMS ("allocated %dx%d fb: 0x%08lx, bo %p\n" , fb->width, fb->height, - obj->gtt_space->start, obj); +i915_gem_obj_offset (obj), obj);mutex_unlock (&dev->struct_mutex);
drivers/gpu/drm/i915/intel_overlay.c +8 -7
@@ -196,7 +196,7 @@ intel_overlay_map_regs(struct intel_overlay *overlay) regs = (struct overlay_registers __iomem *)overlay->reg_bo->phys_obj->handle->vaddr; else regs =io_mapping_map_wc (dev_priv->gtt.mappable, - overlay->reg_bo->gtt_space->start); +i915_gem_obj_offset (overlay->reg_bo));return regs; }
@@ -740,7 +740,8 @@ static int intel_overlay_do_put_image(struct intel_overlay *overlay, swidth = params->src_w; swidthsw =calc_swidthsw (overlay->dev, params->offset_Y, tmp_width); sheight = params->src_h; -iowrite32 (new_bo->gtt_space->start + params->offset_Y, ®s->OBUF_0Y); +iowrite32 (i915_gem_obj_offset (new_bo) + params->offset_Y, + ®s->OBUF_0Y); ostride = params->stride_Y;if (params->format &I915_OVERLAY_YUV_PLANAR ) {
@@ -754,9 +755,9 @@ static int intel_overlay_do_put_image(struct intel_overlay *overlay, params->src_w/uv_hscale); swidthsw |=max_t (u32, tmp_U, tmp_V) <<16 ; sheight |= (params->src_h/uv_vscale) <<16 ; -iowrite32 (new_bo->gtt_space->start + params->offset_U, +iowrite32 (i915_gem_obj_offset (new_bo) + params->offset_U, ®s->OBUF_0U); -iowrite32 (new_bo->gtt_space->start + params->offset_V, +iowrite32 (i915_gem_obj_offset (new_bo) + params->offset_V, ®s->OBUF_0V); ostride |= params->stride_UV <<16 ; }
@@ -1357,7 +1358,7 @@ void intel_setup_overlay(struct drm_device *dev)DRM_ERROR ("failed to pin overlay register bo\n" ); goto out_free_bo; } - overlay->flip_addr = reg_bo->gtt_space->start; + overlay->flip_addr =i915_gem_obj_offset (reg_bo); ret =i915_gem_object_set_to_gtt_domain (reg_bo, true);if (ret) {
@@ -1436,7 +1437,7 @@ intel_overlay_map_regs_atomic(struct intel_overlay *overlay) overlay->reg_bo->phys_obj->handle->vaddr;return io_mapping_map_atomic_wc (dev_priv->gtt.mappable, - overlay->reg_bo->gtt_space->start); +i915_gem_obj_offset (overlay->reg_bo)); } static void intel_overlay_unmap_regs_atomic(struct intel_overlay *overlay,
@@ -1467,7 +1468,7 @@ intel_overlay_capture_error_state(struct drm_device *dev)if (OVERLAY_NEEDS_PHYSICAL (overlay->dev)) error->base = (__force long )overlay->reg_bo->phys_obj->handle->vaddr;else - error->base = overlay->reg_bo->gtt_space->start; + error->base =i915_gem_obj_offset (overlay->reg_bo); regs =intel_overlay_map_regs_atomic (overlay);if (!regs)
drivers/gpu/drm/i915/intel_pm.c +4 -3
@@ -217,7 +217,7 @@ static void ironlake_enable_fbc(struct drm_crtc *crtc, unsigned long interval) (stall_watermark <<DPFC_RECOMP_STALL_WM_SHIFT ) | (interval << DPFC_RECOMP_TIMER_COUNT_SHIFT));I915_WRITE (ILK_DPFC_FENCE_YOFF , crtc->y); -I915_WRITE (ILK_FBC_RT_BASE , obj->gtt_space->start |ILK_FBC_RT_VALID ); +I915_WRITE (ILK_FBC_RT_BASE ,i915_gem_obj_offset (obj) |ILK_FBC_RT_VALID );/* enable it... */ I915_WRITE (ILK_DPFC_CONTROL , dpfc_ctl |DPFC_CTL_EN );
@@ -3685,7 +3685,7 @@ static void ironlake_enable_rc6(struct drm_device *dev)intel_ring_emit (ring,MI_SUSPEND_FLUSH |MI_SUSPEND_FLUSH_EN );intel_ring_emit (ring,MI_SET_CONTEXT ); - intel_ring_emit(ring, dev_priv->ips.renderctx->gtt_space->start | + intel_ring_emit(ring, i915_gem_obj_offset(dev_priv->ips.renderctx) | MI_MM_SPACE_GTT | MI_SAVE_EXT_STATE_EN | MI_RESTORE_EXT_STATE_EN |
@@ -3708,7 +3708,8 @@ static void ironlake_enable_rc6(struct drm_device *dev)return ; } -I915_WRITE (PWRCTXA , dev_priv->ips.pwrctx->gtt_space->start |PWRCTX_EN ); +I915_WRITE (PWRCTXA ,i915_gem_obj_offset (dev_priv->ips.pwrctx) | +PWRCTX_EN );I915_WRITE (RSTDBYCTL ,I915_READ (RSTDBYCTL ) & ~RCX_SW_EXIT ); }
drivers/gpu/drm/i915/intel_ringbuffer.c +6 -6
@@ -424,14 +424,14 @@ static int init_ring_common(struct intel_ring_buffer *ring)* registers with the above sequence (the readback of the HEAD registers * also enforces ordering), otherwise the hw might lose the new ring * register values. */ -I915_WRITE_START (ring, obj->gtt_space->start); +I915_WRITE_START (ring,i915_gem_obj_offset (obj));I915_WRITE_CTL (ring, ((ring->size -PAGE_SIZE ) &RING_NR_PAGES ) |RING_VALID );/* If the head is still not zero, the ring is dead */ if (wait_for ((I915_READ_CTL (ring) &RING_VALID ) !=0 && -I915_READ_START (ring) == obj->gtt_space->start && +I915_READ_START (ring) ==i915_gem_obj_offset (obj) && (I915_READ_HEAD (ring) &HEAD_ADDR ) ==0 ,50 )) { DRM_ERROR("%s initialization failed " "ctl %08x head %08x tail %08x start %08x\n",
@@ -489,7 +489,7 @@ init_pipe_control(struct intel_ring_buffer *ring)if (ret) goto err_unref; - pc->gtt_offset = obj->gtt_space->start; + pc->gtt_offset =i915_gem_obj_offset (obj); pc->cpu_page =kmap (sg_page (obj->pages->sgl));if (pc->cpu_page ==NULL ) { ret = -ENOMEM ;
@@ -1129,7 +1129,7 @@ i830_dispatch_execbuffer(struct intel_ring_buffer *ring,intel_ring_advance (ring); }else {struct drm_i915_gem_object *obj = ring->private; -u32 cs_offset = obj->gtt_space->start; +u32 cs_offset =i915_gem_obj_offset (obj);if (len >I830_BATCH_LIMIT )return -ENOSPC ;
@@ -1214,7 +1214,7 @@ static int init_status_page(struct intel_ring_buffer *ring) goto err_unref; } - ring->status_page.gfx_addr = obj->gtt_space->start; + ring->status_page.gfx_addr =i915_gem_obj_offset (obj); ring->status_page.page_addr =kmap (sg_page (obj->pages->sgl));if (ring->status_page.page_addr ==NULL ) { ret = -ENOMEM ;
@@ -1308,7 +1308,7 @@ static int intel_init_ring_buffer(struct drm_device *dev, goto err_unpin; ring->virtual_start = -ioremap_wc (dev_priv->gtt.mappable_base + obj->gtt_space->start, +ioremap_wc (dev_priv->gtt.mappable_base +i915_gem_obj_offset (obj), ring->size);if (ring->virtual_start ==NULL ) {DRM_ERROR ("Failed to map ringbuffer.\n" );
drivers/gpu/drm/i915/intel_sprite.c +3 -3
@@ -133,7 +133,7 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_framebuffer *fb,I915_WRITE (SPSIZE (pipe, plane), (crtc_h <<16 ) | crtc_w);I915_WRITE (SPCNTR (pipe, plane), sprctl); -I915_MODIFY_DISPBASE (SPSURF (pipe, plane), obj->gtt_space->start + +I915_MODIFY_DISPBASE (SPSURF (pipe, plane),i915_gem_obj_offset (obj) + sprsurf_offset);POSTING_READ (SPSURF (pipe, plane)); }
@@ -309,7 +309,7 @@ ivb_update_plane(struct drm_plane *plane, struct drm_framebuffer *fb,I915_WRITE (SPRSCALE (pipe), sprscale);I915_WRITE (SPRCTL (pipe), sprctl);I915_MODIFY_DISPBASE (SPRSURF (pipe), - obj->gtt_space->start + sprsurf_offset); +i915_gem_obj_offset (obj) + sprsurf_offset);POSTING_READ (SPRSURF (pipe));/* potentially re-enable LP watermarks */
@@ -480,7 +480,7 @@ ilk_update_plane(struct drm_plane *plane, struct drm_framebuffer *fb,I915_WRITE (DVSSCALE (pipe), dvsscale);I915_WRITE (DVSCNTR (pipe), dvscntr);I915_MODIFY_DISPBASE (DVSSURF (pipe), - obj->gtt_space->start + dvssurf_offset); +i915_gem_obj_offset (obj) + dvssurf_offset);POSTING_READ (DVSSURF (pipe)); }
Signature · 1 line
1.8.3.1
Re: [PATCH 30/66] drm/i915: Getter/setter for object attributes
Quoted 4 lines · Ben Widawsky
This will be handy when we add VMs. It's not strictly, necessary, but it will make the code much cleaner.
Signed-off-by Ben Widawsky <[email protected]>
You're going to hate, but this is patch ordering fail. Imo this should be one of the very first patches, at least before you kill obj->gtt_offset.
To increase your hatred some more, I have bikesheds on the names, too.
I think the best would be to respin this patch and merge it right away. It'll cause tons of conflicts. But keeping it as no. 30 in this series will be even worse, since merging the first 30 patches won't happen instantly. So much more potential for rebase hell imo.
The MO for when you stumble over such a giant renaming operation should be imo to submit the "add inline abstraction functions" patch(es) right away. That way everyone else who potentially works in the same area also gets a heads up.
drivers/gpu/drm/i915/i915_drv.h struct drm_i915_gem_object { · line 1355
Quoted 12 lines
drivers/gpu/drm/i915/i915_drv.h +4
-0@@ -1349,6 +1349,27 @@ struct drm_i915_gem_object {#define to_intel_bo (x) container_of(x, struct drm_i915_gem_object, base) +static inline unsigned long i915_gem_obj_offset (struct drm_i915_gem_object *o) +{ +return o->gtt_space->start; +}
To differentiate from the ppgtt offset I'd call this i915_gem_obj_ggtt_offset.
drivers/gpu/drm/i915/i915_drv.h struct drm_i915_gem_object { · line 1360
Quoted 5 lines
drivers/gpu/drm/i915/i915_drv.h +5
-0+ +static inline bool i915_gem_obj_bound (struct drm_i915_gem_object *o) +{ +return o->gtt_space !=NULL ; +}
Same here, I think we want ggtt inserted.
drivers/gpu/drm/i915/i915_drv.h struct drm_i915_gem_object { · line 1365
Quoted 5 lines
drivers/gpu/drm/i915/i915_drv.h +5
-0+ +static inline unsigned long i915_gem_obj_size (struct drm_i915_gem_object *o) +{ +return o->gtt_space->size; +}
This is even more misleading and the real reasons I vote for all the ggtt
bikesheds: ggtt_size != obj->size is very much possible (on gen2/3 only though). We use that to satisfy alignment/size constraints on tiled objects. So the i915_gem_obj_ggtt_size rename is mandatory here.
drivers/gpu/drm/i915/i915_drv.h struct drm_i915_gem_object { · line 1371
Quoted 6 lines
drivers/gpu/drm/i915/i915_drv.h +6
-0+ +static inline void i915_gem_obj_set_color (struct drm_i915_gem_object *o, +enum i915_cache_level color) +{ + o->gtt_space->color = color; +}
Dito for consistency.
Cheers, Daniel
Quoted 850 lines
drivers/gpu/drm/i915/i915_drv.h +1
-0+/** * Request queue structure. * drivers/gpu/drm/i915/i915_gem.c +35
-34@@ -135,7 +135,7 @@ int i915_mutex_lock_interruptible(struct drm_device *dev)static inline bool i915_gem_object_is_inactive (struct drm_i915_gem_object *obj) { -return obj->gtt_space && !obj->active; +return i915_gem_obj_bound (obj) && !obj->active; }int @@ -178,7 +178,7 @@ i915_gem_get_aperture_ioctl(struct drm_device *dev, void *data,mutex_lock (&dev->struct_mutex);list_for_each_entry (obj, &dev_priv->mm.bound_list, global_list)if (obj->pin_count) - pinned += obj->gtt_space->size; + pinned +=i915_gem_obj_size (obj);mutex_unlock (&dev->struct_mutex); args->aper_size = i915_gtt_vm->total;@@ -422,7 +422,7 @@ i915_gem_shmem_pread(struct drm_device *dev,* anyway again before the next pread happens. */ if (obj->cache_level ==I915_CACHE_NONE ) needs_clflush =1 ; -if (obj->gtt_space) { +if (i915_gem_obj_bound (obj)) { ret =i915_gem_object_set_to_gtt_domain (obj, false);if (ret)return ret;@@ -609,7 +609,7 @@ i915_gem_gtt_pwrite_fast(struct drm_device *dev, user_data =to_user_ptr (args->data_ptr); remain = args->size; - offset = obj->gtt_space->start + args->offset; + offset =i915_gem_obj_offset (obj) + args->offset;while (remain >0 ) {/* Operation in this page @@ -739,7 +739,7 @@ i915_gem_shmem_pwrite(struct drm_device *dev,* right away and we therefore have to clflush anyway. */ if (obj->cache_level ==I915_CACHE_NONE ) needs_clflush_after =1 ; -if (obj->gtt_space) { +if (i915_gem_obj_bound (obj)) { ret =i915_gem_object_set_to_gtt_domain (obj, true);if (ret)return ret;@@ -1361,7 +1361,7 @@ int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf) obj->fault_mappable = true; - pfn += (obj->gtt_space->start >>PAGE_SHIFT ) + page_offset; + pfn += (i915_gem_obj_offset (obj) >>PAGE_SHIFT ) + page_offset;/* Finally, remap it using the new GTT offset */ ret =vm_insert_pfn (vma, (unsigned long )vmf->virtual_address, pfn);@@ -1667,7 +1667,7 @@ i915_gem_object_put_pages(struct drm_i915_gem_object *obj)if (obj->pages ==NULL )return 0 ; -BUG_ON (obj->gtt_space); +BUG_ON (i915_gem_obj_bound (obj));if (obj->pages_pin_count)return -EBUSY ;@@ -2587,7 +2587,7 @@ i915_gem_object_unbind(struct drm_i915_gem_object *obj)drm_i915_private_t *dev_priv = obj->base.dev->dev_private;int ret; -if (obj->gtt_space ==NULL ) +if (!i915_gem_obj_bound (obj))return 0 ;if (obj->pin_count)@@ -2669,11 +2669,11 @@ static void i965_write_fence_reg(struct drm_device *dev, int reg, }if (obj) { -u32 size = obj->gtt_space->size; +u32 size =i915_gem_obj_size (obj); - val = (uint64_t )((obj->gtt_space->start + size -4096 ) & + val = (uint64_t )((i915_gem_obj_offset (obj) + size -4096 ) &0xfffff000 ) <<32 ; - val |= obj->gtt_space->start &0xfffff000 ; + val |=i915_gem_obj_offset (obj) &0xfffff000 ; val |= (uint64_t )((obj->stride /128 ) -1 ) << fence_pitch_shift;if (obj->tiling_mode ==I915_TILING_Y ) val |=1 <<I965_FENCE_TILING_Y_SHIFT ;@@ -2693,15 +2693,15 @@ static void i915_write_fence_reg(struct drm_device *dev, int reg,u32 val;if (obj) { -u32 size = obj->gtt_space->size; +u32 size =i915_gem_obj_size (obj);int pitch_val;int tile_width; -WARN ((obj->gtt_space->start & ~I915_FENCE_START_MASK ) || +WARN ((i915_gem_obj_offset (obj) & ~I915_FENCE_START_MASK ) || (size & -size) != size || - (obj->gtt_space->start & (size -1 )), + (i915_gem_obj_offset (obj) & (size -1 )),"object 0x%08lx [fenceable? %d] not 1M or pot-size (0x%08x) aligned\n" , - obj->gtt_space->start, obj->map_and_fenceable, size); +i915_gem_obj_offset (obj), obj->map_and_fenceable, size);if (obj->tiling_mode ==I915_TILING_Y &&HAS_128_BYTE_Y_TILING (dev)) tile_width =128 ;@@ -2712,7 +2712,7 @@ static void i915_write_fence_reg(struct drm_device *dev, int reg, pitch_val = obj->stride / tile_width; pitch_val =ffs (pitch_val) -1 ; - val = obj->gtt_space->start; + val =i915_gem_obj_offset (obj);if (obj->tiling_mode ==I915_TILING_Y ) val |=1 <<I830_FENCE_TILING_Y_SHIFT ; val |=I915_FENCE_SIZE_BITS (size);@@ -2737,19 +2737,19 @@ static void i830_write_fence_reg(struct drm_device *dev, int reg,uint32_t val;if (obj) { -u32 size = obj->gtt_space->size; +u32 size =i915_gem_obj_size (obj);uint32_t pitch_val; -WARN ((obj->gtt_space->start & ~I830_FENCE_START_MASK ) || +WARN ((i915_gem_obj_offset (obj) & ~I830_FENCE_START_MASK ) || (size & -size) != size || - (obj->gtt_space->start & (size -1 )), + (i915_gem_obj_offset (obj) & (size -1 )),"object 0x%08lx not 512K or pot-size 0x%08x aligned\n" , - obj->gtt_space->start, size); +i915_gem_obj_offset (obj), size); pitch_val = obj->stride /128 ; pitch_val =ffs (pitch_val) -1 ; - val = obj->gtt_space->start; + val =i915_gem_obj_offset (obj);if (obj->tiling_mode ==I915_TILING_Y ) val |=1 <<I830_FENCE_TILING_Y_SHIFT ; val |=I830_FENCE_SIZE_BITS (size);@@ -3030,6 +3030,7 @@ static void i915_gem_verify_gtt(struct drm_device *dev)int err =0 ;list_for_each_entry (obj, &dev_priv->mm.gtt_list, global_list) { +unsigned long obj_offset =i915_gem_obj_offset (obj);if (obj->gtt_space ==NULL ) {printk (KERN_ERR "object found on GTT list with no space reserved\n" ); err++;@@ -3038,8 +3039,8 @@ static void i915_gem_verify_gtt(struct drm_device *dev)if (obj->cache_level != obj->gtt_space->color) {printk (KERN_ERR "object reserved space [%08lx, %08lx] with wrong color, cache_level=%x, color=%lx\n" , - obj->gtt_space->start, - obj->gtt_space->start + obj->gtt_space->size, + obj_offset, + obj_offset +i915_gem_obj_size (obj), obj->cache_level, obj->gtt_space->color); err++;@@ -3050,8 +3051,8 @@ static void i915_gem_verify_gtt(struct drm_device *dev) obj->gtt_space, obj->cache_level)) {printk (KERN_ERR "invalid GTT space found at [%08lx, %08lx] - color=%x\n" , - obj->gtt_space->start, - obj->gtt_space->start + obj->gtt_space->size, + obj_offset, + obj_offset +i915_gem_obj_size (obj), obj->cache_level); err++;continue ;@@ -3267,7 +3268,7 @@ i915_gem_object_set_to_gtt_domain(struct drm_i915_gem_object *obj, bool write)int ret;/* Not valid to be called on unbound objects. */ -if (obj->gtt_space ==NULL ) +if (!i915_gem_obj_bound (obj))return -EINVAL ;if (obj->base.write_domain ==I915_GEM_DOMAIN_GTT )@@ -3332,7 +3333,7 @@ int i915_gem_object_set_cache_level(struct drm_i915_gem_object *obj,return ret; } -if (obj->gtt_space) { +if (i915_gem_obj_bound (obj)) { ret =i915_gem_object_finish_gpu (obj);if (ret)return ret;@@ -3355,7 +3356,7 @@ int i915_gem_object_set_cache_level(struct drm_i915_gem_object *obj,i915_ppgtt_bind_object (dev_priv->gtt.aliasing_ppgtt, obj, cache_level); - obj->gtt_space->color = cache_level; +i915_gem_obj_set_color (obj, cache_level); }if (cache_level ==I915_CACHE_NONE ) {@@ -3636,14 +3637,14 @@ i915_gem_object_pin(struct drm_i915_gem_object *obj,if (WARN_ON (obj->pin_count ==DRM_I915_GEM_OBJECT_MAX_PIN_COUNT ))return -EBUSY ; -if (obj->gtt_space !=NULL ) { -if ((alignment && obj->gtt_space->start & (alignment -1 )) || +if (i915_gem_obj_bound (obj)) { +if ((alignment &&i915_gem_obj_offset (obj) & (alignment -1 )) || (map_and_fenceable && !obj->map_and_fenceable)) {WARN (obj->pin_count,"bo is already pinned with incorrect alignment:" " offset=%lx, req.alignment=%x, req.map_and_fenceable=%d," " obj->map_and_fenceable=%d\n" , - obj->gtt_space->start, alignment, +i915_gem_obj_offset (obj), alignment, map_and_fenceable, obj->map_and_fenceable); ret =i915_gem_object_unbind (obj);@@ -3652,7 +3653,7 @@ i915_gem_object_pin(struct drm_i915_gem_object *obj, } } -if (obj->gtt_space ==NULL ) { +if (!i915_gem_obj_bound (obj)) {struct drm_i915_private *dev_priv = obj->base.dev->dev_private; ret = i915_gem_object_bind_to_gtt(obj, alignment,@@ -3678,7 +3679,7 @@ void i915_gem_object_unpin(struct drm_i915_gem_object *obj) {BUG_ON (obj->pin_count ==0 ); -BUG_ON (obj->gtt_space ==NULL ); +BUG_ON (!i915_gem_obj_bound (obj));if (--obj->pin_count ==0 ) obj->pin_mappable = false;@@ -3728,7 +3729,7 @@ i915_gem_pin_ioctl(struct drm_device *dev, void *data,* as the X server doesn't manage domains yet */ i915_gem_object_flush_cpu_write_domain (obj); - args->offset = obj->gtt_space->start; + args->offset =i915_gem_obj_offset (obj); out:drm_gem_object_unreference (&obj->base); unlock:drivers/gpu/drm/i915/i915_gem_context.c +1
-1@@ -395,7 +395,7 @@ mi_set_context(struct intel_ring_buffer *ring,intel_ring_emit (ring,MI_NOOP );intel_ring_emit (ring,MI_SET_CONTEXT ); - intel_ring_emit(ring, new_context->obj->gtt_space->start | + intel_ring_emit(ring, i915_gem_obj_offset(new_context->obj) | MI_MM_SPACE_GTT | MI_SAVE_EXT_STATE_EN | MI_RESTORE_EXT_STATE_EN |drivers/gpu/drm/i915/i915_gem_execbuffer.c +11
-9@@ -188,7 +188,7 @@ i915_gem_execbuffer_relocate_entry(struct drm_i915_gem_object *obj,return -ENOENT ; target_i915_obj =to_intel_bo (target_obj); - target_offset = target_i915_obj->gtt_space->start; + target_offset =i915_gem_obj_offset (target_i915_obj);/* Sandybridge PPGTT errata: We need a global gtt mapping for MI and * pipe_control writes because the gpu doesn't properly redirect them @@ -280,7 +280,7 @@ i915_gem_execbuffer_relocate_entry(struct drm_i915_gem_object *obj,return ret;/* Map the page containing the relocation we're going to perform. */ - reloc->offset += obj->gtt_space->start; + reloc->offset +=i915_gem_obj_offset (obj); reloc_page =io_mapping_map_atomic_wc (dev_priv->gtt.mappable, reloc->offset &PAGE_MASK ); reloc_entry = (uint32_t __iomem *)@@ -436,8 +436,8 @@ i915_gem_execbuffer_reserve_object(struct drm_i915_gem_object *obj, obj->has_aliasing_ppgtt_mapping =1 ; } -if (entry->offset != obj->gtt_space->start) { - entry->offset = obj->gtt_space->start; +if (entry->offset !=i915_gem_obj_offset (obj)) { + entry->offset =i915_gem_obj_offset (obj); *need_reloc = true; }@@ -458,7 +458,7 @@ i915_gem_execbuffer_unreserve_object(struct drm_i915_gem_object *obj) {struct drm_i915_gem_exec_object2 *entry; -if (!obj->gtt_space) +if (!i915_gem_obj_bound (obj))return ; entry = obj->exec_entry;@@ -528,11 +528,13 @@ i915_gem_execbuffer_reserve(struct intel_ring_buffer *ring,/* Unbind any ill-fitting objects or pin. */ list_for_each_entry (obj, objects, exec_list) {struct drm_i915_gem_exec_object2 *entry = obj->exec_entry; +unsigned long obj_offset;bool need_fence, need_mappable; -if (!obj->gtt_space) +if (!i915_gem_obj_bound (obj))continue ; + obj_offset =i915_gem_obj_offset (obj); need_fence = has_fenced_gpu_access && entry->flags & EXEC_OBJECT_NEEDS_FENCE &&@@ -540,7 +542,7 @@ i915_gem_execbuffer_reserve(struct intel_ring_buffer *ring, need_mappable = need_fence ||need_reloc_mappable (obj);if ((entry->alignment && - obj->gtt_space->start & (entry->alignment -1 )) || + obj_offset & (entry->alignment -1 )) || (need_mappable && !obj->map_and_fenceable)) ret =i915_gem_object_unbind (obj);else @@ -551,7 +553,7 @@ i915_gem_execbuffer_reserve(struct intel_ring_buffer *ring,/* Bind fresh objects */ list_for_each_entry (obj, objects, exec_list) { -if (obj->gtt_space) +if (i915_gem_obj_bound (obj))continue ; ret =i915_gem_execbuffer_reserve_object (obj, ring, need_relocs);@@ -1072,7 +1074,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, goto err; } - exec_start = batch_obj->gtt_space->start + args->batch_start_offset; + exec_start =i915_gem_obj_offset (batch_obj) + args->batch_start_offset; exec_len = args->batch_len;if (cliprects) {for (i =0 ; i < args->num_cliprects; i++) {drivers/gpu/drm/i915/i915_gem_gtt.c +7
-5@@ -390,7 +390,7 @@ void i915_ppgtt_bind_object(struct i915_hw_ppgtt *ppgtt, enum i915_cache_level cache_level) { ppgtt->base.insert_entries (&ppgtt->base, obj->pages, - obj->gtt_space->start >>PAGE_SHIFT , +i915_gem_obj_offset (obj) >>PAGE_SHIFT , cache_level); }@@ -398,7 +398,7 @@ void i915_ppgtt_unbind_object(struct i915_hw_ppgtt *ppgtt, struct drm_i915_gem_object *obj) { ppgtt->base.clear_range (&ppgtt->base, - obj->gtt_space->start >>PAGE_SHIFT , +i915_gem_obj_offset (obj) >>PAGE_SHIFT , obj->base.size >>PAGE_SHIFT ); }@@ -570,9 +570,10 @@ void i915_gem_gtt_bind_object(struct drm_i915_gem_object *obj, {struct drm_device *dev = obj->base.dev;struct drm_i915_private *dev_priv = dev->dev_private; +unsigned long obj_offset =i915_gem_obj_offset (obj); i915_gtt_vm->insert_entries (&dev_priv->gtt.base, obj->pages, - obj->gtt_space->start >>PAGE_SHIFT , + obj_offset >>PAGE_SHIFT , cache_level); obj->has_global_gtt_mapping =1 ;@@ -582,9 +583,10 @@ void i915_gem_gtt_unbind_object(struct drm_i915_gem_object *obj) {struct drm_device *dev = obj->base.dev;struct drm_i915_private *dev_priv = dev->dev_private; +unsigned long obj_offset =i915_gem_obj_offset (obj); i915_gtt_vm->clear_range (&dev_priv->gtt.base, - obj->gtt_space->start >>PAGE_SHIFT , + obj_offset >>PAGE_SHIFT , obj->base.size >>PAGE_SHIFT ); obj->has_global_gtt_mapping =0 ;@@ -682,7 +684,7 @@ void i915_gem_setup_global_gtt(struct drm_device *dev,uintptr_t gtt_offset = (uintptr_t )obj->gtt_space;int ret;DRM_DEBUG_KMS ("reserving preallocated space: %lx + %zx\n" , - obj->gtt_space->start, obj->base.size); +i915_gem_obj_offset (obj), obj->base.size);BUG_ON ((gtt_offset &I915_GTT_RESERVED ) ==0 ); gtt_offset = gtt_offset & ~I915_GTT_RESERVED ;drivers/gpu/drm/i915/i915_gem_tiling.c +7
-7@@ -268,18 +268,18 @@ i915_gem_object_fence_ok(struct drm_i915_gem_object *obj, int tiling_mode)return true;if (INTEL_INFO (obj->base.dev)->gen ==3 ) { -if (obj->gtt_space->start & ~I915_FENCE_START_MASK ) +if (i915_gem_obj_offset (obj) & ~I915_FENCE_START_MASK )return false; }else { -if (obj->gtt_space->start & ~I830_FENCE_START_MASK ) +if (i915_gem_obj_offset (obj) & ~I830_FENCE_START_MASK )return false; } size =i915_gem_get_gtt_size (obj->base.dev, obj->base.size, tiling_mode); -if (obj->gtt_space->size != size) +if (i915_gem_obj_size (obj) != size)return false; -if (obj->gtt_space->start & (size -1 )) +if (i915_gem_obj_offset (obj) & (size -1 ))return false;return true;@@ -358,8 +358,8 @@ i915_gem_set_tiling(struct drm_device *dev, void *data,* whilst executing a fenced command for an untiled object. */ - obj->map_and_fenceable = obj->gtt_space ==NULL || - (obj->gtt_space->start + + obj->map_and_fenceable = !i915_gem_obj_bound (obj) || + (i915_gem_obj_offset (obj) + obj->base.size <= dev_priv->gtt.mappable_end &&i915_gem_object_fence_ok (obj, args->tiling_mode));@@ -369,7 +369,7 @@ i915_gem_set_tiling(struct drm_device *dev, void *data,i915_gem_get_gtt_alignment (dev, obj->base.size, args->tiling_mode, false); -if (obj->gtt_space->start & (unfenced_alignment -1 )) +if (i915_gem_obj_offset (obj) & (unfenced_alignment -1 )) ret =i915_gem_object_unbind (obj); }drivers/gpu/drm/i915/i915_irq.c +8
-8@@ -1512,7 +1512,7 @@ i915_error_object_create_sized(struct drm_i915_private *dev_priv,if (dst ==NULL )return NULL ; - reloc_offset = src->gtt_space->start; + reloc_offset =i915_gem_obj_offset (src);for (i =0 ; i < num_pages; i++) {unsigned long flags;void *d;@@ -1564,7 +1564,7 @@ i915_error_object_create_sized(struct drm_i915_private *dev_priv, reloc_offset +=PAGE_SIZE ; } dst->page_count = num_pages; - dst->gtt_offset = src->gtt_space->start; + dst->gtt_offset =i915_gem_obj_offset (src);return dst;@@ -1618,7 +1618,7 @@ static void capture_bo(struct drm_i915_error_buffer *err, err->name = obj->base.name; err->rseqno = obj->last_read_seqno; err->wseqno = obj->last_write_seqno; - err->gtt_offset = obj->gtt_space->start; + err->gtt_offset =i915_gem_obj_offset (obj); err->read_domains = obj->base.read_domains; err->write_domain = obj->base.write_domain; err->fence_reg = obj->fence_reg;@@ -1716,8 +1716,8 @@ i915_error_first_batchbuffer(struct drm_i915_private *dev_priv,return NULL ; obj = ring->private; -if (acthd >= obj->gtt_space->start && - acthd < obj->gtt_space->start + obj->base.size) +if (acthd >=i915_gem_obj_offset (obj) && + acthd <i915_gem_obj_offset (obj) + obj->base.size)return i915_error_object_create (dev_priv, obj); }@@ -1798,7 +1798,7 @@ static void i915_gem_record_active_context(struct intel_ring_buffer *ring,return ;list_for_each_entry (obj, &dev_priv->mm.bound_list, global_list) { -if ((error->ccid &PAGE_MASK ) == obj->gtt_space->start) { +if ((error->ccid &PAGE_MASK ) ==i915_gem_obj_offset (obj)) { ering->ctx =i915_error_object_create_sized (dev_priv, obj,1 ); }@@ -2152,10 +2152,10 @@ static void __always_unused i915_pageflip_stall_check(struct drm_device *dev, inif (INTEL_INFO (dev)->gen >=4 ) {int dspsurf =DSPSURF (intel_crtc->plane); stall_detected =I915_HI_DISPBASE (I915_READ (dspsurf)) == - obj->gtt_space->start; +i915_gem_obj_offset (obj); }else {int dspaddr =DSPADDR (intel_crtc->plane); - stall_detected =I915_READ (dspaddr) == (obj->gtt_space->start + + stall_detected =I915_READ (dspaddr) == (i915_gem_obj_offset (obj) + crtc->y * crtc->fb->pitches[0 ] + crtc->x * crtc->fb->bits_per_pixel/8 ); }drivers/gpu/drm/i915/i915_trace.h +4
-4@@ -46,8 +46,8 @@ TRACE_EVENT(i915_gem_object_bind,TP_fast_assign ( __entry->obj = obj; - __entry->offset = obj->gtt_space->start; - __entry->size = obj->gtt_space->size; + __entry->offset =i915_gem_obj_offset (obj); + __entry->size =i915_gem_obj_size (obj); __entry->mappable = mappable; ),@@ -68,8 +68,8 @@ TRACE_EVENT(i915_gem_object_unbind,TP_fast_assign ( __entry->obj = obj; - __entry->offset = obj->gtt_space->start; - __entry->size = obj->gtt_space->size; + __entry->offset =i915_gem_obj_offset (obj); + __entry->size =i915_gem_obj_size (obj); ), TP_printk("obj=%p, offset=%08x size=%x",drivers/gpu/drm/i915/intel_display.c +11
-11@@ -1943,18 +1943,18 @@ static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb, }DRM_DEBUG_KMS ("Writing base %08lX %08lX %d %d %d\n" , - obj->gtt_space->start, linear_offset, x, y, +i915_gem_obj_offset (obj), linear_offset, x, y, fb->pitches[0 ]);I915_WRITE (DSPSTRIDE (plane), fb->pitches[0 ]);if (INTEL_INFO (dev)->gen >=4 ) {I915_MODIFY_DISPBASE (DSPSURF (plane), - obj->gtt_space->start + +i915_gem_obj_offset (obj) + intel_crtc->dspaddr_offset);I915_WRITE (DSPTILEOFF (plane), (y <<16 ) | x);I915_WRITE (DSPLINOFF (plane), linear_offset); }else I915_WRITE (DSPADDR (plane), - obj->gtt_space->start + linear_offset); +i915_gem_obj_offset (obj) + linear_offset);POSTING_READ (reg);return 0 ;@@ -2035,11 +2035,11 @@ static int ironlake_update_plane(struct drm_crtc *crtc, linear_offset -= intel_crtc->dspaddr_offset;DRM_DEBUG_KMS ("Writing base %08lX %08lX %d %d %d\n" , - obj->gtt_space->start, linear_offset, x, y, +i915_gem_obj_offset (obj), linear_offset, x, y, fb->pitches[0 ]);I915_WRITE (DSPSTRIDE (plane), fb->pitches[0 ]);I915_MODIFY_DISPBASE (DSPSURF (plane), - obj->gtt_space->start+intel_crtc->dspaddr_offset); +i915_gem_obj_offset (obj)+intel_crtc->dspaddr_offset);if (IS_HASWELL (dev)) {I915_WRITE (DSPOFFSET (plane), (y <<16 ) | x); }else {@@ -6558,7 +6558,7 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc, goto fail_unpin; } - addr = obj->gtt_space->start; + addr =i915_gem_obj_offset (obj); }else {int align =IS_I830 (dev) ?16 *1024 :256 ; ret = i915_gem_attach_phys_object(dev, obj,@@ -7274,7 +7274,7 @@ static int intel_gen2_queue_flip(struct drm_device *dev, MI_DISPLAY_FLIP_PLANE(intel_crtc->plane));intel_ring_emit (ring, fb->pitches[0 ]);intel_ring_emit (ring, - obj->gtt_space->start + intel_crtc->dspaddr_offset); +i915_gem_obj_offset (obj) + intel_crtc->dspaddr_offset);intel_ring_emit (ring,0 );/* aux display base address, unused */ intel_mark_page_flip_active (intel_crtc);@@ -7316,7 +7316,7 @@ static int intel_gen3_queue_flip(struct drm_device *dev, MI_DISPLAY_FLIP_PLANE(intel_crtc->plane));intel_ring_emit (ring, fb->pitches[0 ]);intel_ring_emit (ring, - obj->gtt_space->start + intel_crtc->dspaddr_offset); +i915_gem_obj_offset (obj) + intel_crtc->dspaddr_offset);intel_ring_emit (ring,MI_NOOP );intel_mark_page_flip_active (intel_crtc);@@ -7356,7 +7356,7 @@ static int intel_gen4_queue_flip(struct drm_device *dev, MI_DISPLAY_FLIP_PLANE(intel_crtc->plane));intel_ring_emit (ring, fb->pitches[0 ]);intel_ring_emit (ring, - (obj->gtt_space->start + intel_crtc->dspaddr_offset) | + (i915_gem_obj_offset (obj) + intel_crtc->dspaddr_offset) | obj->tiling_mode);/* XXX Enabling the panel-fitter across page-flip is so far @@ -7400,7 +7400,7 @@ static int intel_gen6_queue_flip(struct drm_device *dev, MI_DISPLAY_FLIP_PLANE(intel_crtc->plane));intel_ring_emit (ring, fb->pitches[0 ] | obj->tiling_mode);intel_ring_emit (ring, - obj->gtt_space->start + intel_crtc->dspaddr_offset); +i915_gem_obj_offset (obj) + intel_crtc->dspaddr_offset);/* Contrary to the suggestions in the documentation, * "Enable Panel Fitter" does not seem to be required when page @@ -7466,7 +7466,7 @@ static int intel_gen7_queue_flip(struct drm_device *dev,intel_ring_emit (ring,MI_DISPLAY_FLIP_I915 | plane_bit);intel_ring_emit (ring, (fb->pitches[0 ] | obj->tiling_mode));intel_ring_emit (ring, - obj->gtt_space->start + intel_crtc->dspaddr_offset); +i915_gem_obj_offset (obj) + intel_crtc->dspaddr_offset);intel_ring_emit (ring, (MI_NOOP ));intel_mark_page_flip_active (intel_crtc);drivers/gpu/drm/i915/intel_fb.c +3
-3@@ -139,11 +139,11 @@ static int intelfb_create(struct drm_fb_helper *helper, info->apertures->ranges[0 ].base = dev->mode_config.fb_base; info->apertures->ranges[0 ].size = dev_priv->gtt.mappable_end; - info->fix.smem_start = dev->mode_config.fb_base + obj->gtt_space->start; + info->fix.smem_start = dev->mode_config.fb_base +i915_gem_obj_offset (obj); info->fix.smem_len = size; info->screen_base = -ioremap_wc (dev_priv->gtt.mappable_base + obj->gtt_space->start, +ioremap_wc (dev_priv->gtt.mappable_base +i915_gem_obj_offset (obj), size);if (!info->screen_base) { ret = -ENOSPC ;@@ -168,7 +168,7 @@ static int intelfb_create(struct drm_fb_helper *helper,DRM_DEBUG_KMS ("allocated %dx%d fb: 0x%08lx, bo %p\n" , fb->width, fb->height, - obj->gtt_space->start, obj); +i915_gem_obj_offset (obj), obj);mutex_unlock (&dev->struct_mutex);drivers/gpu/drm/i915/intel_overlay.c +8
-7@@ -196,7 +196,7 @@ intel_overlay_map_regs(struct intel_overlay *overlay) regs = (struct overlay_registers __iomem *)overlay->reg_bo->phys_obj->handle->vaddr; else regs =io_mapping_map_wc (dev_priv->gtt.mappable, - overlay->reg_bo->gtt_space->start); +i915_gem_obj_offset (overlay->reg_bo));return regs; }@@ -740,7 +740,8 @@ static int intel_overlay_do_put_image(struct intel_overlay *overlay, swidth = params->src_w; swidthsw =calc_swidthsw (overlay->dev, params->offset_Y, tmp_width); sheight = params->src_h; -iowrite32 (new_bo->gtt_space->start + params->offset_Y, ®s->OBUF_0Y); +iowrite32 (i915_gem_obj_offset (new_bo) + params->offset_Y, + ®s->OBUF_0Y); ostride = params->stride_Y;if (params->format &I915_OVERLAY_YUV_PLANAR ) {@@ -754,9 +755,9 @@ static int intel_overlay_do_put_image(struct intel_overlay *overlay, params->src_w/uv_hscale); swidthsw |=max_t (u32, tmp_U, tmp_V) <<16 ; sheight |= (params->src_h/uv_vscale) <<16 ; -iowrite32 (new_bo->gtt_space->start + params->offset_U, +iowrite32 (i915_gem_obj_offset (new_bo) + params->offset_U, ®s->OBUF_0U); -iowrite32 (new_bo->gtt_space->start + params->offset_V, +iowrite32 (i915_gem_obj_offset (new_bo) + params->offset_V, ®s->OBUF_0V); ostride |= params->stride_UV <<16 ; }@@ -1357,7 +1358,7 @@ void intel_setup_overlay(struct drm_device *dev)DRM_ERROR ("failed to pin overlay register bo\n" ); goto out_free_bo; } - overlay->flip_addr = reg_bo->gtt_space->start; + overlay->flip_addr =i915_gem_obj_offset (reg_bo); ret =i915_gem_object_set_to_gtt_domain (reg_bo, true);if (ret) {@@ -1436,7 +1437,7 @@ intel_overlay_map_regs_atomic(struct intel_overlay *overlay) overlay->reg_bo->phys_obj->handle->vaddr;return io_mapping_map_atomic_wc (dev_priv->gtt.mappable, - overlay->reg_bo->gtt_space->start); +i915_gem_obj_offset (overlay->reg_bo)); } static void intel_overlay_unmap_regs_atomic(struct intel_overlay *overlay,@@ -1467,7 +1468,7 @@ intel_overlay_capture_error_state(struct drm_device *dev)if (OVERLAY_NEEDS_PHYSICAL (overlay->dev)) error->base = (__force long )overlay->reg_bo->phys_obj->handle->vaddr;else - error->base = overlay->reg_bo->gtt_space->start; + error->base =i915_gem_obj_offset (overlay->reg_bo); regs =intel_overlay_map_regs_atomic (overlay);if (!regs)drivers/gpu/drm/i915/intel_pm.c +4
-3@@ -217,7 +217,7 @@ static void ironlake_enable_fbc(struct drm_crtc *crtc, unsigned long interval) (stall_watermark <<DPFC_RECOMP_STALL_WM_SHIFT ) | (interval << DPFC_RECOMP_TIMER_COUNT_SHIFT));I915_WRITE (ILK_DPFC_FENCE_YOFF , crtc->y); -I915_WRITE (ILK_FBC_RT_BASE , obj->gtt_space->start |ILK_FBC_RT_VALID ); +I915_WRITE (ILK_FBC_RT_BASE ,i915_gem_obj_offset (obj) |ILK_FBC_RT_VALID );/* enable it... */ I915_WRITE (ILK_DPFC_CONTROL , dpfc_ctl |DPFC_CTL_EN );@@ -3685,7 +3685,7 @@ static void ironlake_enable_rc6(struct drm_device *dev)intel_ring_emit (ring,MI_SUSPEND_FLUSH |MI_SUSPEND_FLUSH_EN );intel_ring_emit (ring,MI_SET_CONTEXT ); - intel_ring_emit(ring, dev_priv->ips.renderctx->gtt_space->start | + intel_ring_emit(ring, i915_gem_obj_offset(dev_priv->ips.renderctx) | MI_MM_SPACE_GTT | MI_SAVE_EXT_STATE_EN | MI_RESTORE_EXT_STATE_EN |@@ -3708,7 +3708,8 @@ static void ironlake_enable_rc6(struct drm_device *dev)return ; } -I915_WRITE (PWRCTXA , dev_priv->ips.pwrctx->gtt_space->start |PWRCTX_EN ); +I915_WRITE (PWRCTXA ,i915_gem_obj_offset (dev_priv->ips.pwrctx) | +PWRCTX_EN );I915_WRITE (RSTDBYCTL ,I915_READ (RSTDBYCTL ) & ~RCX_SW_EXIT ); }drivers/gpu/drm/i915/intel_ringbuffer.c +6
-6@@ -424,14 +424,14 @@ static int init_ring_common(struct intel_ring_buffer *ring)* registers with the above sequence (the readback of the HEAD registers * also enforces ordering), otherwise the hw might lose the new ring * register values. */ -I915_WRITE_START (ring, obj->gtt_space->start); +I915_WRITE_START (ring,i915_gem_obj_offset (obj));I915_WRITE_CTL (ring, ((ring->size -PAGE_SIZE ) &RING_NR_PAGES ) |RING_VALID );/* If the head is still not zero, the ring is dead */ if (wait_for ((I915_READ_CTL (ring) &RING_VALID ) !=0 && -I915_READ_START (ring) == obj->gtt_space->start && +I915_READ_START (ring) ==i915_gem_obj_offset (obj) && (I915_READ_HEAD (ring) &HEAD_ADDR ) ==0 ,50 )) { DRM_ERROR("%s initialization failed " "ctl %08x head %08x tail %08x start %08x\n",@@ -489,7 +489,7 @@ init_pipe_control(struct intel_ring_buffer *ring)if (ret) goto err_unref; - pc->gtt_offset = obj->gtt_space->start; + pc->gtt_offset =i915_gem_obj_offset (obj); pc->cpu_page =kmap (sg_page (obj->pages->sgl));if (pc->cpu_page ==NULL ) { ret = -ENOMEM ;@@ -1129,7 +1129,7 @@ i830_dispatch_execbuffer(struct intel_ring_buffer *ring,intel_ring_advance (ring); }else {struct drm_i915_gem_object *obj = ring->private; -u32 cs_offset = obj->gtt_space->start; +u32 cs_offset =i915_gem_obj_offset (obj);if (len >I830_BATCH_LIMIT )return -ENOSPC ;@@ -1214,7 +1214,7 @@ static int init_status_page(struct intel_ring_buffer *ring) goto err_unref; } - ring->status_page.gfx_addr = obj->gtt_space->start; + ring->status_page.gfx_addr =i915_gem_obj_offset (obj); ring->status_page.page_addr =kmap (sg_page (obj->pages->sgl));if (ring->status_page.page_addr ==NULL ) { ret = -ENOMEM ;@@ -1308,7 +1308,7 @@ static int intel_init_ring_buffer(struct drm_device *dev, goto err_unpin; ring->virtual_start = -ioremap_wc (dev_priv->gtt.mappable_base + obj->gtt_space->start, +ioremap_wc (dev_priv->gtt.mappable_base +i915_gem_obj_offset (obj), ring->size);if (ring->virtual_start ==NULL ) {DRM_ERROR ("Failed to map ringbuffer.\n" );drivers/gpu/drm/i915/intel_sprite.c +3
-3@@ -133,7 +133,7 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_framebuffer *fb,I915_WRITE (SPSIZE (pipe, plane), (crtc_h <<16 ) | crtc_w);I915_WRITE (SPCNTR (pipe, plane), sprctl); -I915_MODIFY_DISPBASE (SPSURF (pipe, plane), obj->gtt_space->start + +I915_MODIFY_DISPBASE (SPSURF (pipe, plane),i915_gem_obj_offset (obj) + sprsurf_offset);POSTING_READ (SPSURF (pipe, plane)); }@@ -309,7 +309,7 @@ ivb_update_plane(struct drm_plane *plane, struct drm_framebuffer *fb,I915_WRITE (SPRSCALE (pipe), sprscale);I915_WRITE (SPRCTL (pipe), sprctl);I915_MODIFY_DISPBASE (SPRSURF (pipe), - obj->gtt_space->start + sprsurf_offset); +i915_gem_obj_offset (obj) + sprsurf_offset);POSTING_READ (SPRSURF (pipe));/* potentially re-enable LP watermarks */ @@ -480,7 +480,7 @@ ilk_update_plane(struct drm_plane *plane, struct drm_framebuffer *fb,I915_WRITE (DVSSCALE (pipe), dvsscale);I915_WRITE (DVSCNTR (pipe), dvscntr);I915_MODIFY_DISPBASE (DVSSURF (pipe), - obj->gtt_space->start + dvssurf_offset); +i915_gem_obj_offset (obj) + dvssurf_offset);POSTING_READ (DVSSURF (pipe)); }Signature · 6 lines
1.8.3.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 30/66] drm/i915: Getter/setter for object attributes
Quoted 66 lines · Daniel Vetter
Quoted 4 lines · Ben Widawsky
This will be handy when we add VMs. It's not strictly, necessary, but it will make the code much cleaner.
Signed-off-by Ben Widawsky <[email protected]>You're going to hate, but this is patch ordering fail. Imo this should be one of the very first patches, at least before you kill
obj->gtt_offset.To increase your hatred some more, I have bikesheds on the names, too.
I think the best would be to respin this patch and merge it right away. It'll cause tons of conflicts. But keeping it as no. 30 in this series will be even worse, since merging the first 30 patches won't happen instantly. So much more potential for rebase hell imo.
The MO for when you stumble over such a giant renaming operation should be imo to submit the "add inline abstraction functions" patch(es) right away. That way everyone else who potentially works in the same area also gets a heads up.
drivers/gpu/drm/i915/i915_drv.h struct drm_i915_gem_object { · line 1355
Quoted 12 lines
drivers/gpu/drm/i915/i915_drv.h +4
-0@@ -1349,6 +1349,27 @@ struct drm_i915_gem_object {#define to_intel_bo (x) container_of(x, struct drm_i915_gem_object, base) +static inline unsigned long i915_gem_obj_offset (struct drm_i915_gem_object *o) +{ +return o->gtt_space->start; +}To differentiate from the ppgtt offset I'd call this
i915_gem_obj_ggtt_offset.drivers/gpu/drm/i915/i915_drv.h struct drm_i915_gem_object { · line 1360
Quoted 5 lines
drivers/gpu/drm/i915/i915_drv.h +5
-0+ +static inline bool i915_gem_obj_bound (struct drm_i915_gem_object *o) +{ +return o->gtt_space !=NULL ; +}Same here, I think we want ggtt inserted.
drivers/gpu/drm/i915/i915_drv.h struct drm_i915_gem_object { · line 1365
Quoted 5 lines
drivers/gpu/drm/i915/i915_drv.h +5
-0+ +static inline unsigned long i915_gem_obj_size (struct drm_i915_gem_object *o) +{ +return o->gtt_space->size; +}This is even more misleading and the real reasons I vote for all the ggtt
bikesheds:ggtt_size!=obj->sizeis very much possible (on gen2/3 only though). We use that to satisfy alignment/size constraints on tiled objects. So thei915_gem_obj_ggtt_sizerename is mandatory here.drivers/gpu/drm/i915/i915_drv.h struct drm_i915_gem_object { · line 1371
Quoted 6 lines
drivers/gpu/drm/i915/i915_drv.h +6
-0+ +static inline void i915_gem_obj_set_color (struct drm_i915_gem_object *o, +enum i915_cache_level color) +{ + o->gtt_space->color = color; +}Dito for consistency.
Quoted 3 lines
Cheers, Daniel
All of this is addressed in future patches. As we've discussed, I think I'll have to respin it anyway, so I'll name it as such upfront. To me it felt a little weird to start calling things "ggtt" before I made the separation.
[snip]
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
Re: [PATCH 30/66] drm/i915: Getter/setter for object attributes
Quoted 67 lines · Ben Widawsky
Quoted 66 lines · Daniel Vetter
Quoted 4 lines · Ben Widawsky
This will be handy when we add VMs. It's not strictly, necessary, but it will make the code much cleaner.
Signed-off-by Ben Widawsky <[email protected]>You're going to hate, but this is patch ordering fail. Imo this should be one of the very first patches, at least before you kill
obj->gtt_offset.To increase your hatred some more, I have bikesheds on the names, too.
I think the best would be to respin this patch and merge it right away. It'll cause tons of conflicts. But keeping it as no. 30 in this series will be even worse, since merging the first 30 patches won't happen instantly. So much more potential for rebase hell imo.
The MO for when you stumble over such a giant renaming operation should be imo to submit the "add inline abstraction functions" patch(es) right away. That way everyone else who potentially works in the same area also gets a heads up.
drivers/gpu/drm/i915/i915_drv.h struct drm_i915_gem_object { · line 1355
Quoted 12 lines
drivers/gpu/drm/i915/i915_drv.h +4
-0@@ -1349,6 +1349,27 @@ struct drm_i915_gem_object {#define to_intel_bo (x) container_of(x, struct drm_i915_gem_object, base) +static inline unsigned long i915_gem_obj_offset (struct drm_i915_gem_object *o) +{ +return o->gtt_space->start; +}To differentiate from the ppgtt offset I'd call this
i915_gem_obj_ggtt_offset.drivers/gpu/drm/i915/i915_drv.h struct drm_i915_gem_object { · line 1360
Quoted 5 lines
drivers/gpu/drm/i915/i915_drv.h +5
-0+ +static inline bool i915_gem_obj_bound (struct drm_i915_gem_object *o) +{ +return o->gtt_space !=NULL ; +}Same here, I think we want ggtt inserted.
drivers/gpu/drm/i915/i915_drv.h struct drm_i915_gem_object { · line 1365
Quoted 5 lines
drivers/gpu/drm/i915/i915_drv.h +5
-0+ +static inline unsigned long i915_gem_obj_size (struct drm_i915_gem_object *o) +{ +return o->gtt_space->size; +}This is even more misleading and the real reasons I vote for all the ggtt
bikesheds:ggtt_size!=obj->sizeis very much possible (on gen2/3 only though). We use that to satisfy alignment/size constraints on tiled objects. So thei915_gem_obj_ggtt_sizerename is mandatory here.drivers/gpu/drm/i915/i915_drv.h struct drm_i915_gem_object { · line 1371
Quoted 6 lines
drivers/gpu/drm/i915/i915_drv.h +6
-0+ +static inline void i915_gem_obj_set_color (struct drm_i915_gem_object *o, +enum i915_cache_level color) +{ + o->gtt_space->color = color; +}Dito for consistency.
Quoted 7 lines
Quoted 3 lines
Cheers, Daniel
All of this is addressed in future patches. As we've discussed, I think I'll have to respin it anyway, so I'll name it as such upfront. To me it felt a little weird to start calling things "ggtt" before I made the separation.
I think now that we know what the end result should (more or less at least) look like we can aim to make it right the first time we touch a piece of code. That will reduce the churn in the patch series and so make the beast easier to review.
Imo foreshadowing (to keep consistent with the "a patch series should tell a story" analogy) is perfectly fine, and in many cases helps in understanding the big picture of a large pile of patches. -Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 30/66] drm/i915: Getter/setter for object attributes
Quoted 5 lines · Daniel Vetter
Quoted 4 lines
All of this is addressed in future patches. As we've discussed, I think I'll have to respin it anyway, so I'll name it as such upfront. To me it felt a little weird to start calling things "ggtt" before I made the separation.
Quoted 8 lines
I think now that we know what the end result should (more or less at least) look like we can aim to make it right the first time we touch a piece of code. That will reduce the churn in the patch series and so make the beast easier to review.
Imo foreshadowing (to keep consistent with the "a patch series should tell a story" analogy) is perfectly fine, and in many cases helps in understanding the big picture of a large pile of patches.
I've forgotten to add one thing: If you switch these again later on (layz me didn't check for that) it's imo best to stick with those names (presuming they fit, since the gtt_size vs. obj->size disdinction is a rather important one). Again I think now that we know where to go to it's best to get there with as few intermediate steps as possible.
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 30/66] drm/i915: Getter/setter for object attributes
Quoted 15 lines · Daniel Vetter
Quoted 5 lines · Daniel Vetter
Quoted 4 lines
All of this is addressed in future patches. As we've discussed, I think I'll have to respin it anyway, so I'll name it as such upfront. To me it felt a little weird to start calling things "ggtt" before I made the separation.
Quoted 8 lines
I think now that we know what the end result should (more or less at least) look like we can aim to make it right the first time we touch a piece of code. That will reduce the churn in the patch series and so make the beast easier to review.
Imo foreshadowing (to keep consistent with the "a patch series should tell a story" analogy) is perfectly fine, and in many cases helps in understanding the big picture of a large pile of patches.
Quoted 8 lines
I've forgotten to add one thing: If you switch these again later on (layz me didn't check for that) it's imo best to stick with those names (presuming they fit, since the
gtt_sizevs.obj->sizedisdinction is a rather important one). Again I think now that we know where to go to it's best to get there with as few intermediate steps as possible.
-Daniel
I don't recall object size being very important actually, so I don't think the distinction is too important, but I'm just arguing for the sake of arguing. With the sg page stuff that Imre did, I think most size calculations unrelated to gtt size are there anyway, and most of our mm (not page allocation) code should only ever care about the gtt.
Quoted 4 lines
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
Re: [PATCH 30/66] drm/i915: Getter/setter for object attributes
Quoted 25 lines · Ben Widawsky
Quoted 15 lines · Daniel Vetter
Quoted 5 lines · Daniel Vetter
Quoted 4 lines
All of this is addressed in future patches. As we've discussed, I think I'll have to respin it anyway, so I'll name it as such upfront. To me it felt a little weird to start calling things "ggtt" before I made the separation.
Quoted 8 lines
I think now that we know what the end result should (more or less at least) look like we can aim to make it right the first time we touch a piece of code. That will reduce the churn in the patch series and so make the beast easier to review.
Imo foreshadowing (to keep consistent with the "a patch series should tell a story" analogy) is perfectly fine, and in many cases helps in understanding the big picture of a large pile of patches.
Quoted 8 lines
I've forgotten to add one thing: If you switch these again later on (layz me didn't check for that) it's imo best to stick with those names (presuming they fit, since the
gtt_sizevs.obj->sizedisdinction is a rather important one). Again I think now that we know where to go to it's best to get there with as few intermediate steps as possible.
-Daniel
Quoted 5 lines
I don't recall object size being very important actually, so I don't think the distinction is too important, but I'm just arguing for the sake of arguing. With the sg page stuff that Imre did, I think most size calculations unrelated to gtt size are there anyway, and most of our mm (not page allocation) code should only ever care about the gtt.
The disdinction is only important on gen2/3, which is why you don't recall it being important ;-)
I think you have two options:
- Trust me that it's indeed important.
- Read up on gen2/3 fencing code and make up your own mind.
Cheers, Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 30/66] drm/i915: Getter/setter for object attributes
Quoted 32 lines · Daniel Vetter
Quoted 25 lines · Ben Widawsky
Quoted 15 lines · Daniel Vetter
Quoted 5 lines · Daniel Vetter
Quoted 4 lines
All of this is addressed in future patches. As we've discussed, I think I'll have to respin it anyway, so I'll name it as such upfront. To me it felt a little weird to start calling things "ggtt" before I made the separation.
Quoted 8 lines
I think now that we know what the end result should (more or less at least) look like we can aim to make it right the first time we touch a piece of code. That will reduce the churn in the patch series and so make the beast easier to review.
Imo foreshadowing (to keep consistent with the "a patch series should tell a story" analogy) is perfectly fine, and in many cases helps in understanding the big picture of a large pile of patches.
Quoted 8 lines
I've forgotten to add one thing: If you switch these again later on (layz me didn't check for that) it's imo best to stick with those names (presuming they fit, since the
gtt_sizevs.obj->sizedisdinction is a rather important one). Again I think now that we know where to go to it's best to get there with as few intermediate steps as possible.
-DanielQuoted 5 lines
I don't recall object size being very important actually, so I don't think the distinction is too important, but I'm just arguing for the sake of arguing. With the sg page stuff that Imre did, I think most size calculations unrelated to gtt size are there anyway, and most of our mm (not page allocation) code should only ever care about the gtt.
Quoted 8 lines
The disdinction is only important on gen2/3, which is why you don't recall it being important ;-)
I think you have two options:
- Trust me that it's indeed important.
- Read up on gen2/3 fencing code and make up your own mind.Cheers, Daniel
I am not saying the distinction doesn't exist. I was saying it's not prevalent in too many places. See the second part of my statement, I believe it holds.
But please be clear what you're asking for, do you want 2 getters for vma size vs. obj size?
Quoted 4 lines
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
Re: [PATCH 30/66] drm/i915: Getter/setter for object attributes
Quoted 40 lines · Ben Widawsky
Quoted 39 lines · Daniel Vetter
Quoted 25 lines · Ben Widawsky
Quoted 15 lines · Daniel Vetter
Quoted 5 lines · Daniel Vetter
Quoted 4 lines
All of this is addressed in future patches. As we've discussed, I think I'll have to respin it anyway, so I'll name it as such upfront. To me it felt a little weird to start calling things "ggtt" before I made the separation.
Quoted 8 lines
I think now that we know what the end result should (more or less at least) look like we can aim to make it right the first time we touch a piece of code. That will reduce the churn in the patch series and so make the beast easier to review.
Imo foreshadowing (to keep consistent with the "a patch series should tell a story" analogy) is perfectly fine, and in many cases helps in understanding the big picture of a large pile of patches.
Quoted 8 lines
I've forgotten to add one thing: If you switch these again later on (layz me didn't check for that) it's imo best to stick with those names (presuming they fit, since the
gtt_sizevs.obj->sizedisdinction is a rather important one). Again I think now that we know where to go to it's best to get there with as few intermediate steps as possible.
-DanielQuoted 5 lines
I don't recall object size being very important actually, so I don't think the distinction is too important, but I'm just arguing for the sake of arguing. With the sg page stuff that Imre did, I think most size calculations unrelated to gtt size are there anyway, and most of our mm (not page allocation) code should only ever care about the gtt.
The disdinction is only important on gen2/3, which is why you don't recall it being important ;-)
I think you have two options:
- Trust me that it's indeed important.
- Read up on gen2/3 fencing code and make up your own mind.
Quoted 7 lines
Quoted 1 line
Cheers, Daniel
I am not saying the distinction doesn't exist. I was saying it's not prevalent in too many places. See the second part of my statement, I believe it holds.
But please be clear what you're asking for, do you want 2 getters for vma size vs. obj size?
I guess we need a few different things:
- vma->node.size: Most functions can probably just access that one directly (e.g. for writing the ptes), maybe we need something for transition. I guess we could call it obj_gtt_size since while transition there's only the one gtt address space.
- The obj size in the gtt. Differs from obj->size on gen2/3 for tiled objects (and has pretty funny rules at that how it changes). Mostly important for debugfs, for the gtt stats. Any access helper which just calls this obj_size is imo highly misleading, hence why I've voted for for obj_gtt_size.
- I don't think we need an access helper for obj->size itself, since that is invariant and I don't think we'll move it around either.
Cheers, Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
PATCH 31/66 drm/i915: Create VMAs (part 1)
In reply to Ben WidawskyCreates the VMA, but leaves the old obj->gtt_space in place. This primarily just puts the basic infrastructure in place, and helps check for leaks.
BISECT WARNING: This patch was not meant for bisect. If it does end up upstream, it should be included in the 3 part series for creating the VMA.
v2: s/i915_obj/i915_gem_obj (Chris)
v3: Only move an object to the now global unbound list if there are no more VMAs for the object which are bound into a VM (ie. the list is empty).
--- drivers/gpu/drm/i915/i915_drv.h | 30 ++++++++++++++++++- drivers/gpu/drm/i915/i915_gem.c | 54 ++++++++++++++++++++++++++++++++-- drivers/gpu/drm/i915/i915_gem_evict.c | 8 ++++- drivers/gpu/drm/i915/i915_gem_gtt.c | 3 ++ drivers/gpu/drm/i915/i915_gem_stolen.c | 13 ++++++++ 5 files changed, 104 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +29 -1
@@ -539,6 +539,19 @@ struct i915_hw_ppgtt {void (*cleanup)(struct i915_hw_ppgtt *ppgtt); }; +/* To make things as simple as possible (ie. no refcounting), a VMA's lifetime +* will always be <= an objects lifetime. So object refcounting should cover us. +*/ +struct i915_vma { +struct i915_address_space *vm; +struct drm_i915_gem_object *obj; +struct drm_mm_node node; +/* Page aligned offset (helper for stolen) */ +unsigned long deferred_offset; + +struct list_head vma_link;/* Link in the object's VMA list */ +}; +struct i915_ctx_hang_stats {/* This context had batch pending when hang was declared */ unsigned batch_pending;
@@ -1222,8 +1235,9 @@ struct drm_i915_gem_object {const struct drm_i915_gem_object_ops *ops; -/** Current space allocated to this object in the GTT, if any. */ struct drm_mm_node *gtt_space; +struct list_head vma_list; +/** Stolen memory for this object, instead of being backed by shmem. */ struct drm_mm_node *stolen;struct list_head global_list;
@@ -1351,6 +1365,7 @@ struct drm_i915_gem_object {static inline unsigned long i915_gem_obj_offset (struct drm_i915_gem_object *o) { +BUG_ON (list_empty (&o->vma_list));return o->gtt_space->start; }
@@ -1361,6 +1376,7 @@ static inline bool i915_gem_obj_bound(struct drm_i915_gem_object *o)static inline unsigned long i915_gem_obj_size (struct drm_i915_gem_object *o) { +BUG_ON (list_empty (&o->vma_list));return o->gtt_space->size; }
@@ -1370,6 +1386,16 @@ static inline void i915_gem_obj_set_color(struct drm_i915_gem_object *o, o->gtt_space->color = color; } +/* This is a temporary define to help transition us to real VMAs. If you see +* this, you're either reviewing code, or bisecting it. */ +static inline struct i915_vma * +__i915_gem_obj_to_vma (struct drm_i915_gem_object *obj) +{ +BUG_ON (!i915_gem_obj_bound (obj)); +BUG_ON (list_empty (&obj->vma_list)); + return list_first_entry(&obj->vma_list, struct i915_vma, vma_link); +} +/** * Request queue structure. *
@@ -1680,6 +1706,8 @@ void i915_gem_object_init(struct drm_i915_gem_object *obj,struct drm_i915_gem_object *i915_gem_alloc_object (struct drm_device *dev,size_t size);void i915_gem_free_object (struct drm_gem_object *obj); +struct i915_vma *i915_gem_vma_create (struct drm_i915_gem_object *obj); +void i915_gem_vma_destroy (struct i915_vma *vma); int __must_check i915_gem_object_pin(struct drm_i915_gem_object *obj, uint32_t alignment,
drivers/gpu/drm/i915/i915_gem.c +52 -2
116 lines not on this page · raw message
drivers/gpu/drm/i915/i915_gem_evict.c +7 -1
@@ -38,6 +38,8 @@ mark_free(struct drm_i915_gem_object *obj, struct list_head *unwind)return false;list_add (&obj->exec_list, unwind); +BUG_ON (__i915_gem_obj_to_vma (obj)->node.start != +i915_gem_obj_offset (obj));return drm_mm_scan_add_block (obj->gtt_space); }
@@ -48,6 +50,7 @@ i915_gem_evict_something(struct drm_device *dev, int min_size, {drm_i915_private_t *dev_priv = dev->dev_private;struct list_head eviction_list, unwind_list; +struct i915_vma *vma;struct drm_i915_gem_object *obj;int ret =0 ;
@@ -106,7 +109,8 @@ none: obj =list_first_entry (&unwind_list, struct drm_i915_gem_object, exec_list); - + vma =__i915_gem_obj_to_vma (obj); +BUG_ON (vma->node.start !=i915_gem_obj_offset (obj)); ret =drm_mm_scan_remove_block (obj->gtt_space);BUG_ON (ret);
@@ -127,6 +131,8 @@ found: obj =list_first_entry (&unwind_list, struct drm_i915_gem_object, exec_list); + vma =__i915_gem_obj_to_vma (obj); +BUG_ON (vma->node.start !=i915_gem_obj_offset (obj));if (drm_mm_scan_remove_block (obj->gtt_space)) {list_move (&obj->exec_list, &eviction_list);drm_gem_object_reference (&obj->base);
drivers/gpu/drm/i915/i915_gem_gtt.c +3 -0
@@ -687,6 +687,8 @@ void i915_gem_setup_global_gtt(struct drm_device *dev, i915_gem_obj_offset(obj), obj->base.size);BUG_ON ((gtt_offset &I915_GTT_RESERVED ) ==0 ); +BUG_ON ((__i915_gem_obj_to_vma (obj)->deferred_offset + &I915_GTT_RESERVED ) ==0 ); gtt_offset = gtt_offset & ~I915_GTT_RESERVED ; obj->gtt_space =kzalloc (sizeof (*obj->gtt_space),GFP_KERNEL );if (!obj->gtt_space) {
@@ -700,6 +702,7 @@ void i915_gem_setup_global_gtt(struct drm_device *dev,if (ret)DRM_DEBUG_KMS ("Reservation failed\n" ); obj->has_global_gtt_mapping =1 ; +list_add (&__i915_gem_obj_to_vma (obj)->vma_link, &obj->vma_list); } i915_gtt_vm->start = start;
drivers/gpu/drm/i915/i915_gem_stolen.c +13 -0
@@ -330,6 +330,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,struct drm_i915_private *dev_priv = dev->dev_private;struct drm_i915_gem_object *obj;struct drm_mm_node *stolen; +struct i915_vma *vma;int ret;if (dev_priv->gtt.stolen_base ==0 )
@@ -368,6 +369,12 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,if (gtt_offset ==-1 )return obj; + vma =i915_gem_vma_create (obj); +if (!vma) { +drm_gem_object_unreference (&obj->base); +return NULL ; + } +/* To simplify the initialisation sequence between KMS and GTT, * we allow construction of the stolen object prior to * setting up the GTT space. The actual reservation will occur
@@ -376,6 +383,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,if (drm_mm_initialized (&i915_gtt_vm->mm)) { obj->gtt_space =kzalloc (sizeof (*obj->gtt_space),GFP_KERNEL );if (!obj->gtt_space) { +i915_gem_vma_destroy (vma);drm_gem_object_unreference (&obj->base);return NULL ; }
@@ -383,15 +391,20 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev, gtt_offset, size);if (ret) {DRM_DEBUG_KMS ("failed to allocate stolen GTT space\n" ); +i915_gem_vma_destroy (vma);drm_gem_object_unreference (&obj->base);kfree (obj->gtt_space);return NULL ; } + vma->node.start = obj->gtt_space->start; + vma->node.size = obj->gtt_space->size; obj->gtt_space->start = gtt_offset; +list_add (&vma->vma_link, &obj->vma_list); }else {/* NB: Safe because we assert page alignment */ obj->gtt_space = (struct drm_mm_node *) ((uintptr_t )gtt_offset |I915_GTT_RESERVED ); + vma->deferred_offset = gtt_offset |I915_GTT_RESERVED ; } obj->has_global_gtt_mapping =1 ;
Signature · 1 line
1.8.3.1
PATCH 32/66 drm/i915: Create VMAs (part 2) - kill gtt space
In reply to Ben WidawskyRemove the obj->gtt_space. See if it still works. This validates that what we did in part 1 was correct.
BISECT WARNING: This patch was not meant for bisect. If it does end up upstream, it should be included in the 3 part series for creating the VMA.
--- drivers/gpu/drm/i915/i915_debugfs.c | 2 +- drivers/gpu/drm/i915/i915_drv.h | 16 ++++++++---- drivers/gpu/drm/i915/i915_gem.c | 48 ++++++++++++---------------------- drivers/gpu/drm/i915/i915_gem_evict.c | 13 +++++---- drivers/gpu/drm/i915/i915_gem_gtt.c | 12 +++------ drivers/gpu/drm/i915/i915_gem_stolen.c | 18 ++----------- drivers/gpu/drm/i915/intel_pm.c | 2 +- 7 files changed, 41 insertions(+), 70 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +1 -1
@@ -210,7 +210,7 @@ static int per_file_stats(int id, void *ptr, void *data) stats->count++; stats->total += obj->base.size; -if (obj->gtt_space) { +if (i915_gem_obj_bound (obj)) {if (!list_empty (&obj->ring_list)) stats->active += obj->base.size;else
drivers/gpu/drm/i915/i915_drv.h +11 -5
@@ -1235,7 +1235,6 @@ struct drm_i915_gem_object {const struct drm_i915_gem_object_ops *ops; -struct drm_mm_node *gtt_space;struct list_head vma_list;/** Stolen memory for this object, instead of being backed by shmem. */
@@ -1365,25 +1364,32 @@ struct drm_i915_gem_object {static inline unsigned long i915_gem_obj_offset (struct drm_i915_gem_object *o) { +struct i915_vma *vma;BUG_ON (list_empty (&o->vma_list)); -return o->gtt_space->start; + vma = list_first_entry(&o->vma_list, struct i915_vma, vma_link); +return vma->node.start; }static inline bool i915_gem_obj_bound (struct drm_i915_gem_object *o) { -return o->gtt_space !=NULL ; +return !list_empty (&o->vma_list); }static inline unsigned long i915_gem_obj_size (struct drm_i915_gem_object *o) { +struct i915_vma *vma;BUG_ON (list_empty (&o->vma_list)); -return o->gtt_space->size; + vma = list_first_entry(&o->vma_list, struct i915_vma, vma_link); +return vma->node.size; }static inline void i915_gem_obj_set_color (struct drm_i915_gem_object *o,enum i915_cache_level color) { - o->gtt_space->color = color; +struct i915_vma *vma; +BUG_ON (list_empty (&o->vma_list)); + vma = list_first_entry(&o->vma_list, struct i915_vma, vma_link); + vma->node.color = color; }/* This is a temporary define to help transition us to real VMAs. If you see
drivers/gpu/drm/i915/i915_gem.c +17 -31
117 lines not on this page · raw message
drivers/gpu/drm/i915/i915_gem_evict.c +6 -7
@@ -34,13 +34,13 @@static bool mark_free (struct drm_i915_gem_object *obj,struct list_head *unwind) { +struct i915_vma *vma =__i915_gem_obj_to_vma (obj); +if (obj->pin_count)return false;list_add (&obj->exec_list, unwind); -BUG_ON (__i915_gem_obj_to_vma (obj)->node.start != -i915_gem_obj_offset (obj)); -return drm_mm_scan_add_block (obj->gtt_space); +return drm_mm_scan_add_block (&vma->node); }int
@@ -110,8 +110,7 @@ none: struct drm_i915_gem_object, exec_list); vma =__i915_gem_obj_to_vma (obj); -BUG_ON (vma->node.start !=i915_gem_obj_offset (obj)); - ret =drm_mm_scan_remove_block (obj->gtt_space); + ret =drm_mm_scan_remove_block (&vma->node);BUG_ON (ret);list_del_init (&obj->exec_list);
@@ -128,12 +127,12 @@ found:* temporary list. */ INIT_LIST_HEAD (&eviction_list);while (!list_empty (&unwind_list)) { +struct i915_vma *vma; obj =list_first_entry (&unwind_list, struct drm_i915_gem_object, exec_list); vma =__i915_gem_obj_to_vma (obj); -BUG_ON (vma->node.start !=i915_gem_obj_offset (obj)); -if (drm_mm_scan_remove_block (obj->gtt_space)) { +if (drm_mm_scan_remove_block (&vma->node)) {list_move (&obj->exec_list, &eviction_list);drm_gem_object_reference (&obj->base);continue ;
drivers/gpu/drm/i915/i915_gem_gtt.c +3 -9
@@ -681,22 +681,16 @@ void i915_gem_setup_global_gtt(struct drm_device *dev,/* Mark any preallocated objects as occupied */ list_for_each_entry (obj, &dev_priv->mm.bound_list, global_list) { -uintptr_t gtt_offset = (uintptr_t )obj->gtt_space; +struct i915_vma *vma =__i915_gem_obj_to_vma (obj); +uintptr_t gtt_offset = (uintptr_t )vma->deferred_offset;int ret;DRM_DEBUG_KMS ("reserving preallocated space: %lx + %zx\n" ,i915_gem_obj_offset (obj), obj->base.size);BUG_ON ((gtt_offset &I915_GTT_RESERVED ) ==0 ); -BUG_ON ((__i915_gem_obj_to_vma (obj)->deferred_offset - &I915_GTT_RESERVED ) ==0 ); gtt_offset = gtt_offset & ~I915_GTT_RESERVED ; - obj->gtt_space =kzalloc (sizeof (*obj->gtt_space),GFP_KERNEL ); -if (!obj->gtt_space) { -DRM_ERROR ("Failed to preserve all objects\n" ); -break ; - } ret =drm_mm_create_block (&i915_gtt_vm->mm, - obj->gtt_space, + &vma->node, gtt_offset, obj->base.size);if (ret)
drivers/gpu/drm/i915/i915_gem_stolen.c +2 -16
@@ -381,31 +381,17 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,* later. */ if (drm_mm_initialized (&i915_gtt_vm->mm)) { - obj->gtt_space =kzalloc (sizeof (*obj->gtt_space),GFP_KERNEL ); -if (!obj->gtt_space) { -i915_gem_vma_destroy (vma); -drm_gem_object_unreference (&obj->base); -return NULL ; - } - ret =drm_mm_create_block (&i915_gtt_vm->mm, obj->gtt_space, + ret =drm_mm_create_block (&i915_gtt_vm->mm, &vma->node, gtt_offset, size);if (ret) {DRM_DEBUG_KMS ("failed to allocate stolen GTT space\n" );i915_gem_vma_destroy (vma);drm_gem_object_unreference (&obj->base); -kfree (obj->gtt_space);return NULL ; } - vma->node.start = obj->gtt_space->start; - vma->node.size = obj->gtt_space->size; - obj->gtt_space->start = gtt_offset;list_add (&vma->vma_link, &obj->vma_list); - }else { -/* NB: Safe because we assert page alignment */ - obj->gtt_space = (struct drm_mm_node *) - ((uintptr_t )gtt_offset |I915_GTT_RESERVED ); + }else vma->deferred_offset = gtt_offset |I915_GTT_RESERVED ; - } obj->has_global_gtt_mapping =1 ;
drivers/gpu/drm/i915/intel_pm.c +1 -1
@@ -274,7 +274,7 @@ static void gen7_enable_fbc(struct drm_crtc *crtc, unsigned long interval)struct drm_i915_gem_object *obj = intel_fb->obj;struct intel_crtc *intel_crtc =to_intel_crtc (crtc); -I915_WRITE (IVB_FBC_RT_BASE , obj->gtt_space->start); +I915_WRITE (IVB_FBC_RT_BASE ,i915_gem_obj_offset (obj)); I915_WRITE(ILK_DPFC_CONTROL, DPFC_CTL_EN | DPFC_CTL_LIMIT_1X | IVB_DPFC_CTL_FENCE_EN |
Signature · 1 line
1.8.3.1
PATCH 33/66 drm/i915: Create VMAs (part 3) - plumbing
In reply to Ben WidawskyPlumb the functions we care about with VM arguments.
With the exception of the hack in i915_ppgtt_bind to only ever be able to do aliasing PPGTT, this most everything we want.
v2: Fix purge to pick an object and unbind all vmas This was doable because of the global bound list change.
v3: With the commit to actually pin/unpin pages in place, there is no longer a need to check if unbind succeeded before calling put_pages(). Make put_pages only BUG() after checking pin count.
v4: Rebased on top of the new hangcheck work by Mika plumbed eb_destroy also
Many checkpatch related fixes
--- drivers/gpu/drm/i915/i915_debugfs.c | 59 +++-- drivers/gpu/drm/i915/i915_dma.c | 8 +- drivers/gpu/drm/i915/i915_drv.h | 109 +++++---- drivers/gpu/drm/i915/i915_gem.c | 377 +++++++++++++++++++++-------- drivers/gpu/drm/i915/i915_gem_context.c | 11 +- drivers/gpu/drm/i915/i915_gem_evict.c | 57 +++-- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 87 ++++--- drivers/gpu/drm/i915/i915_gem_gtt.c | 101 ++++---- drivers/gpu/drm/i915/i915_gem_stolen.c | 11 +- drivers/gpu/drm/i915/i915_gem_tiling.c | 19 +- drivers/gpu/drm/i915/i915_irq.c | 27 ++- drivers/gpu/drm/i915/i915_trace.h | 20 +- drivers/gpu/drm/i915/intel_display.c | 22 +- drivers/gpu/drm/i915/intel_fb.c | 6 +- drivers/gpu/drm/i915/intel_overlay.c | 16 +- drivers/gpu/drm/i915/intel_pm.c | 11 +- drivers/gpu/drm/i915/intel_ringbuffer.c | 29 ++- drivers/gpu/drm/i915/intel_sprite.c | 6 +- 18 files changed, 609 insertions(+), 367 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +34 -25
@@ -122,10 +122,14 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)seq_printf (m," (pinned x %d)" , obj->pin_count);if (obj->fence_reg !=I915_FENCE_REG_NONE )seq_printf (m," (fence: %d)" , obj->fence_reg); -if (i915_gem_obj_bound (obj)) -seq_printf (m," (gtt offset: %08lx, size: %08lx)" , -i915_gem_obj_offset (obj), -i915_gem_obj_size (obj)); +if (i915_gem_obj_bound_any (obj)) { +struct i915_vma *vma; +list_for_each_entry (vma, &obj->vma_list, vma_link) { +seq_printf (m," (gtt offset: %08lx, size: %08lx)" , +i915_gem_obj_offset (obj, vma->vm), +i915_gem_obj_size (obj, vma->vm)); + } + }if (obj->stolen)seq_printf (m," (stolen: %08lx)" , obj->stolen->start);if (obj->pin_mappable || obj->fault_mappable) {
@@ -159,11 +163,11 @@ static int i915_gem_object_list_info(struct seq_file *m, void *data)switch (list) {case ACTIVE_LIST :seq_printf (m,"Active:\n" ); - head = &i915_gtt_vm->active_list; + head =ggtt_list (active_list);break ;case INACTIVE_LIST :seq_printf (m,"Inactive:\n" ); - head = &i915_gtt_vm->inactive_list; + head =ggtt_list (inactive_list);break ;default :mutex_unlock (&dev->struct_mutex);
@@ -176,7 +180,8 @@ static int i915_gem_object_list_info(struct seq_file *m, void *data)describe_obj (m, obj);seq_printf (m,"\n" ); total_obj_size += obj->base.size; - total_gtt_size +=i915_gem_obj_size (obj); +/* FIXME: Add size of all VMs */ + total_gtt_size +=i915_gem_ggtt_size (obj); count++; }mutex_unlock (&dev->struct_mutex);
@@ -186,12 +191,13 @@ static int i915_gem_object_list_info(struct seq_file *m, void *data)return 0 ; } +/* FIXME: Support multiple VM? */ #define count_objects (list, member) do { \ list_for_each_entry(obj, list, member) { \ - size += i915_gem_obj_size(obj); \ + size += i915_gem_ggtt_size(obj); \ ++count; \ if (obj->map_and_fenceable) { \ - mappable_size += i915_gem_obj_size(obj); \ + mappable_size += i915_gem_ggtt_size(obj); \ ++mappable_count; \ } \ } \
@@ -210,7 +216,7 @@ static int per_file_stats(int id, void *ptr, void *data) stats->count++; stats->total += obj->base.size; -if (i915_gem_obj_bound (obj)) { +if (i915_gem_obj_bound_any (obj)) {if (!list_empty (&obj->ring_list)) stats->active += obj->base.size;else
@@ -248,12 +254,12 @@ static int i915_gem_object_info(struct seq_file *m, void* data) count, mappable_count, size, mappable_size); size = count = mappable_size = mappable_count =0 ; -count_objects (&i915_gtt_vm->active_list, mm_list); +count_objects (ggtt_list (active_list), mm_list);seq_printf (m," %u [%u] active objects, %zu [%zu] bytes\n" , count, mappable_count, size, mappable_size); size = count = mappable_size = mappable_count =0 ; -count_objects (&i915_gtt_vm->inactive_list, mm_list); +count_objects (ggtt_list (inactive_list), mm_list);seq_printf (m," %u [%u] inactive objects, %zu [%zu] bytes\n" , count, mappable_count, size, mappable_size);
@@ -268,11 +274,11 @@ static int i915_gem_object_info(struct seq_file *m, void* data) size = count = mappable_size = mappable_count =0 ;list_for_each_entry (obj, &dev_priv->mm.bound_list, global_list) {if (obj->fault_mappable) { - size +=i915_gem_obj_size (obj); + size +=i915_gem_ggtt_size (obj); ++count; }if (obj->pin_mappable) { - mappable_size +=i915_gem_obj_size (obj); + mappable_size +=i915_gem_ggtt_size (obj); ++mappable_count; }if (obj->madv ==I915_MADV_DONTNEED ) {
@@ -288,8 +294,8 @@ static int i915_gem_object_info(struct seq_file *m, void* data) count, size);seq_printf (m,"%zu [%lu] gtt total\n" , - i915_gtt_vm->total, - dev_priv->gtt.mappable_end - i915_gtt_vm->start); + dev_priv->gtt.base.total, + dev_priv->gtt.mappable_end - dev_priv->gtt.base.start);seq_printf (m,"\n" );list_for_each_entry_reverse (file, &dev->filelist, lhead) {
@@ -334,7 +340,7 @@ static int i915_gem_gtt_info(struct seq_file *m, void* data)describe_obj (m, obj);seq_printf (m,"\n" ); total_obj_size += obj->base.size; - total_gtt_size +=i915_gem_obj_size (obj); + total_gtt_size +=i915_gem_ggtt_size (obj); count++; }
@@ -381,13 +387,13 @@ static int i915_gem_pageflip_info(struct seq_file *m, void *data)struct drm_i915_gem_object *obj = work->old_fb_obj;if (obj)seq_printf (m,"Old framebuffer gtt_offset 0x%08lx\n" , -i915_gem_obj_offset (obj)); +i915_gem_ggtt_offset (obj)); }if (work->pending_flip_obj) {struct drm_i915_gem_object *obj = work->pending_flip_obj;if (obj)seq_printf (m,"New framebuffer gtt_offset 0x%08lx\n" , -i915_gem_obj_offset (obj)); +i915_gem_ggtt_offset (obj)); } }spin_unlock_irqrestore (&dev->event_lock, flags);
@@ -1980,19 +1986,22 @@ i915_drop_caches_set(void *data, u64 val)i915_gem_retire_requests (dev);if (val &DROP_BOUND ) { -list_for_each_entry_safe (obj, next, &i915_gtt_vm->inactive_list, +/* FIXME: Do this for all vms? */ +list_for_each_entry_safe (obj, next,ggtt_list (inactive_list), mm_list) -if (obj->pin_count ==0 ) { - ret =i915_gem_object_unbind (obj); -if (ret) - goto unlock; - } +if (obj->pin_count) +continue ; + + ret =i915_gem_object_unbind (obj, &dev_priv->gtt.base); +if (ret) + goto unlock; }if (val &DROP_UNBOUND ) {list_for_each_entry_safe (obj, next, &dev_priv->mm.unbound_list, global_list)if (obj->pages_pin_count ==0 ) { +/* FIXME: Do this for all vms? */ ret =i915_gem_object_put_pages (obj);if (ret) goto unlock;
drivers/gpu/drm/i915/i915_dma.c +2 -6
@@ -1363,7 +1363,7 @@ cleanup_gem:i915_gem_cleanup_ringbuffer (dev);i915_gem_context_fini (dev);mutex_unlock (&dev->struct_mutex); -drm_mm_takedown (&i915_gtt_vm->mm); +drm_mm_takedown (&dev_priv->gtt.base.mm); cleanup_irq:drm_irq_uninstall (dev); cleanup_gem_stolen:
@@ -1497,10 +1497,6 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)i915_dump_device_info (dev_priv); -INIT_LIST_HEAD (&dev_priv->vm_list); -INIT_LIST_HEAD (&dev_priv->gtt.base.global_link); -list_add (&dev_priv->gtt.base.global_link, &dev_priv->vm_list); -if (i915_get_bridge_dev (dev)) { ret = -EIO ; goto free_priv;
@@ -1758,7 +1754,7 @@ int i915_driver_unload(struct drm_device *dev) }list_del (&dev_priv->vm_list); -drm_mm_takedown (&i915_gtt_vm->mm); +drm_mm_takedown (&dev_priv->gtt.base.mm);if (dev_priv->regs !=NULL )pci_iounmap (dev->pdev, dev_priv->regs);
drivers/gpu/drm/i915/i915_drv.h +62 -47
170 lines not on this page · raw message
drivers/gpu/drm/i915/i915_gem.c +270 -107
841 lines not on this page · raw message
drivers/gpu/drm/i915/i915_gem_context.c +7 -4
@@ -157,6 +157,7 @@ create_hw_context(struct drm_device *dev,if (INTEL_INFO (dev)->gen >=7 ) { ret =i915_gem_object_set_cache_level (ctx->obj, + &dev_priv->gtt.base,I915_CACHE_LLC_MLC );/* Failure shouldn't ever happen this early */ if (WARN_ON (ret))
@@ -219,7 +220,7 @@ static int create_default_context(struct drm_i915_private *dev_priv)* may not be available. To avoid this we always pin the * default context. */ - ret =i915_gem_object_pin (ctx->obj,CONTEXT_ALIGN , false, false); + ret =i915_gem_ggtt_pin (ctx->obj,CONTEXT_ALIGN , false, false);if (ret) {DRM_DEBUG_DRIVER ("Couldn't pin %d\n" , ret); goto err_destroy;
@@ -395,7 +396,7 @@ mi_set_context(struct intel_ring_buffer *ring,intel_ring_emit (ring,MI_NOOP );intel_ring_emit (ring,MI_SET_CONTEXT ); - intel_ring_emit(ring, i915_gem_obj_offset(new_context->obj) | + intel_ring_emit(ring, i915_gem_ggtt_offset(new_context->obj) | MI_MM_SPACE_GTT | MI_SAVE_EXT_STATE_EN | MI_RESTORE_EXT_STATE_EN |
@@ -416,6 +417,7 @@ mi_set_context(struct intel_ring_buffer *ring,static int do_switch (struct i915_hw_context *to) {struct intel_ring_buffer *ring = to->ring; +struct drm_i915_private *dev_priv = ring->dev->dev_private;struct i915_hw_context *from = ring->last_context;u32 hw_flags =0 ;int ret;
@@ -425,7 +427,7 @@ static int do_switch(struct i915_hw_context *to)if (from == to)return 0 ; - ret =i915_gem_object_pin (to->obj,CONTEXT_ALIGN , false, false); + ret =i915_gem_ggtt_pin (to->obj,CONTEXT_ALIGN , false, false);if (ret)return ret;
@@ -462,7 +464,8 @@ static int do_switch(struct i915_hw_context *to)*/ if (from !=NULL ) { from->obj->base.read_domains =I915_GEM_DOMAIN_INSTRUCTION ; -i915_gem_object_move_to_active (from->obj, ring); +i915_gem_object_move_to_active (from->obj, &dev_priv->gtt.base, + ring);/* As long as MI_SET_CONTEXT is serializing, ie. it flushes the * whole damn pipeline, we don't need to explicitly mark the * object dirty. The only exception is that the context must be
drivers/gpu/drm/i915/i915_gem_evict.c +32 -25
118 lines not on this page · raw message
drivers/gpu/drm/i915/i915_gem_execbuffer.c +54 -33
291 lines not on this page · raw message
drivers/gpu/drm/i915/i915_gem_gtt.c +56 -45
230 lines not on this page · raw message
drivers/gpu/drm/i915/i915_gem_stolen.c +6 -5
@@ -328,6 +328,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev, u32 size) {struct drm_i915_private *dev_priv = dev->dev_private; +struct i915_address_space *gtt_vm = &dev_priv->gtt.base;struct drm_i915_gem_object *obj;struct drm_mm_node *stolen;struct i915_vma *vma;
@@ -369,7 +370,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,if (gtt_offset ==-1 )return obj; - vma =i915_gem_vma_create (obj); + vma =i915_gem_vma_create (obj, gtt_vm);if (!vma) {drm_gem_object_unreference (&obj->base);return NULL ;
@@ -380,9 +381,9 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,* setting up the GTT space. The actual reservation will occur * later. */ -if (drm_mm_initialized (&i915_gtt_vm->mm)) { - ret =drm_mm_create_block (&i915_gtt_vm->mm, &vma->node, - gtt_offset, size); +if (drm_mm_initialized (>t_vm->mm)) { + ret =drm_mm_create_block (>t_vm->mm, &vma->node, gtt_offset, + size);if (ret) {DRM_DEBUG_KMS ("failed to allocate stolen GTT space\n" );i915_gem_vma_destroy (vma);
@@ -396,7 +397,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev, obj->has_global_gtt_mapping =1 ;list_add_tail (&obj->global_list, &dev_priv->mm.bound_list); -list_add_tail (&obj->mm_list, &i915_gtt_vm->inactive_list); +list_add_tail (&obj->mm_list, >t_vm->inactive_list);return obj; }
drivers/gpu/drm/i915/i915_gem_tiling.c +10 -9
@@ -268,18 +268,18 @@ i915_gem_object_fence_ok(struct drm_i915_gem_object *obj, int tiling_mode)return true;if (INTEL_INFO (obj->base.dev)->gen ==3 ) { -if (i915_gem_obj_offset (obj) & ~I915_FENCE_START_MASK ) +if (i915_gem_ggtt_offset (obj) & ~I915_FENCE_START_MASK )return false; }else { -if (i915_gem_obj_offset (obj) & ~I830_FENCE_START_MASK ) +if (i915_gem_ggtt_offset (obj) & ~I830_FENCE_START_MASK )return false; } size =i915_gem_get_gtt_size (obj->base.dev, obj->base.size, tiling_mode); -if (i915_gem_obj_size (obj) != size) +if (i915_gem_ggtt_size (obj) != size)return false; -if (i915_gem_obj_offset (obj) & (size -1 )) +if (i915_gem_ggtt_offset (obj) & (size -1 ))return false;return true;
@@ -358,19 +358,20 @@ i915_gem_set_tiling(struct drm_device *dev, void *data,* whilst executing a fenced command for an untiled object. */ - obj->map_and_fenceable = !i915_gem_obj_bound (obj) || - (i915_gem_obj_offset (obj) + + obj->map_and_fenceable = !i915_gem_obj_bound_ggtt (obj) || + (i915_gem_ggtt_offset (obj) + obj->base.size <= dev_priv->gtt.mappable_end &&i915_gem_object_fence_ok (obj, args->tiling_mode));/* Rebind if we need a change of alignment */ if (!obj->map_and_fenceable) { -u32 unfenced_alignment = +struct i915_address_space *ggtt = &dev_priv->gtt.base; +u32 unfenced_align =i915_gem_get_gtt_alignment (dev, obj->base.size, args->tiling_mode, false); -if (i915_gem_obj_offset (obj) & (unfenced_alignment -1 )) - ret =i915_gem_object_unbind (obj); +if (i915_gem_ggtt_offset (obj) & (unfenced_align -1 )) + ret =i915_gem_object_unbind (obj, ggtt); }if (ret ==0 ) {
drivers/gpu/drm/i915/i915_irq.c +16 -11
@@ -1512,7 +1512,8 @@ i915_error_object_create_sized(struct drm_i915_private *dev_priv,if (dst ==NULL )return NULL ; - reloc_offset =i915_gem_obj_offset (src); +/* FIXME: must handle per faulty VM */ + reloc_offset =i915_gem_ggtt_offset (src);for (i =0 ; i < num_pages; i++) {unsigned long flags;void *d;
@@ -1564,7 +1565,7 @@ i915_error_object_create_sized(struct drm_i915_private *dev_priv, reloc_offset +=PAGE_SIZE ; } dst->page_count = num_pages; - dst->gtt_offset =i915_gem_obj_offset (src); + dst->gtt_offset =i915_gem_ggtt_offset (src);return dst;
@@ -1618,7 +1619,8 @@ static void capture_bo(struct drm_i915_error_buffer *err, err->name = obj->base.name; err->rseqno = obj->last_read_seqno; err->wseqno = obj->last_write_seqno; - err->gtt_offset =i915_gem_obj_offset (obj); +/* FIXME: plumb the actual context into here to pull the right VM */ + err->gtt_offset =i915_gem_ggtt_offset (obj); err->read_domains = obj->base.read_domains; err->write_domain = obj->base.write_domain; err->fence_reg = obj->fence_reg;
@@ -1712,17 +1714,20 @@ i915_error_first_batchbuffer(struct drm_i915_private *dev_priv,if (HAS_BROKEN_CS_TLB (dev_priv->dev)) {u32 acthd =I915_READ (ACTHD ); +if (WARN_ON (HAS_HW_CONTEXTS (dev_priv->dev))) +return NULL ; +if (WARN_ON (ring->id !=RCS ))return NULL ; obj = ring->private; -if (acthd >=i915_gem_obj_offset (obj) && - acthd <i915_gem_obj_offset (obj) + obj->base.size) +if (acthd >=i915_gem_ggtt_offset (obj) && + acthd <i915_gem_ggtt_offset (obj) + obj->base.size)return i915_error_object_create (dev_priv, obj); } seqno = ring->get_seqno (ring, false); -list_for_each_entry (obj, &i915_gtt_vm->active_list, mm_list) { +list_for_each_entry (obj,ggtt_list (active_list), mm_list) {if (obj->ring != ring)continue ;
@@ -1798,7 +1803,7 @@ static void i915_gem_record_active_context(struct intel_ring_buffer *ring,return ;list_for_each_entry (obj, &dev_priv->mm.bound_list, global_list) { -if ((error->ccid &PAGE_MASK ) ==i915_gem_obj_offset (obj)) { +if ((error->ccid &PAGE_MASK ) ==i915_gem_ggtt_offset (obj)) { ering->ctx =i915_error_object_create_sized (dev_priv, obj,1 ); }
@@ -1857,7 +1862,7 @@ static void i915_gem_capture_buffers(struct drm_i915_private *dev_priv,int i; i =0 ; -list_for_each_entry (obj, &i915_gtt_vm->active_list, mm_list) +list_for_each_entry (obj,ggtt_list (active_list), mm_list) i++; error->active_bo_count = i;list_for_each_entry (obj, &dev_priv->mm.bound_list, global_list)
@@ -1877,7 +1882,7 @@ static void i915_gem_capture_buffers(struct drm_i915_private *dev_priv, error->active_bo_count =capture_active_bo (error->active_bo, error->active_bo_count, - &i915_gtt_vm->active_list); +ggtt_list (active_list));if (error->pinned_bo) error->pinned_bo_count =
@@ -2152,10 +2157,10 @@ static void __always_unused i915_pageflip_stall_check(struct drm_device *dev, inif (INTEL_INFO (dev)->gen >=4 ) {int dspsurf =DSPSURF (intel_crtc->plane); stall_detected =I915_HI_DISPBASE (I915_READ (dspsurf)) == -i915_gem_obj_offset (obj); +i915_gem_ggtt_offset (obj); }else {int dspaddr =DSPADDR (intel_crtc->plane); - stall_detected =I915_READ (dspaddr) == (i915_gem_obj_offset (obj) + + stall_detected =I915_READ (dspaddr) == (i915_gem_ggtt_offset (obj) + crtc->y * crtc->fb->pitches[0 ] + crtc->x * crtc->fb->bits_per_pixel/8 ); }
drivers/gpu/drm/i915/i915_trace.h +12 -8
@@ -34,11 +34,13 @@ TRACE_EVENT(i915_gem_object_create, ); TRACE_EVENT(i915_gem_object_bind, - TP_PROTO(struct drm_i915_gem_object *obj, bool mappable), - TP_ARGS(obj, mappable), + TP_PROTO(struct drm_i915_gem_object *obj, + struct i915_address_space *vm, bool mappable), + TP_ARGS(obj, vm, mappable), TP_STRUCT__entry( __field(struct drm_i915_gem_object *, obj) + __field(struct i915_address_space *, vm) __field(u32, offset) __field(u32, size) __field(bool, mappable)
@@ -46,8 +48,8 @@ TRACE_EVENT(i915_gem_object_bind,TP_fast_assign ( __entry->obj = obj; - __entry->offset =i915_gem_obj_offset (obj); - __entry->size =i915_gem_obj_size (obj); + __entry->offset =i915_gem_obj_offset (obj, vm); + __entry->size =i915_gem_obj_size (obj, vm); __entry->mappable = mappable; ),
@@ -57,19 +59,21 @@ TRACE_EVENT(i915_gem_object_bind, ); TRACE_EVENT(i915_gem_object_unbind, - TP_PROTO(struct drm_i915_gem_object *obj), - TP_ARGS(obj), + TP_PROTO(struct drm_i915_gem_object *obj, + struct i915_address_space *vm), + TP_ARGS(obj, vm), TP_STRUCT__entry( __field(struct drm_i915_gem_object *, obj) + __field(struct i915_address_space *, vm) __field(u32, offset) __field(u32, size) ), TP_fast_assign( __entry->obj = obj; - __entry->offset = i915_gem_obj_offset(obj); - __entry->size = i915_gem_obj_size(obj); + __entry->offset = i915_gem_obj_offset(obj, vm); + __entry->size = i915_gem_obj_size(obj, vm); ), TP_printk("obj=%p, offset=%08x size=%x",
drivers/gpu/drm/i915/intel_display.c +11 -11
@@ -1943,18 +1943,18 @@ static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb, }DRM_DEBUG_KMS ("Writing base %08lX %08lX %d %d %d\n" , -i915_gem_obj_offset (obj), linear_offset, x, y, +i915_gem_ggtt_offset (obj), linear_offset, x, y, fb->pitches[0 ]);I915_WRITE (DSPSTRIDE (plane), fb->pitches[0 ]);if (INTEL_INFO (dev)->gen >=4 ) {I915_MODIFY_DISPBASE (DSPSURF (plane), -i915_gem_obj_offset (obj) + +i915_gem_ggtt_offset (obj) + intel_crtc->dspaddr_offset);I915_WRITE (DSPTILEOFF (plane), (y <<16 ) | x);I915_WRITE (DSPLINOFF (plane), linear_offset); }else I915_WRITE (DSPADDR (plane), -i915_gem_obj_offset (obj) + linear_offset); +i915_gem_ggtt_offset (obj) + linear_offset);POSTING_READ (reg);return 0 ;
@@ -2035,11 +2035,11 @@ static int ironlake_update_plane(struct drm_crtc *crtc, linear_offset -= intel_crtc->dspaddr_offset;DRM_DEBUG_KMS ("Writing base %08lX %08lX %d %d %d\n" , -i915_gem_obj_offset (obj), linear_offset, x, y, +i915_gem_ggtt_offset (obj), linear_offset, x, y, fb->pitches[0 ]);I915_WRITE (DSPSTRIDE (plane), fb->pitches[0 ]);I915_MODIFY_DISPBASE (DSPSURF (plane), -i915_gem_obj_offset (obj)+intel_crtc->dspaddr_offset); +i915_gem_ggtt_offset (obj)+intel_crtc->dspaddr_offset);if (IS_HASWELL (dev)) {I915_WRITE (DSPOFFSET (plane), (y <<16 ) | x); }else {
@@ -6558,7 +6558,7 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc, goto fail_unpin; } - addr =i915_gem_obj_offset (obj); + addr =i915_gem_ggtt_offset (obj); }else {int align =IS_I830 (dev) ?16 *1024 :256 ; ret = i915_gem_attach_phys_object(dev, obj,
@@ -7274,7 +7274,7 @@ static int intel_gen2_queue_flip(struct drm_device *dev, MI_DISPLAY_FLIP_PLANE(intel_crtc->plane));intel_ring_emit (ring, fb->pitches[0 ]);intel_ring_emit (ring, -i915_gem_obj_offset (obj) + intel_crtc->dspaddr_offset); +i915_gem_ggtt_offset (obj) + intel_crtc->dspaddr_offset);intel_ring_emit (ring,0 );/* aux display base address, unused */ intel_mark_page_flip_active (intel_crtc);
@@ -7316,7 +7316,7 @@ static int intel_gen3_queue_flip(struct drm_device *dev, MI_DISPLAY_FLIP_PLANE(intel_crtc->plane));intel_ring_emit (ring, fb->pitches[0 ]);intel_ring_emit (ring, -i915_gem_obj_offset (obj) + intel_crtc->dspaddr_offset); +i915_gem_ggtt_offset (obj) + intel_crtc->dspaddr_offset);intel_ring_emit (ring,MI_NOOP );intel_mark_page_flip_active (intel_crtc);
@@ -7356,7 +7356,7 @@ static int intel_gen4_queue_flip(struct drm_device *dev, MI_DISPLAY_FLIP_PLANE(intel_crtc->plane));intel_ring_emit (ring, fb->pitches[0 ]);intel_ring_emit (ring, - (i915_gem_obj_offset (obj) + intel_crtc->dspaddr_offset) | + (i915_gem_ggtt_offset (obj) + intel_crtc->dspaddr_offset) | obj->tiling_mode);/* XXX Enabling the panel-fitter across page-flip is so far
@@ -7400,7 +7400,7 @@ static int intel_gen6_queue_flip(struct drm_device *dev, MI_DISPLAY_FLIP_PLANE(intel_crtc->plane));intel_ring_emit (ring, fb->pitches[0 ] | obj->tiling_mode);intel_ring_emit (ring, -i915_gem_obj_offset (obj) + intel_crtc->dspaddr_offset); +i915_gem_ggtt_offset (obj) + intel_crtc->dspaddr_offset);/* Contrary to the suggestions in the documentation, * "Enable Panel Fitter" does not seem to be required when page
@@ -7466,7 +7466,7 @@ static int intel_gen7_queue_flip(struct drm_device *dev,intel_ring_emit (ring,MI_DISPLAY_FLIP_I915 | plane_bit);intel_ring_emit (ring, (fb->pitches[0 ] | obj->tiling_mode));intel_ring_emit (ring, -i915_gem_obj_offset (obj) + intel_crtc->dspaddr_offset); +i915_gem_ggtt_offset (obj) + intel_crtc->dspaddr_offset);intel_ring_emit (ring, (MI_NOOP ));intel_mark_page_flip_active (intel_crtc);
drivers/gpu/drm/i915/intel_fb.c +3 -3
@@ -139,11 +139,11 @@ static int intelfb_create(struct drm_fb_helper *helper, info->apertures->ranges[0 ].base = dev->mode_config.fb_base; info->apertures->ranges[0 ].size = dev_priv->gtt.mappable_end; - info->fix.smem_start = dev->mode_config.fb_base +i915_gem_obj_offset (obj); + info->fix.smem_start = dev->mode_config.fb_base +i915_gem_ggtt_offset (obj); info->fix.smem_len = size; info->screen_base = -ioremap_wc (dev_priv->gtt.mappable_base +i915_gem_obj_offset (obj), +ioremap_wc (dev_priv->gtt.mappable_base +i915_gem_ggtt_offset (obj), size);if (!info->screen_base) { ret = -ENOSPC ;
@@ -168,7 +168,7 @@ static int intelfb_create(struct drm_fb_helper *helper,DRM_DEBUG_KMS ("allocated %dx%d fb: 0x%08lx, bo %p\n" , fb->width, fb->height, -i915_gem_obj_offset (obj), obj); +i915_gem_ggtt_offset (obj), obj);mutex_unlock (&dev->struct_mutex);
drivers/gpu/drm/i915/intel_overlay.c +8 -8
@@ -196,7 +196,7 @@ intel_overlay_map_regs(struct intel_overlay *overlay) regs = (struct overlay_registers __iomem *)overlay->reg_bo->phys_obj->handle->vaddr; else regs =io_mapping_map_wc (dev_priv->gtt.mappable, -i915_gem_obj_offset (overlay->reg_bo)); +i915_gem_ggtt_offset (overlay->reg_bo));return regs; }
@@ -740,7 +740,7 @@ static int intel_overlay_do_put_image(struct intel_overlay *overlay, swidth = params->src_w; swidthsw =calc_swidthsw (overlay->dev, params->offset_Y, tmp_width); sheight = params->src_h; -iowrite32 (i915_gem_obj_offset (new_bo) + params->offset_Y, +iowrite32 (i915_gem_ggtt_offset (new_bo) + params->offset_Y, ®s->OBUF_0Y); ostride = params->stride_Y;
@@ -755,9 +755,9 @@ static int intel_overlay_do_put_image(struct intel_overlay *overlay, params->src_w/uv_hscale); swidthsw |=max_t (u32, tmp_U, tmp_V) <<16 ; sheight |= (params->src_h/uv_vscale) <<16 ; -iowrite32 (i915_gem_obj_offset (new_bo) + params->offset_U, +iowrite32 (i915_gem_ggtt_offset (new_bo) + params->offset_U, ®s->OBUF_0U); -iowrite32 (i915_gem_obj_offset (new_bo) + params->offset_V, +iowrite32 (i915_gem_ggtt_offset (new_bo) + params->offset_V, ®s->OBUF_0V); ostride |= params->stride_UV <<16 ; }
@@ -1353,12 +1353,12 @@ void intel_setup_overlay(struct drm_device *dev) } overlay->flip_addr = reg_bo->phys_obj->handle->busaddr; }else { - ret =i915_gem_object_pin (reg_bo,PAGE_SIZE , true, false); + ret =i915_gem_ggtt_pin (reg_bo,PAGE_SIZE , true, false);if (ret) {DRM_ERROR ("failed to pin overlay register bo\n" ); goto out_free_bo; } - overlay->flip_addr =i915_gem_obj_offset (reg_bo); + overlay->flip_addr =i915_gem_ggtt_offset (reg_bo); ret =i915_gem_object_set_to_gtt_domain (reg_bo, true);if (ret) {
@@ -1437,7 +1437,7 @@ intel_overlay_map_regs_atomic(struct intel_overlay *overlay) overlay->reg_bo->phys_obj->handle->vaddr;return io_mapping_map_atomic_wc (dev_priv->gtt.mappable, -i915_gem_obj_offset (overlay->reg_bo)); +i915_gem_ggtt_offset (overlay->reg_bo)); } static void intel_overlay_unmap_regs_atomic(struct intel_overlay *overlay,
@@ -1468,7 +1468,7 @@ intel_overlay_capture_error_state(struct drm_device *dev)if (OVERLAY_NEEDS_PHYSICAL (overlay->dev)) error->base = (__force long )overlay->reg_bo->phys_obj->handle->vaddr;else - error->base =i915_gem_obj_offset (overlay->reg_bo); + error->base =i915_gem_ggtt_offset (overlay->reg_bo); regs =intel_overlay_map_regs_atomic (overlay);if (!regs)
drivers/gpu/drm/i915/intel_pm.c +6 -5
@@ -217,7 +217,8 @@ static void ironlake_enable_fbc(struct drm_crtc *crtc, unsigned long interval) (stall_watermark <<DPFC_RECOMP_STALL_WM_SHIFT ) | (interval << DPFC_RECOMP_TIMER_COUNT_SHIFT));I915_WRITE (ILK_DPFC_FENCE_YOFF , crtc->y); -I915_WRITE (ILK_FBC_RT_BASE ,i915_gem_obj_offset (obj) |ILK_FBC_RT_VALID ); +I915_WRITE (ILK_FBC_RT_BASE , +i915_gem_ggtt_offset (obj) |ILK_FBC_RT_VALID );/* enable it... */ I915_WRITE (ILK_DPFC_CONTROL , dpfc_ctl |DPFC_CTL_EN );
@@ -274,7 +275,7 @@ static void gen7_enable_fbc(struct drm_crtc *crtc, unsigned long interval)struct drm_i915_gem_object *obj = intel_fb->obj;struct intel_crtc *intel_crtc =to_intel_crtc (crtc); -I915_WRITE (IVB_FBC_RT_BASE ,i915_gem_obj_offset (obj)); +I915_WRITE (IVB_FBC_RT_BASE ,i915_gem_ggtt_offset (obj)); I915_WRITE(ILK_DPFC_CONTROL, DPFC_CTL_EN | DPFC_CTL_LIMIT_1X | IVB_DPFC_CTL_FENCE_EN |
@@ -2860,7 +2861,7 @@ intel_alloc_context_page(struct drm_device *dev)return NULL ; } - ret =i915_gem_object_pin (ctx,4096 , true, false); + ret =i915_gem_ggtt_pin (ctx,4096 , true, false);if (ret) {DRM_ERROR ("failed to pin power context: %d\n" , ret); goto err_unref;
@@ -3685,7 +3686,7 @@ static void ironlake_enable_rc6(struct drm_device *dev)intel_ring_emit (ring,MI_SUSPEND_FLUSH |MI_SUSPEND_FLUSH_EN );intel_ring_emit (ring,MI_SET_CONTEXT ); - intel_ring_emit(ring, i915_gem_obj_offset(dev_priv->ips.renderctx) | + intel_ring_emit(ring, i915_gem_ggtt_offset(dev_priv->ips.renderctx) | MI_MM_SPACE_GTT | MI_SAVE_EXT_STATE_EN | MI_RESTORE_EXT_STATE_EN |
@@ -3708,7 +3709,7 @@ static void ironlake_enable_rc6(struct drm_device *dev)return ; } -I915_WRITE (PWRCTXA ,i915_gem_obj_offset (dev_priv->ips.pwrctx) | +I915_WRITE (PWRCTXA ,i915_gem_ggtt_offset (dev_priv->ips.pwrctx) |PWRCTX_EN );I915_WRITE (RSTDBYCTL ,I915_READ (RSTDBYCTL ) & ~RCX_SW_EXIT ); }
drivers/gpu/drm/i915/intel_ringbuffer.c +17 -12
@@ -424,14 +424,14 @@ static int init_ring_common(struct intel_ring_buffer *ring)* registers with the above sequence (the readback of the HEAD registers * also enforces ordering), otherwise the hw might lose the new ring * register values. */ -I915_WRITE_START (ring,i915_gem_obj_offset (obj)); +I915_WRITE_START (ring,i915_gem_ggtt_offset (obj));I915_WRITE_CTL (ring, ((ring->size -PAGE_SIZE ) &RING_NR_PAGES ) |RING_VALID );/* If the head is still not zero, the ring is dead */ if (wait_for ((I915_READ_CTL (ring) &RING_VALID ) !=0 && -I915_READ_START (ring) ==i915_gem_obj_offset (obj) && +I915_READ_START (ring) ==i915_gem_ggtt_offset (obj) && (I915_READ_HEAD (ring) &HEAD_ADDR ) ==0 ,50 )) { DRM_ERROR("%s initialization failed " "ctl %08x head %08x tail %08x start %08x\n",
@@ -465,6 +465,7 @@ out:static int init_pipe_control (struct intel_ring_buffer *ring) { +struct drm_i915_private *dev_priv = ring->dev->dev_private;struct pipe_control *pc;struct drm_i915_gem_object *obj;int ret;
@@ -483,13 +484,14 @@ init_pipe_control(struct intel_ring_buffer *ring) goto err; } -i915_gem_object_set_cache_level (obj,I915_CACHE_LLC ); +i915_gem_object_set_cache_level (obj, &dev_priv->gtt.base, +I915_CACHE_LLC ); - ret =i915_gem_object_pin (obj,4096 , true, false); + ret =i915_gem_ggtt_pin (obj,4096 , true, false);if (ret) goto err_unref; - pc->gtt_offset =i915_gem_obj_offset (obj); + pc->gtt_offset =i915_gem_ggtt_offset (obj); pc->cpu_page =kmap (sg_page (obj->pages->sgl));if (pc->cpu_page ==NULL ) { ret = -ENOMEM ;
@@ -1129,7 +1131,7 @@ i830_dispatch_execbuffer(struct intel_ring_buffer *ring,intel_ring_advance (ring); }else {struct drm_i915_gem_object *obj = ring->private; -u32 cs_offset =i915_gem_obj_offset (obj); +u32 cs_offset =i915_gem_ggtt_offset (obj);if (len >I830_BATCH_LIMIT )return -ENOSPC ;
@@ -1197,6 +1199,7 @@ static void cleanup_status_page(struct intel_ring_buffer *ring)static int init_status_page (struct intel_ring_buffer *ring) {struct drm_device *dev = ring->dev; +struct drm_i915_private *dev_priv = dev->dev_private;struct drm_i915_gem_object *obj;int ret;
@@ -1207,14 +1210,15 @@ static int init_status_page(struct intel_ring_buffer *ring) goto err; } -i915_gem_object_set_cache_level (obj,I915_CACHE_LLC ); +i915_gem_object_set_cache_level (obj, &dev_priv->gtt.base, +I915_CACHE_LLC ); - ret =i915_gem_object_pin (obj,4096 , true, false); + ret =i915_gem_ggtt_pin (obj,4096 , true, false);if (ret !=0 ) { goto err_unref; } - ring->status_page.gfx_addr =i915_gem_obj_offset (obj); + ring->status_page.gfx_addr =i915_gem_ggtt_offset (obj); ring->status_page.page_addr =kmap (sg_page (obj->pages->sgl));if (ring->status_page.page_addr ==NULL ) { ret = -ENOMEM ;
@@ -1299,7 +1303,7 @@ static int intel_init_ring_buffer(struct drm_device *dev, ring->obj = obj; - ret =i915_gem_object_pin (obj,PAGE_SIZE , true, false); + ret =i915_gem_ggtt_pin (obj,PAGE_SIZE , true, false);if (ret) goto err_unref;
@@ -1308,7 +1312,8 @@ static int intel_init_ring_buffer(struct drm_device *dev, goto err_unpin; ring->virtual_start = -ioremap_wc (dev_priv->gtt.mappable_base +i915_gem_obj_offset (obj), +ioremap_wc (dev_priv->gtt.mappable_base + +i915_gem_ggtt_offset (obj), ring->size);if (ring->virtual_start ==NULL ) {DRM_ERROR ("Failed to map ringbuffer.\n" );
@@ -1821,7 +1826,7 @@ int intel_init_render_ring_buffer(struct drm_device *dev)return -ENOMEM ; } - ret =i915_gem_object_pin (obj,0 , true, false); + ret =i915_gem_ggtt_pin (obj,0 , true, false);if (ret !=0 ) {drm_gem_object_unreference (&obj->base);DRM_ERROR ("Failed to ping batch bo\n" );
drivers/gpu/drm/i915/intel_sprite.c +3 -3
@@ -133,7 +133,7 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_framebuffer *fb,I915_WRITE (SPSIZE (pipe, plane), (crtc_h <<16 ) | crtc_w);I915_WRITE (SPCNTR (pipe, plane), sprctl); -I915_MODIFY_DISPBASE (SPSURF (pipe, plane),i915_gem_obj_offset (obj) + +I915_MODIFY_DISPBASE (SPSURF (pipe, plane),i915_gem_ggtt_offset (obj) + sprsurf_offset);POSTING_READ (SPSURF (pipe, plane)); }
@@ -309,7 +309,7 @@ ivb_update_plane(struct drm_plane *plane, struct drm_framebuffer *fb,I915_WRITE (SPRSCALE (pipe), sprscale);I915_WRITE (SPRCTL (pipe), sprctl);I915_MODIFY_DISPBASE (SPRSURF (pipe), -i915_gem_obj_offset (obj) + sprsurf_offset); +i915_gem_ggtt_offset (obj) + sprsurf_offset);POSTING_READ (SPRSURF (pipe));/* potentially re-enable LP watermarks */
@@ -480,7 +480,7 @@ ilk_update_plane(struct drm_plane *plane, struct drm_framebuffer *fb,I915_WRITE (DVSSCALE (pipe), dvsscale);I915_WRITE (DVSCNTR (pipe), dvscntr);I915_MODIFY_DISPBASE (DVSSURF (pipe), -i915_gem_obj_offset (obj) + dvssurf_offset); +i915_gem_ggtt_offset (obj) + dvssurf_offset);POSTING_READ (DVSSURF (pipe)); }
Signature · 1 line
1.8.3.1
PATCH 34/66 drm/i915: Create VMAs (part 3.5) - map and fenceable tracking
In reply to Ben WidawskyThis commit is split out because it's a bit tricky (or at least it was for me). It could very well be squashed in to the previous commits.
The map_and_fenceable tracking is per object. Map_and_fenceable however only makes sense in the context of the global gtt. As such, VMAs created for any other address space should ever modify these flags.
--- drivers/gpu/drm/i915/i915_gem.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +6 -3
@@ -2644,7 +2644,7 @@ i915_gem_object_unbind(struct drm_i915_gem_object *obj,trace_i915_gem_object_unbind (obj, vm); -if (obj->has_global_gtt_mapping) +if (obj->has_global_gtt_mapping &&is_i915_ggtt (vm))i915_gem_gtt_unbind_object (obj);if (obj->has_aliasing_ppgtt_mapping) {i915_ppgtt_unbind_object (dev_priv->gtt.aliasing_ppgtt, obj);
@@ -2655,7 +2655,8 @@ i915_gem_object_unbind(struct drm_i915_gem_object *obj,list_del (&obj->mm_list);/* Avoid an unnecessary call to unbind on rebind. */ - obj->map_and_fenceable = true; +if (is_i915_ggtt (vm)) + obj->map_and_fenceable = true; vma =i915_gem_obj_to_vma (obj, vm);list_del (&vma->vma_link);
@@ -3223,7 +3224,9 @@ search_free:is_i915_ggtt (vm) && vma->node.start + obj->base.size <= dev_priv->gtt.mappable_end; - obj->map_and_fenceable = mappable && fenceable; +/* Map and fenceable only changes if the VM is the global GGTT */ +if (is_i915_ggtt (vm)) + obj->map_and_fenceable = mappable && fenceable;trace_i915_gem_object_bind (obj, vm, map_and_fenceable);i915_gem_verify_gtt (dev);
Signature · 1 line
1.8.3.1
PATCH 35/66 drm/i915: Create VMAs (part 4) - Error capture
In reply to Ben WidawskySince the active/inactive lists are per VM, we need to modify the error capture code to be aware of this, and also extend it to capture the buffers from all the VMs. For now all the code assumes only 1 VM, but it will become more generic over the next few patches.
NOTE: If the number of VMs in a real world system grows significantly we'll have to focus on only capturing the guilty VM, or else it's likely there won't be enough space for error capture.
--- drivers/gpu/drm/i915/i915_debugfs.c | 8 +-- drivers/gpu/drm/i915/i915_drv.h | 4 +- drivers/gpu/drm/i915/i915_irq.c | 104 ++++++++++++++++++++++++------------ 3 files changed, 77 insertions(+), 39 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +4 -4
@@ -842,13 +842,13 @@ static int i915_error_state(struct i915_error_state_file_priv *error_priv,if (error->active_bo)print_error_buffers (m,"Active" , - error->active_bo, - error->active_bo_count); + error->active_bo[0 ], + error->active_bo_count[0 ]);if (error->pinned_bo)print_error_buffers (m,"Pinned" , - error->pinned_bo, - error->pinned_bo_count); + error->pinned_bo[0 ], + error->pinned_bo_count[0 ]);for (i =0 ; i <ARRAY_SIZE (error->ring); i++) {struct drm_i915_error_object *obj;
drivers/gpu/drm/i915/i915_drv.h +2 -2
@@ -320,8 +320,8 @@ struct drm_i915_error_state { u32 purgeable:1; s32 ring:4; u32 cache_level:2; - } *active_bo, *pinned_bo; -u32 active_bo_count, pinned_bo_count; + } **active_bo, **pinned_bo; +u32 *active_bo_count, *pinned_bo_count;struct intel_overlay_error_state *overlay;struct intel_display_error_state *display; };
drivers/gpu/drm/i915/i915_irq.c +71 -33
144 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 36/66 drm/i915: Create VMAs (part 5) - move mm_list
In reply to Ben WidawskyThe mm_list is used for the active/inactive LRUs. Since those LRUs are per address space, the link should be per VM area
Because we'll only ever have 1 VMA before this point, it's not incorrect to defer this change until this point in the patch series, and doing it here makes the change much easier to understand.
v2: only bump GGTT LRU in i915_gem_object_set_to_gtt_domain (Chris)
--- drivers/gpu/drm/i915/i915_debugfs.c | 49 ++++++++++++++++++++++------------ drivers/gpu/drm/i915/i915_drv.h | 5 ++-- drivers/gpu/drm/i915/i915_gem.c | 31 ++++++++++++++------- drivers/gpu/drm/i915/i915_gem_evict.c | 14 +++++----- drivers/gpu/drm/i915/i915_gem_stolen.c | 2 +- drivers/gpu/drm/i915/i915_irq.c | 13 +++++---- 6 files changed, 71 insertions(+), 43 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +32 -17
@@ -152,7 +152,7 @@ static int i915_gem_object_list_info(struct seq_file *m, void *data)struct list_head *head;struct drm_device *dev = node->minor->dev;drm_i915_private_t *dev_priv = dev->dev_private; -struct drm_i915_gem_object *obj; +struct i915_vma *vma;size_t total_obj_size, total_gtt_size;int count, ret;
@@ -160,6 +160,7 @@ static int i915_gem_object_list_info(struct seq_file *m, void *data)if (ret)return ret; +/* FIXME: the user of this interface might want more than just GGTT */ switch (list) {case ACTIVE_LIST :seq_printf (m,"Active:\n" );
@@ -175,13 +176,12 @@ static int i915_gem_object_list_info(struct seq_file *m, void *data) } total_obj_size = total_gtt_size = count =0 ; -list_for_each_entry (obj, head, mm_list) { +list_for_each_entry (vma, head, mm_list) {seq_printf (m," " ); -describe_obj (m, obj); +describe_obj (m, vma->obj);seq_printf (m,"\n" ); - total_obj_size += obj->base.size; -/* FIXME: Add size of all VMs */ - total_gtt_size +=i915_gem_ggtt_size (obj); + total_obj_size += vma->obj->base.size; + total_gtt_size +=i915_gem_ggtt_size (vma->obj); count++; }mutex_unlock (&dev->struct_mutex);
@@ -229,6 +229,17 @@ static int per_file_stats(int id, void *ptr, void *data)return 0 ; } +#define count_vmas (list, member) do { \ + list_for_each_entry(vma, list, member) { \ + size += i915_gem_ggtt_size(vma->obj); \ + ++count; \ + if (vma->obj->map_and_fenceable) { \ + mappable_size += i915_gem_ggtt_size(vma->obj); \ + ++mappable_count; \ + } \ + } \ +} while (0) +static int i915_gem_object_info (struct seq_file *m,void * data) {struct drm_info_node *node = (struct drm_info_node *) m->private;
@@ -238,6 +249,7 @@ static int i915_gem_object_info(struct seq_file *m, void* data)size_t size, mappable_size, purgeable_size;struct drm_i915_gem_object *obj;struct drm_file *file; +struct i915_vma *vma;int ret; ret =mutex_lock_interruptible (&dev->struct_mutex);
@@ -254,12 +266,12 @@ static int i915_gem_object_info(struct seq_file *m, void* data) count, mappable_count, size, mappable_size); size = count = mappable_size = mappable_count =0 ; -count_objects (ggtt_list (active_list), mm_list); +count_vmas (ggtt_list (active_list), mm_list);seq_printf (m," %u [%u] active objects, %zu [%zu] bytes\n" , count, mappable_count, size, mappable_size); size = count = mappable_size = mappable_count =0 ; -count_objects (ggtt_list (inactive_list), mm_list); +count_vmas (ggtt_list (inactive_list), mm_list);seq_printf (m," %u [%u] inactive objects, %zu [%zu] bytes\n" , count, mappable_count, size, mappable_size);
@@ -1966,6 +1978,8 @@ i915_drop_caches_set(void *data, u64 val)struct drm_device *dev = data;struct drm_i915_private *dev_priv = dev->dev_private;struct drm_i915_gem_object *obj, *next; +struct i915_address_space *vm; +struct i915_vma *vma, *x;int ret;DRM_DEBUG_DRIVER ("Dropping caches: 0x%08llx\n" , val);
@@ -1986,15 +2000,16 @@ i915_drop_caches_set(void *data, u64 val)i915_gem_retire_requests (dev);if (val &DROP_BOUND ) { -/* FIXME: Do this for all vms? */ -list_for_each_entry_safe (obj, next,ggtt_list (inactive_list), - mm_list) -if (obj->pin_count) -continue ; - - ret =i915_gem_object_unbind (obj, &dev_priv->gtt.base); -if (ret) - goto unlock; +list_for_each_entry (vm, &dev_priv->vm_list, global_link) { +list_for_each_entry_safe (vma, x, &vm->inactive_list, + mm_list) +if (vma->obj->pin_count ==0 ) { + ret =i915_gem_object_unbind (vma->obj, + vm); +if (ret) + goto unlock; + } + } }if (val &DROP_UNBOUND ) {
drivers/gpu/drm/i915/i915_drv.h +3 -2
@@ -545,6 +545,9 @@ struct i915_vma {/* Page aligned offset (helper for stolen) */ unsigned long deferred_offset; +/** This object's place on the active/inactive lists */ +struct list_head mm_list; +struct list_head vma_link;/* Link in the object's VMA list */ };
@@ -1237,9 +1240,7 @@ struct drm_i915_gem_object {struct drm_mm_node *stolen;struct list_head global_list; -/** This object's place on the active/inactive lists */ struct list_head ring_list; -struct list_head mm_list;/** This object's place in the batchbuffer or on the eviction list */ struct list_head exec_list;
drivers/gpu/drm/i915/i915_gem.c +21 -10
@@ -1878,6 +1878,7 @@ i915_gem_object_move_to_active(struct drm_i915_gem_object *obj,struct drm_device *dev = obj->base.dev;struct drm_i915_private *dev_priv = dev->dev_private;u32 seqno =intel_ring_get_seqno (ring); +struct i915_vma *vma;BUG_ON (ring ==NULL ); obj->ring = ring;
@@ -1889,7 +1890,8 @@ i915_gem_object_move_to_active(struct drm_i915_gem_object *obj, }/* Move from whatever list we were on to the tail of execution. */ -list_move_tail (&obj->mm_list, &vm->active_list); + vma =i915_gem_obj_to_vma (obj, vm); +list_move_tail (&vma->mm_list, &vm->active_list);list_move_tail (&obj->ring_list, &ring->active_list); obj->last_read_seqno = seqno;
@@ -1912,10 +1914,13 @@ static void i915_gem_object_move_to_inactive(struct drm_i915_gem_object *obj, struct i915_address_space *vm) { + struct i915_vma *vma; +BUG_ON (obj->base.write_domain & ~I915_GEM_GPU_DOMAINS );BUG_ON (!obj->active); -list_move_tail (&obj->mm_list, &vm->inactive_list); + vma =i915_gem_obj_to_vma (obj, vm); +list_move_tail (&vma->mm_list, &vm->inactive_list);list_del_init (&obj->ring_list); obj->ring =NULL ;
@@ -2290,9 +2295,9 @@ void i915_gem_restore_fences(struct drm_device *dev)bool i915_gem_reset (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; -struct drm_i915_gem_object *obj;struct intel_ring_buffer *ring;struct i915_address_space *vm; +struct i915_vma *vma;int i;bool ctx_banned = false;
@@ -2305,8 +2310,8 @@ bool i915_gem_reset(struct drm_device *dev)* necessary invalidation upon reuse. */ list_for_each_entry (vm, &dev_priv->vm_list, global_link) -list_for_each_entry (obj, &vm->inactive_list, mm_list) - obj->base.read_domains &= ~I915_GEM_GPU_DOMAINS ; +list_for_each_entry (vma, &vm->inactive_list, mm_list) + vma->obj->base.read_domains &= ~I915_GEM_GPU_DOMAINS ;/* The fence registers are invalidated so clear them out */ i915_gem_restore_fences (dev);
@@ -2653,12 +2658,12 @@ i915_gem_object_unbind(struct drm_i915_gem_object *obj,i915_gem_gtt_finish_object (obj);i915_gem_object_unpin_pages (obj); -list_del (&obj->mm_list);/* Avoid an unnecessary call to unbind on rebind. */ if (is_i915_ggtt (vm)) obj->map_and_fenceable = true; vma =i915_gem_obj_to_vma (obj, vm); +list_del (&vma->mm_list);list_del (&vma->vma_link);drm_mm_remove_node (&vma->node);i915_gem_vma_destroy (vma);
@@ -3208,7 +3213,7 @@ search_free: }list_move_tail (&obj->global_list, &dev_priv->mm.bound_list); -list_add_tail (&obj->mm_list, &vm->inactive_list); +list_add_tail (&vma->mm_list, &vm->inactive_list);/* Keep GGTT vmas first to make debug easier */ if (is_i915_ggtt (vm))list_add (&vma->vma_link, &obj->vma_list);
@@ -3364,8 +3369,14 @@ i915_gem_object_set_to_gtt_domain(struct drm_i915_gem_object *obj, bool write) old_write_domain);/* And bump the LRU for this access */ -if (i915_gem_object_is_inactive (obj)) -list_move_tail (&obj->mm_list,ggtt_list (inactive_list)); +if (i915_gem_object_is_inactive (obj)) { +struct i915_vma *vma =i915_gem_obj_to_vma (obj, + &dev_priv->gtt.base); +if (vma) +list_move_tail (&vma->mm_list, + &dev_priv->gtt.base.inactive_list); + + }return 0 ; }
@@ -3943,7 +3954,6 @@ unlock:void i915_gem_object_init (struct drm_i915_gem_object *obj,const struct drm_i915_gem_object_ops *ops) { -INIT_LIST_HEAD (&obj->mm_list);INIT_LIST_HEAD (&obj->global_list);INIT_LIST_HEAD (&obj->ring_list);INIT_LIST_HEAD (&obj->exec_list);
@@ -4086,6 +4096,7 @@ struct i915_vma *i915_gem_vma_create(struct drm_i915_gem_object *obj,return ERR_PTR (-ENOMEM );INIT_LIST_HEAD (&vma->vma_link); +INIT_LIST_HEAD (&vma->mm_list); vma->vm = vm; vma->obj = obj;
drivers/gpu/drm/i915/i915_gem_evict.c +6 -8
@@ -86,8 +86,7 @@ i915_gem_evict_something(struct drm_device *dev, struct i915_address_space *vm,drm_mm_init_scan (&vm->mm, min_size, alignment, cache_level);/* First see if there is a large enough contiguous idle region... */ -list_for_each_entry (obj, &vm->inactive_list, mm_list) { -struct i915_vma *vma =i915_gem_obj_to_vma (obj, vm); +list_for_each_entry (vma, &vm->inactive_list, mm_list) {if (mark_free (vma, &unwind_list)) goto found; }
@@ -96,8 +95,7 @@ i915_gem_evict_something(struct drm_device *dev, struct i915_address_space *vm, goto none;/* Now merge in the soon-to-be-expired objects... */ -list_for_each_entry (obj, &vm->active_list, mm_list) { -struct i915_vma *vma =i915_gem_obj_to_vma (obj, vm); +list_for_each_entry (vma, &vm->active_list, mm_list) {if (mark_free (vma, &unwind_list)) goto found; }
@@ -158,8 +156,8 @@ int i915_gem_evict_everything(struct drm_device *dev) {drm_i915_private_t *dev_priv = dev->dev_private; -struct drm_i915_gem_object *obj, *next;struct i915_address_space *vm; +struct i915_vma *vma, *next;bool lists_empty = true;int ret;
@@ -187,9 +185,9 @@ i915_gem_evict_everything(struct drm_device *dev)/* Having flushed everything, unbind() should never raise an error */ list_for_each_entry (vm, &dev_priv->vm_list, global_link) { -list_for_each_entry_safe (obj, next, &vm->inactive_list, mm_list) -if (obj->pin_count ==0 ) -WARN_ON (i915_gem_object_unbind (obj, vm)); +list_for_each_entry_safe (vma, next, &vm->inactive_list, mm_list) +if (vma->obj->pin_count ==0 ) +WARN_ON (i915_gem_object_unbind (vma->obj, vm)); }
drivers/gpu/drm/i915/i915_gem_stolen.c +1 -1
@@ -397,7 +397,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev, obj->has_global_gtt_mapping =1 ;list_add_tail (&obj->global_list, &dev_priv->mm.bound_list); -list_add_tail (&obj->mm_list, >t_vm->inactive_list); +list_add_tail (&vma->mm_list, >t_vm->inactive_list);return obj; }
drivers/gpu/drm/i915/i915_irq.c +8 -5
@@ -1643,11 +1643,11 @@ static void capture_bo(struct drm_i915_error_buffer *err,static u32 capture_active_bo (struct drm_i915_error_buffer *err,int count,struct list_head *head) { -struct drm_i915_gem_object *obj; +struct i915_vma *vma;int i =0 ; -list_for_each_entry (obj, head, mm_list) { -capture_bo (err++, obj); +list_for_each_entry (vma, head, mm_list) { +capture_bo (err++, vma->obj);if (++i == count)break ; }
@@ -1710,6 +1710,7 @@ i915_error_first_batchbuffer(struct drm_i915_private *dev_priv, struct intel_ring_buffer *ring) {struct i915_address_space *vm; +struct i915_vma *vma;struct drm_i915_gem_object *obj;u32 seqno;
@@ -1733,7 +1734,8 @@ i915_error_first_batchbuffer(struct drm_i915_private *dev_priv, seqno = ring->get_seqno (ring, false);list_for_each_entry (vm, &dev_priv->vm_list, global_link) { -list_for_each_entry (obj, &vm->active_list, mm_list) { +list_for_each_entry (vma, &vm->active_list, mm_list) { + obj = vma->obj;if (obj->ring != ring)continue ;
@@ -1872,11 +1874,12 @@ static void i915_gem_capture_vm(struct drm_i915_private *dev_priv, const int ndx) {struct drm_i915_error_buffer *active_bo =NULL , *pinned_bo =NULL ; +struct i915_vma *vma;struct drm_i915_gem_object *obj;int i; i =0 ; -list_for_each_entry (obj, &vm->active_list, mm_list) +list_for_each_entry (vma, &vm->active_list, mm_list) i++; error->active_bo_count[ndx] = i;list_for_each_entry (obj, &dev_priv->mm.bound_list, global_list)
Signature · 1 line
1.8.3.1
PATCH 37/66 drm/i915: Create VMAs (part 6) - finish error plumbing
In reply to Ben Widawsky--- drivers/gpu/drm/i915/i915_irq.c | 53 ++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 16 deletions(-)
drivers/gpu/drm/i915/i915_irq.c +37 -16
@@ -1499,6 +1499,7 @@ static void i915_get_extra_instdone(struct drm_device *dev,static struct drm_i915_error_object *i915_error_object_create_sized (struct drm_i915_private *dev_priv,struct drm_i915_gem_object *src, +struct i915_address_space *vm,const int num_pages) {struct drm_i915_error_object *dst;
@@ -1512,8 +1513,7 @@ i915_error_object_create_sized(struct drm_i915_private *dev_priv,if (dst ==NULL )return NULL ; -/* FIXME: must handle per faulty VM */ - reloc_offset =i915_gem_ggtt_offset (src); + reloc_offset =i915_gem_obj_offset (src, vm);for (i =0 ; i < num_pages; i++) {unsigned long flags;void *d;
@@ -1565,7 +1565,7 @@ i915_error_object_create_sized(struct drm_i915_private *dev_priv, reloc_offset +=PAGE_SIZE ; } dst->page_count = num_pages; - dst->gtt_offset =i915_gem_ggtt_offset (src); + dst->gtt_offset =i915_gem_obj_offset (src, vm);return dst;
@@ -1575,8 +1575,9 @@ unwind:kfree (dst);return NULL ; } -#define i915_error_object_create (dev_priv, src) \ +#define i915_error_object_create (dev_priv, src, vm) \ i915_error_object_create_sized((dev_priv), (src), \ + vm, \ (src)->base.size>>PAGE_SHIFT) static void
@@ -1617,14 +1618,14 @@ i915_error_state_free(struct kref *error_ref)kfree (error); }static void capture_bo (struct drm_i915_error_buffer *err, -struct drm_i915_gem_object *obj) +struct drm_i915_gem_object *obj, +struct i915_address_space *vm) { err->size = obj->base.size; err->name = obj->base.name; err->rseqno = obj->last_read_seqno; err->wseqno = obj->last_write_seqno; -/* FIXME: plumb the actual context into here to pull the right VM */ - err->gtt_offset =i915_gem_ggtt_offset (obj); + err->gtt_offset =i915_gem_obj_offset (obj, vm); err->read_domains = obj->base.read_domains; err->write_domain = obj->base.write_domain; err->fence_reg = obj->fence_reg;
@@ -1647,7 +1648,7 @@ static u32 capture_active_bo(struct drm_i915_error_buffer *err,int i =0 ;list_for_each_entry (vma, head, mm_list) { -capture_bo (err++, vma->obj); +capture_bo (err++, vma->obj, vma->vm);if (++i == count)break ; }
@@ -1662,10 +1663,14 @@ static u32 capture_pinned_bo(struct drm_i915_error_buffer *err,int i =0 ;list_for_each_entry (obj, head, global_list) { +struct i915_vma *vma;if (obj->pin_count ==0 )continue ; -capture_bo (err++, obj); +/* Object may be pinned in multiple VMs, just take first */ + vma = list_first_entry(&obj->vma_list, struct i915_vma, + vma_link); +capture_bo (err++, obj, vma->vm);if (++i == count)break ; }
@@ -1713,6 +1718,7 @@ i915_error_first_batchbuffer(struct drm_i915_private *dev_priv,struct i915_vma *vma;struct drm_i915_gem_object *obj;u32 seqno; +u32 pp_db;if (!ring->get_seqno)return NULL ;
@@ -1729,11 +1735,19 @@ i915_error_first_batchbuffer(struct drm_i915_private *dev_priv, obj = ring->private;if (acthd >=i915_gem_ggtt_offset (obj) && acthd <i915_gem_ggtt_offset (obj) + obj->base.size) -return i915_error_object_create (dev_priv, obj); +return i915_error_object_create (dev_priv, obj, + &dev_priv->gtt.base); } + pp_db =I915_READ (RING_PP_DIR_BASE (ring)); seqno = ring->get_seqno (ring, false); +list_for_each_entry (vm, &dev_priv->vm_list, global_link) { +struct i915_hw_ppgtt *ppgtt = + container_of(vm, struct i915_hw_ppgtt, base); +if (!is_i915_ggtt (vm) && pp_db >>10 != ppgtt->pd_offset) +continue ; +list_for_each_entry (vma, &vm->active_list, mm_list) { obj = vma->obj;if (obj->ring != ring)
@@ -1749,7 +1763,7 @@ i915_error_first_batchbuffer(struct drm_i915_private *dev_priv,* simplest method to avoid being overwritten by * userspace. */ -return i915_error_object_create (dev_priv, obj); +return i915_error_object_create (dev_priv, obj, vm); } }
@@ -1806,6 +1820,7 @@ static void i915_gem_record_active_context(struct intel_ring_buffer *ring, struct drm_i915_error_ring *ering) {struct drm_i915_private *dev_priv = ring->dev->dev_private; +struct i915_address_space *ggtt = &dev_priv->gtt.base;struct drm_i915_gem_object *obj;/* Currently render ring is the only HW context user */
@@ -1813,9 +1828,14 @@ static void i915_gem_record_active_context(struct intel_ring_buffer *ring,return ;list_for_each_entry (obj, &dev_priv->mm.bound_list, global_list) { +if (!i915_gem_obj_bound (obj, ggtt)) +continue ; +if ((error->ccid &PAGE_MASK ) ==i915_gem_ggtt_offset (obj)) { ering->ctx =i915_error_object_create_sized (dev_priv, - obj,1 ); + obj, + ggtt, +1 ); } } }
@@ -1835,8 +1855,8 @@ static void i915_gem_record_rings(struct drm_device *dev,i915_error_first_batchbuffer (dev_priv, ring); error->ring[i].ringbuffer = -i915_error_object_create (dev_priv, ring->obj); - +i915_error_object_create (dev_priv, ring->obj, + &dev_priv->gtt.base);i915_gem_record_active_context (ring, error, &error->ring[i]);
@@ -1912,7 +1932,7 @@ static void i915_gem_capture_buffers(struct drm_i915_private *dev_priv, struct drm_i915_error_state *error) {struct i915_address_space *vm; -int cnt =0 ; +int cnt =0 , i =0 ;list_for_each_entry (vm, &dev_priv->vm_list, global_link) cnt++;
@@ -1929,7 +1949,8 @@ static void i915_gem_capture_buffers(struct drm_i915_private *dev_priv, error->pinned_bo_count =kcalloc (cnt,sizeof (*error->pinned_bo_count),GFP_ATOMIC ); -i915_gem_capture_vm (dev_priv, error, vm,0 ); +list_for_each_entry (vm, &dev_priv->vm_list, global_link) +i915_gem_capture_vm (dev_priv, error, vm, i++); }/**
Signature · 1 line
1.8.3.1
PATCH 38/66 drm/i915: create an object_is_active()
In reply to Ben WidawskyThis is simply obj->active for now, but will serve a purpose when we track activity per vma.
--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/i915_gem.c | 18 ++++++++++++------ drivers/gpu/drm/i915/i915_gem_context.c | 2 +- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 2 +- 4 files changed, 15 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -1709,6 +1709,7 @@ static inline void i915_gem_object_unpin_pages(struct drm_i915_gem_object *obj)int __must_check i915_mutex_lock_interruptible (struct drm_device *dev);int i915_gem_object_sync (struct drm_i915_gem_object *obj,struct intel_ring_buffer *to); +bool i915_gem_object_is_active (struct drm_i915_gem_object *obj);void i915_gem_object_move_to_active (struct drm_i915_gem_object *obj,struct i915_address_space *vm,struct intel_ring_buffer *ring);
drivers/gpu/drm/i915/i915_gem.c +12 -6
@@ -134,10 +134,16 @@ int i915_mutex_lock_interruptible(struct drm_device *dev)return 0 ; } +/* NB: Not the same as !i915_gem_object_is_inactive */ +bool i915_gem_object_is_active (struct drm_i915_gem_object *obj) +{ +return obj->active; +} +static inline bool i915_gem_object_is_inactive (struct drm_i915_gem_object *obj) { -return i915_gem_obj_bound_any (obj) && !obj->active; +return i915_gem_obj_bound_any (obj) && !i915_gem_object_is_active (obj); }int
@@ -1884,7 +1890,7 @@ i915_gem_object_move_to_active(struct drm_i915_gem_object *obj, obj->ring = ring;/* Add a reference if we're newly entering the active list. */ -if (!obj->active) { +if (!i915_gem_object_is_active (obj)) {drm_gem_object_reference (&obj->base); obj->active =1 ; }
@@ -1917,7 +1923,7 @@ i915_gem_object_move_to_inactive(struct drm_i915_gem_object *obj,struct i915_vma *vma;BUG_ON (obj->base.write_domain & ~I915_GEM_GPU_DOMAINS ); -BUG_ON (!obj->active); +BUG_ON (!i915_gem_object_is_active (obj)); vma =i915_gem_obj_to_vma (obj, vm);list_move_tail (&vma->mm_list, &vm->inactive_list);
@@ -2446,7 +2452,7 @@ i915_gem_object_flush_active(struct drm_i915_gem_object *obj) {int ret; -if (obj->active) { +if (i915_gem_object_is_active (obj)) { ret =i915_gem_check_olr (obj->ring, obj->last_read_seqno);if (ret)return ret;
@@ -2511,7 +2517,7 @@ i915_gem_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file)if (ret) goto out; -if (obj->active) { +if (i915_gem_object_is_active (obj)) { seqno = obj->last_read_seqno; ring = obj->ring; }
@@ -3885,7 +3891,7 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data,*/ ret =i915_gem_object_flush_active (obj); - args->busy = obj->active; + args->busy =i915_gem_object_is_active (obj);if (obj->ring) {BUILD_BUG_ON (I915_NUM_RINGS >16 ); args->busy |=intel_ring_flag (obj->ring) <<16 ;
drivers/gpu/drm/i915/i915_gem_context.c +1 -1
@@ -292,7 +292,7 @@ void i915_gem_context_fini(struct drm_device *dev)WARN_ON (!dev_priv->ring[RCS ].last_context);if (dev_priv->ring[RCS ].last_context == dctx) {/* Fake switch to NULL context */ -WARN_ON (dctx->obj->active); +WARN_ON (i915_gem_object_is_active (dctx->obj));i915_gem_object_unpin (dctx->obj);i915_gem_context_unreference (dctx); }
drivers/gpu/drm/i915/i915_gem_execbuffer.c +1 -1
@@ -251,7 +251,7 @@ i915_gem_execbuffer_relocate_entry(struct drm_i915_gem_object *obj, }/* We can't wait for rendering with pagefaults disabled */ -if (obj->active &&in_atomic ()) +if (i915_gem_object_is_active (obj) &&in_atomic ())return -EFAULT ; reloc->delta += target_offset;
Signature · 1 line
1.8.3.1
PATCH 39/66 drm/i915: Move active to vma
In reply to Ben WidawskyProbably need to squash whole thing, or just the inactive part, tbd...
--- drivers/gpu/drm/i915/i915_drv.h | 14 ++++++------ drivers/gpu/drm/i915/i915_gem.c | 47 ++++++++++++++++++++++++----------------- 2 files changed, 35 insertions(+), 26 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +7 -7
@@ -545,6 +545,13 @@ struct i915_vma {/* Page aligned offset (helper for stolen) */ unsigned long deferred_offset; +/** +* 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 +* inactive (ready to be unbound) list. +*/ + unsigned int active:1; +/** This object's place on the active/inactive lists */ struct list_head mm_list;
@@ -1245,13 +1252,6 @@ struct drm_i915_gem_object {struct list_head exec_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 -* inactive (ready to be unbound) list. -*/ - unsigned int active:1; - -/** * This is set if the object has been written to since last bound * to the GTT */
drivers/gpu/drm/i915/i915_gem.c +28 -19
104 lines not on this page · raw message
Signature · 1 line
1.8.3.1