Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Ghimiray, Himal Prasad" <himal.prasad.ghimiray@intel.com>
To: Nareshkumar Gollakoti <naresh.kumar.g@intel.com>,
	<intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH v9 1/6] drm/xe: add page size allocation control state to xe_device
Date: Tue, 28 Jul 2026 11:36:10 +0530	[thread overview]
Message-ID: <fde9ef1f-2a41-4958-bf22-806f759b82e0@intel.com> (raw)
In-Reply-To: <20260728060132.4067990-2-naresh.kumar.g@intel.com>



On 28-07-2026 11:31, Nareshkumar Gollakoti wrote:
> Introduce xe_page_size_alloc_ctrl_mode and add page_size_alloc_ctrl
> state to struct xe_device along with mutex lock.
> 
> The new control supports forcing user BO allocations to 2M pages,
> forcing them to 1G pages, or using a mixed round-robin mode across
> 4K, 64K, 2M, and 1G page sizes. Track the current mixed-mode index
> in xe_device so allocation policy can be applied consistently.
> 
> v2
> - make cur_index to atomic as update need in later patch to
>    avoid race/concurency (sashiko)
> v3
> - reworded comments
> - protect mode/index updates with a mutex for proper concurrency handling
> 
> v4(sashiko)
> - move xe_debug_page_size_alloc_ctrl_init() before drm_dev_register(),
>    so mutex and control states are initialized
>    before any userspace visibility
> 
> v5(Himal)
> - Guard all the debug page size policy code under CONFIG
> - Squash Kconfig patch to have Kconfig entry for DEBUG_PAGE_SIZE
> - Add inline to check debug page size support and exact mode
>    configured if it is supported.
> 
> v6 (fix CI build)
> 
> v8 (Himal)
> - use drmm_mutex_init to avoid leak with mutex_init
> - call xe_debug_page_size_alloc_ctrl_init unconditionally
> - Add missed mixed mode check on xe_debug_page_size_mode_not_none check
> - Add xe_debug_page_size_mode_is_mixed() function
> 
> v9
> - make xe_debug_page_size_alloc_ctrl_init() return int
> - fail probe if drmm_mutex_init() for page_size_alloc_ctrl.lock fails
> 
> Signed-off-by: Nareshkumar Gollakoti <naresh.kumar.g@intel.com>
> Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>

Reviewed-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>

> ---
>   drivers/gpu/drm/xe/Kconfig.debug     | 16 ++++++++++
>   drivers/gpu/drm/xe/xe_device.c       | 25 +++++++++++++++
>   drivers/gpu/drm/xe/xe_device.h       | 48 ++++++++++++++++++++++++++++
>   drivers/gpu/drm/xe/xe_device_types.h | 31 ++++++++++++++++++
>   4 files changed, 120 insertions(+)
> 
> diff --git a/drivers/gpu/drm/xe/Kconfig.debug b/drivers/gpu/drm/xe/Kconfig.debug
> index 01227c77f6d7..79118d9efd93 100644
> --- a/drivers/gpu/drm/xe/Kconfig.debug
> +++ b/drivers/gpu/drm/xe/Kconfig.debug
> @@ -86,6 +86,22 @@ config DRM_XE_KUNIT_TEST
>   
>   	  If in doubt, say "N".
>   
> +config DRM_XE_DEBUG_PAGE_SIZE
> +	bool "Enable debug control for user BO page-size allocation"
> +	depends on DRM_XE_DEBUG && DEBUG_FS
> +	help
> +	  Expose a debugfs knob to override user BO page-size allocation
> +	  handling for validation and debug. Supported modes include forced
> +	  2M, forced 1G, and a mixed mode that exercises 4K, 64K, 2M, and
> +	  1G page-size paths on platforms that support them.
> +
> +	  This is an unstable debugfs interface intended for development and
> +	  validation only. Its layout, contents, and existence may change or
> +	  be removed at any time with no regression warranty.
> +
> +	  Recommended for driver developers only.
> +	  If in doubt, say "N".
> +
>   config DRM_XE_DEBUG_GUC
>           bool "Enable extra GuC related debug options"
>           depends on DRM_XE_DEBUG
> diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
> index 4eed9a251e65..7007b6113760 100644
> --- a/drivers/gpu/drm/xe/xe_device.c
> +++ b/drivers/gpu/drm/xe/xe_device.c
> @@ -921,6 +921,27 @@ static void xe_device_wedged_fini(struct drm_device *drm, void *arg)
>   		xe_pm_runtime_put(xe);
>   }
>   
> +#ifdef CONFIG_DRM_XE_DEBUG_PAGE_SIZE
> +static int xe_debug_page_size_alloc_ctrl_init(struct xe_device *xe)
> +{
> +	int err;
> +
> +	err = drmm_mutex_init(&xe->drm, &xe->page_size_alloc_ctrl.lock);
> +	if (err)
> +		return err;
> +
> +	xe->page_size_alloc_ctrl.mode = XE_PAGE_SIZE_ALLOC_CTRL_MODE_NONE;
> +	xe->page_size_alloc_ctrl.cur_index = 0;
> +
> +	return 0;
> +}
> +#else
> +static int xe_debug_page_size_alloc_ctrl_init(struct xe_device *xe)
> +{
> +	return 0;
> +}
> +#endif
> +
>   int xe_device_probe(struct xe_device *xe)
>   {
>   	struct xe_tile *tile;
> @@ -1073,6 +1094,10 @@ int xe_device_probe(struct xe_device *xe)
>   	if (err)
>   		return err;
>   
> +	err = xe_debug_page_size_alloc_ctrl_init(xe);
> +	if (err)
> +		return err;
> +
>   	err = drm_dev_register(&xe->drm, 0);
>   	if (err)
>   		return err;
> diff --git a/drivers/gpu/drm/xe/xe_device.h b/drivers/gpu/drm/xe/xe_device.h
> index a03760d0ce38..6c4cfaebc44a 100644
> --- a/drivers/gpu/drm/xe/xe_device.h
> +++ b/drivers/gpu/drm/xe/xe_device.h
> @@ -212,6 +212,54 @@ static inline bool xe_device_wedged(struct xe_device *xe)
>   	return atomic_read(&xe->wedged.flag);
>   }
>   
> +#ifdef CONFIG_DRM_XE_DEBUG_PAGE_SIZE
> +static inline bool xe_debug_page_size_supported(struct xe_device *xe)
> +{
> +	return IS_DGFX(xe);
> +}
> +
> +static inline bool xe_debug_page_size_mode_not_none(struct xe_device *xe)
> +{
> +	enum xe_page_size_alloc_ctrl_mode mode;
> +
> +	if (!xe_debug_page_size_supported(xe))
> +		return false;
> +
> +	mode = READ_ONCE(xe->page_size_alloc_ctrl.mode);
> +
> +	return mode == XE_PAGE_SIZE_ALLOC_CTRL_MODE_ONLY_2M ||
> +	       mode == XE_PAGE_SIZE_ALLOC_CTRL_MODE_ONLY_1G ||
> +	       mode == XE_PAGE_SIZE_ALLOC_CTRL_MODE_MIXED;
> +}
> +
> +static inline bool xe_debug_page_size_mode_is_mixed(struct xe_device *xe)
> +{
> +	enum xe_page_size_alloc_ctrl_mode mode;
> +
> +	if (!xe_debug_page_size_supported(xe))
> +		return false;
> +
> +	mode = READ_ONCE(xe->page_size_alloc_ctrl.mode);
> +
> +	return mode == XE_PAGE_SIZE_ALLOC_CTRL_MODE_MIXED;
> +}
> +#else
> +static inline bool xe_debug_page_size_supported(struct xe_device *xe)
> +{
> +	return false;
> +}
> +
> +static inline bool xe_debug_page_size_mode_not_none(struct xe_device *xe)
> +{
> +	return false;
> +}
> +
> +static inline bool xe_debug_page_size_mode_is_mixed(struct xe_device *xe)
> +{
> +	return false;
> +}
> +#endif
> +
>   void xe_device_set_wedged_method(struct xe_device *xe, unsigned long method);
>   void xe_device_declare_wedged(struct xe_device *xe);
>   int xe_device_validate_wedged_mode(struct xe_device *xe, unsigned int mode);
> diff --git a/drivers/gpu/drm/xe/xe_device_types.h b/drivers/gpu/drm/xe/xe_device_types.h
> index 860ad322237f..03a7bb08adf7 100644
> --- a/drivers/gpu/drm/xe/xe_device_types.h
> +++ b/drivers/gpu/drm/xe/xe_device_types.h
> @@ -61,6 +61,23 @@ enum xe_wedged_mode {
>   	XE_WEDGED_MODE_UPON_ANY_HANG_NO_RESET = 2,
>   };
>   
> +#ifdef CONFIG_DRM_XE_DEBUG_PAGE_SIZE
> +/**
> + * enum xe_page_size_alloc_ctrl_mode - User BO page-size allocation control modes
> + * @XE_PAGE_SIZE_ALLOC_CTRL_MODE_NONE: Use the normal allocation policy
> + * @XE_PAGE_SIZE_ALLOC_CTRL_MODE_ONLY_2M: Force user BO allocations to 2M pages
> + * @XE_PAGE_SIZE_ALLOC_CTRL_MODE_ONLY_1G: Force user BO allocations to 1G pages
> + * @XE_PAGE_SIZE_ALLOC_CTRL_MODE_MIXED: Select page sizes in round-robin order
> + *     (4K, 64K, 2M, 1G)
> + */
> +enum xe_page_size_alloc_ctrl_mode {
> +	XE_PAGE_SIZE_ALLOC_CTRL_MODE_NONE = 0,
> +	XE_PAGE_SIZE_ALLOC_CTRL_MODE_ONLY_2M,
> +	XE_PAGE_SIZE_ALLOC_CTRL_MODE_ONLY_1G,
> +	XE_PAGE_SIZE_ALLOC_CTRL_MODE_MIXED
> +};
> +#endif
> +
>   #define XE_BO_INVALID_OFFSET	LONG_MAX
>   
>   #define GRAPHICS_VER(xe) ((xe)->info.graphics_verx100 / 100)
> @@ -478,6 +495,20 @@ struct xe_device {
>   	/** @late_bind: xe mei late bind interface */
>   	struct xe_late_bind late_bind;
>   
> +#ifdef CONFIG_DRM_XE_DEBUG_PAGE_SIZE
> +	/**
> +	 * @page_size_alloc_ctrl: User BO page-size allocation
> +	 * debug control state
> +	 */
> +	struct {
> +		/** @page_size_alloc_ctrl.mode: xe page size allocation control mode */
> +		enum xe_page_size_alloc_ctrl_mode mode;
> +		/** @page_size_alloc_ctrl.cur_index: Round-robin index used by mixed mode */
> +		u32 cur_index;
> +		/** @page_size_alloc_ctrl.lock: Protects @mode and @cur_index */
> +		struct mutex lock;
> +	} page_size_alloc_ctrl;
> +#endif
>   	/** @oa: oa observation subsystem */
>   	struct xe_oa oa;
>   


  reply	other threads:[~2026-07-28  6:06 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-28  6:01 [PATCH v9 0/6] drm/xe: add page size allocation mode control and coverage Nareshkumar Gollakoti
2026-07-28  6:01 ` [PATCH v9 1/6] drm/xe: add page size allocation control state to xe_device Nareshkumar Gollakoti
2026-07-28  6:06   ` Ghimiray, Himal Prasad [this message]
2026-07-28  6:01 ` [PATCH v9 2/6] drm/xe/debugfs: add page-size allocation mode knob Nareshkumar Gollakoti
2026-07-28  6:06   ` Ghimiray, Himal Prasad
2026-07-28  6:01 ` [PATCH v9 3/6] drm/xe: add XE_BO_FLAG_NEEDS_1G for minimum page-size sizing Nareshkumar Gollakoti
2026-07-28  6:01 ` [PATCH v9 4/6] drm/xe: apply debug page-size allocation policy to user BOs Nareshkumar Gollakoti
2026-07-28  6:01 ` [PATCH v9 5/6] drm/xe/pt: allow selecting the bind leaf PTE level Nareshkumar Gollakoti
2026-07-28  6:01 ` [PATCH v9 6/6] drm/xe/tests: add live KUnit coverage for BO page-size allocation modes Nareshkumar Gollakoti
2026-07-28  6:07   ` Ghimiray, Himal Prasad
2026-07-28  7:07 ` ✓ CI.KUnit: success for drm/xe: add page size allocation mode control and coverage (rev7) Patchwork
2026-07-28  7:24 ` ✗ CI.checksparse: warning " Patchwork
2026-07-28  7:44 ` ✓ Xe.CI.BAT: success " Patchwork
2026-07-28 10:31 ` ✓ 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=fde9ef1f-2a41-4958-bf22-806f759b82e0@intel.com \
    --to=himal.prasad.ghimiray@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=naresh.kumar.g@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