Skip to content

Conversation

@mariopaja
Copy link
Contributor

This change removes the on-stack copying and instead uses a pointer to the configuration to avoid unnecessary stack usage

struct k_fifo fifo_in;
struct k_fifo fifo_out;
struct video_buffer *vbuf;
struct stream dma;
Copy link
Contributor

@gautierg-st gautierg-st Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change (moving struct stream dma from config to data) should at least be explained in the commit message (maybe even be its own commit since it's more than changing . to ->).
Otherwise LGTM.

Copy link
Contributor

@mathieuchopstm mathieuchopstm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM except for the remark of @gautierg-st

This change removes the on-stack copying and instead
uses a pointer to the configuration to  avoid unnecessary
stack usage

Signed-off-by: Mario Paja <mariopaja@hotmail.com>
@mariopaja mariopaja force-pushed the st_remove_on_stack_dma_cfg branch from 007c79b to 5fca018 Compare December 8, 2025 16:19
@zephyrbot zephyrbot requested a review from ngphibang December 8, 2025 16:20
mathieuchopstm
mathieuchopstm previously approved these changes Dec 8, 2025
Copy link

@avolmat-st avolmat-st left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very minor point so I am also ok to approve it as is. Since dma pointer in introduced in the stm32_dma_init function, one of dma_cfg pointer can directly be retrieved via the dma pointer as done in all other places of that function.

* how to route callbacks.
*/
struct dma_config dma_cfg = config->dma.cfg;
struct dma_config *dma_cfg = &data->dma.cfg;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
struct dma_config *dma_cfg = &data->dma.cfg;
struct dma_config *dma_cfg = &dma->cfg;

Copy link
Contributor

@JarmouniA JarmouniA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This kind of change should be examined carefully, not saying it is wrong.
It's not just a matter of stack-usage, it's also a question of: Do we want the subsequent values assigned to the members of the stack-allocated struct to be setted globally, or just be passed to the functions called locally with the struct as an arg and then be forgotten?
Since the drivers in qst seem to be working fine without those values being setted globally (unless there are undiscovered bugs, or the values are setted elsewhere), I kind of question the need to set them in the global config/data struct.

This change moves the dma stream from _config to _data,
allowing direct reference the DMA stream rather than
duplicating it on the stack. Additionally, it aligns the
declaration to the other STM32 drivers.

Signed-off-by: Mario Paja <mariopaja@hotmail.com>
@mariopaja mariopaja requested a review from avolmat-st December 9, 2025 08:01
@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 9, 2025

@avolmat-st
Copy link

This kind of change should be examined carefully, not saying it is wrong. It's not just a matter of stack-usage, it's also a question of: Do we want the subsequent values assigned to the members of the stack-allocated struct to be setted globally, or just be passed to the functions called locally with the struct as an arg and then be forgotten? Since the drivers in qst seem to be working fine without those values being setted globally (unless there are undiscovered bugs, or the values are setted elsewhere), I kind of question the need to set them in the global config/data struct.

As far as the DCMI is concerned, anyway this structure stream is already part of the global structures and was finally only partially used. With that done, the globally allocated area is used instead of the stack, releasing pressure on the stack. Moreover, I do not see to have those values (which were stored in the stack before) in the global structure stream pointer so I am fine with this modification.

@fabiobaltieri fabiobaltieri merged commit f4cfd85 into zephyrproject-rtos:main Dec 10, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants