mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 04:38:03 +02:00
pan/kmod: Add a panfrost_kmod_driver_version_at_least() helper
We have a few hand-rolled instances of this which work well enough but it gets more complicated as soon as we care about checking a major version more than 1. Add a helper to make this more robust. Reviewed-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/36385>
This commit is contained in:
parent
ee172bb769
commit
7e65322c93
3 changed files with 18 additions and 5 deletions
|
|
@ -451,6 +451,19 @@ struct pan_kmod_driver {
|
|||
} version;
|
||||
};
|
||||
|
||||
static inline bool
|
||||
pan_kmod_driver_version_at_least(const struct pan_kmod_driver *driver,
|
||||
uint32_t major, uint32_t minor)
|
||||
{
|
||||
if (driver->version.major < major)
|
||||
return false;
|
||||
|
||||
if (driver->version.major > major)
|
||||
return true;
|
||||
|
||||
return driver->version.minor >= minor;
|
||||
}
|
||||
|
||||
/* Device object. */
|
||||
struct pan_kmod_dev {
|
||||
/* FD attached to the device. */
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ panfrost_dev_query_props(struct panfrost_kmod_dev *panfrost_dev)
|
|||
|
||||
panfrost_dev_query_thread_props(panfrost_dev);
|
||||
|
||||
if (dev->driver.version.major > 1 || dev->driver.version.minor >= 3) {
|
||||
if (pan_kmod_driver_version_at_least(&dev->driver, 1, 3)) {
|
||||
props->gpu_can_query_timestamp = true;
|
||||
props->timestamp_frequency = panfrost_query_raw(
|
||||
fd, DRM_PANFROST_PARAM_SYSTEM_TIMESTAMP_FREQUENCY, true, 0);
|
||||
|
|
@ -239,7 +239,7 @@ to_panfrost_bo_flags(struct pan_kmod_dev *dev, uint32_t flags)
|
|||
{
|
||||
uint32_t panfrost_flags = 0;
|
||||
|
||||
if (dev->driver.version.major > 1 || dev->driver.version.minor >= 1) {
|
||||
if (pan_kmod_driver_version_at_least(&dev->driver, 1, 1)) {
|
||||
/* The alloc-on-fault feature is only used for the tiler HEAP object,
|
||||
* hence the name of the flag on panfrost.
|
||||
*/
|
||||
|
|
@ -509,7 +509,7 @@ panfrost_kmod_bo_label(struct pan_kmod_dev *dev, struct pan_kmod_bo *bo, const c
|
|||
{
|
||||
char truncated_label[PANFROST_BO_LABEL_MAXLEN];
|
||||
|
||||
if (!(dev->driver.version.major > 1 || dev->driver.version.minor >= 4))
|
||||
if (!pan_kmod_driver_version_at_least(&dev->driver, 1, 4))
|
||||
return;
|
||||
|
||||
if (strnlen(label, PANFROST_BO_LABEL_MAXLEN) == PANFROST_BO_LABEL_MAXLEN) {
|
||||
|
|
|
|||
|
|
@ -1187,7 +1187,7 @@ panthor_kmod_get_csif_props(const struct pan_kmod_dev *dev)
|
|||
static uint64_t
|
||||
panthor_kmod_query_timestamp(const struct pan_kmod_dev *dev)
|
||||
{
|
||||
if (dev->driver.version.major <= 1 && dev->driver.version.minor < 1)
|
||||
if (!pan_kmod_driver_version_at_least(&dev->driver, 1, 1))
|
||||
return 0;
|
||||
|
||||
struct drm_panthor_timestamp_info timestamp_info;
|
||||
|
|
@ -1212,7 +1212,7 @@ panthor_kmod_bo_label(struct pan_kmod_dev *dev, struct pan_kmod_bo *bo, const ch
|
|||
{
|
||||
char truncated_label[PANTHOR_BO_LABEL_MAXLEN];
|
||||
|
||||
if (!(dev->driver.version.major > 1 || dev->driver.version.minor >= 4))
|
||||
if (!pan_kmod_driver_version_at_least(&dev->driver, 1, 4))
|
||||
return;
|
||||
|
||||
if (strnlen(label, PANTHOR_BO_LABEL_MAXLEN) == PANTHOR_BO_LABEL_MAXLEN) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue