rpmsg updates for 5.10

This introduces rpmsg_char support for GLINK and fixes a few issues.
 -----BEGIN PGP SIGNATURE-----
 
 iQJPBAABCAA5FiEEBd4DzF816k8JZtUlCx85Pw2ZrcUFAl+Rs8wbHGJqb3JuLmFu
 ZGVyc3NvbkBsaW5hcm8ub3JnAAoJEAsfOT8Nma3FlfYP/2DiXRaxn9JaDCXLeexW
 bGAWWFV1yp4FF2TGKZ0CuwQsbAL2fZKdMlzbzQzXVUzlcb5rKNXhIU5WyDSav1Vw
 3ytfI4dyoQagQLWt0aGCrANkb4s7dOecz2TawgAJlVtOy9wG9u7bGPqnfjX9YmJR
 3P4XAqDT2u3MLygytPy/qJNK+xMDrtXqmut4dN90ltE0DsiaqtvSXrk0dUos1m0x
 3cD7pC0qAi8NwbBOWtslX5u0ph56yRBpubXBDiWFBhwyxLBAMGRdcprzUeEJc079
 kmcfXm+A6Qt96FqhdO2ZnH9xalARV5vgidQQWOLmMneUlHp0z8r79LFXxgkrxKVo
 jYOA4Y1b6Dx/zn+0XwgQ1DpadMCvy/qsl/n/wOVUBH/6t7Gbjc7xEnOrc0BGk/t8
 vagPPEYRue725SYS5NPXfJA9wsmSjkNqIeN8dwkOFvPZ3h4pf+gMN/Yks8WjA0Y/
 VhvwJCYO/KuOlt+HDkFxM0xYMqHqFuZVR2EdMrjtEzmCnG+oWzZPC1xyilyWnMPU
 fwFmOrYkwnI9Lcrunn7xIIl/oTK6fF5u1vaEcaXr2g78F0KQNaV1XOCdmJcTYCw+
 SC16wpijHhNdpMBP9SIFGUF/lSSEplcG5/tWKZb35DLcOGqS1VCYSQlWkqA06MYv
 915jnSIzU32s00LDiYyRxpKe
 =fv8T
 -----END PGP SIGNATURE-----

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()
This commit is contained in:
Linus Torvalds 2020-10-22 12:58:21 -07:00
commit 60573c2966
5 changed files with 97 additions and 23 deletions

View File

@ -200,7 +200,6 @@ static int mtk_rpmsg_register_device(struct mtk_rpmsg_rproc_subdev *mtk_subdev,
struct rpmsg_device *rpdev;
struct mtk_rpmsg_device *mdev;
struct platform_device *pdev = mtk_subdev->pdev;
int ret;
mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
if (!mdev)
@ -219,13 +218,7 @@ static int mtk_rpmsg_register_device(struct mtk_rpmsg_rproc_subdev *mtk_subdev,
rpdev->dev.parent = &pdev->dev;
rpdev->dev.release = mtk_rpmsg_release_device;
ret = rpmsg_register_device(rpdev);
if (ret) {
kfree(mdev);
return ret;
}
return 0;
return rpmsg_register_device(rpdev);
}
static void mtk_register_device_work_function(struct work_struct *register_work)

View File

@ -970,7 +970,7 @@ static int qcom_glink_rx_open_ack(struct qcom_glink *glink, unsigned int lcid)
return -EINVAL;
}
complete(&channel->open_ack);
complete_all(&channel->open_ack);
return 0;
}
@ -1178,7 +1178,7 @@ static int qcom_glink_announce_create(struct rpmsg_device *rpdev)
__be32 *val = defaults;
int size;
if (glink->intentless)
if (glink->intentless || !completion_done(&channel->open_ack))
return 0;
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,
channel->rcid = ret;
spin_unlock_irqrestore(&glink->idr_lock, flags);
complete(&channel->open_req);
complete_all(&channel->open_req);
if (create_device) {
rpdev = kzalloc(sizeof(*rpdev), GFP_KERNEL);
@ -1574,6 +1574,60 @@ static void qcom_glink_cancel_rx_work(struct qcom_glink *glink)
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,
unsigned long features,
struct qcom_glink_pipe *rx,
@ -1604,6 +1658,12 @@ struct qcom_glink *qcom_glink_native_probe(struct device *dev,
idr_init(&glink->lcids);
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);
if (ret < 0)
glink->name = dev->of_node->name;
@ -1633,6 +1693,10 @@ struct qcom_glink *qcom_glink_native_probe(struct device *dev,
if (ret)
return ERR_PTR(ret);
ret = qcom_glink_create_chrdev(glink);
if (ret)
dev_err(glink->dev, "failed to register chrdev\n");
return glink;
}
EXPORT_SYMBOL_GPL(qcom_glink_native_probe);

View File

@ -1338,7 +1338,7 @@ static int qcom_smd_parse_edge(struct device *dev,
ret = of_property_read_u32(node, key, &edge->edge_id);
if (ret) {
dev_err(dev, "edge missing %s property\n", key);
return -EINVAL;
goto put_node;
}
edge->remote_pid = QCOM_SMEM_HOST_ANY;
@ -1349,32 +1349,37 @@ static int qcom_smd_parse_edge(struct device *dev,
edge->mbox_client.knows_txdone = true;
edge->mbox_chan = mbox_request_channel(&edge->mbox_client, 0);
if (IS_ERR(edge->mbox_chan)) {
if (PTR_ERR(edge->mbox_chan) != -ENODEV)
return PTR_ERR(edge->mbox_chan);
if (PTR_ERR(edge->mbox_chan) != -ENODEV) {
ret = PTR_ERR(edge->mbox_chan);
goto put_node;
}
edge->mbox_chan = NULL;
syscon_np = of_parse_phandle(node, "qcom,ipc", 0);
if (!syscon_np) {
dev_err(dev, "no qcom,ipc node\n");
return -ENODEV;
ret = -ENODEV;
goto put_node;
}
edge->ipc_regmap = syscon_node_to_regmap(syscon_np);
if (IS_ERR(edge->ipc_regmap))
return PTR_ERR(edge->ipc_regmap);
if (IS_ERR(edge->ipc_regmap)) {
ret = PTR_ERR(edge->ipc_regmap);
goto put_node;
}
key = "qcom,ipc";
ret = of_property_read_u32_index(node, key, 1, &edge->ipc_offset);
if (ret < 0) {
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);
if (ret < 0) {
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,
irq = irq_of_parse_and_map(node, 0);
if (irq < 0) {
dev_err(dev, "required smd interrupt missing\n");
return -EINVAL;
ret = irq;
goto put_node;
}
ret = devm_request_irq(dev, irq,
@ -1393,12 +1399,18 @@ static int qcom_smd_parse_edge(struct device *dev,
node->name, edge);
if (ret) {
dev_err(dev, "failed to request smd irq\n");
return ret;
goto put_node;
}
edge->irq = irq;
return 0;
put_node:
of_node_put(node);
edge->of_node = NULL;
return ret;
}
/*

View File

@ -81,7 +81,7 @@ EXPORT_SYMBOL(rpmsg_create_ept);
*/
void rpmsg_destroy_ept(struct rpmsg_endpoint *ept)
{
if (ept)
if (ept && ept->ops)
ept->ops->destroy_ept(ept);
}
EXPORT_SYMBOL(rpmsg_destroy_ept);

View File

@ -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 rpmsg_device rpdev;