Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7f46f9c1 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'iommu-fixes-v3.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu

Pull IOMMU fixes from Joerg Roedel:
 "These patches fix a couple of issues.  First of all a few problems
  with ACS on x86 introduced in the last merge window, where ACS did not
  work on AMD and a NULL pointer dereference when there ran against
  SR-IOV devices.

  The patches fallen out of coccinelle checks fix a possible invalid
  memory reference and a possible memory leak.  The other patches mostly
  fix build errors and warnings and a wrong return value."

* tag 'iommu-fixes-v3.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu:
  iommu/amd: Fix ACS path checking
  iommu/intel: Fix ACS path checking
  iommu/amd: Fix pci_request_acs() call-place
  iommu/exynos: Fix build error
  iommu/tegra: smmu: Fix error initial value at domain_init
  iommu/tegra: smmu: Cleanup with lesser nest
  iommu: Add missing forward declaration in include file
  iommu: Include linux/types.h
  iommu/intel: add missing free_domain_mem
  iommu/tegra: remove invalid reference to list iterator variable
parents 6666cabf 31fe9435
Loading
Loading
Loading
Loading
+22 −3
Original line number Diff line number Diff line
@@ -296,8 +296,13 @@ static int iommu_init_device(struct device *dev)
	} else
		dma_pdev = pci_dev_get(pdev);

	/* Account for quirked devices */
	swap_pci_ref(&dma_pdev, pci_get_dma_source(dma_pdev));

	/*
	 * If it's a multifunction device that does not support our
	 * required ACS flags, add to the same group as function 0.
	 */
	if (dma_pdev->multifunction &&
	    !pci_acs_enabled(dma_pdev, REQ_ACS_FLAGS))
		swap_pci_ref(&dma_pdev,
@@ -305,14 +310,28 @@ static int iommu_init_device(struct device *dev)
					  PCI_DEVFN(PCI_SLOT(dma_pdev->devfn),
					  0)));

	/*
	 * Devices on the root bus go through the iommu.  If that's not us,
	 * find the next upstream device and test ACS up to the root bus.
	 * Finding the next device may require skipping virtual buses.
	 */
	while (!pci_is_root_bus(dma_pdev->bus)) {
		if (pci_acs_path_enabled(dma_pdev->bus->self,
					 NULL, REQ_ACS_FLAGS))
		struct pci_bus *bus = dma_pdev->bus;

		while (!bus->self) {
			if (!pci_is_root_bus(bus))
				bus = bus->parent;
			else
				goto root_bus;
		}

		if (pci_acs_path_enabled(bus->self, NULL, REQ_ACS_FLAGS))
			break;

		swap_pci_ref(&dma_pdev, pci_dev_get(dma_pdev->bus->self));
		swap_pci_ref(&dma_pdev, pci_dev_get(bus->self));
	}

root_bus:
	group = iommu_group_get(&dma_pdev->dev);
	pci_dev_put(dma_pdev);
	if (!group) {
+3 −3
Original line number Diff line number Diff line
@@ -1131,9 +1131,6 @@ static int __init amd_iommu_init_pci(void)
			break;
	}

	/* Make sure ACS will be enabled */
	pci_request_acs();

	ret = amd_iommu_init_devices();

	print_iommu_info();
@@ -1652,6 +1649,9 @@ static bool detect_ivrs(void)

	early_acpi_os_unmap_memory((char __iomem *)ivrs_base, ivrs_size);

	/* Make sure ACS will be enabled during PCI probe */
	pci_request_acs();

	return true;
}

+3 −3
Original line number Diff line number Diff line
@@ -732,9 +732,9 @@ static int exynos_iommu_domain_init(struct iommu_domain *domain)
	spin_lock_init(&priv->pgtablelock);
	INIT_LIST_HEAD(&priv->clients);

	dom->geometry.aperture_start = 0;
	dom->geometry.aperture_end   = ~0UL;
	dom->geometry.force_aperture = true;
	domain->geometry.aperture_start = 0;
	domain->geometry.aperture_end   = ~0UL;
	domain->geometry.force_aperture = true;

	domain->priv = priv;
	return 0;
+23 −3
Original line number Diff line number Diff line
@@ -2008,6 +2008,7 @@ static struct dmar_domain *get_domain_for_dev(struct pci_dev *pdev, int gaw)
	if (!drhd) {
		printk(KERN_ERR "IOMMU: can't find DMAR for device %s\n",
			pci_name(pdev));
		free_domain_mem(domain);
		return NULL;
	}
	iommu = drhd->iommu;
@@ -4124,8 +4125,13 @@ static int intel_iommu_add_device(struct device *dev)
	} else
		dma_pdev = pci_dev_get(pdev);

	/* Account for quirked devices */
	swap_pci_ref(&dma_pdev, pci_get_dma_source(dma_pdev));

	/*
	 * If it's a multifunction device that does not support our
	 * required ACS flags, add to the same group as function 0.
	 */
	if (dma_pdev->multifunction &&
	    !pci_acs_enabled(dma_pdev, REQ_ACS_FLAGS))
		swap_pci_ref(&dma_pdev,
@@ -4133,14 +4139,28 @@ static int intel_iommu_add_device(struct device *dev)
					  PCI_DEVFN(PCI_SLOT(dma_pdev->devfn),
					  0)));

	/*
	 * Devices on the root bus go through the iommu.  If that's not us,
	 * find the next upstream device and test ACS up to the root bus.
	 * Finding the next device may require skipping virtual buses.
	 */
	while (!pci_is_root_bus(dma_pdev->bus)) {
		if (pci_acs_path_enabled(dma_pdev->bus->self,
					 NULL, REQ_ACS_FLAGS))
		struct pci_bus *bus = dma_pdev->bus;

		while (!bus->self) {
			if (!pci_is_root_bus(bus))
				bus = bus->parent;
			else
				goto root_bus;
		}

		if (pci_acs_path_enabled(bus->self, NULL, REQ_ACS_FLAGS))
			break;

		swap_pci_ref(&dma_pdev, pci_dev_get(dma_pdev->bus->self));
		swap_pci_ref(&dma_pdev, pci_dev_get(bus->self));
	}

root_bus:
	group = iommu_group_get(&dma_pdev->dev);
	pci_dev_put(dma_pdev);
	if (!group) {
+10 −7
Original line number Diff line number Diff line
@@ -799,14 +799,14 @@ static void smmu_iommu_detach_dev(struct iommu_domain *domain,
			goto out;
		}
	}
	dev_err(smmu->dev, "Couldn't find %s\n", dev_name(c->dev));
	dev_err(smmu->dev, "Couldn't find %s\n", dev_name(dev));
out:
	spin_unlock(&as->client_lock);
}

static int smmu_iommu_domain_init(struct iommu_domain *domain)
{
	int i, err = -ENODEV;
	int i, err = -EAGAIN;
	unsigned long flags;
	struct smmu_as *as;
	struct smmu_device *smmu = smmu_handle;
@@ -814,11 +814,14 @@ static int smmu_iommu_domain_init(struct iommu_domain *domain)
	/* Look for a free AS with lock held */
	for  (i = 0; i < smmu->num_as; i++) {
		as = &smmu->as[i];
		if (!as->pdir_page) {

		if (as->pdir_page)
			continue;

		err = alloc_pdir(as);
		if (!err)
			goto found;
		}

		if (err != -EAGAIN)
			break;
	}
Loading