aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlias Apalodimas <ilias.apalodimas@linaro.org>2017-10-06 14:09:16 +0300
committerIlias Apalodimas <ilias.apalodimas@linaro.org>2017-10-06 14:09:16 +0300
commita0eff9d76ccb514cbc476f68bb1a586a2312398c (patch)
tree6e2ec7c01cf5f9bdc8636f6ee70fa94111596f8d
parent5798d785e263d18d62c1e698551a7bc932addca8 (diff)
added patch for 4.10.x kernels
-rw-r--r--linux-4.10.17.patch182
-rw-r--r--vfio-iommu-map-unmap.c3
2 files changed, 184 insertions, 1 deletions
diff --git a/linux-4.10.17.patch b/linux-4.10.17.patch
new file mode 100644
index 0000000..eaa5618
--- /dev/null
+++ b/linux-4.10.17.patch
@@ -0,0 +1,182 @@
+--- a/drivers/iommu/iommu.c 2017-09-13 12:02:08.000000000 +0300
++++ b/drivers/iommu/iommu.c 2017-10-06 03:11:53.253065551 +0300
+@@ -1243,12 +1243,16 @@
+ {
+ struct iommu_domain *domain;
+
+- if (bus == NULL || bus->iommu_ops == NULL)
++ if (bus == NULL || bus->iommu_ops == NULL) {
++ printk("%s %d\n", __FILE__, __LINE__);
+ return NULL;
++ }
+
+ domain = bus->iommu_ops->domain_alloc(type);
+- if (!domain)
++ if (!domain) {
++ printk("%s %d\n", __FILE__, __LINE__);
+ return NULL;
++ }
+
+ domain->ops = bus->iommu_ops;
+ domain->type = type;
+@@ -1274,12 +1278,16 @@
+ struct device *dev)
+ {
+ int ret;
+- if (unlikely(domain->ops->attach_dev == NULL))
++ if (unlikely(domain->ops->attach_dev == NULL)) {
++ printk("%s %d\n", __FILE__, __LINE__);
+ return -ENODEV;
++ }
+
+ ret = domain->ops->attach_dev(domain, dev);
+- if (!ret)
++ if (!ret) {
+ trace_attach_device_to_domain(dev);
++ }
++
+ return ret;
+ }
+
+@@ -1385,8 +1393,10 @@
+ {
+ int ret;
+
+- if (group->default_domain && group->domain != group->default_domain)
++ if (group->default_domain && group->domain != group->default_domain) {
++ printk("%s %d\n", __FILE__, __LINE__);
+ return -EBUSY;
++ }
+
+ ret = __iommu_group_for_each_dev(group, domain,
+ iommu_group_do_attach_device);
+--- a/drivers/vfio/vfio_iommu_type1.c 2017-09-13 12:02:08.000000000 +0300
++++ b/drivers/vfio/vfio_iommu_type1.c 2017-10-06 13:45:21.441068304 +0300
+@@ -1030,11 +1030,13 @@
+ /* Insert zero-sized and grow as we map chunks of it */
+ vfio_link_dma(iommu, dma);
+
+- /* Don't pin and map if container doesn't contain IOMMU capable domain*/
+- if (!IS_IOMMU_CAP_DOMAIN_IN_CONTAINER(iommu))
++ /* Don't pin and map if container doesn't contain IOMMU capable domain */
++ if (!IS_IOMMU_CAP_DOMAIN_IN_CONTAINER(iommu)) {
++ printk("%s %d\n", __FILE__, __LINE__);
+ dma->size = size;
+- else
++ } else {
+ ret = vfio_pin_map_dma(iommu, dma, size);
++ }
+
+ out_unlock:
+ mutex_unlock(&iommu->lock);
+@@ -1257,6 +1259,7 @@
+
+ domain->domain = iommu_domain_alloc(bus);
+ if (!domain->domain) {
++ //printk("%s %d\n", __FILE__, __LINE__);
+ ret = -EIO;
+ goto out_free;
+ }
+@@ -1266,13 +1269,17 @@
+
+ ret = iommu_domain_set_attr(domain->domain, DOMAIN_ATTR_NESTING,
+ &attr);
+- if (ret)
++ if (ret) {
++ //printk("%s %d\n", __FILE__, __LINE__);
+ goto out_domain;
++ }
+ }
+
+ ret = iommu_attach_group(domain->domain, iommu_group);
+- if (ret)
++ if (ret) {
++ //printk("%s %d\n", __FILE__, __LINE__);
+ goto out_domain;
++ }
+
+ resv_msi = vfio_iommu_has_resv_msi(iommu_group, &resv_msi_base);
+
+@@ -1283,6 +1290,7 @@
+ iommu_capable(bus, IOMMU_CAP_INTR_REMAP);
+
+ if (!allow_unsafe_interrupts && !msi_remap) {
++ //printk("%s %d\n", __FILE__, __LINE__);
+ pr_warn("%s: No interrupt remapping support. Use the module param \"allow_unsafe_interrupts\" to enable VFIO IOMMU support on this platform\n",
+ __func__);
+ ret = -EPERM;
+@@ -1308,12 +1316,15 @@
+ iommu_domain_free(domain->domain);
+ kfree(domain);
+ mutex_unlock(&iommu->lock);
++ //printk("%s %d\n", __FILE__, __LINE__);
+ return 0;
+ }
+
+ ret = iommu_attach_group(domain->domain, iommu_group);
+- if (ret)
++ if (ret) {
++ //printk("%s %d\n", __FILE__, __LINE__);
+ goto out_domain;
++ }
+ }
+ }
+
+@@ -1334,10 +1345,13 @@
+ return 0;
+
+ out_detach:
++ printk("%s %d\n", __FILE__, __LINE__);
+ iommu_detach_group(domain->domain, iommu_group);
+ out_domain:
++ printk("%s %d\n", __FILE__, __LINE__);
+ iommu_domain_free(domain->domain);
+ out_free:
++ printk("%s %d\n", __FILE__, __LINE__);
+ kfree(domain);
+ kfree(group);
+ mutex_unlock(&iommu->lock);
+--- a/drivers/iommu/intel-iommu.c 2017-10-06 02:30:16.130952639 +0300
++++ b/drivers/iommu/intel-iommu.c 2017-10-06 13:44:39.689608720 +0300
+@@ -49,6 +49,7 @@
+ #include <asm/irq_remapping.h>
+ #include <asm/cacheflush.h>
+ #include <asm/iommu.h>
++#include <linux/mdev.h>
+
+ #include "irq_remapping.h"
+
+@@ -892,6 +893,20 @@
+ if (iommu_dummy(dev))
+ return NULL;
+
++ /*
++ * Linaro convert mdev to their parent pci device
++ * XXX FIXME dev_is_mdev should be used here instead of hacks
++ */
++ if (dev->driver && dev->driver->name &&
++ !strcmp(dev->driver->name, "vfio_mdev")) {
++ //printk("mdev %s to", dev_name(dev));
++ /* Should always exist */
++ if (dev->parent && dev->parent->parent &&
++ dev->parent->parent->parent)
++ dev = dev->parent->parent->parent;
++ //printk("pci dev %s\n", dev_name(dev));
++ }
++
+ if (dev_is_pci(dev)) {
+ struct pci_dev *pf_pdev;
+
+@@ -901,8 +916,11 @@
+ pf_pdev = pci_physfn(pdev);
+ dev = &pf_pdev->dev;
+ segment = pci_domain_nr(pdev->bus);
+- } else if (has_acpi_companion(dev))
++ //printk("pci dev %s\n", dev_name(dev));
++ } else if (has_acpi_companion(dev)) {
+ dev = &ACPI_COMPANION(dev)->dev;
++ //printk("ACPI dev %s\n", dev_name(dev));
++ }
+
+ rcu_read_lock();
+ for_each_active_iommu(iommu, drhd) {
diff --git a/vfio-iommu-map-unmap.c b/vfio-iommu-map-unmap.c
index a5d5c46..da88e40 100644
--- a/vfio-iommu-map-unmap.c
+++ b/vfio-iommu-map-unmap.c
@@ -13,7 +13,8 @@
#include <linux/ioctl.h>
#include <linux/vfio.h>
-#define MAP_SIZE (1UL * 1024 * 1024 * 1024)
+#define MAP_SIZE (1UL * 8 * 1024)
+//#define MAP_SIZE (1UL * 1024 * 1024 * 1024)
#define MAP_CHUNK (4 * 1024)
#define REALLOC_INTERVAL 30