diff options
| author | Lukasz Laguna <lukasz.laguna@intel.com> | 2026-07-30 11:38:06 +0200 |
|---|---|---|
| committer | Lukasz Laguna <lukasz.laguna@intel.com> | 2026-08-04 08:13:23 +0200 |
| commit | de6fcadec516caa8942775f27d17aef9b12dc358 (patch) | |
| tree | aec6664f859e634561ef0217106f99752abfa23e /lib/xe | |
| parent | 270bc13954ccab274f11ea80b4a857ad8b9e194b (diff) | |
lib/xe/xe_ggtt: Extract generic GGTT code into library
Add a shared xe_ggtt library with a common GGTT definitions, including
bitfields, bitmasks and helpers.
Signed-off-by: Lukasz Laguna <lukasz.laguna@intel.com>
Reviewed-by: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
Diffstat (limited to 'lib/xe')
| -rw-r--r-- | lib/xe/xe_ggtt.c | 22 | ||||
| -rw-r--r-- | lib/xe/xe_ggtt.h | 21 | ||||
| -rw-r--r-- | lib/xe/xe_mmio.h | 3 |
3 files changed, 44 insertions, 2 deletions
diff --git a/lib/xe/xe_ggtt.c b/lib/xe/xe_ggtt.c new file mode 100644 index 000000000..96b189b7a --- /dev/null +++ b/lib/xe/xe_ggtt.c @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: MIT +/* + * Copyright(c) 2026 Intel Corporation. All rights reserved. + */ + +#include "igt.h" +#include "xe/xe_ggtt.h" + +xe_ggtt_pte_mask_t xe_ggtt_get_gpa_mask(int pf_fd) +{ + if (IS_TIGERLAKE(intel_get_drm_devid(pf_fd))) + return TGL_GGTT_PTE_ADDR_MASK; + + return GGTT_PTE_ADDR_MASK; +} + +uint64_t xe_ggtt_pte_get_gpa(int pf_fd, xe_ggtt_pte_t pte) +{ + xe_ggtt_pte_mask_t mask = xe_ggtt_get_gpa_mask(pf_fd); + + return (uint64_t)((pte & mask) >> GGTT_PTE_ADDR_SHIFT); +} diff --git a/lib/xe/xe_ggtt.h b/lib/xe/xe_ggtt.h new file mode 100644 index 000000000..5e4038591 --- /dev/null +++ b/lib/xe/xe_ggtt.h @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Copyright(c) 2026 Intel Corporation. All rights reserved. + */ + +#ifndef __XE_GGTT_H__ +#define __XE_GGTT_H__ + +#include <stdint.h> + +#define GGTT_PTE_ADDR_MASK GENMASK_ULL(45, 12) +#define TGL_GGTT_PTE_ADDR_MASK GENMASK_ULL(38, 12) +#define GGTT_PTE_ADDR_SHIFT 12 + +typedef uint64_t xe_ggtt_pte_t; +typedef uint64_t xe_ggtt_pte_mask_t; + +xe_ggtt_pte_mask_t xe_ggtt_get_gpa_mask(int pf_fd); +uint64_t xe_ggtt_pte_get_gpa(int pf_fd, xe_ggtt_pte_t pte); + +#endif /* __XE_GGTT_H__ */ diff --git a/lib/xe/xe_mmio.h b/lib/xe/xe_mmio.h index 030c50a2e..65aea65ea 100644 --- a/lib/xe/xe_mmio.h +++ b/lib/xe/xe_mmio.h @@ -5,6 +5,7 @@ #include "lib/intel_io.h" #include "lib/igt_sizes.h" +#include "lib/xe/xe_ggtt.h" #ifndef XE_MMIO_H #define XE_MMIO_H @@ -12,8 +13,6 @@ #define TILE_MMIO_SIZE SZ_16M #define GGTT_OFFSET_IN_TILE SZ_8M -typedef uint64_t xe_ggtt_pte_t; - struct xe_mmio { int fd; bool init; |
