LCOV - code coverage report
Current view: top level - /home/runner/zephyrproject/zephyr/kernel - spinlock_validate.c (source / functions) Coverage Total Hit
Test: lcov.info Lines: 78.6 % 14 11
Test Date: 2026-01-29 09:48:10 Functions: 100.0 % 3 3
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 30.0 % 10 3

             Branch data     Line data    Source code
       1                 :             : /*
       2                 :             :  * Copyright (c) 2018,2024 Intel Corporation
       3                 :             :  *
       4                 :             :  * SPDX-License-Identifier: Apache-2.0
       5                 :             :  */
       6                 :             : #include <kernel_internal.h>
       7                 :             : #include <zephyr/spinlock.h>
       8                 :             : #include <zephyr/llext/symbol.h>
       9                 :             : 
      10                 :         511 : bool z_spin_lock_valid(struct k_spinlock *l)
      11                 :             : {
      12                 :         511 :         uintptr_t thread_cpu = l->thread_cpu;
      13                 :             : 
      14         [ -  + ]:         511 :         if (thread_cpu != 0U) {
      15         [ #  # ]:           0 :                 if ((thread_cpu & 3U) == _current_cpu->id) {
      16                 :           0 :                         return false;
      17                 :             :                 }
      18                 :             :         }
      19                 :             :         return true;
      20                 :             : }
      21                 :             : EXPORT_SYMBOL(z_spin_lock_valid);
      22                 :             : 
      23                 :         511 : bool z_spin_unlock_valid(struct k_spinlock *l)
      24                 :             : {
      25                 :         511 :         uintptr_t tcpu = l->thread_cpu;
      26                 :             : 
      27                 :         511 :         l->thread_cpu = 0;
      28                 :             : 
      29   [ -  +  -  - ]:         511 :         if (arch_is_in_isr() && _current->base.thread_state & _THREAD_DUMMY) {
      30                 :             :                 /* Edge case where an ISR aborted _current */
      31                 :             :                 return true;
      32                 :             :         }
      33         [ -  + ]:         511 :         if (tcpu != (_current_cpu->id | (uintptr_t)_current)) {
      34                 :           0 :                 return false;
      35                 :             :         }
      36                 :             :         return true;
      37                 :             : }
      38                 :             : EXPORT_SYMBOL(z_spin_unlock_valid);
      39                 :             : 
      40                 :         511 : void z_spin_lock_set_owner(struct k_spinlock *l)
      41                 :             : {
      42                 :         511 :         l->thread_cpu = _current_cpu->id | (uintptr_t)_current;
      43                 :         511 : }
      44                 :             : EXPORT_SYMBOL(z_spin_lock_set_owner);
      45                 :             : 
      46                 :             : #ifdef CONFIG_KERNEL_COHERENCE
      47                 :             : bool z_spin_lock_mem_coherent(struct k_spinlock *l)
      48                 :             : {
      49                 :             :         return sys_cache_is_mem_coherent((void *)l);
      50                 :             : }
      51                 :             : EXPORT_SYMBOL(z_spin_lock_mem_coherent);
      52                 :             : #endif /* CONFIG_KERNEL_COHERENCE */
        

Generated by: LCOV version 2.0-1