All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@linaro.org>
To: linux-kernel@vger.kernel.org, stefano.stabellini@eu.citrix.com
Cc: linux-arm-kernel@lists.infradead.org, ian.campbell@citrix.com,
	xen-devel@lists.xenproject.org,
	Julien Grall <julien.grall@linaro.org>,
	Russell King <linux@arm.linux.org.co.uk>
Subject: [PATCH 1/2] arm/xen: Introduce need_xen_dma_ops and use it in get_dma_ops
Date: Thu, 20 Feb 2014 16:21:21 +0000	[thread overview]
Message-ID: <1392913281-25483-1-git-send-email-julien.grall@linaro.org> (raw)

If Xen programs the IOMMU to protect a device, it can safely use it's own DMA
ops. Some devices may use DMA but are not protected by an IOMMU. A such device
still need to use xen-swiotlb.

This patch introduces need_xen_dma_ops which will check if a device needs to
use xen DMA ops. For now, it's only check if Linux is running as DOM0.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Cc: Russell King <linux@arm.linux.org.co.uk>
---
 arch/arm/include/asm/dma-mapping.h     |    5 ++---
 arch/arm/include/asm/xen/dma-mapping.h |   13 +++++++++++++
 arch/arm/include/asm/xen/hypervisor.h  |    2 --
 3 files changed, 15 insertions(+), 5 deletions(-)
 create mode 100644 arch/arm/include/asm/xen/dma-mapping.h

diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h
index e701a4d..a40d077 100644
--- a/arch/arm/include/asm/dma-mapping.h
+++ b/arch/arm/include/asm/dma-mapping.h
@@ -11,8 +11,7 @@
 #include <asm-generic/dma-coherent.h>
 #include <asm/memory.h>
 
-#include <xen/xen.h>
-#include <asm/xen/hypervisor.h>
+#include <asm/xen/dma-mapping.h>
 
 #define DMA_ERROR_CODE	(~0)
 extern struct dma_map_ops arm_dma_ops;
@@ -27,7 +26,7 @@ static inline struct dma_map_ops *__generic_dma_ops(struct device *dev)
 
 static inline struct dma_map_ops *get_dma_ops(struct device *dev)
 {
-	if (xen_initial_domain())
+	if (need_xen_dma_ops(dev))
 		return xen_dma_ops;
 	else
 		return __generic_dma_ops(dev);
diff --git a/arch/arm/include/asm/xen/dma-mapping.h b/arch/arm/include/asm/xen/dma-mapping.h
new file mode 100644
index 0000000..002fc57
--- /dev/null
+++ b/arch/arm/include/asm/xen/dma-mapping.h
@@ -0,0 +1,13 @@
+#ifndef _ASM_ARM_XEN_DMA_MAPPING_H
+#define _ASM_ARM_XEN_DMA_MAPPING_H
+
+#include <xen/xen.h>
+
+extern struct dma_map_ops *xen_dma_ops;
+
+static inline bool need_xen_dma_ops(struct device *dev)
+{
+	return xen_initial_domain();
+}
+
+#endif /* _ASM_ARM_XEN_DMA_MAPPING_H */
diff --git a/arch/arm/include/asm/xen/hypervisor.h b/arch/arm/include/asm/xen/hypervisor.h
index 1317ee4..d7ab99a 100644
--- a/arch/arm/include/asm/xen/hypervisor.h
+++ b/arch/arm/include/asm/xen/hypervisor.h
@@ -16,6 +16,4 @@ static inline enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
 	return PARAVIRT_LAZY_NONE;
 }
 
-extern struct dma_map_ops *xen_dma_ops;
-
 #endif /* _ASM_ARM_XEN_HYPERVISOR_H */
-- 
1.7.10.4


WARNING: multiple messages have this Message-ID (diff)
From: julien.grall@linaro.org (Julien Grall)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] arm/xen: Introduce need_xen_dma_ops and use it in get_dma_ops
Date: Thu, 20 Feb 2014 16:21:21 +0000	[thread overview]
Message-ID: <1392913281-25483-1-git-send-email-julien.grall@linaro.org> (raw)

If Xen programs the IOMMU to protect a device, it can safely use it's own DMA
ops. Some devices may use DMA but are not protected by an IOMMU. A such device
still need to use xen-swiotlb.

This patch introduces need_xen_dma_ops which will check if a device needs to
use xen DMA ops. For now, it's only check if Linux is running as DOM0.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Cc: Russell King <linux@arm.linux.org.co.uk>
---
 arch/arm/include/asm/dma-mapping.h     |    5 ++---
 arch/arm/include/asm/xen/dma-mapping.h |   13 +++++++++++++
 arch/arm/include/asm/xen/hypervisor.h  |    2 --
 3 files changed, 15 insertions(+), 5 deletions(-)
 create mode 100644 arch/arm/include/asm/xen/dma-mapping.h

diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h
index e701a4d..a40d077 100644
--- a/arch/arm/include/asm/dma-mapping.h
+++ b/arch/arm/include/asm/dma-mapping.h
@@ -11,8 +11,7 @@
 #include <asm-generic/dma-coherent.h>
 #include <asm/memory.h>
 
-#include <xen/xen.h>
-#include <asm/xen/hypervisor.h>
+#include <asm/xen/dma-mapping.h>
 
 #define DMA_ERROR_CODE	(~0)
 extern struct dma_map_ops arm_dma_ops;
@@ -27,7 +26,7 @@ static inline struct dma_map_ops *__generic_dma_ops(struct device *dev)
 
 static inline struct dma_map_ops *get_dma_ops(struct device *dev)
 {
-	if (xen_initial_domain())
+	if (need_xen_dma_ops(dev))
 		return xen_dma_ops;
 	else
 		return __generic_dma_ops(dev);
diff --git a/arch/arm/include/asm/xen/dma-mapping.h b/arch/arm/include/asm/xen/dma-mapping.h
new file mode 100644
index 0000000..002fc57
--- /dev/null
+++ b/arch/arm/include/asm/xen/dma-mapping.h
@@ -0,0 +1,13 @@
+#ifndef _ASM_ARM_XEN_DMA_MAPPING_H
+#define _ASM_ARM_XEN_DMA_MAPPING_H
+
+#include <xen/xen.h>
+
+extern struct dma_map_ops *xen_dma_ops;
+
+static inline bool need_xen_dma_ops(struct device *dev)
+{
+	return xen_initial_domain();
+}
+
+#endif /* _ASM_ARM_XEN_DMA_MAPPING_H */
diff --git a/arch/arm/include/asm/xen/hypervisor.h b/arch/arm/include/asm/xen/hypervisor.h
index 1317ee4..d7ab99a 100644
--- a/arch/arm/include/asm/xen/hypervisor.h
+++ b/arch/arm/include/asm/xen/hypervisor.h
@@ -16,6 +16,4 @@ static inline enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
 	return PARAVIRT_LAZY_NONE;
 }
 
-extern struct dma_map_ops *xen_dma_ops;
-
 #endif /* _ASM_ARM_XEN_HYPERVISOR_H */
-- 
1.7.10.4

             reply	other threads:[~2014-02-20 16:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-20 16:21 Julien Grall [this message]
2014-02-20 16:21 ` [PATCH 1/2] arm/xen: Introduce need_xen_dma_ops and use it in get_dma_ops Julien Grall
2014-02-20 16:21 Julien Grall

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=1392913281-25483-1-git-send-email-julien.grall@linaro.org \
    --to=julien.grall@linaro.org \
    --cc=ian.campbell@citrix.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.co.uk \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.