freedreno/drm: handle ancient kernels
authorRob Clark <robdclark@chromium.org>
Sun, 17 May 2020 23:16:43 +0000 (16:16 -0700)
committerMarge Bot <eric+marge@anholt.net>
Mon, 18 May 2020 19:00:47 +0000 (19:00 +0000)
Older kernels did not support `MSM_INFO_GET_IOVA`.  But this is only
required for (a) clover (ie. `fd_set_global_binding()`) and drm paths
that are limited to newer kernels.  So move the location of the assert
to fix new userspace on old kernels.

Fixes: c9e8df61dc8 ("freedreno: Initialize the bo's iova at creation time.")
Signed-off-by: Rob Clark <robdclark@chromium.org>
Tested-by: Ilia Mirkin <imirkin@alum.mit.edu>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5081>

src/freedreno/drm/freedreno_bo.c
src/freedreno/drm/msm_bo.c

index a4218cd8ffb38957891d7a7524225fc35bb05307..b6d5cdd9bec254ee1f7b5f80e15956e3b0886756 100644 (file)
@@ -236,6 +236,8 @@ fd_bo_mark_for_dump(struct fd_bo *bo)
 
 uint64_t fd_bo_get_iova(struct fd_bo *bo)
 {
+       /* ancient kernels did not support this */
+       assert(bo->iova != 0);
        return bo->iova;
 }
 
index da2609903c12b762faeb396d2dbf50141fd45bd5..7253a8cc7bd3c4aad86bae4db277a7e17e3c0e33 100644 (file)
@@ -112,7 +112,8 @@ static uint64_t msm_bo_iova(struct fd_bo *bo)
        int ret;
 
        ret = drmCommandWriteRead(bo->dev->fd, DRM_MSM_GEM_INFO, &req, sizeof(req));
-       debug_assert(ret == 0);
+       if (ret)
+               return 0;
 
        return req.value;
 }