All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Michael Ellerman <michael@ellerman.id.au>
Cc: linuxppc-dev <linuxppc-dev@lists.ozlabs.org>
Subject: Re: [PATCH] powerpc/powernv: Add a debugfs file to read the firmware console
Date: Wed, 09 Oct 2013 15:23:21 +1100	[thread overview]
Message-ID: <1381292601.645.258.camel@pasglop> (raw)
In-Reply-To: <20131009032314.GD23780@concordia>

On Wed, 2013-10-09 at 14:23 +1100, Michael Ellerman wrote:
> On Tue, Oct 08, 2013 at 06:46:40PM +1100, Benjamin Herrenschmidt wrote:
> > With OPALv3, the firmware can provide the address of it's internal console
> > to Linux, which we can then display using debugfs. This is handy for
> > diagnostics and debugging.
> > 
> > Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> > ---
> > 
> > diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c
> > index 2911abe..10d7894 100644
> > --- a/arch/powerpc/platforms/powernv/opal.c
> > +++ b/arch/powerpc/platforms/powernv/opal.c
> > @@ -17,6 +17,8 @@
> >  #include <linux/interrupt.h>
> >  #include <linux/notifier.h>
> >  #include <linux/slab.h>
> > +#include <linux/debugfs.h>
> > +#include <linux/uaccess.h>
> >  #include <asm/opal.h>
> >  #include <asm/firmware.h>
> >  
> > @@ -27,6 +29,21 @@ struct opal {
> >  	u64 entry;
> >  } opal;
> >  
> > +/* OPAL in-memory console */
> 
> It might be nice to point out that the format of the struct is defined
> by OPAL and must be in sync with what OPAL is using.

Yes, we could move the structure definition to opal.h...

> > +struct memcons {
> > +	uint64_t magic;
> 
> u64 ?

Who cares ? Especially if it goes into opal.h it should stick to the
types used in that file.

> > +#define MEMCONS_MAGIC	0x6630696567726173
> > +	uint64_t obuf_phys;
> > +	uint64_t ibuf_phys;
> > +	uint32_t obuf_size;
> > +	uint32_t ibuf_size;
> > +	uint32_t out_pos;
> > +#define MEMCONS_OUT_POS_WRAP	0x80000000u
> > +#define MEMCONS_OUT_POS_MASK	0x00ffffffu
> 
> Where does this come from?

My a** :-) I made it up as I wrote the OPAL side one, why ?

> > +	uint32_t in_prod;
> > +	uint32_t in_cons;
> > +};
> 
> Should it be packed?

Nope, no need. It's all nice and naturally aligned.

> > @@ -369,6 +386,90 @@ static irqreturn_t opal_interrupt(int irq, void *data)
> >  	return IRQ_HANDLED;
> >  }
> >  
> > +#ifdef CONFIG_DEBUG_FS
> > +static ssize_t opal_memcons_read(struct file *file, char __user *to,
> > +				 size_t count, loff_t *ppos)
> > +{
> > +	struct memcons *mc = file->private_data;
> > +	size_t available, ret, chunk0, chunk1, lcount;
> > +	const char *start, *conbuf = __va(mc->obuf_phys);
> > +	loff_t opos, pos;
> > +
> > +	/*
> > +	 * Find out how much is in the buffer. If it has wrapped
> > +	 * the whole buffer, else just the beginning. It has wrapped
> > +	 * if the next character is not \0
> > +	 */
> > +	if (mc->out_pos & MEMCONS_OUT_POS_WRAP) {
> > +		available = mc->obuf_size;
> > +		chunk1 = mc->out_pos & MEMCONS_OUT_POS_MASK;
> > +		start = conbuf + chunk1;
> > +		chunk0 = mc->obuf_size - chunk1;
> > +	} else {
> > +		available = mc->out_pos;
> > +		start = conbuf;
> > +		chunk0 = available;
> > +		chunk1 = 0;
> > +	}
> 
> Surely simple_read_from_buffer() could make some of this simpler?

If you can find a way to make it deal with a ring buffer...

Cheers,
Ben.

  reply	other threads:[~2013-10-09  4:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-08  7:46 [PATCH] powerpc/powernv: Add a debugfs file to read the firmware console Benjamin Herrenschmidt
2013-10-09  3:23 ` Michael Ellerman
2013-10-09  4:23   ` Benjamin Herrenschmidt [this message]
2013-10-09  6:06     ` Michael Ellerman
2013-10-09  6:51       ` Benjamin Herrenschmidt

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=1381292601.645.258.camel@pasglop \
    --to=benh@kernel.crashing.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=michael@ellerman.id.au \
    /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.