-
Notifications
You must be signed in to change notification settings - Fork 321
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
Rename IS_ALIGN() to SOF_IS_ALIGN() #8755
Conversation
This reverts commit 0a3b816. Opportunistic, `#ifndef` definitions make macro troubleshooting even more of a nightmare than it already is. https://docs.zephyrproject.org/latest/contribute/coding_guidelines/index.html#rule-a-3-macro-name-collisions forbids #ifndef in Zephyr. Signed-off-by: Marc Herbert <[email protected]>
This is the simplest, cheapest and safest to avoid the collision with the incoming Zephyr macro IS_ALIGN() submitted in zephyrproject-rtos/zephyr#67243 As SOF depends on Zephyr, most SOF symbols should be prefixed SOF_ or something specific. This is compliant with: https://docs.zephyrproject.org/latest/contribute/coding_guidelines/index.html#rule-a-3-macro-name-collisions Signed-off-by: Marc Herbert <[email protected]>
Failures to compile with the Zephyr main branch are known and unrelated:
They're caused by backwards-incompatible change: |
Unrelated pause-resume failure in ACE https://sof-ci.01.org/sofpr/PR8755/build1982/devicetest/index.html . pause-resume is not reliable right now. Maybe #8651? Unrelated checkpatch https://github.com/thesofproject/sof/actions/runs/7563103579/job/20594859309?pr=8755 complains about the URL being too long. Everything else green. |
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.
We want to use native Zephyr APIs and this seems to be taking us away from it
#define IS_ALIGNED(size, alignment) ((size) % (alignment) == 0) | ||
#endif |
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.
if zephyrproject-rtos/zephyr#67243 happens to be merged before this (yes, I know that it's currently blocked) and we move to a Zephyr version after it, this would break compilation. Why not just merge these two commits?
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.
we probably should hold of until we can get the Zephyr interface merged in. We have the SMP interface in flight (plus the regression), so the air is getting too thick with incompatible combinations.
@@ -633,7 +633,7 @@ static int dai_set_sg_config(struct dai_data *dd, struct comp_dev *dev, uint32_t | |||
period_count); | |||
buf_size = period_count * period_bytes; | |||
do { | |||
if (IS_ALIGNED(buf_size, max_block_count)) { | |||
if (SOF_IS_ALIGNED(buf_size, max_block_count)) { |
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.
is it the plan then after zephyrproject-rtos/zephyr#67243 is merged to move to the "proper" Zephyr-provided IS_ALIGNED()
and to rename back?
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.
I think an alternative would be to take the Zephyr change with IS_ALIGNED in, then add IS_ALIGNED definition only for xtos builds in SOF, and call it a day.
The current ifdef can carry us until then.
Or we merge this, but I agree this is going against our long term plans. We want to use native Zephyr interfaces in generic SOF code whenever possible (e.g. #5794).
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.
I think this we should consider also moving this to rtos abstraction and keep using native interfaces.
#define IS_ALIGNED(size, alignment) ((size) % (alignment) == 0) | ||
#endif |
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.
we probably should hold of until we can get the Zephyr interface merged in. We have the SMP interface in flight (plus the regression), so the air is getting too thick with incompatible combinations.
@@ -633,7 +633,7 @@ static int dai_set_sg_config(struct dai_data *dd, struct comp_dev *dev, uint32_t | |||
period_count); | |||
buf_size = period_count * period_bytes; | |||
do { | |||
if (IS_ALIGNED(buf_size, max_block_count)) { | |||
if (SOF_IS_ALIGNED(buf_size, max_block_count)) { |
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.
I think an alternative would be to take the Zephyr change with IS_ALIGNED in, then add IS_ALIGNED definition only for xtos builds in SOF, and call it a day.
The current ifdef can carry us until then.
Or we merge this, but I agree this is going against our long term plans. We want to use native Zephyr interfaces in generic SOF code whenever possible (e.g. #5794).
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.
We want to use native Zephyr APIs and this seems to be taking us away from it
In theory yes. In practice these are 4 lines in 2 files.
Every time we want to use a "Zephyr API", we have to implement some indirection logic for XTOS that we (Intel) can't test any more.
Calling this one-liner macro a "Zephyr API" is blowing it out of proportion.
I'm aware the "air is getting thick" and this is precisely why this PR is the simplest, cheapest and safest solution in the short term. I understand and agree in general but this particular example is just 4 lines; let's not over-engineer it.
4 lines including... 3 lines in unused and never compiled I think we have much bigger problems to solve than making this one-liner macro used once "API policy compliant" |
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.
Sorry, no, I don't like this. I really don't think we should add a SOF_*
version for every Zephyr macro. We want to use them directly and for non-Zephyr builds define them in compatibility headers.
I forgot how many times I wrote "just this one, with have bigger problems"
Agreed, please send a better (and tested) PR since you have the time. |
After a chat with @lyakh I realized I forgot to explicit the main concern behind this PR: if the SOF definition is guarded with the (evil) I admit I didn't check whether inclusion order this an actual problem right now, it was much faster (and safer) to submit this PR. Actually testing this inclusion order problem could require testing multiple defconfig variations again. Even if not today, the inclusion order could very easily become a real problem in any future refactoring. Hence this dead simple PR to move on with our lives. |
@marc-hb no, there's no order problem there. The header is already included before the Lines 17 to 24 in 0a3b816
|
OK, let's not worry then. |
This is the simplest, cheapest and safest to avoid the collision with
the incoming Zephyr macro IS_ALIGN() submitted in
zephyrproject-rtos/zephyr#67243
As SOF depends on Zephyr, most SOF symbols should be prefixed SOF_ or
something specific.
This is compliant with:
https://docs.zephyrproject.org/latest/contribute/coding_guidelines/index.html#rule-a-3-macro-name-collisions
Signed-off-by: Marc Herbert [email protected]