zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.93k stars 6.65k forks source link

arch.interrupt: fails on NXP Cortex-M0+ platforms #35097

Closed hakehuang closed 3 years ago

hakehuang commented 3 years ago

Describe the bug test_isr_offload_job_multiple cause hard fault

To Reproduce Steps to reproduce the behavior:

  1. cd tests/kernel/interrupt ;mkdir build; cd build
  2. cmake -DBOARD=frdm_kl25z ..
  3. make falsh
  4. See error

Expected behavior Test pass

Impact interrupt handle

Logs and console output

   *** Booting Zephyr OS build zephyr-v2.5.0-3761-g730acbd6ed85  ***

    Running test suite interrupt_feature

    ===================================================================

    START - test_isr_dynamic

    installing dynamic ISR for IRQ 0

     PASS - test_isr_dynamic in 0.3 seconds

    ===================================================================

    START - test_nested_isr

    Triggering irq : 29

    isr0: Enter

    Triggering irq : 28

    isr1: Enter

    isr1: Leave

    isr0: Leave

     PASS - test_nested_isr in 0.19 seconds

    ===================================================================

    START - test_prevent_interruption

    locking interrupts

    unlocking interrupts

    timer fired

     PASS - test_prevent_interruption in 2.5 seconds

    ===================================================================

    START - test_isr_regular

     SKIP - test_isr_regular in 0.1 seconds

    ===================================================================

    START - test_isr_offload_job_multiple

    case 0

    case 0

    ASSERTION FAIL [work->queue != ((void *)0)] @ WEST_TOPDIR/zephyr/kernel/work.c:334

    E: ***** HARD FAULT *****

    E: ARCH_EXCEPT with reason 4

    E: r0/a1:  0x00000004  r1/a2:  0x0000014e  r2/a3:  0x00006e75

    E: r3/a4:  0x00003879 r12/ip:  0x00000000 r14/lr:  0x00003883

    E:  xpsr:  0x0100000b

    E: Faulting instruction address (r15/pc): 0x00005720

    E: >>> ZEPHYR FATAL ERROR 4: Kernel panic on CPU 0

    E: Fault during interrupt handling

    E: Current thread: 0x1ffff480 (ztest_thread)

    E: Halting system

Environment (please complete the following information):

hakehuang commented 3 years ago

@MaureenHelm , @dleach02 , @mmahadevan108

erwango commented 3 years ago

@hakehuang can you check https://github.com/zephyrproject-rtos/zephyr/pull/35061 ? Edit: likely not the same fix should be used, but this would be similar

hakehuang commented 3 years ago

@hakehuang can you check #35061 ? Edit: likely not the same fix should be used, but this would be similar

@erwango looks not related, the fix in #35061 is for the test_nop, but the failure here is interrupt_offload_multi, according to the code comments, it is likely not supported yet. @enjiamai

` /*

enjiamai commented 3 years ago

Hi, @hakehuang @erwango Yes, it is not relative to #35061.

And this test case is supported by using the irq_offload() to trigger the SW interrupt, it is tested. According to the error msg, it seems like when trying to offload job to a k_work by calling k_work_submit_to_queue(). But the first parameter &wq_queue(a global variable) is NULL in the ISR handler.

Please let me see if I can have a frdm_kl25z board to reproduce this and figure this out, thanks.

ABOSTM commented 3 years ago

The same problem (same assert failed, followed by a HardFault) occurs on some STM32 boards:

But it is passed on other boards including nucleo_f103rb (cortex M3) and nucleo_g071rb (cortex M0+)

enjiamai commented 3 years ago

I did not have these boards, I just have frdm_k64f in hand, and it passed when I use twister to test it. Excuse me, @hakehuang , if it is possible, could you please help to run this command on frdm_kl25z to see whether it pass or not?

twister -p  frdm_kl25z --device-testing --device-serial="/dev/ttyACM0" -T tests/kernel/interrupt/ -vv
galak commented 3 years ago

@ioannisg @carlescufi Can you try this on any Nordic M0?

MaureenHelm commented 3 years ago

I did not have these boards, I just have frdm_k64f in hand, and it passed when I use twister to test it. Excuse me, @hakehuang , if it is possible, could you please help to run this command on frdm_kl25z to see whether it pass or not?

twister -p  frdm_kl25z --device-testing --device-serial="/dev/ttyACM0" -T tests/kernel/interrupt/ -vv

It fails. I ran on commit 53b8706f05aee7777caae8b6d3c2e5bde957a4bf:

$ twister -p  frdm_kl25z --device-testing --device-serial="/dev/ttyACM0" -T tests/kernel/interrupt/ -vv
Renaming output directory to /home/maureen/zephyrproject/zephyr/twister-out.3
INFO    - Zephyr version: v2.6.0-rc1-40-g53b8706f05ae
INFO    - JOBS: 1
DEBUG   - Reading test case configuration files under /home/maureen/zephyrproject/zephyr/tests/kernel/interrupt...
DEBUG   - Found possible test case in /home/maureen/zephyrproject/zephyr/tests/kernel/interrupt
DEBUG   - Reading platform configuration files under /home/maureen/zephyrproject/zephyr/boards...
DEBUG   - Reading platform configuration files under /home/maureen/zephyrproject/zephyr/scripts/pylib/twister/boards...
DEBUG   - Running cmake script /home/maureen/zephyrproject/zephyr/cmake/verify-toolchain.cmake
DEBUG   - Calling cmake with arguments: ['-DFORMAT=json', '-P', PosixPath('/home/maureen/zephyrproject/zephyr/cmake/verify-toolchain.cmake')]
DEBUG   - Finished running  /home/maureen/zephyrproject/zephyr/cmake/verify-toolchain.cmake
INFO    - Using 'zephyr' toolchain.
DEBUG   - platform filter: ['frdm_kl25z']
DEBUG   -     arch_filter: None
DEBUG   -      tag_filter: None
DEBUG   -     exclude_tag: None
INFO    - Building initial testcase list...
DEBUG   - frdm_kl25z                tests/kernel/interrupt/arch.interrupt.x86_64       SKIPPED: Not in test case arch allow list
DEBUG   - frdm_kl25z                tests/kernel/interrupt/arch.interrupt.x86          SKIPPED: Not in test case arch allow list
INFO    - 3 test scenarios (3 configurations) selected, 2 configurations discarded due to filters.

Device testing on:

| Platform   | ID   | Serial device   |
|------------|------|-----------------|
| frdm_kl25z |      | /dev/ttyACM0    |

INFO    - Adding tasks to the queue...
DEBUG   - adding frdm_kl25z/tests/kernel/interrupt/arch.interrupt
INFO    - Added initial list of jobs to queue
DEBUG   - Launch process 0
DEBUG   - Running cmake on /home/maureen/zephyrproject/zephyr/tests/kernel/interrupt for frdm_kl25z
DEBUG   - Calling cmake with arguments: ['-B/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt', '-S/home/maureen/zephyrproject/zephyr/tests/kernel/interrupt', '-DEXTRA_CFLAGS="-Werror"', '-DEXTRA_AFLAGS="-Wa,--fatal-warnings', '-DEXTRA_LDFLAGS="-Wl,--fatal-warnings"', '-DEXTRA_GEN_DEFINES_ARGS=--err-on-deprecated-properties', '-GUnix Makefiles', '-DBOARD=frdm_kl25z']
DEBUG   - Finished building /home/maureen/zephyrproject/zephyr/tests/kernel/interrupt for frdm_kl25z
DEBUG   - build test: frdm_kl25z/tests/kernel/interrupt/arch.interrupt
DEBUG   - Building /home/maureen/zephyrproject/zephyr/tests/kernel/interrupt for frdm_kl25z
DEBUG   - run test: frdm_kl25z/tests/kernel/interrupt/arch.interrupt
DEBUG   - Using serial device /dev/ttyACM0
DEBUG   - Flash command: ['make', '-C', '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt', 'flash']
DEBUG   - DEVICE: *** Booting Zephyr OS build v2.6.0-rc1-40-g53b8706f05ae  ***
DEBUG   - DEVICE: Running test suite interrupt_feature
DEBUG   - DEVICE: ===================================================================
DEBUG   - DEVICE: START - test_isr_dynamic
DEBUG   - DEVICE: installing dynamic ISR for IRQ 0
DEBUG   - DEVICE: PASS - test_isr_dynamic in 0.3 seconds
DEBUG   - DEVICE: ===================================================================
DEBUG   - DEVICE: START - test_nested_isr
DEBUG   - DEVICE: Triggering irq : 29
DEBUG   - DEVICE: isr0: Enter
DEBUG   - DEVICE: Triggering irq : 28
DEBUG   - DEVICE: isr1: Enter
DEBUG   - DEVICE: isr1: Leave
DEBUG   - DEVICE: isr0: Leave
DEBUG   - DEVICE: PASS - test_nested_isr in 0.19 seconds
DEBUG   - DEVICE: ===================================================================
DEBUG   - DEVICE: START - test_prevent_interruption
DEBUG   - DEVICE: locking interrupts
DEBUG   - make: Entering directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
make[1]: Entering directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
make[2]: Entering directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
make[3]: Entering directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
Scanning dependencies of target flash
make[3]: Leaving directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
make[3]: Entering directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
Flashing frdm_kl25z
-- west flash: rebuilding
make[4]: Entering directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
make[5]: Entering directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
make[6]: Entering directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
make[6]: Leaving directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
[  2%] Built target parse_syscalls_target
make[6]: Entering directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
make[6]: Leaving directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
[  3%] Built target kobj_types_h_target
make[6]: Entering directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
make[6]: Leaving directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
[  3%] Built target syscall_list_h_target
make[6]: Entering directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
make[6]: Leaving directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
[  4%] Built target driver_validation_h_target
make[6]: Entering directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
make[6]: Leaving directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
[  5%] Built target offsets
make[6]: Entering directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
make[6]: Leaving directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
[  6%] Built target offsets_h
make[6]: Entering directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
make[6]: Leaving directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
[  6%] Built target zephyr_generated_headers
make[6]: Entering directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
make[6]: Leaving directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
[ 11%] Built target app
make[6]: Entering directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
make[6]: Leaving directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
[ 29%] Built target kernel
make[6]: Entering directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
make[6]: Leaving directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
[ 52%] Built target zephyr
make[6]: Entering directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
make[6]: Leaving directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
[ 52%] Built target linker_zephyr_prebuilt_script_target
make[6]: Entering directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
make[6]: Leaving directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
[ 54%] Built target isr_tables
make[6]: Entering directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
make[6]: Leaving directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
[ 56%] Built target arch__common
make[6]: Entering directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
make[6]: Leaving directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
[ 64%] Built target arch__arm__core__aarch32
make[6]: Entering directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
make[6]: Leaving directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
[ 70%] Built target arch__arm__core__aarch32__cortex_m
make[6]: Entering directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
make[6]: Leaving directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
[ 81%] Built target lib__libc__minimal
make[6]: Entering directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
make[6]: Leaving directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
[ 83%] Built target lib__posix
make[6]: Entering directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
make[6]: Leaving directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
[ 85%] Built target boards__arm__frdm_kl25z
make[6]: Entering directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
make[6]: Leaving directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
[ 87%] Built target subsys__testsuite__ztest
make[6]: Entering directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
make[6]: Leaving directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
[ 88%] Built target drivers__gpio
make[6]: Entering directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
make[6]: Leaving directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
[ 90%] Built target drivers__serial
make[6]: Entering directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
make[6]: Leaving directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
[ 92%] Built target ..__modules__hal__nxp
make[6]: Entering directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
make[6]: Leaving directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
[ 94%] Built target zephyr_prebuilt
make[6]: Entering directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
make[6]: Leaving directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
[ 95%] Built target linker_zephyr_final_script_target
make[6]: Entering directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
make[6]: Leaving directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
[100%] Built target zephyr_final
make[5]: Leaving directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
make[4]: Leaving directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
-- west flash: using runner pyocd
-- runners.pyocd: Flashing file: /home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt/zephyr/zephyr.bin
[---|---|---|---|---|---|---|---|---|----]
[========================================]
make[3]: Leaving directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
Built target flash
make[2]: Leaving directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
make[1]: Leaving directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'
make: Leaving directory '/home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt'

DEBUG   - DEVICE: unlocking interrupts
DEBUG   - DEVICE: timer fired
DEBUG   - DEVICE: PASS - test_prevent_interruption in 2.5 seconds
DEBUG   - DEVICE: ===================================================================
DEBUG   - DEVICE: START - test_isr_regular
DEBUG   - DEVICE: SKIP - test_isr_regular in 0.1 seconds
DEBUG   - DEVICE: ===================================================================
DEBUG   - DEVICE: START - test_isr_offload_job_multiple
DEBUG   - DEVICE: case 0
DEBUG   - DEVICE: case 0
DEBUG   - DEVICE: 
DEBUG   - DEVICE: ASSERTION FAIL [work->queue != ((void *)0)] @ WEST_TOPDIR/zephyr/kernel/work.c:334
DEBUG   - DEVICE: E: ***** HARD FAULT *****
DEBUG   - DEVICE: E: ARCH_EXCEPT with reason 4
DEBUG   - DEVICE: 
DEBUG   - DEVICE: E: r0/a1:  0x00000004  r1/a2:  0x0000014e  r2/a3:  0x00006e75
DEBUG   - DEVICE: E: r3/a4:  0x00003879 r12/ip:  0x00000000 r14/lr:  0x00003883
DEBUG   - DEVICE: E:  xpsr:  0x0100000b
DEBUG   - DEVICE: E: Faulting instruction address (r15/pc): 0x00005720
DEBUG   - DEVICE: E: >>> ZEPHYR FATAL ERROR 4: Kernel panic on CPU 0
DEBUG   - DEVICE: E: Fault during interrupt handling
DEBUG   - DEVICE: 
DEBUG   - DEVICE: E: Current thread: 0x1ffff480 (ztest_thread)
DEBUG   - DEVICE: E: Halting system
DEBUG   - Timed out while monitoring serial output on frdm_kl25z
DEBUG   - run status: frdm_kl25z/tests/kernel/interrupt/arch.interrupt timeout
INFO    - 1/1 frdm_kl25z                tests/kernel/interrupt/arch.interrupt              FAILED Timeout (device 69.883s)
ERROR   - see: /home/maureen/zephyrproject/zephyr/twister-out/frdm_kl25z/tests/kernel/interrupt/arch.interrupt/handler.log

DEBUG   - running footprint_reports
INFO    - 0 of 1 test configurations passed (0.00%), 1 failed, 2 skipped with 0 warnings in 104.01 seconds
INFO    - In total 8 test cases were executed, 16 skipped on 1 out of total 373 platforms (0.27%)
INFO    - 1 test configurations executed on platforms, 0 test configurations were only built.

Hardware distribution summary:

| Board      | ID   |   Counter |
|------------|------|-----------|
| frdm_kl25z |      |         1 |
INFO    - Saving reports...
INFO    - Writing xunit report /home/maureen/zephyrproject/zephyr/twister-out/twister.xml...
INFO    - Writing xunit report /home/maureen/zephyrproject/zephyr/twister-out/twister_report.xml...
INFO    - Run completed
enjiamai commented 3 years ago

@MaureenHelm got it, thanks! I can make sure it happens on frdm_kl25z but frdm_k64f.

MaureenHelm commented 3 years ago

This test was added just a few days ago in #34016. It looks the failure is a timing issue, because the following change allows the test to pass on frdm_kl25z:

diff --git a/tests/kernel/interrupt/src/interrupt_offload.c b/tests/kernel/interrupt/src/interrupt_offload.c
index d00a6167c5..29744b7a7f 100644
--- a/tests/kernel/interrupt/src/interrupt_offload.c
+++ b/tests/kernel/interrupt/src/interrupt_offload.c
@@ -194,7 +194,7 @@ static void run_test_offload(int case_type, int real_irq)
        /* wait for all offload job complete */
        k_sem_take(&end_sem, K_FOREVER);

-       k_usleep(1);
+       k_usleep(1000);

        zassert_equal(orig_t_keep_run, 1,
                        "offload job done, the original thread run");
enjiamai commented 3 years ago

Great, @MaureenHelm , this information helps. Could you please help to try whether this change also works when you got a change? thank you so much!

diff --git a/tests/kernel/interrupt/src/interrupt_offload.c b/tests/kernel/interrupt/src/interrupt_offload.c
index d00a6167c5..4dbc48ee97 100644
--- a/tests/kernel/interrupt/src/interrupt_offload.c
+++ b/tests/kernel/interrupt/src/interrupt_offload.c
@@ -200,6 +200,7 @@ static void run_test_offload(int case_type, int real_irq)
                        "offload job done, the original thread run");

        k_thread_abort(tid);
+       k_thread_join(tid, K_FOREVER);
 }

 /**
MaureenHelm commented 3 years ago

Great, @MaureenHelm , this information helps. Could you please help to try whether this change also works when you got a change? thank you so much!

diff --git a/tests/kernel/interrupt/src/interrupt_offload.c b/tests/kernel/interrupt/src/interrupt_offload.c
index d00a6167c5..4dbc48ee97 100644
--- a/tests/kernel/interrupt/src/interrupt_offload.c
+++ b/tests/kernel/interrupt/src/interrupt_offload.c
@@ -200,6 +200,7 @@ static void run_test_offload(int case_type, int real_irq)
                        "offload job done, the original thread run");

        k_thread_abort(tid);
+       k_thread_join(tid, K_FOREVER);
 }

 /**

This change does not work

enjiamai commented 3 years ago

Excuse me, @MaureenHelm @hakehuang is there any possibility that I can have remote access to this platform? thanks!

enjiamai commented 3 years ago

if not, could you please help to give it one more try again? I appreciate your help.

diff --git a/tests/kernel/interrupt/src/interrupt_offload.c b/tests/kernel/interrupt/src/interrupt_offload.c
index d00a6167c5..fe0c49c6f3 100644
--- a/tests/kernel/interrupt/src/interrupt_offload.c
+++ b/tests/kernel/interrupt/src/interrupt_offload.c
@@ -64,6 +64,7 @@ void isr_handler(const void *param)
        int ret;

        zassert_not_null(work, "kwork should not be NULL");
+       zassert_not_null(wq_queue, "work queue should not be NULL");

        orig_t_keep_run = 0;

@@ -200,6 +201,9 @@ static void run_test_offload(int case_type, int real_irq)
                        "offload job done, the original thread run");

        k_thread_abort(tid);
+
+       /* give it some time to make sure thread abort */
+       k_msleep(1);
 }

 /**
hakehuang commented 3 years ago

zassert_not_null(wq_queue, "work queue should not be NULL");

with below change the issue still there,

diff --git a/tests/kernel/interrupt/src/interrupt_offload.c b/tests/kernel/interrupt/src/interrupt_offload.c
index d00a6167c5..fe0c49c6f3 100644
--- a/tests/kernel/interrupt/src/interrupt_offload.c
+++ b/tests/kernel/interrupt/src/interrupt_offload.c
@@ -64,6 +64,7 @@ void isr_handler(const void *param)
        int ret;

        zassert_not_null(work, "kwork should not be NULL");
+       zassert_not_null(&wq_queue, "work queue should not be NULL");

        orig_t_keep_run = 0;

@@ -200,6 +201,9 @@ static void run_test_offload(int case_type, int real_irq)
                        "offload job done, the original thread run");

        k_thread_abort(tid);
+
+       /* give it some time to make sure thread abort */
+       k_msleep(1);
 }

 /**
*** Booting Zephyr OS build zephyr-v2.5.0-3795-g977aba6d02c8  ***
Running test suite interrupt_feature
===================================================================
START - test_isr_dynamic
installing dynamic ISR for IRQ 0
 PASS - test_isr_dynamic in 0.3 seconds
===================================================================
START - test_nested_isr
Triggering irq : 29
isr0: Enter
Triggering irq : 28
isr1: Enter
isr1: Leave
isr0: Leave
 PASS - test_nested_isr in 0.19 seconds
===================================================================
START - test_prevent_interruption
locking interrupts
unlocking interrupts
timer fired
 PASS - test_prevent_interruption in 2.5 seconds
===================================================================
START - test_isr_regular
 SKIP - test_isr_regular in 0.1 seconds
===================================================================
START - test_isr_offload_job_multiple
case 0
case 0

    Assertion failed at ../src/interrupt_offload.c:200: run_test_offload: (orig_t_keep_run not equal to 1)
offload job done, the original thread run
 FAIL - test_isr_offload_job_multiple in 0.17 seconds
===================================================================
START - test_isr_offload_job_identi
case 1
ASE: ***** HARD FAULT *****
E: r0/a1:  0x1ffff2e8  r1/a2:  0x1ffff820  r2/a3:  0x00000000
E: r3/a4:  0x1ffff2e8 r12/ip:  0x00000a49 r14/lr:  0x0000472f
E:  xpsr:  0x2100000f
E: Faulting instruction address (r15/pc): 0x00004550
E: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
E: Fault during interrupt handling

E: Current thread: 0x1ffff2e8 (unknown)
E: Halting system
enjiamai commented 3 years ago

Thanks so much! @hakehuang , it seems like a timing issue. I need some time to look at this.

stephanosio commented 3 years ago

Seeing the same failures on nRF boards: nrf52840dk_nrf52840 (Cortex-M4) and nrf51dk_nrf51422 (Cortex-M0).

galak commented 3 years ago

Seeing the same failures on nRF boards: nrf52840dk_nrf52840 (Cortex-M4) and nrf51dk_nrf51422 (Cortex-M0).

Can you clarify if that is before or after this PR (or both).

stephanosio commented 3 years ago

Can you clarify if that is before or after this PR (or both).

@galak Before #35302. The issue seems to go away after that PR; though, further validation of the logical changes in that PR would be necessary.