From: jglisse@redhat.com
To: iommu@lists.linux-foundation.org
Cc: "Jérôme Glisse" <jglisse@redhat.com>,
"Joerg Roedel" <jroedel@suse.de>,
"Konrad Rzeszutek Wilk" <Konrad.wilk@oracle.com>,
"Alex Deucher" <alexander.deucher@amd.com>,
"Dave Airlie" <airlied@redhat.com>,
linux-kernel@vger.kernel.org
Subject: [RFC PATCH] dma/swiotlb: Add helper for device driver to opt-out from swiotlb.
Date: Thu, 17 Sep 2015 14:22:38 -0400 [thread overview]
Message-ID: <1442514158-30281-1-git-send-email-jglisse@redhat.com> (raw)
From: Jérôme Glisse <jglisse@redhat.com>
The swiotlb dma backend is not appropriate for some devices like
GPU where bounce buffer or slow dma page allocations is just not
acceptable. With that helper device drivers can opt-out from the
swiotlb and just do sane things without wasting CPU cycles inside
the swiotlb code.
Signed-off-by: Jérôme Glisse <jglisse@redhat.com>
To: iommu@lists.linux-foundation.org
Cc: Joerg Roedel <jroedel@suse.de>
Cc: Konrad Rzeszutek Wilk <Konrad.wilk@oracle.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
CC: Dave Airlie <airlied@redhat.com>
CC: linux-kernel@vger.kernel.org
---
arch/x86/include/asm/dma-mapping.h | 3 +++
arch/x86/kernel/pci-swiotlb.c | 18 ++++++++++++++++++
include/asm-generic/dma-mapping-common.h | 7 +++++++
3 files changed, 28 insertions(+)
diff --git a/arch/x86/include/asm/dma-mapping.h b/arch/x86/include/asm/dma-mapping.h
index 953b726..b50745f 100644
--- a/arch/x86/include/asm/dma-mapping.h
+++ b/arch/x86/include/asm/dma-mapping.h
@@ -46,6 +46,9 @@ bool arch_dma_alloc_attrs(struct device **dev, gfp_t *gfp);
#define HAVE_ARCH_DMA_SUPPORTED 1
extern int dma_supported(struct device *hwdev, u64 mask);
+#define HAVE_ARCH_DMA_OVERRIDE_SWIOTLB 1
+int dma_override_swiotlb(struct device *dev);
+
#include <asm-generic/dma-mapping-common.h>
extern void *dma_generic_alloc_coherent(struct device *dev, size_t size,
diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
index adf0392..6a9efab 100644
--- a/arch/x86/kernel/pci-swiotlb.c
+++ b/arch/x86/kernel/pci-swiotlb.c
@@ -117,3 +117,21 @@ void __init pci_swiotlb_late_init(void)
swiotlb_print_info();
}
}
+
+/* dma_override_swiotlb() - Override swiotlb with nommu.
+ *
+ * @device: Device for which to disable swiotlb.
+ *
+ * The swiotlb infrastructure just get in the way for some devices like GPU,
+ * where things like bounce pages can not work properly or for which we do not
+ * want to take slow page allocation code path. This function allows device
+ * driver opportunity to opt-out from swiotlb.
+ */
+int dma_override_swiotlb(struct device *dev)
+{
+ if (dev->archdata.dma_ops != &swiotlb_dma_ops)
+ return 1;
+ dev->archdata.dma_ops = &nommu_dma_ops;
+ return 1;
+}
+EXPORT_SYMBOL(dma_override_swiotlb);
diff --git a/include/asm-generic/dma-mapping-common.h b/include/asm-generic/dma-mapping-common.h
index b1bc954..452d947 100644
--- a/include/asm-generic/dma-mapping-common.h
+++ b/include/asm-generic/dma-mapping-common.h
@@ -355,4 +355,11 @@ static inline int dma_set_mask(struct device *dev, u64 mask)
}
#endif
+#ifndef HAVE_ARCH_DMA_OVERRIDE_SWIOTLB
+static inline int dma_override_swiotlb(struct device *dev)
+{
+ return 0;
+}
+#endif
+
#endif
--
2.1.0
next reply other threads:[~2015-09-17 18:22 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-17 18:22 jglisse [this message]
2015-09-17 19:02 ` [RFC PATCH] dma/swiotlb: Add helper for device driver to opt-out from swiotlb Konrad Rzeszutek Wilk
2015-09-17 19:06 ` Konrad Rzeszutek Wilk
2015-09-17 19:11 ` Jerome Glisse
2015-09-17 19:24 ` Konrad Rzeszutek Wilk
2015-09-17 19:27 ` Jerome Glisse
2015-09-17 19:07 ` Jerome Glisse
2015-09-17 19:31 ` Konrad Rzeszutek Wilk
2015-09-17 19:40 ` Jerome Glisse
2015-09-22 15:43 ` Jerome Glisse
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=1442514158-30281-1-git-send-email-jglisse@redhat.com \
--to=jglisse@redhat.com \
--cc=Konrad.wilk@oracle.com \
--cc=airlied@redhat.com \
--cc=alexander.deucher@amd.com \
--cc=iommu@lists.linux-foundation.org \
--cc=jroedel@suse.de \
--cc=linux-kernel@vger.kernel.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).