__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, int gfp, 
__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp, 
__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, int gfp,	    pgprot_t prot){	struct page *page;	struct vm_region *c;	unsigned long order;	u64 mask = ISA_DMA_THRESHOLD, limit;	if (!consistent_pte) {		printk(KERN_ERR "%s: not initialised\n", __func__);		dump_stack();		return NULL;	}	if (dev) {		mask = dev->coherent_dma_mask;		/*		 * Sanity check the DMA mask - it must be non-zero, and		 * must be able to be satisfied by a DMA allocation.		 */		if (mask == 0) {			dev_warn(dev, "coherent DMA mask is unset\n");			goto no_page;		}		if ((~mask) & ISA_DMA_THRESHOLD) {			dev_warn(dev, "coherent DMA mask %#llx is smaller "				 "than system GFP_DMA mask %#llx\n",				 mask, (unsigned long long)ISA_DMA_THRESHOLD);			goto no_page;		}	}	/*	 * Sanity check the allocation size.	 */	size = PAGE_ALIGN(size);	limit = (mask + 1) & ~mask;	if ((limit && size >= limit) ||	    size >= (CONSISTENT_END - CONSISTENT_BASE)) {		printk(KERN_WARNING "coherent allocation too big "		       "(requested %#x mask %#llx)\n", size, mask);		goto no_page;	}	order = get_order(size);	if (mask != 0xffffffff)		gfp |= GFP_DMA;	page = alloc_pages(gfp, order);	if (!page)		goto no_page;	/*	 * Invalidate any data that might be lurking in the	 * kernel direct-mapped region for device DMA.	 */	{		unsigned long kaddr = (unsigned long)page_address(page);		memset(page_address(page), 0, size);		dmac_flush_range(kaddr, kaddr + size);	}	/*	 * Allocate a virtual address in the consistent mapping region.	 */	c = vm_region_alloc(&consistent_head, size,			    gfp & ~(__GFP_DMA | __GFP_HIGHMEM));	if (c) {		pte_t *pte = consistent_pte + CONSISTENT_OFFSET(c->vm_start);		struct page *end = page + (1 << order);		c->vm_pages = page;		/*		 * Set the "dma handle"		 */		*handle = page_to_dma(dev, page);		do {			BUG_ON(!pte_none(*pte));			set_page_count(page, 1);			/*			 * x86 does not mark the pages reserved...			 */			SetPageReserved(page);			set_pte(pte, mk_pte(page, prot));			page++;			pte++;		} while (size -= PAGE_SIZE);		/*		 * Free the otherwise unused pages.		 */		while (page < end) {			set_page_count(page, 1);			__free_page(page);			page++;		}		return (void *)c->vm_start;	}	if (page)		__free_pages(page, order); no_page:	*handle = ~0;	return NULL;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/f9e3214a7964f523e12b4f30b6bd6396794818bd/consistent.c/buggy/arch/arm/mm/consistent.c