[PATCH 2/2] drm/xe_device: Evict all the VRAM objects during device remove
Upadhyay, Tejas
tejas.upadhyay at intel.com
Fri Feb 28 07:18:39 UTC 2025
> -----Original Message-----
> From: Bhatia, Aradhya <aradhya.bhatia at intel.com>
> Sent: Friday, February 28, 2025 12:22 PM
> To: Roper, Matthew D <matthew.d.roper at intel.com>
> Cc: Intel XE List <intel-xe at lists.freedesktop.org>; De Marchi, Lucas
> <lucas.demarchi at intel.com>; Hellstrom, Thomas
> <thomas.hellstrom at intel.com>; Upadhyay, Tejas
> <tejas.upadhyay at intel.com>; Ghimiray, Himal Prasad
> <himal.prasad.ghimiray at intel.com>; Bhatia, Aradhya
> <aradhya.bhatia at intel.com>
> Subject: [PATCH 2/2] drm/xe_device: Evict all the VRAM objects during device
> remove
>
> Now that xe's migrate subsystem is dev managed, instead of drm managed,
> evict all the VRAM objects during the xe device remove.
>
> The VRAM and TTM resource manager are drm managed, and so they are
> destroyed when all the references to DRM are put. When that happens, the
> VRAM and TTM resource managers evict all the BOs before their destruction.
> Since the migrate subsystem will already be finished by that point, the
> resource managers won't be able to evict the BOs successfully.
> Change that by preemptively evicting all the VRAM BOs during xe device
> remove.
>
> Signed-off-by: Aradhya Bhatia <aradhya.bhatia at intel.com>
> ---
> drivers/gpu/drm/xe/xe_device.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
> index 9454b51f7ad8..ef293552db6c 100644
> --- a/drivers/gpu/drm/xe/xe_device.c
> +++ b/drivers/gpu/drm/xe/xe_device.c
> @@ -905,8 +905,22 @@ int xe_device_probe(struct xe_device *xe)
>
> void xe_device_remove(struct xe_device *xe) {
> + int ret;
> + u32 mem_type;
> +
> xe_display_unregister(xe);
>
Should we check if dgpu?
Tejas
> + for (mem_type = XE_PL_VRAM0; mem_type <= XE_PL_VRAM1;
> ++mem_type) {
> + struct ttm_resource_manager *man =
> + ttm_manager_type(&xe->ttm, mem_type);
> +
> + if (man) {
> + ret = ttm_resource_manager_evict_all(&xe->ttm,
> man);
> + if (ret)
> + drm_err(&xe->drm, "VRAM evict failed!
> %d\n", ret);
> + }
> + }
> +
> drm_dev_unplug(&xe->drm);
> }
>
> --
> 2.45.2
More information about the Intel-xe
mailing list