drm/imagination: Reasoning code comments for Sparse warnings/errors
Subsystems (3)
PATCH 1/1 drm/imagination: Reasoning code comments for Sparse warnings/errors
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 <[email protected]>
--- drivers/gpu/drm/imagination/pvr_rogue_fwif_check.h | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+)
drivers/gpu/drm/imagination/pvr_rogue_fwif_check.h +28 -0
@@ -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,
Signature · 1 line
Alexandru Dadu <[email protected]>