Commit 60573c29 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'rpmsg-v5.10' of git://git.kernel.org/pub/scm/linux/kernel/git/andersson/remoteproc

Pull rpmsg updates from Bjorn Andersson:
 "This introduces rpmsg_char support for GLINK and fixes a few issues"

* tag 'rpmsg-v5.10' of git://git.kernel.org/pub/scm/linux/kernel/git/andersson/remoteproc:
  rpmsg: glink: Expose rpmsg name attr for glink
  rpmsg: glink: Add support for rpmsg glink chrdev
  rpmsg: Guard against null endpoint ops in destroy
  rpmsg: glink: Use complete_all for open states
  rpmsg: virtio: fix compilation warning for virtio_rpmsg_channel description
  rpmsg: Avoid double-free in mtk_rpmsg_register_device
  rpmsg: smd: Fix a kobj leak in in qcom_smd_parse_edge()
parents 1553d968 4e3dda0b
...@@ -200,7 +200,6 @@ static int mtk_rpmsg_register_device(struct mtk_rpmsg_rproc_subdev *mtk_subdev, ...@@ -200,7 +200,6 @@ static int mtk_rpmsg_register_device(struct mtk_rpmsg_rproc_subdev *mtk_subdev,
struct rpmsg_device *rpdev; struct rpmsg_device *rpdev;
struct mtk_rpmsg_device *mdev; struct mtk_rpmsg_device *mdev;
struct platform_device *pdev = mtk_subdev->pdev; struct platform_device *pdev = mtk_subdev->pdev;
int ret;
mdev = kzalloc(sizeof(*mdev), GFP_KERNEL); mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
if (!mdev) if (!mdev)
...@@ -219,13 +218,7 @@ static int mtk_rpmsg_register_device(struct mtk_rpmsg_rproc_subdev *mtk_subdev, ...@@ -219,13 +218,7 @@ static int mtk_rpmsg_register_device(struct mtk_rpmsg_rproc_subdev *mtk_subdev,
rpdev->dev.parent = &pdev->dev; rpdev->dev.parent = &pdev->dev;
rpdev->dev.release = mtk_rpmsg_release_device; rpdev->dev.release = mtk_rpmsg_release_device;
ret = rpmsg_register_device(rpdev); return rpmsg_register_device(rpdev);
if (ret) {
kfree(mdev);
return ret;
}
return 0;
} }
static void mtk_register_device_work_function(struct work_struct *register_work) static void mtk_register_device_work_function(struct work_struct *register_work)
......
...@@ -970,7 +970,7 @@ static int qcom_glink_rx_open_ack(struct qcom_glink *glink, unsigned int lcid) ...@@ -970,7 +970,7 @@ static int qcom_glink_rx_open_ack(struct qcom_glink *glink, unsigned int lcid)
return -EINVAL; return -EINVAL;
} }
complete(&channel->open_ack); complete_all(&channel->open_ack);
return 0; return 0;
} }
...@@ -1178,7 +1178,7 @@ static int qcom_glink_announce_create(struct rpmsg_device *rpdev) ...@@ -1178,7 +1178,7 @@ static int qcom_glink_announce_create(struct rpmsg_device *rpdev)
__be32 *val = defaults; __be32 *val = defaults;
int size; int size;
if (glink->intentless) if (glink->intentless || !completion_done(&channel->open_ack))
return 0; return 0;
prop = of_find_property(np, "qcom,intents", NULL); prop = of_find_property(np, "qcom,intents", NULL);
...@@ -1413,7 +1413,7 @@ static int qcom_glink_rx_open(struct qcom_glink *glink, unsigned int rcid, ...@@ -1413,7 +1413,7 @@ static int qcom_glink_rx_open(struct qcom_glink *glink, unsigned int rcid,
channel->rcid = ret; channel->rcid = ret;
spin_unlock_irqrestore(&glink->idr_lock, flags); spin_unlock_irqrestore(&glink->idr_lock, flags);
complete(&channel->open_req); complete_all(&channel->open_req);
if (create_device) { if (create_device) {
rpdev = kzalloc(sizeof(*rpdev), GFP_KERNEL); rpdev = kzalloc(sizeof(*rpdev), GFP_KERNEL);
...@@ -1574,6 +1574,60 @@ static void qcom_glink_cancel_rx_work(struct qcom_glink *glink) ...@@ -1574,6 +1574,60 @@ static void qcom_glink_cancel_rx_work(struct qcom_glink *glink)
kfree(dcmd); kfree(dcmd);
} }
static ssize_t rpmsg_name_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
int ret = 0;
const char *name;
ret = of_property_read_string(dev->of_node, "label", &name);
if (ret < 0)
name = dev->of_node->name;
return snprintf(buf, RPMSG_NAME_SIZE, "%s\n", name);
}
static DEVICE_ATTR_RO(rpmsg_name);
static struct attribute *qcom_glink_attrs[] = {
&dev_attr_rpmsg_name.attr,
NULL
};
ATTRIBUTE_GROUPS(qcom_glink);
static void qcom_glink_device_release(struct device *dev)
{
struct rpmsg_device *rpdev = to_rpmsg_device(dev);
struct glink_channel *channel = to_glink_channel(rpdev->ept);
/* Release qcom_glink_alloc_channel() reference */
kref_put(&channel->refcount, qcom_glink_channel_release);
kfree(rpdev);
}
static int qcom_glink_create_chrdev(struct qcom_glink *glink)
{
struct rpmsg_device *rpdev;
struct glink_channel *channel;
rpdev = kzalloc(sizeof(*rpdev), GFP_KERNEL);
if (!rpdev)
return -ENOMEM;
channel = qcom_glink_alloc_channel(glink, "rpmsg_chrdev");
if (IS_ERR(channel)) {
kfree(rpdev);
return PTR_ERR(channel);
}
channel->rpdev = rpdev;
rpdev->ept = &channel->ept;
rpdev->ops = &glink_device_ops;
rpdev->dev.parent = glink->dev;
rpdev->dev.release = qcom_glink_device_release;
return rpmsg_chrdev_register_device(rpdev);
}
struct qcom_glink *qcom_glink_native_probe(struct device *dev, struct qcom_glink *qcom_glink_native_probe(struct device *dev,
unsigned long features, unsigned long features,
struct qcom_glink_pipe *rx, struct qcom_glink_pipe *rx,
...@@ -1604,6 +1658,12 @@ struct qcom_glink *qcom_glink_native_probe(struct device *dev, ...@@ -1604,6 +1658,12 @@ struct qcom_glink *qcom_glink_native_probe(struct device *dev,
idr_init(&glink->lcids); idr_init(&glink->lcids);
idr_init(&glink->rcids); idr_init(&glink->rcids);
glink->dev->groups = qcom_glink_groups;
ret = device_add_groups(dev, qcom_glink_groups);
if (ret)
dev_err(dev, "failed to add groups\n");
ret = of_property_read_string(dev->of_node, "label", &glink->name); ret = of_property_read_string(dev->of_node, "label", &glink->name);
if (ret < 0) if (ret < 0)
glink->name = dev->of_node->name; glink->name = dev->of_node->name;
...@@ -1633,6 +1693,10 @@ struct qcom_glink *qcom_glink_native_probe(struct device *dev, ...@@ -1633,6 +1693,10 @@ struct qcom_glink *qcom_glink_native_probe(struct device *dev,
if (ret) if (ret)
return ERR_PTR(ret); return ERR_PTR(ret);
ret = qcom_glink_create_chrdev(glink);
if (ret)
dev_err(glink->dev, "failed to register chrdev\n");
return glink; return glink;
} }
EXPORT_SYMBOL_GPL(qcom_glink_native_probe); EXPORT_SYMBOL_GPL(qcom_glink_native_probe);
......
...@@ -1338,7 +1338,7 @@ static int qcom_smd_parse_edge(struct device *dev, ...@@ -1338,7 +1338,7 @@ static int qcom_smd_parse_edge(struct device *dev,
ret = of_property_read_u32(node, key, &edge->edge_id); ret = of_property_read_u32(node, key, &edge->edge_id);
if (ret) { if (ret) {
dev_err(dev, "edge missing %s property\n", key); dev_err(dev, "edge missing %s property\n", key);
return -EINVAL; goto put_node;
} }
edge->remote_pid = QCOM_SMEM_HOST_ANY; edge->remote_pid = QCOM_SMEM_HOST_ANY;
...@@ -1349,32 +1349,37 @@ static int qcom_smd_parse_edge(struct device *dev, ...@@ -1349,32 +1349,37 @@ static int qcom_smd_parse_edge(struct device *dev,
edge->mbox_client.knows_txdone = true; edge->mbox_client.knows_txdone = true;
edge->mbox_chan = mbox_request_channel(&edge->mbox_client, 0); edge->mbox_chan = mbox_request_channel(&edge->mbox_client, 0);
if (IS_ERR(edge->mbox_chan)) { if (IS_ERR(edge->mbox_chan)) {
if (PTR_ERR(edge->mbox_chan) != -ENODEV) if (PTR_ERR(edge->mbox_chan) != -ENODEV) {
return PTR_ERR(edge->mbox_chan); ret = PTR_ERR(edge->mbox_chan);
goto put_node;
}
edge->mbox_chan = NULL; edge->mbox_chan = NULL;
syscon_np = of_parse_phandle(node, "qcom,ipc", 0); syscon_np = of_parse_phandle(node, "qcom,ipc", 0);
if (!syscon_np) { if (!syscon_np) {
dev_err(dev, "no qcom,ipc node\n"); dev_err(dev, "no qcom,ipc node\n");
return -ENODEV; ret = -ENODEV;
goto put_node;
} }
edge->ipc_regmap = syscon_node_to_regmap(syscon_np); edge->ipc_regmap = syscon_node_to_regmap(syscon_np);
if (IS_ERR(edge->ipc_regmap)) if (IS_ERR(edge->ipc_regmap)) {
return PTR_ERR(edge->ipc_regmap); ret = PTR_ERR(edge->ipc_regmap);
goto put_node;
}
key = "qcom,ipc"; key = "qcom,ipc";
ret = of_property_read_u32_index(node, key, 1, &edge->ipc_offset); ret = of_property_read_u32_index(node, key, 1, &edge->ipc_offset);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "no offset in %s\n", key); dev_err(dev, "no offset in %s\n", key);
return -EINVAL; goto put_node;
} }
ret = of_property_read_u32_index(node, key, 2, &edge->ipc_bit); ret = of_property_read_u32_index(node, key, 2, &edge->ipc_bit);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "no bit in %s\n", key); dev_err(dev, "no bit in %s\n", key);
return -EINVAL; goto put_node;
} }
} }
...@@ -1385,7 +1390,8 @@ static int qcom_smd_parse_edge(struct device *dev, ...@@ -1385,7 +1390,8 @@ static int qcom_smd_parse_edge(struct device *dev,
irq = irq_of_parse_and_map(node, 0); irq = irq_of_parse_and_map(node, 0);
if (irq < 0) { if (irq < 0) {
dev_err(dev, "required smd interrupt missing\n"); dev_err(dev, "required smd interrupt missing\n");
return -EINVAL; ret = irq;
goto put_node;
} }
ret = devm_request_irq(dev, irq, ret = devm_request_irq(dev, irq,
...@@ -1393,12 +1399,18 @@ static int qcom_smd_parse_edge(struct device *dev, ...@@ -1393,12 +1399,18 @@ static int qcom_smd_parse_edge(struct device *dev,
node->name, edge); node->name, edge);
if (ret) { if (ret) {
dev_err(dev, "failed to request smd irq\n"); dev_err(dev, "failed to request smd irq\n");
return ret; goto put_node;
} }
edge->irq = irq; edge->irq = irq;
return 0; return 0;
put_node:
of_node_put(node);
edge->of_node = NULL;
return ret;
} }
/* /*
......
...@@ -81,7 +81,7 @@ EXPORT_SYMBOL(rpmsg_create_ept); ...@@ -81,7 +81,7 @@ EXPORT_SYMBOL(rpmsg_create_ept);
*/ */
void rpmsg_destroy_ept(struct rpmsg_endpoint *ept) void rpmsg_destroy_ept(struct rpmsg_endpoint *ept)
{ {
if (ept) if (ept && ept->ops)
ept->ops->destroy_ept(ept); ept->ops->destroy_ept(ept);
} }
EXPORT_SYMBOL(rpmsg_destroy_ept); EXPORT_SYMBOL(rpmsg_destroy_ept);
......
...@@ -123,7 +123,12 @@ enum rpmsg_ns_flags { ...@@ -123,7 +123,12 @@ enum rpmsg_ns_flags {
}; };
/** /**
* @vrp: the remote processor this channel belongs to * struct virtio_rpmsg_channel - rpmsg channel descriptor
* @rpdev: the rpmsg channel device
* @vrp: the virtio remote processor device this channel belongs to
*
* This structure stores the channel that links the rpmsg device to the virtio
* remote processor device.
*/ */
struct virtio_rpmsg_channel { struct virtio_rpmsg_channel {
struct rpmsg_device rpdev; struct rpmsg_device rpdev;
......
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