Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: dma: chan_blen_transfer: test breaks if DMA cannot access flash #75125

Closed
mathieuchopstm opened this issue Jun 27, 2024 · 2 comments · Fixed by #75245
Closed

tests: dma: chan_blen_transfer: test breaks if DMA cannot access flash #75125

mathieuchopstm opened this issue Jun 27, 2024 · 2 comments · Fixed by #75245
Assignees
Labels
area: DMA Direct Memory Access area: Tests Issues related to a particular existing or missing test bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug

Comments

@mathieuchopstm
Copy link
Collaborator

Describe the bug

In tests/drivers/dma/chan_blen_transfer, the tx_data buffer is declared const:

static __aligned(32) const char tx_data[] = "It is harder to be kind than to be wise........";

As a result, this buffer is placed in .rodata and ends up in FLASH region. This causes the test to fail on SoCs equipped with a DMA controller that cannot access flash memory, such as STM32WB09 MCUs.

Expected behavior
Test should succeed on SoCs with a DMA as long as it can perform memory -> memory (i.e., RAM -> RAM) transfers, regardless of flash -> memory transfer capabilities.

A possible fix is to remove the const qualifier on tx_data - without the qualifier, the buffer seems to be placed in RAM, and the test succeeds.

Logs and console output

Test log:

Running TESTSUITE dma_m2m
===================================================================
START - test_tst_dma0_m2m_chan0_burst16
Preparing DMA Controller: Name=dmamux@48800000, Chan_ID=7, BURST_LEN=2
Starting the transfer


    Assertion failed at WEST_TOPDIR/zephyr/tests/drivers/dma/chan_blen_transfer/src/test_dma.c:137: dma_m2m_test_tst_dma0_m2m_chan0_burst16: (test_task(dma, CONFIG_DMA_TRANSFER_CHANNEL_NR_0, 16) == TC_PASS) is false

 FAIL - test_tst_dma0_m2m_chan0_burst16 in 2.028 seconds
===================================================================
START - test_tst_dma0_m2m_chan0_burst8
Preparing DMA Controller: Name=dmamux@48800000, Chan_ID=7, BURST_LEN=1
Starting the transfer
E: dma stream 7 is busy.
E: cannot configure the dmamux.
ERROR: transfer

    Assertion failed at WEST_TOPDIR/zephyr/tests/drivers/dma/chan_blen_transfer/src/test_dma.c:137: dma_m2m_test_tst_dma0_m2m_chan0_burst8: (test_task(dma, CONFIG_DMA_TRANSFER_CHANNEL_NR_0, 8) == TC_PASS) is false

 FAIL - test_tst_dma0_m2m_chan0_burst8 in 0.034 seconds
===================================================================
START - test_tst_dma0_m2m_chan1_burst16
Preparing DMA Controller: Name=dmamux@48800000, Chan_ID=6, BURST_LEN=2
Starting the transfer


    Assertion failed at WEST_TOPDIR/zephyr/tests/drivers/dma/chan_blen_transfer/src/test_dma.c:137: dma_m2m_test_tst_dma0_m2m_chan1_burst16: (test_task(dma, CONFIG_DMA_TRANSFER_CHANNEL_NR_1, 16) == TC_PASS) is false

 FAIL - test_tst_dma0_m2m_chan1_burst16 in 2.028 seconds
===================================================================
START - test_tst_dma0_m2m_chan1_burst8
Preparing DMA Controller: Name=dmamux@48800000, Chan_ID=6, BURST_LEN=1
Starting the transfer
E: dma stream 6 is busy.
E: cannot configure the dmamux.
ERROR: transfer

    Assertion failed at WEST_TOPDIR/zephyr/tests/drivers/dma/chan_blen_transfer/src/test_dma.c:137: dma_m2m_test_tst_dma0_m2m_chan1_burst8: (test_task(dma, CONFIG_DMA_TRANSFER_CHANNEL_NR_1, 8) == TC_PASS) is false

 FAIL - test_tst_dma0_m2m_chan1_burst8 in 0.034 seconds
===================================================================
TESTSUITE dma_m2m failed.

------ TESTSUITE SUMMARY START ------

SUITE FAIL -   0.00% [dma_m2m]: pass = 0, fail = 4, skip = 0, total = 4 duration = 4.124 seconds
 - FAIL - [dma_m2m.test_tst_dma0_m2m_chan0_burst16] duration = 2.028 seconds
 - FAIL - [dma_m2m.test_tst_dma0_m2m_chan0_burst8] duration = 0.034 seconds
 - FAIL - [dma_m2m.test_tst_dma0_m2m_chan1_burst16] duration = 2.028 seconds
 - FAIL - [dma_m2m.test_tst_dma0_m2m_chan1_burst8] duration = 0.034 seconds

------ TESTSUITE SUMMARY END ------

===================================================================
PROJECT EXECUTION FAILED

Test log, after removing the const storage qualifier of tx_data:

Running TESTSUITE dma_m2m
===================================================================
START - test_tst_dma0_m2m_chan0_burst16
Preparing DMA Controller: Name=dmamux@48800000, Chan_ID=7, BURST_LEN=2
Starting the transfer
DMA transfer done
It is harder to be kind than to be wise........
 PASS - test_tst_dma0_m2m_chan0_burst16 in 2.015 seconds
===================================================================
START - test_tst_dma0_m2m_chan0_burst8
Preparing DMA Controller: Name=dmamux@48800000, Chan_ID=7, BURST_LEN=1
Starting the transfer
DMA transfer done
It is harder to be kind than to be wise........
 PASS - test_tst_dma0_m2m_chan0_burst8 in 2.015 seconds
===================================================================
START - test_tst_dma0_m2m_chan1_burst16
Preparing DMA Controller: Name=dmamux@48800000, Chan_ID=6, BURST_LEN=2
Starting the transfer
DMA transfer done
It is harder to be kind than to be wise........
 PASS - test_tst_dma0_m2m_chan1_burst16 in 2.015 seconds
===================================================================
START - test_tst_dma0_m2m_chan1_burst8
Preparing DMA Controller: Name=dmamux@48800000, Chan_ID=6, BURST_LEN=1
Starting the transfer
DMA transfer done
It is harder to be kind than to be wise........
 PASS - test_tst_dma0_m2m_chan1_burst8 in 2.015 seconds
===================================================================
TESTSUITE dma_m2m succeeded

------ TESTSUITE SUMMARY START ------

SUITE PASS - 100.00% [dma_m2m]: pass = 4, fail = 0, skip = 0, total = 4 duration = 8.060 seconds
 - PASS - [dma_m2m.test_tst_dma0_m2m_chan0_burst16] duration = 2.015 seconds
 - PASS - [dma_m2m.test_tst_dma0_m2m_chan0_burst8] duration = 2.015 seconds
 - PASS - [dma_m2m.test_tst_dma0_m2m_chan1_burst16] duration = 2.015 seconds
 - PASS - [dma_m2m.test_tst_dma0_m2m_chan1_burst8] duration = 2.015 seconds

------ TESTSUITE SUMMARY END ------

===================================================================
PROJECT EXECUTION SUCCESSFUL
@mathieuchopstm mathieuchopstm added bug The issue is a bug, or the PR is fixing a bug area: DMA Direct Memory Access area: Tests Issues related to a particular existing or missing test labels Jun 27, 2024
@aescolar aescolar added the priority: low Low impact/importance bug label Jun 28, 2024
@teburd
Copy link
Collaborator

teburd commented Jun 28, 2024

Please send a patch with the const qualifier removed since you've already done the work and tested it.

There's still going to be some part that fails at some point though because not all RAM is equal for all DMAs and SoCs.

We should use instead dts defined memory attributes and buffer placement at some point https://docs.zephyrproject.org/latest/services/mem_mgmt/index.html#memory-attributes to provide correct static buffer placements (e.g. place the buffer in a region that is useable by DMA).

mathieuchopstm added a commit to mathieuchopstm/zephyr that referenced this issue Jul 1, 2024
This commit removes the const qualifier from TX (source) buffer
of the chan_blen_transfer DMA test to ensure it gets placed in
RAM rather than flash. This ensures the test can pass on hardware
where the DMA controller is unable to access flash.

Fixes zephyrproject-rtos#75125.

Signed-off-by: Mathieu Choplain <mathieu.choplain@st.com>
@mathieuchopstm
Copy link
Collaborator Author

PR open: #75245

aescolar pushed a commit that referenced this issue Jul 3, 2024
This commit removes the const qualifier from TX (source) buffer
of the chan_blen_transfer DMA test to ensure it gets placed in
RAM rather than flash. This ensures the test can pass on hardware
where the DMA controller is unable to access flash.

Fixes #75125.

Signed-off-by: Mathieu Choplain <mathieu.choplain@st.com>
AlienSarlak pushed a commit to AlienSarlak/zephyr that referenced this issue Jul 13, 2024
This commit removes the const qualifier from TX (source) buffer
of the chan_blen_transfer DMA test to ensure it gets placed in
RAM rather than flash. This ensures the test can pass on hardware
where the DMA controller is unable to access flash.

Fixes zephyrproject-rtos#75125.

Signed-off-by: Mathieu Choplain <mathieu.choplain@st.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: DMA Direct Memory Access area: Tests Issues related to a particular existing or missing test bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants