Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1715197

[PATCH 3.2 27/59] PCI: Ignore write combining when mapping I/O port space

From Ben Hutchings <ben@decadent.org.uk>
Newsgroups linux.kernel
Subject [PATCH 3.2 27/59] PCI: Ignore write combining when mapping I/O port space
Date 2017-08-18 16:30 +0200
Message-ID <ufQrG-4YI-61@gated-at.bofh.it> (permalink)
References <ufPlU-4d0-25@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


3.2.92-rc1 review patch.  If anyone has any objections, please let me know.

------------------

From: Bjorn Helgaas <bhelgaas@google.com>

commit 3a92c319c44a7bcee9f48dff9d97d001943b54c6 upstream.

PCI exposes files like /proc/bus/pci/00/00.0 in procfs.  These files
support operations like this:

  ioctl(fd, PCIIOC_MMAP_IS_IO);           # request I/O port space
  ioctl(fd, PCIIOC_WRITE_COMBINE, 1);     # request write-combining
  mmap(fd, ...)

Write combining is useful on PCI memory space, but I don't think it makes
sense on PCI I/O port space.

We *could* change proc_bus_pci_ioctl() to make it impossible to set
mmap_state == pci_mmap_io and write_combine at the same time, but that
would break the following sequence, which is currently legal:

  mmap(fd, ...)                           # default is I/O, non-combining
  ioctl(fd, PCIIOC_WRITE_COMBINE, 1);     # request write-combining
  ioctl(fd, PCIIOC_MMAP_IS_MEM);          # request memory space
  mmap(fd, ...)                           # get write-combining mapping

Ignore the write-combining flag when mapping I/O port space.

This patch should have no functional effect, based on this analysis of all
implementations of pci_mmap_page_range():

  - ia64 mips parisc sh unicore32 x86 do not support mapping of I/O port
    space at all.

  - arm cris microblaze mn10300 sparc xtensa support mapping of I/O port
    space, but ignore the write_combine argument to pci_mmap_page_range().

  - powerpc supports mapping of I/O port space and uses write_combine, and
    it disables write combining for I/O port space in
    __pci_mmap_set_pgprot().

This patch makes it possible to remove __pci_mmap_set_pgprot() from
powerpc, which simplifies that path.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
 drivers/pci/proc.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

--- a/drivers/pci/proc.c
+++ b/drivers/pci/proc.c
@@ -249,7 +249,7 @@ static int proc_bus_pci_mmap(struct file
 	const struct proc_dir_entry *dp = PDE(inode);
 	struct pci_dev *dev = dp->data;
 	struct pci_filp_private *fpriv = file->private_data;
-	int i, ret;
+	int i, ret, write_combine;
 
 	if (!capable(CAP_SYS_RAWIO))
 		return -EPERM;
@@ -263,9 +263,12 @@ static int proc_bus_pci_mmap(struct file
 	if (i >= PCI_ROM_RESOURCE)
 		return -ENODEV;
 
+	if (fpriv->mmap_state == pci_mmap_mem)
+		write_combine = fpriv->write_combine;
+	else
+		write_combine = 0;
 	ret = pci_mmap_page_range(dev, vma,
-				  fpriv->mmap_state,
-				  fpriv->write_combine);
+				  fpriv->mmap_state, write_combine);
 	if (ret < 0)
 		return ret;
 

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 3.2 00/59] 3.2.92-rc1 review Ben Hutchings <ben@decadent.org.uk> - 2017-08-18 16:30 +0200
  [PATCH 3.2 35/59] [media] dw2102: limit messages to buffer size Ben Hutchings <ben@decadent.org.uk> - 2017-08-18 16:30 +0200
  [PATCH 3.2 24/59] PCI: Fix pci_mmap_fits() for HAVE_PCI_RESOURCE_TO_USER  platforms Ben Hutchings <ben@decadent.org.uk> - 2017-08-18 16:30 +0200
  [PATCH 3.2 17/59] [media] gspca: konica: add missing endpoint  sanity check Ben Hutchings <ben@decadent.org.uk> - 2017-08-18 16:30 +0200
  [PATCH 3.2 13/59] [media] mceusb: fix NULL-deref at probe Ben Hutchings <ben@decadent.org.uk> - 2017-08-18 16:30 +0200
  [PATCH 3.2 20/59] [media] cx231xx-cards: fix NULL-deref at probe Ben Hutchings <ben@decadent.org.uk> - 2017-08-18 16:30 +0200
  [PATCH 3.2 32/59] [media] ttusb2: limit messages to buffer size Ben Hutchings <ben@decadent.org.uk> - 2017-08-18 16:30 +0200
  [PATCH 3.2 02/59] [media] pvrusb2: reduce stack usage  pvr2_eeprom_analyze() Ben Hutchings <ben@decadent.org.uk> - 2017-08-18 16:30 +0200
  [PATCH 3.2 22/59] [media] cx231xx-audio: fix NULL-deref at probe Ben Hutchings <ben@decadent.org.uk> - 2017-08-18 16:30 +0200
  [PATCH 3.2 04/59] ath9k_htc: Add PID/VID for a Ubiquiti WiFiStation Ben Hutchings <ben@decadent.org.uk> - 2017-08-18 16:30 +0200
  [PATCH 3.2 10/59] zd1211rw: fix NULL-deref at probe Ben Hutchings <ben@decadent.org.uk> - 2017-08-18 16:30 +0200
  [PATCH 3.2 27/59] PCI: Ignore write combining when mapping I/O  port space Ben Hutchings <ben@decadent.org.uk> - 2017-08-18 16:30 +0200
  [PATCH 3.2 06/59] ath9k_htc: Add new USB ID Ben Hutchings <ben@decadent.org.uk> - 2017-08-18 16:30 +0200
  [PATCH 3.2 25/59] [media] digitv: limit messages to buffer size Ben Hutchings <ben@decadent.org.uk> - 2017-08-18 16:30 +0200
  [PATCH 3.2 18/59] [media] usbvision: fix NULL-deref at probe Ben Hutchings <ben@decadent.org.uk> - 2017-08-18 16:30 +0200
  Re: [PATCH 3.2 00/59] 3.2.92-rc1 review Guenter Roeck <linux@roeck-us.net> - 2017-08-18 17:00 +0200

csiph-web