From: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Cc: piotr.piorkowski@intel.com, lukasz.laguna@intel.com,
jakub1.kolakowski@intel.com,
Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>,
Jan Sokolowski <jan.sokolowski@intel.com>
Subject: [PATCH i-g-t 1/6] lib/xe_mmio: Introduce tile-level XE MMIO access helpers
Date: Fri, 31 Oct 2025 13:56:28 +0100 [thread overview]
Message-ID: <20251031125633.1374273-2-marcin.bernatowicz@linux.intel.com> (raw)
In-Reply-To: <20251031125633.1374273-1-marcin.bernatowicz@linux.intel.com>
From: Piotr Piórkowski <piotr.piorkowski@intel.com>
Add new helpers for tile-based MMIO access:
- xe_mmio_tile_read32()
- xe_mmio_tile_read64()
- xe_mmio_tile_write32()
- xe_mmio_tile_write64()
These functions provide explicit MMIO read/write operations within
a given tile by applying TILE_MMIO_SIZE offsetting logic. Existing
GT-level MMIO helpers (xe_mmio_gt_*()) are refactored to use these
new tile-level accessors, simplifying code and improving consistency
across MMIO operations.
GGTT is also a per-tile resource, so let's adjust the GGTT access
helpers to use tile IDs instead of GT.
v2:
- find the real tile based on gt instead of assuming root tile
Signed-off-by: Piotr Piórkowski <piotr.piorkowski@intel.com>
Cc: Lukasz Laguna <lukasz.laguna@intel.com>
Cc: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
Cc: Jan Sokolowski <jan.sokolowski@intel.com>
Signed-off-by: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
---
lib/xe/xe_mmio.c | 94 ++++++++++++++++++++++++++--------
lib/xe/xe_mmio.h | 20 +++++---
lib/xe/xe_sriov_provisioning.c | 6 +--
lib/xe/xe_sriov_provisioning.h | 2 +-
tests/intel/xe_sriov_flr.c | 12 ++---
5 files changed, 96 insertions(+), 38 deletions(-)
diff --git a/lib/xe/xe_mmio.c b/lib/xe/xe_mmio.c
index 834816133..8bc446fb9 100644
--- a/lib/xe/xe_mmio.c
+++ b/lib/xe/xe_mmio.c
@@ -107,6 +107,62 @@ void xe_mmio_write64(struct xe_mmio *mmio, uint32_t offset, uint64_t val)
return iowrite64(mmio->intel_mmio.igt_mmio, offset, val);
}
+/** xe_mmio_tile_read32:
+ * @mmio: xe mmio structure for IO operations
+ * @tile: tile id
+ * @offset: mmio register offset in the tile
+ *
+ * 32-bit read of the register at @offset in the specified @tile
+ *
+ * Returns: The value read from the register.
+ */
+uint32_t xe_mmio_tile_read32(struct xe_mmio *mmio, uint8_t tile, uint32_t offset)
+{
+ return xe_mmio_read32(mmio, offset + (TILE_MMIO_SIZE * tile));
+}
+
+/** xe_mmio_tile_read64:
+ * @mmio: xe mmio structure for IO operations
+ * @tile: tile id
+ * @offset: mmio register offset in the @tile
+ *
+ * 64-bit read of the register at @offset in the specified @tile
+ *
+ * Returns: The value read from the register.
+ */
+uint64_t xe_mmio_tile_read64(struct xe_mmio *mmio, uint8_t tile, uint32_t offset)
+{
+ return xe_mmio_read64(mmio, offset + (TILE_MMIO_SIZE * tile));
+}
+
+/**
+ * xe_mmio_tile_write32:
+ * @mmio: xe mmio structure for IO operations
+ * @tile: tile id
+ * @offset: mmio register offset in the @tile
+ * @val: value to write
+ *
+ * 32-bit write to the register at @offset in the specified @tile
+ */
+void xe_mmio_tile_write32(struct xe_mmio *mmio, uint8_t tile, uint32_t offset, uint32_t val)
+{
+ xe_mmio_write32(mmio, offset + (TILE_MMIO_SIZE * tile), val);
+}
+
+/**
+ * xe_mmio_tile_write64:
+ * @mmio: xe mmio structure for IO operations
+ * @tile: tile id
+ * @offset: mmio register offset in the @tile
+ * @val: value to write
+ *
+ * 64-bit write to the register at @offset in the specified @tile
+ */
+void xe_mmio_tile_write64(struct xe_mmio *mmio, uint8_t tile, uint32_t offset, uint64_t val)
+{
+ xe_mmio_write64(mmio, offset + (TILE_MMIO_SIZE * tile), val);
+}
+
/**
* xe_mmio_gt_read32:
* @mmio: xe mmio structure for IO operations
@@ -118,9 +174,9 @@ void xe_mmio_write64(struct xe_mmio *mmio, uint32_t offset, uint64_t val)
* Returns:
* The value read from the register.
*/
-uint32_t xe_mmio_gt_read32(struct xe_mmio *mmio, int gt, uint32_t offset)
+uint32_t xe_mmio_gt_read32(struct xe_mmio *mmio, uint8_t gt, uint32_t offset)
{
- return xe_mmio_read32(mmio, offset + (TILE_MMIO_SIZE * xe_gt_get_tile_id(mmio->fd, gt)));
+ return xe_mmio_tile_read32(mmio, xe_gt_get_tile_id(mmio->fd, gt), offset);
}
/**
@@ -134,9 +190,9 @@ uint32_t xe_mmio_gt_read32(struct xe_mmio *mmio, int gt, uint32_t offset)
* Returns:
* The value read from the register.
*/
-uint64_t xe_mmio_gt_read64(struct xe_mmio *mmio, int gt, uint32_t offset)
+uint64_t xe_mmio_gt_read64(struct xe_mmio *mmio, uint8_t gt, uint32_t offset)
{
- return xe_mmio_read64(mmio, offset + (TILE_MMIO_SIZE * xe_gt_get_tile_id(mmio->fd, gt)));
+ return xe_mmio_tile_read64(mmio, xe_gt_get_tile_id(mmio->fd, gt), offset);
}
/**
@@ -148,10 +204,9 @@ uint64_t xe_mmio_gt_read64(struct xe_mmio *mmio, int gt, uint32_t offset)
*
* 32-bit write to the register at @offset in tile to which @gt belongs.
*/
-void xe_mmio_gt_write32(struct xe_mmio *mmio, int gt, uint32_t offset, uint32_t val)
+void xe_mmio_gt_write32(struct xe_mmio *mmio, uint8_t gt, uint32_t offset, uint32_t val)
{
- return xe_mmio_write32(mmio, offset + (TILE_MMIO_SIZE * xe_gt_get_tile_id(mmio->fd, gt)),
- val);
+ return xe_mmio_tile_write32(mmio, xe_gt_get_tile_id(mmio->fd, gt), offset, val);
}
/**
@@ -163,38 +218,37 @@ void xe_mmio_gt_write32(struct xe_mmio *mmio, int gt, uint32_t offset, uint32_t
*
* 64-bit write to the register at @offset in tile to which @gt belongs.
*/
-void xe_mmio_gt_write64(struct xe_mmio *mmio, int gt, uint32_t offset, uint64_t val)
+void xe_mmio_gt_write64(struct xe_mmio *mmio, uint8_t gt, uint32_t offset, uint64_t val)
{
- return xe_mmio_write64(mmio, offset + (TILE_MMIO_SIZE * xe_gt_get_tile_id(mmio->fd, gt)),
- val);
+ return xe_mmio_tile_write64(mmio, xe_gt_get_tile_id(mmio->fd, gt), offset, val);
}
/**
* xe_mmio_ggtt_read:
* @mmio: xe mmio structure for IO operations
- * @gt: gt id
- * @offset: PTE offset from the beginning of GGTT, in tile to which @gt belongs
+ * @tile: tile id
+ * @offset: PTE offset from the beginning of GGTT in @tile
*
- * Read of GGTT PTE at GGTT @offset in tile to which @gt belongs.
+ * Read of GGTT PTE at GGTT @offset in the @tile.
*
* Returns:
* The value read from the register.
*/
-xe_ggtt_pte_t xe_mmio_ggtt_read(struct xe_mmio *mmio, int gt, uint32_t offset)
+xe_ggtt_pte_t xe_mmio_ggtt_read(struct xe_mmio *mmio, uint8_t tile, uint32_t offset)
{
- return xe_mmio_gt_read64(mmio, gt, offset + GGTT_OFFSET_IN_TILE);
+ return xe_mmio_tile_read64(mmio, tile, offset + GGTT_OFFSET_IN_TILE);
}
/**
* xe_mmio_ggtt_write:
* @mmio: xe mmio structure for IO operations
- * @gt: gt id
- * @offset: PTE offset from the beginning of GGTT, in tile to which @gt belongs
+ * @tile: tile id
+ * @offset: PTE offset from the beginning of GGTT in @tile
* @pte: PTE value to write
*
- * Write PTE value at GGTT @offset in tile to which @gt belongs.
+ * Write PTE value at GGTT @offset in the @tile.
*/
-void xe_mmio_ggtt_write(struct xe_mmio *mmio, int gt, uint32_t offset, xe_ggtt_pte_t pte)
+void xe_mmio_ggtt_write(struct xe_mmio *mmio, uint8_t tile, uint32_t offset, xe_ggtt_pte_t pte)
{
- return xe_mmio_gt_write64(mmio, gt, offset + GGTT_OFFSET_IN_TILE, pte);
+ return xe_mmio_tile_write64(mmio, tile, offset + GGTT_OFFSET_IN_TILE, pte);
}
diff --git a/lib/xe/xe_mmio.h b/lib/xe/xe_mmio.h
index f144d4b53..f15017c96 100644
--- a/lib/xe/xe_mmio.h
+++ b/lib/xe/xe_mmio.h
@@ -29,13 +29,17 @@ uint64_t xe_mmio_read64(struct xe_mmio *mmio, uint32_t offset);
void xe_mmio_write32(struct xe_mmio *mmio, uint32_t offset, uint32_t val);
void xe_mmio_write64(struct xe_mmio *mmio, uint32_t offset, uint64_t val);
-uint32_t xe_mmio_gt_read32(struct xe_mmio *mmio, int gt, uint32_t offset);
-uint64_t xe_mmio_gt_read64(struct xe_mmio *mmio, int gt, uint32_t offset);
-
-void xe_mmio_gt_write32(struct xe_mmio *mmio, int gt, uint32_t offset, uint32_t val);
-void xe_mmio_gt_write64(struct xe_mmio *mmio, int gt, uint32_t offset, uint64_t val);
-
-xe_ggtt_pte_t xe_mmio_ggtt_read(struct xe_mmio *mmio, int gt, uint32_t pte_offset);
-void xe_mmio_ggtt_write(struct xe_mmio *mmio, int gt, uint32_t pte_offset, xe_ggtt_pte_t pte);
+uint32_t xe_mmio_tile_read32(struct xe_mmio *mmio, uint8_t tile, uint32_t offset);
+uint64_t xe_mmio_tile_read64(struct xe_mmio *mmio, uint8_t tile, uint32_t offset);
+void xe_mmio_tile_write32(struct xe_mmio *mmio, uint8_t tile, uint32_t offset, uint32_t val);
+void xe_mmio_tile_write64(struct xe_mmio *mmio, uint8_t tile, uint32_t offset, uint64_t val);
+
+uint32_t xe_mmio_gt_read32(struct xe_mmio *mmio, uint8_t gt, uint32_t offset);
+uint64_t xe_mmio_gt_read64(struct xe_mmio *mmio, uint8_t gt, uint32_t offset);
+void xe_mmio_gt_write32(struct xe_mmio *mmio, uint8_t gt, uint32_t offset, uint32_t val);
+void xe_mmio_gt_write64(struct xe_mmio *mmio, uint8_t gt, uint32_t offset, uint64_t val);
+
+xe_ggtt_pte_t xe_mmio_ggtt_read(struct xe_mmio *mmio, uint8_t tile, uint32_t pte_offset);
+void xe_mmio_ggtt_write(struct xe_mmio *mmio, uint8_t tile, uint32_t pte_offset, xe_ggtt_pte_t pte);
#endif /* XE_MMIO_H */
diff --git a/lib/xe/xe_sriov_provisioning.c b/lib/xe/xe_sriov_provisioning.c
index ff9d1f7d2..2ca73d2ef 100644
--- a/lib/xe/xe_sriov_provisioning.c
+++ b/lib/xe/xe_sriov_provisioning.c
@@ -90,7 +90,7 @@ static int append_range(struct xe_sriov_provisioned_range **ranges,
/**
* xe_sriov_find_ggtt_provisioned_pte_offsets - Find GGTT provisioned PTE offsets
* @pf_fd: File descriptor for the Physical Function
- * @gt: GT identifier
+ * @tile: Tile id
* @mmio: Pointer to the MMIO structure
* @ranges: Pointer to the array of provisioned ranges
* @nr_ranges: Pointer to the number of provisioned ranges
@@ -106,7 +106,7 @@ static int append_range(struct xe_sriov_provisioned_range **ranges,
*
* Returns 0 on success, or a negative error code on failure.
*/
-int xe_sriov_find_ggtt_provisioned_pte_offsets(int pf_fd, int gt, struct xe_mmio *mmio,
+int xe_sriov_find_ggtt_provisioned_pte_offsets(int pf_fd, uint8_t tile, struct xe_mmio *mmio,
struct xe_sriov_provisioned_range **ranges,
unsigned int *nr_ranges)
{
@@ -122,7 +122,7 @@ int xe_sriov_find_ggtt_provisioned_pte_offsets(int pf_fd, int gt, struct xe_mmio
for (uint32_t offset = START_PTE_OFFSET; offset < MAX_PTE_OFFSET;
offset += sizeof(xe_ggtt_pte_t)) {
- pte = xe_mmio_ggtt_read(mmio, gt, offset);
+ pte = xe_mmio_ggtt_read(mmio, tile, offset);
vf_id = (pte & vfid_mask) >> GGTT_PTE_VFID_SHIFT;
if (vf_id != current_vf_id) {
diff --git a/lib/xe/xe_sriov_provisioning.h b/lib/xe/xe_sriov_provisioning.h
index e1a9d0a63..1e1dca866 100644
--- a/lib/xe/xe_sriov_provisioning.h
+++ b/lib/xe/xe_sriov_provisioning.h
@@ -92,7 +92,7 @@ struct xe_sriov_provisioned_range {
const char *xe_sriov_shared_res_to_string(enum xe_sriov_shared_res res);
bool xe_sriov_is_shared_res_provisionable(int pf, enum xe_sriov_shared_res res, unsigned int gt);
-int xe_sriov_find_ggtt_provisioned_pte_offsets(int pf_fd, int gt, struct xe_mmio *mmio,
+int xe_sriov_find_ggtt_provisioned_pte_offsets(int pf_fd, uint8_t tile, struct xe_mmio *mmio,
struct xe_sriov_provisioned_range **ranges,
unsigned int *nr_ranges);
const char *xe_sriov_shared_res_attr_name(enum xe_sriov_shared_res res,
diff --git a/tests/intel/xe_sriov_flr.c b/tests/intel/xe_sriov_flr.c
index aabbd8c05..077ed15af 100644
--- a/tests/intel/xe_sriov_flr.c
+++ b/tests/intel/xe_sriov_flr.c
@@ -493,20 +493,20 @@ struct ggtt_data {
static xe_ggtt_pte_t intel_get_pte(struct xe_mmio *mmio, int gt, uint32_t pte_offset)
{
- return xe_mmio_ggtt_read(mmio, gt, pte_offset);
+ return xe_mmio_ggtt_read(mmio, xe_gt_get_tile_id(mmio->fd, gt), pte_offset);
}
static void intel_set_pte(struct xe_mmio *mmio, int gt, uint32_t pte_offset, xe_ggtt_pte_t pte)
{
- xe_mmio_ggtt_write(mmio, gt, pte_offset, pte);
+ xe_mmio_ggtt_write(mmio, xe_gt_get_tile_id(mmio->fd, gt), pte_offset, pte);
}
static void intel_mtl_set_pte(struct xe_mmio *mmio, int gt, uint32_t pte_offset, xe_ggtt_pte_t pte)
{
- xe_mmio_ggtt_write(mmio, gt, pte_offset, pte);
+ xe_mmio_ggtt_write(mmio, xe_gt_get_tile_id(mmio->fd, gt), pte_offset, pte);
/* force flush by read some MMIO register */
- xe_mmio_gt_read32(mmio, gt, GEN12_VF_CAP_REG);
+ xe_mmio_tile_read32(mmio, xe_gt_get_tile_id(mmio->fd, gt), GEN12_VF_CAP_REG);
}
static bool set_pte_gpa(struct ggtt_ops *ggtt, struct xe_mmio *mmio, int gt, uint32_t pte_offset,
@@ -548,8 +548,8 @@ static int populate_ggtt_pte_offsets(struct ggtt_data *gdata)
gdata->pte_offsets = calloc(num_vfs + 1, sizeof(*gdata->pte_offsets));
igt_assert(gdata->pte_offsets);
- ret = xe_sriov_find_ggtt_provisioned_pte_offsets(pf_fd, gt, gdata->mmio,
- &ranges, &nr_ranges);
+ ret = xe_sriov_find_ggtt_provisioned_pte_offsets(pf_fd, xe_gt_get_tile_id(pf_fd, gt),
+ gdata->mmio, &ranges, &nr_ranges);
if (ret) {
set_skip_reason(&gdata->base, "Failed to scan GGTT PTE offset ranges on gt%u (%d)\n",
gt, ret);
--
2.43.0
next prev parent reply other threads:[~2025-10-31 12:57 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-31 12:56 [PATCH i-g-t 0/6] Multi-tile support for xe_sriov_flr and related MMIO improvements Marcin Bernatowicz
2025-10-31 12:56 ` Marcin Bernatowicz [this message]
2025-11-06 11:12 ` [PATCH i-g-t 1/6] lib/xe_mmio: Introduce tile-level XE MMIO access helpers Laguna, Lukasz
2025-11-06 12:11 ` Bernatowicz, Marcin
2025-10-31 12:56 ` [PATCH i-g-t 2/6] lib/xe_mmio: Add init flag and helper to check initialization Marcin Bernatowicz
2025-10-31 12:56 ` [PATCH i-g-t 3/6] lib/xe/xe_query: Add tile helpers and iteration macro Marcin Bernatowicz
2025-11-06 11:32 ` Laguna, Lukasz
2025-11-06 12:42 ` Bernatowicz, Marcin
2025-10-31 12:56 ` [PATCH i-g-t 4/6] tests/xe_sriov_flr: Make subchecks Tile aware Marcin Bernatowicz
2025-11-06 11:19 ` Piotr Piórkowski
2025-11-06 15:13 ` Bernatowicz, Marcin
2025-10-31 12:56 ` [PATCH i-g-t 5/6] tests/intel/xe_sriov_flr: Use global MMIO context initialized in verify_flr Marcin Bernatowicz
2025-11-06 12:03 ` Piotr Piórkowski
2025-11-06 14:16 ` Bernatowicz, Marcin
2025-10-31 12:56 ` [PATCH i-g-t 6/6] tests/intel/xe_sriov_flr: Do not ignore failed prerequisites Marcin Bernatowicz
2025-11-06 13:48 ` Piotr Piórkowski
2025-11-01 1:43 ` ✓ i915.CI.BAT: success for Multi-tile support for xe_sriov_flr and related MMIO improvements Patchwork
2025-11-01 2:00 ` ✓ Xe.CI.BAT: " Patchwork
2025-11-01 11:23 ` ✗ i915.CI.Full: failure " Patchwork
2025-11-01 18:41 ` ✓ Xe.CI.Full: success " Patchwork
-- strict thread matches above, loose matches on Subject: below --
2025-11-06 15:28 [PATCH i-g-t 0/6] " Marcin Bernatowicz
2025-11-06 15:28 ` [PATCH i-g-t 1/6] lib/xe_mmio: Introduce tile-level XE MMIO access helpers Marcin Bernatowicz
2025-11-07 8:53 ` Laguna, Lukasz
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=20251031125633.1374273-2-marcin.bernatowicz@linux.intel.com \
--to=marcin.bernatowicz@linux.intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=jakub1.kolakowski@intel.com \
--cc=jan.sokolowski@intel.com \
--cc=lukasz.laguna@intel.com \
--cc=piotr.piorkowski@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