On Tue, 2021-10-12 at 20:57 +0200, Thomas Hellström wrote: > > +void vmw_sys_man_fini(struct vmw_private *dev_priv) > > +{ > > + struct ttm_resource_manager *man = > > ttm_manager_type(&dev_priv->bdev, > > + > > VMW_PL_SYSTEM); > > + > > + ttm_resource_manager_evict_all(&dev_priv->bdev, man); > > + > > + ttm_resource_manager_set_used(man, false); > > + ttm_resource_manager_cleanup(man); > > + > > + ttm_set_driver_manager(&dev_priv->bdev, VMW_PL_SYSTEM, > > NULL); > > + kfree(man); > > +} > > I seem to recognize the general pattern here from the > ttm_sys_manager, > Any chance we could add what's needed to the ttm_sys_manager and make > the code reusable? That's the _fini function and the memory type > choice > I guess. I figure i915 will need exactly the same. I think technically we could share this entire thing. I'm not sure how many GPU specific features one needs for "system memory placement but allowing fencing". As to sharing just the fini, I'd be happy to share any code we can but it'd be probably be only between vmwgfx and i915 because the default sys_man doesn't need the evict_all and it's allocated as part of its parent struct so it doesn't need to free. We could trivially add void ttm_fencable_sys_man_fini(struct ttm_device *dev, u32 mem_type) but I'd probably wait until i915 is ready to use it to avoid adding shared code that's only used by a single driver :) z