diff options
author | Sreenivasa Honnur <Sreenivasa.Honnur@neterion.com> | 2010-03-29 00:09:47 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-03-30 01:57:21 +0200 |
commit | 47231f7fb49bed800dd806b4c32f881005d84de8 (patch) | |
tree | 9f2e28e4410373b2d8a8137652666784a9530a78 /drivers/net/vxge/vxge-config.h | |
parent | vxge: Fix starvation of receive ring controller when blasted by short packets. (diff) | |
download | linux-47231f7fb49bed800dd806b4c32f881005d84de8.tar.xz linux-47231f7fb49bed800dd806b4c32f881005d84de8.zip |
vxge: Align the memory only if it is misaligned.
- 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>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/vxge/vxge-config.h')
-rw-r--r-- | drivers/net/vxge/vxge-config.h | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/drivers/net/vxge/vxge-config.h b/drivers/net/vxge/vxge-config.h index e7877df092f3..01595242a6e8 100644 --- a/drivers/net/vxge/vxge-config.h +++ b/drivers/net/vxge/vxge-config.h @@ -1914,20 +1914,32 @@ static inline void *vxge_os_dma_malloc(struct pci_dev *pdev, 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; |