diff mbox

[v2] PCI: Remove sysfs resource mmap warning

Message ID 20171130163557.19488.80756.stgit@bhelgaas-glaptop.roam.corp.google.com (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show

Commit Message

Bjorn Helgaas Nov. 30, 2017, 4:35 p.m. UTC
From: Bjorn Helgaas <bhelgaas@google.com>

When a process uses sysfs and tries to mmap more space than is available in
a PCI BAR, we emit a warning and a backtrace.  The mmap fails anyway, so
the backtrace is mainly for debugging.  But in general we don't emit kernel
messages when syscalls return failure.

The similar procfs mmap path simply fails the mmap with no warning.  Remove
the sysfs warning.

Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/pci-sysfs.c |    9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

Comments

Bjorn Helgaas Dec. 4, 2017, 10:33 p.m. UTC | #1
On Thu, Nov 30, 2017 at 10:35:57AM -0600, Bjorn Helgaas wrote:
> From: Bjorn Helgaas <bhelgaas@google.com>
> 
> When a process uses sysfs and tries to mmap more space than is available in
> a PCI BAR, we emit a warning and a backtrace.  The mmap fails anyway, so
> the backtrace is mainly for debugging.  But in general we don't emit kernel
> messages when syscalls return failure.
> 
> The similar procfs mmap path simply fails the mmap with no warning.  Remove
> the sysfs warning.
> 
> Reported-by: Fengguang Wu <fengguang.wu@intel.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

Applied to pci/resource for v4.16.

> ---
>  drivers/pci/pci-sysfs.c |    9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
> index 06c7f0b85cd2..ccc0e28c6678 100644
> --- a/drivers/pci/pci-sysfs.c
> +++ b/drivers/pci/pci-sysfs.c
> @@ -1216,14 +1216,9 @@ static int pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr,
>  	if (res->flags & IORESOURCE_MEM && iomem_is_exclusive(res->start))
>  		return -EINVAL;
>  
> -	if (!pci_mmap_fits(pdev, bar, vma, PCI_MMAP_SYSFS)) {
> -		WARN(1, "process \"%s\" tried to map 0x%08lx bytes at page 0x%08lx on %s BAR %d (start 0x%16Lx, size 0x%16Lx)\n",
> -			current->comm, vma->vm_end-vma->vm_start, vma->vm_pgoff,
> -			pci_name(pdev), bar,
> -			(u64)pci_resource_start(pdev, bar),
> -			(u64)pci_resource_len(pdev, bar));
> +	if (!pci_mmap_fits(pdev, bar, vma, PCI_MMAP_SYSFS))
>  		return -EINVAL;
> -	}
> +
>  	mmap_type = res->flags & IORESOURCE_MEM ? pci_mmap_mem : pci_mmap_io;
>  
>  	return pci_mmap_resource_range(pdev, bar, vma, mmap_type, write_combine);
>
diff mbox

Patch

diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 06c7f0b85cd2..ccc0e28c6678 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -1216,14 +1216,9 @@  static int pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr,
 	if (res->flags & IORESOURCE_MEM && iomem_is_exclusive(res->start))
 		return -EINVAL;
 
-	if (!pci_mmap_fits(pdev, bar, vma, PCI_MMAP_SYSFS)) {
-		WARN(1, "process \"%s\" tried to map 0x%08lx bytes at page 0x%08lx on %s BAR %d (start 0x%16Lx, size 0x%16Lx)\n",
-			current->comm, vma->vm_end-vma->vm_start, vma->vm_pgoff,
-			pci_name(pdev), bar,
-			(u64)pci_resource_start(pdev, bar),
-			(u64)pci_resource_len(pdev, bar));
+	if (!pci_mmap_fits(pdev, bar, vma, PCI_MMAP_SYSFS))
 		return -EINVAL;
-	}
+
 	mmap_type = res->flags & IORESOURCE_MEM ? pci_mmap_mem : pci_mmap_io;
 
 	return pci_mmap_resource_range(pdev, bar, vma, mmap_type, write_combine);