From: Arnd Bergmann <arnd@arndb.de>
To: Xianting Tian <xianting.tian@linux.alibaba.com>
Cc: Arnd Bergmann <arnd@arndb.de>, Amit Shah <amit@kernel.org>,
gregkh <gregkh@linuxfoundation.org>,
linuxppc-dev <linuxppc-dev@lists.ozlabs.org>,
"open list:DRM DRIVER FOR QEMU'S CIRRUS DEVICE"
<virtualization@lists.linux-foundation.org>,
Jiri Slaby <jirislaby@kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/2] tty: hvc: pass DMA capable memory to put_chars()
Date: Sun, 1 Aug 2021 11:24:15 +0200 [thread overview]
Message-ID: <CAK8P3a2_ip1zGMe=EeAA7Xpkvi8iQGWw6=0sGvLqv02Mj4LrmA@mail.gmail.com> (raw)
In-Reply-To: <20210801051627.78999-1-xianting.tian@linux.alibaba.com>
On Sun, Aug 1, 2021 at 7:16 AM Xianting Tian
<xianting.tian@linux.alibaba.com> wrote:
> Considering lock competition of hp->outbuf and the complicated logic in
> hvc_console_print(), I didn’t use hp->outbuf, just allocate additional
> memory(length N_OUTBUF) and append it to hp->outbuf.
> For the issue in hvc_poll_put_char(), I use a static char to replace
> the char in stack.
While this may work, it sounds rather obscure to me, I don't think
it's a good idea
to append the buffer at the back.
If you need a separate field besides hp->outbuf, I would make that part of the
structure itself, and give it the correct alignment constraints to ensure it is
in a cache line by itself. The size of this field is a compile-time
constant, so I
don't see a need to play tricks with pointer arithmetic.
I'm not sure about the locking either: Is it possible for two CPUs to enter
hvc_console_print() at the same time, or is there locking at a higher level
already? It would be good to document this in the structure definition next
to the field.
> @@ -878,6 +885,7 @@ static void hvc_poll_put_char(struct tty_driver *driver, int line, char ch)
> struct tty_struct *tty = driver->ttys[0];
> struct hvc_struct *hp = tty->driver_data;
> int n;
> + static char ch = ch;
>
> do {
> n = hp->ops->put_chars(hp->vtermno, &ch, 1);
This does not compile, and it's neither thread-safe nor dma safe if you get it
to build by renaming the variable.
Arnd
next prev parent reply other threads:[~2021-08-01 9:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-01 5:16 [PATCH 1/2] tty: hvc: pass DMA capable memory to put_chars() Xianting Tian
2021-08-01 9:24 ` Arnd Bergmann [this message]
2021-08-01 11:49 ` kernel test robot
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='CAK8P3a2_ip1zGMe=EeAA7Xpkvi8iQGWw6=0sGvLqv02Mj4LrmA@mail.gmail.com' \
--to=arnd@arndb.de \
--cc=amit@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=virtualization@lists.linux-foundation.org \
--cc=xianting.tian@linux.alibaba.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).