mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mark Craske <Mark_Craske@mentor.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: <linux-kernel@vger.kernel.org>,
	"George G. Davis" <George_Davis@mentor.com>,
	Jiada Wang <Jiada_Wang@mentor.com>
Subject: [PATCH v1 2/2] drivers: dma-coherent: Move spinlock in dma_alloc_from_coherent()
Date: Thu, 15 Sep 2016 10:39:59 +0100	[thread overview]
Message-ID: <1473932399-23224-3-git-send-email-Mark_Craske@mentor.com> (raw)
In-Reply-To: <1473932399-23224-1-git-send-email-Mark_Craske@mentor.com>

From: Bastian Hecht <bhecht@de.adit-jv.com>

We don't need to hold the spinlock while zeroing the allocated memory.
In case we handle big buffers this is a severe issue as other CPUs might
be spinning half a second or longer.

Signed-off-by: Bastian Hecht <bhecht@de.adit-jv.com>
Signed-off-by: George G. Davis <george_davis@mentor.com>
Signed-off-by: Mark Craske <Mark_Craske@mentor.com>
---
 drivers/base/dma-coherent.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c
index abd83b7..d092df4 100644
--- a/drivers/base/dma-coherent.c
+++ b/drivers/base/dma-coherent.c
@@ -165,6 +165,7 @@ int dma_alloc_from_coherent(struct device *dev, ssize_t size,
 	int order = get_order(size);
 	unsigned long flags;
 	int pageno;
+	int dma_memory_map;
 
 	if (!dev)
 		return 0;
@@ -187,11 +188,12 @@ int dma_alloc_from_coherent(struct device *dev, ssize_t size,
 	 */
 	*dma_handle = mem->device_base + (pageno << PAGE_SHIFT);
 	*ret = mem->virt_base + (pageno << PAGE_SHIFT);
-	if (mem->flags & DMA_MEMORY_MAP)
+	dma_memory_map = (mem->flags & DMA_MEMORY_MAP);
+	spin_unlock_irqrestore(&mem->spinlock, flags);
+	if (dma_memory_map)
 		memset(*ret, 0, size);
 	else
 		memset_io(*ret, 0, size);
-	spin_unlock_irqrestore(&mem->spinlock, flags);
 
 	return 1;
 
-- 
1.7.9.5

  parent reply	other threads:[~2016-09-15  9:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <Mark Craske <Mark_Craske@mentor.com>
2016-09-15  9:39 ` [PATCH v1 0/2] Two small dma-coherent bug fixes Mark Craske
2016-09-15  9:39   ` [PATCH v1 1/2] drivers: dma-coherent: Fix DMA coherent size for less than page Mark Craske
2016-09-27 10:53     ` Greg Kroah-Hartman
2016-09-15  9:39   ` Mark Craske [this message]
2016-09-28  7:51 ` [PATCH v2 0/2] Two small dma-coherent bug fixes Mark Craske
2016-09-28  7:51   ` [PATCH v2 1/2] drivers: dma-coherent: Fix DMA coherent size for less than page Mark Craske
2016-09-28  7:51   ` [PATCH v2 2/2] drivers: dma-coherent: Move spinlock in dma_alloc_from_coherent() Mark Craske

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=1473932399-23224-3-git-send-email-Mark_Craske@mentor.com \
    --to=mark_craske@mentor.com \
    --cc=George_Davis@mentor.com \
    --cc=Jiada_Wang@mentor.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®