lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1222107681-8185-3-git-send-email-joerg.roedel@amd.com>
Date:	Mon, 22 Sep 2008 20:21:14 +0200
From:	Joerg Roedel <joerg.roedel@....com>
To:	linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
	iommu@...ts.linux-foundation.org
CC:	David Woodhouse <dwmw2@...radead.org>,
	Muli Ben-Yehuda <muli@...ibm.com>,
	Amit Shah <amit.shah@...ranet.com>,
	Ingo Molnar <mingo@...hat.com>,
	FUJITA Tomonori <fujita.tomonori@....ntt.co.jp>,
	Joerg Roedel <joerg.roedel@....com>
Subject: [PATCH 2/9] x86/iommu: add stackable dma_ops registration interface

This patch adds the function x86_register_dma_ops which drivers can use
to register their specific dma_ops implementations. The patch also adds
the data structures necessary for registration and the initializtion of
them.

Signed-off-by: Joerg Roedel <joerg.roedel@....com>
---
 arch/x86/kernel/pci-dma.c     |   31 +++++++++++++++++++++++++++++++
 include/asm-x86/dma-mapping.h |    3 +++
 2 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index d2f2c01..c783b73 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -47,6 +47,11 @@ EXPORT_SYMBOL(iommu_bio_merge);
 dma_addr_t bad_dma_address __read_mostly = 0;
 EXPORT_SYMBOL(bad_dma_address);
 
+/* The lists for stacking dma_ops and its lock */
+static DEFINE_RWLOCK(dma_ops_list_lock);
+
+static struct list_head dma_ops_list[DMA_OPS_TYPE_MAX];
+
 /* Dummy device used for NULL arguments (normally ISA). Better would
    be probably a smaller DMA mask, but this is bug-to-bug compatible
    to older i386. */
@@ -57,6 +62,26 @@ struct device x86_dma_fallback_dev = {
 };
 EXPORT_SYMBOL(x86_dma_fallback_dev);
 
+static void __init init_dma_ops_list(void)
+{
+	int i;
+
+	for (i = 0; i < DMA_OPS_TYPE_MAX; ++i)
+		INIT_LIST_HEAD(&dma_ops_list[i]);
+}
+
+void x86_register_dma_ops(struct dma_mapping_ops *ops,
+			  enum dma_ops_driver_type type)
+{
+	unsigned long flags;
+
+	BUG_ON(type < DMA_OPS_TYPE_PV || type >= DMA_OPS_TYPE_MAX);
+
+	write_lock_irqsave(&dma_ops_list_lock, flags);
+	list_add_tail(&ops->list, &dma_ops_list[type]);
+	write_unlock_irqrestore(&dma_ops_list_lock, flags);
+}
+
 int dma_set_mask(struct device *dev, u64 mask)
 {
 	if (!dev->dma_mask || !dma_supported(dev, mask))
@@ -257,6 +282,12 @@ EXPORT_SYMBOL(dma_supported);
 
 static int __init pci_iommu_init(void)
 {
+	/*
+	 * initialize dma_ops_list so that drivers can register their
+	 * implementations
+	 */
+	init_dma_ops_list();
+
 	calgary_iommu_init();
 
 	intel_iommu_init();
diff --git a/include/asm-x86/dma-mapping.h b/include/asm-x86/dma-mapping.h
index 59d1101..128786b 100644
--- a/include/asm-x86/dma-mapping.h
+++ b/include/asm-x86/dma-mapping.h
@@ -80,6 +80,9 @@ enum dma_ops_driver_type {
 	DMA_OPS_TYPE_MAX,
 };
 
+extern void x86_register_dma_ops(struct dma_mapping_ops *ops,
+				 enum dma_ops_driver_type type);
+
 extern struct dma_mapping_ops *dma_ops;
 
 static inline struct dma_mapping_ops *get_dma_ops(struct device *dev)
-- 
1.5.6.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ