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

drivers: i2c: stm32: don't manage cache aside DMA support #87681

Merged
merged 1 commit into from
Mar 27, 2025

Conversation

etienne-lms
Copy link
Collaborator

@etienne-lms etienne-lms commented Mar 26, 2025

Commit 42c3a78 ("i2c: stm32: Add cache memory support") introduced a call to mem_attr_check_buf() in STM32 I2C driver i2c_ll_stm32_v2.c without adding the config dependency on CONFIG_MEM_ATTR needed. Fix STM32 I2C Kconfig accordingly.
By the way, select CONFIG_CACHE_MANAGEMENT and CONFIG_MEM_ATTR upon CONFIG_DCACHE=y instead of CONFIG_CPU_HAS_DCACHE to better relate to how STM32 I2C driver is implemented.

(edited)

Fix STM32 I2C driver to not call cache management related functions when DMA is not used. This change fixes an issue introduced by commit 42c3a78 ("i2c: stm32: Add cache memory support"). The issue makes boards embedding this driver with both CONFIG_I2C_STM32_V2_DMA and CONFIG_ARCH_MPU disabled to fail to build with an error trace message like the below:

  .../i2c_ll_stm32_v2.c:701: undefined reference to `mem_attr_check_buf'

Fixes: 42c3a78

@etienne-lms
Copy link
Collaborator Author

@sgilbert182, could you have a look at this change. Some build currently fail on STM32 I2C driver and seem related to #81814.

@sgilbert182
Copy link
Contributor

@sgilbert182, could you have a look at this change. Some build currently fail on STM32 I2C driver and seem related to #81814.

Will do, give me an hour or so

@etienne-lms
Copy link
Collaborator Author

For info, my patch was not accurate enough. I've updated it.

@etienne-lms
Copy link
Collaborator Author

etienne-lms commented Mar 26, 2025

By the way, @JarmouniA, looking at other STM32 drivers, I saw some other equivalent potential issues in drivers/adc/adc_stm32.c, drivers/spi/spi_ll_stm32.c and drivers/serial/uart_stm32.c that are hidden by the fact CONFIG_MEM_ATTR is default enabled when CONFIG_ARM_MPU=y which seems the case for the SoCs embedding these drivers. I wonder if equivalent explicit dependencies are worth being also defined in the Kconfig files relative to these drivers. What do you think?

@etienne-lms
Copy link
Collaborator Author

Comment addressed.

@JarmouniA
Copy link
Collaborator

looking at other STM32 drivers, I saw some other equivalent potential issues in drivers/adc/adc_stm32.c, drivers/spi/spi_ll_stm32.c and drivers/serial/uart_stm32.c that are hidden by the fact CONFIG_MEM_ATTR is default enabled when CONFIG_ARM_MPU=y which seems the case for the SoCs embedding these drivers.

I don't know if that's really problematic for the time being, since AFAIK STM32 targets that have DCache support (mainly CM7) in Zephyr also have an ARM MPU & it's enabled at the board level.

I wonder if equivalent explicit dependencies are worth being also defined in the Kconfig files relative to these drivers. What do you think?

Maybe, to avoid potential issues later down the road.

@etienne-lms
Copy link
Collaborator Author

@erwango, may I ask your feedback on this change? It's needed to fix issues currently reported by CI tests on various P-Rs.

@etienne-lms
Copy link
Collaborator Author

I wonder if equivalent explicit dependencies are worth being also defined in the Kconfig files relative to these drivers. What do you think?

Maybe, to avoid potential issues later down the road.

FYI I've created #87757.

Fix STM32 I2C driver to not call cache management related functions
when DMA is not used. This change fixes an issue introduced by
commit 42c3a78 ("i2c: stm32: Add cache memory support"). The issue
makes boards embedding this driver with both CONFIG_I2C_STM32_V2_DMA
and CONFIG_ARCH_MPU disabled to fail to build with an error trace message
like the below:
   .../i2c_ll_stm32_v2.c:701: undefined reference to `mem_attr_check_buf'

Fixes: 42c3a78
Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
@etienne-lms
Copy link
Collaborator Author

As discussed above, I restricted this P-R to a change in driver source file.
Cleaning the Kconfig file is still prefer IMHO but I've moved it to #87757 so that the CI tests issue gets fixed quicker.

Copy link
Member

@erwango erwango left a comment

Choose a reason for hiding this comment

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

Nit: Update PR title and description

@erwango erwango added the Hotfix Fix for issues blocking development, i.e. CI issues, tests failing in CI, etc. label Mar 27, 2025
@etienne-lms etienne-lms changed the title drivers: i2c: stm32: fix dependency on CONFIG_MEM_ATTR drivers: i2c: stm32: don't manage cache aside DMA support Mar 27, 2025
Copy link
Collaborator

@pillo79 pillo79 left a comment

Choose a reason for hiding this comment

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

Thanks for the hotfix!

@kartben kartben merged commit d0d8fa4 into zephyrproject-rtos:main Mar 27, 2025
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: I2C Hotfix Fix for issues blocking development, i.e. CI issues, tests failing in CI, etc. platform: STM32 ST Micro STM32
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants