From: Mathieu Poirier <mathieu.poirier@linaro.org>
To: Richard Weinberger <richard@nod.at>
Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org,
andersson@kernel.org, upstream+rproc@sigma-star.at,
ohad@wizery.com, s-anna@ti.com, t-kristo@ti.com
Subject: Re: [PATCH] rpmsg_ns: Work around TI non-standard message
Date: Tue, 15 Oct 2024 10:48:08 -0600 [thread overview]
Message-ID: <Zw6cyFirqQ6Esr+0@p14s> (raw)
In-Reply-To: <20241011123922.23135-1-richard@nod.at>
Good morning Richard,
On Fri, Oct 11, 2024 at 02:39:22PM +0200, Richard Weinberger wrote:
> Texas Instruments ships a patch in their vendor kernels,
> which adds a new NS message that includes a description field.
> While TI is free to do whatever they want in their copy of the kernel,
> it becomes a mess when people switch to a mainline kernel and want
> to use their existing DSP programs with it.
I suspect there is a lot more things to change when going from downstream to a
mainline kernel.
>
> To make it easier to migrate to a mainline kernel,
> let's make the kernel aware of their non-standard extension but
> briefly ignore the description field.
In my opinion the real fix here is to get TI to use the standard message
announcement structure. The ->desc field doesn't seem to be that useful since
it gets discarted.
Thanks,
Mathieu
>
> [0] https://patchwork.kernel.org/project/linux-remoteproc/patch/20190815231448.10100-1-s-anna@ti.com/
> [1] https://stash.phytec.com/projects/PUB/repos/linux-phytec-ti/commits/aeded1f439effc84aa9f4e341a6e92ce1844ab98#drivers/rpmsg/virtio_rpmsg_bus.c
>
> Cc: ohad@wizery.com
> Cc: s-anna@ti.com
> Cc: t-kristo@ti.com
> Signed-off-by: Richard Weinberger <richard@nod.at>
> ---
> FWIW, this is a forward port of a patch I'm using on v6.6.
>
> Thanks,
> //richard
> ---
> drivers/rpmsg/rpmsg_ns.c | 30 ++++++++++++++++++++++--------
> include/linux/rpmsg/ns.h | 8 ++++++++
> 2 files changed, 30 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/rpmsg/rpmsg_ns.c b/drivers/rpmsg/rpmsg_ns.c
> index bde8c8d433e0a..2fb3721eb0141 100644
> --- a/drivers/rpmsg/rpmsg_ns.c
> +++ b/drivers/rpmsg/rpmsg_ns.c
> @@ -31,10 +31,11 @@ EXPORT_SYMBOL(rpmsg_ns_register_device);
> static int rpmsg_ns_cb(struct rpmsg_device *rpdev, void *data, int len,
> void *priv, u32 src)
> {
> - struct rpmsg_ns_msg *msg = data;
> struct rpmsg_device *newch;
> struct rpmsg_channel_info chinfo;
> struct device *dev = rpdev->dev.parent;
> + __rpmsg32 ns_addr, ns_flags;
> + char *ns_name;
> int ret;
>
> #if defined(CONFIG_DYNAMIC_DEBUG)
> @@ -42,23 +43,36 @@ static int rpmsg_ns_cb(struct rpmsg_device *rpdev, void *data, int len,
> data, len, true);
> #endif
>
> - if (len != sizeof(*msg)) {
> + if (len == sizeof(struct rpmsg_ns_msg)) {
> + struct rpmsg_ns_msg *msg = data;
> +
> + ns_addr = msg->addr;
> + ns_flags = msg->flags;
> + ns_name = msg->name;
> + } else if (len == sizeof(struct __rpmsg_ns_msg_ti)) {
> + struct __rpmsg_ns_msg_ti *msg = data;
> +
> + ns_addr = msg->addr;
> + ns_flags = msg->flags;
> + ns_name = msg->name;
> + dev_warn(dev, "non-standard ns msg found\n");
> + } else {
> dev_err(dev, "malformed ns msg (%d)\n", len);
> return -EINVAL;
> }
>
> /* don't trust the remote processor for null terminating the name */
> - msg->name[RPMSG_NAME_SIZE - 1] = '\0';
> + ns_name[RPMSG_NAME_SIZE - 1] = '\0';
>
> - strscpy_pad(chinfo.name, msg->name, sizeof(chinfo.name));
> + strscpy_pad(chinfo.name, ns_name, sizeof(chinfo.name));
> chinfo.src = RPMSG_ADDR_ANY;
> - chinfo.dst = rpmsg32_to_cpu(rpdev, msg->addr);
> + chinfo.dst = rpmsg32_to_cpu(rpdev, ns_addr);
>
> dev_info(dev, "%sing channel %s addr 0x%x\n",
> - rpmsg32_to_cpu(rpdev, msg->flags) & RPMSG_NS_DESTROY ?
> - "destroy" : "creat", msg->name, chinfo.dst);
> + rpmsg32_to_cpu(rpdev, ns_flags) & RPMSG_NS_DESTROY ?
> + "destroy" : "creat", ns_name, chinfo.dst);
>
> - if (rpmsg32_to_cpu(rpdev, msg->flags) & RPMSG_NS_DESTROY) {
> + if (rpmsg32_to_cpu(rpdev, ns_flags) & RPMSG_NS_DESTROY) {
> ret = rpmsg_release_channel(rpdev, &chinfo);
> if (ret)
> dev_err(dev, "rpmsg_destroy_channel failed: %d\n", ret);
> diff --git a/include/linux/rpmsg/ns.h b/include/linux/rpmsg/ns.h
> index a7804edd6d58f..60fca84ad4cea 100644
> --- a/include/linux/rpmsg/ns.h
> +++ b/include/linux/rpmsg/ns.h
> @@ -26,6 +26,14 @@ struct rpmsg_ns_msg {
> __rpmsg32 flags;
> } __packed;
>
> +/* Non-standard extended ns message by Texas Instruments */
> +struct __rpmsg_ns_msg_ti {
> + char name[RPMSG_NAME_SIZE];
> + char desc[RPMSG_NAME_SIZE]; /* ignored */
> + u32 addr;
> + u32 flags;
> +} __packed;
> +
> /**
> * enum rpmsg_ns_flags - dynamic name service announcement flags
> *
> --
> 2.35.3
>
next prev parent reply other threads:[~2024-10-15 16:48 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-11 12:39 [PATCH] rpmsg_ns: Work around TI non-standard message Richard Weinberger
2024-10-12 15:53 ` kernel test robot
2024-10-14 9:24 ` Richard Weinberger
2024-10-15 16:48 ` Mathieu Poirier [this message]
2024-10-15 16:58 ` Richard Weinberger
2024-10-15 17:56 ` Mathieu Poirier
2024-10-15 18:00 ` Richard Weinberger
2024-10-29 16:15 ` Romain Naour
2024-12-03 15:19 ` Andrew Davis
2024-12-03 16:40 ` Richard Weinberger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Zw6cyFirqQ6Esr+0@p14s \
--to=mathieu.poirier@linaro.org \
--cc=andersson@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=ohad@wizery.com \
--cc=richard@nod.at \
--cc=s-anna@ti.com \
--cc=t-kristo@ti.com \
--cc=upstream+rproc@sigma-star.at \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox