From cd8b8baf6ea33985240075744435bb3b4b05b433 Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Thu, 24 Jul 2025 20:29:12 +0000 Subject: [PATCH] pan/kmod: Expose the BO flags supported by a pan_kmod_device Will be needed to let the frontend know if it can use cached CPU-mappings, and it allows us to extend the set of supported flags without introducing a new field if we ever have to. Reviewed-by: Boris Brezillon Reviewed-by: Christoph Pillmayer Part-of: --- src/panfrost/lib/kmod/pan_kmod.h | 10 ++++++++++ src/panfrost/lib/kmod/panfrost_kmod.c | 11 +++++++++++ src/panfrost/lib/kmod/panthor_kmod.c | 15 +++++++++++++-- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/panfrost/lib/kmod/pan_kmod.h b/src/panfrost/lib/kmod/pan_kmod.h index 4149086f402..d136fdd0d8f 100644 --- a/src/panfrost/lib/kmod/pan_kmod.h +++ b/src/panfrost/lib/kmod/pan_kmod.h @@ -102,6 +102,13 @@ enum pan_kmod_bo_flags { * is called. */ PAN_KMOD_BO_FLAG_GPU_UNCACHED = BITFIELD_BIT(5), + + /* CPU map the buffer object in userspace by forcing the "Write-Back + * Cacheable" cacheability attribute. The mapping otherwise uses the + * "Non-Cacheable" attribute if the ACE-Lite coherency protocol isn't + * supported by the GPU. + */ + PAN_KMOD_BO_FLAG_WB_MMAP = BITFIELD_BIT(6), }; /* Allowed group priority flags. */ @@ -213,6 +220,9 @@ struct pan_kmod_dev_props { /* A mask of flags containing the allowed group priorities. */ enum pan_kmod_group_allow_priority_flags allowed_group_priorities_mask; + + /* Mask of BO flags supported by the KMD. */ + uint32_t supported_bo_flags; }; /* Memory allocator for kmod internal allocations. */ diff --git a/src/panfrost/lib/kmod/panfrost_kmod.c b/src/panfrost/lib/kmod/panfrost_kmod.c index f3cc6da4b8f..7d554b679ae 100644 --- a/src/panfrost/lib/kmod/panfrost_kmod.c +++ b/src/panfrost/lib/kmod/panfrost_kmod.c @@ -197,6 +197,12 @@ panfrost_dev_query_props(struct panfrost_kmod_dev *panfrost_dev) if (prios & BITFIELD_BIT(PANFROST_JM_CTX_PRIORITY_HIGH)) props->allowed_group_priorities_mask |= PAN_KMOD_GROUP_ALLOW_PRIORITY_HIGH; + + props->supported_bo_flags = PAN_KMOD_BO_FLAG_EXECUTABLE | + PAN_KMOD_BO_FLAG_ALLOC_ON_FAULT | + PAN_KMOD_BO_FLAG_NO_MMAP; + if (pan_kmod_driver_version_at_least(&dev->driver, 1, 6)) + props->supported_bo_flags |= PAN_KMOD_BO_FLAG_WB_MMAP; } static struct pan_kmod_dev * @@ -250,6 +256,11 @@ to_panfrost_bo_flags(struct pan_kmod_dev *dev, uint32_t flags) panfrost_flags |= PANFROST_BO_NOEXEC; } + if (flags & PAN_KMOD_BO_FLAG_WB_MMAP) { + assert(!(flags & PAN_KMOD_BO_FLAG_NO_MMAP)); + panfrost_flags |= PANFROST_BO_WB_MMAP; + } + return panfrost_flags; } diff --git a/src/panfrost/lib/kmod/panthor_kmod.c b/src/panfrost/lib/kmod/panthor_kmod.c index 6fbf8d8bfd2..3d9253c2f57 100644 --- a/src/panfrost/lib/kmod/panthor_kmod.c +++ b/src/panfrost/lib/kmod/panthor_kmod.c @@ -171,12 +171,18 @@ panthor_dev_query_props(struct panthor_kmod_dev *panthor_dev) .allowed_group_priorities_mask = to_kmod_group_allow_priority_flags( panthor_dev->props.group_priorities.allowed_mask), + + .supported_bo_flags = PAN_KMOD_BO_FLAG_EXECUTABLE | + PAN_KMOD_BO_FLAG_NO_MMAP | + PAN_KMOD_BO_FLAG_GPU_UNCACHED, }; - if (panthor_dev->base.driver.version.major > 1 || - panthor_dev->base.driver.version.minor >= 6) + if (pan_kmod_driver_version_at_least(&panthor_dev->base.driver, 1, 6)) props->timestamp_device_coherent = true; + if (pan_kmod_driver_version_at_least(&panthor_dev->base.driver, 1, 7)) + props->supported_bo_flags |= PAN_KMOD_BO_FLAG_WB_MMAP; + static_assert(sizeof(props->texture_features) == sizeof(panthor_dev->props.gpu.texture_features), "Mismatch in texture_features array size"); @@ -333,6 +339,11 @@ to_panthor_bo_flags(uint32_t flags) if (flags & PAN_KMOD_BO_FLAG_NO_MMAP) panthor_flags |= DRM_PANTHOR_BO_NO_MMAP; + if (flags & PAN_KMOD_BO_FLAG_WB_MMAP) { + assert(!(flags & PAN_KMOD_BO_FLAG_NO_MMAP)); + panthor_flags |= DRM_PANTHOR_BO_WB_MMAP; + } + return panthor_flags; }