Skip to content

Commit

Permalink
Merge tag 'iommu-fixes-v3.6-rc1' of git://git.kernel.org/pub/scm/linu…
Browse files Browse the repository at this point in the history
…x/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
  • Loading branch information
torvalds committed Aug 8, 2012
2 parents 6666cab + 31fe943 commit 7f46f9c
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 19 deletions.
25 changes: 22 additions & 3 deletions drivers/iommu/amd_iommu.c
Expand Up @@ -296,23 +296,42 @@ 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,
pci_get_slot(dma_pdev->bus,
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) {
Expand Down
6 changes: 3 additions & 3 deletions drivers/iommu/amd_iommu_init.c
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}

Expand Down
6 changes: 3 additions & 3 deletions drivers/iommu/exynos-iommu.c
Expand Up @@ -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;
Expand Down
26 changes: 23 additions & 3 deletions drivers/iommu/intel-iommu.c
Expand Up @@ -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;
Expand Down Expand Up @@ -4124,23 +4125,42 @@ 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,
pci_get_slot(dma_pdev->bus,
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) {
Expand Down
17 changes: 10 additions & 7 deletions drivers/iommu/tegra-smmu.c
Expand Up @@ -799,26 +799,29 @@ 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;

/* Look for a free AS with lock held */
for (i = 0; i < smmu->num_as; i++) {
as = &smmu->as[i];
if (!as->pdir_page) {
err = alloc_pdir(as);
if (!err)
goto found;
}

if (as->pdir_page)
continue;

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

if (err != -EAGAIN)
break;
}
Expand Down
2 changes: 2 additions & 0 deletions include/linux/iommu.h
Expand Up @@ -20,6 +20,7 @@
#define __LINUX_IOMMU_H

#include <linux/errno.h>
#include <linux/types.h>

#define IOMMU_READ (1)
#define IOMMU_WRITE (2)
Expand All @@ -30,6 +31,7 @@ struct iommu_group;
struct bus_type;
struct device;
struct iommu_domain;
struct notifier_block;

/* iommu fault flags */
#define IOMMU_FAULT_READ 0x0
Expand Down

0 comments on commit 7f46f9c

Please sign in to comment.