From: Maarten Lankhorst <dev@lankhorst.se>
To: intel-xe@lists.freedesktop.org
Cc: Maarten Lankhorst <dev@lankhorst.se>,
Matthew.brost@intel.com,
Michal Wajdeczko <michal.wajdeczko@intel.com>
Subject: [PATCH v2 6/7] drm/xe: Improve xe_gt_sriov_pf_config GGTT handling
Date: Thu, 8 Jan 2026 11:10:21 +0100 [thread overview]
Message-ID: <20260108101014.579906-15-dev@lankhorst.se> (raw)
In-Reply-To: <20260108101014.579906-9-dev@lankhorst.se>
Do not directly dereference xe_ggtt_node, and add
a function to retrieve the allocated GGTT size.
Reviewed-by: Matthew.brost@intel.com
Reviewed-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Signed-off-by: Maarten Lankhorst <dev@lankhorst.se>
---
drivers/gpu/drm/xe/xe_ggtt.c | 11 +++++++++++
drivers/gpu/drm/xe/xe_ggtt.h | 1 +
drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 15 ++++++++-------
3 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
index 7f45bcd0c56b0..e396f33e2c5c9 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.c
+++ b/drivers/gpu/drm/xe/xe_ggtt.c
@@ -1196,3 +1196,14 @@ u64 xe_ggtt_node_addr(const struct xe_ggtt_node *node)
{
return node->base.start;
}
+
+/**
+ * xe_ggtt_node_size - Get @node allocation size.
+ * @node: &xe_ggtt_node
+ *
+ * Get the allocated node's size.
+ */
+u64 xe_ggtt_node_size(const struct xe_ggtt_node *node)
+{
+ return node->base.size;
+}
diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
index 76336a6296c45..70d5e07ac4b66 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.h
+++ b/drivers/gpu/drm/xe/xe_ggtt.h
@@ -62,5 +62,6 @@ u64 xe_ggtt_encode_pte_flags(struct xe_ggtt *ggtt, struct xe_bo *bo, u16 pat_ind
u64 xe_ggtt_read_pte(struct xe_ggtt *ggtt, u64 offset);
u64 xe_ggtt_node_addr(const struct xe_ggtt_node *node);
+u64 xe_ggtt_node_size(const struct xe_ggtt_node *node);
#endif
diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
index bed6580d8d090..9f2525f3cb379 100644
--- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
+++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
@@ -284,7 +284,7 @@ static u32 encode_config_ggtt(u32 *cfg, const struct xe_gt_sriov_config *config,
if (!xe_ggtt_node_allocated(node))
return 0;
- return encode_ggtt(cfg, node->base.start, node->base.size, details);
+ return encode_ggtt(cfg, xe_ggtt_node_addr(node), xe_ggtt_node_size(node), details);
}
static u32 encode_config_sched(struct xe_gt *gt, u32 *cfg, u32 n,
@@ -545,9 +545,9 @@ static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size)
xe_ggtt_assign(node, vfid);
xe_gt_sriov_dbg_verbose(gt, "VF%u assigned GGTT %llx-%llx\n",
- vfid, node->base.start, node->base.start + node->base.size - 1);
+ vfid, xe_ggtt_node_addr(node), xe_ggtt_node_addr(node) + size - 1);
- err = pf_distribute_config_ggtt(gt->tile, vfid, node->base.start, node->base.size);
+ err = pf_distribute_config_ggtt(gt->tile, vfid, xe_ggtt_node_addr(node), size);
if (unlikely(err))
goto err;
@@ -564,7 +564,7 @@ static u64 pf_get_vf_config_ggtt(struct xe_gt *gt, unsigned int vfid)
struct xe_ggtt_node *node = config->ggtt_region;
xe_gt_assert(gt, xe_gt_is_main_type(gt));
- return xe_ggtt_node_allocated(node) ? node->base.size : 0;
+ return xe_ggtt_node_allocated(node) ? xe_ggtt_node_size(node) : 0;
}
/**
@@ -3040,11 +3040,12 @@ int xe_gt_sriov_pf_config_print_ggtt(struct xe_gt *gt, struct drm_printer *p)
if (!xe_ggtt_node_allocated(config->ggtt_region))
continue;
- string_get_size(config->ggtt_region->base.size, 1, STRING_UNITS_2,
+ string_get_size(xe_ggtt_node_size(config->ggtt_region), 1, STRING_UNITS_2,
buf, sizeof(buf));
drm_printf(p, "VF%u:\t%#0llx-%#llx\t(%s)\n",
- n, config->ggtt_region->base.start,
- config->ggtt_region->base.start + config->ggtt_region->base.size - 1,
+ n, xe_ggtt_node_addr(config->ggtt_region),
+ xe_ggtt_node_addr(config->ggtt_region) +
+ xe_ggtt_node_size(config->ggtt_region) - 1,
buf);
}
--
2.51.0
next prev parent reply other threads:[~2026-01-08 10:10 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-08 10:10 [PATCH v2 0/7] drm/xe: Privatize struct xe_ggtt_node Maarten Lankhorst
2026-01-08 10:10 ` [PATCH v2 1/7] drm/xe: Start using ggtt->start in preparation of balloon removal Maarten Lankhorst
2026-01-08 10:10 ` [PATCH v2 2/7] drm/xe: Convert xe_fb_pin to use a callback for insertion into GGTT Maarten Lankhorst
2026-01-08 10:10 ` [PATCH v2 3/7] drm/xe: Add xe_ggtt_node_addr() to avoid dereferencing xe_ggtt_node Maarten Lankhorst
2026-01-08 16:15 ` Matthew Brost
2026-01-08 10:10 ` [PATCH v2 4/7] drm/xe/display: Avoid " Maarten Lankhorst
2026-01-12 14:46 ` Rodrigo Vivi
2026-01-08 10:10 ` [PATCH v2 5/7] drm/xe: Do not dereference ggtt_node in xe_bo.c Maarten Lankhorst
2026-01-08 16:16 ` Matthew Brost
2026-01-08 10:10 ` Maarten Lankhorst [this message]
2026-01-08 10:10 ` [PATCH v2 7/7] drm/xe: Privatize xe_ggtt_node Maarten Lankhorst
2026-01-08 10:40 ` ✗ CI.checkpatch: warning for drm/xe: Privatize struct xe_ggtt_node. (rev2) Patchwork
2026-01-08 10:41 ` ✓ CI.KUnit: success " Patchwork
2026-01-08 11:40 ` ✓ Xe.CI.BAT: " Patchwork
2026-01-08 14:19 ` ✓ 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=20260108101014.579906-15-dev@lankhorst.se \
--to=dev@lankhorst.se \
--cc=Matthew.brost@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=michal.wajdeczko@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