All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roland Dreier <roland@kernel.org>
To: Joerg Roedel <joerg.roedel@amd.com>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] dma-debug: Fix deadlock with netconsole or other drivers that use the DMA API
Date: Thu, 19 Apr 2012 11:12:53 -0700	[thread overview]
Message-ID: <1334859173-9446-1-git-send-email-roland@kernel.org> (raw)

From: Roland Dreier <roland@purestorage.com>

If we exhaust the free_entries list, then we print the error message

    DMA-API: debugging out of memory - disabling

to the kernel log, while holding free_entries_lock.  Unfortunately, if
the console driver ends up calling back into the DMA API to map a
buffer, as eg a NIC driver is quite likely to for the packet netconsole
asks it to send, this will deadlock on free_entries_lock.

A fix is pretty simple: if we flip the order of setting global_disable
to be before we print the error message, then the nested call into the
DMA API will bail out before trying to get free_entries_lock.

Signed-off-by: Roland Dreier <roland@purestorage.com>
---
 lib/dma-debug.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/dma-debug.c b/lib/dma-debug.c
index 13ef233..f198b4e 100644
--- a/lib/dma-debug.c
+++ b/lib/dma-debug.c
@@ -436,8 +436,8 @@ static struct dma_debug_entry *dma_entry_alloc(void)
 	spin_lock_irqsave(&free_entries_lock, flags);
 
 	if (list_empty(&free_entries)) {
-		pr_err("DMA-API: debugging out of memory - disabling\n");
 		global_disable = true;
+		pr_err("DMA-API: debugging out of memory - disabling\n");
 		goto out;
 	}
 
-- 
1.7.9.5


             reply	other threads:[~2012-04-19 18:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-19 18:12 Roland Dreier [this message]
2012-04-19 18:48 ` [PATCH] dma-debug: Fix deadlock with netconsole or other drivers that use the DMA API Andrew Morton
2012-04-19 23:36   ` Roland Dreier
2012-04-19 23:50     ` Andrew Morton
2012-04-20 11:22   ` Joerg Roedel

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=1334859173-9446-1-git-send-email-roland@kernel.org \
    --to=roland@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=joerg.roedel@amd.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.