-
Notifications
You must be signed in to change notification settings - Fork 7.4k
drivers: clock_control: stm32: don't enable RUNTIME_NMI
all the time
#90609
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: clock_control: stm32: don't enable RUNTIME_NMI
all the time
#90609
Conversation
The Clock Security System (CSS) feature signals failure of an external oscillator by triggering an NMI. As such, when this feature is enabled, RUNTIME_NMI must also be enabled such that the NMI handler can be modified to point to the appropriate function. The STM32 clock control Kconfig checks whether the CSS has been enabled in Device Tree, and forcefully selects RUNTIME_NMI if enabled since the driver code will require it. However, the check has been implemented improperly: "dt_nodelabel_has_prop" was used instead of "dt_nodelabel_bool_prop", an error similar to using DT_NODE_HAS_PROP() instead of DT_PROP() in C code. Since the property always exists, as long as the HSE is enabled, the RUNTIME_NMI option is always select'ed, even if not actually required. Use the correct Kconfig function to ensure RUNTIME_NMI is select'ed only when it is required, instead of whenever HSE is enabled regardless of CSS. Signed-off-by: Mathieu Choplain <mathieu.choplain@st.com>
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Despite your change is consistent, I don't understand why the previous implementation led to false positive detection of HSE CSS enable.
The previous implementation checked both clk_hse
node being enabled and the node having property css-enabled
.
zephyr/include/zephyr/devicetree.h Lines 3771 to 3785 in 21b20de
Emphasis mine: To get a boolean property's truth value, use DT_PROP(node_id, prop) instead. My understanding is that boolean properties are treated specially: a regular property is !EXISTS if not present in DTS, and EXISTS if present ( You can verify locally that
and running |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, if 'prop' exists inside the node
means the property is meaningful for that node, not it is set in the targeted node.
Quite subtle. Thanks for the details.
The Clock Security System (CSS) feature signals failure of an external oscillator by triggering an NMI. As such, when this feature is enabled,
RUNTIME_NMI
must also be enabled such that the NMI handler can be modified to point to the appropriate function.The STM32 clock control Kconfig checks whether the CSS has been enabled in Device Tree, and forcefully selects
RUNTIME_NMI
if enabled since the driver code will require it. However, the check has been implemented improperly:dt_nodelabel_has_prop
was used instead ofdt_nodelabel_bool_prop
, an error similar to usingDT_NODE_HAS_PROP()
instead ofDT_PROP()
in C code.Since the property always exists, as long as the HSE is enabled, the
RUNTIME_NMI
option is always select'ed, even if not actually required.Use the correct Kconfig function to ensure RUNTIME_NMI is select'ed only when it is required, instead of whenever HSE is enabled regardless of CSS.