From 6db59e857fc5a41892252b6c2c9a9b8788ad0c04 Mon Sep 17 00:00:00 2001 From: Roy Pledge Date: Tue, 2 Dec 2014 11:19:07 -0500 Subject: Reserve proper length in processes VMA when mapping USDPAA memory USDPAA memory mapping were not properly reserving the entire length of the memory area when perfoming mapping of not power of 4 regions. This causes issues if the choosen address overlapped with an existing memory area. Signed-off-by: Roy Pledge Change-Id: I078d12279a43ddf3fc7c5de4b9e4a932d588832e Reviewed-on: http://git.am.freescale.net:8181/25329 Tested-by: Review Code-CDREVIEW Reviewed-by: Geoff Thorpe Reviewed-by: Matthew Weigel diff --git a/drivers/staging/fsl_qbman/fsl_usdpaa.c b/drivers/staging/fsl_qbman/fsl_usdpaa.c index e5e4fa2..8cfdabe 100644 --- a/drivers/staging/fsl_qbman/fsl_usdpaa.c +++ b/drivers/staging/fsl_qbman/fsl_usdpaa.c @@ -766,14 +766,13 @@ static unsigned long usdpaa_get_unmapped_area(struct file *file, if (len % PAGE_SIZE) return -EINVAL; - /* Need to align to largest pagesize to ensure all pages - will be correctly aligned */ - len = largest_page_size(len); - if (!len) return -EINVAL; - addr = USDPAA_MEM_ROUNDUP(addr, len); + /* Need to align the address to the largest pagesize of the mapping + * because the MMU requires the virtual address to have the same + * alignment as the physical address */ + addr = USDPAA_MEM_ROUNDUP(addr, largest_page_size(len)); vma = find_vma(current->mm, addr); /* Keep searching until we reach the end of currently-used virtual * address-space or we find a big enough gap. */ @@ -781,7 +780,7 @@ static unsigned long usdpaa_get_unmapped_area(struct file *file, if ((addr + len) < vma->vm_start) return addr; - addr = USDPAA_MEM_ROUNDUP(vma->vm_end, len); + addr = USDPAA_MEM_ROUNDUP(vma->vm_end, largest_page_size(len)); vma = vma->vm_next; } if ((TASK_SIZE - len) < addr) -- cgit v0.10.2