public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH,resend] Fix strange panic message selection logic when swiotlb fills up
@ 2009-08-20 19:52 Casey Dahlin
  2009-08-20 23:25 ` Andrew Morton
  0 siblings, 1 reply; 2+ messages in thread
From: Casey Dahlin @ 2009-08-20 19:52 UTC (permalink / raw)
  To: Linux Kernel; +Cc: akpm, torvalds, beckyb

swiotlb_full in lib/swiotlb.c throws one of two panic messages based on whether
the direction of transfer is from the device or to the device. The logic around
this is somewhat weird in the case of bidirectional transfers. It appears to
want to throw both in succession, but since its a panic only the first makes it.

This patch adds a third, separate error for DMA_BIDIRECTIONAL to make things a
bit clearer.

Signed-off-by: Casey Dahlin <cdahlin@redhat.com>

---
 lib/swiotlb.c |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

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");
 }
 
 /*

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH,resend] Fix strange panic message selection logic when swiotlb fills up
  2009-08-20 19:52 [PATCH,resend] Fix strange panic message selection logic when swiotlb fills up Casey Dahlin
@ 2009-08-20 23:25 ` Andrew Morton
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2009-08-20 23:25 UTC (permalink / raw)
  To: Casey Dahlin; +Cc: linux-kernel, torvalds, beckyb

On Thu, 20 Aug 2009 15:52:28 -0400
Casey Dahlin <cdahlin@redhat.com> wrote:

> swiotlb_full in lib/swiotlb.c throws one of two panic messages based on whether
> the direction of transfer is from the device or to the device. The logic around
> this is somewhat weird in the case of bidirectional transfers. It appears to
> want to throw both in succession, but since its a panic only the first makes it.
> 
> This patch adds a third, separate error for DMA_BIDIRECTIONAL to make things a
> bit clearer.
> 
> Signed-off-by: Casey Dahlin <cdahlin@redhat.com>
> 
> ---
>  lib/swiotlb.c |   15 +++++++++------
>  1 files changed, 9 insertions(+), 6 deletions(-)
> 
> 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");
>  }
>  

Seems sane to me.

While we're there, how about we make the final message less ambiguous? 

--- a/lib/swiotlb.c~lib-swiotlbc-fix-strange-panic-message-selection-logic-when-swiotlb-fills-up-fix
+++ a/lib/swiotlb.c
@@ -633,7 +633,7 @@ swiotlb_full(struct device *dev, size_t 
 	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");
+		panic("DMA: Random memory would be DMAed from\n");
 }
 
 /*
_


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-08-20 23:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-20 19:52 [PATCH,resend] Fix strange panic message selection logic when swiotlb fills up Casey Dahlin
2009-08-20 23:25 ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox