aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/platforms/book3s
diff options
context:
space:
mode:
authorHaren Myneni <haren@linux.ibm.com>2021-06-17 13:31:06 -0700
committerMichael Ellerman <mpe@ellerman.id.au>2021-06-20 21:58:55 +1000
commit1a0d0d5ed5e3cd9e3fc1ad4459f1db2f3618fce0 (patch)
tree5566fdcf67f14697769574fe07646191342a5f08 /arch/powerpc/platforms/book3s
parentpowerpc/powernv/vas: Rename register/unregister functions (diff)
downloadlinux-dev-1a0d0d5ed5e3cd9e3fc1ad4459f1db2f3618fce0.tar.xz
linux-dev-1a0d0d5ed5e3cd9e3fc1ad4459f1db2f3618fce0.zip
powerpc/vas: Add platform specific user window operations
PowerNV uses registers to open/close VAS windows, and getting the paste address. Whereas the hypervisor calls are used on PowerVM. This patch adds the platform specific user space window operations and register with the common VAS user space interface. Signed-off-by: Haren Myneni <haren@linux.ibm.com> Reviewed-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/f85091f4ace67f951ac04d60394d67b21e2f5d3c.camel@linux.ibm.com
Diffstat (limited to 'arch/powerpc/platforms/book3s')
-rw-r--r--arch/powerpc/platforms/book3s/vas-api.c53
1 files changed, 32 insertions, 21 deletions
diff --git a/arch/powerpc/platforms/book3s/vas-api.c b/arch/powerpc/platforms/book3s/vas-api.c
index 72c126d87216..ad566464b55b 100644
--- a/arch/powerpc/platforms/book3s/vas-api.c
+++ b/arch/powerpc/platforms/book3s/vas-api.c
@@ -42,6 +42,7 @@ static struct coproc_dev {
dev_t devt;
struct class *class;
enum vas_cop_type cop_type;
+ const struct vas_user_win_ops *vops;
} coproc_device;
struct coproc_instance {
@@ -72,11 +73,10 @@ static int coproc_open(struct inode *inode, struct file *fp)
static int coproc_ioc_tx_win_open(struct file *fp, unsigned long arg)
{
void __user *uptr = (void __user *)arg;
- struct vas_tx_win_attr txattr = {};
struct vas_tx_win_open_attr uattr;
struct coproc_instance *cp_inst;
struct vas_window *txwin;
- int rc, vasid;
+ int rc;
cp_inst = fp->private_data;
@@ -93,27 +93,20 @@ static int coproc_ioc_tx_win_open(struct file *fp, unsigned long arg)
}
if (uattr.version != 1) {
- pr_err("Invalid version\n");
+ pr_err("Invalid window open API version\n");
return -EINVAL;
}
- vasid = uattr.vas_id;
-
- vas_init_tx_win_attr(&txattr, cp_inst->coproc->cop_type);
-
- txattr.lpid = mfspr(SPRN_LPID);
- txattr.pidr = mfspr(SPRN_PID);
- txattr.user_win = true;
- txattr.rsvd_txbuf_count = false;
- txattr.pswid = false;
-
- pr_devel("Pid %d: Opening txwin, PIDR %ld\n", txattr.pidr,
- mfspr(SPRN_PID));
+ if (!cp_inst->coproc->vops && !cp_inst->coproc->vops->open_win) {
+ pr_err("VAS API is not registered\n");
+ return -EACCES;
+ }
- txwin = vas_tx_win_open(vasid, cp_inst->coproc->cop_type, &txattr);
+ txwin = cp_inst->coproc->vops->open_win(uattr.vas_id, uattr.flags,
+ cp_inst->coproc->cop_type);
if (IS_ERR(txwin)) {
- pr_err("%s() vas_tx_win_open() failed, %ld\n", __func__,
- PTR_ERR(txwin));
+ pr_err("%s() VAS window open failed, %ld\n", __func__,
+ PTR_ERR(txwin));
return PTR_ERR(txwin);
}
@@ -125,9 +118,15 @@ static int coproc_ioc_tx_win_open(struct file *fp, unsigned long arg)
static int coproc_release(struct inode *inode, struct file *fp)
{
struct coproc_instance *cp_inst = fp->private_data;
+ int rc;
if (cp_inst->txwin) {
- vas_win_close(cp_inst->txwin);
+ if (cp_inst->coproc->vops &&
+ cp_inst->coproc->vops->close_win) {
+ rc = cp_inst->coproc->vops->close_win(cp_inst->txwin);
+ if (rc)
+ return rc;
+ }
cp_inst->txwin = NULL;
}
@@ -168,7 +167,17 @@ static int coproc_mmap(struct file *fp, struct vm_area_struct *vma)
return -EINVAL;
}
- vas_win_paste_addr(txwin, &paste_addr, NULL);
+ if (!cp_inst->coproc->vops && !cp_inst->coproc->vops->paste_addr) {
+ pr_err("%s(): VAS API is not registered\n", __func__);
+ return -EACCES;
+ }
+
+ paste_addr = cp_inst->coproc->vops->paste_addr(txwin);
+ if (!paste_addr) {
+ pr_err("%s(): Window paste address failed\n", __func__);
+ return -EINVAL;
+ }
+
pfn = paste_addr >> PAGE_SHIFT;
/* flags, page_prot from cxl_mmap(), except we want cachable */
@@ -208,7 +217,8 @@ static struct file_operations coproc_fops = {
* extended to other coprocessor types later.
*/
int vas_register_coproc_api(struct module *mod, enum vas_cop_type cop_type,
- const char *name)
+ const char *name,
+ const struct vas_user_win_ops *vops)
{
int rc = -EINVAL;
dev_t devno;
@@ -230,6 +240,7 @@ int vas_register_coproc_api(struct module *mod, enum vas_cop_type cop_type,
}
coproc_device.class->devnode = coproc_devnode;
coproc_device.cop_type = cop_type;
+ coproc_device.vops = vops;
coproc_fops.owner = mod;
cdev_init(&coproc_device.cdev, &coproc_fops);