Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] drm/xe: broken VRAM dma-buf eviction on unplug in xe_tt_map_sg() --
commit 6ee99dc07c1b583a7ad70334282ca88f6e39b4b1 Author: Matthew Brost <[email protected]> drm/xe: Don't DMA map tt pages after device unplug This commit rejects DMA-mapping ttm_tt pages in xe_tt_map_sg() with -ENODEV once the DRM device has been marked unplugged. > diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c > index 41092e2810b42..8ff92b2c91761 100644 > --- a/drivers/gpu/drm/xe/xe_bo.c > +++ b/drivers/gpu/drm/xe/xe_bo.c > @@ -499,6 +499,16 @@ static int xe_tt_map_sg(struct xe_device *xe, struct > ttm_tt *tt) > if (xe_tt->sg) > return 0; > > + /* > + * Once the device is unplugged, xe_bo_pci_dev_remove_all() has dropped > + * (or is about to drop, under each bo's lock) all DMA mappings. Don't > + * create new ones, e.g. when an exported dma-buf moved out to system > + * is migrated back to TT by begin_cpu_access(): such a mapping would > + * outlive the device's IOMMU group and crash on unmap. > + */ > + if (drm_dev_is_unplugged(&xe->drm)) > + return -ENODEV; [Severity: High] Does this break evicting exported dma-buf BOs from VRAM during device removal? In xe_device_remove(), drm_dev_unplug() runs before xe_bo_pci_dev_remove_all(): drivers/gpu/drm/xe/xe_device.c:xe_device_remove() { ... drm_dev_unplug(&xe->drm); xe_bo_pci_dev_remove_all(xe); ... } When xe_bo_pci_dev_remove_all() evicts an exported dma-buf BO from XE_PL_VRAM0 or XE_PL_VRAM1, xe_evict_flags() selects tt_placement so the BO moves to XE_PL_TT before XE_PL_SYSTEM. That VRAM-to-TT move allocates a new ttm_tt and calls xe_bo_move() -> xe_tt_map_sg(), which now fails with -ENODEV because drm_dev_is_unplugged() is already true. As a result, ttm_resource_manager_evict_all() aborts with a warning, the exported dma-buf BO is left in VRAM, and xe_ttm_vram_mgr_fini() returns early without running gpu_buddy_fini() or ttm_resource_manager_cleanup(). -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=26
