Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1606477 > unrolled thread
| Started by | David Woodhouse <dwmw2@infradead.org> |
|---|---|
| First post | 2017-03-22 14:30 +0100 |
| Last post | 2017-03-24 18:10 +0100 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 03/17] pci: Only allow WC mmap on prefetchable resources David Woodhouse <dwmw2@infradead.org> - 2017-03-22 14:30 +0100
Re: [PATCH 03/17] pci: Only allow WC mmap on prefetchable resources Arnd Bergmann <arnd@arndb.de> - 2017-03-24 17:10 +0100
Re: [PATCH 03/17] pci: Only allow WC mmap on prefetchable resources David Woodhouse <dwmw2@infradead.org> - 2017-03-24 18:10 +0100
| From | David Woodhouse <dwmw2@infradead.org> |
|---|---|
| Date | 2017-03-22 14:30 +0100 |
| Subject | [PATCH 03/17] pci: Only allow WC mmap on prefetchable resources |
| Message-ID | <tnOuS-32T-25@gated-at.bofh.it> |
From: David Woodhouse <dwmw@amazon.co.uk>
The /proc/bus/pci mmap interface allows the user to specify whether they
want WC or not. Don't let them do so on non-prefetchable BARs.
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Cc: stable@vger.kernel.org
---
drivers/pci/proc.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
index 62a0c3e..dc8912e 100644
--- a/drivers/pci/proc.c
+++ b/drivers/pci/proc.c
@@ -231,7 +231,7 @@ static int proc_bus_pci_mmap(struct file *file, struct vm_area_struct *vma)
{
struct pci_dev *dev = PDE_DATA(file_inode(file));
struct pci_filp_private *fpriv = file->private_data;
- int i, ret, write_combine, res_bit;
+ int i, ret, write_combine = 0, res_bit;
if (!capable(CAP_SYS_RAWIO))
return -EPERM;
@@ -251,10 +251,13 @@ static int proc_bus_pci_mmap(struct file *file, struct vm_area_struct *vma)
if (i >= PCI_ROM_RESOURCE)
return -ENODEV;
- if (fpriv->mmap_state == pci_mmap_mem)
- write_combine = fpriv->write_combine;
- else
- write_combine = 0;
+ if (fpriv->mmap_state == pci_mmap_mem &&
+ fpriv->write_combine) {
+ if (dev->resource[i].flags & IORESOURCE_PREFETCH)
+ write_combine = 1;
+ else
+ return -EINVAL;
+ }
ret = pci_mmap_page_range(dev, vma,
fpriv->mmap_state, write_combine);
if (ret < 0)
--
2.9.3
[toc] | [next] | [standalone]
| From | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| Date | 2017-03-24 17:10 +0100 |
| Message-ID | <tozWO-44H-35@gated-at.bofh.it> |
| In reply to | #1606477 |
On Wed, Mar 22, 2017 at 2:25 PM, David Woodhouse <dwmw2@infradead.org> wrote:
> From: David Woodhouse <dwmw@amazon.co.uk>
>
> The /proc/bus/pci mmap interface allows the user to specify whether they
> want WC or not. Don't let them do so on non-prefetchable BARs.
>
> Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
> Cc: stable@vger.kernel.org
Can you explain this a little more? I understand that we usually want to use
WC mappings on prefetchable BARs, and uncached non-WC on
non-prefetchable, but why do we have to force an error here?
Couldn't there be some hardware that allows write-combining access
but no prefetches?
Arnd
[toc] | [prev] | [next] | [standalone]
| From | David Woodhouse <dwmw2@infradead.org> |
|---|---|
| Date | 2017-03-24 18:10 +0100 |
| Message-ID | <toASS-4Ki-17@gated-at.bofh.it> |
| In reply to | #1608611 |
[Multipart message — attachments visible in raw view] — view raw
On Fri, 2017-03-24 at 17:05 +0100, Arnd Bergmann wrote: > On Wed, Mar 22, 2017 at 2:25 PM, David Woodhouse <dwmw2@infradead.org> wrote: > > > > From: David Woodhouse <dwmw@amazon.co.uk> > > > > The /proc/bus/pci mmap interface allows the user to specify whether they > > want WC or not. Don't let them do so on non-prefetchable BARs. > > > > Signed-off-by: David Woodhouse <dwmw@amazon.co.uk> > > Cc: stable@vger.kernel.org > Can you explain this a little more? I understand that we usually want to use > WC mappings on prefetchable BARs, and uncached non-WC on > non-prefetchable, but why do we have to force an error here? > > Couldn't there be some hardware that allows write-combining access > but no prefetches? Note that this is only for the procfs interface. The sysfs interface already imposes the same restriction by just *not* creating the 'resourceX_wc' attr when the resource isn't prefetchable. So this just brings procfs into line.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web