public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Michael Brown" <mcb30@ipxe.org>
To: devel@edk2.groups.io, ardb@kernel.org, pedro.falcato@gmail.com
Cc: jlotwo@gmail.com, Leif Lindholm <quic_llindhol@quicinc.com>,
	 Sami Mujawar <sami.mujawar@arm.com>, Ray Ni <ray.ni@intel.com>
Subject: Re: [edk2-devel] [RFC] Ordering of Arm PCI ECAM and MMIO operations
Date: Wed, 1 Nov 2023 12:25:43 +0000	[thread overview]
Message-ID: <0102018b8ad8c2e7-187ec6ab-01ca-4b47-8c19-aa2748065b06-000000@eu-west-1.amazonses.com> (raw)
In-Reply-To: <CAMj1kXHTX3Hwh1zZ_3CruOoCXNGtx216S5G8-XnLte=zHp7jWw@mail.gmail.com>

On 01/11/2023 09:56, Ard Biesheuvel wrote:
> On Wed, 1 Nov 2023 at 03:09, Pedro Falcato <pedro.falcato@gmail.com> wrote:
>> On Wed, Nov 1, 2023 at 12:40 AM Joe L <jlotwo@gmail.com> wrote:
>>> Our CMN TRM showcases an example where ECAM and MMIO are two different regions in the HN-I SAM. The implication is that we would expect a DSB between the ECAM write and MMIO read. I'm asking our Open Source Software group to confirm that standard PCIe software is generally expected to be aware of the need for a DSB--but my impression from talking to some of our hardware engineers is that that is indeed the expectation.
> 
> <snip>
> 
> 1) as per the architecture (as interpreted by the ARM architects), a
> DSB is required to ensure that the side effects of enabling a MMIO BAR
> in the PCI config space are sufficiently observable to memory accesses
> to that BAR that appear after the PCI config space access in the
> program.

It's possibly worth mentioning what the PCIe specification requires in 
terms of ECAM ordering:

   "As an example, software may wish to configure a device Function’s
    Base Address register by writing to the device using the ECAM,
    and then read a location in the memory-mapped range described by
    this Base Address register. If the software were to issue the
    memory-mapped read before the ECAM write was completed, it would
    be possible for the memory-mapped read to be re-ordered and arrive
    at the device before the Configuration Write Request, thus causing
    unpredictable results.

    To avoid this problem, processor and host bridge implementations must
    ensure that a method exists for the software to determine when the
    write using the ECAM is completed by the completer."

By my reading, the PCIe specification seems to therefore require 
something stronger than an ordering guarantee: it requires the ability 
for software to make a standalone determination that the write has 
*completed*, independent of the existence of any subsequent I/O operations.

As a practical example of when this might be relevant: software could be 
writing to device configuration space to disable bus mastering as part 
of a reset or shutdown sequence, in order to guarantee that the device 
will initiate no further DMA operations and that any DMA buffers 
allocated to the device can be freed and reused.  In this situation, 
there may be no subsequent MMIO read or write to the device, and so 
there is no way to rely upon an ordering guarantee to satisfy the 
requirement.

Any solution involving ordering guarantees can therefore mask the 
problem in some situations, but cannot solve it.

The PCIe specification does not mandate that any particular mechanism be 
used, but it does require that the processor and/or host bridge provides 
*some* mechanism for software to determine that the ECAM write has 
completed.

What mechanism does ARM (or the host bridge) provide to determine 
completion of an ECAM write?

Thanks,

Michael



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#110477): https://edk2.groups.io/g/devel/message/110477
Mute This Topic: https://groups.io/mt/102310377/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



  reply	other threads:[~2023-11-01 12:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-31 23:24 [edk2-devel] [RFC] Ordering of Arm PCI ECAM and MMIO operations Joe L
2023-11-01  2:09 ` Pedro Falcato
2023-11-01  9:56   ` Ard Biesheuvel
2023-11-01 12:25     ` Michael Brown [this message]
2023-11-01 12:51       ` Ard Biesheuvel
2023-11-01 13:23         ` Michael Brown
2023-11-01 16:41           ` Ard Biesheuvel
2023-11-01 20:17             ` Joe L
2023-11-01 21:51               ` Michael Brown
2023-11-01 23:07                 ` Pedro Falcato

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-list 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=0102018b8ad8c2e7-187ec6ab-01ca-4b47-8c19-aa2748065b06-000000@eu-west-1.amazonses.com \
    --to=devel@edk2.groups.io \
    /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