aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iommu
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/iommu')
-rw-r--r--drivers/iommu/amd_iommu.c14
-rw-r--r--drivers/iommu/amd_iommu_init.c40
-rw-r--r--drivers/iommu/amd_iommu_types.h11
3 files changed, 28 insertions, 37 deletions
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index 1d84be17ff21..21d02b0d907c 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -174,7 +174,7 @@ static inline u16 get_device_id(struct device *dev)
174{ 174{
175 struct pci_dev *pdev = to_pci_dev(dev); 175 struct pci_dev *pdev = to_pci_dev(dev);
176 176
177 return calc_devid(pdev->bus->number, pdev->devfn); 177 return PCI_DEVID(pdev->bus->number, pdev->devfn);
178} 178}
179 179
180static struct iommu_dev_data *get_dev_data(struct device *dev) 180static struct iommu_dev_data *get_dev_data(struct device *dev)
@@ -644,26 +644,26 @@ retry:
644 case EVENT_TYPE_ILL_DEV: 644 case EVENT_TYPE_ILL_DEV:
645 printk("ILLEGAL_DEV_TABLE_ENTRY device=%02x:%02x.%x " 645 printk("ILLEGAL_DEV_TABLE_ENTRY device=%02x:%02x.%x "
646 "address=0x%016llx flags=0x%04x]\n", 646 "address=0x%016llx flags=0x%04x]\n",
647 PCI_BUS(devid), PCI_SLOT(devid), PCI_FUNC(devid), 647 PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
648 address, flags); 648 address, flags);
649 dump_dte_entry(devid); 649 dump_dte_entry(devid);
650 break; 650 break;
651 case EVENT_TYPE_IO_FAULT: 651 case EVENT_TYPE_IO_FAULT:
652 printk("IO_PAGE_FAULT device=%02x:%02x.%x " 652 printk("IO_PAGE_FAULT device=%02x:%02x.%x "
653 "domain=0x%04x address=0x%016llx flags=0x%04x]\n", 653 "domain=0x%04x address=0x%016llx flags=0x%04x]\n",
654 PCI_BUS(devid), PCI_SLOT(devid), PCI_FUNC(devid), 654 PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
655 domid, address, flags); 655 domid, address, flags);
656 break; 656 break;
657 case EVENT_TYPE_DEV_TAB_ERR: 657 case EVENT_TYPE_DEV_TAB_ERR:
658 printk("DEV_TAB_HARDWARE_ERROR device=%02x:%02x.%x " 658 printk("DEV_TAB_HARDWARE_ERROR device=%02x:%02x.%x "
659 "address=0x%016llx flags=0x%04x]\n", 659 "address=0x%016llx flags=0x%04x]\n",
660 PCI_BUS(devid), PCI_SLOT(devid), PCI_FUNC(devid), 660 PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
661 address, flags); 661 address, flags);
662 break; 662 break;
663 case EVENT_TYPE_PAGE_TAB_ERR: 663 case EVENT_TYPE_PAGE_TAB_ERR:
664 printk("PAGE_TAB_HARDWARE_ERROR device=%02x:%02x.%x " 664 printk("PAGE_TAB_HARDWARE_ERROR device=%02x:%02x.%x "
665 "domain=0x%04x address=0x%016llx flags=0x%04x]\n", 665 "domain=0x%04x address=0x%016llx flags=0x%04x]\n",
666 PCI_BUS(devid), PCI_SLOT(devid), PCI_FUNC(devid), 666 PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
667 domid, address, flags); 667 domid, address, flags);
668 break; 668 break;
669 case EVENT_TYPE_ILL_CMD: 669 case EVENT_TYPE_ILL_CMD:
@@ -677,13 +677,13 @@ retry:
677 case EVENT_TYPE_IOTLB_INV_TO: 677 case EVENT_TYPE_IOTLB_INV_TO:
678 printk("IOTLB_INV_TIMEOUT device=%02x:%02x.%x " 678 printk("IOTLB_INV_TIMEOUT device=%02x:%02x.%x "
679 "address=0x%016llx]\n", 679 "address=0x%016llx]\n",
680 PCI_BUS(devid), PCI_SLOT(devid), PCI_FUNC(devid), 680 PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
681 address); 681 address);
682 break; 682 break;
683 case EVENT_TYPE_INV_DEV_REQ: 683 case EVENT_TYPE_INV_DEV_REQ:
684 printk("INVALID_DEVICE_REQUEST device=%02x:%02x.%x " 684 printk("INVALID_DEVICE_REQUEST device=%02x:%02x.%x "
685 "address=0x%016llx flags=0x%04x]\n", 685 "address=0x%016llx flags=0x%04x]\n",
686 PCI_BUS(devid), PCI_SLOT(devid), PCI_FUNC(devid), 686 PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
687 address, flags); 687 address, flags);
688 break; 688 break;
689 default: 689 default:
diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
index 9d23552a9619..bf51abb78dee 100644
--- a/drivers/iommu/amd_iommu_init.c
+++ b/drivers/iommu/amd_iommu_init.c
@@ -414,7 +414,7 @@ static int __init find_last_devid_on_pci(int bus, int dev, int fn, int cap_ptr)
414 u32 cap; 414 u32 cap;
415 415
416 cap = read_pci_config(bus, dev, fn, cap_ptr+MMIO_RANGE_OFFSET); 416 cap = read_pci_config(bus, dev, fn, cap_ptr+MMIO_RANGE_OFFSET);
417 update_last_devid(calc_devid(MMIO_GET_BUS(cap), MMIO_GET_LD(cap))); 417 update_last_devid(PCI_DEVID(MMIO_GET_BUS(cap), MMIO_GET_LD(cap)));
418 418
419 return 0; 419 return 0;
420} 420}
@@ -431,7 +431,7 @@ static int __init find_last_devid_from_ivhd(struct ivhd_header *h)
431 p += sizeof(*h); 431 p += sizeof(*h);
432 end += h->length; 432 end += h->length;
433 433
434 find_last_devid_on_pci(PCI_BUS(h->devid), 434 find_last_devid_on_pci(PCI_BUS_NUM(h->devid),
435 PCI_SLOT(h->devid), 435 PCI_SLOT(h->devid),
436 PCI_FUNC(h->devid), 436 PCI_FUNC(h->devid),
437 h->cap_ptr); 437 h->cap_ptr);
@@ -833,10 +833,10 @@ static int __init init_iommu_from_acpi(struct amd_iommu *iommu,
833 833
834 DUMP_printk(" DEV_ALL\t\t\t first devid: %02x:%02x.%x" 834 DUMP_printk(" DEV_ALL\t\t\t first devid: %02x:%02x.%x"
835 " last device %02x:%02x.%x flags: %02x\n", 835 " last device %02x:%02x.%x flags: %02x\n",
836 PCI_BUS(iommu->first_device), 836 PCI_BUS_NUM(iommu->first_device),
837 PCI_SLOT(iommu->first_device), 837 PCI_SLOT(iommu->first_device),
838 PCI_FUNC(iommu->first_device), 838 PCI_FUNC(iommu->first_device),
839 PCI_BUS(iommu->last_device), 839 PCI_BUS_NUM(iommu->last_device),
840 PCI_SLOT(iommu->last_device), 840 PCI_SLOT(iommu->last_device),
841 PCI_FUNC(iommu->last_device), 841 PCI_FUNC(iommu->last_device),
842 e->flags); 842 e->flags);
@@ -850,7 +850,7 @@ static int __init init_iommu_from_acpi(struct amd_iommu *iommu,
850 850
851 DUMP_printk(" DEV_SELECT\t\t\t devid: %02x:%02x.%x " 851 DUMP_printk(" DEV_SELECT\t\t\t devid: %02x:%02x.%x "
852 "flags: %02x\n", 852 "flags: %02x\n",
853 PCI_BUS(e->devid), 853 PCI_BUS_NUM(e->devid),
854 PCI_SLOT(e->devid), 854 PCI_SLOT(e->devid),
855 PCI_FUNC(e->devid), 855 PCI_FUNC(e->devid),
856 e->flags); 856 e->flags);
@@ -862,7 +862,7 @@ static int __init init_iommu_from_acpi(struct amd_iommu *iommu,
862 862
863 DUMP_printk(" DEV_SELECT_RANGE_START\t " 863 DUMP_printk(" DEV_SELECT_RANGE_START\t "
864 "devid: %02x:%02x.%x flags: %02x\n", 864 "devid: %02x:%02x.%x flags: %02x\n",
865 PCI_BUS(e->devid), 865 PCI_BUS_NUM(e->devid),
866 PCI_SLOT(e->devid), 866 PCI_SLOT(e->devid),
867 PCI_FUNC(e->devid), 867 PCI_FUNC(e->devid),
868 e->flags); 868 e->flags);
@@ -876,11 +876,11 @@ static int __init init_iommu_from_acpi(struct amd_iommu *iommu,
876 876
877 DUMP_printk(" DEV_ALIAS\t\t\t devid: %02x:%02x.%x " 877 DUMP_printk(" DEV_ALIAS\t\t\t devid: %02x:%02x.%x "
878 "flags: %02x devid_to: %02x:%02x.%x\n", 878 "flags: %02x devid_to: %02x:%02x.%x\n",
879 PCI_BUS(e->devid), 879 PCI_BUS_NUM(e->devid),
880 PCI_SLOT(e->devid), 880 PCI_SLOT(e->devid),
881 PCI_FUNC(e->devid), 881 PCI_FUNC(e->devid),
882 e->flags, 882 e->flags,
883 PCI_BUS(e->ext >> 8), 883 PCI_BUS_NUM(e->ext >> 8),
884 PCI_SLOT(e->ext >> 8), 884 PCI_SLOT(e->ext >> 8),
885 PCI_FUNC(e->ext >> 8)); 885 PCI_FUNC(e->ext >> 8));
886 886
@@ -895,11 +895,11 @@ static int __init init_iommu_from_acpi(struct amd_iommu *iommu,
895 DUMP_printk(" DEV_ALIAS_RANGE\t\t " 895 DUMP_printk(" DEV_ALIAS_RANGE\t\t "
896 "devid: %02x:%02x.%x flags: %02x " 896 "devid: %02x:%02x.%x flags: %02x "
897 "devid_to: %02x:%02x.%x\n", 897 "devid_to: %02x:%02x.%x\n",
898 PCI_BUS(e->devid), 898 PCI_BUS_NUM(e->devid),
899 PCI_SLOT(e->devid), 899 PCI_SLOT(e->devid),
900 PCI_FUNC(e->devid), 900 PCI_FUNC(e->devid),
901 e->flags, 901 e->flags,
902 PCI_BUS(e->ext >> 8), 902 PCI_BUS_NUM(e->ext >> 8),
903 PCI_SLOT(e->ext >> 8), 903 PCI_SLOT(e->ext >> 8),
904 PCI_FUNC(e->ext >> 8)); 904 PCI_FUNC(e->ext >> 8));
905 905
@@ -913,7 +913,7 @@ static int __init init_iommu_from_acpi(struct amd_iommu *iommu,
913 913
914 DUMP_printk(" DEV_EXT_SELECT\t\t devid: %02x:%02x.%x " 914 DUMP_printk(" DEV_EXT_SELECT\t\t devid: %02x:%02x.%x "
915 "flags: %02x ext: %08x\n", 915 "flags: %02x ext: %08x\n",
916 PCI_BUS(e->devid), 916 PCI_BUS_NUM(e->devid),
917 PCI_SLOT(e->devid), 917 PCI_SLOT(e->devid),
918 PCI_FUNC(e->devid), 918 PCI_FUNC(e->devid),
919 e->flags, e->ext); 919 e->flags, e->ext);
@@ -926,7 +926,7 @@ static int __init init_iommu_from_acpi(struct amd_iommu *iommu,
926 926
927 DUMP_printk(" DEV_EXT_SELECT_RANGE\t devid: " 927 DUMP_printk(" DEV_EXT_SELECT_RANGE\t devid: "
928 "%02x:%02x.%x flags: %02x ext: %08x\n", 928 "%02x:%02x.%x flags: %02x ext: %08x\n",
929 PCI_BUS(e->devid), 929 PCI_BUS_NUM(e->devid),
930 PCI_SLOT(e->devid), 930 PCI_SLOT(e->devid),
931 PCI_FUNC(e->devid), 931 PCI_FUNC(e->devid),
932 e->flags, e->ext); 932 e->flags, e->ext);
@@ -939,7 +939,7 @@ static int __init init_iommu_from_acpi(struct amd_iommu *iommu,
939 case IVHD_DEV_RANGE_END: 939 case IVHD_DEV_RANGE_END:
940 940
941 DUMP_printk(" DEV_RANGE_END\t\t devid: %02x:%02x.%x\n", 941 DUMP_printk(" DEV_RANGE_END\t\t devid: %02x:%02x.%x\n",
942 PCI_BUS(e->devid), 942 PCI_BUS_NUM(e->devid),
943 PCI_SLOT(e->devid), 943 PCI_SLOT(e->devid),
944 PCI_FUNC(e->devid)); 944 PCI_FUNC(e->devid));
945 945
@@ -973,7 +973,7 @@ static int __init init_iommu_from_acpi(struct amd_iommu *iommu,
973 973
974 DUMP_printk(" DEV_SPECIAL(%s[%d])\t\tdevid: %02x:%02x.%x\n", 974 DUMP_printk(" DEV_SPECIAL(%s[%d])\t\tdevid: %02x:%02x.%x\n",
975 var, (int)handle, 975 var, (int)handle,
976 PCI_BUS(devid), 976 PCI_BUS_NUM(devid),
977 PCI_SLOT(devid), 977 PCI_SLOT(devid),
978 PCI_FUNC(devid)); 978 PCI_FUNC(devid));
979 979
@@ -1135,7 +1135,7 @@ static int __init init_iommu_all(struct acpi_table_header *table)
1135 1135
1136 DUMP_printk("device: %02x:%02x.%01x cap: %04x " 1136 DUMP_printk("device: %02x:%02x.%01x cap: %04x "
1137 "seg: %d flags: %01x info %04x\n", 1137 "seg: %d flags: %01x info %04x\n",
1138 PCI_BUS(h->devid), PCI_SLOT(h->devid), 1138 PCI_BUS_NUM(h->devid), PCI_SLOT(h->devid),
1139 PCI_FUNC(h->devid), h->cap_ptr, 1139 PCI_FUNC(h->devid), h->cap_ptr,
1140 h->pci_seg, h->flags, h->info); 1140 h->pci_seg, h->flags, h->info);
1141 DUMP_printk(" mmio-addr: %016llx\n", 1141 DUMP_printk(" mmio-addr: %016llx\n",
@@ -1165,7 +1165,7 @@ static int iommu_init_pci(struct amd_iommu *iommu)
1165 int cap_ptr = iommu->cap_ptr; 1165 int cap_ptr = iommu->cap_ptr;
1166 u32 range, misc, low, high; 1166 u32 range, misc, low, high;
1167 1167
1168 iommu->dev = pci_get_bus_and_slot(PCI_BUS(iommu->devid), 1168 iommu->dev = pci_get_bus_and_slot(PCI_BUS_NUM(iommu->devid),
1169 iommu->devid & 0xff); 1169 iommu->devid & 0xff);
1170 if (!iommu->dev) 1170 if (!iommu->dev)
1171 return -ENODEV; 1171 return -ENODEV;
@@ -1177,9 +1177,9 @@ static int iommu_init_pci(struct amd_iommu *iommu)
1177 pci_read_config_dword(iommu->dev, cap_ptr + MMIO_MISC_OFFSET, 1177 pci_read_config_dword(iommu->dev, cap_ptr + MMIO_MISC_OFFSET,
1178 &misc); 1178 &misc);
1179 1179
1180 iommu->first_device = calc_devid(MMIO_GET_BUS(range), 1180 iommu->first_device = PCI_DEVID(MMIO_GET_BUS(range),
1181 MMIO_GET_FD(range)); 1181 MMIO_GET_FD(range));
1182 iommu->last_device = calc_devid(MMIO_GET_BUS(range), 1182 iommu->last_device = PCI_DEVID(MMIO_GET_BUS(range),
1183 MMIO_GET_LD(range)); 1183 MMIO_GET_LD(range));
1184 1184
1185 if (!(iommu->cap & (1 << IOMMU_CAP_IOTLB))) 1185 if (!(iommu->cap & (1 << IOMMU_CAP_IOTLB)))
@@ -1437,8 +1437,8 @@ static int __init init_unity_map_range(struct ivmd_header *m)
1437 1437
1438 DUMP_printk("%s devid_start: %02x:%02x.%x devid_end: %02x:%02x.%x" 1438 DUMP_printk("%s devid_start: %02x:%02x.%x devid_end: %02x:%02x.%x"
1439 " range_start: %016llx range_end: %016llx flags: %x\n", s, 1439 " range_start: %016llx range_end: %016llx flags: %x\n", s,
1440 PCI_BUS(e->devid_start), PCI_SLOT(e->devid_start), 1440 PCI_BUS_NUM(e->devid_start), PCI_SLOT(e->devid_start),
1441 PCI_FUNC(e->devid_start), PCI_BUS(e->devid_end), 1441 PCI_FUNC(e->devid_start), PCI_BUS_NUM(e->devid_end),
1442 PCI_SLOT(e->devid_end), PCI_FUNC(e->devid_end), 1442 PCI_SLOT(e->devid_end), PCI_FUNC(e->devid_end),
1443 e->address_start, e->address_end, m->flags); 1443 e->address_start, e->address_end, m->flags);
1444 1444
diff --git a/drivers/iommu/amd_iommu_types.h b/drivers/iommu/amd_iommu_types.h
index b81153fb9e60..0285a215df16 100644
--- a/drivers/iommu/amd_iommu_types.h
+++ b/drivers/iommu/amd_iommu_types.h
@@ -24,6 +24,7 @@
24#include <linux/mutex.h> 24#include <linux/mutex.h>
25#include <linux/list.h> 25#include <linux/list.h>
26#include <linux/spinlock.h> 26#include <linux/spinlock.h>
27#include <linux/pci.h>
27 28
28/* 29/*
29 * Maximum number of IOMMUs supported 30 * Maximum number of IOMMUs supported
@@ -316,9 +317,6 @@
316 317
317#define MAX_DOMAIN_ID 65536 318#define MAX_DOMAIN_ID 65536
318 319
319/* FIXME: move this macro to <linux/pci.h> */
320#define PCI_BUS(x) (((x) >> 8) & 0xff)
321
322/* Protection domain flags */ 320/* Protection domain flags */
323#define PD_DMA_OPS_MASK (1UL << 0) /* domain used for dma_ops */ 321#define PD_DMA_OPS_MASK (1UL << 0) /* domain used for dma_ops */
324#define PD_DEFAULT_MASK (1UL << 1) /* domain is a default dma_ops 322#define PD_DEFAULT_MASK (1UL << 1) /* domain is a default dma_ops
@@ -705,13 +703,6 @@ extern int amd_iommu_max_glx_val;
705 */ 703 */
706extern void iommu_flush_all_caches(struct amd_iommu *iommu); 704extern void iommu_flush_all_caches(struct amd_iommu *iommu);
707 705
708/* takes bus and device/function and returns the device id
709 * FIXME: should that be in generic PCI code? */
710static inline u16 calc_devid(u8 bus, u8 devfn)
711{
712 return (((u16)bus) << 8) | devfn;
713}
714
715static inline int get_ioapic_devid(int id) 706static inline int get_ioapic_devid(int id)
716{ 707{
717 struct devid_map *entry; 708 struct devid_map *entry;