Skip to content

Mark BBBuffer as #[repr(C)] to support alignment#93

Closed
mciantyre wants to merge 1 commit intojamesmunns:mainfrom
mciantyre:reprc-bbbuffer
Closed

Mark BBBuffer as #[repr(C)] to support alignment#93
mciantyre wants to merge 1 commit intojamesmunns:mainfrom
mciantyre:reprc-bbbuffer

Conversation

@mciantyre
Copy link

Some DMA engines and peripherals require that buffers are precisely
aligned. This commit marks BBBuffer as #[repr(C)] so that the buffer is
the first member of the struct. With this guarantee, we can align the
BBBuffer for our hardware-assisted transfers. Updated documentation
shows one way to align the buffer.

Tested on an i.MX RT processor, where the DMA engine requires circular
buffers that are power-of-two sized and aligned. If I can't align my
BBBuffer, I'll treat the BBBuffer as linear memory and schedule multiple
transfers to handle split_read wraparound. I'm happy to go this route if
this commit isn't appropriate for bbqueue.

Some DMA engines and peripherals require that buffers are precisely
aligned. This commit marks BBBuffer as #[repr(C)] so that the buffer is
the first member of the struct. With this guarantee, we can align the
BBBuffer for our hardware-assisted transfers. Updated documentation
shows one way to align the buffer.

Tested on an i.MX RT processor, where the DMA engine requires circular
buffers that are power-of-two sized and aligned. If I can't align my
BBBuffer, I'll treat the BBBuffer as linear memory and schedule multiple
transfers to handle split_read wraparound. I'm happy to go this route if
this commit isn't appropriate for bbqueue.
@jamesmunns
Copy link
Owner

Hey @mciantyre, sorry for letting this get stale, but bbq2's algorithm, which was merged in #110, allows you more control of the storage of the buffer. If this isn't sufficient, please open an issue and tag me. Thanks!

@jamesmunns jamesmunns closed this Jan 4, 2026
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.

2 participants