Skip to content

decoder: Add reader-side DATA_SYNC() barriers after MB-map polls - #163

Merged
harishdm merged 2 commits into
ittiam-systems:mainfrom
harishdm:datasync
Nov 26, 2026
Merged

harishdm merged 2 commits into
ittiam-systems:mainfrom
harishdm:datasync

Conversation

@harishdm

Copy link
Copy Markdown
Member

Add DATA_SYNC() immediately after CHECK_MB_MAP_BYTE succeeds in ih264d_decode_recon_tfr_nmb_thread(), ih264d_decode_slice_thread(), ih264d_check_mb_map_deblk(), and both wait loops in ih264d_recon_deblk_slice().

The writer paths (ih264d_parse_tfr_nmb() and
ih264d_decode_recon_tfr_nmb_thread()) already execute DATA_SYNC() before UPDATE_MB_MAP_MBNUM_BYTE to order MB metadata (pu2_slice_num_map, ps_frm_mb_info, slice info) and reconstructed pixels before setting the map flag. On weakly ordered architectures (ARMv8/ARMv7/RISC-V), a control dependency alone does not prevent speculative Load->Load reordering across the branch, allowing readers to observe stale payload data after seeing the flag set. The reader-side DATA_SYNC() completes the release/acquire pairing.

Bug: 587588029
Test: ctest

Add DATA_SYNC() immediately after CHECK_MB_MAP_BYTE succeeds in
ih264d_decode_recon_tfr_nmb_thread(), ih264d_decode_slice_thread(),
ih264d_check_mb_map_deblk(), and both wait loops in
ih264d_recon_deblk_slice().

The writer paths (ih264d_parse_tfr_nmb() and
ih264d_decode_recon_tfr_nmb_thread()) already execute DATA_SYNC()
before UPDATE_MB_MAP_MBNUM_BYTE to order MB metadata
(pu2_slice_num_map, ps_frm_mb_info, slice info) and reconstructed
pixels before setting the map flag. On weakly ordered architectures
(ARMv8/ARMv7/RISC-V), a control dependency alone does not prevent
speculative Load->Load reordering across the branch, allowing
readers to observe stale payload data after seeing the flag set.
The reader-side DATA_SYNC() completes the release/acquire pairing.

Bug: 587588029
Test: ctest
Change-Id: I1329d805415428559272d5258b51cf5759135454
… polls

Add DATA_SYNC() immediately after CHECK_MB_MAP_BYTE succeeds in
isvcd_decode_recon_tfr_nmb_thread() and isvcd_decode_slice_thread(),
and after observing ps_dec->cur_dec_mb_num advance (bs_mb_grp > 0)
in the 2-core BS/deblocking loop of isvcd_video_decode().

The writer paths (ih264d_parse_tfr_nmb() and
isvcd_decode_recon_tfr_nmb_thread()) already execute DATA_SYNC()
before updating pu1_dec_mb_map, pu1_recon_mb_map, and cur_dec_mb_num
to order MB metadata (pu2_slice_num_map, ps_frm_mb_info,
ps_svc_frm_mb_info, slice info), residual NNZ (pu2_frm_res_luma_csbp),
and reconstructed pixels before publishing completion. On weakly
ordered architectures (ARMv8/ARMv7/RISC-V), a control dependency
alone does not prevent speculative Load->Load reordering across the
branch, allowing readers to observe stale payload data after seeing
the flag or counter updated. The reader-side DATA_SYNC() completes
the release/acquire pairing.

Bug: 587588029
Test: svcdec 1-core vs 2-core bit-exact check on 2-layer CAVLC/CABAC streams
Change-Id: I8f3c6a9e2b4d7015a6c8e4f91b3d2075c9e1a4b8
@harishdm

Copy link
Copy Markdown
Member Author

This is verified by two different teams independently. So will go ahead and land this.

@harishdm
harishdm merged commit 4af87ce into ittiam-systems:main Nov 26, 2026
10 checks passed
@harishdm
harishdm deleted the datasync branch November 26, 2026 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant