[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260206-bvnc-cleanup-v1-2-f3c818541fbe@imgtec.com>
Date: Fri, 6 Feb 2026 09:56:26 +0000
From: Matt Coster <matt.coster@...tec.com>
To: Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard
<mripard@...nel.org>,
Thomas Zimmermann <tzimmermann@...e.de>,
David Airlie
<airlied@...il.com>, Simona Vetter <simona@...ll.ch>
CC: Frank Binns <frank.binns@...tec.com>,
Brajesh Gupta
<brajesh.gupta@...tec.com>,
Alessio Belle <alessio.belle@...tec.com>,
Alexandru Dadu <alexandru.dadu@...tec.com>,
<dri-devel@...ts.freedesktop.org>, <linux-kernel@...r.kernel.org>,
"Matt
Coster" <matt.coster@...tec.com>
Subject: [PATCH 2/2] drm/imagination: Add PVR_GPU_ID_FMT to format
pvr_gpu_id
There are currently two different combinations of format specifiers used to
print a struct pvr_gpu_id, one using %i and one using %d. Both of these
are technically incorrect since the components are stored as u16.
Introduce macros to simplify and correct the formatting of these values:
- PVR_GPU_ID_FMT: A pre-constructed format string fragment, in the style
of PRIu32.
- PVR_GPU_ID_FMT_ARGS(): Accepts a &struct pvr_gpu_id and expands the
fields into appropriate format arguments to be used with PVR_GPU_ID_FMT.
- PVR_GPU_ID_FMT_ARGS_PACKED(): Accepts a packed GPUID as a u64 and
extracts the components directly into appropriate format arguments to
be used with PVR_GPU_ID_FMT.
Signed-off-by: Matt Coster <matt.coster@...tec.com>
---
drivers/gpu/drm/imagination/pvr_device.c | 4 ++--
drivers/gpu/drm/imagination/pvr_device.h | 6 ++++++
drivers/gpu/drm/imagination/pvr_fw.c | 12 +++++-------
3 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/imagination/pvr_device.c b/drivers/gpu/drm/imagination/pvr_device.c
index f58bb66a6327..e032ebe1e505 100644
--- a/drivers/gpu/drm/imagination/pvr_device.c
+++ b/drivers/gpu/drm/imagination/pvr_device.c
@@ -362,8 +362,8 @@ pvr_build_firmware_filename(struct pvr_device *pvr_dev, const char *base,
{
struct pvr_gpu_id *gpu_id = &pvr_dev->gpu_id;
- return kasprintf(GFP_KERNEL, "%s_%d.%d.%d.%d_v%d.fw", base, gpu_id->b,
- gpu_id->v, gpu_id->n, gpu_id->c, major);
+ return kasprintf(GFP_KERNEL, "%s_" PVR_GPU_ID_FMT "_v%d.fw", base,
+ PVR_GPU_ID_FMT_ARGS(gpu_id), major);
}
static void
diff --git a/drivers/gpu/drm/imagination/pvr_device.h b/drivers/gpu/drm/imagination/pvr_device.h
index 58f0eae05ad9..4213eb8dd7cd 100644
--- a/drivers/gpu/drm/imagination/pvr_device.h
+++ b/drivers/gpu/drm/imagination/pvr_device.h
@@ -53,6 +53,12 @@ struct pvr_gpu_id {
u16 b, v, n, c;
};
+#define PVR_GPU_ID_FMT "%u.%u.%u.%u"
+#define PVR_GPU_ID_FMT_ARGS(gpu_id) (gpu_id)->b, (gpu_id)->v, (gpu_id)->n, (gpu_id)->c
+#define PVR_GPU_ID_FMT_ARGS_PACKED(gpu_id) \
+ (u32)FIELD_GET(DRM_PVR_BVNC_B, gpu_id), (u32)FIELD_GET(DRM_PVR_BVNC_V, gpu_id), \
+ (u32)FIELD_GET(DRM_PVR_BVNC_N, gpu_id), (u32)FIELD_GET(DRM_PVR_BVNC_C, gpu_id)
+
/**
* struct pvr_fw_version - Firmware version information
* @major: Major version number.
diff --git a/drivers/gpu/drm/imagination/pvr_fw.c b/drivers/gpu/drm/imagination/pvr_fw.c
index 779a58fe6ee8..b258c5a4f433 100644
--- a/drivers/gpu/drm/imagination/pvr_fw.c
+++ b/drivers/gpu/drm/imagination/pvr_fw.c
@@ -125,13 +125,11 @@ pvr_fw_validate(struct pvr_device *pvr_dev)
return -EINVAL;
}
- if (pvr_gpu_id_to_packed_bvnc(&pvr_dev->gpu_id) != header->bvnc) {
- struct pvr_gpu_id fw_gpu_id;
-
- packed_bvnc_to_pvr_gpu_id(header->bvnc, &fw_gpu_id);
- drm_err(drm_dev, "FW built for incorrect GPU ID %i.%i.%i.%i (expected %i.%i.%i.%i)\n",
- fw_gpu_id.b, fw_gpu_id.v, fw_gpu_id.n, fw_gpu_id.c,
- pvr_dev->gpu_id.b, pvr_dev->gpu_id.v, pvr_dev->gpu_id.n, pvr_dev->gpu_id.c);
+ u64 device_gpu_id_packed = pvr_gpu_id_to_packed_bvnc(&pvr_dev->gpu_id);
+ if (device_gpu_id_packed != header->bvnc) {
+ drm_err(drm_dev, "FW built for incorrect GPU ID " PVR_GPU_ID_FMT " (expected " PVR_GPU_ID_FMT ")\n",
+ PVR_GPU_ID_FMT_ARGS_PACKED(header->bvnc),
+ PVR_GPU_ID_FMT_ARGS_PACKED(device_gpu_id_packed));
return -EINVAL;
}
--
2.52.0
Powered by blists - more mailing lists