linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Oh <poh@qca.qualcomm.com>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: Bob Copeland <me@bobcopeland.com>,
	<linux-wireless@vger.kernel.org>, <ath10k@lists.infradead.org>,
	Peter Oh <poh@qca.qualcomm.com>
Subject: Re: [PATCH] ath10k: Replace ioread with wmb for data sync
Date: Mon, 2 Feb 2015 09:33:40 -0800	[thread overview]
Message-ID: <54CFB4F4.1070807@qca.qualcomm.com> (raw)
In-Reply-To: <1422882133.1930.10.camel@sipsolutions.net>


On 02/02/2015 05:02 AM, Johannes Berg wrote:
> On Fri, 2015-01-30 at 14:53 -0800, Peter Oh wrote:
>
>> I admit that I/O ordering and posted write are looked different in
>> theory and at glance since posted write could be related cache
> invalidate.
>> But wmb are still related to both.
>> As I addressed wmb uses dsb (in arm arch) and here is the description of
>> arm architecture.
>>
>> * DSB drains write buffer.
>> * DSB is architecturally defined to include all cache, TLB and branch
>> prediction maintenance operations as well as explicit memory operations
>>
>> These are the reasons why I mentioned wmb does both.
>>
>> * captured from ARMv7 Architecture Manual
>> --- Notes ---
>> Historically, this operation was referred to as Drain Write Buffer or
>> Data Write Barrier (DWB). From ARMv6, these
>> names and the use of DWB were deprecated in favor of the new Data
>> Synchronization Barrier name and DSB
>> abbreviation. DSB better reflects the functionality provided from ARMv6,
>> because DSB is architecturally defined
>> to include all cache, TLB and branch prediction maintenance operations
>> as well as explicit memory operations
>>
>> --- A DSB completes when: ---
>> ? all explicit memory accesses that are observed by Pe before the DSB is
>> executed, are of the required access
>> types, and are from observers in the same required shareability domain
>> as Pe, are complete for the set of
>> observers in the required shareability domain.
>> ? if the required accesses types of the DSB is reads and writes, all
>> cache and branch predictor maintenance
>> operations issued by Pe before the DSB are complete for the required
>> shareability domain.
>> ? if the required accesses types of the DSB is reads and writes, all TLB
>> maintenance operations issued by Pe
>> before the DSB are complete for the required shareability domain.
>> --------------
> I cannot read from this in any way that it can post writes to the PCIe
> bus. In fact, architecturally, I cannot think of any reason how it even
> could do that from the CPU.
>
>> Furthermore this is the comparison of the compiled assembly code between
>> ath10k_pci_read32 and wmb.
>>
>> ath10k_pci_read32()
>>        bac:    e5932008     ldr    r2, [r3, #8]
>>        bb0:    f57ff04f     dsb    sy
>>        bb4:    e2883d52     add    r3, r8, #5248    ; 0x1480
>>        bb8:    e283303c     add    r3, r3, #60    ; 0x3c
>>        bbc:    e593300c     ldr    r3, [r3, #12]
>>        bc0:    e2833a09     add    r3, r3, #36864    ; 0x9000
>>
>> wmb();
>>        b9c:    f57ff04e     dsb    st
>>
>> ath10k_pci_read32 does register operation except dsb and there is no
>> cache invalidate related commands.
> I don't think this is relevant. The question is "what are you trying to
> achieve".
>
>> So that if wmb is not enough for the purpose then ath10k_pci_read32 is
>> also not enough for that.
>>
>> Also refer the section "ACQUIRES VS I/O ACCESSES" in
> memory-barriers.txt.
>> It gives an example with PCI bridge and introduces readl as an
>> alternative method to mmiowb which weaker form of wmb.
>>
>> Please give your opinion.
> Again - the question is - what are you trying to achieve?
>
> The code (as it is before your patch) implies that it's trying to make
> sure that before it continues, any previous writes to the PCIe device's
> registers are posted. The only way to ensure that is to do a read to the
> registers, as the code does now.
Do you know how the read ensure that although the read code does not 
check the return value?
Can you explain how a read ensures that posted write reaches PCIe device?
> What you're describing is something else entirely - you're describing a
> way to make sure that some data was flushed out to DRAM from the CPU
> caches.
>
> These two things are not related in any way.
>
> In an interrupt routine, it would make sense to ensure that the write
> was posted (e.g. to mask interrupts, or to acknowledge them, or similar,
> before the routine can be re-invoked.)
>
> To me, flushing memory writes to DRAM makes less sense in an interrupt
> handlers unless the device was somehow using DMA to coordinate
> interrupts [1], which seems unlikely but I haven't checked.
>
> Anyway - I have no particular interest in this discussion, I was merely
> trying to help you out with this :) You can make whatever change you
> want, of course :P
>
> johannes
>
> [1] incidentally, our device [iwlwifi] does in fact do something like
> that, but it's read-only for the driver so no need for such a thing
> either
>
>
> _______________________________________________
> ath10k mailing list
> ath10k@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/ath10k
Thanks,
Peter

  reply	other threads:[~2015-02-02 17:34 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-26 22:25 [PATCH] ath10k: Replace ioread with wmb for data sync Peter Oh
2015-01-27 21:33 ` Bob Copeland
2015-01-27 23:53   ` Peter Oh
2015-01-28  4:30     ` Bob Copeland
2015-01-28  5:39       ` Peter Oh
2015-01-28  7:37         ` Johannes Berg
2015-01-30 22:53           ` Peter Oh
2015-01-31  1:16             ` Sujith Manoharan
2015-01-31  1:56               ` Peter Oh
2015-01-31  2:06                 ` Sujith Manoharan
2015-02-02 17:25                   ` Peter Oh
2015-02-02 22:26                   ` Adrian Chadd
2015-02-02 23:04                     ` Peter Oh
2015-02-02 13:02             ` Johannes Berg
2015-02-02 17:33               ` Peter Oh [this message]
2015-02-02 18:54                 ` Johannes Berg
2015-02-02 19:15                   ` Peter Oh
2015-02-02 19:22                     ` Johannes Berg
2015-02-02 19:36                       ` Peter Oh
2015-02-02 19:47                         ` Johannes Berg
2015-02-02 22:06                           ` Peter Oh
2015-02-02 23:25                             ` Florian Fainelli
2015-02-02 23:49                               ` Peter Oh

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=54CFB4F4.1070807@qca.qualcomm.com \
    --to=poh@qca.qualcomm.com \
    --cc=ath10k@lists.infradead.org \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    --cc=me@bobcopeland.com \
    /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).