Repository navigation
Parse driver config files only while their drivers are configured - #66
Merged
Merged
Conversation
The config tree walk parsed every file in /configs and kept its parsed INI
until the last driver it declares was created. A parsed INI costs several
times the file size in small heap blocks (three allocations per key), and
the walk happens before any driver runs - before dmfmc brings up external
RAM. On the STM32F746G-DISCO the board's driver configs come to ~54 KB of
parsed INI in ~600 blocks of at most 32 bytes; measured when dmeth failed,
the main heap had 16 KB free in 1444 pieces, the largest 136 bytes. Every
module loaded meanwhile (dmtty, dmclk, dmfmc, ...) spilled into the 64 KB
"dma" heap, and dmeth then found no room for its 12 KB descriptor rings
("Out of memory allocating ETH descriptor rings from the 'dma' heap") -
adding any driver configuration (a display, a touch panel) tipped it over.
Now the walk parses a file only to queue its drivers (section, driver
name, driver_order) and releases it right away, keeping just the path.
The file is parsed again when the first of its drivers is created, stays
parsed while the following drivers come from the same file, and is
released as soon as a driver of another file is configured or its last
driver is done - at most one file is parsed at a time.
Verified on the STM32F746G-DISCO with the LCD (dmlcdtft), I2C3 (dmi2c)
and touch panel (dmft5336) configs added: Ethernet comes up again (DHCP)
next to the LCD, the microSD and the touch panel; boot time unchanged. In
Renode the board boots and the touch panel test passes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The config tree walk parsed every file in /configs and kept its parsed INI until the last driver it declares was created. A parsed INI costs several times the file size in small heap blocks (three allocations per key), and the walk happens before any driver runs - before dmfmc brings up external RAM. On the STM32F746G-DISCO the board's driver configs come to ~54 KB of parsed INI in ~600 blocks of at most 32 bytes; measured when dmeth failed, the main heap had 16 KB free in 1444 pieces, the largest 136 bytes. Every module loaded meanwhile (dmtty, dmclk, dmfmc, ...) spilled into the 64 KB "dma" heap, and dmeth then found no room for its 12 KB descriptor rings ("Out of memory allocating ETH descriptor rings from the 'dma' heap") - adding any driver configuration (a display, a touch panel) tipped it over.
Now the walk parses a file only to queue its drivers (section, driver name, driver_order) and releases it right away, keeping just the path. The file is parsed again when the first of its drivers is created, stays parsed while the following drivers come from the same file, and is released as soon as a driver of another file is configured or its last driver is done - at most one file is parsed at a time.
Verified on the STM32F746G-DISCO with the LCD (dmlcdtft), I2C3 (dmi2c) and touch panel (dmft5336) configs added: Ethernet comes up again (DHCP) next to the LCD, the microSD and the touch panel; boot time unchanged. In Renode the board boots and the touch panel test passes.