From: Bjorn Helgaas <helgaas@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
Myron Stowe <myron.stowe@redhat.com>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: mmap/munmap in sysfs
Date: Tue, 25 Jun 2019 17:36:08 -0500 [thread overview]
Message-ID: <20190625223608.GB103694@google.com> (raw)
Hi Greg, et al,
Userspace can mmap PCI device memory via the resourceN files in sysfs,
which use pci_mmap_resource(). I think this path is unaware of power
management, so the device may be runtime-suspended, e.g., it may be in
D1, D2, or D3, where it will not respond to memory accesses.
Userspace accesses while the device is suspended will cause PCI
errors, so I think we need something like the patch below. But this
isn't sufficient by itself because we would need a corresponding
pm_runtime_put() when the mapping goes away. Where should that go?
Or is there a better way to do this?
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 6d27475e39b2..aab7a47679a7 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -1173,6 +1173,7 @@ static int pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr,
mmap_type = res->flags & IORESOURCE_MEM ? pci_mmap_mem : pci_mmap_io;
+ pm_runtime_get_sync(pdev);
return pci_mmap_resource_range(pdev, bar, vma, mmap_type, write_combine);
}
next reply other threads:[~2019-06-25 22:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-25 22:36 Bjorn Helgaas [this message]
2019-06-26 1:07 ` mmap/munmap in sysfs Greg Kroah-Hartman
2019-06-26 11:06 ` Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190625223608.GB103694@google.com \
--to=helgaas@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=myron.stowe@redhat.com \
--cc=rjw@rjwysocki.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox