* [PATCH] drm/imagination: Reasoning code comments for Sparse warnings/errors
@ 2025-06-06 15:04 Alexandru Dadu
0 siblings, 0 replies; only message in thread
From: Alexandru Dadu @ 2025-06-06 15:04 UTC (permalink / raw)
To: Frank Binns, Matt Coster, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter
Cc: dri-devel, linux-kernel, Alexandru Dadu
Added code comments for the lines that might generate Sparse
warnings/errors.
The warnings/errors cannot be fixed with refactoring without masively
impacting the whole code implementation and/or they are incorrectly
generated by Sparse.
Signed-off-by: Alexandru Dadu <alexandru.dadu@imgtec.com>
---
| 28 ++++++++++++++++++++++
1 file changed, 28 insertions(+)
--git a/drivers/gpu/drm/imagination/pvr_rogue_fwif_check.h b/drivers/gpu/drm/imagination/pvr_rogue_fwif_check.h
index 51dc37e78f41d7bdf45d1f434dd1aa5b9eca700a..96a423f34c639581a745a7c0498b82d601680ca6 100644
--- a/drivers/gpu/drm/imagination/pvr_rogue_fwif_check.h
+++ b/drivers/gpu/drm/imagination/pvr_rogue_fwif_check.h
@@ -157,6 +157,20 @@ OFFSET_CHECK(struct rogue_fwif_frag_ctx_state, frag_reg_pm_deallocated_mask_stat
OFFSET_CHECK(struct rogue_fwif_frag_ctx_state, frag_reg_dm_pds_mtilefree_status, 4);
OFFSET_CHECK(struct rogue_fwif_frag_ctx_state, ctx_state_flags, 8);
OFFSET_CHECK(struct rogue_fwif_frag_ctx_state, frag_reg_isp_store, 12);
+
+/*
+ ******************************************************************************
+ * SPARSE warning reasoning: SIZE_CHECK(struct rogue_fwif_frag_ctx_state, 16)
+ ******************************************************************************
+ *
+ * The structure rogue_fwif_frag_ctx_state contains a flexible size field.
+ * The SIZE_CHECK will run a static_assert function over the structure and it
+ * will use 'sizeof' over a flexible structure.
+ * The implementation of the flexible size field is there by design and cannot
+ * be refactored in a way thet doesn't impact key features.
+ * To avoid having the sparse warning this argument can be used when triggering
+ * the sparse check from the build command "-Wno-sizeof-array-argument"
+ */
SIZE_CHECK(struct rogue_fwif_frag_ctx_state, 16);
OFFSET_CHECK(struct rogue_fwif_compute_ctx_state, ctx_state_flags, 0);
@@ -484,6 +498,20 @@ OFFSET_CHECK(struct rogue_fwif_hwrtdata, rtc_dev_addr, 264);
OFFSET_CHECK(struct rogue_fwif_hwrtdata, owner_geom_not_used_by_host, 272);
OFFSET_CHECK(struct rogue_fwif_hwrtdata, geom_caches_need_zeroing, 276);
OFFSET_CHECK(struct rogue_fwif_hwrtdata, cleanup_state, 320);
+
+/*
+ ******************************************************************************
+ * SPARSE error reasoning: SIZE_CHECK(struct rogue_fwif_hwrtdata, 384)
+ ******************************************************************************
+ *
+ * The structure rogue_fwif_hwrtdata contains different memory alignment
+ * attributes for its fields.
+ * The SIZE_CHECK will run a static_assert function over the structure to check
+ * the size. The compilation will fail if the SIZE_CHECK fails.
+ * SPARSE seems to treat the alignment attributes in a different way than the
+ * compilation does since the compilation is not failing.
+ * This SPARSE error over this line should be ignored if it pops up.
+ */
SIZE_CHECK(struct rogue_fwif_hwrtdata, 384);
OFFSET_CHECK(struct rogue_fwif_sync_checkpoint, state, 0);
---
base-commit: 217f80acfcf126b7d7d7b818c9bfea3c96fa85ec
change-id: 20250606-sprase-reasoning-comments-e48064532709
Best regards,
--
Alexandru Dadu <alexandru.dadu@imgtec.com>
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2025-06-06 15:05 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-06 15:04 [PATCH] drm/imagination: Reasoning code comments for Sparse warnings/errors Alexandru Dadu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).