From patchwork Wed Sep 24 22:26:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 4971441 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B8A2BBEEA6 for ; Wed, 24 Sep 2014 22:28:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E7F1420270 for ; Wed, 24 Sep 2014 22:28:47 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DCF832026F for ; Wed, 24 Sep 2014 22:28:46 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XWv15-0000vp-8h; Wed, 24 Sep 2014 22:26:31 +0000 Received: from mail.linuxfoundation.org ([140.211.169.12]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XWv12-0000tO-Rz for linux-arm-kernel@lists.infradead.org; Wed, 24 Sep 2014 22:26:29 +0000 Received: from akpm3.mtv.corp.google.com (unknown [216.239.45.95]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 7A0D9B19; Wed, 24 Sep 2014 22:26:07 +0000 (UTC) Date: Wed, 24 Sep 2014 15:26:06 -0700 From: Andrew Morton To: Marek Szyprowski Subject: Re: [PATCH v2 2/3] drivers: dma-coherent: add initialization from device tree Message-Id: <20140924152606.4f4daa63d01c55b69b1ec617@linux-foundation.org> In-Reply-To: <1410434561-9294-3-git-send-email-m.szyprowski@samsung.com> References: <1410434561-9294-1-git-send-email-m.szyprowski@samsung.com> <1410434561-9294-3-git-send-email-m.szyprowski@samsung.com> X-Mailer: Sylpheed 3.2.0beta5 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140924_152628_931261_67F0564F X-CRM114-Status: GOOD ( 15.52 ) X-Spam-Score: -2.3 (--) Cc: Laura Abbott , Arnd Bergmann , Josh Cartwright , linux-kernel@vger.kernel.org, Michal Nazarewicz , linaro-mm-sig@lists.linaro.org, Kyungmin Park , Grant Likely , Joonsoo Kim , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Thu, 11 Sep 2014 13:22:40 +0200 Marek Szyprowski wrote: > Initialization procedure of dma coherent pool has been split into two > parts, so memory pool can now be initialized without assigning to > particular struct device. Then initialized region can be assigned to > more than one struct device. To protect from concurent allocations from > different devices, a spinlock has been added to dma_coherent_mem > structure. The last part of this patch adds support for handling > 'shared-dma-pool' reserved-memory device tree nodes. > > --- a/drivers/base/dma-coherent.c > +++ b/drivers/base/dma-coherent.c > @@ -14,11 +14,14 @@ struct dma_coherent_mem { > int size; > int flags; > unsigned long *bitmap; > + spinlock_t spinlock; A bit of documentation would be nice: explain what the lock protects, that it is irq-safe, etc. > }; > > -int dma_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr, > - dma_addr_t device_addr, size_t size, int flags) > +static int dma_init_coherent_memory(phys_addr_t phys_addr, dma_addr_t device_addr, > + size_t size, int flags, > + struct dma_coherent_mem **mem) > { > + struct dma_coherent_mem *dma_mem = NULL; The only reason to initialise this is so we can kfree() it without checking. In which case we don't need label free1_out? --- a/drivers/base/dma-coherent.c~drivers-dma-coherent-add-initialization-from-device-tree-fix +++ a/drivers/base/dma-coherent.c @@ -40,7 +40,7 @@ static int dma_init_coherent_memory(phys goto out; dma_mem->bitmap = kzalloc(bitmap_size, GFP_KERNEL); if (!dma_mem->bitmap) - goto free1_out; + goto out; dma_mem->virt_base = mem_base; dma_mem->device_base = device_addr; @@ -56,9 +56,8 @@ static int dma_init_coherent_memory(phys return DMA_MEMORY_IO; - free1_out: +out: kfree(dma_mem); - out: if (mem_base) iounmap(mem_base); return 0;