LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Andi Kleen <andi@firstfloor.org>
To: axboe@kernel.dk, linux-kernel@vger.kernel.org
Subject: [PATCH] [7/7] Allow swiotlb to move block data bouncing to the block layer
Date: Fri,  7 Mar 2008 10:13:28 +0100 (CET)	[thread overview]
Message-ID: <20080307091328.138F61B419C@basil.firstfloor.org> (raw)
In-Reply-To: <200803071013.837692778@firstfloor.org>


The block layer is generally in a better position to bounce
than swiotlb because it is allowed to sleep at
the right places. swiotlb cannot do that and is thus more prone
to panic and failing on overflow.

With the mask allocator pool block layer bouncing and swiotlb
allocate from the same pool, so it's quite possible to shift
some of the bounce burden to the block layer.

This patch adds a new variable to set the bounce threshold
for 64bit hosts and sets it to zero for swiotlb. This has
the effect to always doing the data bounces in the block layer 
for swiotlb, assuming the block driver set the correct
bounce pfn. If it forgets that only sets its dma mask
swiotlb will still take the burden.

Signed-off-by: Andi Kleen <ak@suse.de>

---
 arch/x86/kernel/pci-swiotlb_64.c |    3 +++
 block/blk-settings.c             |    4 +++-
 include/linux/blkdev.h           |    2 +-
 3 files changed, 7 insertions(+), 2 deletions(-)

Index: linux/block/blk-settings.c
===================================================================
--- linux.orig/block/blk-settings.c
+++ linux/block/blk-settings.c
@@ -16,6 +16,8 @@ EXPORT_SYMBOL(blk_max_low_pfn);
 unsigned long blk_max_pfn;
 EXPORT_SYMBOL(blk_max_pfn);
 
+unsigned long blk_min_iommu = 0xffffffff;
+
 /**
  * blk_queue_prep_rq - set a prepare_request function for queue
  * @q:		queue
@@ -139,7 +141,7 @@ void blk_queue_bounce_limit(struct reque
 	/* Assume anything <= 4GB can be handled by IOMMU.
 	   Actually some IOMMUs can handle everything, but I don't
 	   know of a way to test this here. */
-	if (b_pfn <= (min_t(u64, 0xffffffff, BLK_BOUNCE_HIGH) >> PAGE_SHIFT))
+	if (b_pfn <= (min_t(u64, blk_min_iommu, BLK_BOUNCE_HIGH) >> PAGE_SHIFT))
 		dma = 1;
 	q->bounce_pfn = max_low_pfn;
 #else
Index: linux/arch/x86/kernel/pci-swiotlb_64.c
===================================================================
--- linux.orig/arch/x86/kernel/pci-swiotlb_64.c
+++ linux/arch/x86/kernel/pci-swiotlb_64.c
@@ -15,6 +15,7 @@
 #include <linux/ctype.h>
 #include <linux/bootmem.h>
 #include <linux/hardirq.h>
+#include <linux/blkdev.h>
 
 #include <asm/gart.h>
 #include <asm/swiotlb.h>
@@ -411,6 +412,8 @@ void __init pci_swiotlb_init(void)
 
 		dma_ops = &dmatlb_dma_ops;
 	}
+
+	blk_min_iommu = BLK_BOUNCE_HIGH;
 }
 
 #define COMPAT_IO_TLB_SHIFT 11
Index: linux/include/linux/blkdev.h
===================================================================
--- linux.orig/include/linux/blkdev.h
+++ linux/include/linux/blkdev.h
@@ -523,7 +523,7 @@ static inline void blk_clear_queue_full(
 #define BLKPREP_KILL		1	/* fatal error, kill */
 #define BLKPREP_DEFER		2	/* leave on queue */
 
-extern unsigned long blk_max_low_pfn, blk_max_pfn;
+extern unsigned long blk_max_low_pfn, blk_max_pfn, blk_min_iommu;
 
 /*
  * standard bounce addresses:

  parent reply	other threads:[~2008-03-07  9:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-07  9:13 [PATCH] [0/7] Block layer rework for mask allocator Andi Kleen
2008-03-07  9:13 ` [PATCH] [1/7] Convert a few direct bounce_gfp users over to the blk_* wrappers Andi Kleen
2008-03-07  9:13 ` [PATCH] [2/7] Convert open coded reference in libata to q->bounce_gfp to blk_kmalloc Andi Kleen
2008-03-07 21:06   ` Jeff Garzik
2008-03-07  9:13 ` [PATCH] [3/7] Add mempool support for page allocation through the mask allocator Andi Kleen
2008-03-07  9:13 ` [PATCH] [4/7] Add blk_q_mask Andi Kleen
2008-03-07  9:13 ` [PATCH] [5/7] Convert the blk allocator functions over to the mask allocator Andi Kleen
2008-03-07  9:13 ` [PATCH] [6/7] Remove bounce_gfp Andi Kleen
2008-03-07  9:13 ` Andi Kleen [this message]
2008-03-08 12:08   ` [PATCH] [7/7] Allow swiotlb to move block data bouncing to the block layer Andi Kleen

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=20080307091328.138F61B419C@basil.firstfloor.org \
    --to=andi@firstfloor.org \
    --cc=axboe@kernel.dk \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: [PATCH] [7/7] Allow swiotlb to move block data bouncing to the block layer' \
    /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

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).