From patchwork Thu Aug 19 14:40:15 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 120365 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o7JEehjj030356 for ; Thu, 19 Aug 2010 14:40:43 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753748Ab0HSOkC (ORCPT ); Thu, 19 Aug 2010 10:40:02 -0400 Received: from mailout-de.gmx.net ([213.165.64.23]:60240 "HELO mail.gmx.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with SMTP id S1753637Ab0HSOkA (ORCPT ); Thu, 19 Aug 2010 10:40:00 -0400 Received: (qmail invoked by alias); 19 Aug 2010 14:39:58 -0000 Received: from p508982A3.dip0.t-ipconnect.de (EHLO axis700.grange) [80.137.130.163] by mail.gmx.net (mp055) with SMTP; 19 Aug 2010 16:39:58 +0200 X-Authenticated: #20450766 X-Provags-ID: V01U2FsdGVkX18vBYdqtYUvRWQedzT/eI2hs9icBZBJb+8aKZq3Rg YudkGjX3eFIDAj Received: from lyakh (helo=localhost) by axis700.grange with local-esmtp (Exim 4.63) (envelope-from ) id 1Om6Hv-0007dB-SQ; Thu, 19 Aug 2010 16:40:15 +0200 Date: Thu, 19 Aug 2010 16:40:15 +0200 (CEST) From: Guennadi Liakhovetski To: Russell King - ARM Linux cc: linux-sh@vger.kernel.org, Marin Mitov , =?ISO-8859-15?Q?Uwe_Kleine-K=F6nig?= , =?ISO-8859-15?Q?Philippe_R=E9tornaz?= , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, Janusz Krzysztofik Subject: [PATCH 3/5] DMA: reduce the number of memory allocations In-Reply-To: Message-ID: References: MIME-Version: 1.0 X-Y-GMX-Trusted: 0 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 19 Aug 2010 14:40:43 +0000 (UTC) diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c index f369e27..8efdfd4 100644 --- a/drivers/base/dma-coherent.c +++ b/drivers/base/dma-coherent.c @@ -11,7 +11,7 @@ struct dma_coherent_mem { dma_addr_t device_base; int size; int flags; - unsigned long *bitmap; + unsigned long bitmap[0]; }; int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr, @@ -34,12 +34,10 @@ int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr, if (!mem_base) goto out; - dev->dma_mem = kzalloc(sizeof(struct dma_coherent_mem), GFP_KERNEL); + dev->dma_mem = kzalloc(sizeof(struct dma_coherent_mem) + bitmap_size, + GFP_KERNEL); if (!dev->dma_mem) goto out; - dev->dma_mem->bitmap = kzalloc(bitmap_size, GFP_KERNEL); - if (!dev->dma_mem->bitmap) - goto free1_out; dev->dma_mem->virt_base = mem_base; dev->dma_mem->device_base = device_addr; @@ -51,8 +49,6 @@ int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr, return DMA_MEMORY_IO; - free1_out: - kfree(dev->dma_mem); out: if (mem_base) iounmap(mem_base); @@ -68,7 +64,6 @@ void dma_release_declared_memory(struct device *dev) return; dev->dma_mem = NULL; iounmap(mem->virt_base); - kfree(mem->bitmap); kfree(mem); } EXPORT_SYMBOL(dma_release_declared_memory);