public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: Laszlo Ersek <lersek@redhat.com>
Cc: "edk2-devel@lists.01.org" <edk2-devel@ml01.01.org>
Subject: Re: [PATCH 2/5] ArmVirtPkg: implement FdtPciHostBridgeLib
Date: Wed, 31 Aug 2016 14:54:33 +0100	[thread overview]
Message-ID: <CAKv+Gu8cJ-=ODV2FJ4odzQayMqGa863bO6rGL_U-WV6M=P=DPw@mail.gmail.com> (raw)
In-Reply-To: <43a8b0d8-3368-2841-f6eb-d34fcefb32b1@redhat.com>

On 31 August 2016 at 14:51, Laszlo Ersek <lersek@redhat.com> wrote:
> On 08/24/16 17:19, Ard Biesheuvel wrote:
>> On 24 August 2016 at 17:01, Laszlo Ersek <lersek@redhat.com> wrote:
>>> On 08/22/16 02:35, Ard Biesheuvel wrote:
>
>>>> +  PcdSet64 (PcdPciIoTranslation, IoTranslation);
>>>
>>> I agree this is necessary, but it's not in the right place, plus as-is,
>>> it is not sufficient.
>>>
>>> In <https://tianocore.acgmultimedia.com/show_bug.cgi?id=65#c0> I wrote
>>> -- and I'm slightly reformatting it here, because the formatting got
>>> lost in the GitHub -> BZ migration --:
>>>
>>>     The main customization in ArmVirtPkg/PciHostBridgeDxe is that it
>>>     emulates IO port accesses with an MMIO range, whose base address is
>>>     parsed from the DTB.
>>>
>>>     The core PciHostBridgeDxe driver delegates the IO port access
>>>     implementation to EFI_CPU_IO2_PROTOCOL. @ardbiesheuvel recently
>>>     implemented ArmPkg/Drivers/ArmPciCpuIo2Dxe (in commit 3dece14)
>>>     which provides this protocol, backed by the same kind of
>>>     translation as described above. The base address comes from
>>>     gArmTokenSpaceGuid.PcdPciIoTranslation.
>>>
>>>     Therefore:
>>>
>>>     (1) We should extend our ArmVirtPkg/Library/FdtPciPcdProducerLib
>>>         plugin library to locate the IO translation offset in the DTB,
>>>         and store it in the above PCD.
>>>
>>>     (2) We should include ArmPciCpuIo2Dxe in the ArmVirtQemu builds,
>>>         plugging the above library into it.
>>>
>>>     (3) We should implement a PciHostBridgeLib instance, and plug it
>>>         into the core PciHostBridgeDxe driver.
>>>
>>>         We should create one PCI_ROOT_BRIDGE object, populating it with
>>>         the FTD Client code we are currently using in
>>>         ArmVirtPkg/PciHostBridgeDxe.
>>>
>>>     (4) Extra benefit: the core PciHostBridgeDxe driver supports 64-bit
>>>         MMIO, we just have to parse those values from the DTB as well.
>>>
>>> Steps (2) through (4) are implemented by this series, but I don't think
>>> the above PcdSet64() call satisfies (1). What guarantees that by the
>>> time ArmPciCpuIo2Dxe looks at it, PcdPciIoTranslation will be set?
>>>
>>> ... Especially because PciHostBridgeDxe.inf has a DEPEX on
>>> gEfiCpuIo2ProtocolGuid, so the PcdSet64() above is bound to run *after*
>>> ArmPciCpuIo2Dxe is dispatched?
>>>
>>> Hmmmm... Are you making the argument that the PCD is set *between*
>>> ArmPciCpuIo2Dxe's dispatch and actual use of the PCD? That is:
>>>
>>> - ArmPciCpuIo2Dxe is dispatched
>>> - PciHostBridgeDxe is dispatched
>>> - we set the PCD in this lib (as part of PciHostBridgeDxe's startup)
>>> - (much later) something makes a PCI IO or MEM access that causes
>>>   PciHostBridgeDxe to talk to ArmPciCpuIo2Dxe
>>> - ArmPciCpuIo2Dxe consumes the PCD
>>>
>>> I think this is a valid argument to make -- I've even checked:
>>> ArmPciCpuIo2Dxe indeed performs a PcdGet64() on every CpuIoServiceRead()
>>> / CpuIoServiceWrite(), and none in its entry point --, but it has to be
>>> explained in detail.
>>>
>>> This borders on a hack -- because ArmPciCpuIo2Dxe is not actually ready
>>> for use when its entry point exits with success --, but I think we can
>>> allow it, both ArmPciCpuIo2Dxe and this lib being platform specific, as
>>> long as we document it profusely.
>>>
>>> So please describe this quirk in the commit message, and add a large
>>> comment right above the PcdSet64() call.
>>>
>>> (Also, did you test this series with std VGA, on TCG? That will actually
>>> put the IO translation to use.)
>>>
>>> The alternative to the commit msg addition / code comment would be my
>>> suggestion in (1), that is, to extend FdtPciPcdProducerLib with setting
>>> PcdPciIoTranslation, and to link it into ArmPciCpuIo2Dxe via NULL
>>> library resolution. I guess you don't like that, which is fine, but then
>>> please add the docs. Thanks.
>>>
>>
>> Actually, I prefer your original suggestion, to add it to
>> FdtPciPcdProducerLib. That way, we no longer have to set any PCDs in
>> this code, which is much cleaner imo
>
> Sounds good, thanks!
>
> In this case, the IoTranslation variable should become local to
> ProcessPciHost() -- and ProcessPciHost() only -- in this patch, plus I
> think we should also add
>
>   ASSERT (PcdGet64 (PcdPciIoTranslation) == IoTranslation);
>
> to ProcessPciHost() here, under the DTB_PCI_HOST_RANGE_IO branch.
>
> Furthermore, the zero-assignment of the now-local IoTranslation variable
> should probably be moved out from under the
> '-Werror=maybe-uninitialized' comment, because it won't be an output
> parameter any longer. What do you think?
>

Yes, that was my idea as well. The FdtPciPcdProducerLib will need some
work, but it is ultimately a much cleaner approach.


  reply	other threads:[~2016-08-31 13:54 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-22  6:35 [PATCH 0/5] ArmVirtQemu: move to generic PciHostBridgeDxe Ard Biesheuvel
2016-08-22  6:35 ` [PATCH 1/5] ArmVirtPkg/PciHostBridgeDxe: don't set linux, pci-probe-only DT property Ard Biesheuvel
2016-08-23 21:23   ` Laszlo Ersek
2016-08-24  5:30     ` Ard Biesheuvel
2016-08-22  6:35 ` [PATCH 2/5] ArmVirtPkg: implement FdtPciHostBridgeLib Ard Biesheuvel
2016-08-24 15:01   ` Laszlo Ersek
2016-08-24 15:19     ` Ard Biesheuvel
2016-08-31 13:51       ` Laszlo Ersek
2016-08-31 13:54         ` Ard Biesheuvel [this message]
2016-08-22  6:35 ` [PATCH 3/5] ArmVirtPkg/ArmVirtQemu: switch to generic PciHostBridgeDxe Ard Biesheuvel
2016-08-23 18:04   ` Ard Biesheuvel
2016-08-31 12:24     ` Laszlo Ersek
2016-08-22  6:35 ` [PATCH 4/5] ArmVirtPkg/FdtPciHostBridgeLib: add MMIO64 support Ard Biesheuvel
2016-08-31 14:06   ` Laszlo Ersek
2016-08-22  6:35 ` [PATCH 5/5] ArmVirtPkg: remove now unused PciHostBridgeDxe Ard Biesheuvel
2016-08-31 14:11   ` Laszlo Ersek
2016-08-22 11:58 ` [PATCH 0/5] ArmVirtQemu: move to generic PciHostBridgeDxe 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+Gu8cJ-=ODV2FJ4odzQayMqGa863bO6rGL_U-WV6M=P=DPw@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