From: Casey Dahlin <cdahlin@redhat.com>
To: torvalds@linux-foundation.org
Cc: Linux Kernel <linux-kernel@vger.kernel.org>
Subject: [PATCH] Fix strange panic message selection logic when swiotlb fills up
Date: Mon, 13 Jul 2009 15:36:12 -0400 [thread overview]
Message-ID: <4A5B8CAC.3060906@redhat.com> (raw)
swiotlb_full in lib/swiotlb.c contains the following code snippet to produce a panic when the software iotlb is too full to handle a new allocation:
if (size > io_tlb_overflow && do_panic) {
if (dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL)
panic("DMA: Memory would be corrupted\n");
if (dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL)
panic("DMA: Random memory would be DMAed\n");
}
Note the path when dir == DMA_BIDIRECTIONAL. The first panic() will be called always, yet the second if statement still checks for DMA_BIDIRECTIONAL. Unless we intend to panic twice, this is somewhat confusing.
This patch adds a third, separate error for DMA_BIDIRECTIONAL to make things a bit clearer.
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index bffe6d7..35e01b3 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -625,12 +625,15 @@ swiotlb_full(struct device *dev, size_t size, int dir, int do_panic)
printk(KERN_ERR "DMA: Out of SW-IOMMU space for %zu bytes at "
"device %s\n", size, dev ? dev_name(dev) : "?");
- if (size > io_tlb_overflow && do_panic) {
- if (dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL)
- panic("DMA: Memory would be corrupted\n");
- if (dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL)
- panic("DMA: Random memory would be DMAed\n");
- }
+ if (size <= io_tlb_overflow || !do_panic)
+ return;
+
+ if (dir == DMA_BIDIRECTIONAL)
+ panic("DMA: Random memory could be corrupted or DMAed\n");
+ if (dir == DMA_FROM_DEVICE)
+ panic("DMA: Memory would be corrupted\n");
+ if (dir == DMA_TO_DEVICE)
+ panic("DMA: Random memory would be DMAed\n");
}
/*
reply other threads:[~2009-07-13 19:31 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=4A5B8CAC.3060906@redhat.com \
--to=cdahlin@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.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.