aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iommu
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-04-29 12:30:25 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-04-29 12:30:25 -0400
commit96a3e8af5a54c324535472ca946215d5bafe6539 (patch)
treee59b48aa3fa2b8c6c1f59f76b7b4c71f9c694093 /drivers/iommu
parenta87451052fb914744571fc3ab39fcbf4fa4ef944 (diff)
parentd4f09c5d7fbabd1389a5f03f5c9329d790f544e3 (diff)
Merge tag 'pci-v3.10-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci
Pull PCI updates from Bjorn Helgaas: "PCI changes for the v3.10 merge window: PCI device hotplug - Remove ACPI PCI subdrivers (Jiang Liu, Myron Stowe) - Make acpiphp builtin only, not modular (Jiang Liu) - Add acpiphp mutual exclusion (Jiang Liu) Power management - Skip "PME enabled/disabled" messages when not supported (Rafael Wysocki) - Fix fallback to PCI_D0 (Rafael Wysocki) Miscellaneous - Factor quirk_io_region (Yinghai Lu) - Cache MSI capability offsets & cleanup (Gavin Shan, Bjorn Helgaas) - Clean up EISA resource initialization and logging (Bjorn Helgaas) - Fix prototype warnings (Andy Shevchenko, Bjorn Helgaas) - MIPS: Initialize of_node before scanning bus (Gabor Juhos) - Fix pcibios_get_phb_of_node() declaration "weak" annotation (Gabor Juhos) - Add MSI INTX_DISABLE quirks for AR8161/AR8162/etc (Xiong Huang) - Fix aer_inject return values (Prarit Bhargava) - Remove PME/ACPI dependency (Andrew Murray) - Use shared PCI_BUS_NUM() and PCI_DEVID() (Shuah Khan)" * tag 'pci-v3.10-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci: (63 commits) vfio-pci: Use cached MSI/MSI-X capabilities vfio-pci: Use PCI_MSIX_TABLE_BIR, not PCI_MSIX_FLAGS_BIRMASK PCI: Remove "extern" from function declarations PCI: Use PCI_MSIX_TABLE_BIR, not PCI_MSIX_FLAGS_BIRMASK PCI: Drop msi_mask_reg() and remove drivers/pci/msi.h PCI: Use msix_table_size() directly, drop multi_msix_capable() PCI: Drop msix_table_offset_reg() and msix_pba_offset_reg() macros PCI: Drop is_64bit_address() and is_mask_bit_support() macros PCI: Drop msi_data_reg() macro PCI: Drop msi_lower_address_reg() and msi_upper_address_reg() macros PCI: Drop msi_control_reg() macro and use PCI_MSI_FLAGS directly PCI: Use cached MSI/MSI-X offsets from dev, not from msi_desc PCI: Clean up MSI/MSI-X capability #defines PCI: Use cached MSI-X cap while enabling MSI-X PCI: Use cached MSI cap while enabling MSI interrupts PCI: Remove MSI/MSI-X cap check in pci_msi_check_device() PCI: Cache MSI/MSI-X capability offsets in struct pci_dev PCI: Use u8, not int, for PM capability offset [SCSI] megaraid_sas: Use correct #define for MSI-X capability PCI: Remove "extern" from function declarations ...
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 b287ca33833d..830183737b0f 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -173,7 +173,7 @@ static inline u16 get_device_id(struct device *dev)
173{ 173{
174 struct pci_dev *pdev = to_pci_dev(dev); 174 struct pci_dev *pdev = to_pci_dev(dev);
175 175
176 return calc_devid(pdev->bus->number, pdev->devfn); 176 return PCI_DEVID(pdev->bus->number, pdev->devfn);
177} 177}
178 178
179static struct iommu_dev_data *get_dev_data(struct device *dev) 179static struct iommu_dev_data *get_dev_data(struct device *dev)
@@ -649,26 +649,26 @@ retry:
649 case EVENT_TYPE_ILL_DEV: 649 case EVENT_TYPE_ILL_DEV:
650 printk("ILLEGAL_DEV_TABLE_ENTRY device=%02x:%02x.%x " 650 printk("ILLEGAL_DEV_TABLE_ENTRY device=%02x:%02x.%x "
651 "address=0x%016llx flags=0x%04x]\n", 651 "address=0x%016llx flags=0x%04x]\n",
652 PCI_BUS(devid), PCI_SLOT(devid), PCI_FUNC(devid), 652 PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
653 address, flags); 653 address, flags);
654 dump_dte_entry(devid); 654 dump_dte_entry(devid);
655 break; 655 break;
656 case EVENT_TYPE_IO_FAULT: 656 case EVENT_TYPE_IO_FAULT:
657 printk("IO_PAGE_FAULT device=%02x:%02x.%x " 657 printk("IO_PAGE_FAULT device=%02x:%02x.%x "
658 "domain=0x%04x address=0x%016llx flags=0x%04x]\n", 658 "domain=0x%04x address=0x%016llx flags=0x%04x]\n",
659 PCI_BUS(devid), PCI_SLOT(devid), PCI_FUNC(devid), 659 PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
660 domid, address, flags); 660 domid, address, flags);
661 break; 661 break;
662 case EVENT_TYPE_DEV_TAB_ERR: 662 case EVENT_TYPE_DEV_TAB_ERR:
663 printk("DEV_TAB_HARDWARE_ERROR device=%02x:%02x.%x " 663 printk("DEV_TAB_HARDWARE_ERROR device=%02x:%02x.%x "
664 "address=0x%016llx flags=0x%04x]\n", 664 "address=0x%016llx flags=0x%04x]\n",
665 PCI_BUS(devid), PCI_SLOT(devid), PCI_FUNC(devid), 665 PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
666 address, flags); 666 address, flags);
667 break; 667 break;
668 case EVENT_TYPE_PAGE_TAB_ERR: 668 case EVENT_TYPE_PAGE_TAB_ERR:
669 printk("PAGE_TAB_HARDWARE_ERROR device=%02x:%02x.%x " 669 printk("PAGE_TAB_HARDWARE_ERROR device=%02x:%02x.%x "
670 "domain=0x%04x address=0x%016llx flags=0x%04x]\n", 670 "domain=0x%04x address=0x%016llx flags=0x%04x]\n",
671 PCI_BUS(devid), PCI_SLOT(devid), PCI_FUNC(devid), 671 PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
672 domid, address, flags); 672 domid, address, flags);
673 break; 673 break;
674 case EVENT_TYPE_ILL_CMD: 674 case EVENT_TYPE_ILL_CMD:
@@ -682,13 +682,13 @@ retry:
682 case EVENT_TYPE_IOTLB_INV_TO: 682 case EVENT_TYPE_IOTLB_INV_TO:
683 printk("IOTLB_INV_TIMEOUT device=%02x:%02x.%x " 683 printk("IOTLB_INV_TIMEOUT device=%02x:%02x.%x "
684 "address=0x%016llx]\n", 684 "address=0x%016llx]\n",
685 PCI_BUS(devid), PCI_SLOT(devid), PCI_FUNC(devid), 685 PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
686 address); 686 address);
687 break; 687 break;
688 case EVENT_TYPE_INV_DEV_REQ: 688 case EVENT_TYPE_INV_DEV_REQ:
689 printk("INVALID_DEVICE_REQUEST device=%02x:%02x.%x " 689 printk("INVALID_DEVICE_REQUEST device=%02x:%02x.%x "
690 "address=0x%016llx flags=0x%04x]\n", 690 "address=0x%016llx flags=0x%04x]\n",
691 PCI_BUS(devid), PCI_SLOT(devid), PCI_FUNC(devid), 691 PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
692 address, flags); 692 address, flags);
693 break; 693 break;
694 default: 694 default:
diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
index e3c2d74b7684..2f46881256a2 100644
--- a/drivers/iommu/amd_iommu_init.c
+++ b/drivers/iommu/amd_iommu_init.c
@@ -406,7 +406,7 @@ static int __init find_last_devid_on_pci(int bus, int dev, int fn, int cap_ptr)
406 u32 cap; 406 u32 cap;
407 407
408 cap = read_pci_config(bus, dev, fn, cap_ptr+MMIO_RANGE_OFFSET); 408 cap = read_pci_config(bus, dev, fn, cap_ptr+MMIO_RANGE_OFFSET);
409 update_last_devid(calc_devid(MMIO_GET_BUS(cap), MMIO_GET_LD(cap))); 409 update_last_devid(PCI_DEVID(MMIO_GET_BUS(cap), MMIO_GET_LD(cap)));
410 410
411 return 0; 411 return 0;
412} 412}
@@ -423,7 +423,7 @@ static int __init find_last_devid_from_ivhd(struct ivhd_header *h)
423 p += sizeof(*h); 423 p += sizeof(*h);
424 end += h->length; 424 end += h->length;
425 425
426 find_last_devid_on_pci(PCI_BUS(h->devid), 426 find_last_devid_on_pci(PCI_BUS_NUM(h->devid),
427 PCI_SLOT(h->devid), 427 PCI_SLOT(h->devid),
428 PCI_FUNC(h->devid), 428 PCI_FUNC(h->devid),
429 h->cap_ptr); 429 h->cap_ptr);
@@ -784,10 +784,10 @@ static int __init init_iommu_from_acpi(struct amd_iommu *iommu,
784 784
785 DUMP_printk(" DEV_ALL\t\t\t first devid: %02x:%02x.%x" 785 DUMP_printk(" DEV_ALL\t\t\t first devid: %02x:%02x.%x"
786 " last device %02x:%02x.%x flags: %02x\n", 786 " last device %02x:%02x.%x flags: %02x\n",
787 PCI_BUS(iommu->first_device), 787 PCI_BUS_NUM(iommu->first_device),
788 PCI_SLOT(iommu->first_device), 788 PCI_SLOT(iommu->first_device),
789 PCI_FUNC(iommu->first_device), 789 PCI_FUNC(iommu->first_device),
790 PCI_BUS(iommu->last_device), 790 PCI_BUS_NUM(iommu->last_device),
791 PCI_SLOT(iommu->last_device), 791 PCI_SLOT(iommu->last_device),
792 PCI_FUNC(iommu->last_device), 792 PCI_FUNC(iommu->last_device),
793 e->flags); 793 e->flags);
@@ -801,7 +801,7 @@ static int __init init_iommu_from_acpi(struct amd_iommu *iommu,
801 801
802 DUMP_printk(" DEV_SELECT\t\t\t devid: %02x:%02x.%x " 802 DUMP_printk(" DEV_SELECT\t\t\t devid: %02x:%02x.%x "
803 "flags: %02x\n", 803 "flags: %02x\n",
804 PCI_BUS(e->devid), 804 PCI_BUS_NUM(e->devid),
805 PCI_SLOT(e->devid), 805 PCI_SLOT(e->devid),
806 PCI_FUNC(e->devid), 806 PCI_FUNC(e->devid),
807 e->flags); 807 e->flags);
@@ -813,7 +813,7 @@ static int __init init_iommu_from_acpi(struct amd_iommu *iommu,
813 813
814 DUMP_printk(" DEV_SELECT_RANGE_START\t " 814 DUMP_printk(" DEV_SELECT_RANGE_START\t "
815 "devid: %02x:%02x.%x flags: %02x\n", 815 "devid: %02x:%02x.%x flags: %02x\n",
816 PCI_BUS(e->devid), 816 PCI_BUS_NUM(e->devid),
817 PCI_SLOT(e->devid), 817 PCI_SLOT(e->devid),
818 PCI_FUNC(e->devid), 818 PCI_FUNC(e->devid),
819 e->flags); 819 e->flags);
@@ -827,11 +827,11 @@ static int __init init_iommu_from_acpi(struct amd_iommu *iommu,
827 827
828 DUMP_printk(" DEV_ALIAS\t\t\t devid: %02x:%02x.%x " 828 DUMP_printk(" DEV_ALIAS\t\t\t devid: %02x:%02x.%x "
829 "flags: %02x devid_to: %02x:%02x.%x\n", 829 "flags: %02x devid_to: %02x:%02x.%x\n",
830 PCI_BUS(e->devid), 830 PCI_BUS_NUM(e->devid),
831 PCI_SLOT(e->devid), 831 PCI_SLOT(e->devid),
832 PCI_FUNC(e->devid), 832 PCI_FUNC(e->devid),
833 e->flags, 833 e->flags,
834 PCI_BUS(e->ext >> 8), 834 PCI_BUS_NUM(e->ext >> 8),
835 PCI_SLOT(e->ext >> 8), 835 PCI_SLOT(e->ext >> 8),
836 PCI_FUNC(e->ext >> 8)); 836 PCI_FUNC(e->ext >> 8));
837 837
@@ -846,11 +846,11 @@ static int __init init_iommu_from_acpi(struct amd_iommu *iommu,
846 DUMP_printk(" DEV_ALIAS_RANGE\t\t " 846 DUMP_printk(" DEV_ALIAS_RANGE\t\t "
847 "devid: %02x:%02x.%x flags: %02x " 847 "devid: %02x:%02x.%x flags: %02x "
848 "devid_to: %02x:%02x.%x\n", 848 "devid_to: %02x:%02x.%x\n",
849 PCI_BUS(e->devid), 849 PCI_BUS_NUM(e->devid),
850 PCI_SLOT(e->devid), 850 PCI_SLOT(e->devid),
851 PCI_FUNC(e->devid), 851 PCI_FUNC(e->devid),
852 e->flags, 852 e->flags,
853 PCI_BUS(e->ext >> 8), 853 PCI_BUS_NUM(e->ext >> 8),
854 PCI_SLOT(e->ext >> 8), 854 PCI_SLOT(e->ext >> 8),
855 PCI_FUNC(e->ext >> 8)); 855 PCI_FUNC(e->ext >> 8));
856 856
@@ -864,7 +864,7 @@ static int __init init_iommu_from_acpi(struct amd_iommu *iommu,
864 864
865 DUMP_printk(" DEV_EXT_SELECT\t\t devid: %02x:%02x.%x " 865 DUMP_printk(" DEV_EXT_SELECT\t\t devid: %02x:%02x.%x "
866 "flags: %02x ext: %08x\n", 866 "flags: %02x ext: %08x\n",
867 PCI_BUS(e->devid), 867 PCI_BUS_NUM(e->devid),
868 PCI_SLOT(e->devid), 868 PCI_SLOT(e->devid),
869 PCI_FUNC(e->devid), 869 PCI_FUNC(e->devid),
870 e->flags, e->ext); 870 e->flags, e->ext);
@@ -877,7 +877,7 @@ static int __init init_iommu_from_acpi(struct amd_iommu *iommu,
877 877
878 DUMP_printk(" DEV_EXT_SELECT_RANGE\t devid: " 878 DUMP_printk(" DEV_EXT_SELECT_RANGE\t devid: "
879 "%02x:%02x.%x flags: %02x ext: %08x\n", 879 "%02x:%02x.%x flags: %02x ext: %08x\n",
880 PCI_BUS(e->devid), 880 PCI_BUS_NUM(e->devid),
881 PCI_SLOT(e->devid), 881 PCI_SLOT(e->devid),
882 PCI_FUNC(e->devid), 882 PCI_FUNC(e->devid),
883 e->flags, e->ext); 883 e->flags, e->ext);
@@ -890,7 +890,7 @@ static int __init init_iommu_from_acpi(struct amd_iommu *iommu,
890 case IVHD_DEV_RANGE_END: 890 case IVHD_DEV_RANGE_END:
891 891
892 DUMP_printk(" DEV_RANGE_END\t\t devid: %02x:%02x.%x\n", 892 DUMP_printk(" DEV_RANGE_END\t\t devid: %02x:%02x.%x\n",
893 PCI_BUS(e->devid), 893 PCI_BUS_NUM(e->devid),
894 PCI_SLOT(e->devid), 894 PCI_SLOT(e->devid),
895 PCI_FUNC(e->devid)); 895 PCI_FUNC(e->devid));
896 896
@@ -924,7 +924,7 @@ static int __init init_iommu_from_acpi(struct amd_iommu *iommu,
924 924
925 DUMP_printk(" DEV_SPECIAL(%s[%d])\t\tdevid: %02x:%02x.%x\n", 925 DUMP_printk(" DEV_SPECIAL(%s[%d])\t\tdevid: %02x:%02x.%x\n",
926 var, (int)handle, 926 var, (int)handle,
927 PCI_BUS(devid), 927 PCI_BUS_NUM(devid),
928 PCI_SLOT(devid), 928 PCI_SLOT(devid),
929 PCI_FUNC(devid)); 929 PCI_FUNC(devid));
930 930
@@ -1086,7 +1086,7 @@ static int __init init_iommu_all(struct acpi_table_header *table)
1086 1086
1087 DUMP_printk("device: %02x:%02x.%01x cap: %04x " 1087 DUMP_printk("device: %02x:%02x.%01x cap: %04x "
1088 "seg: %d flags: %01x info %04x\n", 1088 "seg: %d flags: %01x info %04x\n",
1089 PCI_BUS(h->devid), PCI_SLOT(h->devid), 1089 PCI_BUS_NUM(h->devid), PCI_SLOT(h->devid),
1090 PCI_FUNC(h->devid), h->cap_ptr, 1090 PCI_FUNC(h->devid), h->cap_ptr,
1091 h->pci_seg, h->flags, h->info); 1091 h->pci_seg, h->flags, h->info);
1092 DUMP_printk(" mmio-addr: %016llx\n", 1092 DUMP_printk(" mmio-addr: %016llx\n",
@@ -1116,7 +1116,7 @@ static int iommu_init_pci(struct amd_iommu *iommu)
1116 int cap_ptr = iommu->cap_ptr; 1116 int cap_ptr = iommu->cap_ptr;
1117 u32 range, misc, low, high; 1117 u32 range, misc, low, high;
1118 1118
1119 iommu->dev = pci_get_bus_and_slot(PCI_BUS(iommu->devid), 1119 iommu->dev = pci_get_bus_and_slot(PCI_BUS_NUM(iommu->devid),
1120 iommu->devid & 0xff); 1120 iommu->devid & 0xff);
1121 if (!iommu->dev) 1121 if (!iommu->dev)
1122 return -ENODEV; 1122 return -ENODEV;
@@ -1128,9 +1128,9 @@ static int iommu_init_pci(struct amd_iommu *iommu)
1128 pci_read_config_dword(iommu->dev, cap_ptr + MMIO_MISC_OFFSET, 1128 pci_read_config_dword(iommu->dev, cap_ptr + MMIO_MISC_OFFSET,
1129 &misc); 1129 &misc);
1130 1130
1131 iommu->first_device = calc_devid(MMIO_GET_BUS(range), 1131 iommu->first_device = PCI_DEVID(MMIO_GET_BUS(range),
1132 MMIO_GET_FD(range)); 1132 MMIO_GET_FD(range));
1133 iommu->last_device = calc_devid(MMIO_GET_BUS(range), 1133 iommu->last_device = PCI_DEVID(MMIO_GET_BUS(range),
1134 MMIO_GET_LD(range)); 1134 MMIO_GET_LD(range));
1135 1135
1136 if (!(iommu->cap & (1 << IOMMU_CAP_IOTLB))) 1136 if (!(iommu->cap & (1 << IOMMU_CAP_IOTLB)))
@@ -1388,8 +1388,8 @@ static int __init init_unity_map_range(struct ivmd_header *m)
1388 1388
1389 DUMP_printk("%s devid_start: %02x:%02x.%x devid_end: %02x:%02x.%x" 1389 DUMP_printk("%s devid_start: %02x:%02x.%x devid_end: %02x:%02x.%x"
1390 " range_start: %016llx range_end: %016llx flags: %x\n", s, 1390 " range_start: %016llx range_end: %016llx flags: %x\n", s,
1391 PCI_BUS(e->devid_start), PCI_SLOT(e->devid_start), 1391 PCI_BUS_NUM(e->devid_start), PCI_SLOT(e->devid_start),
1392 PCI_FUNC(e->devid_start), PCI_BUS(e->devid_end), 1392 PCI_FUNC(e->devid_start), PCI_BUS_NUM(e->devid_end),
1393 PCI_SLOT(e->devid_end), PCI_FUNC(e->devid_end), 1393 PCI_SLOT(e->devid_end), PCI_FUNC(e->devid_end),
1394 e->address_start, e->address_end, m->flags); 1394 e->address_start, e->address_end, m->flags);
1395 1395
diff --git a/drivers/iommu/amd_iommu_types.h b/drivers/iommu/amd_iommu_types.h
index e38ab438bb34..ec36cf63e0ca 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
@@ -315,9 +316,6 @@
315 316
316#define MAX_DOMAIN_ID 65536 317#define MAX_DOMAIN_ID 65536
317 318
318/* FIXME: move this macro to <linux/pci.h> */
319#define PCI_BUS(x) (((x) >> 8) & 0xff)
320
321/* Protection domain flags */ 319/* Protection domain flags */
322#define PD_DMA_OPS_MASK (1UL << 0) /* domain used for dma_ops */ 320#define PD_DMA_OPS_MASK (1UL << 0) /* domain used for dma_ops */
323#define PD_DEFAULT_MASK (1UL << 1) /* domain is a default dma_ops 321#define PD_DEFAULT_MASK (1UL << 1) /* domain is a default dma_ops
@@ -703,13 +701,6 @@ extern int amd_iommu_max_glx_val;
703 */ 701 */
704extern void iommu_flush_all_caches(struct amd_iommu *iommu); 702extern void iommu_flush_all_caches(struct amd_iommu *iommu);
705 703
706/* takes bus and device/function and returns the device id
707 * FIXME: should that be in generic PCI code? */
708static inline u16 calc_devid(u8 bus, u8 devfn)
709{
710 return (((u16)bus) << 8) | devfn;
711}
712
713static inline int get_ioapic_devid(int id) 704static inline int get_ioapic_devid(int id)
714{ 705{
715 struct devid_map *entry; 706 struct devid_map *entry;