linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: bjorn.andersson@linaro.org (Bjorn Andersson)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] mailbox: add support for doorbell/signal mode controllers
Date: Wed, 1 Nov 2017 20:27:28 -0700	[thread overview]
Message-ID: <20171102032728.GI28761@minitux> (raw)
In-Reply-To: <CABb+yY0unrs-LpqFyh1ibVO00ztA+=i_1-+MpRCrG5mLsWoiSw@mail.gmail.com>

On Wed 01 Nov 20:02 PDT 2017, Jassi Brar wrote:

> On Thu, Nov 2, 2017 at 3:47 AM, Bjorn Andersson
> <bjorn.andersson@linaro.org> wrote:
> > On Wed 01 Nov 11:15 PDT 2017, Sudeep Holla wrote:
> >>
> >>  80         writel_relaxed(msg->cmd, mb->mbox_base +
> >> MAILBOX_A2B_CMD(chans->idx));
> >>  81         writel_relaxed(msg->rx_size, mb->mbox_base +
> >>
> >>  82                        MAILBOX_A2B_DAT(chans->idx));
> >>
> >>  83
> >
> > This is just terrible, using the void *mssg to pass a struct which is
> > interpreted by the controller removes any form of abstraction provided
> > by the framework.
> >
> > In my view the void *mssg should point to the data to be written in the
> > mailbox register, and hence might be of different size - but only of
> > native type.
> >
> Please note the terrible 'rx_size' is not a software option - the
> hardware has a DAT register so the driver rightfully allows a client
> to write a value in that as well.

Okay, so the interface exposed by the mailbox driver is not { cmd,
rx_size } but rather __le32 data[2], or perhaps a generic { cmd, data }.
That sounds more generic.


I think it would be good to replace the totally opaque void * with some
sort of structured data type and having the framework ensure that
clients and controllers are compatible. That would, by design, allow for
reuse between controllers and clients.

Perhaps something like:

enum mbox_msg_type {
	MBOX_MSG_TYPE_NULL,
	MBOX_MSG_TYPE_U32,
	MBOX_MSG_TYPE_CMD_DATA,
};

struct mbox_msg {
	enum mbox_msg_type type;

	union {
		u32 u;
		struct {
			u32 cmd;
			u32 data;
		} cd;
	};
};

And have the controller register for a specific "type", so the framework
could validate that the type of data being passed matches the hardware.

Have you had any thoughts around this before?

Regards,
Bjorn

  reply	other threads:[~2017-11-02  3:27 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-01 16:32 [PATCH] mailbox: add support for doorbell/signal mode controllers Sudeep Holla
2017-11-01 18:03 ` Jassi Brar
2017-11-01 18:15   ` Sudeep Holla
2017-11-01 22:17     ` Bjorn Andersson
2017-11-02  3:02       ` Jassi Brar
2017-11-02  3:27         ` Bjorn Andersson [this message]
2017-11-02  4:48           ` Jassi Brar
2017-11-02  2:39     ` Jassi Brar
2017-11-02 10:47       ` Sudeep Holla
2017-11-02 11:26         ` Jassi Brar
2017-11-02 11:49           ` Sudeep Holla
2017-11-02 12:21             ` Jassi Brar
2017-11-02 12:37               ` Sudeep Holla
2017-11-02 14:52                 ` Jassi Brar
2017-11-01 22:12   ` Bjorn Andersson
2017-11-02  2:56     ` Jassi Brar
2017-11-02 10:51     ` Sudeep Holla

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=20171102032728.GI28761@minitux \
    --to=bjorn.andersson@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).