public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Laszlo Ersek" <lersek@redhat.com>
To: Jiahui Cen <cenjiahui@huawei.com>, devel@edk2.groups.io
Cc: Jordan Justen <jordan.l.justen@intel.com>,
	Ard Biesheuvel <ard.biesheuvel@arm.com>,
	Rebecca Cran <rebecca@bsdio.com>,
	Peter Grehan <grehan@freebsd.org>,
	Anthony Perard <anthony.perard@citrix.com>,
	Julien Grall <julien@xen.org>, Leif Lindholm <leif@nuviainc.com>,
	Sami Mujawar <sami.mujawar@arm.com>,
	xieyingtai@huawei.com, wu.wubin@huawei.com,
	Yubo Miao <miaoyubo@huawei.com>
Subject: Re: [edk2-devel] [PATCH v4 5/9] ArmVirtPkg/FdtPciHostBridgeLib: Rebase to InitRootBridge() / UninitRootBridge()
Date: Wed, 13 Jan 2021 10:05:16 +0100	[thread overview]
Message-ID: <1d9dfe70-21d3-54a0-f180-eaa77a2643d0@redhat.com> (raw)
In-Reply-To: <be57d8a8-bb5a-b4b4-355f-5d71f6d3a8f4@huawei.com>

On 01/13/21 07:10, Jiahui Cen wrote:
> Hi Laszlo,
> 
> On 2021/1/13 10:15, Laszlo Ersek wrote:
>> On 01/12/21 10:45, Jiahui Cen via groups.io wrote:
>>> Rebase ArmVirtPkg/FdtPciHostBridgeLib to the new
>>> PciHostBridgeUtilityInitRootBridge() / PciHostBridgeUtilityUninitRootBridge()
>>> functions.
>>>
>>> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3059
>>>
>>> Cc: Laszlo Ersek <lersek@redhat.com>
>>> Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
>>> Cc: Leif Lindholm <leif@nuviainc.com>
>>> Signed-off-by: Jiahui Cen <cenjiahui@huawei.com>
>>> Signed-off-by: Yubo Miao <miaoyubo@huawei.com>
>>> ---
>>>  ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.inf |   1 +
>>>  ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.c   | 124 ++++++++++----------
>>>  2 files changed, 61 insertions(+), 64 deletions(-)
>>>
>>> diff --git a/ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.inf b/ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.inf
>>> index 01d39626d14c..b813a0851d2a 100644
>>> --- a/ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.inf
>>> +++ b/ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.inf
>>> @@ -34,6 +34,7 @@ [Packages]
>>>    OvmfPkg/OvmfPkg.dec
>>>
>>>  [LibraryClasses]
>>> +  BaseMemoryLib
>>>    DebugLib
>>>    DevicePathLib
>>>    DxeServicesTableLib
>>> diff --git a/ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.c b/ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.c
>>> index d554479bf0de..95166d18c82d 100644
>>> --- a/ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.c
>>> +++ b/ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.c
>>> @@ -7,6 +7,7 @@
>>>
>>>  **/
>>>  #include <PiDxe.h>
>>> +#include <Library/BaseMemoryLib.h>
>>>  #include <Library/DebugLib.h>
>>>  #include <Library/DevicePathLib.h>
>>>  #include <Library/DxeServicesTableLib.h>
>>> @@ -20,37 +21,6 @@
>>>  #include <Protocol/PciRootBridgeIo.h>
>>>  #include <Protocol/PciHostBridgeResourceAllocation.h>
>>>
>>> -#pragma pack(1)
>>> -typedef struct {
>>> -  ACPI_HID_DEVICE_PATH     AcpiDevicePath;
>>> -  EFI_DEVICE_PATH_PROTOCOL EndDevicePath;
>>> -} EFI_PCI_ROOT_BRIDGE_DEVICE_PATH;
>>> -#pragma pack ()
>>> -
>>> -STATIC EFI_PCI_ROOT_BRIDGE_DEVICE_PATH mEfiPciRootBridgeDevicePath = {
>>> -  {
>>> -    {
>>> -      ACPI_DEVICE_PATH,
>>> -      ACPI_DP,
>>> -      {
>>> -        (UINT8) (sizeof(ACPI_HID_DEVICE_PATH)),
>>> -        (UINT8) ((sizeof(ACPI_HID_DEVICE_PATH)) >> 8)
>>> -      }
>>> -    },
>>> -    EISA_PNP_ID(0x0A03),
>>> -    0
>>> -  },
>>> -
>>> -  {
>>> -    END_DEVICE_PATH_TYPE,
>>> -    END_ENTIRE_DEVICE_PATH_SUBTYPE,
>>> -    {
>>> -      END_DEVICE_PATH_LENGTH,
>>> -      0
>>> -    }
>>> -  }
>>> -};
>>> -
>>>  //
>>>  // We expect the "ranges" property of "pci-host-ecam-generic" to consist of
>>>  // records like this.
>>> @@ -319,11 +289,18 @@ PciHostBridgeGetRootBridges (
>>>    UINTN *Count
>>>    )
>>>  {
>>> -  UINT64              IoBase, IoSize;
>>> -  UINT64              Mmio32Base, Mmio32Size;
>>> -  UINT64              Mmio64Base, Mmio64Size;
>>> -  UINT32              BusMin, BusMax;
>>> -  EFI_STATUS          Status;
>>> +  UINT64                   IoBase, IoSize;
>>> +  UINT64                   Mmio32Base, Mmio32Size;
>>> +  UINT64                   Mmio64Base, Mmio64Size;
>>> +  UINT32                   BusMin, BusMax;
>>> +  EFI_STATUS               Status;
>>> +  UINT64                   Attributes;
>>> +  UINT64                   AllocationAttributes;
>>> +  PCI_ROOT_BRIDGE_APERTURE Io;
>>> +  PCI_ROOT_BRIDGE_APERTURE Mem;
>>> +  PCI_ROOT_BRIDGE_APERTURE MemAbove4G;
>>> +  PCI_ROOT_BRIDGE_APERTURE PMem;
>>> +  PCI_ROOT_BRIDGE_APERTURE PMemAbove4G;
>>>
>>>    if (PcdGet64 (PcdPciExpressBaseAddress) == 0) {
>>>      DEBUG ((EFI_D_INFO, "%a: PCI host bridge not present\n", __FUNCTION__));
>>> @@ -341,33 +318,29 @@ PciHostBridgeGetRootBridges (
>>>      return NULL;
>>>    }
>>>
>>> -  *Count = 1;
>>> +  ZeroMem (&Io, sizeof (Io));
>>> +  ZeroMem (&Mem, sizeof (Mem));
>>> +  ZeroMem (&MemAbove4G, sizeof (MemAbove4G));
>>> +  ZeroMem (&PMem, sizeof (PMem));
>>> +  ZeroMem (&PMemAbove4G, sizeof (PMemAbove4G));
>>>
>>> -  mRootBridge.Segment               = 0;
>>> -  mRootBridge.Supports              = EFI_PCI_ATTRIBUTE_ISA_IO_16 |
>>> -                                      EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO |
>>> -                                      EFI_PCI_ATTRIBUTE_VGA_IO_16  |
>>> -                                      EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16;
>>> -  mRootBridge.Attributes            = mRootBridge.Supports;
>>> +  Attributes           = EFI_PCI_ATTRIBUTE_ISA_IO_16 |
>>> +                         EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO |
>>> +                         EFI_PCI_ATTRIBUTE_VGA_IO_16  |
>>> +                         EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16;
>>>
>>> -  mRootBridge.DmaAbove4G            = TRUE;
>>> -  mRootBridge.NoExtendedConfigSpace = FALSE;
>>> -  mRootBridge.ResourceAssigned      = FALSE;
>>> +  AllocationAttributes = EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM;
>>>
>>> -  mRootBridge.AllocationAttributes  = EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM;
>>> -
>>> -  mRootBridge.Bus.Base              = BusMin;
>>> -  mRootBridge.Bus.Limit             = BusMax;
>>> -  mRootBridge.Io.Base               = IoBase;
>>> -  mRootBridge.Io.Limit              = IoBase + IoSize - 1;
>>> -  mRootBridge.Mem.Base              = Mmio32Base;
>>> -  mRootBridge.Mem.Limit             = Mmio32Base + Mmio32Size - 1;
>>> +  Io.Base              = IoBase;
>>> +  Io.Limit             = IoBase + IoSize - 1;
>>> +  Mem.Base             = Mmio32Base;
>>> +  Mem.Limit            = Mmio32Base + Mmio32Size - 1;
>>>
>>>    if (sizeof (UINTN) == sizeof (UINT64)) {
>>> -    mRootBridge.MemAbove4G.Base       = Mmio64Base;
>>> -    mRootBridge.MemAbove4G.Limit      = Mmio64Base + Mmio64Size - 1;
>>> +    MemAbove4G.Base    = Mmio64Base;
>>> +    MemAbove4G.Limit   = Mmio64Base + Mmio64Size - 1;
>>>      if (Mmio64Size > 0) {
>>> -      mRootBridge.AllocationAttributes |= EFI_PCI_HOST_BRIDGE_MEM64_DECODE;
>>> +      AllocationAttributes |= EFI_PCI_HOST_BRIDGE_MEM64_DECODE;
>>>      }
>>>    } else {
>>>      //
>>> @@ -376,19 +349,41 @@ PciHostBridgeGetRootBridges (
>>>      // BARs unless they are allocated below 4 GB. So ignore the range above
>>>      // 4 GB in this case.
>>>      //
>>> -    mRootBridge.MemAbove4G.Base       = MAX_UINT64;
>>> -    mRootBridge.MemAbove4G.Limit      = 0;
>>> +    MemAbove4G.Base    = MAX_UINT64;
>>> +    MemAbove4G.Limit   = 0;
>>>    }
>>>
>>>    //
>>>    // No separate ranges for prefetchable and non-prefetchable BARs
>>>    //
>>> -  mRootBridge.PMem.Base             = MAX_UINT64;
>>> -  mRootBridge.PMem.Limit            = 0;
>>> -  mRootBridge.PMemAbove4G.Base      = MAX_UINT64;
>>> -  mRootBridge.PMemAbove4G.Limit     = 0;
>>> +  PMem.Base            = MAX_UINT64;
>>> +  PMem.Limit           = 0;
>>> +  PMemAbove4G.Base     = MAX_UINT64;
>>> +  PMemAbove4G.Limit    = 0;
>>>
>>> -  mRootBridge.DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)&mEfiPciRootBridgeDevicePath;
>>> +  Status = PciHostBridgeUtilityInitRootBridge (
>>> +    Attributes,
>>> +    Attributes,
>>> +    AllocationAttributes,
>>> +    TRUE,
>>> +    FALSE,
>>> +    BusMin,
>>> +    BusMax,
>>> +    &Io,
>>> +    &Mem,
>>> +    &MemAbove4G,
>>> +    &PMem,
>>> +    &PMemAbove4G,
>>> +    &mRootBridge
>>> +    );
>>> +  if (EFI_ERROR (Status)) {
>>> +    DEBUG ((EFI_D_ERROR, "%a: failed to initialize PCI host bridge: %r\n",
>>> +      __FUNCTION__, Status));
>>
>> (1) EFI_D_ERROR will fail "BaseTools/Scripts/PatchCheck.py":
>>
>>> Code format is not valid:
>>>  * EFI_D_ERROR was used, but DEBUG_ERROR is now recommended
>>>    File: ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.c
>>>    Line:     DEBUG ((EFI_D_ERROR, "%a: failed to initialize PCI host bridge: %r\n",
>>
> 
> Sorry for forgetting to check patches. Will fix it.
> BTW, EFI_D_ERROR are also used in the other part of the same
> function, do I need to fix them too?

No, just please don't introduce new instances of EFI_D_*.

Thanks,
Laszlo

> 
>> There are some other syntactic issues with this patch set that
>> "PatchCheck.py" catches.
> 
> Another issue is that the subject is too long. Will try to shorten it.
> Seems patch [8/9] has the same issue, will fix too.
> 
> Thanks,
> Jiahui
> 
>>
>> It's simplest if you open a pull request with your topic branch, about
>> to be submitted to the list, on github.com. The PR will be auto-closed,
>> but it will run CI on your patch series first, and you will get a chance
>> to fix issues before the on-list review. The CI tasks include
>> "PatchCheck".
>>
>> You can also run "BaseTools/Scripts/PatchCheck.py" locally. (You can run
>> more or less the whole CI content locally, but setting that up is not
>> quick.)
>>
>> With the PatchCheck errors addressed, this patch will be OK.
>>
>> Thanks,
>> Laszlo
>>
>>
>>> +    *Count = 0;
>>> +    return NULL;
>>> +  }
>>> +
>>> +  *Count = 1;
>>>
>>>    return &mRootBridge;
>>>  }
>>> @@ -408,6 +403,7 @@ PciHostBridgeFreeRootBridges (
>>>    )
>>>  {
>>>    ASSERT (Count == 1);
>>> +  PciHostBridgeUtilityUninitRootBridge (Bridges);
>>>  }
>>>
>>>  /**
>>>
>>
>> .
>>
> 


  reply	other threads:[~2021-01-13  9:05 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-12  9:45 [PATCH v4 0/9] Add extra pci roots support for Arm Jiahui Cen
2021-01-12  9:45 ` [PATCH v4 1/9] OvmfPkg: Introduce PciHostBridgeUtilityLib class Jiahui Cen
2021-01-13  0:41   ` [edk2-devel] " Laszlo Ersek
2021-01-14  8:57   ` Laszlo Ersek
2021-01-12  9:45 ` [PATCH v4 2/9] ArmVirtPkg: Refactor with PciHostBridgeUtilityLib Jiahui Cen
2021-01-13  0:44   ` [edk2-devel] " Laszlo Ersek
2021-01-12  9:45 ` [PATCH v4 3/9] OvmfPkg/PciHostBridgeLib: Extract InitRootBridge/UninitRootBridge Jiahui Cen
2021-01-13  1:28   ` [edk2-devel] " Laszlo Ersek
2021-01-13  6:00     ` Jiahui Cen
2021-01-13  9:06       ` Laszlo Ersek
2021-01-14  8:51   ` Laszlo Ersek
2021-01-12  9:45 ` [PATCH v4 4/9] OvmfPkg/PciHostBridgeUtilityLib: Extend parameter list of InitRootBridge Jiahui Cen
2021-01-13  1:51   ` [edk2-devel] " Laszlo Ersek
2021-01-13  6:01     ` Jiahui Cen
2021-01-12  9:45 ` [PATCH v4 5/9] ArmVirtPkg/FdtPciHostBridgeLib: Rebase to InitRootBridge() / UninitRootBridge() Jiahui Cen
2021-01-13  2:15   ` [edk2-devel] " Laszlo Ersek
2021-01-13  6:10     ` Jiahui Cen
2021-01-13  9:05       ` Laszlo Ersek [this message]
2021-01-12  9:45 ` [PATCH v4 6/9] OvmfPkg/PciHostBridgeLib: Extract GetRootBridges/FreeRootBridges Jiahui Cen
2021-01-14  9:12   ` [edk2-devel] " Laszlo Ersek
2021-01-12  9:45 ` [PATCH v4 7/9] OvmfPkg/PciHostBridgeUtilityLib: Extend parameter list of GetRootBridges Jiahui Cen
2021-01-14 10:46   ` [edk2-devel] " Laszlo Ersek
2021-01-14 12:44     ` Jiahui Cen
2021-01-14 16:03       ` Laszlo Ersek
2021-01-15  7:25     ` Jiahui Cen
2021-01-15  7:59       ` Laszlo Ersek
2021-01-15  8:30         ` Jiahui Cen
2021-01-12  9:45 ` [PATCH v4 8/9] ArmVirtPkg/FdtPciHostBridgeLib: Refactor GetRootBridges() / FreeRootBridges() Jiahui Cen
2021-01-14 11:01   ` [edk2-devel] " Laszlo Ersek
2021-01-14 12:48     ` Jiahui Cen
2021-01-12  9:45 ` [PATCH v4 9/9] ArmVirtPkg/ArmVirtQemu: Add support for HotPlug Jiahui Cen
2021-01-14 11:04   ` [edk2-devel] " Laszlo Ersek
2021-01-14 11:53 ` [PATCH v4 0/9] Add extra pci roots support for Arm Laszlo Ersek
2021-01-14 12:51   ` Jiahui Cen
2021-01-18 17:26     ` [edk2-devel] " 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=1d9dfe70-21d3-54a0-f180-eaa77a2643d0@redhat.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