[PATCH 2/2] drm/xe_device: Evict all the VRAM objects during device remove
Hellstrom, Thomas
thomas.hellstrom at intel.com
Fri Feb 28 11:21:58 UTC 2025
On Fri, 2025-02-28 at 06:52 +0000, Aradhya Bhatia wrote:
> 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);
>
> + 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);
> + }
> + }
> +
You probably want to make all this a function in xe_bo.c It also needs
to be called *after* drm_dev_unplug(). Otherwise the memory can be
brought back in again by a running application.
Finally you'd also want to evict all XE_PL_TT bos, because those are
the ones that have dma maps. Evicting XE_PL_TT to XE_PL_SYSTEM doesn't
do much more than unmapping dma.
/Thomas
> drm_dev_unplug(&xe->drm);
> }
>
More information about the Intel-xe
mailing list