linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linaro-mm-sig@lists.linaro.org, Arnd Bergmann <arnd@arndb.de>,
	Michal Nazarewicz <mina86@mina86.com>,
	Grant Likely <grant.likely@linaro.org>,
	Laura Abbott <lauraa@codeaurora.org>,
	Josh Cartwright <joshc@codeaurora.org>,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>,
	Kyungmin Park <kyungmin.park@samsung.com>
Subject: Re: [PATCH v2 2/3] drivers: dma-coherent: add initialization from device tree
Date: Wed, 24 Sep 2014 15:26:06 -0700	[thread overview]
Message-ID: <20140924152606.4f4daa63d01c55b69b1ec617@linux-foundation.org> (raw)
In-Reply-To: <1410434561-9294-3-git-send-email-m.szyprowski@samsung.com>

On Thu, 11 Sep 2014 13:22:40 +0200 Marek Szyprowski <m.szyprowski@samsung.com> 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;
_


  reply	other threads:[~2014-09-24 22:26 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-11 11:22 [PATCH v2 0/3] CMA & device tree, another approach Marek Szyprowski
2014-09-11 11:22 ` [PATCH v2 1/3] drivers: of: add return value to of_reserved_mem_device_init Marek Szyprowski
2014-09-26  6:44   ` [PATCH v2 1/3] drivers: of: add return value to of_reserved_mem_device_init (fixup) Marek Szyprowski
2014-09-27 13:58     ` Fabio Estevam
2014-09-26 20:13   ` [PATCH v2 1/3] drivers: of: add return value to of_reserved_mem_device_init Arnd Bergmann
2014-10-09 12:18   ` [PATCH v3] " Marek Szyprowski
2014-10-13 11:19     ` Arnd Bergmann
2014-10-15 11:01       ` [PATCH v4] " Marek Szyprowski
2014-10-20 19:04         ` [Linaro-mm-sig] " Arnd Bergmann
2014-09-11 11:22 ` [PATCH v2 2/3] drivers: dma-coherent: add initialization from device tree Marek Szyprowski
2014-09-24 22:26   ` Andrew Morton [this message]
2014-09-24 22:28   ` Andrew Morton
2014-09-11 11:22 ` [PATCH v2 3/3] drivers: dma-contiguous: " Marek Szyprowski
2014-09-23  8:05 ` [PATCH v2 0/3] CMA & device tree, another approach Marek Szyprowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140924152606.4f4daa63d01c55b69b1ec617@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=grant.likely@linaro.org \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=joshc@codeaurora.org \
    --cc=kyungmin.park@samsung.com \
    --cc=lauraa@codeaurora.org \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=mina86@mina86.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).