<feed xmlns='http://www.w3.org/2005/Atom'>
<title>opensbi.git/lib/sbi/riscv_atomic.c, branch master</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.</subtitle>
<id>http://cgit.235523.xyz/opensbi.git/atom/lib/sbi/riscv_atomic.c?h=master</id>
<link rel='self' href='http://cgit.235523.xyz/opensbi.git/atom/lib/sbi/riscv_atomic.c?h=master'/>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/opensbi.git/'/>
<updated>2026-03-10T05:17:23Z</updated>
<entry>
<title>lib: Use proper add opcode on RV32 with Zalrsc</title>
<updated>2026-03-10T05:17:23Z</updated>
<author>
<name>Marti Alonso</name>
<email>martialonso11@gmail.com</email>
</author>
<published>2026-03-01T20:54:21Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/opensbi.git/commit/?id=b5348006e98077076a0b1a690c3a9f63c7151a4b'/>
<id>urn:sha1:b5348006e98077076a0b1a690c3a9f63c7151a4b</id>
<content type='text'>
The addw opcode is only defined in RV64, which produces 32-bit results.
On RV32, the default add opcode already produces 32-bit results.

Fixes: 995f226f3f33 ("lib: Emit lr and sc instructions based on -march flags")
Signed-off-by: Marti Alonso &lt;martialonso11@gmail.com&gt;
Reviewed-by: Anup Patel &lt;anup@brainfault.org&gt;
Link: https://lore.kernel.org/r/20260301205421.2074835-1-martialonso11@gmail.com
Signed-off-by: Anup Patel &lt;anup@brainfault.org&gt;
</content>
</entry>
<entry>
<title>lib: atomics: fix AMO test macros</title>
<updated>2025-12-28T15:14:03Z</updated>
<author>
<name>Vladimir Kondratiev</name>
<email>vladimir.kondratiev@mobileye.com</email>
</author>
<published>2025-12-28T07:33:21Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/opensbi.git/commit/?id=f6fa62bd169e55f479b137da13ca83b27bb304a9'/>
<id>urn:sha1:f6fa62bd169e55f479b137da13ca83b27bb304a9</id>
<content type='text'>
The "RISC-V C API" [1] defines architecture extension test macros
says naming rule for the test macros is __riscv_&lt;ext_name&gt;, where
&lt;ext_name&gt; is all lower-case.

Three extensions dealing with atomics implementation are:
  "zaamo" consists of AMO instructions,
  "zalrsc" - LR/SC,
  "a" extension means both "zaamo" and "zalrsc"
Built-in test macros are __riscv_a, __riscv_zaamo and __riscv_zalrsc.
Alternative to the __riscv_a macro name, __riscv_atomic, is deprecated.

Use correct test macro __riscv_zaamo for the AMO variant of atomics.
It used to be __riscv_atomic that is both deprecated and incorrect
because it tests for the "a" extension; i.e. both "zaamo" and "zalrsc"
If ISA enables only zaamo but not zalrsc, code as it was would not compile.

Older toolchains may have neither __riscv_zaamo nor __riscv_zalrsc, so
query __riscv_atomic - it should be treated as both __riscv_zaamo and
__riscv_zalrsc, in all present cases __riscv_zaamo is more favorable
so take is as alternative for __riscv_zaamo

[1] https://github.com/riscv-non-isa/riscv-c-api-doc

Signed-off-by: Vladimir Kondratiev &lt;vladimir.kondratiev@mobileye.com&gt;
Reviewed-by: Anup Patel &lt;anup@brainfault.org&gt;
Link: https://lore.kernel.org/r/20251228073321.1533844-1-vladimir.kondratiev@mobileye.com
Signed-off-by: Anup Patel &lt;anup@brainfault.org&gt;
</content>
</entry>
<entry>
<title>lib: Emit lr and sc instructions based on -march flags</title>
<updated>2025-03-28T13:22:05Z</updated>
<author>
<name>Chao-ying Fu</name>
<email>icebergfu@gmail.com</email>
</author>
<published>2025-02-26T01:47:27Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/opensbi.git/commit/?id=995f226f3f335864d2fca6254af32fa7ab0162e6'/>
<id>urn:sha1:995f226f3f335864d2fca6254af32fa7ab0162e6</id>
<content type='text'>
When -march=rv64im_zalrsc_zicsr is used, provide atomic operations
and locks using lr and sc instructions only.

Signed-off-by: Chao-ying Fu &lt;cfu@mips.com&gt;
Reviewed-by: Anup Patel &lt;anup@brainfault.org&gt;
Link: https://lore.kernel.org/r/20250226014727.19710-1-cfu@mips.com
Signed-off-by: Anup Patel &lt;anup@brainfault.org&gt;
</content>
</entry>
<entry>
<title>lib: sbi: Replace __atomic_op_bit_ord with __atomic intrinsics</title>
<updated>2023-12-08T08:36:40Z</updated>
<author>
<name>Anup Patel</name>
<email>anup@brainfault.org</email>
</author>
<published>2023-12-08T08:24:07Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/opensbi.git/commit/?id=88398696c816dfc79d5301180dfe42a5d8c497c9'/>
<id>urn:sha1:88398696c816dfc79d5301180dfe42a5d8c497c9</id>
<content type='text'>
Simplify atomic-related bit operations through __atomic intrinsics.

Signed-off-by: Xiang W &lt;wxjstz@126.com&gt;
Reviewed-by: Anup Patel &lt;anup@brainfault.org&gt;
</content>
</entry>
<entry>
<title>lib: sbi: Fix __atomic_op_bit_ord and comments</title>
<updated>2023-12-08T08:17:31Z</updated>
<author>
<name>Xiang W</name>
<email>wxjstz@126.com</email>
</author>
<published>2023-11-15T14:59:21Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/opensbi.git/commit/?id=11bf49b44466b821d0936419caf24befab0a61b7'/>
<id>urn:sha1:11bf49b44466b821d0936419caf24befab0a61b7</id>
<content type='text'>
The original code returns the value of the word before modification.
When modifying the upper 32 bits under RV64, the value returned via
int return will have no meaning. Corrected to return the value of the
bit. And modify the function description.

Signed-off-by: Xiang W &lt;wxjstz@126.com&gt;
Reviewed-by: Anup Patel &lt;anup@brainfault.org&gt;
</content>
</entry>
<entry>
<title>lib: sbi: Remove xchg/cmpxchg implemented via lr/sc</title>
<updated>2023-12-08T05:24:35Z</updated>
<author>
<name>Xiang W</name>
<email>wxjstz@126.com</email>
</author>
<published>2023-11-08T03:28:16Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/opensbi.git/commit/?id=6b9a8494828d3983784fb46bb6cd2b6cc9a54ab1'/>
<id>urn:sha1:6b9a8494828d3983784fb46bb6cd2b6cc9a54ab1</id>
<content type='text'>
lr/sc is part of the A extension. If the A extension is not supported,
lr/sc cannot be used. So remove xchg/cmpxchg.

Signed-off-by: Xiang W &lt;wxjstz@126.com&gt;
Reviewed-by: Anup Patel &lt;anup@brainfault.org&gt;
</content>
</entry>
<entry>
<title>lib: sbi: fix atomic_add_return</title>
<updated>2021-04-09T13:21:02Z</updated>
<author>
<name>Xiang W</name>
<email>wxjstz@126.com</email>
</author>
<published>2021-04-06T03:34:38Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/opensbi.git/commit/?id=70ffc3e2e690f2b7bcea456f49206b636420ef5f'/>
<id>urn:sha1:70ffc3e2e690f2b7bcea456f49206b636420ef5f</id>
<content type='text'>
The unsigned length may be 4 bytes or 8 bytes, amoadd.w only applies
to 4 bytes hence this patch.

Signed-off-by: Xiang W &lt;wxjstz@126.com&gt;
Reviewed-by: Anup Patel &lt;anup.patel@wdc.com&gt;
</content>
</entry>
<entry>
<title>include: Use more consistent name for atomic xchg() and cmpxchg()</title>
<updated>2020-03-28T08:02:38Z</updated>
<author>
<name>Anup Patel</name>
<email>anup.patel@wdc.com</email>
</author>
<published>2020-03-26T12:40:02Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/opensbi.git/commit/?id=5b6957eed75ca7842861e0f6765d0f6a64408e05'/>
<id>urn:sha1:5b6957eed75ca7842861e0f6765d0f6a64408e05</id>
<content type='text'>
We should remove the "arch_" prefix from atomic xchg() and cmpxchg()
function names to have consistent naming of all atomic functions.

Signed-off-by: Anup Patel &lt;anup.patel@wdc.com&gt;
Reviewed-by: Atish Patra &lt;atish.patra@wdc.com&gt;
</content>
</entry>
<entry>
<title>lib: sbi: Fix coding style issues</title>
<updated>2020-03-10T04:57:28Z</updated>
<author>
<name>Bin Meng</name>
<email>bmeng.cn@gmail.com</email>
</author>
<published>2020-03-09T03:52:41Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/opensbi.git/commit/?id=650c0e525ce60e80b6756aa8cc4eeae5b20ccbd8'/>
<id>urn:sha1:650c0e525ce60e80b6756aa8cc4eeae5b20ccbd8</id>
<content type='text'>
This fixes various coding style issues found in the SBI codes.
No functional changes.

Signed-off-by: Bin Meng &lt;bmeng.cn@gmail.com&gt;
Reviewed-by: Anup Patel &lt;anup.patel@wdc.com&gt;
</content>
</entry>
<entry>
<title>include: Move bits related defines and macros to sbi_bitops.h</title>
<updated>2020-03-08T05:36:18Z</updated>
<author>
<name>Anup Patel</name>
<email>anup.patel@wdc.com</email>
</author>
<published>2020-03-04T05:38:35Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/opensbi.git/commit/?id=00d332bbe726d85e4c2b81ab0a08182612f96c03'/>
<id>urn:sha1:00d332bbe726d85e4c2b81ab0a08182612f96c03</id>
<content type='text'>
The right location for all bits related defines and macros is
sbi_bitops.h hence this patch. With this patch, the sbi_bits.h
is redundant so we remove it.

Signed-off-by: Anup Patel &lt;anup.patel@wdc.com&gt;
Reviewed-by: Atish Patra &lt;atish.patra@wdc.com&gt;
</content>
</entry>
</feed>
