From patchwork Mon Mar 29 08:09:47 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sreenivasa Honnur X-Patchwork-Id: 48814 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 1C4D1B6EEB for ; Mon, 29 Mar 2010 19:23:30 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753370Ab0C2IXY (ORCPT ); Mon, 29 Mar 2010 04:23:24 -0400 Received: from barracuda.s2io.com ([72.1.205.138]:48131 "EHLO barracuda.s2io.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753027Ab0C2IXW (ORCPT ); Mon, 29 Mar 2010 04:23:22 -0400 X-ASG-Debug-ID: 1269850188-55b5000e0000-gSecQ8 X-Barracuda-URL: http://72.1.205.138:8000/cgi-bin/mark.cgi Received: from guinness.s2io.com (localhost [127.0.0.1]) by barracuda.s2io.com (Spam & Virus Firewall) with ESMTP id 9D41F20B929F; Mon, 29 Mar 2010 04:09:48 -0400 (EDT) Received: from guinness.s2io.com (142-46-210.147.tel-ott.com [142.46.210.147]) by barracuda.s2io.com with ESMTP id gOEysQsAK1BxZUZd; Mon, 29 Mar 2010 04:09:48 -0400 (EDT) X-Barracuda-Envelope-From: Sreenivasa.Honnur@neterion.com X-ASG-Whitelist: Client Received: from guinness.s2io.com (localhost [127.0.0.1]) by guinness.s2io.com (8.12.6/8.12.6) with ESMTP id o2T89mmd004657; Mon, 29 Mar 2010 04:09:48 -0400 (EDT) Received: from localhost (shonnur@localhost) by guinness.s2io.com (8.12.6/8.12.6/Submit) with ESMTP id o2T89lsR004654; Mon, 29 Mar 2010 04:09:47 -0400 (EDT) Date: Mon, 29 Mar 2010 04:09:47 -0400 (EDT) From: Sreenivasa Honnur To: davem@davemloft.net cc: netdev@vger.kernel.org, support@neterion.com X-ASG-Orig-Subj: [net-next-2.6 PATCH 3/8] vxge: Align the memory only if it is misaligned. Subject: [net-next-2.6 PATCH 3/8] vxge: Align the memory only if it is misaligned. Message-ID: MIME-Version: 1.0 X-Barracuda-Connect: 142-46-210.147.tel-ott.com[142.46.210.147] X-Barracuda-Start-Time: 1269850188 X-Barracuda-Virus-Scanned: by Barracuda Spam & Virus Firewall at s2io.com Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org - Align the memory only if it is misaligned. Signed-off-by: Sreenivasa Honnur Signed-off-by: Ramkrishna Vepa --- -- 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;