mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joerg Roedel <joerg.roedel@amd.com>
To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
	iommu@lists.linux-foundation.org
Cc: David Woodhouse <dwmw2@infradead.org>,
	Muli Ben-Yehuda <muli@il.ibm.com>,
	Amit Shah <amit.shah@qumranet.com>,
	Ingo Molnar <mingo@redhat.com>,
	FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>,
	Joerg Roedel <joerg.roedel@amd.com>
Subject: [PATCH 4/9] x86/iommu: change SWIOTLB to use dma_ops register interface
Date: Mon, 22 Sep 2008 20:21:16 +0200	[thread overview]
Message-ID: <1222107681-8185-5-git-send-email-joerg.roedel@amd.com> (raw)
In-Reply-To: <1222107681-8185-1-git-send-email-joerg.roedel@amd.com>

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
 arch/x86/kernel/pci-dma.c        |    6 +++++-
 arch/x86/kernel/pci-swiotlb_64.c |   16 +++++++++++++++-
 include/asm-x86/swiotlb.h        |    1 +
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index c783b73..b990fb6 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -156,7 +156,7 @@ void __init pci_iommu_alloc(void)
 
 	amd_iommu_detect();
 
-	pci_swiotlb_init();
+	pci_swiotlb_detect();
 }
 
 unsigned long iommu_num_pages(unsigned long addr, unsigned long len)
@@ -296,6 +296,10 @@ static int __init pci_iommu_init(void)
 
 	gart_iommu_init();
 
+#ifdef CONFIG_X86_64
+	pci_swiotlb_init();
+#endif
+
 	no_iommu_init();
 	return 0;
 }
diff --git a/arch/x86/kernel/pci-swiotlb_64.c b/arch/x86/kernel/pci-swiotlb_64.c
index c4ce033..26747e0 100644
--- a/arch/x86/kernel/pci-swiotlb_64.c
+++ b/arch/x86/kernel/pci-swiotlb_64.c
@@ -18,6 +18,12 @@ swiotlb_map_single_phys(struct device *hwdev, phys_addr_t paddr, size_t size,
 	return swiotlb_map_single(hwdev, phys_to_virt(paddr), size, direction);
 }
 
+static int
+swiotlb_device_supported(struct device *hwdev)
+{
+	return 1;
+}
+
 struct dma_mapping_ops swiotlb_dma_ops = {
 	.mapping_error = swiotlb_dma_mapping_error,
 	.alloc_coherent = swiotlb_alloc_coherent,
@@ -33,9 +39,10 @@ struct dma_mapping_ops swiotlb_dma_ops = {
 	.map_sg = swiotlb_map_sg,
 	.unmap_sg = swiotlb_unmap_sg,
 	.dma_supported = NULL,
+	.device_supported = swiotlb_device_supported,
 };
 
-void __init pci_swiotlb_init(void)
+void __init pci_swiotlb_detect(void)
 {
 	/* don't initialize swiotlb if iommu=off (no_iommu=1) */
 	if (!iommu_detected && !no_iommu && max_pfn > MAX_DMA32_PFN)
@@ -45,6 +52,13 @@ void __init pci_swiotlb_init(void)
 	if (swiotlb) {
 		printk(KERN_INFO "PCI-DMA: Using software bounce buffering for IO (SWIOTLB)\n");
 		swiotlb_init();
+	}
+}
+
+void __init pci_swiotlb_init(void)
+{
+	if (swiotlb) {
+		x86_register_dma_ops(&swiotlb_dma_ops, DMA_OPS_TYPE_SOFT);
 		dma_ops = &swiotlb_dma_ops;
 	}
 }
diff --git a/include/asm-x86/swiotlb.h b/include/asm-x86/swiotlb.h
index 2730b35..20dfcb0 100644
--- a/include/asm-x86/swiotlb.h
+++ b/include/asm-x86/swiotlb.h
@@ -45,6 +45,7 @@ extern int swiotlb_force;
 
 #ifdef CONFIG_SWIOTLB
 extern int swiotlb;
+extern void pci_swiotlb_detect(void);
 extern void pci_swiotlb_init(void);
 #else
 #define swiotlb 0
-- 
1.5.6.4



  parent reply	other threads:[~2008-09-22 18:23 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-22 18:21 [PATCH 0/9][RFC] stackable dma_ops for x86 Joerg Roedel
2008-09-22 18:21 ` [PATCH 1/9] x86/iommu: add necessary types for stackable dma_ops Joerg Roedel
2008-09-22 18:21 ` [PATCH 2/9] x86/iommu: add stackable dma_ops registration interface Joerg Roedel
2008-09-22 18:21 ` [PATCH 3/9] x86/iommu: change PCI-NOMMU to use dma_ops register interface Joerg Roedel
2008-09-22 18:21 ` Joerg Roedel [this message]
2008-09-22 18:21 ` [PATCH 5/9] x86/iommu: change GART " Joerg Roedel
2008-09-22 18:21 ` [PATCH 6/9] x86/iommu: change Calgary " Joerg Roedel
2008-09-23 14:37   ` Muli Ben-Yehuda
2008-09-30 11:10   ` Ingo Molnar
2008-09-30 11:58     ` Joerg Roedel
2008-09-30 13:30     ` Muli Ben-Yehuda
2008-09-30 15:38       ` Ingo Molnar
2008-09-30 18:33         ` Muli Ben-Yehuda
2008-09-22 18:21 ` [PATCH 7/9] x86/iommu: change AMD IOMMU " Joerg Roedel
2008-09-22 18:21 ` [PATCH 8/9] x86/iommu: change Intel " Joerg Roedel
2008-09-22 18:21 ` [PATCH 9/9] x86/iommu: use dma_ops_list in get_dma_ops Joerg Roedel
2008-09-26  7:56   ` Amit Shah
2008-09-26  8:59     ` Joerg Roedel
2008-09-26 10:49       ` Amit Shah
2008-09-26 12:32         ` Joerg Roedel
2008-09-27  0:13           ` Muli Ben-Yehuda
2008-09-28 19:13             ` Joerg Roedel
2008-09-29  9:30               ` Muli Ben-Yehuda
2008-09-29  9:36                 ` Joerg Roedel
2008-09-29 13:16                   ` FUJITA Tomonori
2008-09-29 13:33                     ` Joerg Roedel
2008-09-30 19:44                       ` Muli Ben-Yehuda
2008-10-01  7:19                         ` Joerg Roedel
2008-10-03  8:38                           ` Muli Ben-Yehuda
2008-09-26 11:00     ` Joerg Roedel
2008-09-28 14:21   ` FUJITA Tomonori
2008-09-28 18:44     ` Joerg Roedel
2008-09-29  9:25       ` Muli Ben-Yehuda
2008-09-29  9:29         ` Joerg Roedel
2008-09-22 18:36 ` [PATCH 0/9][RFC] stackable dma_ops for x86 Arjan van de Ven
2008-09-22 18:39   ` Joerg Roedel
2008-09-23  2:41     ` Jeremy Fitzhardinge
2008-09-23  2:50       ` Arjan van de Ven
2008-09-28 14:21 ` FUJITA Tomonori
2008-09-28 18:49   ` Joerg Roedel
2008-09-29 13:16     ` FUJITA Tomonori
2008-09-29 13:26       ` Joerg Roedel
2008-09-29 13:42         ` FUJITA Tomonori
2008-09-29 13:51           ` Joerg Roedel

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=1222107681-8185-5-git-send-email-joerg.roedel@amd.com \
    --to=joerg.roedel@amd.com \
    --cc=amit.shah@qumranet.com \
    --cc=dwmw2@infradead.org \
    --cc=fujita.tomonori@lab.ntt.co.jp \
    --cc=iommu@lists.linux-foundation.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=muli@il.ibm.com \
    /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

all inboxes | Powered by JetHome®