aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iommu
diff options
context:
space:
mode:
authorJoerg Roedel <jroedel@suse.de>2015-10-20 11:33:39 -0400
committerJoerg Roedel <jroedel@suse.de>2015-10-21 05:30:32 -0400
commit61289cbaf6c854a493ad0fa405c3dd39e7a384f3 (patch)
tree394e62a647f6618dc75264d14a3e3625c91ccd9c /drivers/iommu
parente25bfb56ea7f046b71414e02f80f620deb5c6362 (diff)
iommu/amd: Remove old alias handling code
This mostly removes the code to create dev_data structures for alias device ids. They are not necessary anymore, as they were only created for device ids which have no struct pci_dev associated with it. But these device ids are handled in a simpler way now, so there is no need for this code anymore. Signed-off-by: Joerg Roedel <jroedel@suse.de>
Diffstat (limited to 'drivers/iommu')
-rw-r--r--drivers/iommu/amd_iommu.c99
1 files changed, 0 insertions, 99 deletions
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index 68b8ecf075ca..fe112bbaae88 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -89,8 +89,6 @@ static struct dma_map_ops amd_iommu_dma_ops;
89struct iommu_dev_data { 89struct iommu_dev_data {
90 struct list_head list; /* For domain->dev_list */ 90 struct list_head list; /* For domain->dev_list */
91 struct list_head dev_data_list; /* For global dev_data_list */ 91 struct list_head dev_data_list; /* For global dev_data_list */
92 struct list_head alias_list; /* Link alias-groups together */
93 struct iommu_dev_data *alias_data;/* The alias dev_data */
94 struct protection_domain *domain; /* Domain the device is bound to */ 92 struct protection_domain *domain; /* Domain the device is bound to */
95 u16 devid; /* PCI Device ID */ 93 u16 devid; /* PCI Device ID */
96 bool iommu_v2; /* Device can make use of IOMMUv2 */ 94 bool iommu_v2; /* Device can make use of IOMMUv2 */
@@ -136,8 +134,6 @@ static struct iommu_dev_data *alloc_dev_data(u16 devid)
136 if (!dev_data) 134 if (!dev_data)
137 return NULL; 135 return NULL;
138 136
139 INIT_LIST_HEAD(&dev_data->alias_list);
140
141 dev_data->devid = devid; 137 dev_data->devid = devid;
142 138
143 spin_lock_irqsave(&dev_data_list_lock, flags); 139 spin_lock_irqsave(&dev_data_list_lock, flags);
@@ -147,17 +143,6 @@ static struct iommu_dev_data *alloc_dev_data(u16 devid)
147 return dev_data; 143 return dev_data;
148} 144}
149 145
150static void free_dev_data(struct iommu_dev_data *dev_data)
151{
152 unsigned long flags;
153
154 spin_lock_irqsave(&dev_data_list_lock, flags);
155 list_del(&dev_data->dev_data_list);
156 spin_unlock_irqrestore(&dev_data_list_lock, flags);
157
158 kfree(dev_data);
159}
160
161static struct iommu_dev_data *search_dev_data(u16 devid) 146static struct iommu_dev_data *search_dev_data(u16 devid)
162{ 147{
163 struct iommu_dev_data *dev_data; 148 struct iommu_dev_data *dev_data;
@@ -311,73 +296,10 @@ out:
311 iommu_group_put(group); 296 iommu_group_put(group);
312} 297}
313 298
314static int __last_alias(struct pci_dev *pdev, u16 alias, void *data)
315{
316 *(u16 *)data = alias;
317 return 0;
318}
319
320static u16 get_alias(struct device *dev)
321{
322 struct pci_dev *pdev = to_pci_dev(dev);
323 u16 devid, ivrs_alias, pci_alias;
324
325 devid = get_device_id(dev);
326 ivrs_alias = amd_iommu_alias_table[devid];
327 pci_for_each_dma_alias(pdev, __last_alias, &pci_alias);
328
329 if (ivrs_alias == pci_alias)
330 return ivrs_alias;
331
332 /*
333 * DMA alias showdown
334 *
335 * The IVRS is fairly reliable in telling us about aliases, but it
336 * can't know about every screwy device. If we don't have an IVRS
337 * reported alias, use the PCI reported alias. In that case we may
338 * still need to initialize the rlookup and dev_table entries if the
339 * alias is to a non-existent device.
340 */
341 if (ivrs_alias == devid) {
342 if (!amd_iommu_rlookup_table[pci_alias]) {
343 amd_iommu_rlookup_table[pci_alias] =
344 amd_iommu_rlookup_table[devid];
345 memcpy(amd_iommu_dev_table[pci_alias].data,
346 amd_iommu_dev_table[devid].data,
347 sizeof(amd_iommu_dev_table[pci_alias].data));
348 }
349
350 return pci_alias;
351 }
352
353 pr_info("AMD-Vi: Using IVRS reported alias %02x:%02x.%d "
354 "for device %s[%04x:%04x], kernel reported alias "
355 "%02x:%02x.%d\n", PCI_BUS_NUM(ivrs_alias), PCI_SLOT(ivrs_alias),
356 PCI_FUNC(ivrs_alias), dev_name(dev), pdev->vendor, pdev->device,
357 PCI_BUS_NUM(pci_alias), PCI_SLOT(pci_alias),
358 PCI_FUNC(pci_alias));
359
360 /*
361 * If we don't have a PCI DMA alias and the IVRS alias is on the same
362 * bus, then the IVRS table may know about a quirk that we don't.
363 */
364 if (pci_alias == devid &&
365 PCI_BUS_NUM(ivrs_alias) == pdev->bus->number) {
366 pdev->dev_flags |= PCI_DEV_FLAGS_DMA_ALIAS_DEVFN;
367 pdev->dma_alias_devfn = ivrs_alias & 0xff;
368 pr_info("AMD-Vi: Added PCI DMA alias %02x.%d for %s\n",
369 PCI_SLOT(ivrs_alias), PCI_FUNC(ivrs_alias),
370 dev_name(dev));
371 }
372
373 return ivrs_alias;
374}
375
376static int iommu_init_device(struct device *dev) 299static int iommu_init_device(struct device *dev)
377{ 300{
378 struct pci_dev *pdev = to_pci_dev(dev); 301 struct pci_dev *pdev = to_pci_dev(dev);
379 struct iommu_dev_data *dev_data; 302 struct iommu_dev_data *dev_data;
380 u16 alias;
381 303
382 if (dev->archdata.iommu) 304 if (dev->archdata.iommu)
383 return 0; 305 return 0;
@@ -386,24 +308,6 @@ static int iommu_init_device(struct device *dev)
386 if (!dev_data) 308 if (!dev_data)
387 return -ENOMEM; 309 return -ENOMEM;
388 310
389 alias = get_alias(dev);
390
391 if (alias != dev_data->devid) {
392 struct iommu_dev_data *alias_data;
393
394 alias_data = find_dev_data(alias);
395 if (alias_data == NULL) {
396 pr_err("AMD-Vi: Warning: Unhandled device %s\n",
397 dev_name(dev));
398 free_dev_data(dev_data);
399 return -ENOTSUPP;
400 }
401 dev_data->alias_data = alias_data;
402
403 /* Add device to the alias_list */
404 list_add(&dev_data->alias_list, &alias_data->alias_list);
405 }
406
407 if (pci_iommuv2_capable(pdev)) { 311 if (pci_iommuv2_capable(pdev)) {
408 struct amd_iommu *iommu; 312 struct amd_iommu *iommu;
409 313
@@ -445,9 +349,6 @@ static void iommu_uninit_device(struct device *dev)
445 349
446 iommu_group_remove_device(dev); 350 iommu_group_remove_device(dev);
447 351
448 /* Unlink from alias, it may change if another device is re-plugged */
449 dev_data->alias_data = NULL;
450
451 /* Remove dma-ops */ 352 /* Remove dma-ops */
452 dev->archdata.dma_ops = NULL; 353 dev->archdata.dma_ops = NULL;
453 354