All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: "Tauro, Riana" <riana.tauro@intel.com>
Cc: <dri-devel@lists.freedesktop.org>,
	<intel-xe@lists.freedesktop.org>,
	Aravind Iddamsetty <aravind.iddamsetty@linux.intel.com>,
	Tejas Upadhyay <tejas.upadhyay@intel.com>,
	Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Subject: Re: [PATCH v7 3/3] drm/xe: Expose retired VRAM pages via drm-ras
Date: Wed, 2 Dec 2026 08:42:13 -0500	[thread overview]
Message-ID: <axAgNfYlTp6YqoEF@intel.com> (raw)
In-Reply-To: <32a0015f-aa9f-4b14-8156-14a770fcdc61@intel.com>

On Wed, Dec 02, 2026 at 11:07:28AM +0530, Tauro, Riana wrote:
> 
> On 30-11-2026 23:23, Rodrigo Vivi wrote:
> > From: Aravind Iddamsetty <aravind.iddamsetty@linux.intel.com>
> > 
> > Retired VRAM pages are only visible through the vram_bad_pages debugfs
> > file today. Register a drm-ras retired-pages node so userspace gets
> > them, and the maximum number of pages that can be retired, through a
> > stable interface.
> > 
> > The snapshot of the dump is taken in one pass over the page lists of
> > each VRAM manager, under its lock.
> > 
> > v3 (Rodrigo+LLM):
> >   - Use the drm-ras retired-pages node type, which replaces the nested
> >     retired-resources layout (Jakub).
> >   - Walk the lists under mgr->lock instead of RCU, which they are not
> >     protected by, and stop reading the buddy blocks (Sashiko).
> >   - Add a generation counter for interrupted dumps.
> >   - Keep the vram_bad_pages debugfs file for now.
> >   - Remove deprecated Assisted-by tag.
> > 
> > v4 (Rodrigo+LLM):
> >   - Register the node at the end of xe_ras_init(), once the retired page
> >     lists are fetched. That point is only reached with a system
> >     controller, which replaces the XE_CRESCENTISLAND check and keeps the
> >     node off VFs (local Sashiko).
> >   - Report the list generation also when no page is left (local Sashiko).
> > 
> > v6 (Rodrigo+LLM):
> >   - Add the pages to the drm-ras snapshot in one pass over the page
> >     lists, instead of a walk per page, and drop the generation counter
> >     (Riana).
> >   - Do not read the pages of an unplugged device (Riana).
> >   - Return -EINVAL when firmware reports no max pages (Riana).
> >   - Do not register the node when page offlining is disabled, and do not
> >     fail probe if the registration fails (Riana).
> > 
> > Cc: Tejas Upadhyay <tejas.upadhyay@intel.com>
> > Cc: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
> > Cc: Riana Tauro <riana.tauro@intel.com>
> > Signed-off-by: Aravind Iddamsetty <aravind.iddamsetty@linux.intel.com>
> > Reviewed-by: Tejas Upadhyay <tejas.upadhyay@intel.com>
> > Reviewed-by: Riana Tauro <riana.tauro@intel.com> (#xe_drm_ras)
> > Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> > ---
> >   drivers/gpu/drm/xe/xe_drm_ras.c      | 78 ++++++++++++++++++++++++++++
> >   drivers/gpu/drm/xe/xe_drm_ras.h      |  1 +
> >   drivers/gpu/drm/xe/xe_ras.c          |  2 +
> >   drivers/gpu/drm/xe/xe_ttm_vram_mgr.c | 58 +++++++++++++++++++++
> >   drivers/gpu/drm/xe/xe_ttm_vram_mgr.h |  2 +
> >   5 files changed, 141 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/xe/xe_drm_ras.c b/drivers/gpu/drm/xe/xe_drm_ras.c
> > index 86c589437a9f..7490281095ae 100644
> > --- a/drivers/gpu/drm/xe/xe_drm_ras.c
> > +++ b/drivers/gpu/drm/xe/xe_drm_ras.c
> > @@ -13,6 +13,7 @@
> >   #include "xe_device_types.h"
> >   #include "xe_drm_ras.h"
> >   #include "xe_ras.h"
> > +#include "xe_ttm_vram_mgr.h"
> >   #include "xe_wedge.h"
> >   static const char * const error_components[] = DRM_XE_RAS_ERROR_COMPONENT_NAMES;
> > @@ -272,6 +273,83 @@ static int register_nodes(struct xe_device *xe)
> >   	return ret;
> >   }
> > +static int query_retired_pages(struct drm_ras_node *node, struct drm_ras_retired_pages *list)
> > +{
> > +	struct xe_device *xe = node->priv;
> > +	int idx, ret;
> > +
> > +	if (!drm_dev_enter(&xe->drm, &idx))
> > +		return -ENODEV;
> > +
> > +	ret = xe_ttm_vram_get_retired_pages(xe, list);
> > +
> > +	drm_dev_exit(idx);
> > +
> > +	return ret;
> > +}
> > +
> > +static int query_retired_pages_info(struct drm_ras_node *node,
> > +				    struct drm_ras_retired_pages_info *info)
> > +{
> > +	struct xe_device *xe = node->priv;
> > +	int idx, ret = 0;
> > +
> > +	if (!drm_dev_enter(&xe->drm, &idx))
> > +		return -ENODEV;
> > +
> > +	info->max_pages = xe_ras_get_max_pages(xe);
> > +	if (!info->max_pages)
> > +		ret = -EINVAL;
> > +
> > +	drm_dev_exit(idx);
> > +
> > +	return ret;
> > +}
> > +
> > +/**
> > + * xe_drm_ras_register_retired_pages() - Register the retired VRAM pages node
> > + * @xe: xe device instance
> > + *
> > + * Called once the retired page lists are populated.
> > + *
> > + * Return: 0 on success, negative error code otherwise.
> > + */
> > +int xe_drm_ras_register_retired_pages(struct xe_device *xe)
> > +{
> > +	struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
> > +	struct drm_ras_node *node;
> > +	int ret;
> > +
> > +	if (!xe->info.has_drm_ras || xe_ras_get_disable_vram_page_offline(xe))
> 
> This is failing build now because of a recent change.
> commit a6276b686dd3607638d8d24049253ff62def784d  drm/xe: Invert
> vram_page_offline configfs attribute

ouch, good catch, thanks for noticing this before the merge.

v8 is rebased on today's drm-tip and uses
!xe_ras_get_enable_vram_page_offline(xe). The default is still on, and
it is set at the start of xe_ras_init(), before we register the node,
so the behaviour doesn't change.

> 
> Riana
> 
> > +		return 0;
> > +
> > +	node = drmm_kzalloc(&xe->drm, sizeof(*node), GFP_KERNEL);
> > +	if (!node)
> > +		return -ENOMEM;
> > +
> > +	node->device_name = kasprintf(GFP_KERNEL, "%04x:%02x:%02x.%d",
> > +				      pci_domain_nr(pdev->bus), pdev->bus->number,
> > +				      PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
> > +	if (!node->device_name)
> > +		return -ENOMEM;
> > +
> > +	node->node_name = "vram-retired-pages";
> > +	node->type = DRM_RAS_NODE_TYPE_RETIRED_PAGES;
> > +	node->query_retired_pages = query_retired_pages;
> > +	node->query_retired_pages_info = query_retired_pages_info;
> > +	node->priv = xe;
> > +
> > +	ret = drm_ras_node_register(node);
> > +	if (ret) {
> > +		drm_err(&xe->drm, "Failed to register DRM RAS retired pages node (%pe)\n",
> > +			ERR_PTR(ret));
> > +		cleanup_node_param(node);
> > +		return ret;
> > +	}
> > +
> > +	return drmm_add_action_or_reset(&xe->drm, cleanup_node, node);
> > +}
> > +
> >   /**
> >    * xe_drm_ras_event() - Report drm-ras error event to userspace
> >    * @xe: xe device structure
> > diff --git a/drivers/gpu/drm/xe/xe_drm_ras.h b/drivers/gpu/drm/xe/xe_drm_ras.h
> > index 723229b2cffb..a6fc2255986d 100644
> > --- a/drivers/gpu/drm/xe/xe_drm_ras.h
> > +++ b/drivers/gpu/drm/xe/xe_drm_ras.h
> > @@ -13,6 +13,7 @@ struct xe_device;
> >   	for (i = 0; i < DRM_XE_RAS_ERR_SEV_MAX; i++)
> >   int xe_drm_ras_init(struct xe_device *xe);
> > +int xe_drm_ras_register_retired_pages(struct xe_device *xe);
> >   void xe_drm_ras_event(struct xe_device *xe, u32 component, u32 severity, u32 value);
> >   #endif
> > diff --git a/drivers/gpu/drm/xe/xe_ras.c b/drivers/gpu/drm/xe/xe_ras.c
> > index f8113530068d..2dd1391724c9 100644
> > --- a/drivers/gpu/drm/xe/xe_ras.c
> > +++ b/drivers/gpu/drm/xe/xe_ras.c
> > @@ -1523,6 +1523,8 @@ int xe_ras_init(struct xe_device *xe)
> >   	get_offline_list(xe);
> >   	get_offline_queue(xe);
> > +	xe_drm_ras_register_retired_pages(xe);
> > +
> >   	/*
> >   	 * During probe, process and log any errors detected by firmware while the driver was not
> >   	 * loaded. Critical errors such as Punit and CSC are reported through Pcode init failure,
> > diff --git a/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c b/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c
> > index 36d47de8b11b..7658ce9f1bd9 100644
> > --- a/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c
> > +++ b/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c
> > @@ -10,6 +10,7 @@
> >   #include <drm/drm_managed.h>
> >   #include <drm/drm_drv.h>
> >   #include <drm/drm_buddy.h>
> > +#include <drm/drm_ras.h>
> >   #include <uapi/drm/xe_drm.h>
> >   #include <drm/ttm/ttm_placement.h>
> > @@ -625,6 +626,63 @@ u64 xe_ttm_vram_get_avail(struct ttm_resource_manager *man)
> >   	return avail;
> >   }
> > +/**
> > + * xe_ttm_vram_get_retired_pages - Get a snapshot of the retired VRAM pages
> > + * @xe: xe device instance
> > + * @list: drm-ras snapshot to add the retired pages to
> > + *
> > + * Return: 0 on success, negative error code otherwise.
> > + */
> > +int xe_ttm_vram_get_retired_pages(struct xe_device *xe, struct drm_ras_retired_pages *list)
> > +{
> > +	struct xe_ttm_vram_offline_resource *pos;
> > +	struct drm_ras_retired_page page;
> > +	struct xe_tile *tile;
> > +	u8 id;
> > +	int ret;
> > +
> > +	for_each_tile(tile, xe, id) {
> > +		struct xe_vram_region *vr = tile->mem.vram;
> > +		struct ttm_resource_manager *man;
> > +		struct xe_ttm_vram_mgr *mgr;
> > +
> > +		man = ttm_manager_type(&xe->ttm, XE_PL_VRAM0 + id);
> > +		if (!man || !vr)
> > +			continue;
> > +		mgr = to_xe_ttm_vram_mgr(man);
> > +
> > +		guard(mutex)(&mgr->lock);
> > +
> > +		list_for_each_entry(pos, &mgr->offlined_pages, offlined_link) {
> > +			page = (struct drm_ras_retired_page) {
> > +				.address = pos->addr + vr->dpa_base,
> > +				.size = PAGE_SIZE,
> > +				.status = DRM_RAS_RETIRED_PAGE_STATUS_RETIRED,
> > +			};
> > +
> > +			ret = drm_ras_retired_pages_add(list, &page);
> > +			if (ret)
> > +				return ret;
> > +		}
> > +
> > +		list_for_each_entry(pos, &mgr->queued_pages, queued_link) {
> > +			page = (struct drm_ras_retired_page) {
> > +				.address = pos->addr + vr->dpa_base,
> > +				.size = PAGE_SIZE,
> > +				.status = pos->status == XE_PAGE_RESERVE_FAIL ?
> > +					  DRM_RAS_RETIRED_PAGE_STATUS_FAILED :
> > +					  DRM_RAS_RETIRED_PAGE_STATUS_PENDING,
> > +			};
> > +
> > +			ret = drm_ras_retired_pages_add(list, &page);
> > +			if (ret)
> > +				return ret;
> > +		}
> > +	}
> > +
> > +	return 0;
> > +}
> > +
> >   static int xe_ttm_vram_purge_page(struct xe_device *xe, struct xe_bo *bo)
> >   {
> >   	u32 q_flag = DRM_XE_EXEC_QUEUE_BAN_REASON_PAGE_OFFLINE;
> > diff --git a/drivers/gpu/drm/xe/xe_ttm_vram_mgr.h b/drivers/gpu/drm/xe/xe_ttm_vram_mgr.h
> > index d77f067d197b..7fdcd9836148 100644
> > --- a/drivers/gpu/drm/xe/xe_ttm_vram_mgr.h
> > +++ b/drivers/gpu/drm/xe/xe_ttm_vram_mgr.h
> > @@ -9,6 +9,7 @@
> >   #include "xe_ttm_vram_mgr_types.h"
> >   enum dma_data_direction;
> > +struct drm_ras_retired_pages;
> >   struct xe_device;
> >   struct xe_tile;
> >   struct xe_vram_region;
> > @@ -33,6 +34,7 @@ void xe_ttm_vram_get_used(struct ttm_resource_manager *man,
> >   			  u64 *used, u64 *used_visible);
> >   int xe_ttm_vram_handle_addr_fault(struct xe_device *xe, u64 addr);
> >   int xe_ttm_vram_inject_fault(struct xe_device *xe);
> > +int xe_ttm_vram_get_retired_pages(struct xe_device *xe, struct drm_ras_retired_pages *list);
> >   static inline struct xe_ttm_vram_mgr_resource *
> >   to_xe_ttm_vram_mgr_resource(struct ttm_resource *res)

  reply	other threads:[~2026-12-02 13:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 17:53 [PATCH v7 0/3] drm/xe: Expose retired VRAM pages via drm-ras Rodrigo Vivi
2026-11-30 17:53 ` [PATCH v7 1/3] drm/ras: Check the node type in node lookups Rodrigo Vivi
2026-11-30 17:53 ` [PATCH v7 2/3] drm/ras: Add retired-pages node type Rodrigo Vivi
2026-12-02  9:02   ` Tauro, Riana
2026-12-02 13:41     ` Rodrigo Vivi
2026-11-30 17:53 ` [PATCH v7 3/3] drm/xe: Expose retired VRAM pages via drm-ras Rodrigo Vivi
2026-12-02  5:37   ` Tauro, Riana
2026-12-02 13:42     ` Rodrigo Vivi [this message]
2026-11-30 18:13 ` ✗ CI.checkpatch: warning for drm/xe: Expose retired VRAM pages via drm-ras (rev7) Patchwork
2026-11-30 18:15 ` ✓ CI.KUnit: success " Patchwork
2026-11-30 18:52 ` ✓ Xe.CI.BAT: " Patchwork
2026-12-01  3:18 ` ✗ Xe.CI.FULL: failure " 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=axAgNfYlTp6YqoEF@intel.com \
    --to=rodrigo.vivi@intel.com \
    --cc=aravind.iddamsetty@linux.intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=himal.prasad.ghimiray@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=riana.tauro@intel.com \
    --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.