Add back the buddy allocator
Subsystems (2)
cover Add back the buddy allocator
Needs to be applied on top of:
https://patchwork.freedesktop.org/series/90681/
Matthew Auld (5):
drm/i915/ttm: add ttm_buddy_man drm/i915/ttm: add i915_sg_from_buddy_resource drm/i915/ttm: pass along the I915_BO_ALLOC_CONTIGUOUS drm/i915/ttm: switch over to ttm_buddy_man drm/i915/ttm: restore min_page_size behaviour
Thomas Hellström (1):
drm/i915/ttm: Calculate the object placement at get_pages time
drivers/gpu/drm/i915/Makefile | 2 + drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 105 ++- drivers/gpu/drm/i915/i915_buddy.c | 412 +++++++++ drivers/gpu/drm/i915/i915_buddy.h | 133 +++ drivers/gpu/drm/i915/i915_scatterlist.c | 80 ++ drivers/gpu/drm/i915/i915_scatterlist.h | 5 + drivers/gpu/drm/i915/i915_ttm_buddy_manager.c | 246 ++++++ drivers/gpu/drm/i915/i915_ttm_buddy_manager.h | 56 ++ drivers/gpu/drm/i915/intel_memory_region.c | 55 +- drivers/gpu/drm/i915/intel_memory_region.h | 20 +- drivers/gpu/drm/i915/intel_region_ttm.c | 108 +-- drivers/gpu/drm/i915/intel_region_ttm.h | 2 + drivers/gpu/drm/i915/selftests/i915_buddy.c | 789 ++++++++++++++++++ .../drm/i915/selftests/intel_memory_region.c | 170 ++-- drivers/gpu/drm/i915/selftests/mock_region.c | 17 +- 15 files changed, 1970 insertions(+), 230 deletions(-) create mode 100644 drivers/gpu/drm/i915/i915_buddy.c create mode 100644 drivers/gpu/drm/i915/i915_buddy.h create mode 100644 drivers/gpu/drm/i915/i915_ttm_buddy_manager.c create mode 100644 drivers/gpu/drm/i915/i915_ttm_buddy_manager.h create mode 100644 drivers/gpu/drm/i915/selftests/i915_buddy.c
Signature · 1 line
2.26.3
PATCH 1/6 drm/i915/ttm: add ttm_buddy_man
Add back our standalone i915_buddy allocator and integrate it into a ttm_resource_manager. This will plug into our ttm backend for managing device local-memory in the next couple of patches.
--- drivers/gpu/drm/i915/Makefile | 2 + drivers/gpu/drm/i915/i915_buddy.c | 412 +++++++++ drivers/gpu/drm/i915/i915_buddy.h | 133 +++ drivers/gpu/drm/i915/i915_ttm_buddy_manager.c | 246 ++++++ drivers/gpu/drm/i915/i915_ttm_buddy_manager.h | 56 ++ drivers/gpu/drm/i915/selftests/i915_buddy.c | 789 ++++++++++++++++++ 6 files changed, 1638 insertions(+) create mode 100644 drivers/gpu/drm/i915/i915_buddy.c create mode 100644 drivers/gpu/drm/i915/i915_buddy.h create mode 100644 drivers/gpu/drm/i915/i915_ttm_buddy_manager.c create mode 100644 drivers/gpu/drm/i915/i915_ttm_buddy_manager.h create mode 100644 drivers/gpu/drm/i915/selftests/i915_buddy.c
drivers/gpu/drm/i915/Makefile +2 -0
@@ -162,6 +162,7 @@ gem-y += \ i915-y += \ $(gem-y) \ i915_active.o \ + i915_buddy.o \ i915_cmd_parser.o \ i915_gem_evict.o \ i915_gem_gtt.o \
@@ -171,6 +172,7 @@ i915-y += \ i915_request.o \ i915_scheduler.o \ i915_trace_points.o \ + i915_ttm_buddy_manager.o \ i915_vma.o \ intel_wopcm.o
drivers/gpu/drm/i915/i915_buddy.c new file +412 -0
412 lines not on this page · raw message
drivers/gpu/drm/i915/i915_buddy.h new file +133 -0
133 lines not on this page · raw message
drivers/gpu/drm/i915/i915_ttm_buddy_manager.c new file +246 -0
246 lines not on this page · raw message
drivers/gpu/drm/i915/i915_ttm_buddy_manager.h new file +56 -0
56 lines not on this page · raw message
drivers/gpu/drm/i915/selftests/i915_buddy.c new file +789 -0
789 lines not on this page · raw message
Signature · 6 lines
2.26.3 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 1/6] drm/i915/ttm: add ttm_buddy_man
Quoted 9 lines · Matthew Auld
Add back our standalone
i915_buddyallocator and integrate it into attm_resource_manager. This will plug into our ttm backend for managing
device local-memory in the next couple of patches.Signed-off-by Matthew Auld <[email protected]>Cc Thomas Hellström <[email protected]>---
Since the buddy + selftests have been part of the driver before, I didn't review them separately, but for the TTM interface, some minor comments below. With those fixed,
Quoted 20 lines
drivers/gpu/drm/i915/i915_ttm_buddy_manager.c new file +13
-0@@ -0,0 +1,246 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright © 2021 Intel Corporation +*/ + +#include <linux/slab.h> + +#include <drm/ttm/ttm_bo_driver.h> +#include <drm/ttm/ttm_placement.h> + +#include "i915_ttm_buddy_manager.h" + +#include "i915_buddy.h"
drivers/gpu/drm/i915/i915_ttm_buddy_manager.c line 23
Quoted 10 lines
drivers/gpu/drm/i915/i915_ttm_buddy_manager.c new file +10
-0+#include "i915_gem.h" + +struct i915_ttm_buddy_manager { + struct ttm_resource_manager manager; + struct i915_buddy_mm mm; + struct list_head reserved; + struct mutex lock; +}; + +static inline struct i915_ttm_buddy_manager *
"inline" shouldn't be needed here.
Quoted 55 lines
drivers/gpu/drm/i915/i915_ttm_buddy_manager.c new file +3
-0+to_buddy_manager(struct ttm_resource_manager *man) +{ + return container_of(man, struct i915_ttm_buddy_manager,manager);
drivers/gpu/drm/i915/i915_ttm_buddy_manager.c new file +3
-0+} + +static int i915_ttm_buddy_man_alloc(struct ttm_resource_manager*man,
+ structttm_buffer_object*bo, + const structttm_place*place, + structttm_resource**res)drivers/gpu/drm/i915/i915_ttm_buddy_manager.c new file +24
-0+{ + struct i915_ttm_buddy_manager *bman = to_buddy_manager(man); + struct i915_ttm_buddy_resource *bman_res; + struct i915_buddy_mm *mm = &bman->mm; + unsigned long n_pages; + unsigned int min_order; + u64 size; + int err; + + GEM_BUG_ON(place->fpfn || place->lpfn); + GEM_BUG_ON(bo->page_alignment < mm->chunk_size); + + bman_res = kzalloc(sizeof(*bman_res), GFP_KERNEL); + if (!bman_res) + return -ENOMEM; + + ttm_resource_init(bo, place, &bman_res->base); + INIT_LIST_HEAD(&bman_res->blocks); + bman_res->mm = mm; + + GEM_BUG_ON(!bman_res->base.num_pages); + size = bman_res->base.num_pages << PAGE_SHIFT; + + min_order = ilog2(bo->page_alignment) - ilog2(mm-Quoted 1 line
chunk_size);+ if (
place->flags&TTM_PL_FLAG_CONTIGUOUS) {
+ size =roundup_pow_of_two(size);
+ min_order = ilog2(size) -ilog2(mm->chunk_size); + }drivers/gpu/drm/i915/i915_ttm_buddy_manager.c new file +15
-0+ + if (size > mm->size) { + err = -E2BIG; + goto err_free_res; + } + + n_pages = size >> ilog2(mm->chunk_size); + + do { + struct i915_buddy_block *block; + unsigned int order; + + order = fls(n_pages) - 1; + GEM_BUG_ON(order > mm->max_order); + GEM_BUG_ON(order < min_order);
drivers/gpu/drm/i915/i915_ttm_buddy_manager.c line 85
Quoted 10 lines
drivers/gpu/drm/i915/i915_ttm_buddy_manager.c new file +10
-0+ + do { + mutex_lock(&bman->lock); + block = i915_buddy_alloc(mm, order); + mutex_unlock(&bman->lock); + if (!IS_ERR(block)) + break; + + if (order-- == min_order) { + err = -ENXIO;
IIRC, TTM relies on -ENOSPC to retry with evictions.
Quoted 14 lines
+ goto
err_free_blocks; + }
+ } while (1);drivers/gpu/drm/i915/i915_ttm_buddy_manager.c new file +11
-0+ + n_pages -= BIT(order); + + list_add_tail(&block->link, &bman_res->blocks); + + if (!n_pages) + break; + } while (1); + + *res = &bman_res->base; + return 0;
drivers/gpu/drm/i915/i915_ttm_buddy_manager.c line 109
Quoted 10 lines
drivers/gpu/drm/i915/i915_ttm_buddy_manager.c new file +10
-0+ +err_free_blocks: + mutex_lock(&bman->lock); + i915_buddy_free_list(mm, &bman_res->blocks); + mutex_unlock(&bman->lock); +err_free_res: + kfree(bman_res); + return err; +} +
/Thomas
Re: [PATCH 1/6] drm/i915/ttm: add ttm_buddy_man
Quoted 110 lines · Thomas Hellström
Quoted 9 lines · Matthew Auld
Add back our standalone
i915_buddyallocator and integrate it into attm_resource_manager. This will plug into our ttm backend for managing
device local-memory in the next couple of patches.Signed-off-by Matthew Auld <[email protected]>Cc Thomas Hellström <[email protected]>---
Since the buddy + selftests have been part of the driver before, I didn't review them separately, but for the TTM interface, some minor comments below. With those fixed,
Acked-by Thomas Hellström <[email protected]>Quoted 20 lines
drivers/gpu/drm/i915/i915_ttm_buddy_manager.c new file +13
-0@@ -0,0 +1,246 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright © 2021 Intel Corporation +*/ + +#include <linux/slab.h> + +#include <drm/ttm/ttm_bo_driver.h> +#include <drm/ttm/ttm_placement.h> + +#include "i915_ttm_buddy_manager.h" + +#include "i915_buddy.h" drivers/gpu/drm/i915/i915_ttm_buddy_manager.c line 23
Quoted 10 lines
drivers/gpu/drm/i915/i915_ttm_buddy_manager.c new file +10
-0+#include "i915_gem.h" + +struct i915_ttm_buddy_manager { + struct ttm_resource_manager manager; + struct i915_buddy_mm mm; + struct list_head reserved; + struct mutex lock; +}; + +static inline struct i915_ttm_buddy_manager *"inline" shouldn't be needed here.
Quoted 59 lines
drivers/gpu/drm/i915/i915_ttm_buddy_manager.c new file +3
-0+to_buddy_manager(struct ttm_resource_manager *man) +{ + return container_of(man, struct i915_ttm_buddy_manager,manager);
drivers/gpu/drm/i915/i915_ttm_buddy_manager.c new file +3
-0+} + +static int i915_ttm_buddy_man_alloc(struct ttm_resource_manager*man,
+ structttm_buffer_object*bo, + const structttm_place*place, + structttm_resource**res)drivers/gpu/drm/i915/i915_ttm_buddy_manager.c new file +24
-0+{ + struct i915_ttm_buddy_manager *bman = to_buddy_manager(man); + struct i915_ttm_buddy_resource *bman_res; + struct i915_buddy_mm *mm = &bman->mm; + unsigned long n_pages; + unsigned int min_order; + u64 size; + int err; + + GEM_BUG_ON(place->fpfn || place->lpfn); + GEM_BUG_ON(bo->page_alignment < mm->chunk_size); + + bman_res = kzalloc(sizeof(*bman_res), GFP_KERNEL); + if (!bman_res) + return -ENOMEM; + + ttm_resource_init(bo, place, &bman_res->base); + INIT_LIST_HEAD(&bman_res->blocks); + bman_res->mm = mm; + + GEM_BUG_ON(!bman_res->base.num_pages); + size = bman_res->base.num_pages << PAGE_SHIFT; + + min_order = ilog2(bo->page_alignment) - ilog2(mm-Quoted 1 line
chunk_size);+ if (
place->flags&TTM_PL_FLAG_CONTIGUOUS) {
+ size =roundup_pow_of_two(size);
+ min_order = ilog2(size) -ilog2(mm->chunk_size); + }drivers/gpu/drm/i915/i915_ttm_buddy_manager.c new file +19
-0+ + if (size > mm->size) { + err = -E2BIG; + goto err_free_res; + } + + n_pages = size >> ilog2(mm->chunk_size); + + do { + struct i915_buddy_block *block; + unsigned int order; + + order = fls(n_pages) - 1; + GEM_BUG_ON(order > mm->max_order); + GEM_BUG_ON(order < min_order); + + do { + mutex_lock(&bman->lock); + block = i915_buddy_alloc(mm, order);
Quoted 8 lines
Quoted 6 lines
+ mutex_unlock(&bman->lock); + if (!IS_ERR(block)) + break;
+
+ if (order-- ==min_order) { + err =-ENXIO;IIRC, TTM relies on
-ENOSPCto retry with evictions.
Ah, right. We convert that back to -ENXIO in the upper levels somewhere?
Quoted 19 lines
Quoted 19 lines
+ goto
err_free_blocks; + }
+ } while (1);drivers/gpu/drm/i915/i915_ttm_buddy_manager.c new file +15
-0+ + n_pages -= BIT(order); + + list_add_tail(&block->link, &bman_res->blocks); + + if (!n_pages) + break; + } while (1); + + *res = &bman_res->base; + return 0; + +err_free_blocks: + mutex_lock(&bman->lock); + i915_buddy_free_list(mm, &bman_res->blocks);
Quoted 10 lines
drivers/gpu/drm/i915/i915_ttm_buddy_manager.c line 109
Quoted 6 lines
+ mutex_unlock(&bman->lock);
drivers/gpu/drm/i915/i915_ttm_buddy_manager.c new file +5
-0+err_free_res: + kfree(bman_res); + return err; +} +/Thomas
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 1/6] drm/i915/ttm: add ttm_buddy_man
Quoted 120 lines · Matthew Auld
Quoted 110 lines · Thomas Hellström
Quoted 9 lines · Matthew Auld
Add back our standalone
i915_buddyallocator and integrate it into attm_resource_manager. This will plug into our ttm backend for managing
device local-memory in the next couple of patches.Signed-off-by Matthew Auld <[email protected]>Cc Thomas Hellström <[email protected]>---
Since the buddy + selftests have been part of the driver before, I didn't review them separately, but for the TTM interface, some minor comments below. With those fixed,
Acked-by Thomas Hellström <[email protected]>Quoted 20 lines
drivers/gpu/drm/i915/i915_ttm_buddy_manager.c new file +13
-0@@ -0,0 +1,246 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright © 2021 Intel Corporation +*/ + +#include <linux/slab.h> + +#include <drm/ttm/ttm_bo_driver.h> +#include <drm/ttm/ttm_placement.h> + +#include "i915_ttm_buddy_manager.h" + +#include "i915_buddy.h" drivers/gpu/drm/i915/i915_ttm_buddy_manager.c line 23
Quoted 10 lines
drivers/gpu/drm/i915/i915_ttm_buddy_manager.c new file +10
-0+#include "i915_gem.h" + +struct i915_ttm_buddy_manager { + struct ttm_resource_manager manager; + struct i915_buddy_mm mm; + struct list_head reserved; + struct mutex lock; +}; + +static inline struct i915_ttm_buddy_manager *"inline" shouldn't be needed here.
Quoted 59 lines
drivers/gpu/drm/i915/i915_ttm_buddy_manager.c new file +3
-0+to_buddy_manager(struct ttm_resource_manager *man) +{ + return container_of(man, struct i915_ttm_buddy_manager,manager);
drivers/gpu/drm/i915/i915_ttm_buddy_manager.c new file +3
-0+} + +static int i915_ttm_buddy_man_alloc(struct ttm_resource_manager*man,
+ structttm_buffer_object*bo, + const structttm_place*place, + structttm_resource**res)drivers/gpu/drm/i915/i915_ttm_buddy_manager.c new file +24
-0+{ + struct i915_ttm_buddy_manager *bman = to_buddy_manager(man); + struct i915_ttm_buddy_resource *bman_res; + struct i915_buddy_mm *mm = &bman->mm; + unsigned long n_pages; + unsigned int min_order; + u64 size; + int err; + + GEM_BUG_ON(place->fpfn || place->lpfn); + GEM_BUG_ON(bo->page_alignment < mm->chunk_size); + + bman_res = kzalloc(sizeof(*bman_res), GFP_KERNEL); + if (!bman_res) + return -ENOMEM; + + ttm_resource_init(bo, place, &bman_res->base); + INIT_LIST_HEAD(&bman_res->blocks); + bman_res->mm = mm; + + GEM_BUG_ON(!bman_res->base.num_pages); + size = bman_res->base.num_pages << PAGE_SHIFT; + + min_order = ilog2(bo->page_alignment) - ilog2(mm-Quoted 1 line
chunk_size);+ if (
place->flags&TTM_PL_FLAG_CONTIGUOUS) {
+ size =roundup_pow_of_two(size);
+ min_order = ilog2(size) -ilog2(mm->chunk_size); + }drivers/gpu/drm/i915/i915_ttm_buddy_manager.c new file +19
-0+ + if (size > mm->size) { + err = -E2BIG; + goto err_free_res; + } + + n_pages = size >> ilog2(mm->chunk_size); + + do { + struct i915_buddy_block *block; + unsigned int order; + + order = fls(n_pages) - 1; + GEM_BUG_ON(order > mm->max_order); + GEM_BUG_ON(order < min_order); + + do { + mutex_lock(&bman->lock); + block = i915_buddy_alloc(mm, order);Quoted 8 lines
Quoted 6 lines
+ mutex_unlock(&bman->lock); + if (!IS_ERR(block)) + break;
+
+ if (order-- ==min_order) { + err =-ENXIO;IIRC, TTM relies on
-ENOSPCto retry with evictions.
Quoted 2 lines
Ah, right. We convert that back to
-ENXIOin the upper levels somewhere?
Yes, that's done in the ttm bo backend after ttm_bo_validate() and bo initialization.
/Thomas
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/6 drm/i915/ttm: add i915_sg_from_buddy_resource
In reply to Matthew AuldWe need to be able to build an sg table from our list of buddy blocks, so that we can later plug this into our ttm backend, and replace our use of the range manager.
--- drivers/gpu/drm/i915/i915_scatterlist.c | 80 +++++++++++++++++++++++++ drivers/gpu/drm/i915/i915_scatterlist.h | 5 ++ 2 files changed, 85 insertions(+)
drivers/gpu/drm/i915/i915_scatterlist.c +80 -0
@@ -6,6 +6,9 @@#include "i915_scatterlist.h" +#include "i915_buddy.h" +#include "i915_ttm_buddy_manager.h" +#include <drm/drm_mm.h> #include <linux/slab.h>
@@ -104,6 +107,83 @@ struct sg_table *i915_sg_from_mm_node(const struct drm_mm_node *node,return st; } +/** +* i915_sg_from_buddy_resource - Create an sg_table from a struct +* i915_buddy_block list +* @res: The i915_ttm_buddy_resource. +* @region_start: An offset to add to the dma addresses of the sg list. +* +* Create a struct sg_table, initializing it from struct i915_buddy_block list, +* taking a maximum segment length into account, splitting into segments +* if necessary. +* +* Return: A pointer to a kmalloced struct sg_table on success, negative +* error code cast to an error pointer on failure. +*/ +struct sg_table *i915_sg_from_buddy_resource (struct ttm_resource *res, +u64 region_start) +{ +struct i915_ttm_buddy_resource *bman_res =to_ttm_buddy_resource (res); +struct i915_buddy_mm *mm = bman_res->mm; +const u64 size = res->num_pages <<PAGE_SHIFT ; +const u64 max_segment =UINT_MAX ; +struct list_head *blocks = &bman_res->blocks; +struct i915_buddy_block *block; +struct scatterlist *sg; +struct sg_table *st; +resource_size_t prev_end; + +GEM_BUG_ON (list_empty (blocks)); + + st =kmalloc (sizeof (*st),GFP_KERNEL ); +if (!st) +return ERR_PTR (-ENOMEM ); + +if (sg_alloc_table (st, size >>PAGE_SHIFT ,GFP_KERNEL )) { +kfree (st); +return ERR_PTR (-ENOMEM ); + } + + sg = st->sgl; + st->nents =0 ; + prev_end = (resource_size_t)-1 ; + +list_for_each_entry (block, blocks, link) { +u64 block_size, offset; + + block_size =min_t (u64, size,i915_buddy_block_size (mm, block)); + offset =i915_buddy_block_offset (block); + +while (block_size) { +u64 len; + +if (offset != prev_end || sg->length >= max_segment) { +if (st->nents) + sg =__sg_next (sg); + +sg_dma_address (sg) = region_start + offset; +sg_dma_len (sg) =0 ; + sg->length =0 ; + st->nents++; + } + + len =min (block_size, max_segment - sg->length); + sg->length += len; +sg_dma_len (sg) += len; + + offset += len; + block_size -= len; + + prev_end = offset; + } + } + +sg_mark_end (sg); +i915_sg_trim (st); + +return st; +} +#if IS_ENABLED (CONFIG_DRM_I915_SELFTEST )#include "selftests/scatterlist.c" #endif
drivers/gpu/drm/i915/i915_scatterlist.h +5 -0
@@ -14,6 +14,7 @@#include "i915_gem.h" struct drm_mm_node ; +struct ttm_resource ;/* * Optimised SGL iterator for GEM objects
@@ -145,4 +146,8 @@ bool i915_sg_trim(struct sg_table *orig_st);struct sg_table *i915_sg_from_mm_node (const struct drm_mm_node *node,u64 region_start); + +struct sg_table *i915_sg_from_buddy_resource (struct ttm_resource *res, +u64 region_start); +#endif
Signature · 1 line
2.26.3
Re: [PATCH 2/6] drm/i915/ttm: add i915_sg_from_buddy_resource
Quoted 8 lines · Matthew Auld
We need to be able to build an sg table from our list of buddy blocks,
so that we can later plug this into our ttm backend, and replace our use
of the range manager.Signed-off-by Matthew Auld <[email protected]>Cc Thomas Hellström <[email protected]>
Not sure whether this is the best place to put this or move both the drm_mm variant and this to the TTM region code, but I guess it doesn't really matter.
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/6 drm/i915/ttm: Calculate the object placement at get_pages time
In reply to Matthew AuldFrom: Thomas Hellström <[email protected]>
Instead of relying on a static placement, calculate at get_pages() time. This should work for LMEM regions and system for now. For stolen we need to take preallocated range into account. That well be added later.
--- drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 69 +++++++++++++++++++++---- drivers/gpu/drm/i915/intel_region_ttm.c | 8 ++- drivers/gpu/drm/i915/intel_region_ttm.h | 2 + 3 files changed, 68 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_ttm.c +60 -9
@@ -24,6 +24,11 @@#define I915_TTM_PRIO_NO_PAGES 1#define I915_TTM_PRIO_HAS_PAGES 2 +/* +* Size of struct ttm_place vector in on-stack struct ttm_placement allocs +*/ +#define I915_TTM_MAX_PLACEMENTS 10 +/** * struct i915_ttm_tt - TTM page vector with additional private information * @ttm: The base TTM page vector.
@@ -56,13 +61,6 @@ static const struct ttm_place lmem0_sys_placement_flags[] = { } }; -static struct ttm_placement i915_lmem0_placement = { - .num_placement =1 , - .placement = &lmem0_sys_placement_flags[0 ], - .num_busy_placement =1 , - .busy_placement = &lmem0_sys_placement_flags[0 ], -}; -static struct ttm_placement i915_sys_placement = { .num_placement =1 , .placement = &lmem0_sys_placement_flags[1 ],
@@ -72,6 +70,55 @@ static struct ttm_placement i915_sys_placement = {static void i915_ttm_adjust_lru (struct drm_i915_gem_object *obj); +static enum ttm_caching +i915_ttm_select_tt_caching (const struct drm_i915_gem_object *obj) +{ +/* +* Objects only allowed in system get cached cpu-mappings. +* Other objects get WC mapping for now. Even if in system. +*/ +if (obj->mm.region->type ==INTEL_MEMORY_SYSTEM && + obj->mm.n_placements <=1 ) +return ttm_cached; + +return ttm_write_combined; +} + +static void +i915_ttm_place_from_region (const struct intel_memory_region *mr, +struct ttm_place *place) +{ +memset (place,0 ,sizeof (*place)); + place->mem_type =intel_region_to_ttm_type (mr); +} + +static void +i915_ttm_placement_from_obj (const struct drm_i915_gem_object *obj, +struct ttm_place *requested, +struct ttm_place *busy, +struct ttm_placement *placement) +{ +unsigned int i; +unsigned int num_allowed = obj->mm.n_placements; + + placement->num_placement =1 ; +i915_ttm_place_from_region (num_allowed ? obj->mm.placements[0 ] : + obj->mm.region, requested); + +/* Cache this on object? */ + placement->num_busy_placement = num_allowed; +for (i =0 ; i < placement->num_busy_placement; ++i) +i915_ttm_place_from_region (obj->mm.placements[i], busy + i); + +if (num_allowed ==0 ) { + *busy = *requested; + placement->num_busy_placement =1 ; + } + + placement->placement = requested; + placement->busy_placement = busy; +} +static struct ttm_tt *i915_ttm_tt_create (struct ttm_buffer_object *bo,uint32_t page_flags) {
@@ -89,7 +136,8 @@ static struct ttm_tt *i915_ttm_tt_create(struct ttm_buffer_object *bo, man->use_tt) page_flags |=TTM_PAGE_FLAG_ZERO_ALLOC ; - ret =ttm_tt_init (&i915_tt->ttm, bo, page_flags, ttm_write_combined); + ret =ttm_tt_init (&i915_tt->ttm, bo, page_flags, +i915_ttm_select_tt_caching (obj));if (ret) {kfree (i915_tt);return NULL ;
@@ -414,10 +462,13 @@ static int i915_ttm_get_pages(struct drm_i915_gem_object *obj) .no_wait_gpu = false, };struct sg_table *st; +struct ttm_place requested, busy[I915_TTM_MAX_PLACEMENTS ]; +struct ttm_placement placement;int ret;/* Move to the requested placement. */ - ret =ttm_bo_validate (bo, &i915_lmem0_placement, &ctx); +i915_ttm_placement_from_obj (obj, &requested, busy, &placement); + ret =ttm_bo_validate (bo, &placement, &ctx);if (ret)return ret == -ENOSPC ? -ENXIO : ret;
drivers/gpu/drm/i915/intel_region_ttm.c +6 -2
@@ -50,12 +50,16 @@ void intel_region_ttm_device_fini(struct drm_i915_private *dev_priv)* driver-private types for now, reserving TTM_PL_VRAM for stolen * memory and TTM_PL_TT for GGTT use if decided to implement this. */ -static int intel_region_to_ttm_type (struct intel_memory_region *mem) +int intel_region_to_ttm_type (const struct intel_memory_region *mem) {int type;GEM_BUG_ON (mem->type !=INTEL_MEMORY_LOCAL && - mem->type !=INTEL_MEMORY_MOCK ); + mem->type !=INTEL_MEMORY_MOCK && + mem->type !=INTEL_MEMORY_SYSTEM ); + +if (mem->type ==INTEL_MEMORY_SYSTEM ) +return TTM_PL_SYSTEM ; type = mem->instance +TTM_PL_PRIV ;GEM_BUG_ON (type >=TTM_NUM_MEM_TYPES );
drivers/gpu/drm/i915/intel_region_ttm.h +2 -0
@@ -22,6 +22,8 @@ int intel_region_ttm_init(struct intel_memory_region *mem);void intel_region_ttm_fini (struct intel_memory_region *mem); +int intel_region_to_ttm_type (const struct intel_memory_region *mem); +struct sg_table *intel_region_ttm_node_to_st (struct intel_memory_region *mem,struct ttm_resource *res);
Signature · 6 lines
2.26.3 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 4/6 drm/i915/ttm: pass along the I915_BO_ALLOC_CONTIGUOUS
In reply to Matthew AuldCurrently we just ignore the I915_BO_ALLOC_CONTIGUOUS flag, which is fine since everything is already contiguous with the ttm range manager. However in the next patch we want to switch over to the ttm buddy manager, where allocations are by default not contiguous.
--- drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_ttm.c +12 -3
@@ -86,10 +86,18 @@ i915_ttm_select_tt_caching(const struct drm_i915_gem_object *obj)static void i915_ttm_place_from_region (const struct intel_memory_region *mr, -struct ttm_place *place) +struct ttm_place *place, +unsigned int flags) {memset (place,0 ,sizeof (*place)); place->mem_type =intel_region_to_ttm_type (mr); + +switch (mr->type) { +case INTEL_MEMORY_LOCAL : +if (flags &I915_BO_ALLOC_CONTIGUOUS ) + place->flags =TTM_PL_FLAG_CONTIGUOUS ; +break ; + } } static void
@@ -100,15 +108,16 @@ i915_ttm_placement_from_obj(const struct drm_i915_gem_object *obj, {unsigned int i;unsigned int num_allowed = obj->mm.n_placements; +unsigned int flags = obj->flags; placement->num_placement =1 ;i915_ttm_place_from_region (num_allowed ? obj->mm.placements[0 ] : - obj->mm.region, requested); + obj->mm.region, requested, flags);/* Cache this on object? */ placement->num_busy_placement = num_allowed;for (i =0 ; i < placement->num_busy_placement; ++i) -i915_ttm_place_from_region (obj->mm.placements[i], busy + i); +i915_ttm_place_from_region (obj->mm.placements[i], busy + i, flags);if (num_allowed ==0 ) { *busy = *requested;
Signature · 1 line
2.26.3
Re: [PATCH 4/6] drm/i915/ttm: pass along the I915_BO_ALLOC_CONTIGUOUS
Hi,
Quoted 27 lines · Matthew Auld
Currently we just ignore the
I915_BO_ALLOC_CONTIGUOUSflag, which is fine since everything is already contiguous with the ttm range manager.
However in the next patch we want to switch over to the ttm buddy manager, where allocations are by default not contiguous.Signed-off-by Matthew Auld <[email protected]>Cc Thomas Hellström <[email protected]>---
drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 15 ++++++++++++---1 file changed, 12 insertions(+), 3 deletions(-)drivers/gpu/drm/i915/gem/i915_gem_ttm.c +0
-0@@ -86,10 +86,18 @@ i915_ttm_select_tt_caching(const struct drm_i915_gem_object *obj)
static void
i915_ttm_place_from_region(const structintel_memory_region*mr, - structttm_place*place)
+ structttm_place*place,
+ unsigned int flags)
{
memset(place, 0,sizeof(*place));
Quoted 8 lines
place->mem_type =
intel_region_to_ttm_type(mr); +
+ switch(mr->type) {
+ caseINTEL_MEMORY_LOCAL:
+ if (flags &I915_BO_ALLOC_CONTIGUOUS) + place->flags =TTM_PL_FLAG_CONTIGUOUS; + break;
+ }
Do we need to restrict this to INTEL_MEMORY_LOCAL? While it doesn't currently make much sense for other memory regions, no point in not forwarding for all?
/Thomas
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 4/6] drm/i915/ttm: pass along the I915_BO_ALLOC_CONTIGUOUS
Quoted 34 lines · Thomas Hellström
Hi,
Quoted 31 lines · Matthew Auld
Currently we just ignore the
I915_BO_ALLOC_CONTIGUOUSflag, which is fine since everything is already contiguous with the ttm range manager.
However in the next patch we want to switch over to the ttm buddy manager, where allocations are by default not contiguous.Signed-off-by Matthew Auld <[email protected]>Cc Thomas Hellström <[email protected]>--- drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)drivers/gpu/drm/i915/gem/i915_gem_ttm.c +5
-1@@ -86,10 +86,18 @@ i915_ttm_select_tt_caching(const struct drm_i915_gem_object *obj) static void i915_ttm_place_from_region(const struct intel_memory_region *mr, - struct ttm_place *place) + struct ttm_place *place, + unsigned int flags) { memset(place, 0, sizeof(*place)); place->mem_type = intel_region_to_ttm_type(mr); + + switch(mr->type) { + case INTEL_MEMORY_LOCAL:
Quoted 8 lines
drivers/gpu/drm/i915/gem/i915_gem_ttm.c i915_ttm_select_tt_caching(const struct drm_i915_gem_object *obj) · line 100
Quoted 4 lines
drivers/gpu/drm/i915/gem/i915_gem_ttm.c +4
-0+ if (flags & I915_BO_ALLOC_CONTIGUOUS) + place->flags = TTM_PL_FLAG_CONTIGUOUS; + break; + }Do we need to restrict this to
INTEL_MEMORY_LOCAL? While it doesn't currently make much sense for other memory regions, no point in not forwarding for all?
Yeah, don't see why not.
Quoted 4 lines
/Thomas
PATCH 5/6 drm/i915/ttm: switch over to ttm_buddy_man
In reply to Matthew AuldMove back to the buddy allocator for managing device local memory, and restore the lost mock selftests. Keep around the range manager related bits, since we likely need this for managing stolen at some point. For stolen we also don't need to reserve anything so no need to support a generic reserve interface.
--- drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 26 +-- drivers/gpu/drm/i915/intel_memory_region.c | 55 +----- drivers/gpu/drm/i915/intel_memory_region.h | 17 -- drivers/gpu/drm/i915/intel_region_ttm.c | 100 +++-------- .../drm/i915/selftests/intel_memory_region.c | 170 ++++++++++++------ drivers/gpu/drm/i915/selftests/mock_region.c | 15 +- 6 files changed, 168 insertions(+), 215 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_ttm.c +7 -19
@@ -185,11 +185,7 @@ static bool i915_ttm_eviction_valuable(struct ttm_buffer_object *bo,struct drm_i915_gem_object *obj =i915_ttm_to_gem (bo);/* Will do for now. Our pinned objects are still on TTM's LRU lists */ -if (!i915_gem_object_evictable (obj)) -return false; - -/* This isn't valid with a buddy allocator */ -return ttm_bo_eviction_valuable (bo, place); +return i915_gem_object_evictable (obj); } static void i915_ttm_evict_flags(struct ttm_buffer_object *bo,
@@ -332,11 +328,15 @@ i915_ttm_resource_get_st(struct drm_i915_gem_object *obj,struct ttm_buffer_object *bo =i915_gem_to_ttm (obj);struct ttm_resource_manager *man =ttm_manager_type (bo->bdev, res->mem_type); +struct intel_memory_region *mr = obj->mm.region;if (man->use_tt)return i915_ttm_tt_get_st (bo->ttm); -return intel_region_ttm_node_to_st (obj->mm.region, res->mm_node); +if (mr->is_range_manager) +return intel_region_ttm_node_to_st (mr, res); +else +return i915_sg_from_buddy_resource (res, mr->region.start); } static int i915_ttm_move(struct ttm_buffer_object *bo, bool evict,
@@ -661,20 +661,8 @@ int __i915_gem_ttm_object_init(struct intel_memory_region *mem,static struct lock_class_key lock_class;struct drm_i915_private *i915 = mem->i915;enum ttm_bo_type bo_type; -size_t alignment =0 ;int ret; -/* Adjust alignment to GPU- and CPU huge page sizes. */ - -if (mem->is_range_manager) { -if (size >=SZ_1G ) - alignment =SZ_1G >>PAGE_SHIFT ; -else if (size >=SZ_2M ) - alignment =SZ_2M >>PAGE_SHIFT ; -else if (size >=SZ_64K ) - alignment =SZ_64K >>PAGE_SHIFT ; - } -drm_gem_private_object_init (&i915->drm, &obj->base, size);i915_gem_object_init (obj, &i915_gem_ttm_obj_ops, &lock_class, flags);i915_gem_object_init_memory_region (obj, mem);
@@ -696,7 +684,7 @@ int __i915_gem_ttm_object_init(struct intel_memory_region *mem,*/ obj->base.vma_node.driver_private =i915_gem_to_ttm (obj); ret =ttm_bo_init (&i915->bdev,i915_gem_to_ttm (obj), size, - bo_type, &i915_sys_placement, alignment, + bo_type, &i915_sys_placement,PAGE_SIZE , true,NULL ,NULL , i915_ttm_bo_destroy);if (!ret)
drivers/gpu/drm/i915/intel_memory_region.c +4 -51
96 lines not on this page · raw message
drivers/gpu/drm/i915/intel_memory_region.h +0 -17
@@ -59,19 +59,10 @@ struct intel_memory_region_ops { unsigned int flags); }; -struct intel_memory_region_private_ops { -struct ttm_resource *(*reserve)(struct intel_memory_region *mem, -resource_size_t offset, -resource_size_t size); -void (*free)(struct intel_memory_region *mem, -struct ttm_resource *res); -}; -struct intel_memory_region {struct drm_i915_private *i915;const struct intel_memory_region_ops *ops; -const struct intel_memory_region_private_ops *priv_ops;struct io_mapping iomap;struct resource region;
@@ -79,8 +70,6 @@ struct intel_memory_region {/* For fake LMEM */ struct drm_mm_node fake_mappable; -struct mutex mm_lock; -struct kref kref;resource_size_t io_start;
@@ -94,8 +83,6 @@ struct intel_memory_region {char name[16 ];bool private;/* not for userspace */ -struct list_head reserved; -dma_addr_t remap_addr;struct {
@@ -103,8 +90,6 @@ struct intel_memory_region {struct list_head list; } objects; -size_t chunk_size; -unsigned int max_order;bool is_range_manager;void *region_private;
@@ -138,8 +123,6 @@ __printf(2, 3) void intel_memory_region_set_name(struct intel_memory_region *mem, const char *fmt, ...); -void intel_memory_region_unreserve (struct intel_memory_region *mem); -int intel_memory_region_reserve (struct intel_memory_region *mem,resource_size_t offset,resource_size_t size);
drivers/gpu/drm/i915/intel_region_ttm.c +27 -73
138 lines not on this page · raw message
drivers/gpu/drm/i915/selftests/intel_memory_region.c +119 -51
286 lines not on this page · raw message
drivers/gpu/drm/i915/selftests/mock_region.c +11 -4
@@ -3,6 +3,7 @@* Copyright © 2019-2021 Intel Corporation */ +#include <drm/ttm/ttm_placement.h> #include <linux/scatterlist.h> #include <drm/ttm/ttm_placement.h>
@@ -25,10 +26,11 @@ static int mock_region_get_pages(struct drm_i915_gem_object *obj) {unsigned int flags;struct sg_table *pages; +int err; flags =I915_ALLOC_MIN_PAGE_SIZE ;if (obj->flags &I915_BO_ALLOC_CONTIGUOUS ) - flags |=I915_ALLOC_CONTIGUOUS ; + flags |=TTM_PL_FLAG_CONTIGUOUS ; obj->mm.st_mm_node = intel_region_ttm_node_alloc(obj->mm.region, obj->base.size,
@@ -36,15 +38,20 @@ static int mock_region_get_pages(struct drm_i915_gem_object *obj)if (IS_ERR (obj->mm.st_mm_node))return PTR_ERR (obj->mm.st_mm_node); - pages =intel_region_ttm_node_to_st (obj->mm.region, obj->mm.st_mm_node); + pages =i915_sg_from_buddy_resource (obj->mm.st_mm_node, + obj->mm.region->region.start);if (IS_ERR (pages)) { -intel_region_ttm_node_free (obj->mm.region, obj->mm.st_mm_node); -return PTR_ERR (pages); + err =PTR_ERR (pages); + goto err_free_mm_node; }__i915_gem_object_set_pages (obj, pages,i915_sg_dma_sizes (pages->sgl));return 0 ; + +err_free_mm_node: +intel_region_ttm_node_free (obj->mm.region, obj->mm.st_mm_node); +return err; }static const struct drm_i915_gem_object_ops mock_region_obj_ops = {
Signature · 1 line
2.26.3
Re: [PATCH 5/6] drm/i915/ttm: switch over to ttm_buddy_man
Quoted 11 lines · Matthew Auld
Move back to the buddy allocator for managing device local memory, and
restore the lost mock selftests. Keep around the range manager related
bits, since we likely need this for managing stolen at some point. For
stolen we also don't need to reserve anything so no need to support a generic reserve interface.Signed-off-by Matthew Auld <[email protected]>Cc Thomas Hellström <[email protected]>
lgtm.
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 5/6] drm/i915/ttm: switch over to ttm_buddy_man
In reply to Matthew AuldQuoted 19 lines · Matthew Auld
Move back to the buddy allocator for managing device local memory, and
restore the lost mock selftests. Keep around the range manager related
bits, since we likely need this for managing stolen at some point. For
stolen we also don't need to reserve anything so no need to support a generic reserve interface.Signed-off-by Matthew Auld <[email protected]>Cc Thomas Hellström <[email protected]>---
drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 26 +-- drivers/gpu/drm/i915/intel_memory_region.c | 55 +----- drivers/gpu/drm/i915/intel_memory_region.h | 17 -- drivers/gpu/drm/i915/intel_region_ttm.c | 100 +++-------- .../drm/i915/selftests/intel_memory_region.c | 170 ++++++++++++---- --
...
Quoted 26 lines
static int i915_ttm_move(structttm_buffer_object*bo, bool evict,drivers/gpu/drm/i915/gem/i915_gem_ttm.c +0
-1@@ -661,20 +661,8 @@ int __i915_gem_ttm_object_init(struct intel_memory_region *mem, static struct lock_class_key lock_class; struct drm_i915_private *i915 = mem->i915; enum ttm_bo_type bo_type; - size_t alignment = 0; int ret;
- /* Adjust alignment to GPU- and CPU huge page sizes. */drivers/gpu/drm/i915/gem/i915_gem_ttm.c +0
-10- - if (mem->is_range_manager) { - if (size >= SZ_1G) - alignment = SZ_1G >> PAGE_SHIFT; - else if (size >= SZ_2M) - alignment = SZ_2M >> PAGE_SHIFT; - else if (size >= SZ_64K) - alignment = SZ_64K >> PAGE_SHIFT; - } -drm_gem_private_object_init(&i915->drm,
&obj->base, size);i915_gem_object_init(obj, &i915_gem_ttm_obj_ops, &lock_class, flags);
i915_gem_object_init_memory_region(obj, mem);
drivers/gpu/drm/i915/gem/i915_gem_ttm.c int __i915_gem_ttm_object_init(struct · line 688
Quoted 6 lines
drivers/gpu/drm/i915/gem/i915_gem_ttm.c +1
-1@@ -696,7 +684,7 @@ int __i915_gem_ttm_object_init(structintel_memory_region *mem, */ obj->base.vma_node.driver_private = i915_gem_to_ttm(obj); ret = ttm_bo_init(&i915->bdev, i915_gem_to_ttm(obj), size, - bo_type, &i915_sys_placement, alignment, + bo_type, &i915_sys_placement, PAGE_SIZE,
Actually just realized that the alignment is specified in PAGE_SIZE units, so above should be s/PAGE_SIZE/1/. Might need to check that the buddy TTM interface gets this right as well.
Re: [PATCH 5/6] drm/i915/ttm: switch over to ttm_buddy_man
Quoted 51 lines · Thomas Hellström
Quoted 19 lines · Matthew Auld
Move back to the buddy allocator for managing device local memory, and
restore the lost mock selftests. Keep around the range manager related
bits, since we likely need this for managing stolen at some point. For
stolen we also don't need to reserve anything so no need to support a generic reserve interface.Signed-off-by Matthew Auld <[email protected]>Cc Thomas Hellström <[email protected]>--- drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 26 +-- drivers/gpu/drm/i915/intel_memory_region.c | 55 +----- drivers/gpu/drm/i915/intel_memory_region.h | 17 -- drivers/gpu/drm/i915/intel_region_ttm.c | 100 +++-------- .../drm/i915/selftests/intel_memory_region.c | 170 ++++++++++++------
...
Quoted 28 lines
static int i915_ttm_move(struct
ttm_buffer_object*bo, bool evict,drivers/gpu/drm/i915/gem/i915_gem_ttm.c +0
-12@@ -661,20 +661,8 @@ int __i915_gem_ttm_object_init(struct intel_memory_region *mem, static struct lock_class_key lock_class; struct drm_i915_private *i915 = mem->i915; enum ttm_bo_type bo_type; - size_t alignment = 0; int ret; - /* Adjust alignment to GPU- and CPU huge page sizes. */ - - if (mem->is_range_manager) { - if (size >= SZ_1G) - alignment = SZ_1G >> PAGE_SHIFT; - else if (size >= SZ_2M) - alignment = SZ_2M >> PAGE_SHIFT; - else if (size >= SZ_64K) - alignment = SZ_64K >> PAGE_SHIFT; - } - drm_gem_private_object_init(&i915->drm, &obj->base, size); i915_gem_object_init(obj, &i915_gem_ttm_obj_ops, &lock_class,flags);
i915_gem_object_init_memory_region(obj, mem);(quoted diff) +0
-0@@ -696,7 +684,7 @@ int __i915_gem_ttm_object_init(struct intel_memory_region *mem, */
Quoted 8 lines
drivers/gpu/drm/i915/gem/i915_gem_ttm.c int __i915_gem_ttm_object_init(struct intel_memory_region *mem, · line 687
Quoted 4 lines
drivers/gpu/drm/i915/gem/i915_gem_ttm.c +1
-1obj->base.vma_node.driver_private = i915_gem_to_ttm(obj); ret = ttm_bo_init(&i915->bdev, i915_gem_to_ttm(obj), size, - bo_type, &i915_sys_placement, alignment, + bo_type, &i915_sys_placement, PAGE_SIZE,Actually just realized that the alignment is specified in
PAGE_SIZEunits, so above should be s/PAGE_SIZE/1/. Might need to check that the buddy TTM interface gets this right as well.
Oops, and yes it looks like the buddy is also confused here.
Quoted 2 lines
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 6/6 drm/i915/ttm: restore min_page_size behaviour
In reply to Matthew AuldWe now have bo->page_alignment which perfectly describes what we need if we have min page size restrictions for lmem. We can also drop the flag here, since this is the default behaviour for all objects.
--- drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 3 +-- drivers/gpu/drm/i915/intel_memory_region.h | 3 +-- drivers/gpu/drm/i915/intel_region_ttm.c | 2 +- drivers/gpu/drm/i915/selftests/mock_region.c | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_ttm.c +1 -2
@@ -684,9 +684,8 @@ int __i915_gem_ttm_object_init(struct intel_memory_region *mem,*/ obj->base.vma_node.driver_private =i915_gem_to_ttm (obj); ret =ttm_bo_init (&i915->bdev,i915_gem_to_ttm (obj), size, - bo_type, &i915_sys_placement,PAGE_SIZE , + bo_type, &i915_sys_placement, mem->min_page_size, true,NULL ,NULL , i915_ttm_bo_destroy); -if (!ret) obj->ttm.created = true;
drivers/gpu/drm/i915/intel_memory_region.h +1 -2
@@ -40,8 +40,7 @@ enum intel_region_id {#define REGION_STOLEN_SMEM BIT(INTEL_REGION_STOLEN_SMEM)#define REGION_STOLEN_LMEM BIT(INTEL_REGION_STOLEN_LMEM) -#define I915_ALLOC_MIN_PAGE_SIZE BIT(0) -#define I915_ALLOC_CONTIGUOUS BIT(1) +#define I915_ALLOC_CONTIGUOUS BIT(0)#define for_each_memory_region (mr, i915, id) \ for (id = 0; id < ARRAY_SIZE((i915)->mm.regions); id++) \
drivers/gpu/drm/i915/intel_region_ttm.c +1 -1
@@ -153,7 +153,7 @@ intel_region_ttm_node_alloc(struct intel_memory_region *mem,int ret; mock_bo.base.size = size; - mock_bo.page_alignment =PAGE_SIZE ; + mock_bo.page_alignment = mem->min_page_size; place.flags = flags; ret = man->func->alloc (man, &mock_bo, &place, &res);
drivers/gpu/drm/i915/selftests/mock_region.c +1 -1
@@ -28,7 +28,7 @@ static int mock_region_get_pages(struct drm_i915_gem_object *obj)struct sg_table *pages;int err; - flags =I915_ALLOC_MIN_PAGE_SIZE ; + flags =0 ;if (obj->flags &I915_BO_ALLOC_CONTIGUOUS ) flags |=TTM_PL_FLAG_CONTIGUOUS ;
Signature · 6 lines
2.26.3 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 6/6] drm/i915/ttm: restore min_page_size behaviour
Quoted 21 lines · Matthew Auld
We now have
bo->page_alignmentwhich perfectly describes what we need if
we have min page size restrictions for lmem. We can also drop the flag
here, since this is the default behaviour for all objects.Signed-off-by Matthew Auld <[email protected]>Cc Thomas Hellström <[email protected]>---
drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 3 +-- drivers/gpu/drm/i915/intel_memory_region.h | 3 +-- drivers/gpu/drm/i915/intel_region_ttm.c | 2 +-drivers/gpu/drm/i915/selftests/mock_region.c| 2 +-4 files changed, 4 insertions(+), 6 deletions(-)drivers/gpu/drm/i915/gem/i915_gem_ttm.c +0
-0
drivers/gpu/drm/i915/gem/i915_gem_ttm.c int __i915_gem_ttm_object_init(struct · line 689
Quoted 7 lines
drivers/gpu/drm/i915/gem/i915_gem_ttm.c +1
-1@@ -684,9 +684,8 @@ int __i915_gem_ttm_object_init(structintel_memory_region *mem, */ obj->base.vma_node.driver_private = i915_gem_to_ttm(obj); ret = ttm_bo_init(&i915->bdev, i915_gem_to_ttm(obj), size, - bo_type, &i915_sys_placement, PAGE_SIZE, + bo_type, &i915_sys_placement, mem- >min_page_size,
Page size units here as well.
Quoted 28 lines
drivers/gpu/drm/i915/gem/i915_gem_ttm.c +0
-1true, NULL, NULL, i915_ttm_bo_destroy); - if (!ret)obj->ttm.created = true;
drivers/gpu/drm/i915/intel_memory_region.h +0
-0@@ -40,8 +40,7 @@ enum intel_region_id { #define REGION_STOLEN_SMEM BIT(INTEL_REGION_STOLEN_SMEM) #define REGION_STOLEN_LMEM BIT(INTEL_REGION_STOLEN_LMEM)drivers/gpu/drm/i915/intel_memory_region.h +1
-2-#define I915_ALLOC_MIN_PAGE_SIZE BIT(0) -#define I915_ALLOC_CONTIGUOUS BIT(1) +#define I915_ALLOC_CONTIGUOUS BIT(0)
#definefor_each_memory_region(mr, i915, id)\
for (id = 0; id < ARRAY_SIZE((i915)->mm.regions); id++) \drivers/gpu/drm/i915/intel_region_ttm.c +0
-0@@ -153,7 +153,7 @@ intel_region_ttm_node_alloc(structintel_memory_region *mem, int ret;
Quoted 4 lines
mock_bo.base.size = size;
- mock_bo.page_alignment =PAGE_SIZE; + mock_bo.page_alignment =mem->min_page_size;
And here.
Quoted 18 lines
place.flags = flags;
ret =man->func->alloc(man, &mock_bo, &place, &res);drivers/gpu/drm/i915/selftests/mock_region.c +0
-0@@ -28,7 +28,7 @@ static int mock_region_get_pages(struct drm_i915_gem_object *obj) struct sg_table *pages; int err;
- flags =I915_ALLOC_MIN_PAGE_SIZE; + flags = 0;
if (obj->flags&I915_BO_ALLOC_CONTIGUOUS) flags |=TTM_PL_FLAG_CONTIGUOUS;
Patchwork
CI[Intel-gfx] ✗ Fi.CI.BUILD: failure for Add back the buddy allocator
In reply to Matthew Auld== Series Details ==
== Series Details ==
Series: Add back the buddy allocator
URL : https://patchwork.freedesktop.org/series/91110/
State : failure
== Summary ==
Applying: drm/i915/ttm: add ttm_buddy_man
Applying: drm/i915/ttm: add i915_sg_from_buddy_resource
Applying: drm/i915/ttm: Calculate the object placement at get_pages time
error: sha1 information is lacking or useless (drivers/gpu/drm/i915/gem/i915_gem_ttm.c).
error: could not build fake ancestor
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0003 drm/i915/ttm: Calculate the object placement at get_pages time When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx