aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/filesystems/sysfs-pci.txt3
-rw-r--r--arch/microblaze/include/asm/pci.h3
-rw-r--r--arch/powerpc/include/asm/pci.h1
-rw-r--r--arch/sparc/include/asm/pci_64.h1
-rw-r--r--arch/xtensa/include/asm/pci.h3
-rw-r--r--drivers/pci/pci-sysfs.c13
-rw-r--r--drivers/pci/proc.c11
-rw-r--r--include/linux/pci.h3
8 files changed, 26 insertions, 12 deletions
diff --git a/Documentation/filesystems/sysfs-pci.txt b/Documentation/filesystems/sysfs-pci.txt
index 25b7f1c1b868..46b95d82c4fd 100644
--- a/Documentation/filesystems/sysfs-pci.txt
+++ b/Documentation/filesystems/sysfs-pci.txt
@@ -119,7 +119,8 @@ useful return codes should be provided.
119 119
120Platforms which support write-combining maps of PCI resources must define 120Platforms which support write-combining maps of PCI resources must define
121arch_can_pci_mmap_wc() which shall evaluate to non-zero at runtime when 121arch_can_pci_mmap_wc() which shall evaluate to non-zero at runtime when
122write-combining is permitted. 122write-combining is permitted. Platforms which support maps of I/O resources
123define arch_can_pci_mmap_io() similarly.
123 124
124Legacy resources are protected by the HAVE_PCI_LEGACY define. Platforms 125Legacy resources are protected by the HAVE_PCI_LEGACY define. Platforms
125wishing to support legacy functionality should define it and provide 126wishing to support legacy functionality should define it and provide
diff --git a/arch/microblaze/include/asm/pci.h b/arch/microblaze/include/asm/pci.h
index ab381d283fb9..efd4983cb697 100644
--- a/arch/microblaze/include/asm/pci.h
+++ b/arch/microblaze/include/asm/pci.h
@@ -48,7 +48,8 @@ extern int pci_proc_domain(struct pci_bus *bus);
48struct vm_area_struct; 48struct vm_area_struct;
49 49
50/* Tell drivers/pci/proc.c that we have pci_mmap_page_range() */ 50/* Tell drivers/pci/proc.c that we have pci_mmap_page_range() */
51#define HAVE_PCI_MMAP 1 51#define HAVE_PCI_MMAP 1
52#define arch_can_pci_mmap_io() 1
52 53
53extern int pci_legacy_read(struct pci_bus *bus, loff_t port, u32 *val, 54extern int pci_legacy_read(struct pci_bus *bus, loff_t port, u32 *val,
54 size_t count); 55 size_t count);
diff --git a/arch/powerpc/include/asm/pci.h b/arch/powerpc/include/asm/pci.h
index 55887d171205..c8975dac535f 100644
--- a/arch/powerpc/include/asm/pci.h
+++ b/arch/powerpc/include/asm/pci.h
@@ -80,6 +80,7 @@ struct vm_area_struct;
80 80
81/* Tell drivers/pci/proc.c that we have pci_mmap_page_range() and it does WC */ 81/* Tell drivers/pci/proc.c that we have pci_mmap_page_range() and it does WC */
82#define HAVE_PCI_MMAP 1 82#define HAVE_PCI_MMAP 1
83#define arch_can_pci_mmap_io() 1
83#define arch_can_pci_mmap_wc() 1 84#define arch_can_pci_mmap_wc() 1
84 85
85extern int pci_legacy_read(struct pci_bus *bus, loff_t port, u32 *val, 86extern int pci_legacy_read(struct pci_bus *bus, loff_t port, u32 *val,
diff --git a/arch/sparc/include/asm/pci_64.h b/arch/sparc/include/asm/pci_64.h
index 516fda70a1bb..b957ca5527a3 100644
--- a/arch/sparc/include/asm/pci_64.h
+++ b/arch/sparc/include/asm/pci_64.h
@@ -42,6 +42,7 @@ static inline int pci_proc_domain(struct pci_bus *bus)
42/* Platform support for /proc/bus/pci/X/Y mmap()s. */ 42/* Platform support for /proc/bus/pci/X/Y mmap()s. */
43 43
44#define HAVE_PCI_MMAP 44#define HAVE_PCI_MMAP
45#define arch_can_pci_mmap_io() 1
45#define HAVE_ARCH_PCI_GET_UNMAPPED_AREA 46#define HAVE_ARCH_PCI_GET_UNMAPPED_AREA
46#define get_pci_unmapped_area get_fb_unmapped_area 47#define get_pci_unmapped_area get_fb_unmapped_area
47 48
diff --git a/arch/xtensa/include/asm/pci.h b/arch/xtensa/include/asm/pci.h
index bb5510b28754..e4f366a488d3 100644
--- a/arch/xtensa/include/asm/pci.h
+++ b/arch/xtensa/include/asm/pci.h
@@ -47,7 +47,8 @@ struct pci_dev;
47#define PCI_DMA_BUS_IS_PHYS (1) 47#define PCI_DMA_BUS_IS_PHYS (1)
48 48
49/* Tell drivers/pci/proc.c that we have pci_mmap_page_range() */ 49/* Tell drivers/pci/proc.c that we have pci_mmap_page_range() */
50#define HAVE_PCI_MMAP 1 50#define HAVE_PCI_MMAP 1
51#define arch_can_pci_mmap_io() 1
51 52
52#endif /* __KERNEL__ */ 53#endif /* __KERNEL__ */
53 54
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 7d494bd66a97..cb04bc29943f 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -1174,11 +1174,14 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
1174 } else { 1174 } else {
1175 pdev->res_attr[num] = res_attr; 1175 pdev->res_attr[num] = res_attr;
1176 sprintf(res_attr_name, "resource%d", num); 1176 sprintf(res_attr_name, "resource%d", num);
1177 res_attr->mmap = pci_mmap_resource_uc; 1177 if (pci_resource_flags(pdev, num) & IORESOURCE_IO) {
1178 } 1178 res_attr->read = pci_read_resource_io;
1179 if (pci_resource_flags(pdev, num) & IORESOURCE_IO) { 1179 res_attr->write = pci_write_resource_io;
1180 res_attr->read = pci_read_resource_io; 1180 if (arch_can_pci_mmap_io())
1181 res_attr->write = pci_write_resource_io; 1181 res_attr->mmap = pci_mmap_resource_uc;
1182 } else {
1183 res_attr->mmap = pci_mmap_resource_uc;
1184 }
1182 } 1185 }
1183 res_attr->attr.name = res_attr_name; 1186 res_attr->attr.name = res_attr_name;
1184 res_attr->attr.mode = S_IRUSR | S_IWUSR; 1187 res_attr->attr.mode = S_IRUSR | S_IWUSR;
diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
index a2aa58a8fb96..45e5cf7e9193 100644
--- a/drivers/pci/proc.c
+++ b/drivers/pci/proc.c
@@ -202,6 +202,8 @@ static long proc_bus_pci_ioctl(struct file *file, unsigned int cmd,
202 202
203#ifdef HAVE_PCI_MMAP 203#ifdef HAVE_PCI_MMAP
204 case PCIIOC_MMAP_IS_IO: 204 case PCIIOC_MMAP_IS_IO:
205 if (!arch_can_pci_mmap_io())
206 return -EINVAL;
205 fpriv->mmap_state = pci_mmap_io; 207 fpriv->mmap_state = pci_mmap_io;
206 break; 208 break;
207 209
@@ -232,15 +234,16 @@ static int proc_bus_pci_mmap(struct file *file, struct vm_area_struct *vma)
232{ 234{
233 struct pci_dev *dev = PDE_DATA(file_inode(file)); 235 struct pci_dev *dev = PDE_DATA(file_inode(file));
234 struct pci_filp_private *fpriv = file->private_data; 236 struct pci_filp_private *fpriv = file->private_data;
235 int i, ret, write_combine = 0, res_bit; 237 int i, ret, write_combine = 0, res_bit = IORESOURCE_MEM;
236 238
237 if (!capable(CAP_SYS_RAWIO)) 239 if (!capable(CAP_SYS_RAWIO))
238 return -EPERM; 240 return -EPERM;
239 241
240 if (fpriv->mmap_state == pci_mmap_io) 242 if (fpriv->mmap_state == pci_mmap_io) {
243 if (!arch_can_pci_mmap_io())
244 return -EINVAL;
241 res_bit = IORESOURCE_IO; 245 res_bit = IORESOURCE_IO;
242 else 246 }
243 res_bit = IORESOURCE_MEM;
244 247
245 /* Make sure the caller is mapping a real resource for this device */ 248 /* Make sure the caller is mapping a real resource for this device */
246 for (i = 0; i < PCI_ROM_RESOURCE; i++) { 249 for (i = 0; i < PCI_ROM_RESOURCE; i++) {
diff --git a/include/linux/pci.h b/include/linux/pci.h
index e7bb4b62cc97..590cfcf6acf5 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1636,6 +1636,9 @@ int pci_mmap_page_range(struct pci_dev *pdev, struct vm_area_struct *vma,
1636#ifndef arch_can_pci_mmap_wc 1636#ifndef arch_can_pci_mmap_wc
1637#define arch_can_pci_mmap_wc() 0 1637#define arch_can_pci_mmap_wc() 0
1638#endif 1638#endif
1639#ifndef arch_can_pci_mmap_io
1640#define arch_can_pci_mmap_io() 0
1641#endif
1639 1642
1640#ifndef pci_root_bus_fwnode 1643#ifndef pci_root_bus_fwnode
1641#define pci_root_bus_fwnode(bus) NULL 1644#define pci_root_bus_fwnode(bus) NULL