freedreno/drm: convert ring_pool to child_pool
authorRob Clark <robdclark@chromium.org>
Mon, 29 Jul 2019 18:48:06 +0000 (11:48 -0700)
committerRob Clark <robdclark@chromium.org>
Fri, 2 Aug 2019 17:24:14 +0000 (10:24 -0700)
Worth another couple percent at driver2

Signed-off-by: Rob Clark <robdclark@chromium.org>
src/freedreno/drm/msm_pipe.c
src/freedreno/drm/msm_priv.h
src/freedreno/drm/msm_ringbuffer_sp.c

index 718becbf7820b1f2057dc0eebd5a7637d9239c51..2eef493b5d492029831a30a7d75ec1a268f6ba15 100644 (file)
@@ -167,6 +167,7 @@ static void msm_pipe_destroy(struct fd_pipe *pipe)
 {
        struct msm_pipe *msm_pipe = to_msm_pipe(pipe);
        close_submitqueue(pipe, msm_pipe->queue_id);
+       msm_pipe_sp_ringpool_init(msm_pipe);
        free(msm_pipe);
 }
 
@@ -244,6 +245,8 @@ struct fd_pipe * msm_pipe_new(struct fd_device *dev,
        if (open_submitqueue(pipe, prio))
                goto fail;
 
+       msm_pipe_sp_ringpool_init(msm_pipe);
+
        return pipe;
 fail:
        if (pipe)
index fd4267fa37106911f276e781b316248f2de29827..172e9870fe5973e497229ff39e03e3b229ca4635 100644 (file)
@@ -29,6 +29,8 @@
 
 #include "freedreno_priv.h"
 
+#include "util/slab.h"
+
 #ifndef __user
 #  define __user
 #endif
@@ -51,6 +53,7 @@ struct msm_pipe {
        uint32_t gmem;
        uint32_t chip_id;
        uint32_t queue_id;
+       struct slab_parent_pool ring_pool;
 };
 FD_DEFINE_CAST(fd_pipe, msm_pipe);
 
@@ -63,6 +66,10 @@ struct fd_ringbuffer * msm_ringbuffer_sp_new_object(struct fd_pipe *pipe, uint32
 struct fd_submit * msm_submit_new(struct fd_pipe *pipe);
 struct fd_submit * msm_submit_sp_new(struct fd_pipe *pipe);
 
+void msm_pipe_sp_ringpool_init(struct msm_pipe *msm_pipe);
+void msm_pipe_sp_ringpool_fini(struct msm_pipe *msm_pipe);
+
+
 struct msm_bo {
        struct fd_bo base;
        uint64_t offset;
index c87ad5128100865731652e4d1b6c28ce46f519f3..af71277072c730e29b29af687bbad74915ecbf8f 100644 (file)
@@ -51,7 +51,7 @@ struct msm_submit_sp {
        /* maps fd_bo to idx in bos table: */
        struct hash_table *bo_table;
 
-       struct slab_mempool ring_pool;
+       struct slab_child_pool ring_pool;
 
        struct fd_ringbuffer *primary;
 
@@ -210,7 +210,7 @@ msm_submit_sp_new_ringbuffer(struct fd_submit *submit, uint32_t size,
        struct msm_submit_sp *msm_submit = to_msm_submit_sp(submit);
        struct msm_ringbuffer_sp *msm_ring;
 
-       msm_ring = slab_alloc_st(&msm_submit->ring_pool);
+       msm_ring = slab_alloc(&msm_submit->ring_pool);
 
        msm_ring->u.submit = submit;
 
@@ -317,7 +317,7 @@ msm_submit_sp_destroy(struct fd_submit *submit)
        // TODO it would be nice to have a way to debug_assert() if all
        // rb's haven't been free'd back to the slab, because that is
        // an indication that we are leaking bo's
-       slab_destroy(&msm_submit->ring_pool);
+       slab_destroy_child(&msm_submit->ring_pool);
 
        for (unsigned i = 0; i < msm_submit->nr_bos; i++)
                fd_bo_del(msm_submit->bos[i]);
@@ -341,8 +341,8 @@ msm_submit_sp_new(struct fd_pipe *pipe)
 
        msm_submit->bo_table = _mesa_hash_table_create(NULL,
                        _mesa_hash_pointer, _mesa_key_pointer_equal);
-       // TODO tune size:
-       slab_create(&msm_submit->ring_pool, sizeof(struct msm_ringbuffer_sp), 16);
+
+       slab_create_child(&msm_submit->ring_pool, &to_msm_pipe(pipe)->ring_pool);
 
        submit = &msm_submit->base;
        submit->pipe = pipe;
@@ -351,6 +351,19 @@ msm_submit_sp_new(struct fd_pipe *pipe)
        return submit;
 }
 
+void
+msm_pipe_sp_ringpool_init(struct msm_pipe *msm_pipe)
+{
+       // TODO tune size:
+       slab_create_parent(&msm_pipe->ring_pool, sizeof(struct msm_ringbuffer_sp), 16);
+}
+
+void
+msm_pipe_sp_ringpool_fini(struct msm_pipe *msm_pipe)
+{
+       if (msm_pipe->ring_pool.num_elements)
+               slab_destroy_parent(&msm_pipe->ring_pool);
+}
 
 static void
 finalize_current_cmd(struct fd_ringbuffer *ring)
@@ -511,7 +524,7 @@ msm_ringbuffer_sp_destroy(struct fd_ringbuffer *ring)
                        fd_bo_del(msm_ring->u.cmds[i].ring_bo);
                }
 
-               slab_free_st(&to_msm_submit_sp(submit)->ring_pool, msm_ring);
+               slab_free(&to_msm_submit_sp(submit)->ring_pool, msm_ring);
        }
 }