All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Bur <cyrilbur@gmail.com>
To: Joel Stanley <joel@jms.id.au>
Cc: OpenBMC Maillist <openbmc@lists.ozlabs.org>,
	Andrew Jeffery <andrew@aj.id.au>
Subject: Re: [PATCH linux 2/3] drivers/misc: Add aspeed mbox driver
Date: Thu, 15 Dec 2016 18:59:27 +1100	[thread overview]
Message-ID: <1481788767.814.8.camel@gmail.com> (raw)
In-Reply-To: <CACPK8XdisKkgmE2PT5JGE06AD73rrBizsgL0+SbyFkSHShaEKg@mail.gmail.com>

On Tue, 2016-12-13 at 12:26 +1100, Joel Stanley wrote:
> On Fri, Dec 9, 2016 at 4:43 PM, Cyril Bur <cyrilbur@gmail.com> wrote:
> > Signed-off-by: Cyril Bur <cyrilbur@gmail.com>
> 
> Explain why we need this chardev, why it needs ioctls, etc.
> 

Yeah, we should probably also work on the name and stuff

> > ---
> >  drivers/misc/Kconfig           |   7 +
> >  drivers/misc/Makefile          |   2 +
> >  drivers/misc/mbox-host.c       | 326
> > +++++++++++++++++++++++++++++++++++++++++
> >  include/uapi/linux/mbox-host.h |  18 +++
> >  4 files changed, 353 insertions(+)
> >  create mode 100644 drivers/misc/mbox-host.c
> >  create mode 100644 include/uapi/linux/mbox-host.h
> > 
> > diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
> > index a216b46..44f191d 100644
> > --- a/drivers/misc/Kconfig
> > +++ b/drivers/misc/Kconfig
> > @@ -804,6 +804,13 @@ config PANEL_BOOT_MESSAGE
> >           An empty message will only clear the display at driver
> > init time. Any other
> >           printf()-formatted message is valid with newline and
> > escape codes.
> > 
> > +config MBOX_HOST
> > +       depends on ARCH_ASPEED
> 
> or COMPILE_TEST

Is both a good solution?

> 
> > +       bool "Build MBOX driver for BMC to HOST communication"
> > +       default "n"
> 
> If it's depending on ARCH_ASPEED I think default y is ok.
> 

Yes

> > +       ---help---
> > +         Build the MBOX driver
> 
> More text here please.
> 
> > +
> >  source "drivers/misc/c2port/Kconfig"
> >  source "drivers/misc/eeprom/Kconfig"
> >  source "drivers/misc/cb710/Kconfig"
> > diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
> > index b2fb6dbf..7bcaf30 100644
> > --- a/drivers/misc/Makefile
> > +++ b/drivers/misc/Makefile
> 
> "misc seems a bit too misc" - Andrew Jeffery.
> 
> How about drivers/soc? Or drivers/mfd?

I think we settled on mailbox?

> 
> > +#define DEVICE_NAME    "mbox-host"
> > +
> > +#define MBOX_NUM_REGS 16
> > +#define MBOX_NUM_DATA_REGS 14
> > +
> > +#define MBOX_DATA_0 0x00
> > +#define MBOX_STATUS_0 0x40
> > +#define MBOX_STATUS_1 0x44
> > +#define MBOX_BMC_CTRL 0x48
> > +       #define MBOX_CTRL_RECV 0x80
> > +       #define MBOX_CTRL_MASK 0x02
> > +       #define MBOX_CTRL_SEND 0x01
> 
> If you want to do show these are bits in the CTRL register, do this.
> I
> think it's more readable to represent the bits as shifts, or even
> better, using the BIT() macro.
> 
> #define MBOX_BMC_CTRL 0x48
> #define   MBOX_CTRL_RECV BIT(7)
> #define   MBOX_CTRL_MASK BIT(1)
> 
> etc.
> 

Ah yes looks much better now, thanks

> > +#define MBOX_HOST_CTRL 0x4c
> > +#define MBOX_INTERRUPT_0 0x50
> > +#define MBOX_INTERRUPT_1 0x54
> > +
> > +
> > +static u8 mbox_inb(struct mbox_host *mbox_host, int reg)
> > +{
> > +       return ioread8(mbox_host->base + reg);
> > +}
> > +
> > +static void mbox_outb(struct mbox_host *mbox_host, u8 data, int
> > reg)
> > +{
> > +       iowrite8(data, mbox_host->base + reg);
> > +}
> 
> As mentioned in the other email, all access to the LPC address space
> is through regmap.

Yes.

> 
> > +
> > +static struct mbox_host *file_mbox_host(struct file *file)
> > +{
> > +       return container_of(file->private_data, struct mbox_host,
> > miscdev);
> > +}
> > +
> > +static int mbox_host_open(struct inode *inode, struct file *file)
> > +{
> > +       return 0;
> > +}
> 
> This means userspace can open this device an unlimited number of
> times. I think we only want one user at a time?
> 

That would be wise yes

> 
> > +static int mbox_host_release(struct inode *inode, struct file
> > *file)
> > +{
> > +       return 0;
> > +}
> 
> Why not omit the callback?
> 
> > +
> > +static unsigned int mbox_host_poll(struct file *file, poll_table
> > *wait)
> > +{
> > +       struct mbox_host *mbox_host = file_mbox_host(file);
> > +       unsigned int mask = 0;
> > +
> > +       poll_wait(file, &mbox_host->queue, wait);
> > +
> > +       if (mbox_inb(mbox_host, MBOX_BMC_CTRL) & MBOX_CTRL_RECV)
> > +               mask |= POLLIN;
> > +
> > +       return mask;
> > +}
> > +
> > +static const struct file_operations mbox_host_fops = {
> > +       .owner          = THIS_MODULE,
> > +       .open           = mbox_host_open,
> > +       .read           = mbox_host_read,
> > +       .write          = mbox_host_write,
> > +       .release        = mbox_host_release,
> > +       .poll           = mbox_host_poll,
> > +       .unlocked_ioctl = mbox_host_ioctl,
> > +};
> > +
> > +static void poll_timer(unsigned long data)
> > +{
> > +       struct mbox_host *mbox_host = (void *)data;
> > +
> > +       mbox_host->poll_timer.expires += msecs_to_jiffies(500);
> 
> Why 500?

Why not? I feel like I should test and justify a number, I honestly
have no idea whats good but 500msecs feels decent... perhaps I'll
determine a better number, or a good reason for 500 in my infinite
spare time ;)


Thanks for the review,

Cyril

> 
> > +       wake_up(&mbox_host->queue);
> > +       add_timer(&mbox_host->poll_timer);
> > +}
> > +

  parent reply	other threads:[~2016-12-15  7:59 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-09  5:43 [PATCH linux 0/3] LPC/MBOX work Cyril Bur
2016-12-09  5:43 ` [PATCH linux 1/3] ARM: dts: aspeed: Update palmetto device tree Cyril Bur
2016-12-13  0:44   ` Joel Stanley
2016-12-13  3:11     ` Cyril Bur
2016-12-13  3:29       ` Joel Stanley
2016-12-13  3:48         ` Cyril Bur
2016-12-13  4:34           ` Joel Stanley
2016-12-09  5:43 ` [PATCH linux 2/3] drivers/misc: Add aspeed mbox driver Cyril Bur
2016-12-13  1:26   ` Joel Stanley
2016-12-13  8:03     ` Cédric Le Goater
2016-12-15  7:59     ` Cyril Bur [this message]
2016-12-15 22:50       ` Andrew Jeffery
2016-12-13  8:14   ` Cédric Le Goater
2016-12-15  8:01     ` Cyril Bur
2016-12-14 23:14   ` Andrew Jeffery
2016-12-14 23:14   ` Andrew Jeffery
2016-12-09  5:43 ` [PATCH linux 3/3] drivers/misc: Add aspeed lpc controlling driver Cyril Bur
2016-12-13  0:51   ` Joel Stanley
2016-12-15  0:58   ` Andrew Jeffery
2016-12-15  8:01     ` Cyril Bur
2016-12-13 10:24 ` [PATCH linux 0/3] LPC/MBOX work Cédric Le Goater
2016-12-14  0:13   ` Cyril Bur

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=1481788767.814.8.camel@gmail.com \
    --to=cyrilbur@gmail.com \
    --cc=andrew@aj.id.au \
    --cc=joel@jms.id.au \
    --cc=openbmc@lists.ozlabs.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 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.