pan/kmod: Add priority query uapi support

This adds support for the new DEV_QUERY_GROUP_PRIORITIES_INFO query from
panthor to report and will be used to report appropriate priority mask
in the Gallium driver.

Signed-off-by: Mary Guillemard <mary.guillemard@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30991>
This commit is contained in:
Mary Guillemard
2024-09-04 11:54:27 +02:00
committed by Marge Bot
parent c0b55da825
commit 83bc9bb1af
2 changed files with 63 additions and 0 deletions

View File

@@ -97,6 +97,21 @@ enum pan_kmod_bo_flags {
PAN_KMOD_BO_FLAG_GPU_UNCACHED = BITFIELD_BIT(5),
};
/* Allowed group priority flags. */
enum pan_kmod_group_allow_priority_flags {
/* Allow low priority group. */
PAN_KMOD_GROUP_ALLOW_PRIORITY_LOW = BITFIELD_BIT(0),
/* Allow medium priority group. */
PAN_KMOD_GROUP_ALLOW_PRIORITY_MEDIUM = BITFIELD_BIT(1),
/* Allow high priority group. */
PAN_KMOD_GROUP_ALLOW_PRIORITY_HIGH = BITFIELD_BIT(2),
/* Allow realtime priority group. */
PAN_KMOD_GROUP_ALLOW_PRIORITY_REALTIME = BITFIELD_BIT(3),
};
/* Buffer object. */
struct pan_kmod_bo {
/* Atomic reference count. The only reason we need to refcnt BOs at this
@@ -185,6 +200,9 @@ struct pan_kmod_dev_props {
/* GPU Timestamp frequency */
uint64_t timestamp_frequency;
/* A mask of flags containing the allowed group priorities. */
enum pan_kmod_group_allow_priority_flags allowed_group_priorities_mask;
};
/* Memory allocator for kmod internal allocations. */

View File

@@ -81,6 +81,7 @@ struct panthor_kmod_dev {
struct drm_panthor_gpu_info gpu;
struct drm_panthor_csif_info csif;
struct drm_panthor_timestamp_info timestamp;
struct drm_panthor_group_priorities_info group_priorities;
} props;
};
@@ -156,6 +157,27 @@ panthor_kmod_dev_create(int fd, uint32_t flags, drmVersionPtr version,
goto err_free_dev;
}
if (version->version_major > 1 || version->version_minor >= 2) {
query = (struct drm_panthor_dev_query){
.type = DRM_PANTHOR_DEV_QUERY_GROUP_PRIORITIES_INFO,
.size = sizeof(panthor_dev->props.group_priorities),
.pointer = (uint64_t)(uintptr_t)&panthor_dev->props.group_priorities,
};
ret = drmIoctl(fd, DRM_IOCTL_PANTHOR_DEV_QUERY, &query);
if (ret) {
mesa_loge("DRM_IOCTL_PANTHOR_DEV_QUERY failed (err=%d)", errno);
goto err_free_dev;
}
} else {
/* If the query isn't available, Panthor always allow LOW and MEDIUM
* priority */
panthor_dev->props.group_priorities.allowed_mask |=
BITFIELD_BIT(PANTHOR_GROUP_PRIORITY_MEDIUM);
panthor_dev->props.group_priorities.allowed_mask |=
BITFIELD_BIT(PANTHOR_GROUP_PRIORITY_LOW);
}
assert(!ret);
pan_kmod_dev_init(&panthor_dev->base, fd, flags, version, &panthor_kmod_ops,
allocator);
@@ -177,6 +199,26 @@ panthor_kmod_dev_destroy(struct pan_kmod_dev *dev)
pan_kmod_free(dev->allocator, panthor_dev);
}
static uint32_t
to_kmod_group_allow_priority_flags(uint32_t panthor_flags)
{
uint32_t kmod_flags = 0;
if (panthor_flags & BITFIELD_BIT(PANTHOR_GROUP_PRIORITY_REALTIME))
kmod_flags |= PAN_KMOD_GROUP_ALLOW_PRIORITY_REALTIME;
if (panthor_flags & BITFIELD_BIT(PANTHOR_GROUP_PRIORITY_HIGH))
kmod_flags |= PAN_KMOD_GROUP_ALLOW_PRIORITY_HIGH;
if (panthor_flags & BITFIELD_BIT(PANTHOR_GROUP_PRIORITY_MEDIUM))
kmod_flags |= PAN_KMOD_GROUP_ALLOW_PRIORITY_MEDIUM;
if (panthor_flags & BITFIELD_BIT(PANTHOR_GROUP_PRIORITY_LOW))
kmod_flags |= PAN_KMOD_GROUP_ALLOW_PRIORITY_LOW;
return kmod_flags;
}
static void
panthor_dev_query_thread_props(const struct panthor_kmod_dev *panthor_dev,
struct pan_kmod_dev_props *props)
@@ -223,6 +265,9 @@ panthor_dev_query_props(const struct pan_kmod_dev *dev,
.gpu_can_query_timestamp = true,
.timestamp_frequency = panthor_dev->props.timestamp.timestamp_frequency,
.allowed_group_priorities_mask = to_kmod_group_allow_priority_flags(
panthor_dev->props.group_priorities.allowed_mask),
};
static_assert(sizeof(props->texture_features) ==