Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Date: Mon, 19 Nov 2018 11:00:22 -0700
- Subject: [PATCH] Added sysfs files to enable/disable logging dynamically for
- RPMSG related functionality. Disabled by default for performance reasons.
- ---
- arch/arm/mach-imx/mu.c | 46 ++++++++++++--
- drivers/rpmsg/imx_rpmsg.c | 79 ++++++++++++++++++------
- drivers/rpmsg/imx_rpmsg_tty.c | 47 ++++++++++++---
- drivers/rpmsg/virtio_rpmsg_bus.c | 127 +++++++++++++++++++++++++++++----------
- 4 files changed, 236 insertions(+), 63 deletions(-)
- diff --git a/arch/arm/mach-imx/mu.c b/arch/arm/mach-imx/mu.c
- index 7088d07..394ffef 100644
- --- a/arch/arm/mach-imx/mu.c
- +++ b/arch/arm/mach-imx/mu.c
- @@ -65,6 +65,7 @@ struct irq_domain *domain;
- static bool m4_in_stop;
- static struct clk *clk;
- static DEFINE_SPINLOCK(mu_lock);
- +static bool logging_enabled = true;
- void imx_mu_set_m4_run_mode(void)
- {
- @@ -165,7 +166,7 @@ static int imx_mu_send_message(unsigned int index, unsigned int data)
- break;
- }
- }
- - if (te_flag == 0)
- + if (te_flag == 0 && logging_enabled)
- pr_info("BUG: TEn is not changed immediately"
- "when ATRn is filled up.\n");
- @@ -184,7 +185,9 @@ static void mu_work_handler(struct work_struct *work)
- message = m4_message[out_idx % MAX_NUM];
- spin_unlock_irqrestore(&mu_lock, flags);
- - pr_debug("receive M4 message 0x%x\n", message);
- + if (logging_enabled) {
- + pr_debug("receive M4 message 0x%x\n", message);
- + }
- switch (message) {
- case MU_LPM_M4_RUN_MODE:
- @@ -342,8 +345,10 @@ int imx_mu_rpmsg_reset(const struct device *dev)
- /* Monitor bit7(BRS) of MU_ASR to know when reset sequence has ended */
- do {
- val = readl_relaxed(mu_base + MU_ASR);
- - dev_dbg(dev, "Waiting for ASR bit7 to go low. ASR: 0x%x\n",
- - val);
- + if (logging_enabled) {
- + dev_dbg(dev, "Waiting for ASR bit7 to go low. ASR: 0x%x\n",
- + val);
- + }
- val &= BIT(7);
- } while (val);
- @@ -388,7 +393,9 @@ static ssize_t reset_store(struct device *dev, struct device_attribute *attr,
- return -EINVAL;
- }
- - dev_info(dev, "MU Reset\n");
- + if (logging_enabled) {
- + dev_info(dev, "MU Reset\n");
- + }
- imx_mu_rpmsg_reset(dev);
- return count;
- }
- @@ -464,11 +471,24 @@ static int imx_mu_probe(struct platform_device *pdev)
- writel_relaxed(readl_relaxed(mu_base + MU_ACR) |
- BIT(26) | BIT(27), mu_base + MU_ACR);
- - pr_info("MU is ready for cross core communication!\n");
- + if (logging_enabled) {
- + pr_info("MU is ready for cross core communication!\n");
- + }
- return 0;
- }
- +static ssize_t show_log_level(struct device* dev, struct device_attribute* attr, char* buf)
- +{
- + return scnprintf(buf, PAGE_SIZE, "%s\n", logging_enabled ? "0" : "1");
- +}
- +
- +static ssize_t toggle_log_level(struct device* dev, struct device_attribute* attr, const char* buf, size_t count)
- +{
- + logging_enabled = logging_enabled ? false : true;
- + return count;
- +}
- +
- static const struct of_device_id imx_mu_ids[] = {
- { .compatible = "fsl,imx6sx-mu" },
- { .compatible = "fsl,imx7d-mu" },
- @@ -476,6 +496,19 @@ static const struct of_device_id imx_mu_ids[] = {
- { }
- };
- +static DEVICE_ATTR(log_enabled, 0644, show_log_level, toggle_log_level);
- +static struct attribute* dev_attrs[] = {
- + &dev_attr_log_enabled.attr,
- + NULL,
- +};
- +static struct attribute_group dev_attr_group = {
- + .attrs = dev_attrs,
- +};
- +static const struct attribute_group* dev_attr_groups[] = {
- + &dev_attr_group,
- + NULL,
- +};
- +
- #ifdef CONFIG_PM_SLEEP
- static int mu_suspend(struct device *dev)
- {
- @@ -503,6 +536,7 @@ static struct platform_driver imx_mu_driver = {
- .owner = THIS_MODULE,
- .pm = &mu_pm_ops,
- .of_match_table = imx_mu_ids,
- + .groups = dev_attr_groups,
- },
- .probe = imx_mu_probe,
- };
- diff --git a/drivers/rpmsg/imx_rpmsg.c b/drivers/rpmsg/imx_rpmsg.c
- index d63e353..2b9b81b 100644
- --- a/drivers/rpmsg/imx_rpmsg.c
- +++ b/drivers/rpmsg/imx_rpmsg.c
- @@ -105,6 +105,8 @@ struct imx_rpmsg_vq_info {
- struct imx_rpmsg_vproc *rpdev;
- };
- +static bool logging_enabled = true;
- +
- static u64 imx_rpmsg_get_features(struct virtio_device *vdev)
- {
- /* VIRTIO_RPMSG_F_NS has been made private */
- @@ -141,11 +143,15 @@ static int imx_mu_rpmsg_callback(struct notifier_block *this,
- virdev = container_of(this, struct imx_virdev, nb);
- - pr_debug("%s mu_msg: 0x%x\n", __func__, mu_msg);
- + if (logging_enabled) {
- + dev_info(&virdev->vdev.dev, "%s mu_msg: 0x%x\n", __func__, mu_msg);
- + }
- /* ignore vq indices which are clearly not for us */
- mu_msg = mu_msg >> 16;
- if (mu_msg < virdev->base_vq_id || mu_msg > virdev->base_vq_id + 1) {
- - pr_debug("mu_msg: 0x%x is invalid\n", mu_msg);
- + if (logging_enabled) {
- + dev_info(&virdev->vdev.dev, "mu_msg: 0x%x is invalid\n", mu_msg);
- + }
- return NOTIFY_DONE;
- }
- @@ -216,14 +222,16 @@ static struct virtqueue *rp_find_vq(struct virtio_device *vdev,
- memset(rpvq->addr, 0, RPMSG_RING_SIZE);
- - pr_debug("vring%d: phys 0x%x, virt 0x%p\n", index, virdev->vring[index],
- + if (logging_enabled) {
- + dev_info(&vdev->dev, "vring%d: phys 0x%x, virt 0x%p\n", index, virdev->vring[index],
- rpvq->addr);
- + }
- vq = vring_new_virtqueue(index, RPMSG_NUM_BUFS / 2, RPMSG_VRING_ALIGN,
- vdev, true, rpvq->addr, imx_rpmsg_notify, callback,
- name);
- if (!vq) {
- - pr_err("vring_new_virtqueue failed\n");
- + dev_err(&vdev->dev, "vring_new_virtqueue failed\n");
- err = -ENOMEM;
- goto unmap_vring;
- }
- @@ -301,7 +309,9 @@ static int imx_rpmsg_find_vqs(struct virtio_device *vdev, unsigned int nvqs,
- static void imx_rpmsg_reset(struct virtio_device *vdev)
- {
- - dev_dbg(&vdev->dev, "reset !\n");
- + if (logging_enabled) {
- + dev_dbg(&vdev->dev, "reset !\n");
- + }
- }
- static u8 imx_rpmsg_get_status(struct virtio_device *vdev)
- @@ -311,7 +321,9 @@ static u8 imx_rpmsg_get_status(struct virtio_device *vdev)
- static void imx_rpmsg_set_status(struct virtio_device *vdev, u8 status)
- {
- - dev_dbg(&vdev->dev, "%s new status: %d\n", __func__, status);
- + if (logging_enabled) {
- + dev_dbg(&vdev->dev, "%s new status: %d\n", __func__, status);
- + }
- }
- static void imx_rpmsg_vproc_release(struct device *dev)
- @@ -440,8 +452,8 @@ static int imx_rpmsg_probe(struct platform_device *pdev)
- /* Initialize the mu unit used by rpmsg */
- np_mu = of_find_compatible_node(NULL, NULL, "fsl,imx6sx-mu");
- - if (!np_mu)
- - pr_info("Cannot find MU-RPMSG entry in device tree\n");
- + if (!np_mu && logging_enabled)
- + dev_info(dev, "Cannot find MU-RPMSG entry in device tree\n");
- mu_base = of_iomap(np_mu, 0);
- WARN_ON(!mu_base);
- @@ -454,7 +466,7 @@ static int imx_rpmsg_probe(struct platform_device *pdev)
- IRQF_EARLY_RESUME | IRQF_SHARED,
- "imx-mu-rpmsg", dev);
- if (ret) {
- - pr_err("%s: register interrupt %d failed, rc %d\n",
- + dev_err(dev, "%s: register interrupt %d failed, rc %d\n",
- __func__, irq, ret);
- return ret;
- }
- @@ -462,12 +474,12 @@ static int imx_rpmsg_probe(struct platform_device *pdev)
- if (variant == IMX7D) {
- clk = of_clk_get(np_mu, 0);
- if (IS_ERR(clk)) {
- - pr_err("mu clock source missing or invalid\n");
- + dev_err(dev, "mu clock source missing or invalid\n");
- return PTR_ERR(clk);
- }
- ret = clk_prepare_enable(clk);
- if (ret) {
- - pr_err("unable to enable mu clock\n");
- + dev_err(dev, "unable to enable mu clock\n");
- return ret;
- }
- }
- @@ -485,7 +497,9 @@ static int imx_rpmsg_probe(struct platform_device *pdev)
- }
- BLOCKING_INIT_NOTIFIER_HEAD(&(mu_rpmsg_box.notifier));
- - pr_info("MU is ready for cross core communication!\n");
- + if (logging_enabled) {
- + dev_info(dev, "MU is ready for cross core communication!\n");
- + }
- for (i = 0; i < ARRAY_SIZE(imx_rpmsg_vprocs); i++) {
- struct imx_rpmsg_vproc *rpdev = &imx_rpmsg_vprocs[i];
- @@ -495,7 +509,7 @@ static int imx_rpmsg_probe(struct platform_device *pdev)
- if (ret)
- rpdev->vdev_nums = 1;
- if (rpdev->vdev_nums > MAX_VDEV_NUMS) {
- - pr_err("vdev-nums exceed the max %d\n", MAX_VDEV_NUMS);
- + dev_err(dev, "vdev-nums exceed the max %d\n", MAX_VDEV_NUMS);
- return -EINVAL;
- }
- @@ -503,7 +517,7 @@ static int imx_rpmsg_probe(struct platform_device *pdev)
- ret = set_vring_phy_buf(pdev, rpdev,
- rpdev->vdev_nums);
- if (ret) {
- - pr_err("No vring buffer.\n");
- + dev_err(dev, "No vring buffer.\n");
- return -ENOMEM;
- }
- } else {
- @@ -512,10 +526,12 @@ static int imx_rpmsg_probe(struct platform_device *pdev)
- }
- for (j = 0; j < rpdev->vdev_nums; j++) {
- - pr_debug("%s rpdev%d vdev%d: vring0 0x%x, vring1 0x%x\n",
- - __func__, i, rpdev->vdev_nums,
- - rpdev->ivdev[j].vring[0],
- - rpdev->ivdev[j].vring[1]);
- + if (logging_enabled) {
- + dev_dbg(dev, "%s rpdev%d vdev%d: vring0 0x%x, vring1 0x%x\n",
- + __func__, i, rpdev->vdev_nums,
- + rpdev->ivdev[j].vring[0],
- + rpdev->ivdev[j].vring[1]);
- + }
- rpdev->ivdev[j].vdev.id.device = VIRTIO_ID_RPMSG;
- rpdev->ivdev[j].vdev.config = &imx_rpmsg_config_ops;
- rpdev->ivdev[j].vdev.dev.parent = &pdev->dev;
- @@ -524,7 +540,7 @@ static int imx_rpmsg_probe(struct platform_device *pdev)
- ret = register_virtio_device(&rpdev->ivdev[j].vdev);
- if (ret) {
- - pr_err("%s failed to register rpdev: %d\n",
- + dev_err(dev, "%s failed to register rpdev: %d\n",
- __func__, ret);
- return ret;
- }
- @@ -535,11 +551,36 @@ static int imx_rpmsg_probe(struct platform_device *pdev)
- return ret;
- }
- +static ssize_t show_log_level(struct device* dev, struct device_attribute* attr, char* buf)
- +{
- + return scnprintf(buf, PAGE_SIZE, "%s\n", logging_enabled ? "0" : "1");
- +}
- +
- +static ssize_t toggle_log_level(struct device* dev, struct device_attribute* attr, const char* buf, size_t count)
- +{
- + logging_enabled = logging_enabled ? false : true;
- + return count;
- +}
- +
- +static DEVICE_ATTR(log_enabled, 0644, show_log_level, toggle_log_level);
- +static struct attribute *dev_attrs[] = {
- + &dev_attr_log_enabled.attr,
- + NULL,
- +};
- +static struct attribute_group dev_attr_group = {
- + .attrs = dev_attrs,
- +};
- +static const struct attribute_group *dev_attr_groups[] = {
- + &dev_attr_group,
- + NULL,
- +};
- +
- static struct platform_driver imx_rpmsg_driver = {
- .driver = {
- .owner = THIS_MODULE,
- .name = "imx-rpmsg",
- .of_match_table = imx_rpmsg_dt_ids,
- + .groups = dev_attr_groups,
- },
- .probe = imx_rpmsg_probe,
- };
- diff --git a/drivers/rpmsg/imx_rpmsg_tty.c b/drivers/rpmsg/imx_rpmsg_tty.c
- index 42b245d..42bbf99 100644
- --- a/drivers/rpmsg/imx_rpmsg_tty.c
- +++ b/drivers/rpmsg/imx_rpmsg_tty.c
- @@ -38,6 +38,19 @@ static struct rpmsgtty_port rpmsg_tty_port;
- #define RPMSG_MAX_SIZE 256
- #define MSG "hello world!"
- +static bool logging_enabled = true;
- +
- +static ssize_t show_log_level(struct device* dev, struct device_attribute* attr, char* buf)
- +{
- + return scnprintf(buf, PAGE_SIZE, "%s\n", logging_enabled ? "0" : "1");
- +}
- +
- +static ssize_t toggle_log_level(struct device* dev, struct device_attribute* attr, const char* buf, size_t count)
- +{
- + logging_enabled = logging_enabled ? false : true;
- + return count;
- +}
- +
- static int rpmsg_tty_cb(struct rpmsg_device *rpdev, void *data, int len,
- void *priv, u32 src)
- {
- @@ -49,10 +62,12 @@ static int rpmsg_tty_cb(struct rpmsg_device *rpdev, void *data, int len,
- if (len == 0)
- return 0;
- - dev_dbg(&rpdev->dev, "msg(<- src 0x%x) len %d\n", src, len);
- + if (logging_enabled) {
- + dev_dbg(&rpdev->dev, "msg(<- src 0x%x) len %d\n", src, len);
- - print_hex_dump(KERN_DEBUG, __func__, DUMP_PREFIX_NONE, 16, 1,
- - data, len, true);
- + print_hex_dump(KERN_DEBUG, __func__, DUMP_PREFIX_NONE, 16, 1,
- + data, len, true);
- + }
- spin_lock_bh(&cport->rx_lock);
- space = tty_prepare_flip_string(&cport->port, &cbuf, len);
- @@ -143,8 +158,10 @@ static int rpmsg_tty_probe(struct rpmsg_device *rpdev)
- int err;
- struct rpmsgtty_port *cport = &rpmsg_tty_port;
- - dev_info(&rpdev->dev, "new channel: 0x%x -> 0x%x!\n",
- - rpdev->src, rpdev->dst);
- + if (logging_enabled) {
- + dev_info(&rpdev->dev, "new channel: 0x%x -> 0x%x!\n",
- + rpdev->src, rpdev->dst);
- + }
- /*
- * send a message to our remote processor, and tell remote
- @@ -178,7 +195,7 @@ static int rpmsg_tty_probe(struct rpmsg_device *rpdev)
- if (err < 0) {
- pr_err("Couldn't install rpmsg tty driver: err %d\n", err);
- goto error;
- - } else
- + } else if (logging_enabled)
- pr_info("Install rpmsg tty driver!\n");
- cport->rpdev = rpdev;
- @@ -197,7 +214,9 @@ static void rpmsg_tty_remove(struct rpmsg_device *rpdev)
- {
- struct rpmsgtty_port *cport = &rpmsg_tty_port;
- - dev_info(&rpdev->dev, "rpmsg tty driver is removed\n");
- + if (logging_enabled) {
- + dev_info(&rpdev->dev, "rpmsg tty driver is removed\n");
- + }
- tty_unregister_driver(rpmsgtty_driver);
- put_tty_driver(rpmsgtty_driver);
- @@ -205,6 +224,19 @@ static void rpmsg_tty_remove(struct rpmsg_device *rpdev)
- rpmsgtty_driver = NULL;
- }
- +static DEVICE_ATTR(logging_enabled, 0644, show_log_level, toggle_log_level);
- +static struct attribute* dev_attrs[] = {
- + &dev_attr_logging_enabled.attr,
- + NULL,
- +};
- +static struct attribute_group dev_attr_group = {
- + .attrs = dev_attrs,
- +};
- +static const struct attribute_group* dev_attr_groups[] = {
- + &dev_attr_group,
- + NULL,
- +};
- +
- static struct rpmsg_device_id rpmsg_driver_tty_id_table[] = {
- { .name = "rpmsg-virtual-tty-channel" },
- { .name = "rpmsg-openamp-demo-channel" },
- @@ -215,6 +247,7 @@ MODULE_DEVICE_TABLE(rpmsg, rpmsg_driver_tty_id_table);
- static struct rpmsg_driver rpmsg_tty_driver = {
- .drv.name = KBUILD_MODNAME,
- .drv.owner = THIS_MODULE,
- + .drv.groups = dev_attr_groups,
- .id_table = rpmsg_driver_tty_id_table,
- .probe = rpmsg_tty_probe,
- .callback = rpmsg_tty_cb,
- diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c
- index 15a8fa7..c804e82 100644
- --- a/drivers/rpmsg/virtio_rpmsg_bus.c
- +++ b/drivers/rpmsg/virtio_rpmsg_bus.c
- @@ -192,6 +192,19 @@ static const struct rpmsg_endpoint_ops virtio_endpoint_ops = {
- .trysend_offchannel = virtio_rpmsg_trysend_offchannel,
- };
- +static bool logging_enabled = true;
- +
- +static ssize_t show_log_level(struct device* dev, struct device_attribute* attr, char* buf)
- +{
- + return scnprintf(buf, PAGE_SIZE, "%s\n", logging_enabled ? "0" : "1");
- +}
- +
- +static ssize_t toggle_log_level(struct device* dev, struct device_attribute* attr, const char* buf, size_t count)
- +{
- + logging_enabled = logging_enabled ? false : true;
- + return count;
- +}
- +
- /**
- * __ept_release() - deallocate an rpmsg endpoint
- * @kref: the ept's reference count
- @@ -563,7 +576,9 @@ static int rpmsg_send_offchannel_raw(struct rpmsg_device *rpdev,
- /* bcasting isn't allowed */
- if (src == RPMSG_ADDR_ANY || dst == RPMSG_ADDR_ANY) {
- - dev_err(dev, "invalid addr (src 0x%x, dst 0x%x)\n", src, dst);
- + if (logging_enabled) {
- + dev_err(dev, "invalid addr (src 0x%x, dst 0x%x)\n", src, dst);
- + }
- return -EINVAL;
- }
- @@ -577,7 +592,9 @@ static int rpmsg_send_offchannel_raw(struct rpmsg_device *rpdev,
- * variable-length buffer sizes.
- */
- if (len > RPMSG_BUF_SIZE - sizeof(struct rpmsg_hdr)) {
- - dev_err(dev, "message is too big (%d)\n", len);
- + if (logging_enabled) {
- + dev_err(dev, "message is too big (%d)\n", len);
- + }
- return -EMSGSIZE;
- }
- @@ -606,7 +623,9 @@ static int rpmsg_send_offchannel_raw(struct rpmsg_device *rpdev,
- /* timeout ? */
- if (!err) {
- - dev_err(dev, "timeout waiting for a tx buffer\n");
- + if (logging_enabled) {
- + dev_err(dev, "timeout waiting for a tx buffer\n");
- + }
- return -ERESTARTSYS;
- }
- }
- @@ -618,16 +637,20 @@ static int rpmsg_send_offchannel_raw(struct rpmsg_device *rpdev,
- msg->reserved = 0;
- memcpy(msg->data, data, len);
- - dev_dbg(dev, "TX From 0x%x, To 0x%x, Len %d, Flags %d, Reserved %d\n",
- - msg->src, msg->dst, msg->len, msg->flags, msg->reserved);
- + if (logging_enabled) {
- + dev_dbg(dev, "TX From 0x%x, To 0x%x, Len %d, Flags %d, Reserved %d\n",
- + msg->src, msg->dst, msg->len, msg->flags, msg->reserved);
- #if defined(CONFIG_DYNAMIC_DEBUG)
- - dynamic_hex_dump("rpmsg_virtio TX: ", DUMP_PREFIX_NONE, 16, 1,
- - msg, sizeof(*msg) + msg->len, true);
- + dynamic_hex_dump("rpmsg_virtio TX: ", DUMP_PREFIX_NONE, 16, 1,
- + msg, sizeof(*msg) + msg->len, true);
- #endif
- + }
- err = sg_init_one_full(&sg, msg, sizeof(*msg) + len);
- if (err) {
- - dev_err(dev, "virtqueue_add_outbuf sg_init failed: %d\n", err);
- + if (logging_enabled) {
- + dev_err(dev, "virtqueue_add_outbuf sg_init failed: %d\n", err);
- + }
- return err;
- }
- @@ -641,7 +664,9 @@ static int rpmsg_send_offchannel_raw(struct rpmsg_device *rpdev,
- * (memory won't leak, but rpmsg won't use it again for TX).
- * this will wait for a buffer management overhaul.
- */
- - dev_err(dev, "virtqueue_add_outbuf failed: %d\n", err);
- + if (logging_enabled) {
- + dev_err(dev, "virtqueue_add_outbuf failed: %d\n", err);
- + }
- goto out;
- }
- @@ -710,12 +735,14 @@ static int rpmsg_recv_single(struct virtproc_info *vrp, struct device *dev,
- struct scatterlist sg;
- int err;
- - dev_dbg(dev, "From: 0x%x, To: 0x%x, Len: %d, Flags: %d, Reserved: %d\n",
- - msg->src, msg->dst, msg->len, msg->flags, msg->reserved);
- + if (logging_enabled) {
- + dev_dbg(dev, "From: 0x%x, To: 0x%x, Len: %d, Flags: %d, Reserved: %d\n",
- + msg->src, msg->dst, msg->len, msg->flags, msg->reserved);
- #if defined(CONFIG_DYNAMIC_DEBUG)
- - dynamic_hex_dump("rpmsg_virtio RX: ", DUMP_PREFIX_NONE, 16, 1,
- + dynamic_hex_dump("rpmsg_virtio RX: ", DUMP_PREFIX_NONE, 16, 1,
- msg, sizeof(*msg) + msg->len, true);
- #endif
- + }
- /*
- * We currently use fixed-sized buffers, so trivially sanitize
- @@ -723,7 +750,9 @@ static int rpmsg_recv_single(struct virtproc_info *vrp, struct device *dev,
- */
- if (len > RPMSG_BUF_SIZE ||
- msg->len > (len - sizeof(struct rpmsg_hdr))) {
- - dev_warn(dev, "inbound msg too big: (%d, %d)\n", len, msg->len);
- + if (logging_enabled) {
- + dev_warn(dev, "inbound msg too big: (%d, %d)\n", len, msg->len);
- + }
- return -EINVAL;
- }
- @@ -750,20 +779,24 @@ static int rpmsg_recv_single(struct virtproc_info *vrp, struct device *dev,
- /* farewell, ept, we don't need you anymore */
- kref_put(&ept->refcount, __ept_release);
- - } else
- + } else if (logging_enabled)
- dev_warn(dev, "msg received with no recipient\n");
- /* publish the real size of the buffer */
- err = sg_init_one_full(&sg, msg, RPMSG_BUF_SIZE);
- if (err) {
- - dev_err(dev, "rpmsg_recv_done sg_init failed: %d\n", err);
- + if (logging_enabled) {
- + dev_err(dev, "rpmsg_recv_done sg_init failed: %d\n", err);
- + }
- return err;
- }
- /* add the buffer back to the remote processor's virtqueue */
- err = virtqueue_add_inbuf(vrp->rvq, &sg, 1, msg, GFP_KERNEL);
- if (err < 0) {
- - dev_err(dev, "failed to add a virtqueue buffer: %d\n", err);
- + if (logging_enabled) {
- + dev_err(dev, "failed to add a virtqueue buffer: %d\n", err);
- + }
- return err;
- }
- @@ -781,7 +814,9 @@ static void rpmsg_recv_done(struct virtqueue *rvq)
- msg = virtqueue_get_buf(rvq, &len);
- if (!msg) {
- - dev_err(dev, "uhm, incoming signal, but no used buffer ?\n");
- + if (logging_enabled) {
- + dev_err(dev, "uhm, incoming signal, but no used buffer ?\n");
- + }
- return;
- }
- @@ -795,7 +830,9 @@ static void rpmsg_recv_done(struct virtqueue *rvq)
- msg = virtqueue_get_buf(rvq, &len);
- }
- - dev_dbg(dev, "Received %u messages\n", msgs_received);
- + if (logging_enabled) {
- + dev_dbg(dev, "Received %u messages\n", msgs_received);
- + }
- /* tell the remote processor we added another available rx buffer */
- if (msgs_received)
- @@ -813,7 +850,9 @@ static void rpmsg_xmit_done(struct virtqueue *svq)
- {
- struct virtproc_info *vrp = svq->vdev->priv;
- - dev_dbg(&svq->vdev->dev, "%s\n", __func__);
- + if (logging_enabled) {
- + dev_dbg(&svq->vdev->dev, "%s\n", __func__);
- + }
- /* wake up potential senders that are waiting for a tx buffer */
- wake_up_interruptible(&vrp->sendq);
- @@ -831,12 +870,16 @@ static int rpmsg_ns_cb(struct rpmsg_device *rpdev, void *data, int len,
- int ret;
- #if defined(CONFIG_DYNAMIC_DEBUG)
- - dynamic_hex_dump("NS announcement: ", DUMP_PREFIX_NONE, 16, 1,
- - data, len, true);
- + if (logging_enabled) {
- + dynamic_hex_dump("NS announcement: ", DUMP_PREFIX_NONE, 16, 1,
- + data, len, true);
- + }
- #endif
- if (len != sizeof(*msg)) {
- - dev_err(dev, "malformed ns msg (%d)\n", len);
- + if (logging_enabled) {
- + dev_err(dev, "malformed ns msg (%d)\n", len);
- + }
- return -EINVAL;
- }
- @@ -847,16 +890,20 @@ static int rpmsg_ns_cb(struct rpmsg_device *rpdev, void *data, int len,
- * in somehow.
- */
- if (rpdev) {
- - dev_err(dev, "anomaly: ns ept has an rpdev handle\n");
- + if (logging_enabled) {
- + dev_err(dev, "anomaly: ns ept has an rpdev handle\n");
- + }
- return -EINVAL;
- }
- /* don't trust the remote processor for null terminating the name */
- msg->name[RPMSG_NAME_SIZE - 1] = '\0';
- - dev_info(dev, "%sing channel %s addr 0x%x\n",
- - msg->flags & RPMSG_NS_DESTROY ? "destroy" : "creat",
- - msg->name, msg->addr);
- + if (logging_enabled) {
- + dev_info(dev, "%sing channel %s addr 0x%x\n",
- + msg->flags & RPMSG_NS_DESTROY ? "destroy" : "creat",
- + msg->name, msg->addr);
- + }
- strncpy(chinfo.name, msg->name, sizeof(chinfo.name));
- chinfo.src = RPMSG_ADDR_ANY;
- @@ -864,11 +911,11 @@ static int rpmsg_ns_cb(struct rpmsg_device *rpdev, void *data, int len,
- if (msg->flags & RPMSG_NS_DESTROY) {
- ret = rpmsg_unregister_device(&vrp->vdev->dev, &chinfo);
- - if (ret)
- + if (ret && logging_enabled)
- dev_err(dev, "rpmsg_destroy_channel failed: %d\n", ret);
- } else {
- newch = rpmsg_create_channel(vrp, &chinfo);
- - if (!newch)
- + if (!newch && logging_enabled)
- dev_err(dev, "rpmsg_create_channel failed\n");
- }
- @@ -926,8 +973,10 @@ static int rpmsg_probe(struct virtio_device *vdev)
- goto vqs_del;
- }
- - dev_dbg(&vdev->dev, "buffers: va %p, dma %pad\n",
- - bufs_va, &vrp->bufs_dma);
- + if (logging_enabled) {
- + dev_dbg(&vdev->dev, "buffers: va %p, dma %pad\n",
- + bufs_va, &vrp->bufs_dma);
- + }
- /* half of the buffers is dedicated for RX */
- vrp->rbufs = bufs_va;
- @@ -985,7 +1034,9 @@ static int rpmsg_probe(struct virtio_device *vdev)
- if (notify)
- virtqueue_notify(vrp->rvq);
- - dev_info(&vdev->dev, "rpmsg host is online\n");
- + if (logging_enabled) {
- + dev_info(&vdev->dev, "rpmsg host is online\n");
- + }
- return 0;
- @@ -1040,11 +1091,25 @@ static unsigned int features[] = {
- VIRTIO_RPMSG_F_NS,
- };
- +static DEVICE_ATTR(logging_enabled, 0644, show_log_level, toggle_log_level);
- +static struct attribute* dev_attrs[] = {
- + &dev_attr_logging_enabled.attr,
- + NULL,
- +};
- +static struct attribute_group dev_attr_group = {
- + .attrs = dev_attrs,
- +};
- +static const struct attribute_group* dev_attr_groups[] = {
- + &dev_attr_group,
- + NULL,
- +};
- +
- static struct virtio_driver virtio_ipc_driver = {
- .feature_table = features,
- .feature_table_size = ARRAY_SIZE(features),
- .driver.name = KBUILD_MODNAME,
- .driver.owner = THIS_MODULE,
- + .driver.groups = dev_attr_groups,
- .id_table = id_table,
- .probe = rpmsg_probe,
- .remove = rpmsg_remove,
- --
- 2.7.4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement