We currently assume that if we import a dmabuf, it is not backed by pages (we assume it exists in video memory on a foriegn device). However, some dmabuf will be backed by ordinary struct pages (e.g. vgem) and as such they may be shrinkable from direct reclaim. Since commit 09ea0dfbf972 ("dma-buf: make map_atomic and map function pointers optional") drivers do not need to supply a kmap() vfunc if they have no convenient access to the physical backing page. We can use that information to differentiate dmabuf that are likely to be backed by struct page and so suitable for including in our shrinkable set. Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> Cc: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx> Cc: Daniel Vetter <daniel@xxxxxxxx> --- drivers/gpu/drm/i915/i915_gem_dmabuf.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem_dmabuf.c b/drivers/gpu/drm/i915/i915_gem_dmabuf.c index 82e2ca17a441..8bc4030059f8 100644 --- a/drivers/gpu/drm/i915/i915_gem_dmabuf.c +++ b/drivers/gpu/drm/i915/i915_gem_dmabuf.c @@ -269,7 +269,15 @@ static void i915_gem_object_put_pages_dmabuf(struct drm_i915_gem_object *obj, DMA_BIDIRECTIONAL); } -static const struct drm_i915_gem_object_ops i915_gem_object_dmabuf_ops = { +static const struct drm_i915_gem_object_ops +i915_gem_object_dmabuf_ops = { + .get_pages = i915_gem_object_get_pages_dmabuf, + .put_pages = i915_gem_object_put_pages_dmabuf, +}; + +static const struct drm_i915_gem_object_ops +i915_gem_object_dmabuf_ops__shrinkable = { + .flags = I915_GEM_OBJECT_IS_SHRINKABLE, .get_pages = i915_gem_object_get_pages_dmabuf, .put_pages = i915_gem_object_put_pages_dmabuf, }; @@ -308,7 +316,10 @@ struct drm_gem_object *i915_gem_prime_import(struct drm_device *dev, } drm_gem_private_object_init(dev, &obj->base, dma_buf->size); - i915_gem_object_init(obj, &i915_gem_object_dmabuf_ops); + i915_gem_object_init(obj, + dma_buf->ops->map ? + &i915_gem_object_dmabuf_ops__shrinkable : + &i915_gem_object_dmabuf_ops); obj->base.import_attach = attach; obj->resv = dma_buf->resv; -- 2.18.0 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx