aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci')
-rw-r--r--drivers/pci/intel-iommu.c35
-rw-r--r--drivers/pci/pcie/aer/aerdrv_acpi.c2
-rw-r--r--drivers/pci/probe.c21
-rw-r--r--drivers/pci/proc.c15
4 files changed, 44 insertions, 29 deletions
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index 301c68fab03b..1fd8bb765702 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -1905,32 +1905,31 @@ get_valid_domain_for_dev(struct pci_dev *pdev)
1905 return domain; 1905 return domain;
1906} 1906}
1907 1907
1908static dma_addr_t intel_map_single(struct device *hwdev, void *addr, 1908static dma_addr_t
1909 size_t size, int dir) 1909intel_map_single(struct device *hwdev, phys_addr_t paddr, size_t size, int dir)
1910{ 1910{
1911 struct pci_dev *pdev = to_pci_dev(hwdev); 1911 struct pci_dev *pdev = to_pci_dev(hwdev);
1912 int ret;
1913 struct dmar_domain *domain; 1912 struct dmar_domain *domain;
1914 unsigned long start_addr; 1913 unsigned long start_paddr;
1915 struct iova *iova; 1914 struct iova *iova;
1916 int prot = 0; 1915 int prot = 0;
1916 int ret;
1917 1917
1918 BUG_ON(dir == DMA_NONE); 1918 BUG_ON(dir == DMA_NONE);
1919 if (pdev->dev.archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO) 1919 if (pdev->dev.archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO)
1920 return virt_to_bus(addr); 1920 return paddr;
1921 1921
1922 domain = get_valid_domain_for_dev(pdev); 1922 domain = get_valid_domain_for_dev(pdev);
1923 if (!domain) 1923 if (!domain)
1924 return 0; 1924 return 0;
1925 1925
1926 addr = (void *)virt_to_phys(addr); 1926 size = aligned_size((u64)paddr, size);
1927 size = aligned_size((u64)addr, size);
1928 1927
1929 iova = __intel_alloc_iova(hwdev, domain, size); 1928 iova = __intel_alloc_iova(hwdev, domain, size);
1930 if (!iova) 1929 if (!iova)
1931 goto error; 1930 goto error;
1932 1931
1933 start_addr = iova->pfn_lo << PAGE_SHIFT_4K; 1932 start_paddr = iova->pfn_lo << PAGE_SHIFT_4K;
1934 1933
1935 /* 1934 /*
1936 * Check if DMAR supports zero-length reads on write only 1935 * Check if DMAR supports zero-length reads on write only
@@ -1942,33 +1941,33 @@ static dma_addr_t intel_map_single(struct device *hwdev, void *addr,
1942 if (dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL) 1941 if (dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL)
1943 prot |= DMA_PTE_WRITE; 1942 prot |= DMA_PTE_WRITE;
1944 /* 1943 /*
1945 * addr - (addr + size) might be partial page, we should map the whole 1944 * paddr - (paddr + size) might be partial page, we should map the whole
1946 * page. Note: if two part of one page are separately mapped, we 1945 * page. Note: if two part of one page are separately mapped, we
1947 * might have two guest_addr mapping to the same host addr, but this 1946 * might have two guest_addr mapping to the same host paddr, but this
1948 * is not a big problem 1947 * is not a big problem
1949 */ 1948 */
1950 ret = domain_page_mapping(domain, start_addr, 1949 ret = domain_page_mapping(domain, start_paddr,
1951 ((u64)addr) & PAGE_MASK_4K, size, prot); 1950 ((u64)paddr) & PAGE_MASK_4K, size, prot);
1952 if (ret) 1951 if (ret)
1953 goto error; 1952 goto error;
1954 1953
1955 pr_debug("Device %s request: %lx@%llx mapping: %lx@%llx, dir %d\n", 1954 pr_debug("Device %s request: %lx@%llx mapping: %lx@%llx, dir %d\n",
1956 pci_name(pdev), size, (u64)addr, 1955 pci_name(pdev), size, (u64)paddr,
1957 size, (u64)start_addr, dir); 1956 size, (u64)start_paddr, dir);
1958 1957
1959 /* it's a non-present to present mapping */ 1958 /* it's a non-present to present mapping */
1960 ret = iommu_flush_iotlb_psi(domain->iommu, domain->id, 1959 ret = iommu_flush_iotlb_psi(domain->iommu, domain->id,
1961 start_addr, size >> PAGE_SHIFT_4K, 1); 1960 start_paddr, size >> PAGE_SHIFT_4K, 1);
1962 if (ret) 1961 if (ret)
1963 iommu_flush_write_buffer(domain->iommu); 1962 iommu_flush_write_buffer(domain->iommu);
1964 1963
1965 return (start_addr + ((u64)addr & (~PAGE_MASK_4K))); 1964 return (start_paddr + ((u64)paddr & (~PAGE_MASK_4K)));
1966 1965
1967error: 1966error:
1968 if (iova) 1967 if (iova)
1969 __free_iova(&domain->iovad, iova); 1968 __free_iova(&domain->iovad, iova);
1970 printk(KERN_ERR"Device %s request: %lx@%llx dir %d --- failed\n", 1969 printk(KERN_ERR"Device %s request: %lx@%llx dir %d --- failed\n",
1971 pci_name(pdev), size, (u64)addr, dir); 1970 pci_name(pdev), size, (u64)paddr, dir);
1972 return 0; 1971 return 0;
1973} 1972}
1974 1973
@@ -2082,7 +2081,7 @@ static void * intel_alloc_coherent(struct device *hwdev, size_t size,
2082 return NULL; 2081 return NULL;
2083 memset(vaddr, 0, size); 2082 memset(vaddr, 0, size);
2084 2083
2085 *dma_handle = intel_map_single(hwdev, vaddr, size, DMA_BIDIRECTIONAL); 2084 *dma_handle = intel_map_single(hwdev, virt_to_bus(vaddr), size, DMA_BIDIRECTIONAL);
2086 if (*dma_handle) 2085 if (*dma_handle)
2087 return vaddr; 2086 return vaddr;
2088 free_pages((unsigned long)vaddr, order); 2087 free_pages((unsigned long)vaddr, order);
diff --git a/drivers/pci/pcie/aer/aerdrv_acpi.c b/drivers/pci/pcie/aer/aerdrv_acpi.c
index 96ac54072f6f..d39a78dbd026 100644
--- a/drivers/pci/pcie/aer/aerdrv_acpi.c
+++ b/drivers/pci/pcie/aer/aerdrv_acpi.c
@@ -31,7 +31,7 @@ int aer_osc_setup(struct pcie_device *pciedev)
31{ 31{
32 acpi_status status = AE_NOT_FOUND; 32 acpi_status status = AE_NOT_FOUND;
33 struct pci_dev *pdev = pciedev->port; 33 struct pci_dev *pdev = pciedev->port;
34 acpi_handle handle = 0; 34 acpi_handle handle = NULL;
35 35
36 if (acpi_pci_disabled) 36 if (acpi_pci_disabled)
37 return -1; 37 return -1;
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index f991359f0c36..4a55bf380957 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -842,11 +842,14 @@ static void set_pcie_port_type(struct pci_dev *pdev)
842 * reading the dword at 0x100 which must either be 0 or a valid extended 842 * reading the dword at 0x100 which must either be 0 or a valid extended
843 * capability header. 843 * capability header.
844 */ 844 */
845int pci_cfg_space_size(struct pci_dev *dev) 845int pci_cfg_space_size_ext(struct pci_dev *dev, unsigned check_exp_pcix)
846{ 846{
847 int pos; 847 int pos;
848 u32 status; 848 u32 status;
849 849
850 if (!check_exp_pcix)
851 goto skip;
852
850 pos = pci_find_capability(dev, PCI_CAP_ID_EXP); 853 pos = pci_find_capability(dev, PCI_CAP_ID_EXP);
851 if (!pos) { 854 if (!pos) {
852 pos = pci_find_capability(dev, PCI_CAP_ID_PCIX); 855 pos = pci_find_capability(dev, PCI_CAP_ID_PCIX);
@@ -858,6 +861,7 @@ int pci_cfg_space_size(struct pci_dev *dev)
858 goto fail; 861 goto fail;
859 } 862 }
860 863
864 skip:
861 if (pci_read_config_dword(dev, 256, &status) != PCIBIOS_SUCCESSFUL) 865 if (pci_read_config_dword(dev, 256, &status) != PCIBIOS_SUCCESSFUL)
862 goto fail; 866 goto fail;
863 if (status == 0xffffffff) 867 if (status == 0xffffffff)
@@ -869,6 +873,11 @@ int pci_cfg_space_size(struct pci_dev *dev)
869 return PCI_CFG_SPACE_SIZE; 873 return PCI_CFG_SPACE_SIZE;
870} 874}
871 875
876int pci_cfg_space_size(struct pci_dev *dev)
877{
878 return pci_cfg_space_size_ext(dev, 1);
879}
880
872static void pci_release_bus_bridge_dev(struct device *dev) 881static void pci_release_bus_bridge_dev(struct device *dev)
873{ 882{
874 kfree(dev); 883 kfree(dev);
@@ -964,7 +973,6 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
964 dev->dev.release = pci_release_dev; 973 dev->dev.release = pci_release_dev;
965 pci_dev_get(dev); 974 pci_dev_get(dev);
966 975
967 set_dev_node(&dev->dev, pcibus_to_node(bus));
968 dev->dev.dma_mask = &dev->dma_mask; 976 dev->dev.dma_mask = &dev->dma_mask;
969 dev->dev.dma_parms = &dev->dma_parms; 977 dev->dev.dma_parms = &dev->dma_parms;
970 dev->dev.coherent_dma_mask = 0xffffffffull; 978 dev->dev.coherent_dma_mask = 0xffffffffull;
@@ -1080,6 +1088,10 @@ unsigned int __devinit pci_scan_child_bus(struct pci_bus *bus)
1080 return max; 1088 return max;
1081} 1089}
1082 1090
1091void __attribute__((weak)) set_pci_bus_resources_arch_default(struct pci_bus *b)
1092{
1093}
1094
1083struct pci_bus * pci_create_bus(struct device *parent, 1095struct pci_bus * pci_create_bus(struct device *parent,
1084 int bus, struct pci_ops *ops, void *sysdata) 1096 int bus, struct pci_ops *ops, void *sysdata)
1085{ 1097{
@@ -1119,6 +1131,9 @@ struct pci_bus * pci_create_bus(struct device *parent,
1119 goto dev_reg_err; 1131 goto dev_reg_err;
1120 b->bridge = get_device(dev); 1132 b->bridge = get_device(dev);
1121 1133
1134 if (!parent)
1135 set_dev_node(b->bridge, pcibus_to_node(b));
1136
1122 b->dev.class = &pcibus_class; 1137 b->dev.class = &pcibus_class;
1123 b->dev.parent = b->bridge; 1138 b->dev.parent = b->bridge;
1124 sprintf(b->dev.bus_id, "%04x:%02x", pci_domain_nr(b), bus); 1139 sprintf(b->dev.bus_id, "%04x:%02x", pci_domain_nr(b), bus);
@@ -1136,6 +1151,8 @@ struct pci_bus * pci_create_bus(struct device *parent,
1136 b->resource[0] = &ioport_resource; 1151 b->resource[0] = &ioport_resource;
1137 b->resource[1] = &iomem_resource; 1152 b->resource[1] = &iomem_resource;
1138 1153
1154 set_pci_bus_resources_arch_default(b);
1155
1139 return b; 1156 return b;
1140 1157
1141dev_create_file_err: 1158dev_create_file_err:
diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
index ef18fcd641e2..963a97642ae9 100644
--- a/drivers/pci/proc.c
+++ b/drivers/pci/proc.c
@@ -293,6 +293,7 @@ static int proc_bus_pci_release(struct inode *inode, struct file *file)
293#endif /* HAVE_PCI_MMAP */ 293#endif /* HAVE_PCI_MMAP */
294 294
295static const struct file_operations proc_bus_pci_operations = { 295static const struct file_operations proc_bus_pci_operations = {
296 .owner = THIS_MODULE,
296 .llseek = proc_bus_pci_lseek, 297 .llseek = proc_bus_pci_lseek,
297 .read = proc_bus_pci_read, 298 .read = proc_bus_pci_read,
298 .write = proc_bus_pci_write, 299 .write = proc_bus_pci_write,
@@ -406,11 +407,10 @@ int pci_proc_attach_device(struct pci_dev *dev)
406 } 407 }
407 408
408 sprintf(name, "%02x.%x", PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn)); 409 sprintf(name, "%02x.%x", PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
409 e = create_proc_entry(name, S_IFREG | S_IRUGO | S_IWUSR, bus->procdir); 410 e = proc_create_data(name, S_IFREG | S_IRUGO | S_IWUSR, bus->procdir,
411 &proc_bus_pci_operations, dev);
410 if (!e) 412 if (!e)
411 return -ENOMEM; 413 return -ENOMEM;
412 e->proc_fops = &proc_bus_pci_operations;
413 e->data = dev;
414 e->size = dev->cfg_size; 414 e->size = dev->cfg_size;
415 dev->procent = e; 415 dev->procent = e;
416 416
@@ -462,6 +462,7 @@ static int proc_bus_pci_dev_open(struct inode *inode, struct file *file)
462 return seq_open(file, &proc_bus_pci_devices_op); 462 return seq_open(file, &proc_bus_pci_devices_op);
463} 463}
464static const struct file_operations proc_bus_pci_dev_operations = { 464static const struct file_operations proc_bus_pci_dev_operations = {
465 .owner = THIS_MODULE,
465 .open = proc_bus_pci_dev_open, 466 .open = proc_bus_pci_dev_open,
466 .read = seq_read, 467 .read = seq_read,
467 .llseek = seq_lseek, 468 .llseek = seq_lseek,
@@ -470,12 +471,10 @@ static const struct file_operations proc_bus_pci_dev_operations = {
470 471
471static int __init pci_proc_init(void) 472static int __init pci_proc_init(void)
472{ 473{
473 struct proc_dir_entry *entry;
474 struct pci_dev *dev = NULL; 474 struct pci_dev *dev = NULL;
475 proc_bus_pci_dir = proc_mkdir("pci", proc_bus); 475 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
476 entry = create_proc_entry("devices", 0, proc_bus_pci_dir); 476 proc_create("devices", 0, proc_bus_pci_dir,
477 if (entry) 477 &proc_bus_pci_dev_operations);
478 entry->proc_fops = &proc_bus_pci_dev_operations;
479 proc_initialized = 1; 478 proc_initialized = 1;
480 while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { 479 while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
481 pci_proc_attach_device(dev); 480 pci_proc_attach_device(dev);