Esempio n. 1
0
void *dma_alloc_attrs(struct device *dev, size_t size, dma_addr_t *dma_handle,
		      gfp_t gfp, struct dma_attrs *attrs)
{
	struct dma_map_ops *ops = get_dma_ops(dev);
	void *memory;

	gfp &= ~(__GFP_DMA | __GFP_HIGHMEM | __GFP_DMA32);

	if (dma_alloc_from_coherent(dev, size, dma_handle, &memory))
		return memory;

	if (!dev)
		dev = &x86_dma_fallback_dev;

	if (!is_device_dma_capable(dev))
		return NULL;

	if (!ops->alloc)
		return NULL;

	memory = ops->alloc(dev, size, dma_handle,
			    dma_alloc_coherent_gfp_flags(dev, gfp), attrs);
	debug_dma_alloc_coherent(dev, size, *dma_handle, memory);

	return memory;
}
Esempio n. 2
0
bool arch_dma_alloc_attrs(struct device **dev, gfp_t *gfp)
{
	*gfp = dma_alloc_coherent_gfp_flags(*dev, *gfp);
	*gfp &= ~(__GFP_DMA | __GFP_HIGHMEM | __GFP_DMA32);

	if (!*dev)
		*dev = &x86_dma_fallback_dev;
	if (!is_device_dma_capable(*dev))
		return false;
	return true;

}