Because of the alternative definition of the 'pages' field in shmem after adding
support for sparse allocations, the logic for deciding whether pages are
available must be expanded.

Signed-off-by: Adrián Larumbe <adrian.laru...@collabora.com>
---
 drivers/gpu/drm/panfrost/panfrost_gem.c | 4 +++-
 drivers/gpu/drm/panthor/panthor_gem.c   | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.c 
b/drivers/gpu/drm/panfrost/panfrost_gem.c
index 0cda2c4e524f..ced2fdee74ab 100644
--- a/drivers/gpu/drm/panfrost/panfrost_gem.c
+++ b/drivers/gpu/drm/panfrost/panfrost_gem.c
@@ -200,7 +200,9 @@ static enum drm_gem_object_status 
panfrost_gem_status(struct drm_gem_object *obj
        struct panfrost_gem_object *bo = to_panfrost_bo(obj);
        enum drm_gem_object_status res = 0;
 
-       if (bo->base.base.import_attach || bo->base.pages)
+       if (bo->base.base.import_attach ||
+           (!bo->base.sparse && bo->base.pages) ||
+           (bo->base.sparse && !xa_empty(&bo->base.xapages)))
                res |= DRM_GEM_OBJECT_RESIDENT;
 
        if (bo->base.madv == PANFROST_MADV_DONTNEED)
diff --git a/drivers/gpu/drm/panthor/panthor_gem.c 
b/drivers/gpu/drm/panthor/panthor_gem.c
index 8244a4e6c2a2..8dbaf766bd79 100644
--- a/drivers/gpu/drm/panthor/panthor_gem.c
+++ b/drivers/gpu/drm/panthor/panthor_gem.c
@@ -155,7 +155,9 @@ static enum drm_gem_object_status panthor_gem_status(struct 
drm_gem_object *obj)
        struct panthor_gem_object *bo = to_panthor_bo(obj);
        enum drm_gem_object_status res = 0;
 
-       if (bo->base.base.import_attach || bo->base.pages)
+       if (bo->base.base.import_attach ||
+           (!bo->base.sparse && bo->base.pages) ||
+           (bo->base.sparse && !xa_empty(&bo->base.xapages)))
                res |= DRM_GEM_OBJECT_RESIDENT;
 
        return res;
-- 
2.47.1

Reply via email to