From: Vaibhav Jain <vaibhav@linux.vnet.ibm.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: Vaibhav Jain <vaibhav@linux.vnet.ibm.com>,
Frederic Barrat <fbarrat@linux.vnet.ibm.com>,
Andrew Donnellan <andrew.donnellan@au1.ibm.com>,
Ian Munsie <imunsie@au1.ibm.com>,
Christophe Lombard <christophe_lombard@fr.ibm.com>,
Philippe Bergheaud <philippe.bergheaud@fr.ibm.com>,
Greg Kurz <gkurz@linux.vnet.ibm.com>
Subject: [PATCH 3/3] cxl: Provide user-space access to afu descriptor on bare metal
Date: Tue, 14 Mar 2017 09:36:06 +0530 [thread overview]
Message-ID: <20170314040606.16894-4-vaibhav@linux.vnet.ibm.com> (raw)
In-Reply-To: <20170314040606.16894-1-vaibhav@linux.vnet.ibm.com>
This patch implements cxl backend to provide user-space access to
binary afu descriptor contents via sysfs. We add a new member to
struct cxl_afu_native named phy_desc that caches the physical base
address of afu descriptor, which is then used in implementation of new
native cxl backend ops namel:
* native_afu_desc_size()
* native_afu_desc_read()
* native_afu_desc_mmap()
The implementations of all these callbacks is mostly trivial except
native_afu_desc_mmap() which maps the PFNs pointing to afu descriptor
in i/o memory, to user-space vm_area_struct.
Signed-off-by: Vaibhav Jain <vaibhav@linux.vnet.ibm.com>
---
drivers/misc/cxl/cxl.h | 3 +++
drivers/misc/cxl/native.c | 33 +++++++++++++++++++++++++++++++++
drivers/misc/cxl/pci.c | 3 +++
3 files changed, 39 insertions(+)
diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h
index 1c43d06..c6db1fa 100644
--- a/drivers/misc/cxl/cxl.h
+++ b/drivers/misc/cxl/cxl.h
@@ -386,6 +386,9 @@ struct cxl_afu_native {
int spa_order;
int spa_max_procs;
u64 pp_offset;
+
+ /* Afu descriptor physical address */
+ u64 phy_desc;
};
struct cxl_afu_guest {
diff --git a/drivers/misc/cxl/native.c b/drivers/misc/cxl/native.c
index 20d3df6..44e3e84 100644
--- a/drivers/misc/cxl/native.c
+++ b/drivers/misc/cxl/native.c
@@ -1330,6 +1330,36 @@ static ssize_t native_afu_read_err_buffer(struct cxl_afu *afu, char *buf,
return __aligned_memcpy(buf, ebuf, off, count, afu->eb_len);
}
+static ssize_t native_afu_desc_size(struct cxl_afu *afu)
+{
+ return afu->adapter->native->afu_desc_size;
+}
+
+static ssize_t native_afu_desc_read(struct cxl_afu *afu, char *buf, loff_t off,
+ size_t count)
+{
+ return __aligned_memcpy(buf, afu->native->afu_desc_mmio, off, count,
+ afu->adapter->native->afu_desc_size);
+}
+
+static int native_afu_desc_mmap(struct cxl_afu *afu, struct file *filp,
+ struct vm_area_struct *vma)
+{
+ u64 len = vma->vm_end - vma->vm_start;
+
+ /* Check the size vma so that it doesn't go beyond afud size */
+ if (len > native_afu_desc_size(afu)) {
+ pr_err("Requested VMA too large. Requested=%lld, Available=%ld\n",
+ len, native_afu_desc_size(afu));
+ return -EINVAL;
+ }
+
+ vma->vm_flags |= VM_IO | VM_PFNMAP;
+ vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+
+ return vm_iomap_memory(vma, afu->native->phy_desc, len);
+}
+
const struct cxl_backend_ops cxl_native_ops = {
.module = THIS_MODULE,
.adapter_reset = cxl_pci_reset,
@@ -1361,4 +1391,7 @@ const struct cxl_backend_ops cxl_native_ops = {
.afu_cr_write16 = native_afu_cr_write16,
.afu_cr_write32 = native_afu_cr_write32,
.read_adapter_vpd = cxl_pci_read_adapter_vpd,
+ .afu_desc_read = native_afu_desc_read,
+ .afu_desc_mmap = native_afu_desc_mmap,
+ .afu_desc_size = native_afu_desc_size
};
diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c
index 541dc9a..a6166e0 100644
--- a/drivers/misc/cxl/pci.c
+++ b/drivers/misc/cxl/pci.c
@@ -869,6 +869,9 @@ static int pci_map_slice_regs(struct cxl_afu *afu, struct cxl *adapter, struct p
if (afu_desc) {
if (!(afu->native->afu_desc_mmio = ioremap(afu_desc, adapter->native->afu_desc_size)))
goto err2;
+
+ /* Cache the afu descriptor physical address */
+ afu->native->phy_desc = afu_desc;
}
return 0;
--
2.9.3
prev parent reply other threads:[~2017-03-14 4:07 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-14 4:06 [PATCH 0/3] cxl: Provide user-space r/o access to the AFU descriptor Vaibhav Jain
2017-03-14 4:06 ` [PATCH 1/3] cxl: Re-factor cxl_pci_afu_read_err_buffer() Vaibhav Jain
2017-03-17 4:34 ` Andrew Donnellan
2017-03-21 4:38 ` Vaibhav Jain
2017-03-17 10:51 ` Frederic Barrat
2017-03-14 4:06 ` [PATCH 2/3] cxl: Introduce afu_desc sysfs attribute Vaibhav Jain
2017-03-17 11:19 ` Frederic Barrat
2017-03-21 5:07 ` Vaibhav Jain
2017-03-20 7:42 ` Andrew Donnellan
2017-03-14 4:06 ` Vaibhav Jain [this message]
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=20170314040606.16894-4-vaibhav@linux.vnet.ibm.com \
--to=vaibhav@linux.vnet.ibm.com \
--cc=andrew.donnellan@au1.ibm.com \
--cc=christophe_lombard@fr.ibm.com \
--cc=fbarrat@linux.vnet.ibm.com \
--cc=gkurz@linux.vnet.ibm.com \
--cc=imunsie@au1.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=philippe.bergheaud@fr.ibm.com \
/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).