rpmsg updates for v4.20

This migrates rpmsg_char to use read/write_iter to allow being operated
 using aio, removes the message size alignment requirements from glink,
 closes a potential memory leak in SMD and switches to %pOFn for printing
 device_node names.
 -----BEGIN PGP SIGNATURE-----
 
 iQJPBAABCAA5FiEEBd4DzF816k8JZtUlCx85Pw2ZrcUFAlvXlykbHGJqb3JuLmFu
 ZGVyc3NvbkBsaW5hcm8ub3JnAAoJEAsfOT8Nma3FJOIP/jjGmI2WM+PIsSRajGQA
 zQSTTo2stXhglSE+0HpZ7kOxQC+7BUg3Do7DOUx3g/qT2qIIYdGnsqGGJT2Pg8Pq
 /AtkrPIYoF2uJlREqKrnwNwWEDIHIEFNVKEma2q/4o3COqkqvCCzv8kSKhLqr63I
 YHe5dEiGxndd/9RfmT540bSzYgWYbOZmb1j5f85vqKfiVAtquxApqByzocUgS1AJ
 zz34/HBMOtVw+SAxklcm8n5VlDCBmXg+UBTlWlENFPsJ3RBoVIqpE5a6zrrHcQlD
 Je5jvhfuCsfeYVYCawtqXjbevxuIIz+K/IH5qqUixEnwZmXMt/8b6AuAPgKdtsVN
 T43W/o1WEn2FoIlsnyETsNlwX9FtBrej0hwMFWZsKtbQKqeJgJ1l6vyUOh6qGWGU
 K36rFkO+jY1GenqROhBrowVupNHC9VmZzlacAC+6nmlohtxpKD8coQYtWfH+n5Wh
 2qD+w8OEdQv6AKPdFRroWS3d3TEBQwrQBS5n7tE1bdeu4atIlZGTosFqKWNBJHWq
 5B+lSfm1yiZ2iJY1ELMr7jmMXWwQC5iWUGTpttNx0rI4OnjwFzj0QdS0BdpBOWUt
 BzcmyA23AlW01Nb1b+/peFSvPTJJrkeI8mpfmbJ6GKmlg61x2QPl2CFdlpT0ppd+
 Fj/qze8SS2VOettPu6n22wTB
 =4P1z
 -----END PGP SIGNATURE-----

Merge tag 'rpmsg-v4.20' of git://github.com/andersson/remoteproc

Pull rpmsg updates from Bjorn Andersson:
 "This migrates rpmsg_char to use read/write_iter to allow being
  operated using aio, removes the message size alignment requirements
  from glink, closes a potential memory leak in SMD and switches to
  %pOFn for printing device_node names"

* tag 'rpmsg-v4.20' of git://github.com/andersson/remoteproc:
  rpmsg: glink: smem: Support rx peak for size less than 4 bytes
  rpmsg: smd: fix memory leak on channel create
  rpmsg: glink: Remove chunk size word align warning
  rpmsg: Convert to using %pOFn instead of device_node.name
  rpmsg: char: Migrate to iter versions of read and write
This commit is contained in:
Linus Torvalds 2018-10-29 17:10:03 -07:00
commit 11743c5678
4 changed files with 27 additions and 26 deletions

View File

@ -792,9 +792,6 @@ static int qcom_glink_rx_data(struct qcom_glink *glink, size_t avail)
return -EAGAIN;
}
if (WARN(chunk_size % 4, "Incoming data must be word aligned\n"))
return -EINVAL;
rcid = le16_to_cpu(hdr.msg.param1);
spin_lock_irqsave(&glink->idr_lock, flags);
channel = idr_find(&glink->rcids, rcid);

View File

@ -89,15 +89,11 @@ static void glink_smem_rx_peak(struct qcom_glink_pipe *np,
tail -= pipe->native.length;
len = min_t(size_t, count, pipe->native.length - tail);
if (len) {
__ioread32_copy(data, pipe->fifo + tail,
len / sizeof(u32));
}
if (len)
memcpy_fromio(data, pipe->fifo + tail, len);
if (len != count) {
__ioread32_copy(data + len, pipe->fifo,
(count - len) / sizeof(u32));
}
if (len != count)
memcpy_fromio(data + len, pipe->fifo, (count - len));
}
static void glink_smem_rx_advance(struct qcom_glink_pipe *np,
@ -205,7 +201,7 @@ struct qcom_glink *qcom_glink_smem_register(struct device *parent,
dev->parent = parent;
dev->of_node = node;
dev->release = qcom_glink_smem_release;
dev_set_name(dev, "%s:%s", node->parent->name, node->name);
dev_set_name(dev, "%pOFn:%pOFn", node->parent, node);
ret = device_register(dev);
if (ret) {
pr_err("failed to register glink edge\n");

View File

@ -1122,8 +1122,10 @@ static struct qcom_smd_channel *qcom_smd_create_channel(struct qcom_smd_edge *ed
channel->edge = edge;
channel->name = kstrdup(name, GFP_KERNEL);
if (!channel->name)
return ERR_PTR(-ENOMEM);
if (!channel->name) {
ret = -ENOMEM;
goto free_channel;
}
spin_lock_init(&channel->tx_lock);
spin_lock_init(&channel->recv_lock);
@ -1173,6 +1175,7 @@ static struct qcom_smd_channel *qcom_smd_create_channel(struct qcom_smd_edge *ed
free_name_and_channel:
kfree(channel->name);
free_channel:
kfree(channel);
return ERR_PTR(ret);
@ -1454,7 +1457,7 @@ struct qcom_smd_edge *qcom_smd_register_edge(struct device *parent,
edge->dev.release = qcom_smd_edge_release;
edge->dev.of_node = node;
edge->dev.groups = qcom_smd_edge_groups;
dev_set_name(&edge->dev, "%s:%s", dev_name(parent), node->name);
dev_set_name(&edge->dev, "%s:%pOFn", dev_name(parent), node);
ret = device_register(&edge->dev);
if (ret) {
pr_err("failed to register smd edge\n");

View File

@ -167,9 +167,9 @@ static int rpmsg_eptdev_release(struct inode *inode, struct file *filp)
return 0;
}
static ssize_t rpmsg_eptdev_read(struct file *filp, char __user *buf,
size_t len, loff_t *f_pos)
static ssize_t rpmsg_eptdev_read_iter(struct kiocb *iocb, struct iov_iter *to)
{
struct file *filp = iocb->ki_filp;
struct rpmsg_eptdev *eptdev = filp->private_data;
unsigned long flags;
struct sk_buff *skb;
@ -205,8 +205,8 @@ static ssize_t rpmsg_eptdev_read(struct file *filp, char __user *buf,
if (!skb)
return -EFAULT;
use = min_t(size_t, len, skb->len);
if (copy_to_user(buf, skb->data, use))
use = min_t(size_t, iov_iter_count(to), skb->len);
if (copy_to_iter(skb->data, use, to) != use)
use = -EFAULT;
kfree_skb(skb);
@ -214,16 +214,21 @@ static ssize_t rpmsg_eptdev_read(struct file *filp, char __user *buf,
return use;
}
static ssize_t rpmsg_eptdev_write(struct file *filp, const char __user *buf,
size_t len, loff_t *f_pos)
static ssize_t rpmsg_eptdev_write_iter(struct kiocb *iocb,
struct iov_iter *from)
{
struct file *filp = iocb->ki_filp;
struct rpmsg_eptdev *eptdev = filp->private_data;
size_t len = iov_iter_count(from);
void *kbuf;
int ret;
kbuf = memdup_user(buf, len);
if (IS_ERR(kbuf))
return PTR_ERR(kbuf);
kbuf = kzalloc(len, GFP_KERNEL);
if (!kbuf)
return -ENOMEM;
if (!copy_from_iter_full(kbuf, len, from))
return -EFAULT;
if (mutex_lock_interruptible(&eptdev->ept_lock)) {
ret = -ERESTARTSYS;
@ -281,8 +286,8 @@ static const struct file_operations rpmsg_eptdev_fops = {
.owner = THIS_MODULE,
.open = rpmsg_eptdev_open,
.release = rpmsg_eptdev_release,
.read = rpmsg_eptdev_read,
.write = rpmsg_eptdev_write,
.read_iter = rpmsg_eptdev_read_iter,
.write_iter = rpmsg_eptdev_write_iter,
.poll = rpmsg_eptdev_poll,
.unlocked_ioctl = rpmsg_eptdev_ioctl,
.compat_ioctl = rpmsg_eptdev_ioctl,