freedreno: Initialize the bo's iova at creation time.
authorEric Anholt <eric@anholt.net>
Thu, 7 May 2020 23:58:25 +0000 (16:58 -0700)
committerEric Anholt <eric@anholt.net>
Fri, 8 May 2020 19:35:39 +0000 (12:35 -0700)
Avoids repeated conditionals at reloc time checking if we need to go ask
the kernel.

No statistically significant difference on the drawoverhead case I'm
looking at (n=300).

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4957>

src/freedreno/drm/freedreno_bo.c
src/freedreno/drm/freedreno_drmif.h
src/freedreno/drm/msm_ringbuffer_sp.c
src/gallium/drivers/freedreno/freedreno_state.c

index 6d51023acac735755bcf9357bf5564f62199d0fe..04f9c1d16b4f65bcc5d0ecb82caab46125df7459 100644 (file)
@@ -72,6 +72,8 @@ static struct fd_bo * bo_from_handle(struct fd_device *dev,
        bo->dev = fd_device_ref(dev);
        bo->size = size;
        bo->handle = handle;
+       bo->iova = bo->funcs->iova(bo);
+
        p_atomic_set(&bo->refcnt, 1);
        list_inithead(&bo->list);
        /* add ourself into the handle table: */
@@ -225,16 +227,9 @@ out_unlock:
 
 uint64_t fd_bo_get_iova(struct fd_bo *bo)
 {
-       if (!bo->iova)
-               bo->iova = bo->funcs->iova(bo);
        return bo->iova;
 }
 
-void fd_bo_put_iova(struct fd_bo *bo)
-{
-       /* currently a no-op */
-}
-
 struct fd_bo * fd_bo_ref(struct fd_bo *bo)
 {
        p_atomic_inc(&bo->refcnt);
index 210b5c1860463cd22a36cc3fccf1559586477131..ad8ef9ae316bb2ea219cba5fef1e6f4f558fcba8 100644 (file)
@@ -158,7 +158,6 @@ struct fd_bo *fd_bo_from_handle(struct fd_device *dev,
 struct fd_bo * fd_bo_from_name(struct fd_device *dev, uint32_t name);
 struct fd_bo * fd_bo_from_dmabuf(struct fd_device *dev, int fd);
 uint64_t fd_bo_get_iova(struct fd_bo *bo);
-void fd_bo_put_iova(struct fd_bo *bo);
 struct fd_bo * fd_bo_ref(struct fd_bo *bo);
 void fd_bo_del(struct fd_bo *bo);
 int fd_bo_get_name(struct fd_bo *bo, uint32_t *name);
index 1df82d8f599ca34cbefce7bc7e38d8a7102f72cc..5d8e34cc9c12f37a4e0afb4d96ce0f9f71aad7ea 100644 (file)
@@ -416,7 +416,7 @@ msm_ringbuffer_sp_emit_reloc(struct fd_ringbuffer *ring,
                pipe = msm_ring->u.submit->pipe;
        }
 
-       uint64_t iova = fd_bo_get_iova(reloc->bo) + reloc->offset;
+       uint64_t iova = reloc->bo->iova + reloc->offset;
        int shift = reloc->shift;
 
        if (shift < 0)
index 698ca82e521437515d7327d5a52c608c8d2b77fd..a72958a1bc8a158a2dad80db348f88516e7247c4 100644 (file)
@@ -588,10 +588,6 @@ fd_set_global_binding(struct pipe_context *pctx,
 
                for (unsigned i = 0; i < count; i++) {
                        unsigned n = i + first;
-                       if (so->buf[n]) {
-                               struct fd_resource *rsc = fd_resource(so->buf[n]);
-                               fd_bo_put_iova(rsc->bo);
-                       }
                        pipe_resource_reference(&so->buf[n], NULL);
                }