Commit 8e4d138c authored by Dmitry Kalinkin's avatar Dmitry Kalinkin Committed by Greg Kroah-Hartman

staging: vme_user: allow large read()/write()

This changes large master transfers to do shorter read/write rather than
return -EINVAL. User space will now be able to optimistically request a
large transfer and get at least some data.

This also removes comments suggesting on how to implement large
transfers. Current vme_master_* read and write implementations use CPU
copies that don't produce burst PCI accesses and subsequently no block
transfer on VME bus. In the end overall performance is quiet low and it
can't be fixed by doing direct copy to user space. Much easier solution
would be to just reuse kernel buffer.
Signed-off-by: default avatarDmitry Kalinkin <dmitry.kalinkin@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 1f0622de
...@@ -120,22 +120,18 @@ struct vme_user_vma_priv { ...@@ -120,22 +120,18 @@ struct vme_user_vma_priv {
atomic_t refcnt; atomic_t refcnt;
}; };
/*
* We are going ot alloc a page during init per window for small transfers.
* Small transfers will go VME -> buffer -> user space. Larger (more than a
* page) transfers will lock the user space buffer into memory and then
* transfer the data directly into the user space buffers.
*/
static ssize_t resource_to_user(int minor, char __user *buf, size_t count, static ssize_t resource_to_user(int minor, char __user *buf, size_t count,
loff_t *ppos) loff_t *ppos)
{ {
ssize_t retval; ssize_t retval;
ssize_t copied = 0; ssize_t copied = 0;
if (count <= image[minor].size_buf) { if (count > image[minor].size_buf)
count = image[minor].size_buf;
/* We copy to kernel buffer */ /* We copy to kernel buffer */
copied = vme_master_read(image[minor].resource, copied = vme_master_read(image[minor].resource, image[minor].kern_buf,
image[minor].kern_buf, count, *ppos); count, *ppos);
if (copied < 0) if (copied < 0)
return (int)copied; return (int)copied;
...@@ -147,31 +143,18 @@ static ssize_t resource_to_user(int minor, char __user *buf, size_t count, ...@@ -147,31 +143,18 @@ static ssize_t resource_to_user(int minor, char __user *buf, size_t count,
return -EINVAL; return -EINVAL;
} }
} else {
/* XXX Need to write this */
pr_info("Currently don't support large transfers\n");
/* Map in pages from userspace */
/* Call vme_master_read to do the transfer */
return -EINVAL;
}
return copied; return copied;
} }
/*
* We are going to alloc a page during init per window for small transfers.
* Small transfers will go user space -> buffer -> VME. Larger (more than a
* page) transfers will lock the user space buffer into memory and then
* transfer the data directly from the user space buffers out to VME.
*/
static ssize_t resource_from_user(unsigned int minor, const char __user *buf, static ssize_t resource_from_user(unsigned int minor, const char __user *buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
ssize_t retval; ssize_t retval;
ssize_t copied = 0; ssize_t copied = 0;
if (count <= image[minor].size_buf) { if (count > image[minor].size_buf)
count = image[minor].size_buf;
retval = __copy_from_user(image[minor].kern_buf, buf, retval = __copy_from_user(image[minor].kern_buf, buf,
(unsigned long)count); (unsigned long)count);
if (retval != 0) if (retval != 0)
...@@ -179,16 +162,8 @@ static ssize_t resource_from_user(unsigned int minor, const char __user *buf, ...@@ -179,16 +162,8 @@ static ssize_t resource_from_user(unsigned int minor, const char __user *buf,
else else
copied = count; copied = count;
copied = vme_master_write(image[minor].resource, copied = vme_master_write(image[minor].resource, image[minor].kern_buf,
image[minor].kern_buf, copied, *ppos); copied, *ppos);
} else {
/* XXX Need to write this */
pr_info("Currently don't support large transfers\n");
/* Map in pages from userspace */
/* Call vme_master_write to do the transfer */
return -EINVAL;
}
return copied; return copied;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment