From: Maarten Lankhorst <dev@lankhorst.se>
To: intel-xe@lists.freedesktop.org
Subject: [FOR-CI-DO-NOT-REVIEW-v3 03/12] drm/xe: Add xe_ggtt_node_addr() to avoid dereferencing xe_ggtt_node
Date: Fri, 9 Jan 2026 14:37:36 +0100 [thread overview]
Message-ID: <20260109133746.739923-4-dev@lankhorst.se> (raw)
In-Reply-To: <20260109133746.739923-1-dev@lankhorst.se>
This function makes it possible to add an offset that is applied to
all xe_ggtt_node's, and hides the internals from all its users.
Signed-off-by: Maarten Lankhorst <dev@lankhorst.se>
---
drivers/gpu/drm/xe/xe_bo.h | 8 +++++---
drivers/gpu/drm/xe/xe_ggtt.c | 11 +++++++++++
drivers/gpu/drm/xe/xe_ggtt.h | 2 ++
3 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_bo.h b/drivers/gpu/drm/xe/xe_bo.h
index 8ab4474129c3d..c914ab719f20e 100644
--- a/drivers/gpu/drm/xe/xe_bo.h
+++ b/drivers/gpu/drm/xe/xe_bo.h
@@ -9,6 +9,7 @@
#include <drm/ttm/ttm_tt.h>
#include "xe_bo_types.h"
+#include "xe_ggtt.h"
#include "xe_macros.h"
#include "xe_validation.h"
#include "xe_vm_types.h"
@@ -252,13 +253,14 @@ static inline u32
__xe_bo_ggtt_addr(struct xe_bo *bo, u8 tile_id)
{
struct xe_ggtt_node *ggtt_node = bo->ggtt_node[tile_id];
+ u64 offset;
if (XE_WARN_ON(!ggtt_node))
return 0;
- XE_WARN_ON(ggtt_node->base.size > xe_bo_size(bo));
- XE_WARN_ON(ggtt_node->base.start + ggtt_node->base.size > (1ull << 32));
- return ggtt_node->base.start;
+ offset = xe_ggtt_node_addr(ggtt_node);
+ XE_WARN_ON(offset + xe_bo_size(bo) > (1ull << 32));
+ return offset;
}
static inline u32
diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
index a78aebcd5b194..f72fd3a79a376 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.c
+++ b/drivers/gpu/drm/xe/xe_ggtt.c
@@ -1185,3 +1185,14 @@ u64 xe_ggtt_read_pte(struct xe_ggtt *ggtt, u64 offset)
{
return ioread64(ggtt->gsm + (offset / XE_PAGE_SIZE));
}
+
+/**
+ * xe_ggtt_node_addr - Get @node offset in GGTT.
+ * @node: &xe_ggtt_node
+ *
+ * Get the GGTT offset for allocated node.
+ */
+u64 xe_ggtt_node_addr(const struct xe_ggtt_node *node)
+{
+ return node->base.start;
+}
diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
index 9adfc58edf581..76336a6296c45 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.h
+++ b/drivers/gpu/drm/xe/xe_ggtt.h
@@ -61,4 +61,6 @@ void xe_ggtt_might_lock(struct xe_ggtt *ggtt);
u64 xe_ggtt_encode_pte_flags(struct xe_ggtt *ggtt, struct xe_bo *bo, u16 pat_index);
u64 xe_ggtt_read_pte(struct xe_ggtt *ggtt, u64 offset);
+u64 xe_ggtt_node_addr(const struct xe_ggtt_node *node);
+
#endif
--
2.51.0
next prev parent reply other threads:[~2026-01-09 13:38 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-09 13:37 [FOR-CI-DO-NOT-REVIEW-v3 00/12] Testing entire GGTT privatization preparation series Maarten Lankhorst
2026-01-09 13:37 ` [FOR-CI-DO-NOT-REVIEW-v3 01/12] drm/xe: Start using ggtt->start in preparation of balloon removal Maarten Lankhorst
2026-01-09 13:37 ` [FOR-CI-DO-NOT-REVIEW-v3 02/12] drm/xe: Convert xe_fb_pin to use a callback for insertion into GGTT Maarten Lankhorst
2026-01-09 13:37 ` Maarten Lankhorst [this message]
2026-01-09 13:37 ` [FOR-CI-DO-NOT-REVIEW-v3 04/12] drm/xe/display: Avoid dereferencing xe_ggtt_node Maarten Lankhorst
2026-01-09 13:37 ` [FOR-CI-DO-NOT-REVIEW-v3 05/12] drm/xe: Do not dereference ggtt_node in xe_bo.c Maarten Lankhorst
2026-01-09 13:37 ` [FOR-CI-DO-NOT-REVIEW-v3 06/12] drm/xe: Improve xe_gt_sriov_pf_config GGTT handling Maarten Lankhorst
2026-01-09 13:37 ` [FOR-CI-DO-NOT-REVIEW-v3 07/12] drm/xe: Privatize xe_ggtt_node Maarten Lankhorst
2026-01-09 13:37 ` [FOR-CI-DO-NOT-REVIEW-v3 08/12] drm/xe: Make xe_ggtt_node offset relative to starting offset Maarten Lankhorst
2026-01-09 13:37 ` [FOR-CI-DO-NOT-REVIEW-v3 09/12] drm/xe: Rewrite GGTT VF initialisation Maarten Lankhorst
2026-01-09 13:37 ` [FOR-CI-DO-NOT-REVIEW-v3 10/12] drm/xe: Move struct xe_ggtt to xe_ggtt.c Maarten Lankhorst
2026-01-09 13:37 ` [FOR-CI-DO-NOT-REVIEW-v3 11/12] drm/xe: Make xe_ggtt_node_insert return a node Maarten Lankhorst
2026-01-09 13:37 ` [FOR-CI-DO-NOT-REVIEW-v3 12/12] drm/xe: Remove xe_ggtt_node_allocated Maarten Lankhorst
2026-01-09 13:44 ` ✗ CI.checkpatch: warning for Testing entire GGTT privatization preparation series. (rev4) Patchwork
2026-01-09 13:45 ` ✓ CI.KUnit: success " Patchwork
2026-01-09 14:22 ` ✗ Xe.CI.BAT: failure " Patchwork
2026-01-09 17:57 ` ✗ Xe.CI.Full: " 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=20260109133746.739923-4-dev@lankhorst.se \
--to=dev@lankhorst.se \
--cc=intel-xe@lists.freedesktop.org \
/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