From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: linuxppc-dev@lists.ozlabs.org
Cc: kvm@vger.kernel.org, Alexey Kardashevskiy <aik@ozlabs.ru>,
Alistair Popple <alistair@popple.id.au>,
kvm-ppc@vger.kernel.org,
Alex Williamson <alex.williamson@redhat.com>,
Reza Arbab <arbab@linux.ibm.com>,
David Gibson <david@gibson.dropbear.id.au>
Subject: [PATCH kernel 1/3] vfio_pci: Allow mapping extra regions
Date: Mon, 15 Oct 2018 20:42:31 +1100 [thread overview]
Message-ID: <20181015094233.1324-2-aik@ozlabs.ru> (raw)
In-Reply-To: <20181015094233.1324-1-aik@ozlabs.ru>
So far we only allowed mapping of MMIO BARs to the userspace. However
there there are GPUs with on-board coherent RAM accessible via side
channels which we also want to map to the userspace. The first client
for this is NVIDIA V100 GPU with NVLink2 direct links to a POWER9
NPU-enabled CPU; such GPUs have 16GB RAM which is coherently mapped
to the system address space, we are going to export these as an extra
PCI region.
We already support extra PCI regions and this adds support for mapping
them to the userspace.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
Changes:
v2:
* reverted one of mistakenly removed error checks
---
drivers/vfio/pci/vfio_pci_private.h | 3 +++
drivers/vfio/pci/vfio_pci.c | 8 ++++++++
2 files changed, 11 insertions(+)
diff --git a/drivers/vfio/pci/vfio_pci_private.h b/drivers/vfio/pci/vfio_pci_private.h
index cde3b5d..86aab05 100644
--- a/drivers/vfio/pci/vfio_pci_private.h
+++ b/drivers/vfio/pci/vfio_pci_private.h
@@ -59,6 +59,9 @@ struct vfio_pci_regops {
size_t count, loff_t *ppos, bool iswrite);
void (*release)(struct vfio_pci_device *vdev,
struct vfio_pci_region *region);
+ int (*mmap)(struct vfio_pci_device *vdev,
+ struct vfio_pci_region *region,
+ struct vm_area_struct *vma);
};
struct vfio_pci_region {
diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
index d9af440..7923314 100644
--- a/drivers/vfio/pci/vfio_pci.c
+++ b/drivers/vfio/pci/vfio_pci.c
@@ -1126,6 +1126,14 @@ static int vfio_pci_mmap(void *device_data, struct vm_area_struct *vma)
return -EINVAL;
if ((vma->vm_flags & VM_SHARED) == 0)
return -EINVAL;
+ if (index >= VFIO_PCI_NUM_REGIONS) {
+ int regnum = index - VFIO_PCI_NUM_REGIONS;
+ struct vfio_pci_region *region = vdev->region + regnum;
+
+ if (region && region->ops && region->ops->mmap)
+ return region->ops->mmap(vdev, region, vma);
+ return -EINVAL;
+ }
if (index >= VFIO_PCI_ROM_REGION_INDEX)
return -EINVAL;
if (!vdev->bar_mmap_supported[index])
--
2.11.0
next prev parent reply other threads:[~2018-10-15 9:59 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-15 9:42 [PATCH kernel 0/3] vfio/spapr_tce: Reworks for NVIDIA V100 + P9 passthrough (part 3) Alexey Kardashevskiy
2018-10-15 9:42 ` Alexey Kardashevskiy [this message]
2018-11-08 6:04 ` [PATCH kernel 1/3] vfio_pci: Allow mapping extra regions David Gibson
2018-10-15 9:42 ` [PATCH kernel 2/3] vfio_pci: Allow regions to add own capabilities Alexey Kardashevskiy
2018-11-08 6:21 ` David Gibson
2018-11-08 6:48 ` Alexey Kardashevskiy
2018-11-08 7:16 ` David Gibson
2018-10-15 9:42 ` [PATCH kernel 3/3] vfio_pci: Add NVIDIA GV100GL [Tesla V100 SXM2] [10de:1db1] subdriver Alexey Kardashevskiy
2018-10-16 19:08 ` Alex Williamson
2018-10-17 1:19 ` Alexey Kardashevskiy
2018-10-17 21:52 ` Alex Williamson
2018-10-17 23:42 ` Piotr Jaroszyński
2018-10-18 0:31 ` Alexey Kardashevskiy
2018-10-18 16:55 ` Alex Williamson
2018-10-18 17:37 ` Piotr Jaroszynski
2018-10-18 18:05 ` Alex Williamson
2018-10-18 18:40 ` Piotr Jaroszynski
2018-10-19 6:25 ` Christoph Hellwig
2018-10-19 0:53 ` Alexey Kardashevskiy
2018-11-12 1:08 ` David Gibson
2018-11-12 2:36 ` Alexey Kardashevskiy
2018-11-12 4:23 ` David Gibson
2018-11-12 4:56 ` Alexey Kardashevskiy
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=20181015094233.1324-2-aik@ozlabs.ru \
--to=aik@ozlabs.ru \
--cc=alex.williamson@redhat.com \
--cc=alistair@popple.id.au \
--cc=arbab@linux.ibm.com \
--cc=david@gibson.dropbear.id.au \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
/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;
as well as URLs for NNTP newsgroup(s).