From: Dave Airlie <airl...@redhat.com>

Before exporting a buffer, make sure it has been populated with
pages at least once.

Signed-off-by: Dave Airlie <airl...@redhat.com>
---
 drivers/gpu/drm/nouveau/nouveau_prime.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/gpu/drm/nouveau/nouveau_prime.c 
b/drivers/gpu/drm/nouveau/nouveau_prime.c
index cd95446d6851..caab60fc62f6 100644
--- a/drivers/gpu/drm/nouveau/nouveau_prime.c
+++ b/drivers/gpu/drm/nouveau/nouveau_prime.c
@@ -108,9 +108,21 @@ struct dma_buf *nouveau_gem_prime_export(struct 
drm_gem_object *gobj,
                                         int flags)
 {
        struct nouveau_bo *nvbo = nouveau_gem_object(gobj);
+       struct ttm_operation_ctx ctx = {
+               .interruptible = true,
+               .no_wait_gpu = true,
+               /* We opt to avoid OOM on system pages allocations */
+               .gfp_retry_mayfail = true,
+               .allow_res_evict = false,
+       };
+       int ret;
 
        if (nvbo->no_share)
                return ERR_PTR(-EPERM);
 
+       ret = ttm_bo_setup_export(&nvbo->bo, &ctx);
+       if (ret)
+               return ERR_PTR(ret);
+
        return drm_gem_prime_export(gobj, flags);
 }
-- 
2.50.1

Reply via email to