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

TOMOYO Linux Cross Reference
Linux/kernel/dma.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ 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.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /kernel/dma.c (Version linux-6.12-rc7) and /kernel/dma.c (Version policy-sample)


  1 // SPDX-License-Identifier: GPL-2.0                 1 
  2 /*                                                
  3  * linux/kernel/dma.c: A DMA channel allocator    
  4  *                                                
  5  * Written by Hennus Bergman, 1992.               
  6  *                                                
  7  * 1994/12/26: Changes by Alex Nash to fix a m    
  8  *   In the previous version the reported devi    
  9  *   if a device requested a DMA channel that     
 10  *   [It also happened to remove the sizeof(ch    
 11  *   assumption introduced because of those /p    
 12  */                                               
 13 #include <linux/export.h>                         
 14 #include <linux/kernel.h>                         
 15 #include <linux/errno.h>                          
 16 #include <linux/spinlock.h>                       
 17 #include <linux/string.h>                         
 18 #include <linux/seq_file.h>                       
 19 #include <linux/proc_fs.h>                        
 20 #include <linux/init.h>                           
 21 #include <asm/dma.h>                              
 22                                                   
 23                                                   
 24                                                   
 25 /* A note on resource allocation:                 
 26  *                                                
 27  * All drivers needing DMA channels, should al    
 28  * through the public routines `request_dma()'    
 29  *                                                
 30  * In order to avoid problems, all processes s    
 31  * the same sequence and release them in the r    
 32  *                                                
 33  * So, when allocating DMAs and IRQs, first al    
 34  * When releasing them, first release the DMA,    
 35  * If you don't, you may cause allocation requ    
 36  * This doesn't really matter now, but it will    
 37  * in the kernel.                                 
 38  */                                               
 39                                                   
 40                                                   
 41 DEFINE_SPINLOCK(dma_spin_lock);                   
 42                                                   
 43 /*                                                
 44  *      If our port doesn't define this it has    
 45  */                                               
 46                                                   
 47 #ifdef MAX_DMA_CHANNELS                           
 48                                                   
 49                                                   
 50 /* Channel n is busy iff dma_chan_busy[n].lock    
 51  * DMA0 used to be reserved for DRAM refresh,     
 52  * DMA4 is reserved for cascading.                
 53  */                                               
 54                                                   
 55 struct dma_chan {                                 
 56         int  lock;                                
 57         const char *device_id;                    
 58 };                                                
 59                                                   
 60 static struct dma_chan dma_chan_busy[MAX_DMA_C    
 61         [4] = { 1, "cascade" },                   
 62 };                                                
 63                                                   
 64                                                   
 65 /**                                               
 66  * request_dma - request and reserve a system     
 67  * @dmanr: DMA channel number                     
 68  * @device_id: reserving device ID string, use    
 69  */                                               
 70 int request_dma(unsigned int dmanr, const char    
 71 {                                                 
 72         if (dmanr >= MAX_DMA_CHANNELS)            
 73                 return -EINVAL;                   
 74                                                   
 75         if (xchg(&dma_chan_busy[dmanr].lock, 1    
 76                 return -EBUSY;                    
 77                                                   
 78         dma_chan_busy[dmanr].device_id = devic    
 79                                                   
 80         /* old flag was 0, now contains 1 to i    
 81         return 0;                                 
 82 } /* request_dma */                               
 83                                                   
 84 /**                                               
 85  * free_dma - free a reserved system DMA chann    
 86  * @dmanr: DMA channel number                     
 87  */                                               
 88 void free_dma(unsigned int dmanr)                 
 89 {                                                 
 90         if (dmanr >= MAX_DMA_CHANNELS) {          
 91                 printk(KERN_WARNING "Trying to    
 92                 return;                           
 93         }                                         
 94                                                   
 95         if (xchg(&dma_chan_busy[dmanr].lock, 0    
 96                 printk(KERN_WARNING "Trying to    
 97                 return;                           
 98         }                                         
 99                                                   
100 } /* free_dma */                                  
101                                                   
102 #else                                             
103                                                   
104 int request_dma(unsigned int dmanr, const char    
105 {                                                 
106         return -EINVAL;                           
107 }                                                 
108                                                   
109 void free_dma(unsigned int dmanr)                 
110 {                                                 
111 }                                                 
112                                                   
113 #endif                                            
114                                                   
115 #ifdef CONFIG_PROC_FS                             
116                                                   
117 #ifdef MAX_DMA_CHANNELS                           
118 static int proc_dma_show(struct seq_file *m, v    
119 {                                                 
120         int i;                                    
121                                                   
122         for (i = 0 ; i < MAX_DMA_CHANNELS ; i+    
123                 if (dma_chan_busy[i].lock) {      
124                         seq_printf(m, "%2d: %s    
125                                    dma_chan_bu    
126                 }                                 
127         }                                         
128         return 0;                                 
129 }                                                 
130 #else                                             
131 static int proc_dma_show(struct seq_file *m, v    
132 {                                                 
133         seq_puts(m, "No DMA\n");                  
134         return 0;                                 
135 }                                                 
136 #endif /* MAX_DMA_CHANNELS */                     
137                                                   
138 static int __init proc_dma_init(void)             
139 {                                                 
140         proc_create_single("dma", 0, NULL, pro    
141         return 0;                                 
142 }                                                 
143                                                   
144 __initcall(proc_dma_init);                        
145 #endif                                            
146                                                   
147 EXPORT_SYMBOL(request_dma);                       
148 EXPORT_SYMBOL(free_dma);                          
149 EXPORT_SYMBOL(dma_spin_lock);                     
150                                                   

~ [ 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