Message ID | Pine.GSO.4.10.11003290409080.4435-100000@guinness |
---|---|
State | Accepted, archived |
Delegated to: | David Miller |
Headers | show |
From: Sreenivasa Honnur <Sreenivasa.Honnur@neterion.com> Date: Mon, 29 Mar 2010 04:09:47 -0400 (EDT) > - Align the memory only if it is misaligned. > > Signed-off-by: Sreenivasa Honnur <sreenivasa.honnur@neterion.com> > Signed-off-by: Ramkrishna Vepa <ram.vepa@neterion.com> Applied, but this vxge_os_dma_malloc code is completely unnecessary. If you want to allocate 4K chunks and make sure they are at least 128 byte aligned, you can allocated pages (which are always PAGE_SIZE aligned) and chop them up into the appropriate block size as needed. This is exactly how drivers/net/niu.c handles this situation. See drivers/net/niu.c:niu_rbr_add_page() -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
> From: Sreenivasa Honnur <Sreenivasa.Honnur@neterion.com> > Date: Mon, 29 Mar 2010 04:09:47 -0400 (EDT) > > > - Align the memory only if it is misaligned. > > > > Signed-off-by: Sreenivasa Honnur <sreenivasa.honnur@neterion.com> > > Signed-off-by: Ramkrishna Vepa <ram.vepa@neterion.com> > > Applied, but this vxge_os_dma_malloc code is completely > unnecessary. > > If you want to allocate 4K chunks and make sure they are at least 128 > byte aligned, you can allocated pages (which are always PAGE_SIZE > aligned) and chop them up into the appropriate block size as needed. > > This is exactly how drivers/net/niu.c handles this situation. > > See drivers/net/niu.c:niu_rbr_add_page() Thanks. We'll make this change. Ram -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
> If you want to allocate 4K chunks and make sure they are at least 128 > byte aligned, you can allocated pages (which are always PAGE_SIZE > aligned) and chop them up into the appropriate block size as needed. > > This is exactly how drivers/net/niu.c handles this situation. > > See drivers/net/niu.c:niu_rbr_add_page() Thanks Dave! There's quite a bit of change required in the driver for this. We'll submit the current set of patches we are working on and then look into submitting this change. Ram -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff -urpN patch2/drivers/net/vxge/vxge-config.h patch3/drivers/net/vxge/vxge-config.h --- patch2/drivers/net/vxge/vxge-config.h 2010-03-19 16:08:43.000000000 +0530 +++ patch3/drivers/net/vxge/vxge-config.h 2010-03-22 12:15:04.000000000 +0530 @@ -1914,20 +1914,32 @@ static inline void *vxge_os_dma_malloc(s gfp_t flags; void *vaddr; unsigned long misaligned = 0; + int realloc_flag = 0; *p_dma_acch = *p_dmah = NULL; if (in_interrupt()) flags = GFP_ATOMIC | GFP_DMA; else flags = GFP_KERNEL | GFP_DMA; - - size += VXGE_CACHE_LINE_SIZE; - +realloc: vaddr = kmalloc((size), flags); if (vaddr == NULL) return vaddr; - misaligned = (unsigned long)VXGE_ALIGN(*((u64 *)&vaddr), + misaligned = (unsigned long)VXGE_ALIGN((unsigned long)vaddr, VXGE_CACHE_LINE_SIZE); + if (realloc_flag) + goto out; + + if (misaligned) { + /* misaligned, free current one and try allocating + * size + VXGE_CACHE_LINE_SIZE memory + */ + kfree((void *) vaddr); + size += VXGE_CACHE_LINE_SIZE; + realloc_flag = 1; + goto realloc; + } +out: *(unsigned long *)p_dma_acch = misaligned; vaddr = (void *)((u8 *)vaddr + misaligned); return vaddr;