LKML Archive mirror
 help / color / mirror / Atom feed
* [PATCH v8 0/13] introduce GNTTABOP_cache_flush
@ 2014-11-10 16:12 Stefano Stabellini
  2014-11-10 16:13 ` [PATCH v8 01/13] xen/arm: remove handling of XENFEAT_grant_map_identity Stefano Stabellini
                   ` (13 more replies)
  0 siblings, 14 replies; 25+ messages in thread
From: Stefano Stabellini @ 2014-11-10 16:12 UTC (permalink / raw
  To: xen-devel
  Cc: Konrad Rzeszutek Wilk, Ian Campbell, David Vrabel, linux-kernel,
	Stefano Stabellini, linux-arm-kernel, catalin.marinas

Hi all,
this patch series introduces support for GNTTABOP_cache_flush to perform
cache maintenance operation on foreign pages and reverts the current
code based on XENFEAT_grant_map_identity.

It also provides a very slow fallback by bouncing on the swiotlb buffer,
in case the hypercall is not available.

v7 introduces a flag named dma_coherent in dev_archdata and an accessor
function named is_device_dma_coherent in asm/dma-mapping.h under arm and
arm64.


Changes in v8:
- remove code duplication in mm32.c by moving the pfn_valid check in
page-coherent.h;
- add a dma_addr_t dev_addr argument to xen_dma_map_page;
- use hypercall to flush caches in map_page;
- pass dev_addr to xen_dma_unmap_page and xen_dma_sync_single_for_cpu;
- remove BUG_ON in xen_bus_to_phys.

Changes in v7:
- rebased on 3.18-rc1;
- rename is_dma_coherent to is_device_dma_coherent and move it to
asm/dma-mapping.h on arm and arm64;
- introduce a dma_coherent flag on arm and arm64;
- set the flags from set_arch_dma_coherent_ops.

Changes in v6:
- rename xen_is_dma_coherent to is_dma_coherent;
- use of_dma_is_coherent to detect the dma coherency of a device;
- remove arch/arm64/include/asm/xen/page-coherent.h, include
../../arm/include/asm/xen/page-coherent.h instead;
- fix indentation.

Changes in v5:
- introduce xen_is_dma_coherent as a xen specific function;
- call xen_is_dma_coherent instead of is_dma_coherent;
- introduce xen_is_dma_coherent to
arch/arm64/include/asm/xen/page-coherent.h;
- do not remove arch/arm64/include/asm/xen/page-coherent.h, add
the missing dma_ops calls from it;
- fix indentation;
- rename hypercall_flush to hypercall_cflush;
- remove spurious change.

Changes in v4:
- remove outer_*_range call;
- introduce is_dma_coherent;
- use is_dma_coherent in arch/arm/xen/mm32.c;
- merge xen/mm32.c into xen/mm.c;
- xen/arm/arm64: introduce xen_arch_need_swiotlb;
- avoid bouncing dma map operations that involve foreign grants and
non-coherent devices if GNTTABOP_cache_flush is provided by Xen.

Changes in v3:
- fix the cache maintenance op call to match what Linux does natively;
- update the hypercall interface to match Xen.

Changes in v2:
- remove the definition of XENFEAT_grant_map_identity;
- update the hypercall interface to match Xen;
- call the interface on a single page at a time.


Stefano Stabellini (13):
      xen/arm: remove handling of XENFEAT_grant_map_identity
      xen/arm: remove outer_*_range call
      xen/arm: if(pfn_valid(pfn)) call native dma_ops
      arm64: introduce is_device_dma_coherent
      arm: introduce is_device_dma_coherent
      xen/arm: use is_device_dma_coherent
      xen: add a dma_addr_t dev_addr argument to xen_dma_map_page
      xen/arm: use hypercall to flush caches in map_page
      xen/arm/arm64: merge xen/mm32.c into xen/mm.c
      xen/arm/arm64: introduce xen_arch_need_swiotlb
      xen/arm: introduce GNTTABOP_cache_flush
      swiotlb-xen: pass dev_addr to xen_dma_unmap_page and xen_dma_sync_single_for_cpu
      swiotlb-xen: remove BUG_ON in xen_bus_to_phys

 arch/arm/include/asm/device.h              |    1 +
 arch/arm/include/asm/dma-mapping.h         |    6 +
 arch/arm/include/asm/xen/page-coherent.h   |   56 +++++++-
 arch/arm/include/asm/xen/page.h            |    4 +
 arch/arm/xen/Makefile                      |    2 +-
 arch/arm/xen/enlighten.c                   |    5 -
 arch/arm/xen/mm.c                          |  123 +++++++++++++++++
 arch/arm/xen/mm32.c                        |  202 ----------------------------
 arch/arm64/include/asm/device.h            |    1 +
 arch/arm64/include/asm/dma-mapping.h       |    6 +
 arch/arm64/include/asm/xen/page-coherent.h |   44 +-----
 arch/x86/include/asm/xen/page-coherent.h   |    4 +-
 arch/x86/include/asm/xen/page.h            |    7 +
 drivers/xen/swiotlb-xen.c                  |   19 +--
 include/xen/interface/features.h           |    3 -
 include/xen/interface/grant_table.h        |   19 +++
 16 files changed, 232 insertions(+), 270 deletions(-)
 delete mode 100644 arch/arm/xen/mm32.c

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

* [PATCH v8 01/13] xen/arm: remove handling of XENFEAT_grant_map_identity
  2014-11-10 16:12 [PATCH v8 0/13] introduce GNTTABOP_cache_flush Stefano Stabellini
@ 2014-11-10 16:13 ` Stefano Stabellini
  2014-11-10 16:13 ` [PATCH v8 02/13] xen/arm: remove outer_*_range call Stefano Stabellini
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 25+ messages in thread
From: Stefano Stabellini @ 2014-11-10 16:13 UTC (permalink / raw
  To: xen-devel
  Cc: konrad.wilk, Ian.Campbell, david.vrabel, linux-kernel,
	Stefano.Stabellini, linux-arm-kernel, catalin.marinas,
	Stefano Stabellini

The feature has been removed from Xen. Also Linux cannot use it on ARM32
without CONFIG_ARM_LPAE.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Reviewed-by: David Vrabel <david.vrabel@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>

---
Changes in v2:

- remove the definition of XENFEAT_grant_map_identity.
---
 arch/arm/xen/enlighten.c         |    5 ---
 arch/arm/xen/mm32.c              |   85 +-------------------------------------
 include/xen/interface/features.h |    3 --
 3 files changed, 1 insertion(+), 92 deletions(-)

diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
index 0e15f01..c7ca936 100644
--- a/arch/arm/xen/enlighten.c
+++ b/arch/arm/xen/enlighten.c
@@ -261,11 +261,6 @@ static int __init xen_guest_init(void)
 
 	xen_setup_features();
 
-	if (!xen_feature(XENFEAT_grant_map_identity)) {
-		pr_warn("Please upgrade your Xen.\n"
-				"If your platform has any non-coherent DMA devices, they won't work properly.\n");
-	}
-
 	if (xen_feature(XENFEAT_dom0))
 		xen_start_info->flags |= SIF_INITDOMAIN|SIF_PRIVILEGED;
 	else
diff --git a/arch/arm/xen/mm32.c b/arch/arm/xen/mm32.c
index 3b99860..a5a93fc 100644
--- a/arch/arm/xen/mm32.c
+++ b/arch/arm/xen/mm32.c
@@ -5,70 +5,6 @@
 
 #include <xen/features.h>
 
-static DEFINE_PER_CPU(unsigned long, xen_mm32_scratch_virt);
-static DEFINE_PER_CPU(pte_t *, xen_mm32_scratch_ptep);
-
-static int alloc_xen_mm32_scratch_page(int cpu)
-{
-	struct page *page;
-	unsigned long virt;
-	pmd_t *pmdp;
-	pte_t *ptep;
-
-	if (per_cpu(xen_mm32_scratch_ptep, cpu) != NULL)
-		return 0;
-
-	page = alloc_page(GFP_KERNEL);
-	if (page == NULL) {
-		pr_warn("Failed to allocate xen_mm32_scratch_page for cpu %d\n", cpu);
-		return -ENOMEM;
-	}
-
-	virt = (unsigned long)__va(page_to_phys(page));
-	pmdp = pmd_offset(pud_offset(pgd_offset_k(virt), virt), virt);
-	ptep = pte_offset_kernel(pmdp, virt);
-
-	per_cpu(xen_mm32_scratch_virt, cpu) = virt;
-	per_cpu(xen_mm32_scratch_ptep, cpu) = ptep;
-
-	return 0;
-}
-
-static int xen_mm32_cpu_notify(struct notifier_block *self,
-				    unsigned long action, void *hcpu)
-{
-	int cpu = (long)hcpu;
-	switch (action) {
-	case CPU_UP_PREPARE:
-		if (alloc_xen_mm32_scratch_page(cpu))
-			return NOTIFY_BAD;
-		break;
-	default:
-		break;
-	}
-	return NOTIFY_OK;
-}
-
-static struct notifier_block xen_mm32_cpu_notifier = {
-	.notifier_call	= xen_mm32_cpu_notify,
-};
-
-static void* xen_mm32_remap_page(dma_addr_t handle)
-{
-	unsigned long virt = get_cpu_var(xen_mm32_scratch_virt);
-	pte_t *ptep = __get_cpu_var(xen_mm32_scratch_ptep);
-
-	*ptep = pfn_pte(handle >> PAGE_SHIFT, PAGE_KERNEL);
-	local_flush_tlb_kernel_page(virt);
-
-	return (void*)virt;
-}
-
-static void xen_mm32_unmap(void *vaddr)
-{
-	put_cpu_var(xen_mm32_scratch_virt);
-}
-
 
 /* functions called by SWIOTLB */
 
@@ -88,13 +24,7 @@ static void dma_cache_maint(dma_addr_t handle, unsigned long offset,
 	
 		if (!pfn_valid(pfn))
 		{
-			/* Cannot map the page, we don't know its physical address.
-			 * Return and hope for the best */
-			if (!xen_feature(XENFEAT_grant_map_identity))
-				return;
-			vaddr = xen_mm32_remap_page(handle) + offset;
-			op(vaddr, len, dir);
-			xen_mm32_unmap(vaddr - offset);
+			/* TODO: cache flush */
 		} else {
 			struct page *page = pfn_to_page(pfn);
 
@@ -181,22 +111,9 @@ void xen_dma_sync_single_for_device(struct device *hwdev,
 
 int __init xen_mm32_init(void)
 {
-	int cpu;
-
 	if (!xen_initial_domain())
 		return 0;
 
-	register_cpu_notifier(&xen_mm32_cpu_notifier);
-	get_online_cpus();
-	for_each_online_cpu(cpu) {
-		if (alloc_xen_mm32_scratch_page(cpu)) {
-			put_online_cpus();
-			unregister_cpu_notifier(&xen_mm32_cpu_notifier);
-			return -ENOMEM;
-		}
-	}
-	put_online_cpus();
-
 	return 0;
 }
 arch_initcall(xen_mm32_init);
diff --git a/include/xen/interface/features.h b/include/xen/interface/features.h
index 14334d0..131a6cc 100644
--- a/include/xen/interface/features.h
+++ b/include/xen/interface/features.h
@@ -53,9 +53,6 @@
 /* operation as Dom0 is supported */
 #define XENFEAT_dom0                      11
 
-/* Xen also maps grant references at pfn = mfn */
-#define XENFEAT_grant_map_identity        12
-
 #define XENFEAT_NR_SUBMAPS 1
 
 #endif /* __XEN_PUBLIC_FEATURES_H__ */
-- 
1.7.10.4


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

* [PATCH v8 02/13] xen/arm: remove outer_*_range call
  2014-11-10 16:12 [PATCH v8 0/13] introduce GNTTABOP_cache_flush Stefano Stabellini
  2014-11-10 16:13 ` [PATCH v8 01/13] xen/arm: remove handling of XENFEAT_grant_map_identity Stefano Stabellini
@ 2014-11-10 16:13 ` Stefano Stabellini
  2014-11-10 16:13 ` [PATCH v8 03/13] xen/arm: if(pfn_valid(pfn)) call native dma_ops Stefano Stabellini
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 25+ messages in thread
From: Stefano Stabellini @ 2014-11-10 16:13 UTC (permalink / raw
  To: xen-devel
  Cc: konrad.wilk, Ian.Campbell, david.vrabel, linux-kernel,
	Stefano.Stabellini, linux-arm-kernel, catalin.marinas,
	Stefano Stabellini

Dom0 is not actually capable of issuing outer_inv_range or
outer_clean_range calls.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
 arch/arm/xen/mm32.c |    9 ---------
 1 file changed, 9 deletions(-)

diff --git a/arch/arm/xen/mm32.c b/arch/arm/xen/mm32.c
index a5a93fc..6153d61 100644
--- a/arch/arm/xen/mm32.c
+++ b/arch/arm/xen/mm32.c
@@ -61,9 +61,6 @@ static void __xen_dma_page_dev_to_cpu(struct device *hwdev, dma_addr_t handle,
 	/* Cannot use __dma_page_dev_to_cpu because we don't have a
 	 * struct page for handle */
 
-	if (dir != DMA_TO_DEVICE)
-		outer_inv_range(handle, handle + size);
-
 	dma_cache_maint(handle & PAGE_MASK, handle & ~PAGE_MASK, size, dir, dmac_unmap_area);
 }
 
@@ -72,12 +69,6 @@ static void __xen_dma_page_cpu_to_dev(struct device *hwdev, dma_addr_t handle,
 {
 
 	dma_cache_maint(handle & PAGE_MASK, handle & ~PAGE_MASK, size, dir, dmac_map_area);
-
-	if (dir == DMA_FROM_DEVICE) {
-		outer_inv_range(handle, handle + size);
-	} else {
-		outer_clean_range(handle, handle + size);
-	}
 }
 
 void xen_dma_unmap_page(struct device *hwdev, dma_addr_t handle,
-- 
1.7.10.4


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

* [PATCH v8 03/13] xen/arm: if(pfn_valid(pfn)) call native dma_ops
  2014-11-10 16:12 [PATCH v8 0/13] introduce GNTTABOP_cache_flush Stefano Stabellini
  2014-11-10 16:13 ` [PATCH v8 01/13] xen/arm: remove handling of XENFEAT_grant_map_identity Stefano Stabellini
  2014-11-10 16:13 ` [PATCH v8 02/13] xen/arm: remove outer_*_range call Stefano Stabellini
@ 2014-11-10 16:13 ` Stefano Stabellini
  2014-11-10 18:41   ` Catalin Marinas
  2014-11-10 16:13 ` [PATCH v8 04/13] arm64: introduce is_device_dma_coherent Stefano Stabellini
                   ` (10 subsequent siblings)
  13 siblings, 1 reply; 25+ messages in thread
From: Stefano Stabellini @ 2014-11-10 16:13 UTC (permalink / raw
  To: xen-devel
  Cc: konrad.wilk, Ian.Campbell, david.vrabel, linux-kernel,
	Stefano.Stabellini, linux-arm-kernel, catalin.marinas,
	Stefano Stabellini

Remove code duplication in mm32.c by calling the native dma_ops if the
page is a local page (not a foreign page). Use a simple pfn_valid(pfn)
check to figure out if the page is local, exploiting the fact that dom0
is mapped 1:1, therefore pfn_valid always returns false when called on a
foreign mfn.

Suggested-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
 arch/arm/include/asm/xen/page-coherent.h |   43 ++++++++++++++++++++++--
 arch/arm/xen/mm32.c                      |   52 ++++++++----------------------
 2 files changed, 53 insertions(+), 42 deletions(-)

diff --git a/arch/arm/include/asm/xen/page-coherent.h b/arch/arm/include/asm/xen/page-coherent.h
index e8275ea..d97b0b4 100644
--- a/arch/arm/include/asm/xen/page-coherent.h
+++ b/arch/arm/include/asm/xen/page-coherent.h
@@ -5,6 +5,15 @@
 #include <linux/dma-attrs.h>
 #include <linux/dma-mapping.h>
 
+void __xen_dma_unmap_page(struct device *hwdev, dma_addr_t handle,
+		size_t size, enum dma_data_direction dir,
+		struct dma_attrs *attrs);
+void __xen_dma_sync_single_for_cpu(struct device *hwdev,
+		dma_addr_t handle, size_t size, enum dma_data_direction dir);
+
+void __xen_dma_sync_single_for_device(struct device *hwdev,
+		dma_addr_t handle, size_t size, enum dma_data_direction dir);
+
 static inline void *xen_alloc_coherent_pages(struct device *hwdev, size_t size,
 		dma_addr_t *dma_handle, gfp_t flags,
 		struct dma_attrs *attrs)
@@ -28,12 +37,40 @@ static inline void xen_dma_map_page(struct device *hwdev, struct page *page,
 
 void xen_dma_unmap_page(struct device *hwdev, dma_addr_t handle,
 		size_t size, enum dma_data_direction dir,
-		struct dma_attrs *attrs);
+		struct dma_attrs *attrs)
+{
+	unsigned long pfn = PFN_DOWN(handle);
+	/* Dom0 is mapped 1:1, so calling pfn_valid on a foreign mfn will
+	 * always return false. If the page is local we can safely call the
+	 * native dma_ops function, otherwise we call the xen specific
+	 * function. */
+	if (pfn_valid(pfn)) {
+		if (__generic_dma_ops(hwdev)->unmap_page)
+			__generic_dma_ops(hwdev)->unmap_page(hwdev, handle, size, dir, attrs);
+	} else
+		__xen_dma_unmap_page(hwdev, handle, size, dir, attrs);
+}
 
 void xen_dma_sync_single_for_cpu(struct device *hwdev,
-		dma_addr_t handle, size_t size, enum dma_data_direction dir);
+		dma_addr_t handle, size_t size, enum dma_data_direction dir)
+{
+	unsigned long pfn = PFN_DOWN(handle);
+	if (pfn_valid(pfn)) {
+		if (__generic_dma_ops(hwdev)->sync_single_for_cpu)
+			__generic_dma_ops(hwdev)->sync_single_for_cpu(hwdev, handle, size, dir);
+	} else
+		__xen_dma_sync_single_for_cpu(hwdev, handle, size, dir);
+}
 
 void xen_dma_sync_single_for_device(struct device *hwdev,
-		dma_addr_t handle, size_t size, enum dma_data_direction dir);
+		dma_addr_t handle, size_t size, enum dma_data_direction dir)
+{
+	unsigned long pfn = PFN_DOWN(handle);
+	if (pfn_valid(pfn)) {
+		if (__generic_dma_ops(hwdev)->sync_single_for_device)
+			__generic_dma_ops(hwdev)->sync_single_for_device(hwdev, handle, size, dir);
+	} else
+		__xen_dma_sync_single_for_device(hwdev, handle, size, dir);
+}
 
 #endif /* _ASM_ARM_XEN_PAGE_COHERENT_H */
diff --git a/arch/arm/xen/mm32.c b/arch/arm/xen/mm32.c
index 6153d61..b26bf84 100644
--- a/arch/arm/xen/mm32.c
+++ b/arch/arm/xen/mm32.c
@@ -4,13 +4,15 @@
 #include <linux/highmem.h>
 
 #include <xen/features.h>
-
+enum dma_cache_op {
+       DMA_UNMAP,
+       DMA_MAP,
+};
 
 /* functions called by SWIOTLB */
 
 static void dma_cache_maint(dma_addr_t handle, unsigned long offset,
-	size_t size, enum dma_data_direction dir,
-	void (*op)(const void *, size_t, int))
+	size_t size, enum dma_data_direction dir, enum dma_cache_op op)
 {
 	unsigned long pfn;
 	size_t left = size;
@@ -20,34 +22,10 @@ static void dma_cache_maint(dma_addr_t handle, unsigned long offset,
 
 	do {
 		size_t len = left;
-		void *vaddr;
 	
-		if (!pfn_valid(pfn))
-		{
-			/* TODO: cache flush */
-		} else {
-			struct page *page = pfn_to_page(pfn);
-
-			if (PageHighMem(page)) {
-				if (len + offset > PAGE_SIZE)
-					len = PAGE_SIZE - offset;
-
-				if (cache_is_vipt_nonaliasing()) {
-					vaddr = kmap_atomic(page);
-					op(vaddr + offset, len, dir);
-					kunmap_atomic(vaddr);
-				} else {
-					vaddr = kmap_high_get(page);
-					if (vaddr) {
-						op(vaddr + offset, len, dir);
-						kunmap_high(page);
-					}
-				}
-			} else {
-				vaddr = page_address(page) + offset;
-				op(vaddr, len, dir);
-			}
-		}
+		BUG_ON(pfn_valid(pfn));
+
+		/* TODO: cache flush */
 
 		offset = 0;
 		pfn++;
@@ -58,20 +36,16 @@ static void dma_cache_maint(dma_addr_t handle, unsigned long offset,
 static void __xen_dma_page_dev_to_cpu(struct device *hwdev, dma_addr_t handle,
 		size_t size, enum dma_data_direction dir)
 {
-	/* Cannot use __dma_page_dev_to_cpu because we don't have a
-	 * struct page for handle */
-
-	dma_cache_maint(handle & PAGE_MASK, handle & ~PAGE_MASK, size, dir, dmac_unmap_area);
+	dma_cache_maint(handle & PAGE_MASK, handle & ~PAGE_MASK, size, dir, DMA_UNMAP);
 }
 
 static void __xen_dma_page_cpu_to_dev(struct device *hwdev, dma_addr_t handle,
 		size_t size, enum dma_data_direction dir)
 {
-
-	dma_cache_maint(handle & PAGE_MASK, handle & ~PAGE_MASK, size, dir, dmac_map_area);
+	dma_cache_maint(handle & PAGE_MASK, handle & ~PAGE_MASK, size, dir, DMA_MAP);
 }
 
-void xen_dma_unmap_page(struct device *hwdev, dma_addr_t handle,
+void __xen_dma_unmap_page(struct device *hwdev, dma_addr_t handle,
 		size_t size, enum dma_data_direction dir,
 		struct dma_attrs *attrs)
 
@@ -84,7 +58,7 @@ void xen_dma_unmap_page(struct device *hwdev, dma_addr_t handle,
 	__xen_dma_page_dev_to_cpu(hwdev, handle, size, dir);
 }
 
-void xen_dma_sync_single_for_cpu(struct device *hwdev,
+void __xen_dma_sync_single_for_cpu(struct device *hwdev,
 		dma_addr_t handle, size_t size, enum dma_data_direction dir)
 {
 	if (!__generic_dma_ops(hwdev)->sync_single_for_cpu)
@@ -92,7 +66,7 @@ void xen_dma_sync_single_for_cpu(struct device *hwdev,
 	__xen_dma_page_dev_to_cpu(hwdev, handle, size, dir);
 }
 
-void xen_dma_sync_single_for_device(struct device *hwdev,
+void __xen_dma_sync_single_for_device(struct device *hwdev,
 		dma_addr_t handle, size_t size, enum dma_data_direction dir)
 {
 	if (!__generic_dma_ops(hwdev)->sync_single_for_device)
-- 
1.7.10.4


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

* [PATCH v8 04/13] arm64: introduce is_device_dma_coherent
  2014-11-10 16:12 [PATCH v8 0/13] introduce GNTTABOP_cache_flush Stefano Stabellini
                   ` (2 preceding siblings ...)
  2014-11-10 16:13 ` [PATCH v8 03/13] xen/arm: if(pfn_valid(pfn)) call native dma_ops Stefano Stabellini
@ 2014-11-10 16:13 ` Stefano Stabellini
  2014-11-10 18:42   ` Catalin Marinas
  2014-11-10 16:13 ` [PATCH v8 05/13] arm: " Stefano Stabellini
                   ` (9 subsequent siblings)
  13 siblings, 1 reply; 25+ messages in thread
From: Stefano Stabellini @ 2014-11-10 16:13 UTC (permalink / raw
  To: xen-devel
  Cc: konrad.wilk, Ian.Campbell, david.vrabel, linux-kernel,
	Stefano.Stabellini, linux-arm-kernel, catalin.marinas,
	Stefano Stabellini, will.deacon

Introduce a boolean flag and an accessor function to check whether a
device is dma_coherent. Set the flag from set_arch_dma_coherent_ops.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
CC: will.deacon@arm.com
---
 arch/arm64/include/asm/device.h      |    1 +
 arch/arm64/include/asm/dma-mapping.h |    6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/arch/arm64/include/asm/device.h b/arch/arm64/include/asm/device.h
index cf98b36..243ef25 100644
--- a/arch/arm64/include/asm/device.h
+++ b/arch/arm64/include/asm/device.h
@@ -21,6 +21,7 @@ struct dev_archdata {
 #ifdef CONFIG_IOMMU_API
 	void *iommu;			/* private IOMMU data */
 #endif
+	bool dma_coherent;
 };
 
 struct pdev_archdata {
diff --git a/arch/arm64/include/asm/dma-mapping.h b/arch/arm64/include/asm/dma-mapping.h
index adeae3f..e213dc4 100644
--- a/arch/arm64/include/asm/dma-mapping.h
+++ b/arch/arm64/include/asm/dma-mapping.h
@@ -54,11 +54,17 @@ static inline void set_dma_ops(struct device *dev, struct dma_map_ops *ops)
 
 static inline int set_arch_dma_coherent_ops(struct device *dev)
 {
+	dev->archdata.dma_coherent = true;
 	set_dma_ops(dev, &coherent_swiotlb_dma_ops);
 	return 0;
 }
 #define set_arch_dma_coherent_ops	set_arch_dma_coherent_ops
 
+static inline bool is_device_dma_coherent(struct device *dev)
+{
+	return dev->archdata.dma_coherent;
+}
+
 #include <asm-generic/dma-mapping-common.h>
 
 static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
-- 
1.7.10.4


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

* [PATCH v8 05/13] arm: introduce is_device_dma_coherent
  2014-11-10 16:12 [PATCH v8 0/13] introduce GNTTABOP_cache_flush Stefano Stabellini
                   ` (3 preceding siblings ...)
  2014-11-10 16:13 ` [PATCH v8 04/13] arm64: introduce is_device_dma_coherent Stefano Stabellini
@ 2014-11-10 16:13 ` Stefano Stabellini
  2014-11-10 16:13 ` [PATCH v8 06/13] xen/arm: use is_device_dma_coherent Stefano Stabellini
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 25+ messages in thread
From: Stefano Stabellini @ 2014-11-10 16:13 UTC (permalink / raw
  To: xen-devel
  Cc: konrad.wilk, Ian.Campbell, david.vrabel, linux-kernel,
	Stefano.Stabellini, linux-arm-kernel, catalin.marinas,
	Stefano Stabellini, linux, will.deacon

Introduce a boolean flag and an accessor function to check whether a
device is dma_coherent. Set the flag from set_arch_dma_coherent_ops.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
CC: linux@arm.linux.org.uk
CC: will.deacon@arm.com
---
 arch/arm/include/asm/device.h      |    1 +
 arch/arm/include/asm/dma-mapping.h |    6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/arch/arm/include/asm/device.h b/arch/arm/include/asm/device.h
index dc662fc..4111592 100644
--- a/arch/arm/include/asm/device.h
+++ b/arch/arm/include/asm/device.h
@@ -17,6 +17,7 @@ struct dev_archdata {
 #ifdef CONFIG_ARM_DMA_USE_IOMMU
 	struct dma_iommu_mapping	*mapping;
 #endif
+	bool dma_coherent;
 };
 
 struct omap_device;
diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h
index 85738b2..8c3b616 100644
--- a/arch/arm/include/asm/dma-mapping.h
+++ b/arch/arm/include/asm/dma-mapping.h
@@ -123,11 +123,17 @@ static inline unsigned long dma_max_pfn(struct device *dev)
 
 static inline int set_arch_dma_coherent_ops(struct device *dev)
 {
+	dev->archdata.dma_coherent = true;
 	set_dma_ops(dev, &arm_coherent_dma_ops);
 	return 0;
 }
 #define set_arch_dma_coherent_ops(dev)	set_arch_dma_coherent_ops(dev)
 
+static inline bool is_device_dma_coherent(struct device *dev)
+{
+	return dev->archdata.dma_coherent;
+}
+
 static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
 {
 	unsigned int offset = paddr & ~PAGE_MASK;
-- 
1.7.10.4


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

* [PATCH v8 06/13] xen/arm: use is_device_dma_coherent
  2014-11-10 16:12 [PATCH v8 0/13] introduce GNTTABOP_cache_flush Stefano Stabellini
                   ` (4 preceding siblings ...)
  2014-11-10 16:13 ` [PATCH v8 05/13] arm: " Stefano Stabellini
@ 2014-11-10 16:13 ` Stefano Stabellini
  2014-11-10 16:13 ` [PATCH v8 07/13] xen: add a dma_addr_t dev_addr argument to xen_dma_map_page Stefano Stabellini
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 25+ messages in thread
From: Stefano Stabellini @ 2014-11-10 16:13 UTC (permalink / raw
  To: xen-devel
  Cc: konrad.wilk, Ian.Campbell, david.vrabel, linux-kernel,
	Stefano.Stabellini, linux-arm-kernel, catalin.marinas,
	Stefano Stabellini

Use is_device_dma_coherent to check whether we need to issue cache
maintenance operations rather than checking on the existence of a
particular dma_ops function for the device.

This is correct because coherent devices don't need cache maintenance
operations - arm_coherent_dma_ops does not set the hooks that we
were previously checking for existance.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
 arch/arm/xen/mm32.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/xen/mm32.c b/arch/arm/xen/mm32.c
index b26bf84..7824498 100644
--- a/arch/arm/xen/mm32.c
+++ b/arch/arm/xen/mm32.c
@@ -50,7 +50,7 @@ void __xen_dma_unmap_page(struct device *hwdev, dma_addr_t handle,
 		struct dma_attrs *attrs)
 
 {
-	if (!__generic_dma_ops(hwdev)->unmap_page)
+	if (is_device_dma_coherent(hwdev))
 		return;
 	if (dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs))
 		return;
@@ -61,7 +61,7 @@ void __xen_dma_unmap_page(struct device *hwdev, dma_addr_t handle,
 void __xen_dma_sync_single_for_cpu(struct device *hwdev,
 		dma_addr_t handle, size_t size, enum dma_data_direction dir)
 {
-	if (!__generic_dma_ops(hwdev)->sync_single_for_cpu)
+	if (is_device_dma_coherent(hwdev))
 		return;
 	__xen_dma_page_dev_to_cpu(hwdev, handle, size, dir);
 }
@@ -69,7 +69,7 @@ void __xen_dma_sync_single_for_cpu(struct device *hwdev,
 void __xen_dma_sync_single_for_device(struct device *hwdev,
 		dma_addr_t handle, size_t size, enum dma_data_direction dir)
 {
-	if (!__generic_dma_ops(hwdev)->sync_single_for_device)
+	if (is_device_dma_coherent(hwdev))
 		return;
 	__xen_dma_page_cpu_to_dev(hwdev, handle, size, dir);
 }
-- 
1.7.10.4


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

* [PATCH v8 07/13] xen: add a dma_addr_t dev_addr argument to xen_dma_map_page
  2014-11-10 16:12 [PATCH v8 0/13] introduce GNTTABOP_cache_flush Stefano Stabellini
                   ` (5 preceding siblings ...)
  2014-11-10 16:13 ` [PATCH v8 06/13] xen/arm: use is_device_dma_coherent Stefano Stabellini
@ 2014-11-10 16:13 ` Stefano Stabellini
  2014-11-10 18:24   ` Catalin Marinas
  2014-11-10 16:14 ` [PATCH v8 08/13] xen/arm: use hypercall to flush caches in map_page Stefano Stabellini
                   ` (6 subsequent siblings)
  13 siblings, 1 reply; 25+ messages in thread
From: Stefano Stabellini @ 2014-11-10 16:13 UTC (permalink / raw
  To: xen-devel
  Cc: konrad.wilk, Ian.Campbell, david.vrabel, linux-kernel,
	Stefano.Stabellini, linux-arm-kernel, catalin.marinas,
	Stefano Stabellini

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
CC: david.vrabel@citrix.com
CC: konrad.wilk@oracle.com
---
 arch/arm/include/asm/xen/page-coherent.h   |    4 ++--
 arch/arm64/include/asm/xen/page-coherent.h |    4 ++--
 arch/x86/include/asm/xen/page-coherent.h   |    4 ++--
 drivers/xen/swiotlb-xen.c                  |    6 ++++--
 4 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/arch/arm/include/asm/xen/page-coherent.h b/arch/arm/include/asm/xen/page-coherent.h
index d97b0b4..25d450c 100644
--- a/arch/arm/include/asm/xen/page-coherent.h
+++ b/arch/arm/include/asm/xen/page-coherent.h
@@ -29,8 +29,8 @@ static inline void xen_free_coherent_pages(struct device *hwdev, size_t size,
 }
 
 static inline void xen_dma_map_page(struct device *hwdev, struct page *page,
-	     unsigned long offset, size_t size, enum dma_data_direction dir,
-	     struct dma_attrs *attrs)
+	     dma_addr_t dev_addr, unsigned long offset, size_t size,
+	     enum dma_data_direction dir, struct dma_attrs *attrs)
 {
 	__generic_dma_ops(hwdev)->map_page(hwdev, page, offset, size, dir, attrs);
 }
diff --git a/arch/arm64/include/asm/xen/page-coherent.h b/arch/arm64/include/asm/xen/page-coherent.h
index dde3fc9..d7cd4c2 100644
--- a/arch/arm64/include/asm/xen/page-coherent.h
+++ b/arch/arm64/include/asm/xen/page-coherent.h
@@ -20,8 +20,8 @@ static inline void xen_free_coherent_pages(struct device *hwdev, size_t size,
 }
 
 static inline void xen_dma_map_page(struct device *hwdev, struct page *page,
-	     unsigned long offset, size_t size, enum dma_data_direction dir,
-	     struct dma_attrs *attrs)
+	     dma_addr_t dev_addr, unsigned long offset, size_t size,
+	     enum dma_data_direction dir, struct dma_attrs *attrs)
 {
 }
 
diff --git a/arch/x86/include/asm/xen/page-coherent.h b/arch/x86/include/asm/xen/page-coherent.h
index 7f02fe4..acd844c 100644
--- a/arch/x86/include/asm/xen/page-coherent.h
+++ b/arch/x86/include/asm/xen/page-coherent.h
@@ -22,8 +22,8 @@ static inline void xen_free_coherent_pages(struct device *hwdev, size_t size,
 }
 
 static inline void xen_dma_map_page(struct device *hwdev, struct page *page,
-	     unsigned long offset, size_t size, enum dma_data_direction dir,
-	     struct dma_attrs *attrs) { }
+	     dma_addr_t dev_addr, unsigned long offset, size_t size,
+	     enum dma_data_direction dir, struct dma_attrs *attrs) { }
 
 static inline void xen_dma_unmap_page(struct device *hwdev, dma_addr_t handle,
 		size_t size, enum dma_data_direction dir,
diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c
index ebd8f21..ad2c5eb 100644
--- a/drivers/xen/swiotlb-xen.c
+++ b/drivers/xen/swiotlb-xen.c
@@ -403,7 +403,7 @@ dma_addr_t xen_swiotlb_map_page(struct device *dev, struct page *page,
 		/* we are not interested in the dma_addr returned by
 		 * xen_dma_map_page, only in the potential cache flushes executed
 		 * by the function. */
-		xen_dma_map_page(dev, page, offset, size, dir, attrs);
+		xen_dma_map_page(dev, page, dev_addr, offset, size, dir, attrs);
 		return dev_addr;
 	}
 
@@ -417,7 +417,7 @@ dma_addr_t xen_swiotlb_map_page(struct device *dev, struct page *page,
 		return DMA_ERROR_CODE;
 
 	xen_dma_map_page(dev, pfn_to_page(map >> PAGE_SHIFT),
-					map & ~PAGE_MASK, size, dir, attrs);
+					dev_addr, map & ~PAGE_MASK, size, dir, attrs);
 	dev_addr = xen_phys_to_bus(map);
 
 	/*
@@ -574,6 +574,7 @@ xen_swiotlb_map_sg_attrs(struct device *hwdev, struct scatterlist *sgl,
 				return 0;
 			}
 			xen_dma_map_page(hwdev, pfn_to_page(map >> PAGE_SHIFT),
+						dev_addr,
 						map & ~PAGE_MASK,
 						sg->length,
 						dir,
@@ -584,6 +585,7 @@ xen_swiotlb_map_sg_attrs(struct device *hwdev, struct scatterlist *sgl,
 			 * xen_dma_map_page, only in the potential cache flushes executed
 			 * by the function. */
 			xen_dma_map_page(hwdev, pfn_to_page(paddr >> PAGE_SHIFT),
+						dev_addr,
 						paddr & ~PAGE_MASK,
 						sg->length,
 						dir,
-- 
1.7.10.4


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

* [PATCH v8 08/13] xen/arm: use hypercall to flush caches in map_page
  2014-11-10 16:12 [PATCH v8 0/13] introduce GNTTABOP_cache_flush Stefano Stabellini
                   ` (6 preceding siblings ...)
  2014-11-10 16:13 ` [PATCH v8 07/13] xen: add a dma_addr_t dev_addr argument to xen_dma_map_page Stefano Stabellini
@ 2014-11-10 16:14 ` Stefano Stabellini
  2014-11-10 18:27   ` Catalin Marinas
  2014-11-10 16:14 ` [PATCH v8 09/13] xen/arm/arm64: merge xen/mm32.c into xen/mm.c Stefano Stabellini
                   ` (5 subsequent siblings)
  13 siblings, 1 reply; 25+ messages in thread
From: Stefano Stabellini @ 2014-11-10 16:14 UTC (permalink / raw
  To: xen-devel
  Cc: konrad.wilk, Ian.Campbell, david.vrabel, linux-kernel,
	Stefano.Stabellini, linux-arm-kernel, catalin.marinas,
	Stefano Stabellini

In xen_dma_map_page, if the page is a local page, call the native
map_page dma_ops. If the page is foreign, call __xen_dma_map_page that
issues any required cache maintenane operations via hypercall.

The reason for doing this is that the native dma_ops map_page could
allocate buffers than need to be freed. If the page is foreign we don't
call the native unmap_page dma_ops function, resulting in a memory leak.

Suggested-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
 arch/arm/include/asm/xen/page-coherent.h |    9 ++++++++-
 arch/arm/xen/mm32.c                      |   12 ++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/xen/page-coherent.h b/arch/arm/include/asm/xen/page-coherent.h
index 25d450c..36b79a8 100644
--- a/arch/arm/include/asm/xen/page-coherent.h
+++ b/arch/arm/include/asm/xen/page-coherent.h
@@ -5,6 +5,9 @@
 #include <linux/dma-attrs.h>
 #include <linux/dma-mapping.h>
 
+void __xen_dma_map_page(struct device *hwdev, struct page *page,
+	     dma_addr_t dev_addr, unsigned long offset, size_t size,
+	     enum dma_data_direction dir, struct dma_attrs *attrs);
 void __xen_dma_unmap_page(struct device *hwdev, dma_addr_t handle,
 		size_t size, enum dma_data_direction dir,
 		struct dma_attrs *attrs);
@@ -32,7 +35,11 @@ static inline void xen_dma_map_page(struct device *hwdev, struct page *page,
 	     dma_addr_t dev_addr, unsigned long offset, size_t size,
 	     enum dma_data_direction dir, struct dma_attrs *attrs)
 {
-	__generic_dma_ops(hwdev)->map_page(hwdev, page, offset, size, dir, attrs);
+	if (PFN_DOWN(dev_addr) == page_to_pfn(page)) {
+		if (__generic_dma_ops(hwdev)->map_page)
+			__generic_dma_ops(hwdev)->map_page(hwdev, page, offset, size, dir, attrs);
+	} else
+		__xen_dma_map_page(hwdev, page, dev_addr, offset, size, dir, attrs);
 }
 
 void xen_dma_unmap_page(struct device *hwdev, dma_addr_t handle,
diff --git a/arch/arm/xen/mm32.c b/arch/arm/xen/mm32.c
index 7824498..d611c4b 100644
--- a/arch/arm/xen/mm32.c
+++ b/arch/arm/xen/mm32.c
@@ -45,6 +45,18 @@ static void __xen_dma_page_cpu_to_dev(struct device *hwdev, dma_addr_t handle,
 	dma_cache_maint(handle & PAGE_MASK, handle & ~PAGE_MASK, size, dir, DMA_MAP);
 }
 
+void __xen_dma_map_page(struct device *hwdev, struct page *page,
+	     dma_addr_t dev_addr, unsigned long offset, size_t size,
+	     enum dma_data_direction dir, struct dma_attrs *attrs)
+{
+	if (is_device_dma_coherent(hwdev))
+		return;
+	if (dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs))
+		return;
+
+	__xen_dma_page_cpu_to_dev(hwdev, dev_addr, size, dir);
+}
+
 void __xen_dma_unmap_page(struct device *hwdev, dma_addr_t handle,
 		size_t size, enum dma_data_direction dir,
 		struct dma_attrs *attrs)
-- 
1.7.10.4


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

* [PATCH v8 09/13] xen/arm/arm64: merge xen/mm32.c into xen/mm.c
  2014-11-10 16:12 [PATCH v8 0/13] introduce GNTTABOP_cache_flush Stefano Stabellini
                   ` (7 preceding siblings ...)
  2014-11-10 16:14 ` [PATCH v8 08/13] xen/arm: use hypercall to flush caches in map_page Stefano Stabellini
@ 2014-11-10 16:14 ` Stefano Stabellini
  2014-11-10 18:32   ` Catalin Marinas
  2014-11-10 16:14 ` [PATCH v8 10/13] xen/arm/arm64: introduce xen_arch_need_swiotlb Stefano Stabellini
                   ` (4 subsequent siblings)
  13 siblings, 1 reply; 25+ messages in thread
From: Stefano Stabellini @ 2014-11-10 16:14 UTC (permalink / raw
  To: xen-devel
  Cc: konrad.wilk, Ian.Campbell, david.vrabel, linux-kernel,
	Stefano.Stabellini, linux-arm-kernel, catalin.marinas,
	Stefano Stabellini

Merge xen/mm32.c into xen/mm.c.
As a consequence the code gets compiled on arm64 too.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
 arch/arm/xen/Makefile                      |    2 +-
 arch/arm/xen/mm.c                          |   86 +++++++++++++++++++++++++
 arch/arm/xen/mm32.c                        |   96 ----------------------------
 arch/arm64/include/asm/xen/page-coherent.h |   44 +------------
 4 files changed, 88 insertions(+), 140 deletions(-)
 delete mode 100644 arch/arm/xen/mm32.c

diff --git a/arch/arm/xen/Makefile b/arch/arm/xen/Makefile
index 1f85bfe..1296952 100644
--- a/arch/arm/xen/Makefile
+++ b/arch/arm/xen/Makefile
@@ -1 +1 @@
-obj-y		:= enlighten.o hypercall.o grant-table.o p2m.o mm.o mm32.o
+obj-y		:= enlighten.o hypercall.o grant-table.o p2m.o mm.o
diff --git a/arch/arm/xen/mm.c b/arch/arm/xen/mm.c
index b0e77de..0e96023 100644
--- a/arch/arm/xen/mm.c
+++ b/arch/arm/xen/mm.c
@@ -1,6 +1,10 @@
+#include <linux/cpu.h>
+#include <linux/dma-mapping.h>
 #include <linux/bootmem.h>
 #include <linux/gfp.h>
+#include <linux/highmem.h>
 #include <linux/export.h>
+#include <linux/of_address.h>
 #include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/dma-mapping.h>
@@ -16,6 +20,88 @@
 #include <asm/xen/hypercall.h>
 #include <asm/xen/interface.h>
 
+enum dma_cache_op {
+       DMA_UNMAP,
+       DMA_MAP,
+};
+
+/* functions called by SWIOTLB */
+
+static void dma_cache_maint(dma_addr_t handle, unsigned long offset,
+	size_t size, enum dma_data_direction dir, enum dma_cache_op op)
+{
+	unsigned long pfn;
+	size_t left = size;
+
+	pfn = (handle >> PAGE_SHIFT) + offset / PAGE_SIZE;
+	offset %= PAGE_SIZE;
+
+	do {
+		size_t len = left;
+	
+		BUG_ON(pfn_valid(pfn));
+
+		/* TODO: cache flush */
+
+		offset = 0;
+		pfn++;
+		left -= len;
+	} while (left);
+}
+
+static void __xen_dma_page_dev_to_cpu(struct device *hwdev, dma_addr_t handle,
+		size_t size, enum dma_data_direction dir)
+{
+	dma_cache_maint(handle & PAGE_MASK, handle & ~PAGE_MASK, size, dir, DMA_UNMAP);
+}
+
+static void __xen_dma_page_cpu_to_dev(struct device *hwdev, dma_addr_t handle,
+		size_t size, enum dma_data_direction dir)
+{
+	dma_cache_maint(handle & PAGE_MASK, handle & ~PAGE_MASK, size, dir, DMA_MAP);
+}
+
+void __xen_dma_map_page(struct device *hwdev, struct page *page,
+	     dma_addr_t dev_addr, unsigned long offset, size_t size,
+	     enum dma_data_direction dir, struct dma_attrs *attrs)
+{
+	if (is_device_dma_coherent(hwdev))
+		return;
+	if (dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs))
+		return;
+
+	__xen_dma_page_cpu_to_dev(hwdev, dev_addr, size, dir);
+}
+
+void __xen_dma_unmap_page(struct device *hwdev, dma_addr_t handle,
+		size_t size, enum dma_data_direction dir,
+		struct dma_attrs *attrs)
+
+{
+	if (is_device_dma_coherent(hwdev))
+		return;
+	if (dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs))
+		return;
+
+	__xen_dma_page_dev_to_cpu(hwdev, handle, size, dir);
+}
+
+void __xen_dma_sync_single_for_cpu(struct device *hwdev,
+		dma_addr_t handle, size_t size, enum dma_data_direction dir)
+{
+	if (is_device_dma_coherent(hwdev))
+		return;
+	__xen_dma_page_dev_to_cpu(hwdev, handle, size, dir);
+}
+
+void __xen_dma_sync_single_for_device(struct device *hwdev,
+		dma_addr_t handle, size_t size, enum dma_data_direction dir)
+{
+	if (is_device_dma_coherent(hwdev))
+		return;
+	__xen_dma_page_cpu_to_dev(hwdev, handle, size, dir);
+}
+
 int xen_create_contiguous_region(phys_addr_t pstart, unsigned int order,
 				 unsigned int address_bits,
 				 dma_addr_t *dma_handle)
diff --git a/arch/arm/xen/mm32.c b/arch/arm/xen/mm32.c
deleted file mode 100644
index d611c4b..0000000
--- a/arch/arm/xen/mm32.c
+++ /dev/null
@@ -1,96 +0,0 @@
-#include <linux/cpu.h>
-#include <linux/dma-mapping.h>
-#include <linux/gfp.h>
-#include <linux/highmem.h>
-
-#include <xen/features.h>
-enum dma_cache_op {
-       DMA_UNMAP,
-       DMA_MAP,
-};
-
-/* functions called by SWIOTLB */
-
-static void dma_cache_maint(dma_addr_t handle, unsigned long offset,
-	size_t size, enum dma_data_direction dir, enum dma_cache_op op)
-{
-	unsigned long pfn;
-	size_t left = size;
-
-	pfn = (handle >> PAGE_SHIFT) + offset / PAGE_SIZE;
-	offset %= PAGE_SIZE;
-
-	do {
-		size_t len = left;
-	
-		BUG_ON(pfn_valid(pfn));
-
-		/* TODO: cache flush */
-
-		offset = 0;
-		pfn++;
-		left -= len;
-	} while (left);
-}
-
-static void __xen_dma_page_dev_to_cpu(struct device *hwdev, dma_addr_t handle,
-		size_t size, enum dma_data_direction dir)
-{
-	dma_cache_maint(handle & PAGE_MASK, handle & ~PAGE_MASK, size, dir, DMA_UNMAP);
-}
-
-static void __xen_dma_page_cpu_to_dev(struct device *hwdev, dma_addr_t handle,
-		size_t size, enum dma_data_direction dir)
-{
-	dma_cache_maint(handle & PAGE_MASK, handle & ~PAGE_MASK, size, dir, DMA_MAP);
-}
-
-void __xen_dma_map_page(struct device *hwdev, struct page *page,
-	     dma_addr_t dev_addr, unsigned long offset, size_t size,
-	     enum dma_data_direction dir, struct dma_attrs *attrs)
-{
-	if (is_device_dma_coherent(hwdev))
-		return;
-	if (dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs))
-		return;
-
-	__xen_dma_page_cpu_to_dev(hwdev, dev_addr, size, dir);
-}
-
-void __xen_dma_unmap_page(struct device *hwdev, dma_addr_t handle,
-		size_t size, enum dma_data_direction dir,
-		struct dma_attrs *attrs)
-
-{
-	if (is_device_dma_coherent(hwdev))
-		return;
-	if (dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs))
-		return;
-
-	__xen_dma_page_dev_to_cpu(hwdev, handle, size, dir);
-}
-
-void __xen_dma_sync_single_for_cpu(struct device *hwdev,
-		dma_addr_t handle, size_t size, enum dma_data_direction dir)
-{
-	if (is_device_dma_coherent(hwdev))
-		return;
-	__xen_dma_page_dev_to_cpu(hwdev, handle, size, dir);
-}
-
-void __xen_dma_sync_single_for_device(struct device *hwdev,
-		dma_addr_t handle, size_t size, enum dma_data_direction dir)
-{
-	if (is_device_dma_coherent(hwdev))
-		return;
-	__xen_dma_page_cpu_to_dev(hwdev, handle, size, dir);
-}
-
-int __init xen_mm32_init(void)
-{
-	if (!xen_initial_domain())
-		return 0;
-
-	return 0;
-}
-arch_initcall(xen_mm32_init);
diff --git a/arch/arm64/include/asm/xen/page-coherent.h b/arch/arm64/include/asm/xen/page-coherent.h
index d7cd4c2..2052102 100644
--- a/arch/arm64/include/asm/xen/page-coherent.h
+++ b/arch/arm64/include/asm/xen/page-coherent.h
@@ -1,43 +1 @@
-#ifndef _ASM_ARM64_XEN_PAGE_COHERENT_H
-#define _ASM_ARM64_XEN_PAGE_COHERENT_H
-
-#include <asm/page.h>
-#include <linux/dma-attrs.h>
-#include <linux/dma-mapping.h>
-
-static inline void *xen_alloc_coherent_pages(struct device *hwdev, size_t size,
-		dma_addr_t *dma_handle, gfp_t flags,
-		struct dma_attrs *attrs)
-{
-	return __generic_dma_ops(hwdev)->alloc(hwdev, size, dma_handle, flags, attrs);
-}
-
-static inline void xen_free_coherent_pages(struct device *hwdev, size_t size,
-		void *cpu_addr, dma_addr_t dma_handle,
-		struct dma_attrs *attrs)
-{
-	__generic_dma_ops(hwdev)->free(hwdev, size, cpu_addr, dma_handle, attrs);
-}
-
-static inline void xen_dma_map_page(struct device *hwdev, struct page *page,
-	     dma_addr_t dev_addr, unsigned long offset, size_t size,
-	     enum dma_data_direction dir, struct dma_attrs *attrs)
-{
-}
-
-static inline void xen_dma_unmap_page(struct device *hwdev, dma_addr_t handle,
-		size_t size, enum dma_data_direction dir,
-		struct dma_attrs *attrs)
-{
-}
-
-static inline void xen_dma_sync_single_for_cpu(struct device *hwdev,
-		dma_addr_t handle, size_t size, enum dma_data_direction dir)
-{
-}
-
-static inline void xen_dma_sync_single_for_device(struct device *hwdev,
-		dma_addr_t handle, size_t size, enum dma_data_direction dir)
-{
-}
-#endif /* _ASM_ARM64_XEN_PAGE_COHERENT_H */
+#include <../../arm/include/asm/xen/page-coherent.h>
-- 
1.7.10.4


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

* [PATCH v8 10/13] xen/arm/arm64: introduce xen_arch_need_swiotlb
  2014-11-10 16:12 [PATCH v8 0/13] introduce GNTTABOP_cache_flush Stefano Stabellini
                   ` (8 preceding siblings ...)
  2014-11-10 16:14 ` [PATCH v8 09/13] xen/arm/arm64: merge xen/mm32.c into xen/mm.c Stefano Stabellini
@ 2014-11-10 16:14 ` Stefano Stabellini
  2014-11-10 18:34   ` Catalin Marinas
  2014-11-10 16:14 ` [PATCH v8 11/13] xen/arm: introduce GNTTABOP_cache_flush Stefano Stabellini
                   ` (3 subsequent siblings)
  13 siblings, 1 reply; 25+ messages in thread
From: Stefano Stabellini @ 2014-11-10 16:14 UTC (permalink / raw
  To: xen-devel
  Cc: konrad.wilk, Ian.Campbell, david.vrabel, linux-kernel,
	Stefano.Stabellini, linux-arm-kernel, catalin.marinas,
	Stefano Stabellini

Introduce an arch specific function to find out whether a particular dma
mapping operation needs to bounce on the swiotlb buffer.

On ARM and ARM64, if the page involved is a foreign page and the device
is not coherent, we need to bounce because at unmap time we cannot
execute any required cache maintenance operations (we don't know how to
find the pfn from the mfn).

No change of behaviour for x86.

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

---

Changes in v6:
- fix ts.

Changes in v5:
- fix indentation.
---
 arch/arm/include/asm/xen/page.h |    4 ++++
 arch/arm/xen/mm.c               |    7 +++++++
 arch/x86/include/asm/xen/page.h |    7 +++++++
 drivers/xen/swiotlb-xen.c       |    5 ++++-
 4 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/xen/page.h b/arch/arm/include/asm/xen/page.h
index 135c24a..68c739b 100644
--- a/arch/arm/include/asm/xen/page.h
+++ b/arch/arm/include/asm/xen/page.h
@@ -107,4 +107,8 @@ static inline bool set_phys_to_machine(unsigned long pfn, unsigned long mfn)
 #define xen_remap(cookie, size) ioremap_cache((cookie), (size))
 #define xen_unmap(cookie) iounmap((cookie))
 
+bool xen_arch_need_swiotlb(struct device *dev,
+			   unsigned long pfn,
+			   unsigned long mfn);
+
 #endif /* _ASM_ARM_XEN_PAGE_H */
diff --git a/arch/arm/xen/mm.c b/arch/arm/xen/mm.c
index 0e96023..1b087cd 100644
--- a/arch/arm/xen/mm.c
+++ b/arch/arm/xen/mm.c
@@ -102,6 +102,13 @@ void __xen_dma_sync_single_for_device(struct device *hwdev,
 	__xen_dma_page_cpu_to_dev(hwdev, handle, size, dir);
 }
 
+bool xen_arch_need_swiotlb(struct device *dev,
+			   unsigned long pfn,
+			   unsigned long mfn)
+{
+	return ((pfn != mfn) && !is_device_dma_coherent(dev));
+}
+
 int xen_create_contiguous_region(phys_addr_t pstart, unsigned int order,
 				 unsigned int address_bits,
 				 dma_addr_t *dma_handle)
diff --git a/arch/x86/include/asm/xen/page.h b/arch/x86/include/asm/xen/page.h
index c949923..f58ef6c 100644
--- a/arch/x86/include/asm/xen/page.h
+++ b/arch/x86/include/asm/xen/page.h
@@ -236,4 +236,11 @@ void make_lowmem_page_readwrite(void *vaddr);
 #define xen_remap(cookie, size) ioremap((cookie), (size));
 #define xen_unmap(cookie) iounmap((cookie))
 
+static inline bool xen_arch_need_swiotlb(struct device *dev,
+					 unsigned long pfn,
+					 unsigned long mfn)
+{
+	return false;
+}
+
 #endif /* _ASM_X86_XEN_PAGE_H */
diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c
index ad2c5eb..3725ee4 100644
--- a/drivers/xen/swiotlb-xen.c
+++ b/drivers/xen/swiotlb-xen.c
@@ -399,7 +399,9 @@ dma_addr_t xen_swiotlb_map_page(struct device *dev, struct page *page,
 	 * buffering it.
 	 */
 	if (dma_capable(dev, dev_addr, size) &&
-	    !range_straddles_page_boundary(phys, size) && !swiotlb_force) {
+	    !range_straddles_page_boundary(phys, size) &&
+		!xen_arch_need_swiotlb(dev, PFN_DOWN(phys), PFN_DOWN(dev_addr)) &&
+		!swiotlb_force) {
 		/* we are not interested in the dma_addr returned by
 		 * xen_dma_map_page, only in the potential cache flushes executed
 		 * by the function. */
@@ -557,6 +559,7 @@ xen_swiotlb_map_sg_attrs(struct device *hwdev, struct scatterlist *sgl,
 		dma_addr_t dev_addr = xen_phys_to_bus(paddr);
 
 		if (swiotlb_force ||
+		    xen_arch_need_swiotlb(hwdev, PFN_DOWN(paddr), PFN_DOWN(dev_addr)) ||
 		    !dma_capable(hwdev, dev_addr, sg->length) ||
 		    range_straddles_page_boundary(paddr, sg->length)) {
 			phys_addr_t map = swiotlb_tbl_map_single(hwdev,
-- 
1.7.10.4


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

* [PATCH v8 11/13] xen/arm: introduce GNTTABOP_cache_flush
  2014-11-10 16:12 [PATCH v8 0/13] introduce GNTTABOP_cache_flush Stefano Stabellini
                   ` (9 preceding siblings ...)
  2014-11-10 16:14 ` [PATCH v8 10/13] xen/arm/arm64: introduce xen_arch_need_swiotlb Stefano Stabellini
@ 2014-11-10 16:14 ` Stefano Stabellini
  2014-11-10 16:14 ` [PATCH v8 12/13] swiotlb-xen: pass dev_addr to xen_dma_unmap_page and xen_dma_sync_single_for_cpu Stefano Stabellini
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 25+ messages in thread
From: Stefano Stabellini @ 2014-11-10 16:14 UTC (permalink / raw
  To: xen-devel
  Cc: konrad.wilk, Ian.Campbell, david.vrabel, linux-kernel,
	Stefano.Stabellini, linux-arm-kernel, catalin.marinas,
	Stefano Stabellini

Introduce support for new hypercall GNTTABOP_cache_flush.
Use it to perform cache flashing on pages used for dma when necessary.

If GNTTABOP_cache_flush is supported by the hypervisor, we don't need to
bounce dma map operations that involve foreign grants and non-coherent
devices.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>

---

Changes in v5:
- rename hypercall_flush to hypercall_cflush;
- remove spurious change.

Changes in v4:
- add comment;
- avoid bouncing dma map operations that involve foreign grants and
non-coherent devices if GNTTABOP_cache_flush is provided by Xen.

Changes in v3:
- fix the cache maintenance op call to match what Linux does natively;
- update the hypercall interface to match Xen.

Changes in v2:
- update the hypercall interface to match Xen;
- call the interface on a single page at a time.
---
 arch/arm/xen/mm.c                   |   34 ++++++++++++++++++++++++++++++++--
 include/xen/interface/grant_table.h |   19 +++++++++++++++++++
 2 files changed, 51 insertions(+), 2 deletions(-)

diff --git a/arch/arm/xen/mm.c b/arch/arm/xen/mm.c
index 1b087cd..49bfec9 100644
--- a/arch/arm/xen/mm.c
+++ b/arch/arm/xen/mm.c
@@ -12,6 +12,7 @@
 #include <linux/swiotlb.h>
 
 #include <xen/xen.h>
+#include <xen/interface/grant_table.h>
 #include <xen/interface/memory.h>
 #include <xen/swiotlb-xen.h>
 
@@ -24,12 +25,14 @@ enum dma_cache_op {
        DMA_UNMAP,
        DMA_MAP,
 };
+static bool hypercall_cflush = false;
 
 /* functions called by SWIOTLB */
 
 static void dma_cache_maint(dma_addr_t handle, unsigned long offset,
 	size_t size, enum dma_data_direction dir, enum dma_cache_op op)
 {
+	struct gnttab_cache_flush cflush;
 	unsigned long pfn;
 	size_t left = size;
 
@@ -41,7 +44,26 @@ static void dma_cache_maint(dma_addr_t handle, unsigned long offset,
 	
 		BUG_ON(pfn_valid(pfn));
 
-		/* TODO: cache flush */
+		/* buffers in highmem or foreign pages cannot cross page
+		 * boundaries */
+		if (len + offset > PAGE_SIZE)
+			len = PAGE_SIZE - offset;
+
+		cflush.op = 0;
+		cflush.a.dev_bus_addr = pfn << PAGE_SHIFT;
+		cflush.offset = offset;
+		cflush.length = len;
+
+		if (op == DMA_UNMAP && dir != DMA_TO_DEVICE)
+			cflush.op = GNTTAB_CACHE_INVAL;
+		if (op == DMA_MAP) {
+			if (dir == DMA_FROM_DEVICE)
+				cflush.op = GNTTAB_CACHE_INVAL;
+			else
+				cflush.op = GNTTAB_CACHE_CLEAN;
+		}
+		if (cflush.op)
+			HYPERVISOR_grant_table_op(GNTTABOP_cache_flush, &cflush, 1);
 
 		offset = 0;
 		pfn++;
@@ -106,7 +128,7 @@ bool xen_arch_need_swiotlb(struct device *dev,
 			   unsigned long pfn,
 			   unsigned long mfn)
 {
-	return ((pfn != mfn) && !is_device_dma_coherent(dev));
+	return (!hypercall_cflush && (pfn != mfn) && !is_device_dma_coherent(dev));
 }
 
 int xen_create_contiguous_region(phys_addr_t pstart, unsigned int order,
@@ -149,10 +171,18 @@ static struct dma_map_ops xen_swiotlb_dma_ops = {
 
 int __init xen_mm_init(void)
 {
+	struct gnttab_cache_flush cflush;
 	if (!xen_initial_domain())
 		return 0;
 	xen_swiotlb_init(1, false);
 	xen_dma_ops = &xen_swiotlb_dma_ops;
+
+	cflush.op = 0;
+	cflush.a.dev_bus_addr = 0;
+	cflush.offset = 0;
+	cflush.length = 0;
+	if (HYPERVISOR_grant_table_op(GNTTABOP_cache_flush, &cflush, 1) != -ENOSYS)
+		hypercall_cflush = true;
 	return 0;
 }
 arch_initcall(xen_mm_init);
diff --git a/include/xen/interface/grant_table.h b/include/xen/interface/grant_table.h
index e40fae9..bcce564 100644
--- a/include/xen/interface/grant_table.h
+++ b/include/xen/interface/grant_table.h
@@ -479,6 +479,25 @@ struct gnttab_get_version {
 DEFINE_GUEST_HANDLE_STRUCT(gnttab_get_version);
 
 /*
+ * Issue one or more cache maintenance operations on a portion of a
+ * page granted to the calling domain by a foreign domain.
+ */
+#define GNTTABOP_cache_flush          12
+struct gnttab_cache_flush {
+    union {
+        uint64_t dev_bus_addr;
+        grant_ref_t ref;
+    } a;
+    uint16_t offset;   /* offset from start of grant */
+    uint16_t length;   /* size within the grant */
+#define GNTTAB_CACHE_CLEAN          (1<<0)
+#define GNTTAB_CACHE_INVAL          (1<<1)
+#define GNTTAB_CACHE_SOURCE_GREF    (1<<31)
+    uint32_t op;
+};
+DEFINE_GUEST_HANDLE_STRUCT(gnttab_cache_flush);
+
+/*
  * Bitfield values for update_pin_status.flags.
  */
  /* Map the grant entry for access by I/O devices. */
-- 
1.7.10.4


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

* [PATCH v8 12/13] swiotlb-xen: pass dev_addr to xen_dma_unmap_page and xen_dma_sync_single_for_cpu
  2014-11-10 16:12 [PATCH v8 0/13] introduce GNTTABOP_cache_flush Stefano Stabellini
                   ` (10 preceding siblings ...)
  2014-11-10 16:14 ` [PATCH v8 11/13] xen/arm: introduce GNTTABOP_cache_flush Stefano Stabellini
@ 2014-11-10 16:14 ` Stefano Stabellini
  2014-11-10 16:14 ` [PATCH v8 13/13] swiotlb-xen: remove BUG_ON in xen_bus_to_phys Stefano Stabellini
  2014-11-10 18:44 ` [PATCH v8 0/13] introduce GNTTABOP_cache_flush Catalin Marinas
  13 siblings, 0 replies; 25+ messages in thread
From: Stefano Stabellini @ 2014-11-10 16:14 UTC (permalink / raw
  To: xen-devel
  Cc: konrad.wilk, Ian.Campbell, david.vrabel, linux-kernel,
	Stefano.Stabellini, linux-arm-kernel, catalin.marinas,
	Stefano Stabellini

xen_dma_unmap_page and xen_dma_sync_single_for_cpu take a dma_addr_t
handle as argument, not a physical address.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
 drivers/xen/swiotlb-xen.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c
index 3725ee4..498b654 100644
--- a/drivers/xen/swiotlb-xen.c
+++ b/drivers/xen/swiotlb-xen.c
@@ -449,7 +449,7 @@ static void xen_unmap_single(struct device *hwdev, dma_addr_t dev_addr,
 
 	BUG_ON(dir == DMA_NONE);
 
-	xen_dma_unmap_page(hwdev, paddr, size, dir, attrs);
+	xen_dma_unmap_page(hwdev, dev_addr, size, dir, attrs);
 
 	/* NOTE: We use dev_addr here, not paddr! */
 	if (is_xen_swiotlb_buffer(dev_addr)) {
@@ -497,14 +497,14 @@ xen_swiotlb_sync_single(struct device *hwdev, dma_addr_t dev_addr,
 	BUG_ON(dir == DMA_NONE);
 
 	if (target == SYNC_FOR_CPU)
-		xen_dma_sync_single_for_cpu(hwdev, paddr, size, dir);
+		xen_dma_sync_single_for_cpu(hwdev, dev_addr, size, dir);
 
 	/* NOTE: We use dev_addr here, not paddr! */
 	if (is_xen_swiotlb_buffer(dev_addr))
 		swiotlb_tbl_sync_single(hwdev, paddr, size, dir, target);
 
 	if (target == SYNC_FOR_DEVICE)
-		xen_dma_sync_single_for_cpu(hwdev, paddr, size, dir);
+		xen_dma_sync_single_for_cpu(hwdev, dev_addr, size, dir);
 
 	if (dir != DMA_FROM_DEVICE)
 		return;
-- 
1.7.10.4


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

* [PATCH v8 13/13] swiotlb-xen: remove BUG_ON in xen_bus_to_phys
  2014-11-10 16:12 [PATCH v8 0/13] introduce GNTTABOP_cache_flush Stefano Stabellini
                   ` (11 preceding siblings ...)
  2014-11-10 16:14 ` [PATCH v8 12/13] swiotlb-xen: pass dev_addr to xen_dma_unmap_page and xen_dma_sync_single_for_cpu Stefano Stabellini
@ 2014-11-10 16:14 ` Stefano Stabellini
  2014-11-10 18:44 ` [PATCH v8 0/13] introduce GNTTABOP_cache_flush Catalin Marinas
  13 siblings, 0 replies; 25+ messages in thread
From: Stefano Stabellini @ 2014-11-10 16:14 UTC (permalink / raw
  To: xen-devel
  Cc: konrad.wilk, Ian.Campbell, david.vrabel, linux-kernel,
	Stefano.Stabellini, linux-arm-kernel, catalin.marinas,
	Stefano Stabellini

On x86 truncation cannot occur because config XEN depends on X86_64 ||
(X86_32 && X86_PAE).

On ARM truncation can occur without CONFIG_ARM_LPAE, when the dma
operation involves foreign grants. However in that case the physical
address returned by xen_bus_to_phys is actually invalid (there is no mfn
to pfn tracking for foreign grants on ARM) and it is not used.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
 drivers/xen/swiotlb-xen.c |    2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c
index 498b654..153cf14 100644
--- a/drivers/xen/swiotlb-xen.c
+++ b/drivers/xen/swiotlb-xen.c
@@ -96,8 +96,6 @@ static inline phys_addr_t xen_bus_to_phys(dma_addr_t baddr)
 	dma_addr_t dma = (dma_addr_t)pfn << PAGE_SHIFT;
 	phys_addr_t paddr = dma;
 
-	BUG_ON(paddr != dma); /* truncation has occurred, should never happen */
-
 	paddr |= baddr & ~PAGE_MASK;
 
 	return paddr;
-- 
1.7.10.4


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

* Re: [PATCH v8 07/13] xen: add a dma_addr_t dev_addr argument to xen_dma_map_page
  2014-11-10 16:13 ` [PATCH v8 07/13] xen: add a dma_addr_t dev_addr argument to xen_dma_map_page Stefano Stabellini
@ 2014-11-10 18:24   ` Catalin Marinas
  0 siblings, 0 replies; 25+ messages in thread
From: Catalin Marinas @ 2014-11-10 18:24 UTC (permalink / raw
  To: Stefano Stabellini
  Cc: xen-devel@lists.xensource.com, konrad.wilk@oracle.com,
	Ian.Campbell@citrix.com, david.vrabel@citrix.com,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org

On Mon, Nov 10, 2014 at 04:13:59PM +0000, Stefano Stabellini wrote:
> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> CC: david.vrabel@citrix.com
> CC: konrad.wilk@oracle.com
> ---
>  arch/arm/include/asm/xen/page-coherent.h   |    4 ++--
>  arch/arm64/include/asm/xen/page-coherent.h |    4 ++--
>  arch/x86/include/asm/xen/page-coherent.h   |    4 ++--
>  drivers/xen/swiotlb-xen.c                  |    6 ++++--
>  4 files changed, 10 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/arm/include/asm/xen/page-coherent.h b/arch/arm/include/asm/xen/page-coherent.h
> index d97b0b4..25d450c 100644
> --- a/arch/arm/include/asm/xen/page-coherent.h
> +++ b/arch/arm/include/asm/xen/page-coherent.h
> @@ -29,8 +29,8 @@ static inline void xen_free_coherent_pages(struct device *hwdev, size_t size,
>  }
>  
>  static inline void xen_dma_map_page(struct device *hwdev, struct page *page,
> -	     unsigned long offset, size_t size, enum dma_data_direction dir,
> -	     struct dma_attrs *attrs)
> +	     dma_addr_t dev_addr, unsigned long offset, size_t size,
> +	     enum dma_data_direction dir, struct dma_attrs *attrs)

It works for me as well. But it would be good to add a comment for this
patch to explain why a new argument is needed (like dev_addr being the
actual machine address and not dom0 physical address).

-- 
Catalin

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

* Re: [PATCH v8 08/13] xen/arm: use hypercall to flush caches in map_page
  2014-11-10 16:14 ` [PATCH v8 08/13] xen/arm: use hypercall to flush caches in map_page Stefano Stabellini
@ 2014-11-10 18:27   ` Catalin Marinas
  0 siblings, 0 replies; 25+ messages in thread
From: Catalin Marinas @ 2014-11-10 18:27 UTC (permalink / raw
  To: Stefano Stabellini
  Cc: xen-devel@lists.xensource.com, konrad.wilk@oracle.com,
	Ian.Campbell@citrix.com, david.vrabel@citrix.com,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org

On Mon, Nov 10, 2014 at 04:14:00PM +0000, Stefano Stabellini wrote:
> In xen_dma_map_page, if the page is a local page, call the native
> map_page dma_ops. If the page is foreign, call __xen_dma_map_page that
> issues any required cache maintenane operations via hypercall.
> 
> The reason for doing this is that the native dma_ops map_page could
> allocate buffers than need to be freed. If the page is foreign we don't
> call the native unmap_page dma_ops function, resulting in a memory leak.
> 
> Suggested-by: Catalin Marinas <catalin.marinas@arm.com>
> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> ---
>  arch/arm/include/asm/xen/page-coherent.h |    9 ++++++++-
>  arch/arm/xen/mm32.c                      |   12 ++++++++++++
>  2 files changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/include/asm/xen/page-coherent.h b/arch/arm/include/asm/xen/page-coherent.h
> index 25d450c..36b79a8 100644
> --- a/arch/arm/include/asm/xen/page-coherent.h
> +++ b/arch/arm/include/asm/xen/page-coherent.h
> @@ -5,6 +5,9 @@
>  #include <linux/dma-attrs.h>
>  #include <linux/dma-mapping.h>
>  
> +void __xen_dma_map_page(struct device *hwdev, struct page *page,
> +	     dma_addr_t dev_addr, unsigned long offset, size_t size,
> +	     enum dma_data_direction dir, struct dma_attrs *attrs);
>  void __xen_dma_unmap_page(struct device *hwdev, dma_addr_t handle,
>  		size_t size, enum dma_data_direction dir,
>  		struct dma_attrs *attrs);
> @@ -32,7 +35,11 @@ static inline void xen_dma_map_page(struct device *hwdev, struct page *page,
>  	     dma_addr_t dev_addr, unsigned long offset, size_t size,
>  	     enum dma_data_direction dir, struct dma_attrs *attrs)
>  {
> -	__generic_dma_ops(hwdev)->map_page(hwdev, page, offset, size, dir, attrs);
> +	if (PFN_DOWN(dev_addr) == page_to_pfn(page)) {

Nitpick: you could write:

	bool foreign = PFN_DOWN(dev_addr) == page_to_pfn(page);

or even a static inline xen_foreign_page(page, dev_addr) function for
clarity. This code lacks comments.

> +		if (__generic_dma_ops(hwdev)->map_page)

I'm not sure we need to check map_page() here. I thought it's always
present as host DMA API does not check for it.

-- 
Catalin

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

* Re: [PATCH v8 09/13] xen/arm/arm64: merge xen/mm32.c into xen/mm.c
  2014-11-10 16:14 ` [PATCH v8 09/13] xen/arm/arm64: merge xen/mm32.c into xen/mm.c Stefano Stabellini
@ 2014-11-10 18:32   ` Catalin Marinas
  0 siblings, 0 replies; 25+ messages in thread
From: Catalin Marinas @ 2014-11-10 18:32 UTC (permalink / raw
  To: Stefano Stabellini
  Cc: xen-devel@lists.xensource.com, konrad.wilk@oracle.com,
	Ian.Campbell@citrix.com, david.vrabel@citrix.com,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org

On Mon, Nov 10, 2014 at 04:14:01PM +0000, Stefano Stabellini wrote:
> --- a/arch/arm/xen/mm.c
> +++ b/arch/arm/xen/mm.c
> @@ -1,6 +1,10 @@
> +#include <linux/cpu.h>
> +#include <linux/dma-mapping.h>
>  #include <linux/bootmem.h>
>  #include <linux/gfp.h>
> +#include <linux/highmem.h>
>  #include <linux/export.h>
> +#include <linux/of_address.h>
>  #include <linux/slab.h>
>  #include <linux/types.h>
>  #include <linux/dma-mapping.h>
> @@ -16,6 +20,88 @@
>  #include <asm/xen/hypercall.h>
>  #include <asm/xen/interface.h>
>  
> +enum dma_cache_op {
> +       DMA_UNMAP,
> +       DMA_MAP,
> +};
> +
> +/* functions called by SWIOTLB */
> +
> +static void dma_cache_maint(dma_addr_t handle, unsigned long offset,
> +	size_t size, enum dma_data_direction dir, enum dma_cache_op op)
> +{
> +	unsigned long pfn;
> +	size_t left = size;
> +
> +	pfn = (handle >> PAGE_SHIFT) + offset / PAGE_SIZE;
> +	offset %= PAGE_SIZE;
> +
> +	do {
> +		size_t len = left;
> +	
> +		BUG_ON(pfn_valid(pfn));

You probably don't need this in the loop.

> +
> +		/* TODO: cache flush */
> +
> +		offset = 0;
> +		pfn++;
> +		left -= len;
> +	} while (left);
> +}

That's smaller now ;). I have to finish reading the other patches to see
what ends up replacing TODO.

-- 
Catalin

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

* Re: [PATCH v8 10/13] xen/arm/arm64: introduce xen_arch_need_swiotlb
  2014-11-10 16:14 ` [PATCH v8 10/13] xen/arm/arm64: introduce xen_arch_need_swiotlb Stefano Stabellini
@ 2014-11-10 18:34   ` Catalin Marinas
  2014-11-11 11:52     ` Stefano Stabellini
  0 siblings, 1 reply; 25+ messages in thread
From: Catalin Marinas @ 2014-11-10 18:34 UTC (permalink / raw
  To: Stefano Stabellini
  Cc: xen-devel@lists.xensource.com, konrad.wilk@oracle.com,
	Ian.Campbell@citrix.com, david.vrabel@citrix.com,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org

On Mon, Nov 10, 2014 at 04:14:02PM +0000, Stefano Stabellini wrote:
> --- a/arch/arm/include/asm/xen/page.h
> +++ b/arch/arm/include/asm/xen/page.h
> @@ -107,4 +107,8 @@ static inline bool set_phys_to_machine(unsigned long pfn, unsigned long mfn)
>  #define xen_remap(cookie, size) ioremap_cache((cookie), (size))
>  #define xen_unmap(cookie) iounmap((cookie))
>  
> +bool xen_arch_need_swiotlb(struct device *dev,
> +			   unsigned long pfn,
> +			   unsigned long mfn);
> +
>  #endif /* _ASM_ARM_XEN_PAGE_H */
> diff --git a/arch/arm/xen/mm.c b/arch/arm/xen/mm.c
> index 0e96023..1b087cd 100644
> --- a/arch/arm/xen/mm.c
> +++ b/arch/arm/xen/mm.c
> @@ -102,6 +102,13 @@ void __xen_dma_sync_single_for_device(struct device *hwdev,
>  	__xen_dma_page_cpu_to_dev(hwdev, handle, size, dir);
>  }
>  
> +bool xen_arch_need_swiotlb(struct device *dev,
> +			   unsigned long pfn,
> +			   unsigned long mfn)
> +{
> +	return ((pfn != mfn) && !is_device_dma_coherent(dev));
> +}

Why not a static inline? It doesn't look like a big function.

-- 
Catalin

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

* Re: [PATCH v8 03/13] xen/arm: if(pfn_valid(pfn)) call native dma_ops
  2014-11-10 16:13 ` [PATCH v8 03/13] xen/arm: if(pfn_valid(pfn)) call native dma_ops Stefano Stabellini
@ 2014-11-10 18:41   ` Catalin Marinas
  2014-11-11 11:07     ` Stefano Stabellini
  0 siblings, 1 reply; 25+ messages in thread
From: Catalin Marinas @ 2014-11-10 18:41 UTC (permalink / raw
  To: Stefano Stabellini
  Cc: xen-devel@lists.xensource.com, konrad.wilk@oracle.com,
	Ian.Campbell@citrix.com, david.vrabel@citrix.com,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org

On Mon, Nov 10, 2014 at 04:13:55PM +0000, Stefano Stabellini wrote:
>  void xen_dma_unmap_page(struct device *hwdev, dma_addr_t handle,
>  		size_t size, enum dma_data_direction dir,
> -		struct dma_attrs *attrs);
> +		struct dma_attrs *attrs)
> +{
> +	unsigned long pfn = PFN_DOWN(handle);
> +	/* Dom0 is mapped 1:1, so calling pfn_valid on a foreign mfn will
> +	 * always return false. If the page is local we can safely call the
> +	 * native dma_ops function, otherwise we call the xen specific
> +	 * function. */
> +	if (pfn_valid(pfn)) {
> +		if (__generic_dma_ops(hwdev)->unmap_page)
> +			__generic_dma_ops(hwdev)->unmap_page(hwdev, handle, size, dir, attrs);

Similarly here, do we need the unmap_page check? dma_map_page() does not
do it.

-- 
Catalin

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

* Re: [PATCH v8 04/13] arm64: introduce is_device_dma_coherent
  2014-11-10 16:13 ` [PATCH v8 04/13] arm64: introduce is_device_dma_coherent Stefano Stabellini
@ 2014-11-10 18:42   ` Catalin Marinas
  2014-11-11 11:14     ` Stefano Stabellini
  0 siblings, 1 reply; 25+ messages in thread
From: Catalin Marinas @ 2014-11-10 18:42 UTC (permalink / raw
  To: Stefano Stabellini
  Cc: xen-devel@lists.xensource.com, konrad.wilk@oracle.com,
	Ian.Campbell@citrix.com, david.vrabel@citrix.com,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, Will Deacon

On Mon, Nov 10, 2014 at 04:13:56PM +0000, Stefano Stabellini wrote:
> Introduce a boolean flag and an accessor function to check whether a
> device is dma_coherent. Set the flag from set_arch_dma_coherent_ops.
> 
> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

BTW, why do I sign off this patch? As long as it's you as author, I
don't think you should add my sign-off.

-- 
Catalin

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

* Re: [PATCH v8 0/13] introduce GNTTABOP_cache_flush
  2014-11-10 16:12 [PATCH v8 0/13] introduce GNTTABOP_cache_flush Stefano Stabellini
                   ` (12 preceding siblings ...)
  2014-11-10 16:14 ` [PATCH v8 13/13] swiotlb-xen: remove BUG_ON in xen_bus_to_phys Stefano Stabellini
@ 2014-11-10 18:44 ` Catalin Marinas
  2014-11-11 11:16   ` Stefano Stabellini
  13 siblings, 1 reply; 25+ messages in thread
From: Catalin Marinas @ 2014-11-10 18:44 UTC (permalink / raw
  To: Stefano Stabellini
  Cc: xen-devel@lists.xensource.com, Konrad Rzeszutek Wilk,
	Ian.Campbell@citrix.com, David Vrabel,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org

On Mon, Nov 10, 2014 at 04:12:40PM +0000, Stefano Stabellini wrote:
> this patch series introduces support for GNTTABOP_cache_flush to perform
> cache maintenance operation on foreign pages and reverts the current
> code based on XENFEAT_grant_map_identity.
> 
> It also provides a very slow fallback by bouncing on the swiotlb buffer,
> in case the hypercall is not available.
> 
> v7 introduces a flag named dma_coherent in dev_archdata and an accessor
> function named is_device_dma_coherent in asm/dma-mapping.h under arm and
> arm64.

Apart from a few minor comments I gave already, the series looks fine to
me. Once addressed, you can add:

Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>

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

* Re: [PATCH v8 03/13] xen/arm: if(pfn_valid(pfn)) call native dma_ops
  2014-11-10 18:41   ` Catalin Marinas
@ 2014-11-11 11:07     ` Stefano Stabellini
  0 siblings, 0 replies; 25+ messages in thread
From: Stefano Stabellini @ 2014-11-11 11:07 UTC (permalink / raw
  To: Catalin Marinas
  Cc: Stefano Stabellini, xen-devel@lists.xensource.com,
	konrad.wilk@oracle.com, Ian.Campbell@citrix.com,
	david.vrabel@citrix.com, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org

On Mon, 10 Nov 2014, Catalin Marinas wrote:
> On Mon, Nov 10, 2014 at 04:13:55PM +0000, Stefano Stabellini wrote:
> >  void xen_dma_unmap_page(struct device *hwdev, dma_addr_t handle,
> >  		size_t size, enum dma_data_direction dir,
> > -		struct dma_attrs *attrs);
> > +		struct dma_attrs *attrs)
> > +{
> > +	unsigned long pfn = PFN_DOWN(handle);
> > +	/* Dom0 is mapped 1:1, so calling pfn_valid on a foreign mfn will
> > +	 * always return false. If the page is local we can safely call the
> > +	 * native dma_ops function, otherwise we call the xen specific
> > +	 * function. */
> > +	if (pfn_valid(pfn)) {
> > +		if (__generic_dma_ops(hwdev)->unmap_page)
> > +			__generic_dma_ops(hwdev)->unmap_page(hwdev, handle, size, dir, attrs);
> 
> Similarly here, do we need the unmap_page check? dma_map_page() does not
> do it.

I think we do not need the map_page check, because that's always
implemented, but we need the unmap_page check. In fact
arm_coherent_dma_ops doesn't have unmap_page for example.

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

* Re: [PATCH v8 04/13] arm64: introduce is_device_dma_coherent
  2014-11-10 18:42   ` Catalin Marinas
@ 2014-11-11 11:14     ` Stefano Stabellini
  0 siblings, 0 replies; 25+ messages in thread
From: Stefano Stabellini @ 2014-11-11 11:14 UTC (permalink / raw
  To: Catalin Marinas
  Cc: Stefano Stabellini, xen-devel@lists.xensource.com,
	konrad.wilk@oracle.com, Ian.Campbell@citrix.com,
	david.vrabel@citrix.com, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, Will Deacon

On Mon, 10 Nov 2014, Catalin Marinas wrote:
> On Mon, Nov 10, 2014 at 04:13:56PM +0000, Stefano Stabellini wrote:
> > Introduce a boolean flag and an accessor function to check whether a
> > device is dma_coherent. Set the flag from set_arch_dma_coherent_ops.
> > 
> > Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> > Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
> 
> BTW, why do I sign off this patch? As long as it's you as author, I
> don't think you should add my sign-off.

IANAL but as you wrote most of the code in the patch, I think that your
Signed-off-by is required because the lines you wrote are under your
copyright, not mine. TBH for such a small patch, it probably doesn't
matter (there is a limit to what one can claim copyright on).

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

* Re: [PATCH v8 0/13] introduce GNTTABOP_cache_flush
  2014-11-10 18:44 ` [PATCH v8 0/13] introduce GNTTABOP_cache_flush Catalin Marinas
@ 2014-11-11 11:16   ` Stefano Stabellini
  0 siblings, 0 replies; 25+ messages in thread
From: Stefano Stabellini @ 2014-11-11 11:16 UTC (permalink / raw
  To: Catalin Marinas
  Cc: Stefano Stabellini, xen-devel@lists.xensource.com,
	Konrad Rzeszutek Wilk, Ian.Campbell@citrix.com, David Vrabel,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org

On Mon, 10 Nov 2014, Catalin Marinas wrote:
> On Mon, Nov 10, 2014 at 04:12:40PM +0000, Stefano Stabellini wrote:
> > this patch series introduces support for GNTTABOP_cache_flush to perform
> > cache maintenance operation on foreign pages and reverts the current
> > code based on XENFEAT_grant_map_identity.
> > 
> > It also provides a very slow fallback by bouncing on the swiotlb buffer,
> > in case the hypercall is not available.
> > 
> > v7 introduces a flag named dma_coherent in dev_archdata and an accessor
> > function named is_device_dma_coherent in asm/dma-mapping.h under arm and
> > arm64.
> 
> Apart from a few minor comments I gave already, the series looks fine to
> me. Once addressed, you can add:
> 
> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>

Thank you very much for your help!

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

* Re: [PATCH v8 10/13] xen/arm/arm64: introduce xen_arch_need_swiotlb
  2014-11-10 18:34   ` Catalin Marinas
@ 2014-11-11 11:52     ` Stefano Stabellini
  0 siblings, 0 replies; 25+ messages in thread
From: Stefano Stabellini @ 2014-11-11 11:52 UTC (permalink / raw
  To: Catalin Marinas
  Cc: Stefano Stabellini, xen-devel@lists.xensource.com,
	konrad.wilk@oracle.com, Ian.Campbell@citrix.com,
	david.vrabel@citrix.com, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org

On Mon, 10 Nov 2014, Catalin Marinas wrote:
> On Mon, Nov 10, 2014 at 04:14:02PM +0000, Stefano Stabellini wrote:
> > --- a/arch/arm/include/asm/xen/page.h
> > +++ b/arch/arm/include/asm/xen/page.h
> > @@ -107,4 +107,8 @@ static inline bool set_phys_to_machine(unsigned long pfn, unsigned long mfn)
> >  #define xen_remap(cookie, size) ioremap_cache((cookie), (size))
> >  #define xen_unmap(cookie) iounmap((cookie))
> >  
> > +bool xen_arch_need_swiotlb(struct device *dev,
> > +			   unsigned long pfn,
> > +			   unsigned long mfn);
> > +
> >  #endif /* _ASM_ARM_XEN_PAGE_H */
> > diff --git a/arch/arm/xen/mm.c b/arch/arm/xen/mm.c
> > index 0e96023..1b087cd 100644
> > --- a/arch/arm/xen/mm.c
> > +++ b/arch/arm/xen/mm.c
> > @@ -102,6 +102,13 @@ void __xen_dma_sync_single_for_device(struct device *hwdev,
> >  	__xen_dma_page_cpu_to_dev(hwdev, handle, size, dir);
> >  }
> >  
> > +bool xen_arch_need_swiotlb(struct device *dev,
> > +			   unsigned long pfn,
> > +			   unsigned long mfn)
> > +{
> > +	return ((pfn != mfn) && !is_device_dma_coherent(dev));
> > +}
> 
> Why not a static inline? It doesn't look like a big function.

Because the next patch is going to make this change:

-   return ((pfn != mfn) && !is_device_dma_coherent(dev));
+   return (!hypercall_cflush && (pfn != mfn) && !is_device_dma_coherent(dev));

and I think it makes sense to keep hypercall_cflush as a static variable
within arch/arm/xen/mm.c (avoid exporting it in page.h).

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

end of thread, other threads:[~2014-11-11 12:02 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-10 16:12 [PATCH v8 0/13] introduce GNTTABOP_cache_flush Stefano Stabellini
2014-11-10 16:13 ` [PATCH v8 01/13] xen/arm: remove handling of XENFEAT_grant_map_identity Stefano Stabellini
2014-11-10 16:13 ` [PATCH v8 02/13] xen/arm: remove outer_*_range call Stefano Stabellini
2014-11-10 16:13 ` [PATCH v8 03/13] xen/arm: if(pfn_valid(pfn)) call native dma_ops Stefano Stabellini
2014-11-10 18:41   ` Catalin Marinas
2014-11-11 11:07     ` Stefano Stabellini
2014-11-10 16:13 ` [PATCH v8 04/13] arm64: introduce is_device_dma_coherent Stefano Stabellini
2014-11-10 18:42   ` Catalin Marinas
2014-11-11 11:14     ` Stefano Stabellini
2014-11-10 16:13 ` [PATCH v8 05/13] arm: " Stefano Stabellini
2014-11-10 16:13 ` [PATCH v8 06/13] xen/arm: use is_device_dma_coherent Stefano Stabellini
2014-11-10 16:13 ` [PATCH v8 07/13] xen: add a dma_addr_t dev_addr argument to xen_dma_map_page Stefano Stabellini
2014-11-10 18:24   ` Catalin Marinas
2014-11-10 16:14 ` [PATCH v8 08/13] xen/arm: use hypercall to flush caches in map_page Stefano Stabellini
2014-11-10 18:27   ` Catalin Marinas
2014-11-10 16:14 ` [PATCH v8 09/13] xen/arm/arm64: merge xen/mm32.c into xen/mm.c Stefano Stabellini
2014-11-10 18:32   ` Catalin Marinas
2014-11-10 16:14 ` [PATCH v8 10/13] xen/arm/arm64: introduce xen_arch_need_swiotlb Stefano Stabellini
2014-11-10 18:34   ` Catalin Marinas
2014-11-11 11:52     ` Stefano Stabellini
2014-11-10 16:14 ` [PATCH v8 11/13] xen/arm: introduce GNTTABOP_cache_flush Stefano Stabellini
2014-11-10 16:14 ` [PATCH v8 12/13] swiotlb-xen: pass dev_addr to xen_dma_unmap_page and xen_dma_sync_single_for_cpu Stefano Stabellini
2014-11-10 16:14 ` [PATCH v8 13/13] swiotlb-xen: remove BUG_ON in xen_bus_to_phys Stefano Stabellini
2014-11-10 18:44 ` [PATCH v8 0/13] introduce GNTTABOP_cache_flush Catalin Marinas
2014-11-11 11:16   ` Stefano Stabellini

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 read-only IMAP folder(s) and NNTP newsgroup(s).