From: Jassi Brar <jassisinghbrar@gmail.com>
To: Sven Peter <sven@svenpeter.dev>
Cc: Rob Herring <robh+dt@kernel.org>,
Mark Kettenis <mark.kettenis@xs4all.nl>,
Hector Martin <marcan@marcan.st>,
Alyssa Rosenzweig <alyssa@rosenzweig.io>,
Mohamed Mediouni <mohamed.mediouni@caramail.com>,
Stan Skowronek <stan@corellium.com>,
Devicetree List <devicetree@vger.kernel.org>,
linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 2/2] mailbox: apple: Add driver for Apple mailboxes
Date: Sat, 16 Oct 2021 14:04:34 -0500 [thread overview]
Message-ID: <CABb+yY2XxpQa-QqsVnzVsYb+msSiOiELE1R5UFjE02Diwww2Ew@mail.gmail.com> (raw)
In-Reply-To: <20210916154911.3168-3-sven@svenpeter.dev>
On Thu, Sep 16, 2021 at 10:49 AM Sven Peter <sven@svenpeter.dev> wrote:
....
> +static const struct apple_mbox_hw apple_mbox_asc_hw = {
> + .control_full = APPLE_ASC_MBOX_CONTROL_FULL,
> + .control_empty = APPLE_ASC_MBOX_CONTROL_EMPTY,
> +
> + .a2i_control = APPLE_ASC_MBOX_A2I_CONTROL,
> + .a2i_send0 = APPLE_ASC_MBOX_A2I_SEND0,
> + .a2i_send1 = APPLE_ASC_MBOX_A2I_SEND1,
> +
> + .i2a_control = APPLE_ASC_MBOX_I2A_CONTROL,
> + .i2a_recv0 = APPLE_ASC_MBOX_I2A_RECV0,
> + .i2a_recv1 = APPLE_ASC_MBOX_I2A_RECV1,
> +
> + .has_irq_controls = false,
> +};
> +
> +static const struct apple_mbox_hw apple_mbox_m3_hw = {
> + .control_full = APPLE_M3_MBOX_CONTROL_FULL,
> + .control_empty = APPLE_M3_MBOX_CONTROL_EMPTY,
> +
> + .a2i_control = APPLE_M3_MBOX_A2I_CONTROL,
> + .a2i_send0 = APPLE_M3_MBOX_A2I_SEND0,
> + .a2i_send1 = APPLE_M3_MBOX_A2I_SEND1,
> +
> + .i2a_control = APPLE_M3_MBOX_I2A_CONTROL,
> + .i2a_recv0 = APPLE_M3_MBOX_I2A_RECV0,
> + .i2a_recv1 = APPLE_M3_MBOX_I2A_RECV1,
> +
> + .has_irq_controls = true,
> + .irq_enable = APPLE_M3_MBOX_IRQ_ENABLE,
> + .irq_ack = APPLE_M3_MBOX_IRQ_ACK,
> + .irq_bit_recv_not_empty = APPLE_M3_MBOX_IRQ_I2A_NOT_EMPTY,
> + .irq_bit_send_empty = APPLE_M3_MBOX_IRQ_A2I_EMPTY,
> +};
> +
> +static const struct of_device_id apple_mbox_of_match[] = {
> + { .compatible = "apple,t8103-asc-mailbox", .data = &apple_mbox_asc_hw },
> + { .compatible = "apple,t8103-m3-mailbox", .data = &apple_mbox_m3_hw },
> + {}
> +};
> +MODULE_DEVICE_TABLE(of, apple_mbox_of_match);
> +
Traditionally, these go at the end of file.
....
> +
> +static int apple_mbox_hw_send(struct apple_mbox *apple_mbox,
> + struct apple_mbox_msg *msg)
> +{
> + if (!apple_mbox_hw_can_send(apple_mbox))
> + return -EBUSY;
> +
> + dev_dbg(apple_mbox->dev, "> TX %016llx %08x\n", msg->msg0, msg->msg1);
> +
> + /*
> + * This message may be related to a shared memory buffer and we must
> + * ensure all previous writes to normal memory are visible before
> + * submitting it.
> + */
> + dma_wmb();
> +
This may cause unnecessary overhead.
mbox_client.tx_prepare() is where the SHMEM data is copied, which
should also call dma_wmb() just before return.
......
> +
> +static int apple_mbox_hw_recv(struct apple_mbox *apple_mbox,
> + struct apple_mbox_msg *msg)
> +{
> + if (!apple_mbox_hw_can_recv(apple_mbox))
> + return -ENOMSG;
> +
> + msg->msg0 = readq_relaxed(apple_mbox->regs + apple_mbox->hw->i2a_recv0);
> + msg->msg1 = FIELD_GET(
> + APPLE_MBOX_MSG1_MSG,
> + readq_relaxed(apple_mbox->regs + apple_mbox->hw->i2a_recv1));
> +
> + dev_dbg(apple_mbox->dev, "< RX %016llx %08x\n", msg->msg0, msg->msg1);
> +
> + /*
> + * This message may be related to a shared memory buffer and we must
> + * ensure any following reads from normal memory only happen after
> + * having read this message.
> + */
> + dma_rmb();
> +
.... similarly should be done by the client as the first thing in recv callback.
> +static struct mbox_chan *apple_mbox_of_xlate(struct mbox_controller *mbox,
> + const struct of_phandle_args *spec)
> +{
> + struct apple_mbox *apple_mbox = dev_get_drvdata(mbox->dev);
> +
> + if (spec->args_count != 0)
> + return ERR_PTR(-EINVAL);
> + if (apple_mbox->chan.con_priv)
> + return ERR_PTR(-EBUSY);
> +
> + apple_mbox->chan.con_priv = apple_mbox;
> + return &apple_mbox->chan;
> +}
> +
we could do without of_xlate callback, by assigning chan.con_priv
already in the .probe()
> diff --git a/include/linux/apple-mailbox.h b/include/linux/apple-mailbox.h
> +
> +struct apple_mbox_msg {
> + u64 msg0;
> + u32 msg1;
> +};
> +
Aren't msg0/1 the Tx and Rx channels? If so you may want to separate
them out as such. But of course, I don't know the h/w details so I may
be wrong.
Cheers!
next prev parent reply other threads:[~2021-10-16 19:04 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-16 15:49 [PATCH v2 0/2] Apple Mailbox Controller support Sven Peter
2021-09-16 15:49 ` [PATCH v2 1/2] dt-bindings: mailbox: Add Apple mailbox bindings Sven Peter
2021-09-21 22:08 ` Rob Herring
2021-09-16 15:49 ` [PATCH v2 2/2] mailbox: apple: Add driver for Apple mailboxes Sven Peter
2021-09-19 11:51 ` Alyssa Rosenzweig
2021-10-16 19:04 ` Jassi Brar [this message]
2021-10-16 19:16 ` Alyssa Rosenzweig
2021-10-16 19:17 ` Sven Peter
2021-10-17 11:25 ` Mark Kettenis
2021-10-17 11:27 ` Sven Peter
2021-09-19 11:47 ` [PATCH v2 0/2] Apple Mailbox Controller support Alyssa Rosenzweig
2021-10-16 9:21 ` Sven Peter
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=CABb+yY2XxpQa-QqsVnzVsYb+msSiOiELE1R5UFjE02Diwww2Ew@mail.gmail.com \
--to=jassisinghbrar@gmail.com \
--cc=alyssa@rosenzweig.io \
--cc=devicetree@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcan@marcan.st \
--cc=mark.kettenis@xs4all.nl \
--cc=mohamed.mediouni@caramail.com \
--cc=robh+dt@kernel.org \
--cc=stan@corellium.com \
--cc=sven@svenpeter.dev \
/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).