[PATCHv2 1/2] ARM: dma-mapping: add support for CMA regions placed in highmem zone

Michal Nazarewicz mina86 at mina86.com
Mon Feb 4 08:51:52 EST 2013


On Mon, Feb 04 2013, Marek Szyprowski wrote:
> @@ -186,13 +186,24 @@ static u64 get_coherent_dma_mask(struct device *dev)
>  
>  static void __dma_clear_buffer(struct page *page, size_t size)
>  {
> -	void *ptr;
>  	/*
>  	 * Ensure that the allocated pages are zeroed, and that any data
>  	 * lurking in the kernel direct-mapped region is invalidated.
>  	 */
> -	ptr = page_address(page);
> -	if (ptr) {
> +	if (PageHighMem(page)) {
> +		phys_addr_t base = __pfn_to_phys(page_to_pfn(page));
> +		phys_addr_t end = base + size;
> +		while (size > 0) {
> +			void *ptr = kmap_atomic(page);
> +			memset(ptr, 0, PAGE_SIZE);
> +			dmac_flush_range(ptr, ptr + PAGE_SIZE);
> +			kunmap_atomic(ptr);
> +			page++;
> +			size -= PAGE_SIZE;
> +		}
> +		outer_flush_range(base, end);
> +	} else {
> +		void *ptr = page_address(page);

There used to be a “if (ptr)” check which is now missing.  Why is that?

>  		memset(ptr, 0, size);
>  		dmac_flush_range(ptr, ptr + size);
>  		outer_flush_range(__pa(ptr), __pa(ptr) + size);

-- 
Best regards,                                         _     _
.o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz    (o o)
ooo +----<email/xmpp: mpn at google.com>--------------ooO--(_)--Ooo--
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130204/c8c84ff1/attachment.sig>


More information about the linux-arm-kernel mailing list