[03/10] panfrost: Get rid of the "free imported BO" logic

Submitted by Boris Brezillon on July 2, 2019, 1:23 p.m.

Details

Message ID 20190702132353.21049-4-boris.brezillon@collabora.com
State New
Headers show
Series "panfrost: Try to make BO handling more consistent" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Boris Brezillon July 2, 2019, 1:23 p.m.
bo->imported was never set to true which means this path was never taken.
Moreover, panfrost_drm_free_imported_bo() is doing missing the munmap()
call which seems wrong because the import BO function calls mmap().

Let's just kill this function along with the ->imported field.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
---
 src/gallium/drivers/panfrost/pan_drm.c      | 18 ------------------
 src/gallium/drivers/panfrost/pan_resource.c | 19 +++++++------------
 src/gallium/drivers/panfrost/pan_resource.h |  3 ---
 src/gallium/drivers/panfrost/pan_screen.h   |  3 ---
 4 files changed, 7 insertions(+), 36 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/gallium/drivers/panfrost/pan_drm.c b/src/gallium/drivers/panfrost/pan_drm.c
index 3d25eda9667e..8c9a0612d7ed 100644
--- a/src/gallium/drivers/panfrost/pan_drm.c
+++ b/src/gallium/drivers/panfrost/pan_drm.c
@@ -175,24 +175,6 @@  panfrost_drm_export_bo(struct panfrost_screen *screen, int gem_handle, unsigned
         return TRUE;
 }
 
-void
-panfrost_drm_free_imported_bo(struct panfrost_screen *screen, struct panfrost_bo *bo) 
-{
-	struct drm_gem_close gem_close = {
-		.handle = bo->gem_handle,
-	};
-	int ret;
-
-	ret = drmIoctl(screen->fd, DRM_IOCTL_GEM_CLOSE, &gem_close);
-	if (ret) {
-                fprintf(stderr, "DRM_IOCTL_GEM_CLOSE failed: %d\n", ret);
-		assert(0);
-	}
-
-	bo->gem_handle = -1;
-	bo->gpu = (mali_ptr)NULL;
-}
-
 int
 panfrost_drm_submit_job(struct panfrost_context *ctx, u64 job_desc, int reqs, struct pipe_surface *surf)
 {
diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c
index fae535ed4e29..680b98a6cac3 100644
--- a/src/gallium/drivers/panfrost/pan_resource.c
+++ b/src/gallium/drivers/panfrost/pan_resource.c
@@ -435,19 +435,14 @@  panfrost_resource_create(struct pipe_screen *screen,
 static void
 panfrost_destroy_bo(struct panfrost_screen *screen, struct panfrost_bo *bo)
 {
-        if (bo->imported) {
-                panfrost_drm_free_imported_bo(screen, bo);
-        } else {
-                struct panfrost_memory mem = {
-                        .cpu = bo->cpu,
-                        .gpu = bo->gpu,
-                        .size = bo->size,
-                        .gem_handle = bo->gem_handle,
-                };
-
-                panfrost_drm_free_slab(screen, &mem);
-        }
+        struct panfrost_memory mem = {
+                .cpu = bo->cpu,
+                .gpu = bo->gpu,
+                .size = bo->size,
+                .gem_handle = bo->gem_handle,
+        };
 
+        panfrost_drm_free_slab(screen, &mem);
         ralloc_free(bo);
 }
 
diff --git a/src/gallium/drivers/panfrost/pan_resource.h b/src/gallium/drivers/panfrost/pan_resource.h
index 89a4396c0939..003211b8c4a7 100644
--- a/src/gallium/drivers/panfrost/pan_resource.h
+++ b/src/gallium/drivers/panfrost/pan_resource.h
@@ -75,9 +75,6 @@  struct panfrost_bo {
         /* Distance from tree to tree */
         unsigned cubemap_stride;
 
-        /* Set if this bo was imported rather than allocated */
-        bool imported;
-
         /* Internal layout (tiled?) */
         enum panfrost_memory_layout layout;
 
diff --git a/src/gallium/drivers/panfrost/pan_screen.h b/src/gallium/drivers/panfrost/pan_screen.h
index 22565d6b653b..ebc5fee5cfd6 100644
--- a/src/gallium/drivers/panfrost/pan_screen.h
+++ b/src/gallium/drivers/panfrost/pan_screen.h
@@ -88,9 +88,6 @@  panfrost_drm_import_bo(struct panfrost_screen *screen,
 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);