All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Fabien Dessenne <fabien.dessenne@st.com>
Cc: Ohad Ben-Cohen <ohad@wizery.com>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jslaby@suse.com>,
	linux-kernel@vger.kernel.org, linux-remoteproc@vger.kernel.org,
	Benjamin Gaignard <benjamin.gaignard@st.com>,
	Arnaud Pouliquen <arnaud.pouliquen@st.com>
Subject: Re: [PATCH 2/2] tty: add rpmsg driver
Date: Wed, 3 Apr 2019 10:44:20 +0200	[thread overview]
Message-ID: <20190403084420.GH6734@localhost> (raw)
In-Reply-To: <1553183239-13253-3-git-send-email-fabien.dessenne@st.com>

On Thu, Mar 21, 2019 at 04:47:19PM +0100, Fabien Dessenne wrote:
> This driver exposes a standard tty interface on top of the rpmsg
> framework through the "rpmsg-tty-channel" rpmsg service.
> 
> This driver supports multi-instances, offering a /dev/ttyRPMSGx entry
> per rpmsg endpoint.
> 
> Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
> Signed-off-by: Fabien Dessenne <fabien.dessenne@st.com>
> ---
>  drivers/tty/Kconfig     |   9 ++
>  drivers/tty/Makefile    |   1 +
>  drivers/tty/rpmsg_tty.c | 309 ++++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 319 insertions(+)
>  create mode 100644 drivers/tty/rpmsg_tty.c

> +static int rpmsg_tty_write(struct tty_struct *tty, const unsigned char *buf,
> +			   int total)
> +{
> +	int count, ret = 0;
> +	const unsigned char *tbuf;
> +	struct rpmsg_tty_port *cport = idr_find(&tty_idr, tty->index);
> +	struct rpmsg_device *rpdev;
> +	int msg_size;
> +
> +	if (!cport) {
> +		dev_err(tty->dev, "cannot get cport\n");
> +		return -ENODEV;
> +	}
> +
> +	rpdev = cport->rpdev;
> +
> +	dev_dbg(&rpdev->dev, "%s: send message from tty->index = %d\n",
> +		__func__, tty->index);
> +
> +	if (!buf) {
> +		dev_err(&rpdev->dev, "buf shouldn't be null.\n");
> +		return -ENOMEM;
> +	}
> +
> +	msg_size = rpmsg_get_buf_payload_size(rpdev->ept);
> +	if (msg_size < 0)
> +		return msg_size;
> +
> +	count = total;
> +	tbuf = buf;
> +	do {
> +		/* send a message to our remote processor */
> +		ret = rpmsg_send(rpdev->ept, (void *)tbuf,
> +				 min(count, msg_size));

Just a drive-by comment; it looks like rpmsg_send() may block, but
the tty-driver write() callback must never sleep.

> +		if (ret) {
> +			dev_err(&rpdev->dev, "rpmsg_send failed: %d\n", ret);
> +			return ret;
> +		}
> +
> +		if (count > msg_size) {
> +			count -= msg_size;
> +			tbuf += msg_size;
> +		} else {
> +			count = 0;
> +		}
> +	} while (count > 0);
> +
> +	return total;
> +}

Johan

  reply	other threads:[~2019-04-03  8:44 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-21 15:47 [PATCH 0/2] TTY: add rpmsg tty driver Fabien Dessenne
2019-03-21 15:47 ` Fabien Dessenne
2019-03-21 15:47 ` [PATCH 1/2] rpmsg: core: add possibility to get message payload length Fabien Dessenne
2019-03-21 15:47   ` Fabien Dessenne
2019-03-21 15:47 ` [PATCH 2/2] tty: add rpmsg driver Fabien Dessenne
2019-03-21 15:47   ` Fabien Dessenne
2019-04-03  8:44   ` Johan Hovold [this message]
2019-04-05 12:50     ` Fabien DESSENNE
2019-04-03 12:47   ` xiang xiao
2019-04-04 16:14     ` Arnaud Pouliquen
2019-04-04 16:14       ` Arnaud Pouliquen
2019-04-05 10:12       ` xiang xiao
2019-04-05 12:33         ` Arnaud Pouliquen
2019-04-05 12:33           ` Arnaud Pouliquen
2019-04-05 14:03           ` xiang xiao
2019-04-05 16:08             ` Arnaud Pouliquen
2019-04-05 16:08               ` Arnaud Pouliquen
2019-04-06  7:56               ` xiang xiao
2019-04-08 12:05                 ` Arnaud Pouliquen
2019-04-08 12:05                   ` Arnaud Pouliquen
2019-04-08 13:29                   ` xiang xiao
2019-04-09  7:28                     ` Arnaud Pouliquen
2019-04-09  7:28                       ` Arnaud Pouliquen
2019-04-09 10:14                       ` xiang xiao
2019-04-12 16:00                         ` Arnaud Pouliquen
2019-04-12 16:00                           ` Arnaud Pouliquen
2019-04-15 13:14                           ` Enrico Weigelt, metux IT consult
2019-04-15 13:50                             ` xiang xiao

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=20190403084420.GH6734@localhost \
    --to=johan@kernel.org \
    --cc=arnaud.pouliquen@st.com \
    --cc=benjamin.gaignard@st.com \
    --cc=bjorn.andersson@linaro.org \
    --cc=fabien.dessenne@st.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=ohad@wizery.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.