linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: stefano.stabellini@eu.citrix.com (Stefano Stabellini)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v8 05/17] xen: make xen_create_contiguous_region return the dma address
Date: Wed, 9 Oct 2013 21:48:18 +0100	[thread overview]
Message-ID: <1381351710-1876-5-git-send-email-stefano.stabellini@eu.citrix.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1310092109190.26077@kaball.uk.xensource.com>

Modify xen_create_contiguous_region to return the dma address of the
newly contiguous buffer.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: David Vrabel <david.vrabel@citrix.com>


Changes in v4:
- use virt_to_machine instead of virt_to_bus.
---
 arch/x86/xen/mmu.c        |    4 +++-
 drivers/xen/swiotlb-xen.c |    6 +++---
 include/xen/xen-ops.h     |    3 ++-
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index fdc3ba2..6c34d7c 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -2329,7 +2329,8 @@ static int xen_exchange_memory(unsigned long extents_in, unsigned int order_in,
 }
 
 int xen_create_contiguous_region(unsigned long vstart, unsigned int order,
-				 unsigned int address_bits)
+				 unsigned int address_bits,
+				 dma_addr_t *dma_handle)
 {
 	unsigned long *in_frames = discontig_frames, out_frame;
 	unsigned long  flags;
@@ -2368,6 +2369,7 @@ int xen_create_contiguous_region(unsigned long vstart, unsigned int order,
 
 	spin_unlock_irqrestore(&xen_reservation_lock, flags);
 
+	*dma_handle = virt_to_machine(vstart).maddr;
 	return success ? 0 : -ENOMEM;
 }
 EXPORT_SYMBOL_GPL(xen_create_contiguous_region);
diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c
index 1b2277c..b72f31c 100644
--- a/drivers/xen/swiotlb-xen.c
+++ b/drivers/xen/swiotlb-xen.c
@@ -126,6 +126,7 @@ xen_swiotlb_fixup(void *buf, size_t size, unsigned long nslabs)
 {
 	int i, rc;
 	int dma_bits;
+	dma_addr_t dma_handle;
 
 	dma_bits = get_order(IO_TLB_SEGSIZE << IO_TLB_SHIFT) + PAGE_SHIFT;
 
@@ -137,7 +138,7 @@ xen_swiotlb_fixup(void *buf, size_t size, unsigned long nslabs)
 			rc = xen_create_contiguous_region(
 				(unsigned long)buf + (i << IO_TLB_SHIFT),
 				get_order(slabs << IO_TLB_SHIFT),
-				dma_bits);
+				dma_bits, &dma_handle);
 		} while (rc && dma_bits++ < max_dma_bits);
 		if (rc)
 			return rc;
@@ -294,11 +295,10 @@ xen_swiotlb_alloc_coherent(struct device *hwdev, size_t size,
 		*dma_handle = dev_addr;
 	else {
 		if (xen_create_contiguous_region(vstart, order,
-						 fls64(dma_mask)) != 0) {
+						 fls64(dma_mask), dma_handle) != 0) {
 			free_pages(vstart, order);
 			return NULL;
 		}
-		*dma_handle = virt_to_machine(ret).maddr;
 	}
 	memset(ret, 0, size);
 	return ret;
diff --git a/include/xen/xen-ops.h b/include/xen/xen-ops.h
index d6fe062..9ef704d 100644
--- a/include/xen/xen-ops.h
+++ b/include/xen/xen-ops.h
@@ -20,7 +20,8 @@ int xen_setup_shutdown_event(void);
 
 extern unsigned long *xen_contiguous_bitmap;
 int xen_create_contiguous_region(unsigned long vstart, unsigned int order,
-				unsigned int address_bits);
+				unsigned int address_bits,
+				dma_addr_t *dma_handle);
 
 void xen_destroy_contiguous_region(unsigned long vstart, unsigned int order);
 
-- 
1.7.2.5

  parent reply	other threads:[~2013-10-09 20:48 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-09 20:47 [PATCH v7 0/17] enable swiotlb-xen on arm and arm64 Stefano Stabellini
2013-10-09 20:48 ` [PATCH v8 01/17] arm: make SWIOTLB available Stefano Stabellini
2013-10-10  9:43   ` Will Deacon
2013-10-15 15:45     ` Stefano Stabellini
2013-10-09 20:48 ` [PATCH v8 02/17] arm64: define DMA_ERROR_CODE Stefano Stabellini
2013-10-10  9:44   ` Will Deacon
2013-10-15 15:46     ` Stefano Stabellini
2013-10-09 20:48 ` [PATCH v8 03/17] arm/xen,arm64/xen: introduce p2m Stefano Stabellini
2013-10-09 20:48 ` [PATCH v8 04/17] xen/x86: allow __set_phys_to_machine for autotranslate guests Stefano Stabellini
2013-10-09 20:48 ` Stefano Stabellini [this message]
2013-10-09 20:48 ` [PATCH v8 06/17] xen/arm,arm64: enable SWIOTLB_XEN Stefano Stabellini
2013-10-09 20:48 ` [PATCH v8 07/17] swiotlb-xen: introduce xen_swiotlb_set_dma_mask Stefano Stabellini
2013-10-09 20:48 ` [PATCH v8 08/17] arm/xen: get_dma_ops: return xen_dma_ops if we are running as xen_initial_domain Stefano Stabellini
2013-10-09 20:48 ` [PATCH v8 09/17] arm64/xen: " Stefano Stabellini
2013-10-09 20:48 ` [PATCH v8 10/17] xen: introduce xen_alloc/free_coherent_pages Stefano Stabellini
2013-10-09 20:48 ` [PATCH v8 11/17] swiotlb-xen: use xen_alloc/free_coherent_pages Stefano Stabellini
2013-10-09 20:48 ` [PATCH v8 12/17] xen: introduce xen_dma_map/unmap_page and xen_dma_sync_single_for_cpu/device Stefano Stabellini
2013-10-09 20:48 ` [PATCH v8 13/17] swiotlb-xen: use xen_dma_map/unmap_page, xen_dma_sync_single_for_cpu/device Stefano Stabellini
2013-10-09 20:48 ` [PATCH v8 14/17] ASoC: Samsung: Rename dma_ops by samsung_dma_ops Stefano Stabellini
2013-10-09 20:48 ` [PATCH v8 15/17] swiotlb: print a warning when the swiotlb is full Stefano Stabellini
2013-10-09 20:48 ` [PATCH v8 16/17] arm, arm64: do not always merge biovec if we are running on Xen Stefano Stabellini
2013-10-09 20:48 ` [PATCH v8 17/17] grant-table: call set_phys_to_machine after mapping grant refs Stefano Stabellini

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=1381351710-1876-5-git-send-email-stefano.stabellini@eu.citrix.com \
    --to=stefano.stabellini@eu.citrix.com \
    --cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).