~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/drm/task_barrier.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /include/drm/task_barrier.h (Version linux-6.11.5) and /include/drm/task_barrier.h (Version linux-5.5.19)


  1 /*                                                  1 
  2  * Copyright 2019 Advanced Micro Devices, Inc.    
  3  *                                                
  4  * Permission is hereby granted, free of charg    
  5  * copy of this software and associated docume    
  6  * to deal in the Software without restriction    
  7  * the rights to use, copy, modify, merge, pub    
  8  * and/or sell copies of the Software, and to     
  9  * Software is furnished to do so, subject to     
 10  *                                                
 11  * The above copyright notice and this permiss    
 12  * all copies or substantial portions of the S    
 13  *                                                
 14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT W    
 15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE W    
 16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINF    
 17  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIA    
 18  * OTHER LIABILITY, WHETHER IN AN ACTION OF CO    
 19  * ARISING FROM, OUT OF OR IN CONNECTION WITH     
 20  * OTHER DEALINGS IN THE SOFTWARE.                
 21  *                                                
 22  */                                               
 23 #include <linux/semaphore.h>                      
 24 #include <linux/atomic.h>                         
 25                                                   
 26 /*                                                
 27  * Reusable 2 PHASE task barrier (rendez-vous     
 28  * Based on the Little book of semaphores - ht    
 29  */                                               
 30                                                   
 31                                                   
 32                                                   
 33 #ifndef DRM_TASK_BARRIER_H_                       
 34 #define DRM_TASK_BARRIER_H_                       
 35                                                   
 36 /*                                                
 37  * Represents an instance of a task barrier.      
 38  */                                               
 39 struct task_barrier {                             
 40         unsigned int n;                           
 41         atomic_t count;                           
 42         struct semaphore enter_turnstile;         
 43         struct semaphore exit_turnstile;          
 44 };                                                
 45                                                   
 46 static inline void task_barrier_signal_turnsti    
 47                                                   
 48 {                                                 
 49         int i;                                    
 50                                                   
 51         for (i = 0 ; i < n; i++)                  
 52                 up(turnstile);                    
 53 }                                                 
 54                                                   
 55 static inline void task_barrier_init(struct ta    
 56 {                                                 
 57         tb->n = 0;                                
 58         atomic_set(&tb->count, 0);                
 59         sema_init(&tb->enter_turnstile, 0);       
 60         sema_init(&tb->exit_turnstile, 0);        
 61 }                                                 
 62                                                   
 63 static inline void task_barrier_add_task(struc    
 64 {                                                 
 65         tb->n++;                                  
 66 }                                                 
 67                                                   
 68 static inline void task_barrier_rem_task(struc    
 69 {                                                 
 70         tb->n--;                                  
 71 }                                                 
 72                                                   
 73 /*                                                
 74  * Lines up all the threads BEFORE the critica    
 75  *                                                
 76  * When all thread passed this code the entry     
 77  */                                               
 78 static inline void task_barrier_enter(struct t    
 79 {                                                 
 80         if (atomic_inc_return(&tb->count) == t    
 81                 task_barrier_signal_turnstile(    
 82                                                   
 83         down(&tb->enter_turnstile);               
 84 }                                                 
 85                                                   
 86 /*                                                
 87  * Lines up all the threads AFTER the critical    
 88  *                                                
 89  * This function is used to avoid any one thre    
 90  *  used repeatedly .                             
 91  */                                               
 92 static inline void task_barrier_exit(struct ta    
 93 {                                                 
 94         if (atomic_dec_return(&tb->count) == 0    
 95                 task_barrier_signal_turnstile(    
 96                                                   
 97         down(&tb->exit_turnstile);                
 98 }                                                 
 99                                                   
100 /* Convinieince function when nothing to be do    
101 static inline void task_barrier_full(struct ta    
102 {                                                 
103         task_barrier_enter(tb);                   
104         task_barrier_exit(tb);                    
105 }                                                 
106                                                   
107 #endif                                            
108                                                   

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php