From: Matthew Auld <matthew.auld@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Subject: [Intel-xe] [PATCH 4/6] drm/xe/buddy: remove the virtualized start
Date: Wed, 1 Mar 2023 14:48:13 +0000 [thread overview]
Message-ID: <20230301144815.248239-5-matthew.auld@intel.com> (raw)
In-Reply-To: <20230301144815.248239-1-matthew.auld@intel.com>
Hopefully not needed anymore. We can add a .compatible() hook once we
need to differentiate between mappable and non-mappable vram. If the
allocation is not contiguous then the start value is kind of
meaningless, so rather just mark as invalid.
In upstream, TTM wants to eventually remove the ttm_resource.start
usage.
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
drivers/gpu/drm/xe/xe_bo.c | 6 ++++++
drivers/gpu/drm/xe/xe_ttm_vram_mgr.c | 29 ++++++++++++++--------------
2 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
index 876f77669104..9216adc671a3 100644
--- a/drivers/gpu/drm/xe/xe_bo.c
+++ b/drivers/gpu/drm/xe/xe_bo.c
@@ -662,6 +662,12 @@ static int xe_bo_move(struct ttm_buffer_object *ttm_bo, bool evict,
void *new_addr = gt->mem.vram.mapping +
(new_mem->start << PAGE_SHIFT);
+ if (XE_WARN_ON(new_mem->start == XE_BO_INVALID_OFFSET)) {
+ ret = -EINVAL;
+ xe_device_mem_access_put(xe);
+ goto out;
+ }
+
XE_BUG_ON(new_mem->start !=
bo->placements->fpfn);
diff --git a/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c b/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c
index 643365b18bc7..e3ac8c6d3978 100644
--- a/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c
+++ b/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c
@@ -54,7 +54,6 @@ static int xe_ttm_vram_mgr_new(struct ttm_resource_manager *man,
struct xe_ttm_vram_mgr_resource *vres;
u64 size, remaining_size, lpfn, fpfn;
struct drm_buddy *mm = &mgr->mm;
- struct drm_buddy_block *block;
unsigned long pages_per_block;
int r;
@@ -186,24 +185,24 @@ static int xe_ttm_vram_mgr_new(struct ttm_resource_manager *man,
list_splice_tail(trim_list, &vres->blocks);
}
- vres->base.start = 0;
- list_for_each_entry(block, &vres->blocks, link) {
- unsigned long start;
+ if (!(vres->base.placement & TTM_PL_FLAG_CONTIGUOUS) &&
+ xe_is_vram_mgr_blocks_contiguous(mm, &vres->blocks))
+ vres->base.placement |= TTM_PL_FLAG_CONTIGUOUS;
- start = drm_buddy_block_offset(block) +
- drm_buddy_block_size(mm, block);
- start >>= PAGE_SHIFT;
+ /*
+ * For some kernel objects we still rely on the start when io mapping
+ * the object.
+ */
+ if (vres->base.placement & TTM_PL_FLAG_CONTIGUOUS) {
+ struct drm_buddy_block *block = list_first_entry(&vres->blocks,
+ typeof(*block),
+ link);
- if (start > PFN_UP(vres->base.size))
- start -= PFN_UP(vres->base.size);
- else
- start = 0;
- vres->base.start = max(vres->base.start, start);
+ vres->base.start = drm_buddy_block_offset(block) >> PAGE_SHIFT;
+ } else {
+ vres->base.start = XE_BO_INVALID_OFFSET;
}
- if (xe_is_vram_mgr_blocks_contiguous(mm, &vres->blocks))
- vres->base.placement |= TTM_PL_FLAG_CONTIGUOUS;
-
*res = &vres->base;
return 0;
--
2.39.2
next prev parent reply other threads:[~2023-03-01 14:50 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-01 14:48 [Intel-xe] [PATCH 0/6] Some small-bar prep patches Matthew Auld
2023-03-01 14:48 ` [Intel-xe] [PATCH 1/6] drm/xe: add xe_ttm_stolen_cpu_access_needs_ggtt() Matthew Auld
2023-03-07 9:53 ` Gwan-gyeong Mun
2023-03-07 11:12 ` Matthew Auld
2023-03-01 14:48 ` [Intel-xe] [PATCH 2/6] drm/xe/mmio: s/lmem/vram/ Matthew Auld
2023-03-07 10:03 ` Gwan-gyeong Mun
2023-03-07 11:27 ` Matthew Auld
2023-03-07 16:26 ` Lucas De Marchi
2023-03-01 14:48 ` [Intel-xe] [PATCH 3/6] drm/xe/vram: start tracking the io_size Matthew Auld
2023-03-07 11:55 ` Gwan-gyeong Mun
2023-03-07 12:23 ` Matthew Auld
2023-03-01 14:48 ` Matthew Auld [this message]
2023-03-01 14:48 ` [Intel-xe] [PATCH 5/6] drm/xe/buddy: add visible tracking Matthew Auld
2023-03-01 14:48 ` [Intel-xe] [PATCH 6/6] drm/xe/buddy: add compatible and intersects hooks Matthew Auld
2023-03-01 14:55 ` [Intel-xe] ✓ CI.Patch_applied: success for Some small-bar prep patches Patchwork
2023-03-01 14:56 ` [Intel-xe] ✓ CI.KUnit: " Patchwork
2023-03-01 15:00 ` [Intel-xe] ✓ CI.Build: " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230301144815.248239-5-matthew.auld@intel.com \
--to=matthew.auld@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=lucas.demarchi@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox