Loading arch/x86/include/asm/amd_iommu_types.h +1 −1 Original line number Original line Diff line number Diff line Loading @@ -311,7 +311,7 @@ struct protection_domain { struct iommu_dev_data { struct iommu_dev_data { struct list_head list; /* For domain->dev_list */ struct list_head list; /* For domain->dev_list */ struct list_head dev_data_list; /* For global dev_data_list */ struct list_head dev_data_list; /* For global dev_data_list */ struct device *alias; /* The Alias Device */ struct iommu_dev_data *alias_data;/* The alias dev_data */ struct protection_domain *domain; /* Domain the device is bound to */ struct protection_domain *domain; /* Domain the device is bound to */ atomic_t bind; /* Domain attach reverent count */ atomic_t bind; /* Domain attach reverent count */ u16 devid; /* PCI Device ID */ u16 devid; /* PCI Device ID */ Loading arch/x86/kernel/amd_iommu.c +15 −19 Original line number Original line Diff line number Diff line Loading @@ -203,7 +203,6 @@ static bool check_device(struct device *dev) static int iommu_init_device(struct device *dev) static int iommu_init_device(struct device *dev) { { struct iommu_dev_data *dev_data; struct iommu_dev_data *dev_data; struct pci_dev *pdev; u16 alias; u16 alias; if (dev->archdata.iommu) if (dev->archdata.iommu) Loading @@ -215,13 +214,16 @@ static int iommu_init_device(struct device *dev) alias = amd_iommu_alias_table[dev_data->devid]; alias = amd_iommu_alias_table[dev_data->devid]; if (alias != dev_data->devid) { if (alias != dev_data->devid) { pdev = pci_get_bus_and_slot(PCI_BUS(alias), alias & 0xff); struct iommu_dev_data *alias_data; if (pdev) dev_data->alias = &pdev->dev; alias_data = find_dev_data(alias); else { if (alias_data == NULL) { pr_err("AMD-Vi: Warning: Unhandled device %s\n", dev_name(dev)); free_dev_data(dev_data); free_dev_data(dev_data); return -ENOTSUPP; return -ENOTSUPP; } } dev_data->alias_data = alias_data; } } dev->archdata.iommu = dev_data; dev->archdata.iommu = dev_data; Loading Loading @@ -1642,14 +1644,8 @@ static int __attach_device(struct iommu_dev_data *dev_data, /* lock domain */ /* lock domain */ spin_lock(&domain->lock); spin_lock(&domain->lock); if (dev_data->alias != NULL) { if (dev_data->alias_data != NULL) { struct iommu_dev_data *alias_data; struct iommu_dev_data *alias_data = dev_data->alias_data; alias_data = get_dev_data(dev_data->alias); ret = -EINVAL; if (!alias_data) goto out_unlock; /* Some sanity checks */ /* Some sanity checks */ ret = -EBUSY; ret = -EBUSY; Loading Loading @@ -1721,7 +1717,6 @@ static int attach_device(struct device *dev, */ */ static void __detach_device(struct iommu_dev_data *dev_data) static void __detach_device(struct iommu_dev_data *dev_data) { { struct iommu_dev_data *alias_data; struct protection_domain *domain; struct protection_domain *domain; unsigned long flags; unsigned long flags; Loading @@ -1731,8 +1726,9 @@ static void __detach_device(struct iommu_dev_data *dev_data) spin_lock_irqsave(&domain->lock, flags); spin_lock_irqsave(&domain->lock, flags); if (dev_data->alias) { if (dev_data->alias_data != NULL) { alias_data = get_dev_data(dev_data->alias); struct iommu_dev_data *alias_data = dev_data->alias_data; if (atomic_dec_and_test(&alias_data->bind)) if (atomic_dec_and_test(&alias_data->bind)) do_detach(alias_data); do_detach(alias_data); } } Loading Loading @@ -1779,7 +1775,7 @@ static void detach_device(struct device *dev) */ */ static struct protection_domain *domain_for_device(struct device *dev) static struct protection_domain *domain_for_device(struct device *dev) { { struct iommu_dev_data *dev_data, *alias_data; struct iommu_dev_data *dev_data; struct protection_domain *dom = NULL; struct protection_domain *dom = NULL; unsigned long flags; unsigned long flags; Loading @@ -1788,8 +1784,8 @@ static struct protection_domain *domain_for_device(struct device *dev) if (dev_data->domain) if (dev_data->domain) return dev_data->domain; return dev_data->domain; if (dev_data->alias != NULL) { if (dev_data->alias_data != NULL) { alias_data = get_dev_data(dev_data->alias); struct iommu_dev_data *alias_data = dev_data->alias_data; read_lock_irqsave(&amd_iommu_devtable_lock, flags); read_lock_irqsave(&amd_iommu_devtable_lock, flags); if (alias_data->domain != NULL) { if (alias_data->domain != NULL) { Loading Loading
arch/x86/include/asm/amd_iommu_types.h +1 −1 Original line number Original line Diff line number Diff line Loading @@ -311,7 +311,7 @@ struct protection_domain { struct iommu_dev_data { struct iommu_dev_data { struct list_head list; /* For domain->dev_list */ struct list_head list; /* For domain->dev_list */ struct list_head dev_data_list; /* For global dev_data_list */ struct list_head dev_data_list; /* For global dev_data_list */ struct device *alias; /* The Alias Device */ struct iommu_dev_data *alias_data;/* The alias dev_data */ struct protection_domain *domain; /* Domain the device is bound to */ struct protection_domain *domain; /* Domain the device is bound to */ atomic_t bind; /* Domain attach reverent count */ atomic_t bind; /* Domain attach reverent count */ u16 devid; /* PCI Device ID */ u16 devid; /* PCI Device ID */ Loading
arch/x86/kernel/amd_iommu.c +15 −19 Original line number Original line Diff line number Diff line Loading @@ -203,7 +203,6 @@ static bool check_device(struct device *dev) static int iommu_init_device(struct device *dev) static int iommu_init_device(struct device *dev) { { struct iommu_dev_data *dev_data; struct iommu_dev_data *dev_data; struct pci_dev *pdev; u16 alias; u16 alias; if (dev->archdata.iommu) if (dev->archdata.iommu) Loading @@ -215,13 +214,16 @@ static int iommu_init_device(struct device *dev) alias = amd_iommu_alias_table[dev_data->devid]; alias = amd_iommu_alias_table[dev_data->devid]; if (alias != dev_data->devid) { if (alias != dev_data->devid) { pdev = pci_get_bus_and_slot(PCI_BUS(alias), alias & 0xff); struct iommu_dev_data *alias_data; if (pdev) dev_data->alias = &pdev->dev; alias_data = find_dev_data(alias); else { if (alias_data == NULL) { pr_err("AMD-Vi: Warning: Unhandled device %s\n", dev_name(dev)); free_dev_data(dev_data); free_dev_data(dev_data); return -ENOTSUPP; return -ENOTSUPP; } } dev_data->alias_data = alias_data; } } dev->archdata.iommu = dev_data; dev->archdata.iommu = dev_data; Loading Loading @@ -1642,14 +1644,8 @@ static int __attach_device(struct iommu_dev_data *dev_data, /* lock domain */ /* lock domain */ spin_lock(&domain->lock); spin_lock(&domain->lock); if (dev_data->alias != NULL) { if (dev_data->alias_data != NULL) { struct iommu_dev_data *alias_data; struct iommu_dev_data *alias_data = dev_data->alias_data; alias_data = get_dev_data(dev_data->alias); ret = -EINVAL; if (!alias_data) goto out_unlock; /* Some sanity checks */ /* Some sanity checks */ ret = -EBUSY; ret = -EBUSY; Loading Loading @@ -1721,7 +1717,6 @@ static int attach_device(struct device *dev, */ */ static void __detach_device(struct iommu_dev_data *dev_data) static void __detach_device(struct iommu_dev_data *dev_data) { { struct iommu_dev_data *alias_data; struct protection_domain *domain; struct protection_domain *domain; unsigned long flags; unsigned long flags; Loading @@ -1731,8 +1726,9 @@ static void __detach_device(struct iommu_dev_data *dev_data) spin_lock_irqsave(&domain->lock, flags); spin_lock_irqsave(&domain->lock, flags); if (dev_data->alias) { if (dev_data->alias_data != NULL) { alias_data = get_dev_data(dev_data->alias); struct iommu_dev_data *alias_data = dev_data->alias_data; if (atomic_dec_and_test(&alias_data->bind)) if (atomic_dec_and_test(&alias_data->bind)) do_detach(alias_data); do_detach(alias_data); } } Loading Loading @@ -1779,7 +1775,7 @@ static void detach_device(struct device *dev) */ */ static struct protection_domain *domain_for_device(struct device *dev) static struct protection_domain *domain_for_device(struct device *dev) { { struct iommu_dev_data *dev_data, *alias_data; struct iommu_dev_data *dev_data; struct protection_domain *dom = NULL; struct protection_domain *dom = NULL; unsigned long flags; unsigned long flags; Loading @@ -1788,8 +1784,8 @@ static struct protection_domain *domain_for_device(struct device *dev) if (dev_data->domain) if (dev_data->domain) return dev_data->domain; return dev_data->domain; if (dev_data->alias != NULL) { if (dev_data->alias_data != NULL) { alias_data = get_dev_data(dev_data->alias); struct iommu_dev_data *alias_data = dev_data->alias_data; read_lock_irqsave(&amd_iommu_devtable_lock, flags); read_lock_irqsave(&amd_iommu_devtable_lock, flags); if (alias_data->domain != NULL) { if (alias_data->domain != NULL) { Loading