drm/imagination: GPU_ID-related cleanups
Subsystems (3)
v2 cover drm/imagination: GPU_ID-related cleanups
Just a couple quick QoL improvements around GPU_IDs.
The first patch touches the UAPI, but is not intended to introduce any functional changes; it simply codifies the existing documented layout of packed BVNC fields as a series of GENMASKed macros.
---
Changes in v2:
- Add _CONST variant of PVR_PACKED_BVNC() for use in case statements.
This fixes the build issue reported by the test bot[1][2] (P1)
- Simplify the change made to pvr_fw_validate() (P2)
- Link to v1: https://patch.msgid.link/[email protected]
[1]: https://lore.kernel.org/r/[email protected]/
[2]: https://lore.kernel.org/r/[email protected]/
---
Matt Coster (2):
drm/imagination: Define packed BVNCs in the uapi drm/imagination: Add PVR_GPU_ID_FMT to format pvr_gpu_id
drivers/gpu/drm/imagination/pvr_device.c | 10 +++---- drivers/gpu/drm/imagination/pvr_device.h | 49 +++++++++++++++----------------- drivers/gpu/drm/imagination/pvr_fw.c | 9 ++---- include/uapi/drm/pvr_drm.h | 14 ++++----- 4 files changed, 38 insertions(+), 44 deletions(-)
---
base-commit: fbef867cf6614178bc6afd15ee15f85cddf19eab
change-id: 20260206-bvnc-cleanup-446e70666747
PATCH v2 1/2 drm/imagination: Define packed BVNCs in the uapi
Using the uapi-safe __GENMASK_ULL(), we can stably define the layout of 64-bit packed BVNCs. These defs replace the replicated doc comment that appears all over the place.
---
Changes in v2:
- Add _CONST variant of PVR_PACKED_BVNC() for use in case statements.
This fixes the build issue reported by the test bot[1][2]
- Link to v1: https://patch.msgid.link/[email protected]
[1]: https://lore.kernel.org/r/[email protected]/
[2]: https://lore.kernel.org/r/[email protected]/
--- drivers/gpu/drm/imagination/pvr_device.c | 6 ++--- drivers/gpu/drm/imagination/pvr_device.h | 43 +++++++++++++------------------- include/uapi/drm/pvr_drm.h | 14 +++++------ 3 files changed, 27 insertions(+), 36 deletions(-)
drivers/gpu/drm/imagination/pvr_device.c +3 -3
@@ -547,11 +547,11 @@ static enum pvr_gpu_support_level pvr_gpu_support_level(const struct pvr_gpu_id *gpu_id) {switch (pvr_gpu_id_to_packed_bvnc (gpu_id)) { -case PVR_PACKED_BVNC (33 ,15 ,11 ,3 ): -case PVR_PACKED_BVNC (36 ,53 ,104 ,796 ): +case PVR_PACKED_BVNC_CONST (33 ,15 ,11 ,3 ): +case PVR_PACKED_BVNC_CONST (36 ,53 ,104 ,796 ):return PVR_GPU_SUPPORTED ; -case PVR_PACKED_BVNC (36 ,52 ,104 ,182 ): +case PVR_PACKED_BVNC_CONST (36 ,52 ,104 ,182 ):return PVR_GPU_EXPERIMENTAL ;default :
drivers/gpu/drm/imagination/pvr_device.h +17 -26
79 lines not on this page · raw message
include/uapi/drm/pvr_drm.h +7 -7
@@ -6,6 +6,7 @@#include "drm.h" +#include <linux/bits.h> #include <linux/const.h> #include <linux/types.h>
@@ -113,6 +114,11 @@ struct drm_pvr_obj_array {* DOC: PowerVR IOCTL DEV_QUERY interface */ +#define DRM_PVR_BVNC_B __GENMASK_ULL(63, 48) +#define DRM_PVR_BVNC_V __GENMASK_ULL(47, 32) +#define DRM_PVR_BVNC_N __GENMASK_ULL(31, 16) +#define DRM_PVR_BVNC_C __GENMASK_ULL(15, 0) +/** * struct drm_pvr_dev_query_gpu_info - Container used to fetch information about * the graphics processor.
@@ -125,13 +131,7 @@ struct drm_pvr_dev_query_gpu_info {* @gpu_id: GPU identifier. * * For all currently supported GPUs this is the BVNC encoded as a 64-bit -* value as follows: -* -* +--------+--------+--------+-------+ -* | 63..48 | 47..32 | 31..16 | 15..0 | -* +========+========+========+=======+ -* | B | V | N | C | -* +--------+--------+--------+-------+ +* value using the DRM_PVR_BVNC_* bitmasks. */ __u64 gpu_id;
Signature · 1 line
2.53.0
kernel test robot
build botRe: [PATCH v2 1/2] drm/imagination: Define packed BVNCs in the uapi
kernel test robot noticed the following build errors:
Hi Matt,
kernel test robot noticed the following build errors:
[auto build test ERROR on fbef867cf6614178bc6afd15ee15f85cddf19eab]
url: https://github.com/intel-lab-lkp/linux/commits/Matt-Coster/drm-imagination-Define-packed-BVNCs-in-the-uapi/20260322-112647 base: fbef867cf6614178bc6afd15ee15f85cddf19eab patch link: https://lore.kernel.org/r/20260320-bvnc-cleanup-v2-1-49c3c1453289%40imgtec.com patch subject: [PATCH v2 1/2] drm/imagination: Define packed BVNCs in the uapi config: arm64-randconfig-002-20260322 (https://download.01.org/0day-ci/archive/20260322/[email protected]/config) compiler: aarch64-linux-gcc (GCC) 11.5.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260322/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
In file included from include/linux/build_bug.h:5,
from include/linux/bits.h:30,
from drivers/gpu/drm/imagination/pvr_rogue_fwif.h:7, from drivers/gpu/drm/imagination/pvr_ccb.h:7, from drivers/gpu/drm/imagination/pvr_device.h:7, from drivers/gpu/drm/imagination/pvr_device.c:4:
drivers/gpu/drm/imagination/pvr_device.c: In function 'pvr_gpu_support_level':
>> include/linux/compiler.h:203:82: error: expression in static assertion is not constant
203 | #define __BUILD_BUG_ON_ZERO_MSG(e, msg, ...) ((int)sizeof(struct {_Static_assert(!(e), msg);}))
| ^~~~
include/linux/build_bug.h:17:9: note: in expansion of macro '__BUILD_BUG_ON_ZERO_MSG'
17 | __BUILD_BUG_ON_ZERO_MSG(e, ##__VA_ARGS__, #e " is true")
| ^~~~~~~~~~~~~~~~~~~~~~~
include/linux/bitfield.h:160:17: note: in expansion of macro 'BUILD_BUG_ON_ZERO'
160 | BUILD_BUG_ON_ZERO(~((_mask) >> __bf_shf(_mask)) & (_val)) + \
| ^~~~~~~~~~~~~~~~~
drivers/gpu/drm/imagination/pvr_device.h:474:10: note: in expansion of macro 'FIELD_PREP_CONST'
474 | (prep(DRM_PVR_BVNC_B, b) | \
| ^~~~
drivers/gpu/drm/imagination/pvr_device.h:496:43: note: in expansion of macro '__PVR_PACKED_BVNC'
496 | #define PVR_PACKED_BVNC_CONST(b, v, n, c) __PVR_PACKED_BVNC(FIELD_PREP_CONST, b, v, n, c)
| ^~~~~~~~~~~~~~~~~
drivers/gpu/drm/imagination/pvr_device.c:550:14: note: in expansion of macro 'PVR_PACKED_BVNC_CONST'
550 | case PVR_PACKED_BVNC_CONST(33, 15, 11, 3):
| ^~~~~~~~~~~~~~~~~~~~~
>> include/linux/compiler.h:203:82: error: expression in static assertion is not constant
203 | #define __BUILD_BUG_ON_ZERO_MSG(e, msg, ...) ((int)sizeof(struct {_Static_assert(!(e), msg);}))
| ^~~~
include/linux/build_bug.h:17:9: note: in expansion of macro '__BUILD_BUG_ON_ZERO_MSG'
17 | __BUILD_BUG_ON_ZERO_MSG(e, ##__VA_ARGS__, #e " is true")
| ^~~~~~~~~~~~~~~~~~~~~~~
include/linux/bitfield.h:141:33: note: in expansion of macro 'BUILD_BUG_ON_ZERO'
141 | #define __BF_CHECK_POW2(n) BUILD_BUG_ON_ZERO(((n) & ((n) - 1)) != 0)
| ^~~~~~~~~~~~~~~~~
include/linux/bitfield.h:162:17: note: in expansion of macro '__BF_CHECK_POW2'
162 | __BF_CHECK_POW2((_mask) + (1ULL << __bf_shf(_mask))) + \
| ^~~~~~~~~~~~~~~
drivers/gpu/drm/imagination/pvr_device.h:474:10: note: in expansion of macro 'FIELD_PREP_CONST'
474 | (prep(DRM_PVR_BVNC_B, b) | \
| ^~~~
drivers/gpu/drm/imagination/pvr_device.h:496:43: note: in expansion of macro '__PVR_PACKED_BVNC'
496 | #define PVR_PACKED_BVNC_CONST(b, v, n, c) __PVR_PACKED_BVNC(FIELD_PREP_CONST, b, v, n, c)
| ^~~~~~~~~~~~~~~~~
drivers/gpu/drm/imagination/pvr_device.c:550:14: note: in expansion of macro 'PVR_PACKED_BVNC_CONST'
550 | case PVR_PACKED_BVNC_CONST(33, 15, 11, 3):
| ^~~~~~~~~~~~~~~~~~~~~
>> include/linux/compiler.h:203:82: error: expression in static assertion is not constant
203 | #define __BUILD_BUG_ON_ZERO_MSG(e, msg, ...) ((int)sizeof(struct {_Static_assert(!(e), msg);}))
| ^~~~
include/linux/build_bug.h:17:9: note: in expansion of macro '__BUILD_BUG_ON_ZERO_MSG'
17 | __BUILD_BUG_ON_ZERO_MSG(e, ##__VA_ARGS__, #e " is true")
| ^~~~~~~~~~~~~~~~~~~~~~~
include/linux/bitfield.h:160:17: note: in expansion of macro 'BUILD_BUG_ON_ZERO'
160 | BUILD_BUG_ON_ZERO(~((_mask) >> __bf_shf(_mask)) & (_val)) + \
| ^~~~~~~~~~~~~~~~~
drivers/gpu/drm/imagination/pvr_device.h:474:10: note: in expansion of macro 'FIELD_PREP_CONST'
474 | (prep(DRM_PVR_BVNC_B, b) | \
| ^~~~
drivers/gpu/drm/imagination/pvr_device.h:496:43: note: in expansion of macro '__PVR_PACKED_BVNC'
496 | #define PVR_PACKED_BVNC_CONST(b, v, n, c) __PVR_PACKED_BVNC(FIELD_PREP_CONST, b, v, n, c)
| ^~~~~~~~~~~~~~~~~
drivers/gpu/drm/imagination/pvr_device.c:551:14: note: in expansion of macro 'PVR_PACKED_BVNC_CONST'
551 | case PVR_PACKED_BVNC_CONST(36, 53, 104, 796):
| ^~~~~~~~~~~~~~~~~~~~~
>> include/linux/compiler.h:203:82: error: expression in static assertion is not constant
203 | #define __BUILD_BUG_ON_ZERO_MSG(e, msg, ...) ((int)sizeof(struct {_Static_assert(!(e), msg);}))
| ^~~~
include/linux/build_bug.h:17:9: note: in expansion of macro '__BUILD_BUG_ON_ZERO_MSG'
17 | __BUILD_BUG_ON_ZERO_MSG(e, ##__VA_ARGS__, #e " is true")
| ^~~~~~~~~~~~~~~~~~~~~~~
include/linux/bitfield.h:141:33: note: in expansion of macro 'BUILD_BUG_ON_ZERO'
141 | #define __BF_CHECK_POW2(n) BUILD_BUG_ON_ZERO(((n) & ((n) - 1)) != 0)
| ^~~~~~~~~~~~~~~~~
include/linux/bitfield.h:162:17: note: in expansion of macro '__BF_CHECK_POW2'
162 | __BF_CHECK_POW2((_mask) + (1ULL << __bf_shf(_mask))) + \
| ^~~~~~~~~~~~~~~
drivers/gpu/drm/imagination/pvr_device.h:474:10: note: in expansion of macro 'FIELD_PREP_CONST'
474 | (prep(DRM_PVR_BVNC_B, b) | \
| ^~~~
drivers/gpu/drm/imagination/pvr_device.h:496:43: note: in expansion of macro '__PVR_PACKED_BVNC'
496 | #define PVR_PACKED_BVNC_CONST(b, v, n, c) __PVR_PACKED_BVNC(FIELD_PREP_CONST, b, v, n, c)
| ^~~~~~~~~~~~~~~~~
drivers/gpu/drm/imagination/pvr_device.c:551:14: note: in expansion of macro 'PVR_PACKED_BVNC_CONST'
551 | case PVR_PACKED_BVNC_CONST(36, 53, 104, 796):
| ^~~~~~~~~~~~~~~~~~~~~
>> include/linux/compiler.h:203:82: error: expression in static assertion is not constant
203 | #define __BUILD_BUG_ON_ZERO_MSG(e, msg, ...) ((int)sizeof(struct {_Static_assert(!(e), msg);}))
| ^~~~
include/linux/build_bug.h:17:9: note: in expansion of macro '__BUILD_BUG_ON_ZERO_MSG'
17 | __BUILD_BUG_ON_ZERO_MSG(e, ##__VA_ARGS__, #e " is true")
| ^~~~~~~~~~~~~~~~~~~~~~~
include/linux/bitfield.h:160:17: note: in expansion of macro 'BUILD_BUG_ON_ZERO'
160 | BUILD_BUG_ON_ZERO(~((_mask) >> __bf_shf(_mask)) & (_val)) + \
| ^~~~~~~~~~~~~~~~~
drivers/gpu/drm/imagination/pvr_device.h:474:10: note: in expansion of macro 'FIELD_PREP_CONST'
474 | (prep(DRM_PVR_BVNC_B, b) | \
| ^~~~
drivers/gpu/drm/imagination/pvr_device.h:496:43: note: in expansion of macro '__PVR_PACKED_BVNC'
496 | #define PVR_PACKED_BVNC_CONST(b, v, n, c) __PVR_PACKED_BVNC(FIELD_PREP_CONST, b, v, n, c)
| ^~~~~~~~~~~~~~~~~
drivers/gpu/drm/imagination/pvr_device.c:554:14: note: in expansion of macro 'PVR_PACKED_BVNC_CONST'
554 | case PVR_PACKED_BVNC_CONST(36, 52, 104, 182):
| ^~~~~~~~~~~~~~~~~~~~~
>> include/linux/compiler.h:203:82: error: expression in static assertion is not constant
203 | #define __BUILD_BUG_ON_ZERO_MSG(e, msg, ...) ((int)sizeof(struct {_Static_assert(!(e), msg);}))
| ^~~~
include/linux/build_bug.h:17:9: note: in expansion of macro '__BUILD_BUG_ON_ZERO_MSG'
17 | __BUILD_BUG_ON_ZERO_MSG(e, ##__VA_ARGS__, #e " is true")
| ^~~~~~~~~~~~~~~~~~~~~~~
include/linux/bitfield.h:141:33: note: in expansion of macro 'BUILD_BUG_ON_ZERO'
141 | #define __BF_CHECK_POW2(n) BUILD_BUG_ON_ZERO(((n) & ((n) - 1)) != 0)
| ^~~~~~~~~~~~~~~~~
include/linux/bitfield.h:162:17: note: in expansion of macro '__BF_CHECK_POW2'
162 | __BF_CHECK_POW2((_mask) + (1ULL << __bf_shf(_mask))) + \
| ^~~~~~~~~~~~~~~
drivers/gpu/drm/imagination/pvr_device.h:474:10: note: in expansion of macro 'FIELD_PREP_CONST'
474 | (prep(DRM_PVR_BVNC_B, b) | \
| ^~~~
drivers/gpu/drm/imagination/pvr_device.h:496:43: note: in expansion of macro '__PVR_PACKED_BVNC'
496 | #define PVR_PACKED_BVNC_CONST(b, v, n, c) __PVR_PACKED_BVNC(FIELD_PREP_CONST, b, v, n, c)
| ^~~~~~~~~~~~~~~~~
drivers/gpu/drm/imagination/pvr_device.c:554:14: note: in expansion of macro 'PVR_PACKED_BVNC_CONST'
554 | case PVR_PACKED_BVNC_CONST(36, 52, 104, 182):
| ^~~~~~~~~~~~~~~~~~~~~vim +203 include/linux/compiler.h
230fa253df6352 Christian Borntraeger 2014-11-25 199
cb7380de9e4cbc Kees Cook 2025-02-05 200 #ifdef __CHECKER__
243c90e917f5cf Vincent Mailhol 2025-03-29 201 #define __BUILD_BUG_ON_ZERO_MSG(e, msg, ...) (0)
cb7380de9e4cbc Kees Cook 2025-02-05 202 #else /* __CHECKER__ */
243c90e917f5cf Vincent Mailhol 2025-03-29 @203 #define __BUILD_BUG_ON_ZERO_MSG(e, msg, ...) ((int)sizeof(struct {_Static_assert(!(e), msg);}))
cb7380de9e4cbc Kees Cook 2025-02-05 204 #endif /* __CHECKER__ */
cb7380de9e4cbc Kees Cook 2025-02-05 205 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
PATCH v2 2/2 drm/imagination: Add PVR_GPU_ID_FMT to format pvr_gpu_id
In reply to Matt CosterThere 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 GPU ID as a u64 and extracts the components directly into appropriate format arguments to be used with PVR_GPU_ID_FMT.
---
Changes in v2:
- Simplify the change made to pvr_fw_validate()
- Link to v1: https://patch.msgid.link/[email protected]
--- drivers/gpu/drm/imagination/pvr_device.c | 4 ++-- drivers/gpu/drm/imagination/pvr_device.h | 6 ++++++ drivers/gpu/drm/imagination/pvr_fw.c | 9 +++------ 3 files changed, 11 insertions(+), 8 deletions(-)
drivers/gpu/drm/imagination/pvr_device.c +2 -2
@@ -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
drivers/gpu/drm/imagination/pvr_device.h +6 -0
@@ -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.
drivers/gpu/drm/imagination/pvr_fw.c +3 -6
@@ -126,12 +126,9 @@ pvr_fw_validate(struct pvr_device *pvr_dev) }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); +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 (&pvr_dev->gpu_id));return -EINVAL ; }
Signature · 1 line
2.53.0