[Mesa-dev] [PATCH 2/2] panfrost: Kill the panfrost_driver abstraction

Boris Brezillon boris.brezillon at collabora.com
Fri Jun 21 13:57:27 UTC 2019


The non-drm backend is gone and there's no plan to bring it back to
life. Let's get rid of the panfrost_driver abstraction and call the
panfrost_drm_xxx() functions directly.

Signed-off-by: Boris Brezillon <boris.brezillon at collabora.com>
---
 src/gallium/drivers/panfrost/pan_afbc.c     |   2 +-
 src/gallium/drivers/panfrost/pan_context.c  |  32 +++---
 src/gallium/drivers/panfrost/pan_drm.c      | 102 ++++++--------------
 src/gallium/drivers/panfrost/pan_job.c      |   2 +-
 src/gallium/drivers/panfrost/pan_resource.c |  18 ++--
 src/gallium/drivers/panfrost/pan_screen.c   |   8 +-
 src/gallium/drivers/panfrost/pan_screen.h   |  76 +++++++++------
 7 files changed, 109 insertions(+), 131 deletions(-)

diff --git a/src/gallium/drivers/panfrost/pan_afbc.c b/src/gallium/drivers/panfrost/pan_afbc.c
index 4bef833f1820..5621d1f333a3 100644
--- a/src/gallium/drivers/panfrost/pan_afbc.c
+++ b/src/gallium/drivers/panfrost/pan_afbc.c
@@ -138,7 +138,7 @@ panfrost_enable_afbc(struct panfrost_context *ctx, struct panfrost_resource *rsr
         unsigned buffer_size = header_size + body_size;
 
         /* Allocate the AFBC slab itself, large enough to hold the above */
-        screen->driver->allocate_slab(screen, &rsrc->bo->afbc_slab,
+        panfrost_drm_allocate_slab(screen, &rsrc->bo->afbc_slab,
                                ALIGN(buffer_size, 4096) / 4096,
                                true, 0, 0, 0);
 
diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c
index 867b49c55967..14d29f5d20f1 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -87,7 +87,7 @@ panfrost_enable_checksum(struct panfrost_context *ctx, struct panfrost_resource
         /* 8 byte checksum per tile */
         rsrc->bo->checksum_stride = tile_w * 8;
         int pages = (((rsrc->bo->checksum_stride * tile_h) + 4095) / 4096);
-        screen->driver->allocate_slab(screen, &rsrc->bo->checksum_slab, pages, false, 0, 0, 0);
+        panfrost_drm_allocate_slab(screen, &rsrc->bo->checksum_slab, pages, false, 0, 0, 0);
 
         rsrc->bo->has_checksum = true;
 }
@@ -1431,14 +1431,14 @@ panfrost_submit_frame(struct panfrost_context *ctx, bool flush_immediate,
         /* If visual, we can stall a frame */
 
         if (!flush_immediate)
-                screen->driver->force_flush_fragment(ctx, fence);
+                panfrost_drm_force_flush_fragment(ctx, fence);
 
         screen->last_fragment_flushed = false;
         screen->last_job = job;
 
         /* If readback, flush now (hurts the pipelined performance) */
         if (flush_immediate)
-                screen->driver->force_flush_fragment(ctx, fence);
+                panfrost_drm_force_flush_fragment(ctx, fence);
 #endif
 }
 
@@ -2503,11 +2503,11 @@ panfrost_destroy(struct pipe_context *pipe)
         if (panfrost->blitter)
                 util_blitter_destroy(panfrost->blitter);
 
-        screen->driver->free_slab(screen, &panfrost->scratchpad);
-        screen->driver->free_slab(screen, &panfrost->varying_mem);
-        screen->driver->free_slab(screen, &panfrost->shaders);
-        screen->driver->free_slab(screen, &panfrost->tiler_heap);
-        screen->driver->free_slab(screen, &panfrost->tiler_polygon_list);
+        panfrost_drm_free_slab(screen, &panfrost->scratchpad);
+        panfrost_drm_free_slab(screen, &panfrost->varying_mem);
+        panfrost_drm_free_slab(screen, &panfrost->shaders);
+        panfrost_drm_free_slab(screen, &panfrost->tiler_heap);
+        panfrost_drm_free_slab(screen, &panfrost->tiler_polygon_list);
 
         ralloc_free(pipe);
 }
@@ -2660,12 +2660,12 @@ panfrost_setup_hardware(struct panfrost_context *ctx)
                 ctx->transient_pools[i].entries[0] = (struct panfrost_memory_entry *) pb_slab_alloc(&screen->slabs, entry_size, HEAP_TRANSIENT);
         }
 
-        screen->driver->allocate_slab(screen, &ctx->scratchpad, 64, false, 0, 0, 0);
-        screen->driver->allocate_slab(screen, &ctx->varying_mem, 16384, false, PAN_ALLOCATE_INVISIBLE | PAN_ALLOCATE_COHERENT_LOCAL, 0, 0);
-        screen->driver->allocate_slab(screen, &ctx->shaders, 4096, true, PAN_ALLOCATE_EXECUTE, 0, 0);
-        screen->driver->allocate_slab(screen, &ctx->tiler_heap, 32768, false, PAN_ALLOCATE_INVISIBLE | PAN_ALLOCATE_GROWABLE, 1, 128);
-        screen->driver->allocate_slab(screen, &ctx->tiler_polygon_list, 128*128, false, PAN_ALLOCATE_INVISIBLE | PAN_ALLOCATE_GROWABLE, 1, 128);
-        screen->driver->allocate_slab(screen, &ctx->tiler_dummy, 1, false, PAN_ALLOCATE_INVISIBLE, 0, 0);
+        panfrost_drm_allocate_slab(screen, &ctx->scratchpad, 64, false, 0, 0, 0);
+        panfrost_drm_allocate_slab(screen, &ctx->varying_mem, 16384, false, PAN_ALLOCATE_INVISIBLE | PAN_ALLOCATE_COHERENT_LOCAL, 0, 0);
+        panfrost_drm_allocate_slab(screen, &ctx->shaders, 4096, true, PAN_ALLOCATE_EXECUTE, 0, 0);
+        panfrost_drm_allocate_slab(screen, &ctx->tiler_heap, 32768, false, PAN_ALLOCATE_INVISIBLE | PAN_ALLOCATE_GROWABLE, 1, 128);
+        panfrost_drm_allocate_slab(screen, &ctx->tiler_polygon_list, 128*128, false, PAN_ALLOCATE_INVISIBLE | PAN_ALLOCATE_GROWABLE, 1, 128);
+        panfrost_drm_allocate_slab(screen, &ctx->tiler_dummy, 1, false, PAN_ALLOCATE_INVISIBLE, 0, 0);
 
 }
 
@@ -2681,7 +2681,7 @@ panfrost_create_context(struct pipe_screen *screen, void *priv, unsigned flags)
         struct pipe_context *gallium = (struct pipe_context *) ctx;
         unsigned gpu_id;
 
-        gpu_id = pscreen->driver->query_gpu_version(pscreen);
+        gpu_id = panfrost_drm_query_gpu_version(pscreen);
 
         ctx->is_t6xx = gpu_id <= 0x0750; /* For now, this flag means T760 or less */
         ctx->require_sfbd = gpu_id < 0x0750; /* T760 is the first to support MFBD */
@@ -2755,7 +2755,7 @@ panfrost_create_context(struct pipe_screen *screen, void *priv, unsigned flags)
 
         panfrost_resource_context_init(gallium);
 
-        pscreen->driver->init_context(ctx);
+        panfrost_drm_init_context(ctx);
 
         panfrost_setup_hardware(ctx);
 
diff --git a/src/gallium/drivers/panfrost/pan_drm.c b/src/gallium/drivers/panfrost/pan_drm.c
index f4d0721071bb..6be978d36b67 100644
--- a/src/gallium/drivers/panfrost/pan_drm.c
+++ b/src/gallium/drivers/panfrost/pan_drm.c
@@ -39,12 +39,7 @@
 #include "pan_util.h"
 #include "pandecode/decode.h"
 
-struct panfrost_drm {
-	struct panfrost_driver base;
-	int fd;
-};
-
-static void
+void
 panfrost_drm_allocate_slab(struct panfrost_screen *screen,
 		           struct panfrost_memory *mem,
 		           size_t pages,
@@ -53,7 +48,6 @@ panfrost_drm_allocate_slab(struct panfrost_screen *screen,
 		           int commit_count,
 		           int extent)
 {
-	struct panfrost_drm *drm = (struct panfrost_drm *)screen->driver;
 	struct drm_panfrost_create_bo create_bo = {
 		        .size = pages * 4096,
 		        .flags = 0,  // TODO figure out proper flags..
@@ -65,7 +59,7 @@ panfrost_drm_allocate_slab(struct panfrost_screen *screen,
 	// TODO properly handle errors
 	// TODO take into account extra_flags
 
-	ret = drmIoctl(drm->fd, DRM_IOCTL_PANFROST_CREATE_BO, &create_bo);
+	ret = drmIoctl(screen->fd, DRM_IOCTL_PANFROST_CREATE_BO, &create_bo);
 	if (ret) {
                 fprintf(stderr, "DRM_IOCTL_PANFROST_CREATE_BO failed: %d\n", ret);
 		assert(0);
@@ -78,14 +72,14 @@ panfrost_drm_allocate_slab(struct panfrost_screen *screen,
 
 	// TODO map and unmap on demand?
 	mmap_bo.handle = create_bo.handle;
-	ret = drmIoctl(drm->fd, DRM_IOCTL_PANFROST_MMAP_BO, &mmap_bo);
+	ret = drmIoctl(screen->fd, DRM_IOCTL_PANFROST_MMAP_BO, &mmap_bo);
 	if (ret) {
                 fprintf(stderr, "DRM_IOCTL_PANFROST_MMAP_BO failed: %d\n", ret);
 		assert(0);
 	}
 
         mem->cpu = os_mmap(NULL, mem->size, PROT_READ | PROT_WRITE, MAP_SHARED,
-                       drm->fd, mmap_bo.offset);
+                       screen->fd, mmap_bo.offset);
         if (mem->cpu == MAP_FAILED) {
                 fprintf(stderr, "mmap failed: %p\n", mem->cpu);
 		assert(0);
@@ -96,10 +90,9 @@ panfrost_drm_allocate_slab(struct panfrost_screen *screen,
                 pandecode_inject_mmap(mem->gpu, mem->cpu, mem->size, NULL);
 }
 
-static void
+void
 panfrost_drm_free_slab(struct panfrost_screen *screen, struct panfrost_memory *mem)
 {
-	struct panfrost_drm *drm = (struct panfrost_drm *)screen->driver;
 	struct drm_gem_close gem_close = {
 		.handle = mem->gem_handle,
 	};
@@ -112,7 +105,7 @@ panfrost_drm_free_slab(struct panfrost_screen *screen, struct panfrost_memory *m
 
 	mem->cpu = NULL;
 
-	ret = drmIoctl(drm->fd, DRM_IOCTL_GEM_CLOSE, &gem_close);
+	ret = drmIoctl(screen->fd, DRM_IOCTL_GEM_CLOSE, &gem_close);
 	if (ret) {
                 fprintf(stderr, "DRM_IOCTL_GEM_CLOSE failed: %d\n", ret);
 		assert(0);
@@ -121,21 +114,20 @@ panfrost_drm_free_slab(struct panfrost_screen *screen, struct panfrost_memory *m
 	mem->gem_handle = -1;
 }
 
-static struct panfrost_bo *
+struct panfrost_bo *
 panfrost_drm_import_bo(struct panfrost_screen *screen, struct winsys_handle *whandle)
 {
 	struct panfrost_bo *bo = rzalloc(screen, struct panfrost_bo);
-	struct panfrost_drm *drm = (struct panfrost_drm *)screen->driver;
         struct drm_panfrost_get_bo_offset get_bo_offset = {0,};
 	struct drm_panfrost_mmap_bo mmap_bo = {0,};
         int ret;
         unsigned gem_handle;
 
-	ret = drmPrimeFDToHandle(drm->fd, whandle->handle, &gem_handle);
+	ret = drmPrimeFDToHandle(screen->fd, whandle->handle, &gem_handle);
 	assert(!ret);
 
 	get_bo_offset.handle = gem_handle;
-        ret = drmIoctl(drm->fd, DRM_IOCTL_PANFROST_GET_BO_OFFSET, &get_bo_offset);
+        ret = drmIoctl(screen->fd, DRM_IOCTL_PANFROST_GET_BO_OFFSET, &get_bo_offset);
         assert(!ret);
 
 	bo->gem_handle = gem_handle;
@@ -144,7 +136,7 @@ panfrost_drm_import_bo(struct panfrost_screen *screen, struct winsys_handle *wha
 
 	// TODO map and unmap on demand?
 	mmap_bo.handle = gem_handle;
-	ret = drmIoctl(drm->fd, DRM_IOCTL_PANFROST_MMAP_BO, &mmap_bo);
+	ret = drmIoctl(screen->fd, DRM_IOCTL_PANFROST_MMAP_BO, &mmap_bo);
 	if (ret) {
                 fprintf(stderr, "DRM_IOCTL_PANFROST_MMAP_BO failed: %d\n", ret);
 		assert(0);
@@ -153,7 +145,7 @@ panfrost_drm_import_bo(struct panfrost_screen *screen, struct winsys_handle *wha
         bo->size = lseek(whandle->handle, 0, SEEK_END);
         assert(bo->size > 0);
         bo->cpu = os_mmap(NULL, bo->size, PROT_READ | PROT_WRITE, MAP_SHARED,
-                       drm->fd, mmap_bo.offset);
+                       screen->fd, mmap_bo.offset);
         if (bo->cpu == MAP_FAILED) {
                 fprintf(stderr, "mmap failed: %p\n", bo->cpu);
 		assert(0);
@@ -166,16 +158,15 @@ panfrost_drm_import_bo(struct panfrost_screen *screen, struct winsys_handle *wha
         return bo;
 }
 
-static int
+int
 panfrost_drm_export_bo(struct panfrost_screen *screen, int gem_handle, unsigned int stride, struct winsys_handle *whandle)
 {
-	struct panfrost_drm *drm = (struct panfrost_drm *)screen->driver;
         struct drm_prime_handle args = {
                 .handle = gem_handle,
                 .flags = DRM_CLOEXEC,
         };
 
-        int ret = drmIoctl(drm->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &args);
+        int ret = drmIoctl(screen->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &args);
         if (ret == -1)
                 return FALSE;
 
@@ -185,16 +176,15 @@ panfrost_drm_export_bo(struct panfrost_screen *screen, int gem_handle, unsigned
         return TRUE;
 }
 
-static void
+void
 panfrost_drm_free_imported_bo(struct panfrost_screen *screen, struct panfrost_bo *bo) 
 {
-	struct panfrost_drm *drm = (struct panfrost_drm *)screen->driver;
 	struct drm_gem_close gem_close = {
 		.handle = bo->gem_handle,
 	};
 	int ret;
 
-	ret = drmIoctl(drm->fd, DRM_IOCTL_GEM_CLOSE, &gem_close);
+	ret = drmIoctl(screen->fd, DRM_IOCTL_GEM_CLOSE, &gem_close);
 	if (ret) {
                 fprintf(stderr, "DRM_IOCTL_GEM_CLOSE failed: %d\n", ret);
 		assert(0);
@@ -204,12 +194,11 @@ panfrost_drm_free_imported_bo(struct panfrost_screen *screen, struct panfrost_bo
 	bo->gpu = (mali_ptr)NULL;
 }
 
-static int
+int
 panfrost_drm_submit_job(struct panfrost_context *ctx, u64 job_desc, int reqs, struct pipe_surface *surf)
 {
         struct pipe_context *gallium = (struct pipe_context *) ctx;
         struct panfrost_screen *screen = pan_screen(gallium->screen);
-	struct panfrost_drm *drm = (struct panfrost_drm *)screen->driver;
         struct drm_panfrost_submit submit = {0,};
         int bo_handles[7];
 
@@ -239,7 +228,7 @@ panfrost_drm_submit_job(struct panfrost_context *ctx, u64 job_desc, int reqs, st
 	bo_handles[submit.bo_handle_count++] = ctx->tiler_polygon_list.gem_handle;
 	submit.bo_handles = (u64) (uintptr_t) bo_handles;
 
-	if (drmIoctl(drm->fd, DRM_IOCTL_PANFROST_SUBMIT, &submit)) {
+	if (drmIoctl(screen->fd, DRM_IOCTL_PANFROST_SUBMIT, &submit)) {
 	        fprintf(stderr, "Error submitting: %m\n");
 	        return errno;
 	}
@@ -252,7 +241,7 @@ panfrost_drm_submit_job(struct panfrost_context *ctx, u64 job_desc, int reqs, st
 	return 0;
 }
 
-static int
+int
 panfrost_drm_submit_vs_fs_job(struct panfrost_context *ctx, bool has_draws, bool is_scanout)
 {
         struct pipe_surface *surf = ctx->pipe_framebuffer.cbufs[0];
@@ -268,12 +257,11 @@ panfrost_drm_submit_vs_fs_job(struct panfrost_context *ctx, bool has_draws, bool
         return ret;
 }
 
-static struct panfrost_fence *
+struct panfrost_fence *
 panfrost_fence_create(struct panfrost_context *ctx)
 {
         struct pipe_context *gallium = (struct pipe_context *) ctx;
         struct panfrost_screen *screen = pan_screen(gallium->screen);
-	struct panfrost_drm *drm = (struct panfrost_drm *)screen->driver;
         struct panfrost_fence *f = calloc(1, sizeof(*f));
         if (!f)
                 return NULL;
@@ -283,7 +271,7 @@ panfrost_fence_create(struct panfrost_context *ctx)
          * (HandleToFD/FDToHandle just gives you another syncobj ID for the
          * same syncobj).
          */
-        drmSyncobjExportSyncFile(drm->fd, ctx->out_sync, &f->fd);
+        drmSyncobjExportSyncFile(screen->fd, ctx->out_sync, &f->fd);
         if (f->fd == -1) {
                 fprintf(stderr, "export failed\n");
                 free(f);
@@ -295,16 +283,15 @@ panfrost_fence_create(struct panfrost_context *ctx)
         return f;
 }
 
-static void
+void
 panfrost_drm_force_flush_fragment(struct panfrost_context *ctx,
 				  struct pipe_fence_handle **fence)
 {
         struct pipe_context *gallium = (struct pipe_context *) ctx;
         struct panfrost_screen *screen = pan_screen(gallium->screen);
-        struct panfrost_drm *drm = (struct panfrost_drm *)screen->driver;
 
         if (!screen->last_fragment_flushed) {
-		drmSyncobjWait(drm->fd, &ctx->out_sync, 1, INT64_MAX, 0, NULL);
+		drmSyncobjWait(screen->fd, &ctx->out_sync, 1, INT64_MAX, 0, NULL);
                 screen->last_fragment_flushed = true;
 
                 /* The job finished up, so we're safe to clean it up now */
@@ -318,32 +305,30 @@ panfrost_drm_force_flush_fragment(struct panfrost_context *ctx,
         }
 }
 
-static unsigned
+unsigned
 panfrost_drm_query_gpu_version(struct panfrost_screen *screen)
 {
-	struct panfrost_drm *drm = (struct panfrost_drm *)screen->driver;
         struct drm_panfrost_get_param get_param = {0,};
         int ret;
 
 	get_param.param = DRM_PANFROST_PARAM_GPU_PROD_ID;
-        ret = drmIoctl(drm->fd, DRM_IOCTL_PANFROST_GET_PARAM, &get_param);
+        ret = drmIoctl(screen->fd, DRM_IOCTL_PANFROST_GET_PARAM, &get_param);
         assert(!ret);
 
 	return get_param.value;
 }
 
-static int
+int
 panfrost_drm_init_context(struct panfrost_context *ctx)
 {
         struct pipe_context *gallium = (struct pipe_context *) ctx;
         struct panfrost_screen *screen = pan_screen(gallium->screen);
-	struct panfrost_drm *drm = (struct panfrost_drm *)screen->driver;
 
-        return drmSyncobjCreate(drm->fd, DRM_SYNCOBJ_CREATE_SIGNALED,
+        return drmSyncobjCreate(screen->fd, DRM_SYNCOBJ_CREATE_SIGNALED,
                                 &ctx->out_sync);
 }
 
-static void
+void
 panfrost_drm_fence_reference(struct pipe_screen *screen,
                          struct pipe_fence_handle **ptr,
                          struct pipe_fence_handle *fence)
@@ -359,25 +344,24 @@ panfrost_drm_fence_reference(struct pipe_screen *screen,
         *p = f;
 }
 
-static boolean
+boolean
 panfrost_drm_fence_finish(struct pipe_screen *pscreen,
                       struct pipe_context *ctx,
                       struct pipe_fence_handle *fence,
                       uint64_t timeout)
 {
         struct panfrost_screen *screen = pan_screen(pscreen);
-	struct panfrost_drm *drm = (struct panfrost_drm *)screen->driver;
         struct panfrost_fence *f = (struct panfrost_fence *)fence;
         int ret;
 
         unsigned syncobj;
-        ret = drmSyncobjCreate(drm->fd, 0, &syncobj);
+        ret = drmSyncobjCreate(screen->fd, 0, &syncobj);
         if (ret) {
                 fprintf(stderr, "Failed to create syncobj to wait on: %m\n");
                 return false;
         }
 
-        drmSyncobjImportSyncFile(drm->fd, syncobj, f->fd);
+        drmSyncobjImportSyncFile(screen->fd, syncobj, f->fd);
         if (ret) {
                 fprintf(stderr, "Failed to import fence to syncobj: %m\n");
                 return false;
@@ -387,31 +371,9 @@ panfrost_drm_fence_finish(struct pipe_screen *pscreen,
         if (abs_timeout == OS_TIMEOUT_INFINITE)
                 abs_timeout = INT64_MAX;
 
-        ret = drmSyncobjWait(drm->fd, &syncobj, 1, abs_timeout, 0, NULL);
+        ret = drmSyncobjWait(screen->fd, &syncobj, 1, abs_timeout, 0, NULL);
 
-        drmSyncobjDestroy(drm->fd, syncobj);
+        drmSyncobjDestroy(screen->fd, syncobj);
 
         return ret >= 0;
 }
-
-struct panfrost_driver *
-panfrost_create_drm_driver(int fd)
-{
-	struct panfrost_drm *driver = CALLOC_STRUCT(panfrost_drm);
-
-	driver->fd = fd;
-
-	driver->base.import_bo = panfrost_drm_import_bo;
-	driver->base.export_bo = panfrost_drm_export_bo;
-	driver->base.free_imported_bo = panfrost_drm_free_imported_bo;
-	driver->base.submit_vs_fs_job = panfrost_drm_submit_vs_fs_job;
-	driver->base.force_flush_fragment = panfrost_drm_force_flush_fragment;
-	driver->base.allocate_slab = panfrost_drm_allocate_slab;
-	driver->base.free_slab = panfrost_drm_free_slab;
-	driver->base.query_gpu_version = panfrost_drm_query_gpu_version;
-	driver->base.init_context = panfrost_drm_init_context;
-	driver->base.fence_reference = panfrost_drm_fence_reference;
-	driver->base.fence_finish = panfrost_drm_fence_finish;
-
-        return &driver->base;
-}
diff --git a/src/gallium/drivers/panfrost/pan_job.c b/src/gallium/drivers/panfrost/pan_job.c
index 96f05c663540..1931ddf774ea 100644
--- a/src/gallium/drivers/panfrost/pan_job.c
+++ b/src/gallium/drivers/panfrost/pan_job.c
@@ -155,7 +155,7 @@ panfrost_job_submit(struct panfrost_context *ctx, struct panfrost_job *job)
         if (!job)
                 return;
 
-        ret = screen->driver->submit_vs_fs_job(ctx, has_draws, is_scanout);
+        ret = panfrost_drm_submit_vs_fs_job(ctx, has_draws, is_scanout);
 
         if (ret)
                 fprintf(stderr, "panfrost_job_submit failed: %d\n", ret);
diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c
index 332208d4e2fe..5c0130ca8678 100644
--- a/src/gallium/drivers/panfrost/pan_resource.c
+++ b/src/gallium/drivers/panfrost/pan_resource.c
@@ -69,7 +69,7 @@ panfrost_resource_from_handle(struct pipe_screen *pscreen,
         pipe_reference_init(&prsc->reference, 1);
         prsc->screen = pscreen;
 
-	rsc->bo = screen->driver->import_bo(screen, whandle);
+	rsc->bo = panfrost_drm_import_bo(screen, whandle);
 	rsc->bo->slices[0].stride = whandle->stride;
 
 	if (screen->ro) {
@@ -119,7 +119,9 @@ panfrost_resource_get_handle(struct pipe_screen *pscreen,
 
                         return TRUE;
                 } else
-			return screen->driver->export_bo(screen, rsrc->bo->gem_handle, rsrc->bo->slices[0].stride, handle);
+			return panfrost_drm_export_bo(screen, rsrc->bo->gem_handle,
+                                                      rsrc->bo->slices[0].stride,
+                                                      handle);
 	}
 
 	return FALSE;
@@ -299,7 +301,7 @@ panfrost_create_bo(struct panfrost_screen *screen, const struct pipe_resource *t
         if (bo->layout == PAN_TILED || bo->layout == PAN_LINEAR) {
                 struct panfrost_memory mem;
 
-                screen->driver->allocate_slab(screen, &mem, bo->size / 4096, true, 0, 0, 0);
+                panfrost_drm_allocate_slab(screen, &mem, bo->size / 4096, true, 0, 0, 0);
 
                 bo->cpu = mem.cpu;
                 bo->gpu = mem.gpu;
@@ -380,7 +382,7 @@ panfrost_destroy_bo(struct panfrost_screen *screen, struct panfrost_bo *bo)
                         .gem_handle = bo->gem_handle,
                 };
 
-                screen->driver->free_slab(screen, &mem);
+                panfrost_drm_free_slab(screen, &mem);
         }
 
         if (bo->layout == PAN_AFBC) {
@@ -396,11 +398,11 @@ panfrost_destroy_bo(struct panfrost_screen *screen, struct panfrost_bo *bo)
                         .gem_handle = bo->checksum_slab.gem_handle,
                 };
 
-                screen->driver->free_slab(screen, &mem);
+                panfrost_drm_free_slab(screen, &mem);
         }
 
         if (bo->imported) {
-                screen->driver->free_imported_bo(screen, bo);
+                panfrost_drm_free_imported_bo(screen, bo);
         }
 
         ralloc_free(bo);
@@ -623,7 +625,7 @@ panfrost_slab_alloc(void *priv, unsigned heap, unsigned entry_size, unsigned gro
         /* Actually allocate the memory from kernel-space. Mapped, same_va, no
          * special flags */
 
-        screen->driver->allocate_slab(screen, mem, slab_size / 4096, true, 0, 0, 0);
+        panfrost_drm_allocate_slab(screen, mem, slab_size / 4096, true, 0, 0, 0);
 
         return &mem->slab;
 }
@@ -641,7 +643,7 @@ panfrost_slab_free(void *priv, struct pb_slab *slab)
         struct panfrost_memory *mem = (struct panfrost_memory *) slab;
         struct panfrost_screen *screen = (struct panfrost_screen *) priv;
 
-        screen->driver->free_slab(screen, mem);
+        panfrost_drm_free_slab(screen, mem);
         ralloc_free(mem);
 }
 
diff --git a/src/gallium/drivers/panfrost/pan_screen.c b/src/gallium/drivers/panfrost/pan_screen.c
index 8d43e0d9f4ca..dccb0143a536 100644
--- a/src/gallium/drivers/panfrost/pan_screen.c
+++ b/src/gallium/drivers/panfrost/pan_screen.c
@@ -540,8 +540,7 @@ panfrost_fence_reference(struct pipe_screen *pscreen,
                          struct pipe_fence_handle **ptr,
                          struct pipe_fence_handle *fence)
 {
-        struct panfrost_screen *screen = pan_screen(pscreen);
-        screen->driver->fence_reference(pscreen, ptr, fence);
+        panfrost_drm_fence_reference(pscreen, ptr, fence);
 }
 
 static boolean
@@ -550,8 +549,7 @@ panfrost_fence_finish(struct pipe_screen *pscreen,
                       struct pipe_fence_handle *fence,
                       uint64_t timeout)
 {
-        struct panfrost_screen *screen = pan_screen(pscreen);
-        return screen->driver->fence_finish(pscreen, ctx, fence, timeout);
+        return panfrost_drm_fence_finish(pscreen, ctx, fence, timeout);
 }
 
 static const void *
@@ -581,7 +579,7 @@ panfrost_create_screen(int fd, struct renderonly *ro)
                 }
         }
 
-        screen->driver = panfrost_create_drm_driver(fd);
+        screen->fd = fd;
 
         if (pan_debug & PAN_DBG_TRACE)
                 pandecode_initialize();
diff --git a/src/gallium/drivers/panfrost/pan_screen.h b/src/gallium/drivers/panfrost/pan_screen.h
index c7504f3221d4..4907bd4395fd 100644
--- a/src/gallium/drivers/panfrost/pan_screen.h
+++ b/src/gallium/drivers/panfrost/pan_screen.h
@@ -46,40 +46,11 @@ struct panfrost_screen;
 #define PAN_ALLOCATE_INVISIBLE (1 << 2)
 #define PAN_ALLOCATE_COHERENT_LOCAL (1 << 3)
 
-struct panfrost_driver {
-	struct panfrost_bo * (*import_bo) (struct panfrost_screen *screen, struct winsys_handle *whandle);
-	int (*export_bo) (struct panfrost_screen *screen, int gem_handle, unsigned int stride, struct winsys_handle *whandle);
-
-	int (*submit_vs_fs_job) (struct panfrost_context *ctx, bool has_draws, bool is_scanout);
-	void (*force_flush_fragment) (struct panfrost_context *ctx,
-				      struct pipe_fence_handle **fence);
-	void (*allocate_slab) (struct panfrost_screen *screen,
-		               struct panfrost_memory *mem,
-		               size_t pages,
-		               bool same_va,
-		               int extra_flags,
-		               int commit_count,
-		               int extent);
-        void (*free_slab) (struct panfrost_screen *screen,
-                           struct panfrost_memory *mem);
-        void (*free_imported_bo) (struct panfrost_screen *screen,
-                             struct panfrost_bo *bo);
-	unsigned (*query_gpu_version) (struct panfrost_screen *screen);
-	int (*init_context) (struct panfrost_context *ctx);
-	void (*fence_reference) (struct pipe_screen *screen,
-                         struct pipe_fence_handle **ptr,
-                         struct pipe_fence_handle *fence);
-	boolean (*fence_finish) (struct pipe_screen *screen,
-                      struct pipe_context *ctx,
-                      struct pipe_fence_handle *fence,
-                      uint64_t timeout);
-};
-
 struct panfrost_screen {
         struct pipe_screen base;
+        int fd;
 
         struct renderonly *ro;
-        struct panfrost_driver *driver;
 
         /* Memory management is based on subdividing slabs with AMD's allocator */
         struct pb_slabs slabs;
@@ -100,4 +71,49 @@ pan_screen(struct pipe_screen *p)
    return (struct panfrost_screen *)p;
 }
 
+void
+panfrost_drm_allocate_slab(struct panfrost_screen *screen,
+                           struct panfrost_memory *mem,
+                           size_t pages,
+                           bool same_va,
+                           int extra_flags,
+                           int commit_count,
+                           int extent);
+void
+panfrost_drm_free_slab(struct panfrost_screen *screen,
+                       struct panfrost_memory *mem);
+struct panfrost_bo *
+panfrost_drm_import_bo(struct panfrost_screen *screen,
+                       struct winsys_handle *whandle);
+int
+panfrost_drm_export_bo(struct panfrost_screen *screen, int gem_handle,
+                       unsigned int stride, struct winsys_handle *whandle);
+void
+panfrost_drm_free_imported_bo(struct panfrost_screen *screen,
+                              struct panfrost_bo *bo);
+int
+panfrost_drm_submit_job(struct panfrost_context *ctx, u64 job_desc, int reqs,
+                        struct pipe_surface *surf);
+int
+panfrost_drm_submit_vs_fs_job(struct panfrost_context *ctx, bool has_draws,
+                              bool is_scanout);
+struct panfrost_fence *
+panfrost_fence_create(struct panfrost_context *ctx);
+void
+panfrost_drm_force_flush_fragment(struct panfrost_context *ctx,
+                                  struct pipe_fence_handle **fence);
+unsigned
+panfrost_drm_query_gpu_version(struct panfrost_screen *screen);
+int
+panfrost_drm_init_context(struct panfrost_context *ctx);
+void
+panfrost_drm_fence_reference(struct pipe_screen *screen,
+                             struct pipe_fence_handle **ptr,
+                             struct pipe_fence_handle *fence);
+boolean
+panfrost_drm_fence_finish(struct pipe_screen *pscreen,
+                          struct pipe_context *ctx,
+                          struct pipe_fence_handle *fence,
+                          uint64_t timeout);
+
 #endif /* PAN_SCREEN_H */
-- 
2.20.1



More information about the mesa-dev mailing list