summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/i915/i915_ttm_buddy_manager.c
diff options
context:
space:
mode:
authorMatthew Auld <matthew.auld@intel.com>2021-06-25 13:38:23 +0300
committerMatthew Auld <matthew.auld@intel.com>2021-06-30 15:24:29 +0300
commitd22632c83b948e4f7a3d4202a884be2409098cc2 (patch)
tree6c54a39208b130222bea51a6ba2a53f0137bc0ad /drivers/gpu/drm/i915/i915_ttm_buddy_manager.c
parente11b7b6e574d57b99952213b5388db66445b18f2 (diff)
downloadlinux-d22632c83b948e4f7a3d4202a884be2409098cc2.tar.xz
drm/i915: support forcing the page size with lmem
For some specialised objects we might need something larger than the regions min_page_size due to some hw restriction, and slightly more hairy is needing something smaller with the guarantee that such objects will never be inserted into any GTT, which is the case for the paging structures. This also fixes how we setup the BO page_alignment, if we later migrate the object somewhere else. For example if the placements are {SMEM, LMEM}, then we might get this wrong. Pushing the min_page_size behaviour into the manager should fix this. v2(Thomas): push the default page size behaviour into buddy_man, and let the user override it with the page-alignment, which looks cleaner v3: rebase on ttm sys changes Signed-off-by: Matthew Auld <matthew.auld@intel.com> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com> Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20210625103824.558481-1-matthew.auld@intel.com
Diffstat (limited to 'drivers/gpu/drm/i915/i915_ttm_buddy_manager.c')
-rw-r--r--drivers/gpu/drm/i915/i915_ttm_buddy_manager.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/drivers/gpu/drm/i915/i915_ttm_buddy_manager.c b/drivers/gpu/drm/i915/i915_ttm_buddy_manager.c
index fc7ad5c035b8..6877362f6b85 100644
--- a/drivers/gpu/drm/i915/i915_ttm_buddy_manager.c
+++ b/drivers/gpu/drm/i915/i915_ttm_buddy_manager.c
@@ -18,6 +18,7 @@ struct i915_ttm_buddy_manager {
struct i915_buddy_mm mm;
struct list_head reserved;
struct mutex lock;
+ u64 default_page_size;
};
static struct i915_ttm_buddy_manager *
@@ -53,7 +54,10 @@ static int i915_ttm_buddy_man_alloc(struct ttm_resource_manager *man,
GEM_BUG_ON(!bman_res->base.num_pages);
size = bman_res->base.num_pages << PAGE_SHIFT;
- min_page_size = bo->page_alignment << PAGE_SHIFT;
+ min_page_size = bman->default_page_size;
+ if (bo->page_alignment)
+ min_page_size = bo->page_alignment << PAGE_SHIFT;
+
GEM_BUG_ON(min_page_size < mm->chunk_size);
min_order = ilog2(min_page_size) - ilog2(mm->chunk_size);
if (place->flags & TTM_PL_FLAG_CONTIGUOUS) {
@@ -134,6 +138,9 @@ static const struct ttm_resource_manager_func i915_ttm_buddy_manager_func = {
* @type: Memory type we want to manage
* @use_tt: Set use_tt for the manager
* @size: The size in bytes to manage
+ * @default_page_size: The default minimum page size in bytes for allocations,
+ * this must be at least as large as @chunk_size, and can be overridden by
+ * setting the BO page_alignment, to be larger or smaller as needed.
* @chunk_size: The minimum page size in bytes for our allocations i.e
* order-zero
*
@@ -154,7 +161,8 @@ static const struct ttm_resource_manager_func i915_ttm_buddy_manager_func = {
*/
int i915_ttm_buddy_man_init(struct ttm_device *bdev,
unsigned int type, bool use_tt,
- u64 size, u64 chunk_size)
+ u64 size, u64 default_page_size,
+ u64 chunk_size)
{
struct ttm_resource_manager *man;
struct i915_ttm_buddy_manager *bman;
@@ -170,6 +178,8 @@ int i915_ttm_buddy_man_init(struct ttm_device *bdev,
mutex_init(&bman->lock);
INIT_LIST_HEAD(&bman->reserved);
+ GEM_BUG_ON(default_page_size < chunk_size);
+ bman->default_page_size = default_page_size;
man = &bman->manager;
man->use_tt = use_tt;