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

kernel: atomics: support for 64-bit atomic operations #39531

Conversation

cfriedt
Copy link
Member

@cfriedt cfriedt commented Oct 19, 2021

This change adds support for 64-bit atomic operations for any machine where sizeof(long) == 8.

Fixes #39530
Depends-on

@github-actions github-actions bot added area: API Changes to public APIs area: Kernel area: Tests Issues related to a particular existing or missing test labels Oct 19, 2021
@cfriedt cfriedt force-pushed the issues/39530/kernel-atomics-support-for-64-bit-atomic-operations branch from ce9059b to 092f615 Compare October 19, 2021 00:40
@cfriedt cfriedt self-assigned this Oct 19, 2021
@cfriedt cfriedt force-pushed the issues/39530/kernel-atomics-support-for-64-bit-atomic-operations branch from 092f615 to 763c900 Compare October 19, 2021 02:13
@cfriedt cfriedt force-pushed the issues/39530/kernel-atomics-support-for-64-bit-atomic-operations branch 6 times, most recently from 42debc6 to 94d9d22 Compare October 19, 2021 11:26
include/sys/atomic.h Outdated Show resolved Hide resolved
@cfriedt cfriedt force-pushed the issues/39530/kernel-atomics-support-for-64-bit-atomic-operations branch 3 times, most recently from 0ab2813 to eb4f678 Compare October 19, 2021 12:52
@cfriedt cfriedt marked this pull request as ready for review October 19, 2021 12:52
@cfriedt
Copy link
Member Author

cfriedt commented Oct 19, 2021

This change does not account for the case where CONFIG_64BIT=n but the architecture does support 64-bit operations. That may be the case with something like the x32 ABI.

@cfriedt cfriedt marked this pull request as draft October 19, 2021 15:16
@cfriedt cfriedt force-pushed the issues/39530/kernel-atomics-support-for-64-bit-atomic-operations branch from eb4f678 to 677d3e7 Compare October 20, 2021 19:57
@cfriedt
Copy link
Member Author

cfriedt commented Nov 14, 2021

rebased

With this change, `atomic_t` is 32-bit for 32-bit architectures
and 64-bit for 64-bit architectures. More specifically,
`sizeof(atomic_t) == sizeof(long)`.

Fixes zephyrproject-rtos#39530

Signed-off-by: Christopher Friedt <[email protected]>
By redefining `atomic_t` as `long`, the type is 32-bit on
32-bit architectures and 64-bit on 64-bit architectures.

Signed-off-by: Christopher Friedt <[email protected]>
The print specifier for `atomic_t` should be updated
to `%ld`, `%lu`, or `%lx` to account for the type
change of `atomic_t` to `long`.

Signed-off-by: Christopher Friedt <[email protected]>
This driver aliases a regular `int` to `atomic_t` but that
should be updated to `long` with the change to `atomic_t`.

Added a comment to highlight that the variable was aliased.

Signed-off-by: Christopher Friedt <[email protected]>
With the change of `atomic_t` from `int` to `long` there
were a few places where there was some type aliasing
occuring.

Update CMSIS to use `atomic_t` rather than `int` for all
atomic operations.

Signed-off-by: Christopher Friedt <[email protected]>
@cfriedt cfriedt force-pushed the issues/39530/kernel-atomics-support-for-64-bit-atomic-operations branch from e6babdc to 7d4c88c Compare November 14, 2021 18:49
@cfriedt
Copy link
Member Author

cfriedt commented Nov 14, 2021

updated subsys/bluetooth/audio/otc.c to use %lu print format specifier

The audio/sof Zephyr module needed print specifiers updated
for the transition from `int` to `long` for `atomic_t`
which supports 32-bit atomics and also 64-bit atomics.

Signed-off-by: Christopher Friedt <[email protected]>
This change updates the atomic tests to validate 32-bits on
32-bit architectures and 64-bits on 64-bit architectures.

Signed-off-by: Christopher Friedt <[email protected]>
Atomics changed from `int` to `long` and print format specifiers
must be updated as well.

Signed-off-by: Christopher Friedt <[email protected]>
@cfriedt cfriedt force-pushed the issues/39530/kernel-atomics-support-for-64-bit-atomic-operations branch from 7d4c88c to 78ff65c Compare November 14, 2021 23:50
@github-actions github-actions bot removed the DNM This PR should not be merged (Do Not Merge) label Nov 14, 2021
@nashif nashif merged commit 6735f11 into zephyrproject-rtos:main Nov 15, 2021
cfriedt added a commit to cfriedt/zephyr that referenced this pull request Nov 16, 2021
Previously, a `uint32_t` was aliased as an `atomic_t`. However,
with zephyrproject-rtos#39531, `atomic_t` is now a `long` under the hood, which
is 64-bit on 64-bit platforms.

Fixes zephyrproject-rtos#40369

Signed-off-by: Christopher Friedt <[email protected]>
cfriedt added a commit to cfriedt/zephyr that referenced this pull request Nov 16, 2021
Previously, a `uint32_t` was aliased as an `atomic_t`. However,
with zephyrproject-rtos#39531, `atomic_t` is now a `long` under the hood, which
is 64-bit on 64-bit platforms.

Fixes zephyrproject-rtos#40369

Signed-off-by: Christopher Friedt <[email protected]>
carlescufi pushed a commit that referenced this pull request Nov 17, 2021
Previously, a `uint32_t` was aliased as an `atomic_t`. However,
with #39531, `atomic_t` is now a `long` under the hood, which
is 64-bit on 64-bit platforms.

Fixes #40369

Signed-off-by: Christopher Friedt <[email protected]>
carlescufi pushed a commit that referenced this pull request Nov 17, 2021
Previously, a `uint32_t` was aliased as an `atomic_t`. However,
with #39531, `atomic_t` is now a `long` under the hood, which
is 64-bit on 64-bit platforms.

Fixes #40369

Signed-off-by: Christopher Friedt <[email protected]>
@cfriedt cfriedt added the backport v2.7-branch Request backport to the v2.7-branch label Jul 18, 2022
cfriedt added a commit to cfriedt/zephyr that referenced this pull request Jul 21, 2022
Previously, a `uint32_t` was aliased as an `atomic_t`. However,
with zephyrproject-rtos#39531, `atomic_t` is now a `long` under the hood, which
is 64-bit on 64-bit platforms.

Fixes zephyrproject-rtos#40369

Signed-off-by: Christopher Friedt <[email protected]>
@cfriedt cfriedt deleted the issues/39530/kernel-atomics-support-for-64-bit-atomic-operations branch July 22, 2022 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kernel: atomics: support for 64-bit atomic operations
7 participants