Skip to content

rp2/rp2_dma: Reduce footprint of the DMA control fields table.#19014

Open
agatti wants to merge 1 commit intomicropython:masterfrom
agatti:rp2-dma-shrink
Open

rp2/rp2_dma: Reduce footprint of the DMA control fields table.#19014
agatti wants to merge 1 commit intomicropython:masterfrom
agatti:rp2-dma-shrink

Conversation

@agatti
Copy link
Copy Markdown
Contributor

@agatti agatti commented Mar 30, 2026

Summary

This PR shortens the amount of space taken by the DMA control fields table, and explicitly marks it as const.

The DMA fields info table used a full-size QSTR index value, and 9 bits of numeric information. Given that the QSTR index could be converted into a qstr_short_t, there is no fields spill outside a machine word boundary - albeit with having 7 unused bits but there isn't much that can be done for that. The effective structure size for each entry is halved, from 8 bytes down to 4.

Also, the structure is only read from, yet it was not marked as const. Marking the structure as constant did not help reduce the final size but at least correctly signals the compiler that no write accesses are possible.

This shrinks the RPI_PICO/RPI_PICO_W build by 56 bytes, with a similar size reduction for RPI_PICO2/RPI_PICO2_W.

Testing

The tests/ports/rp2/rp2_dma.py test was executed successfully on a RP2040.

Generative AI

I did not use generative AI tools when creating this PR.

This commit shortens the amount of space taken by the DMA control fields
table, and explicitly marks it as `const`.

The DMA fields info table used a full-size QSTR index value, and 9 bits
of numeric information.  Given that the QSTR index could be converted
into a `qstr_short_t`, there is no fields spill outside a machine word
boundary - albeit with having 7 unused bits but there isn't much that
can be done for that.  The effective structure size for each entry is
halved, from 8 bytes down to 4.

Also, the structure is only read from, yet it was not marked as `const`.
Marking the structure as constant did not help reduce the final size but
at least correctly signals the compiler that no write accesses are
possible.

This shrinks the RPI_PICO/RPI_PICO_W build by 56 bytes, with a similar
size reduction for RPI_PICO2/RPI_PICO2_W.

Signed-off-by: Alessandro Gatti <[email protected]>
@github-actions
Copy link
Copy Markdown

Code size report:

Reference:  esp32/boards/SEEED_XIAO_ESP32C6: Add new XIAO board definition. [2dc2e30]
Comparison: rp2/rp2_dma: Reduce footprint of the DMA control fields table. [merge of bb93522]
  mpy-cross:    +0 +0.000% 
   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
      esp32:    +0 +0.000% ESP32_GENERIC
     mimxrt:    +0 +0.000% TEENSY40
        rp2:   -56 -0.006% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:    +0 +0.000% VIRT_RV32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant