mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-23 23:48:18 +02:00
pan/kmod: Don't pass drmVersionPtr objects around
Stop passing drmVersionPtr to backends and make sure all manual version checks are transitioned to pan_kmod_driver_version_at_least() to encourage new checks to do the same. Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> Reviewed-by: Christoph Pillmayer <christoph.pillmayer@arm.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41704>
This commit is contained in:
parent
2c0caee6db
commit
8b4ea1d658
5 changed files with 35 additions and 26 deletions
|
|
@ -60,11 +60,19 @@ pan_kmod_dev_create(int fd, uint32_t flags,
|
|||
if (!allocator)
|
||||
allocator = &default_allocator;
|
||||
|
||||
const char *drv_name = version->name;
|
||||
const struct pan_kmod_driver drv_info = {
|
||||
.version = {
|
||||
.major = version->version_major,
|
||||
.minor = version->version_minor,
|
||||
},
|
||||
};
|
||||
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(drivers); i++) {
|
||||
if (!strcmp(drivers[i].name, version->name)) {
|
||||
if (!strcmp(drivers[i].name, drv_name)) {
|
||||
const struct pan_kmod_ops *ops = drivers[i].ops;
|
||||
|
||||
dev = ops->dev_create(fd, flags, version, allocator);
|
||||
dev = ops->dev_create(fd, flags, &drv_info, allocator);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -384,6 +384,15 @@ struct pan_kmod_va_range {
|
|||
uint64_t size;
|
||||
};
|
||||
|
||||
/* KMD information. */
|
||||
struct pan_kmod_driver {
|
||||
/* KMD version. */
|
||||
struct {
|
||||
uint32_t major;
|
||||
uint32_t minor;
|
||||
} version;
|
||||
};
|
||||
|
||||
/* KMD backend vtable.
|
||||
*
|
||||
* All methods described there are mandatory, unless explicitly flagged as
|
||||
|
|
@ -394,7 +403,7 @@ struct pan_kmod_ops {
|
|||
* Return NULL if the creation fails for any reason.
|
||||
*/
|
||||
struct pan_kmod_dev *(*dev_create)(
|
||||
int fd, uint32_t flags, const drmVersionPtr version,
|
||||
int fd, uint32_t flags, const struct pan_kmod_driver *drv_info,
|
||||
const struct pan_kmod_allocator *allocator);
|
||||
|
||||
/* Destroy a pan_kmod_dev object. */
|
||||
|
|
@ -476,15 +485,6 @@ struct pan_kmod_ops {
|
|||
void (*bo_set_label)(struct pan_kmod_dev *dev, struct pan_kmod_bo *bo, const char *label);
|
||||
};
|
||||
|
||||
/* KMD information. */
|
||||
struct pan_kmod_driver {
|
||||
/* KMD version. */
|
||||
struct {
|
||||
uint32_t major;
|
||||
uint32_t minor;
|
||||
} version;
|
||||
};
|
||||
|
||||
static inline bool
|
||||
pan_kmod_driver_version_at_least(const struct pan_kmod_driver *driver,
|
||||
uint32_t major, uint32_t minor)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@
|
|||
|
||||
static inline void
|
||||
pan_kmod_dev_init(struct pan_kmod_dev *dev, int fd, uint32_t flags,
|
||||
drmVersionPtr version, const struct pan_kmod_ops *ops,
|
||||
const struct pan_kmod_driver *drv_info,
|
||||
const struct pan_kmod_ops *ops,
|
||||
const struct pan_kmod_allocator *allocator)
|
||||
{
|
||||
simple_mtx_init(&dev->handle_to_bo.lock, mtx_plain);
|
||||
|
|
@ -19,8 +20,7 @@ pan_kmod_dev_init(struct pan_kmod_dev *dev, int fd, uint32_t flags,
|
|||
sizeof(struct pan_kmod_bo *), 512);
|
||||
simple_mtx_init(&dev->pending_bo_syncs.lock, mtx_plain);
|
||||
util_dynarray_init(&dev->pending_bo_syncs.array, NULL);
|
||||
dev->driver.version.major = version->version_major;
|
||||
dev->driver.version.minor = version->version_minor;
|
||||
dev->driver = *drv_info;
|
||||
dev->fd = fd;
|
||||
dev->flags = flags;
|
||||
dev->ops = ops;
|
||||
|
|
|
|||
|
|
@ -214,13 +214,13 @@ panfrost_dev_query_props(struct panfrost_kmod_dev *panfrost_dev)
|
|||
}
|
||||
|
||||
static struct pan_kmod_dev *
|
||||
panfrost_kmod_dev_create(int fd, uint32_t flags, drmVersionPtr version,
|
||||
panfrost_kmod_dev_create(int fd, uint32_t flags,
|
||||
const struct pan_kmod_driver *drv_info,
|
||||
const struct pan_kmod_allocator *allocator)
|
||||
{
|
||||
if (version->version_major < 1 ||
|
||||
(version->version_major == 1 && version->version_minor < 1)) {
|
||||
if (!pan_kmod_driver_version_at_least(drv_info, 1, 1)) {
|
||||
mesa_loge("kernel driver is too old (requires at least 1.1, found %d.%d)",
|
||||
version->version_major, version->version_minor);
|
||||
drv_info->version.major, drv_info->version.minor);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -231,7 +231,7 @@ panfrost_kmod_dev_create(int fd, uint32_t flags, drmVersionPtr version,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
pan_kmod_dev_init(&panfrost_dev->base, fd, flags, version,
|
||||
pan_kmod_dev_init(&panfrost_dev->base, fd, flags, drv_info,
|
||||
&panfrost_kmod_ops, allocator);
|
||||
panfrost_dev_query_props(panfrost_dev);
|
||||
|
||||
|
|
|
|||
|
|
@ -197,7 +197,8 @@ panthor_dev_query_props(struct panthor_kmod_dev *panthor_dev)
|
|||
}
|
||||
|
||||
static struct pan_kmod_dev *
|
||||
panthor_kmod_dev_create(int fd, uint32_t flags, drmVersionPtr version,
|
||||
panthor_kmod_dev_create(int fd, uint32_t flags,
|
||||
const struct pan_kmod_driver *drv_info,
|
||||
const struct pan_kmod_allocator *allocator)
|
||||
{
|
||||
struct panthor_kmod_dev *panthor_dev =
|
||||
|
|
@ -232,7 +233,7 @@ panthor_kmod_dev_create(int fd, uint32_t flags, drmVersionPtr version,
|
|||
goto err_free_dev;
|
||||
}
|
||||
|
||||
if (version->version_major > 1 || version->version_minor >= 1) {
|
||||
if (pan_kmod_driver_version_at_least(drv_info, 1, 1)) {
|
||||
query = (struct drm_panthor_dev_query){
|
||||
.type = DRM_PANTHOR_DEV_QUERY_TIMESTAMP_INFO,
|
||||
.size = sizeof(panthor_dev->props.timestamp),
|
||||
|
|
@ -247,7 +248,7 @@ panthor_kmod_dev_create(int fd, uint32_t flags, drmVersionPtr version,
|
|||
}
|
||||
|
||||
/* Map the LATEST_FLUSH_ID register at device creation time. */
|
||||
if (version->version_major > 1 || version->version_minor >= 5) {
|
||||
if (pan_kmod_driver_version_at_least(drv_info, 1, 5)) {
|
||||
struct drm_panthor_set_user_mmio_offset user_mmio_offset = {
|
||||
.offset = DRM_PANTHOR_USER_MMIO_OFFSET,
|
||||
};
|
||||
|
|
@ -266,7 +267,7 @@ panthor_kmod_dev_create(int fd, uint32_t flags, drmVersionPtr version,
|
|||
goto err_free_dev;
|
||||
}
|
||||
|
||||
if (version->version_major > 1 || version->version_minor >= 2) {
|
||||
if (pan_kmod_driver_version_at_least(drv_info, 1, 2)) {
|
||||
query = (struct drm_panthor_dev_query){
|
||||
.type = DRM_PANTHOR_DEV_QUERY_GROUP_PRIORITIES_INFO,
|
||||
.size = sizeof(panthor_dev->props.group_priorities),
|
||||
|
|
@ -289,8 +290,8 @@ panthor_kmod_dev_create(int fd, uint32_t flags, drmVersionPtr version,
|
|||
|
||||
assert(!ret);
|
||||
|
||||
pan_kmod_dev_init(&panthor_dev->base, fd, flags, version,
|
||||
&panthor_kmod_ops, allocator);
|
||||
pan_kmod_dev_init(&panthor_dev->base, fd, flags, drv_info, &panthor_kmod_ops,
|
||||
allocator);
|
||||
panthor_dev_query_props(panthor_dev);
|
||||
|
||||
return &panthor_dev->base;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue