From: Matt Atwood <matthew.s.atwood@intel.com>
To: Gustavo Sousa <gustavo.sousa@intel.com>
Cc: <igt-dev@lists.freedesktop.org>, Matt Roper <matthew.d.roper@intel.com>
Subject: Re: [PATCH i-g-t v2 09/11] lib/intel_pat: Encapsulate management of xe_device's pat_cache
Date: Tue, 20 Oct 2026 14:35:03 -0700 [thread overview]
Message-ID: <20261020213503.GF180749@msatwood-mobl> (raw)
In-Reply-To: <20260923-wa_14026539277-v2-9-528b575299d2@intel.com>
On Wed, Sep 23, 2026 at 06:41:16PM -0300, Gustavo Sousa wrote:
> Currently xe_device_get() manages the PAT cached information
> information by itself, by doing the necessary memory
> allocation/deallocation and calling xe_get_pat_sw_config() to
> initialize the cached information.
>
> Such management is arguably better suited to be implemented as part of
> the intel_pat module and encapsulated such that xe_query doesn't need
> to know the details.
>
> We will introduce changes that will require an extra logic for
> initializing the cache and having such encapsulation makes it much
> easier to implement. Since we will touch this area, take this
> opportunity to move the existing management to intel_pat.
>
> v2:
> - Don't use void pointer as type of pat_cache. (Matt)
>
> Cc: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Matt Atwood <matthew.s.atwood@intel.com>
> Signed-off-by: Gustavo Sousa <gustavo.sousa@intel.com>
> ---
> lib/intel_pat.c | 27 ++++++++++++++++++++++++++-
> lib/intel_pat.h | 5 +++++
> lib/xe/xe_query.c | 9 ++-------
> 3 files changed, 33 insertions(+), 8 deletions(-)
>
> diff --git a/lib/intel_pat.c b/lib/intel_pat.c
> index da7ba1e51b16..db0f057cbd1e 100644
> --- a/lib/intel_pat.c
> +++ b/lib/intel_pat.c
> @@ -144,6 +144,31 @@ int32_t xe_get_pat_hw_config(int drm_fd, struct intel_pat_cache *xe_pat_cache, i
> return xe_get_pat_config(drm_fd, xe_pat_cache, gt, PAT_HW_CONFIG);
> }
>
> +void intel_pat_build_xe_cache(struct xe_device *xe_dev)
> +{
> + struct intel_pat_cache *pat_cache;
> +
> + pat_cache = calloc(1, sizeof(*pat_cache));
> + igt_assert(pat_cache);
> +
> + if (igt_debug_on(xe_get_pat_sw_config(xe_dev->fd, pat_cache, 0) <= 0)) {
> + free(pat_cache);
> + return;
> + }
> +
> + xe_dev->pat_cache = pat_cache;
> +}
> +
> +void intel_pat_free_xe_cache(struct xe_device *xe_dev)
> +{
> + if (!xe_dev->pat_cache)
> + return;
> +
> + free(xe_dev->pat_cache);
> +
> + xe_dev->pat_cache = NULL;
> +}
> +
> /*
> * Hardcoded PAT indices for Xe platforms, used as a fallback when the
> * kernel doesn't expose gt0/pat_sw_config in debugfs.
> @@ -217,7 +242,7 @@ static void intel_get_pat_idx(int fd, struct intel_pat_cache *pat)
> struct xe_device *xe_dev = xe_device_get(fd);
>
> if (xe_dev->pat_cache) {
> - *pat = *xe_dev->pat_cache;
> + *pat = *((struct intel_pat_cache *)xe_dev->pat_cache);
> } else if (xe_pat_fallback(fd, pat)) {
> igt_info("PAT sw_config debugfs not available, "
> "using hardcoded fallback\n");
> diff --git a/lib/intel_pat.h b/lib/intel_pat.h
> index 52a61e8d25fb..fc8fa3fa9f45 100644
> --- a/lib/intel_pat.h
> +++ b/lib/intel_pat.h
> @@ -13,6 +13,8 @@
> #define XE_PAT_IDX_INVALID ((uint8_t)-2) /* no such PAT index on this platform */
> #define XE_PAT_MAX_ENTRIES 32
>
> +struct xe_device;
> +
> struct xe_pat_entry {
> uint32_t pat;
> bool rsvd;
> @@ -42,4 +44,7 @@ bool intel_has_pat_wt(int fd);
> int32_t xe_get_pat_sw_config(int drm_fd, struct intel_pat_cache *xe_pat_cache, int gt);
> int32_t xe_get_pat_hw_config(int drm_fd, struct intel_pat_cache *xe_pat_cache, int gt);
>
> +void intel_pat_build_xe_cache(struct xe_device *xe_dev);
> +void intel_pat_free_xe_cache(struct xe_device *xe_dev);
> +
> #endif /* INTEL_PAT_H */
> diff --git a/lib/xe/xe_query.c b/lib/xe/xe_query.c
> index d2c4329aa317..e7945c8923db 100644
> --- a/lib/xe/xe_query.c
> +++ b/lib/xe/xe_query.c
> @@ -377,8 +377,8 @@ static void xe_device_free(struct xe_device *xe_dev)
> free(xe_dev->mem_regions);
> free(xe_dev->vram_size);
> free(xe_dev->eu_stall);
> - free(xe_dev->pat_cache);
>
> + intel_pat_free_xe_cache(xe_dev);
> xe_wa_free_cache(xe_dev);
>
> free(xe_dev);
> @@ -458,12 +458,7 @@ struct xe_device *xe_device_get(int fd)
> * should be extended to cache PAT entries by platform version/
> * revision instead.
> */
> - xe_dev->pat_cache = calloc(1, sizeof(*xe_dev->pat_cache));
> - igt_assert(xe_dev->pat_cache);
> - if (xe_get_pat_sw_config(xe_dev->fd, xe_dev->pat_cache, 0) <= 0) {
> - free(xe_dev->pat_cache);
> - xe_dev->pat_cache = NULL;
> - }
> + intel_pat_build_xe_cache(xe_dev);
>
> /* We may get here from multiple threads, use first cached xe_dev */
> pthread_mutex_lock(&cache.cache_mutex);
>
> --
> 2.55.0
>
next prev parent reply other threads:[~2026-10-20 21:36 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-23 21:41 [PATCH i-g-t v2 00/11] Implement Wa_14026539277 Gustavo Sousa
2026-09-23 21:41 ` [PATCH i-g-t v2 01/11] lib/xe: Move lib/intel_wa to lib/xe/xe_wa Gustavo Sousa
2026-09-23 21:41 ` [PATCH i-g-t v2 02/11] lib/xe: Make debugfs_file_has_wa() aware of the debugfs file layout Gustavo Sousa
2026-10-20 21:15 ` Matt Atwood
2026-09-23 21:41 ` [PATCH i-g-t v2 03/11] lib/xe: Gather workarounds debugfs dumps in a cache struct Gustavo Sousa
2026-10-20 21:24 ` Matt Atwood
2026-10-20 22:49 ` Gustavo Sousa
2026-09-23 21:41 ` [PATCH i-g-t v2 04/11] lib/xe: Cache workaround information in xe_device Gustavo Sousa
2026-10-20 21:30 ` Matt Atwood
2026-09-23 21:41 ` [PATCH i-g-t v2 05/11] lib/xe: Return boolean from xe_wa() Gustavo Sousa
2026-10-20 21:32 ` Matt Atwood
2026-09-23 21:41 ` [PATCH i-g-t v2 06/11] lib/xe: Assert that cache is available for xe_wa() Gustavo Sousa
2026-10-20 21:33 ` Matt Atwood
2026-09-23 21:41 ` [PATCH i-g-t v2 07/11] tests/intel/xe_pat: Adapt pat_entry_is_wb() to Xe3p Gustavo Sousa
2026-09-23 21:41 ` [PATCH i-g-t v2 08/11] lib/xe: Add xe_wa_from_cache() Gustavo Sousa
2026-09-23 21:41 ` [PATCH i-g-t v2 09/11] lib/intel_pat: Encapsulate management of xe_device's pat_cache Gustavo Sousa
2026-10-20 21:35 ` Matt Atwood [this message]
2026-09-23 21:41 ` [PATCH i-g-t v2 10/11] lib/intel_pat: Pass xe_device to xe_get_pat_config() Gustavo Sousa
2026-09-23 21:41 ` [PATCH i-g-t v2 11/11] intel: Implement Wa_14026539277 Gustavo Sousa
2026-09-24 1:52 ` ✓ i915.CI.BAT: success for Implement Wa_14026539277 (rev2) Patchwork
2026-09-24 2:18 ` ✓ Xe.CI.BAT: " Patchwork
2026-09-24 16:04 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-09-25 0:41 ` ✗ i915.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=20261020213503.GF180749@msatwood-mobl \
--to=matthew.s.atwood@intel.com \
--cc=gustavo.sousa@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=matthew.d.roper@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