From: "Dixit, Ashutosh" <ashutosh.dixit@intel.com>
To: <himanshu.girotra@intel.com>
Cc: <matthew.d.roper@intel.com>, <x.wang@intel.com>,
<igt-dev@lists.freedesktop.org>, <nishit.sharma@intel.com>,
Zbigniew Kempczynski <zbigniew.kempczynski@intel.com>
Subject: Re: [PATCH v2 i-g-t] lib/intel_pat: Cache PAT config for unprivileged processes
Date: Thu, 05 Mar 2026 05:48:13 -0800 [thread overview]
Message-ID: <87o6l25qw2.wl-ashutosh.dixit@intel.com> (raw)
In-Reply-To: <20260305122548.28328-1-himanshu.girotra@intel.com>
On Thu, 05 Mar 2026 04:25:48 -0800, <himanshu.girotra@intel.com> wrote:
>
> diff --git a/lib/xe/xe_query.c b/lib/xe/xe_query.c
> index 981d76948..256ec1d4d 100644
> --- a/lib/xe/xe_query.c
> +++ b/lib/xe/xe_query.c
> @@ -22,6 +22,7 @@
> #include "ioctl_wrappers.h"
> #include "igt_map.h"
>
> +#include "intel_pat.h"
> #include "xe_query.h"
> #include "xe_ioctl.h"
>
> @@ -299,6 +300,15 @@ struct xe_device *xe_device_get(int fd)
> xe_dev->default_alignment = __mem_default_alignment(xe_dev->mem_regions);
> xe_dev->has_vram = __mem_has_vram(xe_dev->mem_regions);
>
> + /*
> + * Populate the PAT cache while we still have sufficient privileges
> + * to read debugfs. Forked children that inherit this xe_device
> + * (via fork()) will be able to use the cached values even after
> + * dropping root with igt_drop_root().
> + */
> + if (xe_get_pat_sw_config(xe_dev->fd, &xe_dev->pat_cache) > 0)
> + xe_dev->pat_cached = true;
> +
x> /* We may get here from multiple threads, use first cached xe_dev */
> pthread_mutex_lock(&cache.cache_mutex);
> prev = find_in_cache_unlocked(fd);
> diff --git a/lib/xe/xe_query.h b/lib/xe/xe_query.h
> index d7a9f95f9..97bcf0d32 100644
> --- a/lib/xe/xe_query.h
> +++ b/lib/xe/xe_query.h
> @@ -9,6 +9,8 @@
> #ifndef XE_QUERY_H
> #define XE_QUERY_H
>
> +#include "intel_pat.h"
> +
> #include <stdint.h>
> #include <xe_drm.h>
>
> @@ -74,6 +76,12 @@ struct xe_device {
>
> /** @dev_id: Device id of xe device */
> uint16_t dev_id;
> +
> + /** @pat_cache: cached PAT index configuration */
> + struct intel_pat_cache pat_cache;
This should just be "struct intel_pat_cache *pat_cache";
> +
> + /** @pat_cached: true once @pat_cache has been populated */
> + bool pat_cached;
And then we don't need this, we can just check for NULL pointer, like has
been done for other members of 'struct xe_device'.
> };
>
> #define xe_for_each_engine(__fd, __hwe) \
> diff --git a/tests/intel/xe_oa.c b/tests/intel/xe_oa.c
> index 927f3f4f2..9ce828619 100644
> --- a/tests/intel/xe_oa.c
> +++ b/tests/intel/xe_oa.c
> @@ -3453,6 +3453,14 @@ test_single_ctx_render_target_writes_a_counter(const struct drm_xe_oa_unit *oau)
> /* A local device for local resources. */
> drm_fd = drm_reopen_driver(drm_fd);
>
> + /*
> + * Populate the xe_device cache (including PAT) for
> + * the new fd while we still have root privileges.
> + * intel_get_pat_idx_*() reads PAT from xe_device,
> + * so this must happen before igt_drop_root().
> + */
> + xe_device_get(drm_fd);
This is not needed, this is done in igt_main() in xe_oa.c. Also you have
done a xe_device_get() in lib/intel_pat.c in this patch itself.
> +
> igt_drop_root();
>
> single_ctx_helper(oau);
> --
> 2.50.1
>
next prev parent reply other threads:[~2026-03-05 13:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-05 12:25 [PATCH v2 i-g-t] lib/intel_pat: Cache PAT config for unprivileged processes himanshu.girotra
2026-03-05 13:23 ` Zbigniew Kempczyński
2026-03-05 13:48 ` Dixit, Ashutosh [this message]
2026-03-05 13:57 ` Dixit, Ashutosh
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=87o6l25qw2.wl-ashutosh.dixit@intel.com \
--to=ashutosh.dixit@intel.com \
--cc=himanshu.girotra@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=matthew.d.roper@intel.com \
--cc=nishit.sharma@intel.com \
--cc=x.wang@intel.com \
--cc=zbigniew.kempczynski@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.