public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Vincent Whitchurch <vincent.whitchurch@axis.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Arnd Bergmann <arnd@arndb.de>, kernel <kernel@axis.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] char: ttyprintk: register console
Date: Thu, 24 Feb 2022 11:08:33 +0100	[thread overview]
Message-ID: <20220224100833.GA3807@axis.com> (raw)
In-Reply-To: <YhPZeDBlrHjLcgPh@kroah.com>

On Mon, Feb 21, 2022 at 07:27:04PM +0100, Greg Kroah-Hartman wrote:
> On Tue, Feb 15, 2022 at 03:17:49PM +0100, Vincent Whitchurch wrote:
> > Register a console in the ttyprintk driver so that it can be selected
> > for /dev/console with console=ttyprintk on the kernel command line,
> > similar to other console drivers.
> > 
> > Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
> > ---
> >  drivers/char/Kconfig     |  3 ++-
> >  drivers/char/ttyprintk.c | 16 ++++++++++++++++
> >  2 files changed, 18 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
> > index 740811893c57..c553a8a50d03 100644
> > --- a/drivers/char/Kconfig
> > +++ b/drivers/char/Kconfig
> > @@ -18,7 +18,8 @@ config TTY_PRINTK
> >  	  The feature is useful to inline user messages with kernel
> >  	  messages.
> >  	  In order to use this feature, you should output user messages
> > -	  to /dev/ttyprintk or redirect console to this TTY.
> > +	  to /dev/ttyprintk or redirect console to this TTY, or boot
> > +	  the kernel with console=ttyprintk.
> 
> Why do you want to use this tty device as a console?  What benifit
> does that provide?

I run Linux on a secondary processor on my SoC.  This secondary
processor doesn't have any output peripherals of its own, so it uses
pstore to put its kernel messages at a fixed location in memory from
which the primary processor can read them out.

In order to access logs from the secondary processor's userspace, a
simple way is to use ttyprintk.  Userspace logs to the console as normal
and the primary processor can read the unified kernel+userspace logs
from the pstore area.

There are similar uses in other cases not involving multiple processors.
I had mentioned on the lists a couple of years ago that I had this patch
(without posting it), and last week I received a request (off-list) for
it from someone who was looking to use it to debug userspace
initialization in postmarketOS on an Android phone (they only had the
ability to retreive the kernel's logs after a reboot using pstore).

      reply	other threads:[~2022-02-24 10:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-15 14:17 [PATCH] char: ttyprintk: register console Vincent Whitchurch
2022-02-21 18:27 ` Greg Kroah-Hartman
2022-02-24 10:08   ` Vincent Whitchurch [this message]

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=20220224100833.GA3807@axis.com \
    --to=vincent.whitchurch@axis.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel@axis.com \
    --cc=linux-kernel@vger.kernel.org \
    /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