]> xenbits.xensource.com Git - people/pauldu/linux.git/commitdiff
new module
authorPaul Durrant <paul.durrant@citrix.com>
Thu, 26 Jul 2018 07:45:30 +0000 (08:45 +0100)
committerPaul Durrant <paul.durrant@citrix.com>
Thu, 26 Jul 2018 13:07:17 +0000 (14:07 +0100)
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
arch/x86/xen/pci-swiotlb-xen.c
drivers/xen/Makefile
drivers/xen/pv-iommu-xen.c [new file with mode: 0644]
include/xen/pv-iommu-xen.h [new file with mode: 0644]

index 37c6056a7bba013e14386e69bed7cdf25faad510..4cf21a3399d4e9ee6df8aff5c162025d827ff7a9 100644 (file)
@@ -3,6 +3,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/pci.h>
 #include <xen/swiotlb-xen.h>
+#include <xen/pv-iommu-xen.h>
 
 #include <asm/xen/hypervisor.h>
 #include <xen/xen.h>
 #include <linux/export.h>
 
 int xen_swiotlb __read_mostly;
+int xen_pv_iommu __read_mostly;
+
+int __init pci_xen_pv_iommu_detect(void)
+{
+       xen_pv_iommu = xen_pv_iommu_detect();
+       
+       return xen_pv_iommu;
+}
+
+void __init pci_xen_pv_iommu_init(void)
+{
+       if (xen_pv_iommu) {
+               xen_pv_iommu_early_init();
+               dma_ops = &xen_pv_iommu_dma_ops;
+               
+#ifdef CONFIG_PCI
+               /* Make sure ACS will be enabled */
+               pci_request_acs();
+#endif
+       }
+}
+
+void __init pci_xen_pv_iommu_late_init(void)
+{
+       if (xen_pv_iommu)
+               xen_pv_iommu_late_init();
+}
+
+IOMMU_INIT_FINISH(pci_xen_pv_iommu_detect,
+                 NULL,
+                 pci_xen_pv_iommu_init,
+                 pci_xen_pv_iommu_late_init);
 
 /*
  * pci_xen_swiotlb_detect - set xen_swiotlb to 1 if necessary
@@ -89,6 +122,6 @@ int pci_xen_swiotlb_init_late(void)
 EXPORT_SYMBOL_GPL(pci_xen_swiotlb_init_late);
 
 IOMMU_INIT_FINISH(pci_xen_swiotlb_detect,
-                 NULL,
+                 pci_xen_pv_iommu_detect,
                  pci_xen_swiotlb_init,
                  NULL);
index 48b154276179f0269c7444e38d6717ac493a06d5..0309c89610b4b14642f262eea2c9c133b5a92780 100644 (file)
@@ -25,7 +25,7 @@ obj-$(CONFIG_XENFS)                   += xenfs/
 obj-$(CONFIG_XEN_SYS_HYPERVISOR)       += sys-hypervisor.o
 obj-$(CONFIG_XEN_PVHVM)                        += platform-pci.o
 obj-$(CONFIG_XEN_TMEM)                 += tmem.o
-obj-$(CONFIG_SWIOTLB_XEN)              += swiotlb-xen.o
+obj-$(CONFIG_SWIOTLB_XEN)              += swiotlb-xen.o pv-iommu-xen.o
 obj-$(CONFIG_XEN_MCE_LOG)              += mcelog.o
 obj-$(CONFIG_XEN_PCIDEV_BACKEND)       += xen-pciback/
 obj-$(CONFIG_XEN_PRIVCMD)              += xen-privcmd.o
diff --git a/drivers/xen/pv-iommu-xen.c b/drivers/xen/pv-iommu-xen.c
new file mode 100644 (file)
index 0000000..e28ed8a
--- /dev/null
@@ -0,0 +1,45 @@
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/slab.h>
+#include <linux/dma-mapping.h>
+#include <linux/kthread.h>
+
+#include <xen/swiotlb-xen.h>
+#include <xen/pv-iommu-xen.h>
+#include <xen/page.h>
+#include <xen/grant_table.h>
+
+#include <asm/xen/hypervisor.h>
+#include <asm/xen/hypercall.h>
+#include <asm/xen/page.h>
+#include <asm/xen/swiotlb-xen.h>
+#include <xen/xen.h>
+
+#include <trace/events/swiotlb.h>
+
+struct dma_map_ops xen_pv_iommu_dma_ops = {};
+
+int __init xen_pv_iommu_detect(void)
+{
+       xen_swiotlb = 1;
+       
+       return xen_swiotlb;
+}
+
+void __init xen_pv_iommu_early_init(void)
+{
+       pr_info("%s: ====>\n", __func__);
+
+       xen_swiotlb_init(1, true);
+       xen_pv_iommu_dma_ops = xen_swiotlb_dma_ops;
+
+       pr_info("%s: <====\n", __func__);
+}
+
+void __init xen_pv_iommu_late_init(void)
+{
+       pr_info("%s: <===>\n", __func__);
+}
+
+
diff --git a/include/xen/pv-iommu-xen.h b/include/xen/pv-iommu-xen.h
new file mode 100644 (file)
index 0000000..79788f2
--- /dev/null
@@ -0,0 +1,12 @@
+#ifndef __LINUX_PV_IOMMU_XEN_H
+#define __LINUX_PV_IOMMU_XEN_H
+
+#include <linux/swiotlb.h>
+
+int xen_pv_iommu_detect(void);
+void xen_pv_iommu_early_init(void);
+void xen_pv_iommu_late_init(void);
+
+extern struct dma_map_ops xen_pv_iommu_dma_ops;
+
+#endif /* __LINUX_PV_IOMMU_XEN_H */