* [PATCH 0/2] drm/imagination: Tidy-up firmware interface checks
@ 2026-07-29 14:57 Alessio Belle
2026-07-29 14:57 ` [PATCH 1/2] drm/imagination: Move all FW interface check macros to pvr_checks.h Alessio Belle
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Alessio Belle @ 2026-07-29 14:57 UTC (permalink / raw)
To: Luigi Santivetti, Brajesh Gupta, Alexandru Dadu,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Simona Vetter
Cc: linux-kernel, imagination, dri-devel, Alessio Belle
The same macros were repeated in multiple header files, and another
header that could have used them, didn't.
Move things around to to sort out these minor issues.
Strict checkpatch reports "Macro argument reuse 'member' - possible
side-effects?" for FLEX_ARRAY_CHECK() but that's not a problem here.
Signed-off-by: Alessio Belle <alessio.belle@imgtec.com>
---
Alessio Belle (1):
drm/imagination: Reuse layout check macros for MIPS FW structures
Alexandru Dadu (1):
drm/imagination: Move all FW interface check macros to pvr_checks.h
drivers/gpu/drm/imagination/pvr_check.h | 36 +++++++++++
drivers/gpu/drm/imagination/pvr_rogue_fwif_check.h | 26 +-------
.../drm/imagination/pvr_rogue_fwif_client_check.h | 9 +--
.../drm/imagination/pvr_rogue_fwif_shared_check.h | 9 +--
drivers/gpu/drm/imagination/pvr_rogue_mips_check.h | 71 ++++++++--------------
5 files changed, 63 insertions(+), 88 deletions(-)
---
base-commit: e55fead22ff9ee047ab9f1903860c4b43043514e
change-id: 20260729-fwif-checks-updates-52adf8657615
Best regards,
--
Alessio Belle <alessio.belle@imgtec.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] drm/imagination: Move all FW interface check macros to pvr_checks.h
2026-07-29 14:57 [PATCH 0/2] drm/imagination: Tidy-up firmware interface checks Alessio Belle
@ 2026-07-29 14:57 ` Alessio Belle
2026-07-29 14:57 ` [PATCH 2/2] drm/imagination: Reuse layout check macros for MIPS FW structures Alessio Belle
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Alessio Belle @ 2026-07-29 14:57 UTC (permalink / raw)
To: Luigi Santivetti, Brajesh Gupta, Alexandru Dadu,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Simona Vetter
Cc: linux-kernel, imagination, dri-devel, Alessio Belle
From: Alexandru Dadu <alexandru.dadu@imgtec.com>
The same macros are redefined in three places, so move them to a common
file to reduce duplication and make it easier to reuse them.
Signed-off-by: Alexandru Dadu <alexandru.dadu@imgtec.com>
Co-developed-by: Alessio Belle <alessio.belle@imgtec.com>
Signed-off-by: Alessio Belle <alessio.belle@imgtec.com>
---
drivers/gpu/drm/imagination/pvr_check.h | 36 ++++++++++++++++++++++
drivers/gpu/drm/imagination/pvr_rogue_fwif_check.h | 26 +---------------
.../drm/imagination/pvr_rogue_fwif_client_check.h | 9 +-----
.../drm/imagination/pvr_rogue_fwif_shared_check.h | 9 +-----
4 files changed, 39 insertions(+), 41 deletions(-)
diff --git a/drivers/gpu/drm/imagination/pvr_check.h b/drivers/gpu/drm/imagination/pvr_check.h
new file mode 100644
index 000000000000..94764ce9bbd1
--- /dev/null
+++ b/drivers/gpu/drm/imagination/pvr_check.h
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: GPL-2.0-only OR MIT */
+/* Copyright (c) 2026 Imagination Technologies Ltd. */
+
+#ifndef PVR_CHECK_H
+#define PVR_CHECK_H
+
+#include <linux/build_bug.h>
+#include <linux/overflow.h>
+#include <linux/stddef.h>
+
+#define OFFSET_CHECK(type, member, offset) \
+ static_assert(offsetof(type, member) == (offset), \
+ "offsetof(" #type ", " #member ") incorrect")
+
+#define SIZE_CHECK(type, size) \
+ static_assert(sizeof(type) == (size), #type " is incorrect size")
+
+#define ALIGN_CHECK(type, align) \
+ static_assert(__alignof__(type) <= (align), #type " has incorrect alignment")
+
+/*
+ * Where the last member of a struct is a flexible array member, using
+ * SIZE_CHECK() is pointless. If the structure is not already padded to
+ * alignment without the flexible array member, sizeof() will not match the
+ * offset of the flexible array member and the "correct" sizeof() value is
+ * completely meaningless.
+ *
+ * In those instances, use FLEX_ARRAY_CHECK() instead to assert that the final
+ * field is a flexible array member and that it behaves as expected.
+ */
+#define FLEX_ARRAY_CHECK(type, member) \
+ static_assert(flex_array_size((type *)NULL, member, 1) == \
+ sizeof_field(type, member[0]), \
+ #type "->" #member " is incorrect size")
+
+#endif /* PVR_CHECK_H */
diff --git a/drivers/gpu/drm/imagination/pvr_rogue_fwif_check.h b/drivers/gpu/drm/imagination/pvr_rogue_fwif_check.h
index e72f4064af18..5048866359b9 100644
--- a/drivers/gpu/drm/imagination/pvr_rogue_fwif_check.h
+++ b/drivers/gpu/drm/imagination/pvr_rogue_fwif_check.h
@@ -4,31 +4,7 @@
#ifndef PVR_ROGUE_FWIF_CHECK_H
#define PVR_ROGUE_FWIF_CHECK_H
-#include <linux/build_bug.h>
-#include <linux/overflow.h>
-#include <linux/stddef.h>
-
-#define OFFSET_CHECK(type, member, offset) \
- static_assert(offsetof(type, member) == (offset), \
- "offsetof(" #type ", " #member ") incorrect")
-
-#define SIZE_CHECK(type, size) \
- static_assert(sizeof(type) == (size), #type " is incorrect size")
-
-/*
- * Where the last member of a struct is a flexible array member, using
- * SIZE_CHECK() is pointless. If the structure is not already padded to
- * alignment without the flexible array member, sizeof() will not match the
- * offset of the flexible array member and the "correct" sizeof() value is
- * completely meaningless.
- *
- * In those instances, use FLEX_ARRAY_CHECK() instead to assert that the final
- * field is a flexible array member and that it behaves as expected.
- */
-#define FLEX_ARRAY_CHECK(type, member) \
- static_assert(flex_array_size((type *)NULL, member, 1) == \
- sizeof_field(type, member[0]), \
- #type "->" #member " is incorrect size")
+#include "pvr_check.h"
OFFSET_CHECK(struct rogue_fwif_file_info_buf, path, 0);
OFFSET_CHECK(struct rogue_fwif_file_info_buf, info, 200);
diff --git a/drivers/gpu/drm/imagination/pvr_rogue_fwif_client_check.h b/drivers/gpu/drm/imagination/pvr_rogue_fwif_client_check.h
index 54aa4474163e..467d1d2073a1 100644
--- a/drivers/gpu/drm/imagination/pvr_rogue_fwif_client_check.h
+++ b/drivers/gpu/drm/imagination/pvr_rogue_fwif_client_check.h
@@ -4,14 +4,7 @@
#ifndef PVR_ROGUE_FWIF_CLIENT_CHECK_H
#define PVR_ROGUE_FWIF_CLIENT_CHECK_H
-#include <linux/build_bug.h>
-
-#define OFFSET_CHECK(type, member, offset) \
- static_assert(offsetof(type, member) == (offset), \
- "offsetof(" #type ", " #member ") incorrect")
-
-#define SIZE_CHECK(type, size) \
- static_assert(sizeof(type) == (size), #type " is incorrect size")
+#include "pvr_check.h"
OFFSET_CHECK(struct rogue_fwif_geom_regs, vdm_ctrl_stream_base, 0);
OFFSET_CHECK(struct rogue_fwif_geom_regs, tpu_border_colour_table, 8);
diff --git a/drivers/gpu/drm/imagination/pvr_rogue_fwif_shared_check.h b/drivers/gpu/drm/imagination/pvr_rogue_fwif_shared_check.h
index 597ed54bbd3a..59ef0a9aa395 100644
--- a/drivers/gpu/drm/imagination/pvr_rogue_fwif_shared_check.h
+++ b/drivers/gpu/drm/imagination/pvr_rogue_fwif_shared_check.h
@@ -4,14 +4,7 @@
#ifndef PVR_ROGUE_FWIF_SHARED_CHECK_H
#define PVR_ROGUE_FWIF_SHARED_CHECK_H
-#include <linux/build_bug.h>
-
-#define OFFSET_CHECK(type, member, offset) \
- static_assert(offsetof(type, member) == (offset), \
- "offsetof(" #type ", " #member ") incorrect")
-
-#define SIZE_CHECK(type, size) \
- static_assert(sizeof(type) == (size), #type " is incorrect size")
+#include "pvr_check.h"
OFFSET_CHECK(struct rogue_fwif_dma_addr, dev_addr, 0);
OFFSET_CHECK(struct rogue_fwif_dma_addr, fw_addr, 8);
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] drm/imagination: Reuse layout check macros for MIPS FW structures
2026-07-29 14:57 [PATCH 0/2] drm/imagination: Tidy-up firmware interface checks Alessio Belle
2026-07-29 14:57 ` [PATCH 1/2] drm/imagination: Move all FW interface check macros to pvr_checks.h Alessio Belle
@ 2026-07-29 14:57 ` Alessio Belle
2026-08-03 6:41 ` [PATCH 0/2] drm/imagination: Tidy-up firmware interface checks Brajesh Gupta
2026-08-03 10:29 ` Alessio Belle
3 siblings, 0 replies; 5+ messages in thread
From: Alessio Belle @ 2026-07-29 14:57 UTC (permalink / raw)
To: Luigi Santivetti, Brajesh Gupta, Alexandru Dadu,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Simona Vetter
Cc: linux-kernel, imagination, dri-devel, Alessio Belle
Replace static asserts on MIPS firmware structures offsets and sizes
with more compact macros that are already used for similar checks on
common firmware interface structures.
Signed-off-by: Alessio Belle <alessio.belle@imgtec.com>
---
drivers/gpu/drm/imagination/pvr_rogue_mips_check.h | 71 ++++++++--------------
1 file changed, 24 insertions(+), 47 deletions(-)
diff --git a/drivers/gpu/drm/imagination/pvr_rogue_mips_check.h b/drivers/gpu/drm/imagination/pvr_rogue_mips_check.h
index 824b4bf33ac1..aebf231ce90f 100644
--- a/drivers/gpu/drm/imagination/pvr_rogue_mips_check.h
+++ b/drivers/gpu/drm/imagination/pvr_rogue_mips_check.h
@@ -4,55 +4,32 @@
#ifndef PVR_ROGUE_MIPS_CHECK_H
#define PVR_ROGUE_MIPS_CHECK_H
-#include <linux/build_bug.h>
+#include "pvr_check.h"
-static_assert(offsetof(struct rogue_mips_tlb_entry, tlb_page_mask) == 0,
- "offsetof(struct rogue_mips_tlb_entry, tlb_page_mask) incorrect");
-static_assert(offsetof(struct rogue_mips_tlb_entry, tlb_hi) == 4,
- "offsetof(struct rogue_mips_tlb_entry, tlb_hi) incorrect");
-static_assert(offsetof(struct rogue_mips_tlb_entry, tlb_lo0) == 8,
- "offsetof(struct rogue_mips_tlb_entry, tlb_lo0) incorrect");
-static_assert(offsetof(struct rogue_mips_tlb_entry, tlb_lo1) == 12,
- "offsetof(struct rogue_mips_tlb_entry, tlb_lo1) incorrect");
-static_assert(sizeof(struct rogue_mips_tlb_entry) == 16,
- "struct rogue_mips_tlb_entry is incorrect size");
+OFFSET_CHECK(struct rogue_mips_tlb_entry, tlb_page_mask, 0);
+OFFSET_CHECK(struct rogue_mips_tlb_entry, tlb_hi, 4);
+OFFSET_CHECK(struct rogue_mips_tlb_entry, tlb_lo0, 8);
+OFFSET_CHECK(struct rogue_mips_tlb_entry, tlb_lo1, 12);
+SIZE_CHECK(struct rogue_mips_tlb_entry, 16);
-static_assert(offsetof(struct rogue_mips_remap_entry, remap_addr_in) == 0,
- "offsetof(struct rogue_mips_remap_entry, remap_addr_in) incorrect");
-static_assert(offsetof(struct rogue_mips_remap_entry, remap_addr_out) == 4,
- "offsetof(struct rogue_mips_remap_entry, remap_addr_out) incorrect");
-static_assert(offsetof(struct rogue_mips_remap_entry, remap_region_size) == 8,
- "offsetof(struct rogue_mips_remap_entry, remap_region_size) incorrect");
-static_assert(sizeof(struct rogue_mips_remap_entry) == 12,
- "struct rogue_mips_remap_entry is incorrect size");
+OFFSET_CHECK(struct rogue_mips_remap_entry, remap_addr_in, 0);
+OFFSET_CHECK(struct rogue_mips_remap_entry, remap_addr_out, 4);
+OFFSET_CHECK(struct rogue_mips_remap_entry, remap_region_size, 8);
+SIZE_CHECK(struct rogue_mips_remap_entry, 12);
-static_assert(offsetof(struct rogue_mips_state, error_state) == 0,
- "offsetof(struct rogue_mips_state, error_state) incorrect");
-static_assert(offsetof(struct rogue_mips_state, error_epc) == 4,
- "offsetof(struct rogue_mips_state, error_epc) incorrect");
-static_assert(offsetof(struct rogue_mips_state, status_register) == 8,
- "offsetof(struct rogue_mips_state, status_register) incorrect");
-static_assert(offsetof(struct rogue_mips_state, cause_register) == 12,
- "offsetof(struct rogue_mips_state, cause_register) incorrect");
-static_assert(offsetof(struct rogue_mips_state, bad_register) == 16,
- "offsetof(struct rogue_mips_state, bad_register) incorrect");
-static_assert(offsetof(struct rogue_mips_state, epc) == 20,
- "offsetof(struct rogue_mips_state, epc) incorrect");
-static_assert(offsetof(struct rogue_mips_state, sp) == 24,
- "offsetof(struct rogue_mips_state, sp) incorrect");
-static_assert(offsetof(struct rogue_mips_state, debug) == 28,
- "offsetof(struct rogue_mips_state, debug) incorrect");
-static_assert(offsetof(struct rogue_mips_state, depc) == 32,
- "offsetof(struct rogue_mips_state, depc) incorrect");
-static_assert(offsetof(struct rogue_mips_state, bad_instr) == 36,
- "offsetof(struct rogue_mips_state, bad_instr) incorrect");
-static_assert(offsetof(struct rogue_mips_state, unmapped_address) == 40,
- "offsetof(struct rogue_mips_state, unmapped_address) incorrect");
-static_assert(offsetof(struct rogue_mips_state, tlb) == 44,
- "offsetof(struct rogue_mips_state, tlb) incorrect");
-static_assert(offsetof(struct rogue_mips_state, remap) == 300,
- "offsetof(struct rogue_mips_state, remap) incorrect");
-static_assert(sizeof(struct rogue_mips_state) == 684,
- "struct rogue_mips_state is incorrect size");
+OFFSET_CHECK(struct rogue_mips_state, error_state, 0);
+OFFSET_CHECK(struct rogue_mips_state, error_epc, 4);
+OFFSET_CHECK(struct rogue_mips_state, status_register, 8);
+OFFSET_CHECK(struct rogue_mips_state, cause_register, 12);
+OFFSET_CHECK(struct rogue_mips_state, bad_register, 16);
+OFFSET_CHECK(struct rogue_mips_state, epc, 20);
+OFFSET_CHECK(struct rogue_mips_state, sp, 24);
+OFFSET_CHECK(struct rogue_mips_state, debug, 28);
+OFFSET_CHECK(struct rogue_mips_state, depc, 32);
+OFFSET_CHECK(struct rogue_mips_state, bad_instr, 36);
+OFFSET_CHECK(struct rogue_mips_state, unmapped_address, 40);
+OFFSET_CHECK(struct rogue_mips_state, tlb, 44);
+OFFSET_CHECK(struct rogue_mips_state, remap, 300);
+SIZE_CHECK(struct rogue_mips_state, 684);
#endif /* PVR_ROGUE_MIPS_CHECK_H */
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] drm/imagination: Tidy-up firmware interface checks
2026-07-29 14:57 [PATCH 0/2] drm/imagination: Tidy-up firmware interface checks Alessio Belle
2026-07-29 14:57 ` [PATCH 1/2] drm/imagination: Move all FW interface check macros to pvr_checks.h Alessio Belle
2026-07-29 14:57 ` [PATCH 2/2] drm/imagination: Reuse layout check macros for MIPS FW structures Alessio Belle
@ 2026-08-03 6:41 ` Brajesh Gupta
2026-08-03 10:29 ` Alessio Belle
3 siblings, 0 replies; 5+ messages in thread
From: Brajesh Gupta @ 2026-08-03 6:41 UTC (permalink / raw)
To: Luigi Santivetti, tzimmermann, simona, airlied, Alessio Belle,
maarten.lankhorst, Alexandru Dadu, mripard
Cc: dri-devel, imagination, linux-kernel
On Wed, 2026-07-29 at 15:57 +0100, Alessio Belle wrote:
Hi Alessio,
> *** NOTE: This is an internal email from Imagination Technologies ***
>
>
>
>
> The same macros were repeated in multiple header files, and another
> header that could have used them, didn't.
> Move things around to to sort out these minor issues.
>
> Strict checkpatch reports "Macro argument reuse 'member' - possible
> side-effects?" for FLEX_ARRAY_CHECK() but that's not a problem here.
For the whole series:
Reviewed-by: Brajesh Gupta <brajesh.gupta@imgtec.com>
Thanks,
Brajesh
>
>
> Signed-off-by: Alessio Belle <alessio.belle@imgtec.com>
> ---
> Alessio Belle (1):
> drm/imagination: Reuse layout check macros for MIPS FW structures
>
> Alexandru Dadu (1):
> drm/imagination: Move all FW interface check macros to pvr_checks.h
>
> drivers/gpu/drm/imagination/pvr_check.h | 36 +++++++++++
> drivers/gpu/drm/imagination/pvr_rogue_fwif_check.h | 26 +-------
> .../drm/imagination/pvr_rogue_fwif_client_check.h | 9 +--
> .../drm/imagination/pvr_rogue_fwif_shared_check.h | 9 +--
> drivers/gpu/drm/imagination/pvr_rogue_mips_check.h | 71 ++++++++--------------
> 5 files changed, 63 insertions(+), 88 deletions(-)
> ---
> base-commit: e55fead22ff9ee047ab9f1903860c4b43043514e
> change-id: 20260729-fwif-checks-updates-52adf8657615
>
> Best regards,
> --
> Alessio Belle <alessio.belle@imgtec.com>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] drm/imagination: Tidy-up firmware interface checks
2026-07-29 14:57 [PATCH 0/2] drm/imagination: Tidy-up firmware interface checks Alessio Belle
` (2 preceding siblings ...)
2026-08-03 6:41 ` [PATCH 0/2] drm/imagination: Tidy-up firmware interface checks Brajesh Gupta
@ 2026-08-03 10:29 ` Alessio Belle
3 siblings, 0 replies; 5+ messages in thread
From: Alessio Belle @ 2026-08-03 10:29 UTC (permalink / raw)
To: Luigi Santivetti, Brajesh Gupta, Alexandru Dadu,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Simona Vetter, Alessio Belle
Cc: linux-kernel, imagination, dri-devel
On Wed, 29 Jul 2026 15:57:05 +0100, Alessio Belle wrote:
> The same macros were repeated in multiple header files, and another
> header that could have used them, didn't.
> Move things around to to sort out these minor issues.
>
> Strict checkpatch reports "Macro argument reuse 'member' - possible
> side-effects?" for FLEX_ARRAY_CHECK() but that's not a problem here.
>
> [...]
Applied to drm-misc-next, thanks!
[1/2] drm/imagination: Move all FW interface check macros to pvr_checks.h
commit: e0c92f0f9e200799eec6ba76d921643fd5b9f2b2
[2/2] drm/imagination: Reuse layout check macros for MIPS FW structures
commit: 173dceaed68eef074b77278bd92e6fdb4e09606d
Best regards,
--
Alessio Belle <alessio.belle@imgtec.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-08-03 10:30 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-29 14:57 [PATCH 0/2] drm/imagination: Tidy-up firmware interface checks Alessio Belle
2026-07-29 14:57 ` [PATCH 1/2] drm/imagination: Move all FW interface check macros to pvr_checks.h Alessio Belle
2026-07-29 14:57 ` [PATCH 2/2] drm/imagination: Reuse layout check macros for MIPS FW structures Alessio Belle
2026-08-03 6:41 ` [PATCH 0/2] drm/imagination: Tidy-up firmware interface checks Brajesh Gupta
2026-08-03 10:29 ` Alessio Belle
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®