All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ghimiray, Himal Prasad" <himal.prasad.ghimiray@intel.com>
To: Tejas Upadhyay <tejas.upadhyay@intel.com>,
	<intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH V15 08/14] drm/xe/vram: Add page offline data structures and lifecycle
Date: Wed, 12 Aug 2026 17:31:17 +0530	[thread overview]
Message-ID: <f6b491df-d74c-4540-8db5-6b028c85bf25@intel.com> (raw)
In-Reply-To: <20260811124016.3614699-24-tejas.upadhyay@intel.com>



On 11-08-2026 18:10, Tejas Upadhyay wrote:
> Add xe_ttm_vram_offline_resource to track individual offlined VRAM
> pages, and extend xe_ttm_vram_mgr with offlined_pages/queued_pages
> lists and their counters.
> 
> Initialize the lists in __xe_ttm_vram_mgr_init() and add
> xe_ttm_vram_free_bad_pages() to release all tracked pages during
> xe_ttm_vram_mgr_fini() teardown.
> 
> Signed-off-by: Tejas Upadhyay <tejas.upadhyay@intel.com>
> ---
>   drivers/gpu/drm/xe/xe_ttm_vram_mgr.c       | 24 ++++++++++++++++++++
>   drivers/gpu/drm/xe/xe_ttm_vram_mgr_types.h | 26 ++++++++++++++++++++++
>   2 files changed, 50 insertions(+)
> 
> diff --git a/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c b/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c
> index 49eeec90a470..2813ae68325e 100644
> --- a/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c
> +++ b/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c
> @@ -300,6 +300,24 @@ static const struct ttm_resource_manager_func xe_ttm_vram_mgr_func = {
>   	.debug	= xe_ttm_vram_mgr_debug
>   };
>   
> +static void xe_ttm_vram_free_bad_pages(struct drm_device *dev, struct xe_ttm_vram_mgr *mgr)
> +{

Don't see dev being used ?

> +	struct xe_ttm_vram_offline_resource *pos, *n;
> +
> +	list_for_each_entry_safe(pos, n, &mgr->offlined_pages, offlined_link) {
> +		xe_ttm_vram_buddy_free(mgr, &pos->blocks, pos->used_visible_size);
> +		list_del(&pos->offlined_link);
> +		--mgr->n_offlined_pages;
> +		kfree(pos);
> +	}

This can be racy, better to use
list_del_rcu() + kfree_rcu()

> +	list_for_each_entry_safe(pos, n, &mgr->queued_pages, queued_link) {
> +		xe_ttm_vram_buddy_free(mgr, &pos->blocks, 0);

Nit: pos->used_visible_size is always 0, hardcoding is Ok. comment it ?

> +		list_del(&pos->queued_link);
> +		--mgr->n_queued_pages;
> +		kfree(pos);
> +	}
> +}
> +
>   static void xe_ttm_vram_mgr_fini(struct drm_device *dev, void *arg)
>   {
>   	struct xe_device *xe = to_xe_device(dev);
> @@ -311,6 +329,10 @@ static void xe_ttm_vram_mgr_fini(struct drm_device *dev, void *arg)
>   	if (ttm_resource_manager_evict_all(&xe->ttm, man))
>   		return;
>


potential leak here due to early return ?

> +	mutex_lock(&mgr->lock);
> +	xe_ttm_vram_free_bad_pages(dev, mgr);
> +	mutex_unlock(&mgr->lock);
> +
>   	WARN_ON_ONCE(mgr->visible_avail != mgr->visible_size);
>   
>   	gpu_buddy_fini(&mgr->mm);
> @@ -338,6 +360,8 @@ int __xe_ttm_vram_mgr_init(struct xe_device *xe, struct xe_ttm_vram_mgr *mgr,
>   	err = drmm_mutex_init(&xe->drm, &mgr->lock);
>   	if (err)
>   		return err;
> +	INIT_LIST_HEAD(&mgr->offlined_pages);
> +	INIT_LIST_HEAD(&mgr->queued_pages);
>   	mgr->default_page_size = default_page_size;
>   	mgr->visible_size = io_size;
>   	mgr->visible_avail = io_size;
> diff --git a/drivers/gpu/drm/xe/xe_ttm_vram_mgr_types.h b/drivers/gpu/drm/xe/xe_ttm_vram_mgr_types.h
> index 9106da056b49..bdfdf6ec1218 100644
> --- a/drivers/gpu/drm/xe/xe_ttm_vram_mgr_types.h
> +++ b/drivers/gpu/drm/xe/xe_ttm_vram_mgr_types.h
> @@ -19,6 +19,14 @@ struct xe_ttm_vram_mgr {
>   	struct ttm_resource_manager manager;
>   	/** @mm: DRM buddy allocator which manages the VRAM */
>   	struct gpu_buddy mm;
> +	/** @offlined_pages: List of offlined pages */
> +	struct list_head offlined_pages;
> +	/** @n_offlined_pages: Number of offlined pages */
> +	u16 n_offlined_pages;
> +	/** @queued_pages: List of queued pages */
> +	struct list_head queued_pages;
> +	/** @n_queued_pages: Number of queued pages */
> +	u16 n_queued_pages;
>   	/** @visible_size: Proped size of the CPU visible portion */
>   	u64 visible_size;
>   	/** @visible_avail: CPU visible portion still unallocated */
> @@ -45,4 +53,22 @@ struct xe_ttm_vram_mgr_resource {
>   	unsigned long flags;
>   };
>   
> +/**
> + * struct xe_ttm_vram_offline_resource - Tracks a single offlined VRAM page
> + */
> +struct xe_ttm_vram_offline_resource {
> +	/** @offlined_link: Link into mgr->offlined_pages */
> +	struct list_head offlined_link;
> +	/** @queued_link: Link into mgr->queued_pages */
> +	struct list_head queued_link;
> +	/** @blocks: Buddy blocks reserved for this page */
> +	struct list_head blocks;
> +	/** @used_visible_size: CPU-visible bytes consumed */
> +	u64 used_visible_size;
> +	/** @addr: Faulty DPA reported by HW */
> +	u64 addr;
> +	/** @status: Reservation status (0=pending, 1=fail) */
> +	bool status;
> +};
> +
>   #endif


  reply	other threads:[~2026-08-12 12:01 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-11 12:40 [PATCH V15 00/14] Add memory page offlining support Tejas Upadhyay
2026-08-11 12:40 ` [PATCH V15 01/14] drm/xe: Link VRAM object with gpu buddy Tejas Upadhyay
2026-08-11 12:40 ` [PATCH V15 02/14] [DO_NOT_MERGE]drm/gpu: Add gpu_buddy_allocated_addr_to_block helper Tejas Upadhyay
2026-08-11 12:40 ` [PATCH V15 03/14] drm/xe: Link LRC BO and its execution Queue Tejas Upadhyay
2026-08-11 12:40 ` [PATCH V15 04/14] drm/xe: Extend BO purge to handle vram pages as well Tejas Upadhyay
2026-08-11 12:40 ` [PATCH V15 05/14] drm/xe/bo: Make xe_bo_is_user() public Tejas Upadhyay
2026-08-11 15:38   ` Ghimiray, Himal Prasad
2026-08-11 12:40 ` [PATCH V15 06/14] drm/xe: Guard teardown paths against purged BOs Tejas Upadhyay
2026-08-12  3:24   ` Ghimiray, Himal Prasad
2026-08-12  9:40     ` Upadhyay, Tejas
2026-08-11 12:40 ` [PATCH V15 07/14] drm/xe/vram: Extract buddy alloc and free helpers Tejas Upadhyay
2026-08-12  3:25   ` Ghimiray, Himal Prasad
2026-08-11 12:40 ` [PATCH V15 08/14] drm/xe/vram: Add page offline data structures and lifecycle Tejas Upadhyay
2026-08-12 12:01   ` Ghimiray, Himal Prasad [this message]
2026-08-14  6:38     ` Upadhyay, Tejas
2026-08-11 12:40 ` [PATCH V15 09/14] drm/xe/vram: Add VRAM page offline fault handler Tejas Upadhyay
2026-08-13 12:44   ` Ghimiray, Himal Prasad
2026-08-14  5:19     ` Upadhyay, Tejas
2026-08-14 10:16       ` Upadhyay, Tejas
2026-08-11 12:40 ` [PATCH V15 10/14] drm/xe/configfs: Add vram bad page reservation policy Tejas Upadhyay
2026-08-12 12:21   ` Ghimiray, Himal Prasad
2026-08-11 12:40 ` [PATCH V15 11/14] drm/xe/vram: Use RCU for lock-free sysfs reads of bad page lists Tejas Upadhyay
2026-08-12 12:14   ` Ghimiray, Himal Prasad
2026-08-11 12:40 ` [PATCH V15 12/14] drm/xe: Add sysfs interface for bad gpu vram pages Tejas Upadhyay
2026-08-12 12:27   ` Ghimiray, Himal Prasad
2026-08-11 12:40 ` [PATCH V15 13/14] drm/xe/uapi: Expose ban reason in EXEC_QUEUE_GET_PROPERTY_BAN Tejas Upadhyay
2026-08-11 20:08   ` Rodrigo Vivi
2026-08-12 12:24   ` Ghimiray, Himal Prasad
2026-08-11 12:40 ` [PATCH V15 14/14] drm/xe: Add fault-inject based VRAM page offline injection Tejas Upadhyay
2026-08-16 14:35   ` Ghimiray, Himal Prasad

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=f6b491df-d74c-4540-8db5-6b028c85bf25@intel.com \
    --to=himal.prasad.ghimiray@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=tejas.upadhyay@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.