@@ -20,8 +20,6 @@ struct dma_coherent_mem {
2020 bool use_dev_dma_pfn_offset ;
2121};
2222
23- static struct dma_coherent_mem * dma_coherent_default_memory __ro_after_init ;
24-
2523static inline struct dma_coherent_mem * dev_get_coherent_memory (struct device * dev )
2624{
2725 if (dev && dev -> dma_mem )
@@ -191,16 +189,6 @@ int dma_alloc_from_dev_coherent(struct device *dev, ssize_t size,
191189 return 1 ;
192190}
193191
194- void * dma_alloc_from_global_coherent (struct device * dev , ssize_t size ,
195- dma_addr_t * dma_handle )
196- {
197- if (!dma_coherent_default_memory )
198- return NULL ;
199-
200- return __dma_alloc_from_coherent (dev , dma_coherent_default_memory , size ,
201- dma_handle );
202- }
203-
204192static int __dma_release_from_coherent (struct dma_coherent_mem * mem ,
205193 int order , void * vaddr )
206194{
@@ -236,15 +224,6 @@ int dma_release_from_dev_coherent(struct device *dev, int order, void *vaddr)
236224 return __dma_release_from_coherent (mem , order , vaddr );
237225}
238226
239- int dma_release_from_global_coherent (int order , void * vaddr )
240- {
241- if (!dma_coherent_default_memory )
242- return 0 ;
243-
244- return __dma_release_from_coherent (dma_coherent_default_memory , order ,
245- vaddr );
246- }
247-
248227static int __dma_mmap_from_coherent (struct dma_coherent_mem * mem ,
249228 struct vm_area_struct * vma , void * vaddr , size_t size , int * ret )
250229{
@@ -290,6 +269,28 @@ int dma_mmap_from_dev_coherent(struct device *dev, struct vm_area_struct *vma,
290269 return __dma_mmap_from_coherent (mem , vma , vaddr , size , ret );
291270}
292271
272+ #ifdef CONFIG_DMA_GLOBAL_POOL
273+ static struct dma_coherent_mem * dma_coherent_default_memory __ro_after_init ;
274+
275+ void * dma_alloc_from_global_coherent (struct device * dev , ssize_t size ,
276+ dma_addr_t * dma_handle )
277+ {
278+ if (!dma_coherent_default_memory )
279+ return NULL ;
280+
281+ return __dma_alloc_from_coherent (dev , dma_coherent_default_memory , size ,
282+ dma_handle );
283+ }
284+
285+ int dma_release_from_global_coherent (int order , void * vaddr )
286+ {
287+ if (!dma_coherent_default_memory )
288+ return 0 ;
289+
290+ return __dma_release_from_coherent (dma_coherent_default_memory , order ,
291+ vaddr );
292+ }
293+
293294int dma_mmap_from_global_coherent (struct vm_area_struct * vma , void * vaddr ,
294295 size_t size , int * ret )
295296{
@@ -311,6 +312,7 @@ int dma_init_global_coherent(phys_addr_t phys_addr, size_t size)
311312 pr_info ("DMA: default coherent area is set\n" );
312313 return 0 ;
313314}
315+ #endif /* CONFIG_DMA_GLOBAL_POOL */
314316
315317/*
316318 * Support for reserved memory regions defined in device tree
@@ -320,7 +322,9 @@ int dma_init_global_coherent(phys_addr_t phys_addr, size_t size)
320322#include <linux/of_fdt.h>
321323#include <linux/of_reserved_mem.h>
322324
325+ #ifdef CONFIG_DMA_GLOBAL_POOL
323326static struct reserved_mem * dma_reserved_default_memory __initdata ;
327+ #endif
324328
325329static int rmem_dma_device_init (struct reserved_mem * rmem , struct device * dev )
326330{
@@ -377,15 +381,16 @@ static int __init rmem_dma_setup(struct reserved_mem *rmem)
377381 return 0 ;
378382}
379383
384+ #ifdef CONFIG_DMA_GLOBAL_POOL
380385static int __init dma_init_reserved_memory (void )
381386{
382387 if (!dma_reserved_default_memory )
383388 return - ENOMEM ;
384389 return dma_init_global_coherent (dma_reserved_default_memory -> base ,
385390 dma_reserved_default_memory -> size );
386391}
387-
388392core_initcall (dma_init_reserved_memory );
393+ #endif /* CONFIG_DMA_GLOBAL_POOL */
389394
390395RESERVEDMEM_OF_DECLARE (dma , "shared-dma-pool" , rmem_dma_setup );
391396#endif
0 commit comments