Mesa (master): Revert "panfrost: Keep cached BOs mmap'd"

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Jun 6 07:04:28 UTC 2020


Module: Mesa
Branch: master
Commit: a61532e4dbdf4fbbf5822daeb5907efaf584a375
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a61532e4dbdf4fbbf5822daeb5907efaf584a375

Author: Icecream95 <ixn at keemail.me>
Date:   Fri Jun  5 16:52:23 2020 +1200

Revert "panfrost: Keep cached BOs mmap'd"

This reverts commit 794c239a990e08b5a42d42607e9c5e5b0921390c.

A kernel bug causes cached BOs to not be unmapped correctly,
triggering "bad page cache" kernel messages and causing short hangs.

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5355>

---

 src/panfrost/encoder/pan_bo.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/src/panfrost/encoder/pan_bo.c b/src/panfrost/encoder/pan_bo.c
index a663d35d5b8..32fc84e1363 100644
--- a/src/panfrost/encoder/pan_bo.c
+++ b/src/panfrost/encoder/pan_bo.c
@@ -90,11 +90,6 @@ panfrost_bo_free(struct panfrost_bo *bo)
         struct drm_gem_close gem_close = { .handle = bo->gem_handle };
         int ret;
 
-        if (bo->cpu && os_munmap((void *) (uintptr_t)bo->cpu, bo->size)) {
-                perror("munmap");
-                abort();
-        }
-
         ret = drmIoctl(bo->dev->fd, DRM_IOCTL_GEM_CLOSE, &gem_close);
         if (ret) {
                 fprintf(stderr, "DRM_IOCTL_GEM_CLOSE failed: %m\n");
@@ -349,6 +344,20 @@ panfrost_bo_mmap(struct panfrost_bo *bo)
         }
 }
 
+static void
+panfrost_bo_munmap(struct panfrost_bo *bo)
+{
+        if (!bo->cpu)
+                return;
+
+        if (os_munmap((void *) (uintptr_t)bo->cpu, bo->size)) {
+                perror("munmap");
+                abort();
+        }
+
+        bo->cpu = NULL;
+}
+
 struct panfrost_bo *
 panfrost_bo_create(struct panfrost_device *dev, size_t size,
                    uint32_t flags)
@@ -427,6 +436,9 @@ panfrost_bo_unreference(struct panfrost_bo *bo)
         if (p_atomic_read(&bo->refcnt) == 0) {
                 _mesa_set_remove_key(bo->dev->active_bos, bo);
 
+                /* When the reference count goes to zero, we need to cleanup */
+                panfrost_bo_munmap(bo);
+
                 /* Rather than freeing the BO now, we'll cache the BO for later
                  * allocations if we're allowed to.
                  */



More information about the mesa-commit mailing list