From: Hector Martin <marcan@marcan.st>
To: jassisinghbrar@gmail.com
Cc: Anup Patel <anup.patel@broadcom.com>,
Vinod Koul <vkoul@kernel.org>, Sven Peter <sven@svenpeter.dev>,
Alyssa Rosenzweig <alyssa@rosenzweig.io>,
Mun Yew Tham <mun.yew.tham@intel.com>,
Chen-Yu Tsai <wens@csie.org>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Samuel Holland <samuel@sholland.org>,
Michal Simek <michal.simek@xilinx.com>,
Arnd Bergmann <arnd@arndb.de>,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-sunxi@lists.linux.dev
Subject: Re: [PATCH 0/7] mailbox: apple: peek_data cleanup and implementation
Date: Wed, 25 May 2022 00:15:45 +0900 [thread overview]
Message-ID: <8d20b41e-c529-a7f9-11f2-350fa14c9f98@marcan.st> (raw)
In-Reply-To: <20220524145540.363553-1-jassisinghbrar@gmail.com>
On 24/05/2022 23.55, jassisinghbrar@gmail.com wrote:
> From: Jassi Brar <jassisinghbrar@gmail.com>
>> The mailbox API has a `peek_data` operation. Its intent and
>> documentation is rather ambiguous; at first glance and based on the
>> name, it seems like it should only check for whether data is currently
>> pending in the controller, without actually delivering it to the
>> consumer. However, this interpretation is not useful for anything: the
>> function can be called from atomic context, but without a way to
>> actually *poll* for data from atomic context, there is no use in just
>> checking for whether data is available.
>>
> Not exactly... the 'peek_data' is a means for client driver to hint the
> controller driver that some data might have arrived (for controllers that
> don't have anything like RX-Irq). The controller is then expected to dispatch
> data after "not necessarily atomic" read.
If that was the intent, there are no in-kernel users with the "hint"
intent... I am having a hard time imagining a use case for those semantics.
Are there any controllers without an RX IRQ? What do they do, poll
constantly? Or just assume all requests are req/response and have
drivers poll via this function when a request is pending? And in that
case wouldn't reading be atomic too anyway?
> For example, a quick look at some bit may tell there is data available,
> but actually reading the data from buffer may be non-atomic.
Are there any examples of mailbox drivers that have this constraint?
> In your case, you could already implement the patch-7/7 by simply calling it
> peek_data() instead of poll_data(). Its ok to call mbox_chan_received_data()
> from peek_data() because your data-read can be atomic.
So some mailboxes may implement peek_data in a way that guarantees
atomic/synchronous data arrival, and some may not, and consumers are
expected to just know how their particular mailbox behaves?
That doesn't sound like a very good API design...
> Also some platforms may not have users of peek_data upstream (yet), so
> simply weeding them out may not be right.
That's why everyone involved is CCed :)
I'm going to be honest though: I'm finding the entire mailbox
abstraction to be very frustrating. It's trying to cater to a bunch of
rather disparate hardware used as a low-level channel for very tightly
coupled drivers and, in the end, fails to be a useful abstraction since
it can't abstract those differences away. It would've taken us less code
to open-code the mailbox part of our driver into its only consumer,
would've saved a bunch of debugging and headaches, and would perform
better, and wouldn't lose any generality since we only have one consumer
anyway (and if we had more it'd still take less code to roll our own API
rather than using mailbox...).
--
Hector Martin (marcan@marcan.st)
Public Key: https://mrcn.st/pub
prev parent reply other threads:[~2022-05-24 15:16 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-02 9:02 [PATCH 0/7] mailbox: apple: peek_data cleanup and implementation Hector Martin
2022-05-02 9:02 ` [PATCH 1/7] mailbox: zynq: Remove unused zynqmp_ipi_peek_data Hector Martin
2022-05-02 9:02 ` [PATCH 2/7] mailbox: sun6i: Unexport unused sun6i_msgbox_peek_data Hector Martin
2022-05-02 23:18 ` Samuel Holland
2022-05-02 9:02 ` [PATCH 3/7] mailbox: ti-msgmgr Remove unused ti_msgmgr_queue_peek_data Hector Martin
2022-05-02 9:02 ` [PATCH 4/7] mailbox: altera: Remove unused altera_mbox_peek_data Hector Martin
2022-05-02 9:02 ` [PATCH 5/7] mailbox: Rename peek_data to poll_data and fix documentation Hector Martin
2022-05-02 9:02 ` [PATCH 6/7] mailbox: apple: Implement flush() operation Hector Martin
2022-05-02 9:02 ` [PATCH 7/7] mailbox: apple: Implement poll_data() operation Hector Martin
2022-05-02 9:05 ` [PATCH 0/7] mailbox: apple: peek_data cleanup and implementation Hector Martin
2022-05-24 14:55 ` jassisinghbrar
2022-05-24 15:15 ` Hector Martin [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=8d20b41e-c529-a7f9-11f2-350fa14c9f98@marcan.st \
--to=marcan@marcan.st \
--cc=alyssa@rosenzweig.io \
--cc=anup.patel@broadcom.com \
--cc=arnd@arndb.de \
--cc=dmaengine@vger.kernel.org \
--cc=jassisinghbrar@gmail.com \
--cc=jernej.skrabec@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=michal.simek@xilinx.com \
--cc=mun.yew.tham@intel.com \
--cc=samuel@sholland.org \
--cc=sven@svenpeter.dev \
--cc=vkoul@kernel.org \
--cc=wens@csie.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).