@@ -20,8 +20,6 @@ struct dma_coherent_mem {
20
20
bool use_dev_dma_pfn_offset ;
21
21
};
22
22
23
- static struct dma_coherent_mem * dma_coherent_default_memory __ro_after_init ;
24
-
25
23
static inline struct dma_coherent_mem * dev_get_coherent_memory (struct device * dev )
26
24
{
27
25
if (dev && dev -> dma_mem )
@@ -191,16 +189,6 @@ int dma_alloc_from_dev_coherent(struct device *dev, ssize_t size,
191
189
return 1 ;
192
190
}
193
191
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
-
204
192
static int __dma_release_from_coherent (struct dma_coherent_mem * mem ,
205
193
int order , void * vaddr )
206
194
{
@@ -236,15 +224,6 @@ int dma_release_from_dev_coherent(struct device *dev, int order, void *vaddr)
236
224
return __dma_release_from_coherent (mem , order , vaddr );
237
225
}
238
226
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
-
248
227
static int __dma_mmap_from_coherent (struct dma_coherent_mem * mem ,
249
228
struct vm_area_struct * vma , void * vaddr , size_t size , int * ret )
250
229
{
@@ -290,6 +269,28 @@ int dma_mmap_from_dev_coherent(struct device *dev, struct vm_area_struct *vma,
290
269
return __dma_mmap_from_coherent (mem , vma , vaddr , size , ret );
291
270
}
292
271
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
+
293
294
int dma_mmap_from_global_coherent (struct vm_area_struct * vma , void * vaddr ,
294
295
size_t size , int * ret )
295
296
{
@@ -311,6 +312,7 @@ int dma_init_global_coherent(phys_addr_t phys_addr, size_t size)
311
312
pr_info ("DMA: default coherent area is set\n" );
312
313
return 0 ;
313
314
}
315
+ #endif /* CONFIG_DMA_GLOBAL_POOL */
314
316
315
317
/*
316
318
* 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)
320
322
#include <linux/of_fdt.h>
321
323
#include <linux/of_reserved_mem.h>
322
324
325
+ #ifdef CONFIG_DMA_GLOBAL_POOL
323
326
static struct reserved_mem * dma_reserved_default_memory __initdata ;
327
+ #endif
324
328
325
329
static int rmem_dma_device_init (struct reserved_mem * rmem , struct device * dev )
326
330
{
@@ -377,15 +381,16 @@ static int __init rmem_dma_setup(struct reserved_mem *rmem)
377
381
return 0 ;
378
382
}
379
383
384
+ #ifdef CONFIG_DMA_GLOBAL_POOL
380
385
static int __init dma_init_reserved_memory (void )
381
386
{
382
387
if (!dma_reserved_default_memory )
383
388
return - ENOMEM ;
384
389
return dma_init_global_coherent (dma_reserved_default_memory -> base ,
385
390
dma_reserved_default_memory -> size );
386
391
}
387
-
388
392
core_initcall (dma_init_reserved_memory );
393
+ #endif /* CONFIG_DMA_GLOBAL_POOL */
389
394
390
395
RESERVEDMEM_OF_DECLARE (dma , "shared-dma-pool" , rmem_dma_setup );
391
396
#endif
0 commit comments