From: swarren@wwwdotorg.org (Stephen Warren)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 02/10] mailbox: Enable BCM2835 mailbox support
Date: Fri, 06 Mar 2015 13:29:31 -0700 [thread overview]
Message-ID: <54FA0E2B.30300@wwwdotorg.org> (raw)
In-Reply-To: <87bnk5lwvt.fsf@eliezer.anholt.net>
On 03/06/2015 01:00 PM, Eric Anholt wrote:
> Stephen Warren <swarren@wwwdotorg.org> writes:
>
>> On 03/04/2015 11:20 AM, Eric Anholt wrote:
>>> Stephen Warren <swarren@wwwdotorg.org> writes:
>>>
>>>> On 03/02/2015 01:54 PM, Eric Anholt wrote:
>>>>> From: Lubomir Rintel <lkundrak@v3.sk>
>>>>>
>>>>> Implement BCM2835 mailbox support as a device registered with
>>>>> the general purpose mailbox framework. Implementation based on
>>>>> commits by Lubomir Rintel [1], Suman Anna and Jassi Brar [2] on
>>>>> which to base the implementation.
>>>>
>>>>> diff --git a/drivers/mailbox/bcm2835-mailbox.c
>>>>> b/drivers/mailbox/bcm2835-mailbox.c
>>
>>>>> +static irqreturn_t bcm2835_mbox_irq(int irq, void *dev_id) +{
>>>>> + struct bcm2835_mbox *mbox = (struct bcm2835_mbox *) dev_id; +
>>>>> struct device *dev = mbox->dev; + + while (!(readl(mbox->regs +
>>>>> MAIL0_STA) & ARM_MS_EMPTY)) { + u32 msg = readl(mbox->regs +
>>>>> MAIL0_RD); + unsigned int chan = MBOX_CHAN(msg); + + if
>>>>> (!mbox->channel[chan].started) { + dev_err(dev, "Reply on
>>>>> stopped channel %d\n", chan); + continue; + } +
>>>>> dev_dbg(dev, "Reply 0x%08X\n", msg); +
>>>>> mbox_chan_received_data(mbox->channel[chan].link, + (void *)
>>>>> MBOX_DATA28(msg)); + } + rmb(); /* Finished last mailbox read.
>>>>> */
>>>>
>>>> I know the PDF mentioned in the comment earlier in the patch says
>>>> to put in barriers between accesses to different peripherals,
>>>> which this seems compliant with, but I don't see quite what this
>>>> barrier achieves. I think the PDF is talking generalities, not
>>>> imposing a rule that must be blindly followed. Besides, if
>>>> there's a context-switch you can't actually implement the rules
>>>> the PDF suggests. What read operation is this barrier attempting
>>>> to ensure happens after reading all mailbox messages and any
>>>> associated DRAM buffer?
>>>
>>> Looking at this bit of code in particular:
>>>
>>> "As interrupts can appear anywhere in the code so you should
>>> safeguard those. If an interrupt routine reads from a peripheral
>>> the routine should start with a memory read barrier. If an
>>> interrupt routine writes to a peripheral the routine should end
>>> with a memory write barrier."
>>
>> I can see that doing that would be safe, but I don't think following
>> those rules is actually necessary in the general case. Following those
>> rules would cause lots of unnecessary barriers in code.
>>
>> Barriers shouldn't be used arbitrarily at the start/end of ISRs, but
>> rather at specific chosen locations in the code that actually need to
>> enforce some kind of memory ordering.
>
> According to the architecture docs, if you don't RMB at the start of
> your ISR, then the following timeline could get the wrong values:
Which architecture doc and section/... specifically?
> some other device driver our isr
> ------------------------ -------
> rmb()
> read from device
> read from device
> examine value read
> exit isr
> examine value raed.
>
> The ISR could get the device driver's value. This is made explicit in
> footnote 2 on page 7.
Are you saying that the "read from device" in the right -hand "our isr"
column could end up returning the value actually read during "read from
device" in the left-hand "some other device driver" column, or vice-versa?
That doesn't make any sense.
Barriers are about ensuring that accesses happen (are visible or
complete) in the desired order, not about ensuring that the results of
two unrelated reads don't get swapped.
WARNING: multiple messages have this Message-ID (diff)
From: Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
To: Eric Anholt <eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
Cc: linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
Lee Jones <lee-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Jassi Brar
<jassisinghbrar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Craig McGeachie <slapdau-/E1597aS9LT0CCvOHzKKcA@public.gmane.org>,
Lubomir Rintel <lkundrak-NGH9Lh4a5iE@public.gmane.org>,
Suman Anna <s-anna-l0cyMroinI0@public.gmane.org>,
Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: Re: [PATCH 02/10] mailbox: Enable BCM2835 mailbox support
Date: Fri, 06 Mar 2015 13:29:31 -0700 [thread overview]
Message-ID: <54FA0E2B.30300@wwwdotorg.org> (raw)
In-Reply-To: <87bnk5lwvt.fsf-omZaPlIz5HhaEpDpdNBo/KxOck334EZe@public.gmane.org>
On 03/06/2015 01:00 PM, Eric Anholt wrote:
> Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org> writes:
>
>> On 03/04/2015 11:20 AM, Eric Anholt wrote:
>>> Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org> writes:
>>>
>>>> On 03/02/2015 01:54 PM, Eric Anholt wrote:
>>>>> From: Lubomir Rintel <lkundrak-NGH9Lh4a5iE@public.gmane.org>
>>>>>
>>>>> Implement BCM2835 mailbox support as a device registered with
>>>>> the general purpose mailbox framework. Implementation based on
>>>>> commits by Lubomir Rintel [1], Suman Anna and Jassi Brar [2] on
>>>>> which to base the implementation.
>>>>
>>>>> diff --git a/drivers/mailbox/bcm2835-mailbox.c
>>>>> b/drivers/mailbox/bcm2835-mailbox.c
>>
>>>>> +static irqreturn_t bcm2835_mbox_irq(int irq, void *dev_id) +{
>>>>> + struct bcm2835_mbox *mbox = (struct bcm2835_mbox *) dev_id; +
>>>>> struct device *dev = mbox->dev; + + while (!(readl(mbox->regs +
>>>>> MAIL0_STA) & ARM_MS_EMPTY)) { + u32 msg = readl(mbox->regs +
>>>>> MAIL0_RD); + unsigned int chan = MBOX_CHAN(msg); + + if
>>>>> (!mbox->channel[chan].started) { + dev_err(dev, "Reply on
>>>>> stopped channel %d\n", chan); + continue; + } +
>>>>> dev_dbg(dev, "Reply 0x%08X\n", msg); +
>>>>> mbox_chan_received_data(mbox->channel[chan].link, + (void *)
>>>>> MBOX_DATA28(msg)); + } + rmb(); /* Finished last mailbox read.
>>>>> */
>>>>
>>>> I know the PDF mentioned in the comment earlier in the patch says
>>>> to put in barriers between accesses to different peripherals,
>>>> which this seems compliant with, but I don't see quite what this
>>>> barrier achieves. I think the PDF is talking generalities, not
>>>> imposing a rule that must be blindly followed. Besides, if
>>>> there's a context-switch you can't actually implement the rules
>>>> the PDF suggests. What read operation is this barrier attempting
>>>> to ensure happens after reading all mailbox messages and any
>>>> associated DRAM buffer?
>>>
>>> Looking at this bit of code in particular:
>>>
>>> "As interrupts can appear anywhere in the code so you should
>>> safeguard those. If an interrupt routine reads from a peripheral
>>> the routine should start with a memory read barrier. If an
>>> interrupt routine writes to a peripheral the routine should end
>>> with a memory write barrier."
>>
>> I can see that doing that would be safe, but I don't think following
>> those rules is actually necessary in the general case. Following those
>> rules would cause lots of unnecessary barriers in code.
>>
>> Barriers shouldn't be used arbitrarily at the start/end of ISRs, but
>> rather at specific chosen locations in the code that actually need to
>> enforce some kind of memory ordering.
>
> According to the architecture docs, if you don't RMB at the start of
> your ISR, then the following timeline could get the wrong values:
Which architecture doc and section/... specifically?
> some other device driver our isr
> ------------------------ -------
> rmb()
> read from device
> read from device
> examine value read
> exit isr
> examine value raed.
>
> The ISR could get the device driver's value. This is made explicit in
> footnote 2 on page 7.
Are you saying that the "read from device" in the right -hand "our isr"
column could end up returning the value actually read during "read from
device" in the left-hand "some other device driver" column, or vice-versa?
That doesn't make any sense.
Barriers are about ensuring that accesses happen (are visible or
complete) in the desired order, not about ensuring that the results of
two unrelated reads don't get swapped.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2015-03-06 20:29 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-02 20:54 Raspberry Pi mailbox drivers Eric Anholt
2015-03-02 20:54 ` [PATCH 02/10] mailbox: Enable BCM2835 mailbox support Eric Anholt
2015-03-02 20:54 ` Eric Anholt
2015-03-04 3:03 ` Stephen Warren
2015-03-04 3:03 ` Stephen Warren
2015-03-04 9:48 ` Arnd Bergmann
2015-03-04 9:48 ` Arnd Bergmann
2015-03-04 18:20 ` Eric Anholt
2015-03-04 18:20 ` Eric Anholt
2015-03-06 4:54 ` Stephen Warren
2015-03-06 4:54 ` Stephen Warren
2015-03-06 20:00 ` Eric Anholt
2015-03-06 20:00 ` Eric Anholt
2015-03-06 20:29 ` Stephen Warren [this message]
2015-03-06 20:29 ` Stephen Warren
2015-03-06 21:40 ` Stephen Warren
2015-03-06 21:40 ` Stephen Warren
2015-03-04 18:28 ` Eric Anholt
2015-03-04 18:28 ` Eric Anholt
[not found] ` <1425329684-23968-1-git-send-email-eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
2015-03-02 20:54 ` [PATCH 01/10] dt/bindings: Add binding for BCM2835 mailbox driver Eric Anholt
[not found] ` <1425329684-23968-2-git-send-email-eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
2015-03-03 8:05 ` Lee Jones
2015-03-03 19:28 ` Eric Anholt
[not found] ` <87vbih98za.fsf-omZaPlIz5HhaEpDpdNBo/KxOck334EZe@public.gmane.org>
2015-03-04 2:37 ` Stephen Warren
[not found] ` <54F66FDD.2040409-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2015-03-04 17:44 ` Eric Anholt
2015-03-12 23:23 ` Eric Anholt
[not found] ` <87egothkaf.fsf-omZaPlIz5HhaEpDpdNBo/KxOck334EZe@public.gmane.org>
2015-03-17 3:08 ` Stephen Warren
[not found] ` <55079AA0.5090904-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2015-03-17 19:10 ` Eric Anholt
[not found] ` <87vbhzl9t1.fsf-omZaPlIz5HhaEpDpdNBo/KxOck334EZe@public.gmane.org>
2015-03-18 1:52 ` Stephen Warren
2015-03-02 20:54 ` [PATCH 03/10] ARM: bcm2835: Add the mailbox to the device tree Eric Anholt
[not found] ` <1425329684-23968-4-git-send-email-eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
2015-03-03 8:34 ` Lee Jones
2015-03-02 20:54 ` [PATCH 04/10] dt/bindings: Add binding for BCM2835 mailbox power channel driver Eric Anholt
[not found] ` <1425329684-23968-5-git-send-email-eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
2015-03-04 3:07 ` Stephen Warren
2015-03-02 20:54 ` [PATCH 05/10] ARM: bcm2835: Add the " Eric Anholt
[not found] ` <1425329684-23968-6-git-send-email-eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
2015-03-02 21:09 ` Arnd Bergmann
2015-03-02 22:02 ` Eric Anholt
2015-03-04 3:15 ` Stephen Warren
2015-03-02 20:54 ` [PATCH 06/10] ARM: bcm2835: Add the mailbox power channel to the device tree Eric Anholt
2015-03-02 20:54 ` [PATCH 07/10] usb: Make sure that DWC2 initializes after the power channel mailbox driver Eric Anholt
[not found] ` <1425329684-23968-8-git-send-email-eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
2015-03-03 8:32 ` Lee Jones
2015-03-03 20:32 ` [PATCH 07/10 v2] " Eric Anholt
[not found] ` <1425414778-30820-1-git-send-email-eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
2015-03-04 3:24 ` Stephen Warren
2015-03-04 3:17 ` [PATCH 07/10] " Stephen Warren
[not found] ` <54F67944.1030501-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2015-03-04 9:50 ` Arnd Bergmann
2015-03-02 20:54 ` [PATCH 08/10] dt/bindings: Add binding for BCM2835 mailbox property channel driver Eric Anholt
[not found] ` <1425329684-23968-9-git-send-email-eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
2015-03-04 3:53 ` Stephen Warren
[not found] ` <54F681CE.2070801-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2015-03-05 19:50 ` Eric Anholt
[not found] ` <87wq2v6x69.fsf-omZaPlIz5HhaEpDpdNBo/KxOck334EZe@public.gmane.org>
2015-03-06 5:15 ` Stephen Warren
[not found] ` <54F937DF.3020001-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2015-03-06 6:05 ` Jassi Brar
2015-03-02 20:54 ` [PATCH 09/10] ARM: bcm2835: Add the " Eric Anholt
[not found] ` <1425329684-23968-10-git-send-email-eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
2015-03-04 4:00 ` Stephen Warren
[not found] ` <54F68352.5080108-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2015-03-05 19:54 ` Eric Anholt
2015-03-06 5:05 ` Stephen Warren
2015-03-06 5:05 ` Stephen Warren
2015-03-02 20:54 ` [PATCH 10/10] ARM: bcm2835: Add the mailbox property channel to the device tree Eric Anholt
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=54FA0E2B.30300@wwwdotorg.org \
--to=swarren@wwwdotorg.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 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.