aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/pci-sysfs.c
diff options
context:
space:
mode:
authorMichael Ellerman <michael@ellerman.id.au>2005-05-13 03:44:10 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2005-06-28 00:52:45 -0400
commit2311b1f2bbd36fa5f366a7448c718b2556e0f02c (patch)
tree10e836c5c34893f8098464a5ae15aba351a7bb2a /drivers/pci/pci-sysfs.c
parenta0d399a808916d22c1c222c6b5ca4e8edd6d91a9 (diff)
[PATCH] PCI: fix-pci-mmap-on-ppc-and-ppc64.patch
This is an updated version of Ben's fix-pci-mmap-on-ppc-and-ppc64.patch which is in 2.6.12-rc4-mm1. It fixes the patch to work on PPC iSeries, removes some debug printks at Ben's request, and incorporates your fix-pci-mmap-on-ppc-and-ppc64-fix.patch also. Originally from Benjamin Herrenschmidt <benh@kernel.crashing.org> This patch was discussed at length on linux-pci and so far, the last iteration of it didn't raise any comment. It's effect is a nop on architecture that don't define the new pci_resource_to_user() callback anyway. It allows architecture like ppc who put weird things inside of PCI resource structures to convert to some different value for user visible ones. It also fixes mmap'ing of IO space on those archs. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Michael Ellerman <michael@ellerman.id.au> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/pci/pci-sysfs.c')
-rw-r--r--drivers/pci/pci-sysfs.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index a15f94072a6f..cc9d65388e62 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -60,15 +60,18 @@ resource_show(struct device * dev, struct device_attribute *attr, char * buf)
60 char * str = buf; 60 char * str = buf;
61 int i; 61 int i;
62 int max = 7; 62 int max = 7;
63 u64 start, end;
63 64
64 if (pci_dev->subordinate) 65 if (pci_dev->subordinate)
65 max = DEVICE_COUNT_RESOURCE; 66 max = DEVICE_COUNT_RESOURCE;
66 67
67 for (i = 0; i < max; i++) { 68 for (i = 0; i < max; i++) {
68 str += sprintf(str,"0x%016lx 0x%016lx 0x%016lx\n", 69 struct resource *res = &pci_dev->resource[i];
69 pci_resource_start(pci_dev,i), 70 pci_resource_to_user(pci_dev, i, res, &start, &end);
70 pci_resource_end(pci_dev,i), 71 str += sprintf(str,"0x%016llx 0x%016llx 0x%016llx\n",
71 pci_resource_flags(pci_dev,i)); 72 (unsigned long long)start,
73 (unsigned long long)end,
74 (unsigned long long)res->flags);
72 } 75 }
73 return (str - buf); 76 return (str - buf);
74} 77}
@@ -313,8 +316,21 @@ pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr,
313 struct device, kobj)); 316 struct device, kobj));
314 struct resource *res = (struct resource *)attr->private; 317 struct resource *res = (struct resource *)attr->private;
315 enum pci_mmap_state mmap_type; 318 enum pci_mmap_state mmap_type;
319 u64 start, end;
320 int i;
316 321
317 vma->vm_pgoff += res->start >> PAGE_SHIFT; 322 for (i = 0; i < PCI_ROM_RESOURCE; i++)
323 if (res == &pdev->resource[i])
324 break;
325 if (i >= PCI_ROM_RESOURCE)
326 return -ENODEV;
327
328 /* pci_mmap_page_range() expects the same kind of entry as coming
329 * from /proc/bus/pci/ which is a "user visible" value. If this is
330 * different from the resource itself, arch will do necessary fixup.
331 */
332 pci_resource_to_user(pdev, i, res, &start, &end);
333 vma->vm_pgoff += start >> PAGE_SHIFT;
318 mmap_type = res->flags & IORESOURCE_MEM ? pci_mmap_mem : pci_mmap_io; 334 mmap_type = res->flags & IORESOURCE_MEM ? pci_mmap_mem : pci_mmap_io;
319 335
320 return pci_mmap_page_range(pdev, vma, mmap_type, 0); 336 return pci_mmap_page_range(pdev, vma, mmap_type, 0);