Skip to content

include/nuttx/irq.h: add irq_save/irq_restore - #21895

Merged
xiaoxiang781216 merged 1 commit into
apache:masterfrom
CV-Bowen:up/P100-irq-save
Nov 17, 2026
Merged

xiaoxiang781216 merged 1 commit into
apache:masterfrom
CV-Bowen:up/P100-irq-save

Conversation

@CV-Bowen

Copy link
Copy Markdown
Contributor

Summary

Add irq_save()/irq_restore() to include/nuttx/irq.h as the
architecture-independent way for code outside arch/ to disable and
restore local interrupts. For now they map directly to
up_irq_save()/up_irq_restore(); having one name above the arch layer
gives a single place to hook IRQ-disabled time monitoring later.

The first user is the lock-free ring (include/nuttx/ring.h), which
will follow in a separate PR and depends on this one. Existing
up_irq_save() callers are not converted here.

Impact

  • Two new macros, defined only when __ASSEMBLY__ is not defined.
  • No behaviour, Kconfig, build or ABI change; nothing in the tree uses
    them yet.

Testing

Host: Ubuntu 22.04.5 LTS x86_64, QEMU version 10.2.1, sim: cc (Ubuntu 13.1.0-8ubuntu1~22.04) 13.1.0, qemu-armv8a: aarch64-none-elf-gcc (Arm GNU Toolchain 12.2.Rel1 (Build arm-12.24)) 12.2.1 20221205

Built sim:nsh with the ring PR applied on top and
CONFIG_TESTING_CMOCKA=y CONFIG_TESTING_RING=y (the ring cmocka tests,
apps PR to follow), then ran ring_test:

tree result
master + ring link fails: undefined reference to 'irq_save' / 'irq_restore' from include/nuttx/ring.h
master + this PR + ring builds with no warnings; 80/80 cmocka cases pass
ring_test (master + this PR + ring)
[==========] g_spsc_local_tests: Running 36 test(s).
[==========] g_spsc_local_tests: 36 test(s) run.
[  PASSED  ] 36 test(s).
[==========] g_mpsc_local_tests: Running 11 test(s).
[==========] g_mpsc_local_tests: 11 test(s) run.
[  PASSED  ] 11 test(s).
[==========] g_spmc_local_tests: Running 11 test(s).
[==========] g_spmc_local_tests: 11 test(s) run.
[  PASSED  ] 11 test(s).
[==========] g_mpmc_local_tests: Running 22 test(s).
[==========] g_mpmc_local_tests: 22 test(s) run.
[  PASSED  ] 22 test(s).

No regression in rpmsg: sim:rpserver/rpproxy and qemu-armv8a:rpserver/rpproxy boot and pass the fixed rpmsg cases (dump, ping, rpmsgfs; 15/15). qemu-armv8a was built with LIBC_ENVPATH and BINFMT_CHECKEXEC disabled, which current master needs for nxinit to start nsh there; unrelated to this change.

Add irq_save()/irq_restore() as the architecture-independent way for code
outside arch/ to disable and restore local interrupts.  They map to
up_irq_save()/up_irq_restore() and give one place to hook IRQ-disabled
time monitoring later.

The lock-free ring in include/nuttx/ring.h is the first user.  Existing
up_irq_save() callers are left as they are.

Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
@github-actions github-actions Bot added Area: OS Components OS Components issues Size: XS The size of the change in this PR is very small labels Nov 16, 2026
@github-actions

Copy link
Copy Markdown

MemBrowse Memory Report · Explore what changed →

No memory changes detected for:


Catch memory regressions in CI with MemBrowse. Free for open source.

@xiaoxiang781216
xiaoxiang781216 merged commit d934557 into apache:master Nov 17, 2026
52 of 53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: OS Components OS Components issues Size: XS The size of the change in this PR is very small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants