public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: "Ni, Ruiyu" <ruiyu.ni@intel.com>
Cc: Guo Heyi <heyi.guo@linaro.org>, Laszlo Ersek <lersek@redhat.com>,
	 "edk2-devel@lists.01.org" <edk2-devel@lists.01.org>,
	Eric Dong <eric.dong@intel.com>,
	 Michael D Kinney <michael.d.kinney@intel.com>,
	Star Zeng <star.zeng@intel.com>
Subject: Re: [RFC v3 1/3] MdeModulePkg/PciHostBridgeDxe: Add support for address translation
Date: Sat, 24 Feb 2018 08:14:19 +0000	[thread overview]
Message-ID: <CAKv+Gu_9KXGYoCgjiV3uQKuvD1iv-h3fjgU0Rvg3t_7dVWP14Q@mail.gmail.com> (raw)
In-Reply-To: <56a50ebe-c27e-1a0b-1d96-30b0443fee59@Intel.com>

On 24 February 2018 at 03:11, Ni, Ruiyu <ruiyu.ni@intel.com> wrote:
...
>>> (6) For all of these, I believe that we have to think about the corner
>>> case when the Translation value is not a multiple of (Alignment + 1).
>>>
>>> "Alignment" comes from the PCI BAR in question, whereas Base comes from
>>> the platform PciHostBridgeLib. I think these are fairly independent (you
>>> can plug a 3rd party, discrete PCI card into a board). I find it
>>> plausible that the card has such a huge MMIO BAR (and alignment) that
>>> the platform's Translation offset is not a multiple thereof.
>>>
>>> So, which "view" has to be aligned here? The PCI (device) view, or the
>>> host (CPU) view?
>>
>>
>> I believe the alignment requirement is from PCI view, not the CPU view.
>> This
>> also implies alignment in allocating GCD resources becomes meaningless.
>
> I agree. It's an issue we need to think about.
>
> All address spaces in GCD are added by gDS->AddXXX().
> So it means for a given range of address [HostBase, HostLimit) in GCD,
> the corresponding device address is
> [HostBase + Offset, HostLimit + Offset).
> E.g.: GCD entry = [0xFFD, 0x3FFD), Offset = 0x3
> The corresponding device address range is [0x1000, 0x4000)
> If we want to allocate 3 page-aligned pages of MMIO from GCD,
> current AllocateResource() implementation will fail to allocate.
>
> What will the Offset be in real world?
> If it's quite small (smaller than device required alignment),
> thing becomes complicated. I even cannot think of any solution.
> If it's quite large (larger than device required alignment),
> thing becomes easy. Today's implementation can handle it well.
>

I see two typical use cases for this address translation feature:
- adding an address offset to TypeTranslation I/O range, i.e., two RCs
both using 0x0-0xffff on the PCI side, but requiring non-overlapping
memory ranges on the CPU side (this is a limitation in the ACPI spec,
where an I/O range cannot be subject to address translation and type
translation at the same time)
- mapping a MMIO32 range high in the CPU address space

In both cases, I think it is reasonable as an implementation
requirement that the translation is sufficiently aligned, maybe even
to the size of the entire window.


  parent reply	other threads:[~2018-02-24  8:08 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-23  8:53 [RFC v3 0/3] Add translation support to generic PciHostBridge Heyi Guo
2018-02-23  8:53 ` [RFC v3 1/3] MdeModulePkg/PciHostBridgeDxe: Add support for address translation Heyi Guo
2018-02-23 15:05   ` Laszlo Ersek
2018-02-23 15:17     ` Ard Biesheuvel
2018-02-23 15:26       ` Laszlo Ersek
2018-02-24  1:10     ` Guo Heyi
2018-02-24  1:51     ` Guo Heyi
2018-02-24  3:11       ` Ni, Ruiyu
2018-02-24  3:59         ` Guo Heyi
2018-02-24  8:30           ` Ni, Ruiyu
2018-02-24  9:15             ` Guo Heyi
2018-02-24  8:14         ` Ard Biesheuvel [this message]
2018-02-27  2:19     ` Guo Heyi
2018-02-23  8:53 ` [RFC v3 2/3] MdeModulePkg/PciBus: convert host address to device address Heyi Guo
2018-02-23  8:53 ` [RFC v3 3/3] MdeModulePkg/PciBus: return CPU address for GetBarAttributes Heyi Guo
2018-02-23 15:08   ` Laszlo Ersek

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=CAKv+Gu_9KXGYoCgjiV3uQKuvD1iv-h3fjgU0Rvg3t_7dVWP14Q@mail.gmail.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