This patch is also uploaded in following Repo, for review:-
https://github.com/ashrafj/edk2-staging/commit/421511cd582975c65983d75dad0e2a58956bfafd

Thanks
Ashraf

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Javeed,
> Ashraf
> Sent: Friday, November 1, 2019 8:40 PM
> To: devel@edk2.groups.io
> Cc: Wang, Jian J <jian.j.w...@intel.com>; Wu, Hao A <hao.a...@intel.com>;
> Ni, Ray <ray...@intel.com>
> Subject: [edk2-devel] [edk2-staging/UEFI_PCI_ENHANCE-2 PATCH 03/12]
> PciBusDxe: Separation of the PCI device registration and start
> 
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2194
> 
> The separation of the PCI device registration phase includes only the 
> installation
> of the PCI IO Protocol on the PCI node to acquire the EFI handles, and 
> loading of
> its applicable PCI Option ROM.
> 
> The separation of the PCI device start phase only includes the code that 
> enables
> the PCI Bridge device as a Bus Master.
> 
> This code change is made in order to introduce the enabling of the other PCI
> features in the PCI Bus driver.
> 
> Signed-off-by: Ashraf Javeed <ashraf.jav...@intel.com>
> Cc: Jian J Wang <jian.j.w...@intel.com>
> Cc: Hao A Wu <hao.a...@intel.com>
> Cc: Ray Ni <ray...@intel.com>
> ---
>  MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c | 164
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> ----------------------------------
>  1 file changed, 130 insertions(+), 34 deletions(-)
> 
> diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
> b/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
> index 149a120..33a0e94 100644
> --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
> +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
> @@ -561,7 +561,7 @@ DeRegisterPciDevice (  }
> 
>  /**
> -  Start to manage the PCI device on the specified root bridge or PCI-PCI 
> Bridge.
> +  Start the PCI root Ports or PCI-PCI Bridge only.
> 
>    @param Controller          The root bridge handle.
>    @param RootBridge          A pointer to the PCI_IO_DEVICE.
> @@ -576,7 +576,82 @@ DeRegisterPciDevice (
> 
>  **/
>  EFI_STATUS
> -StartPciDevicesOnBridge (
> +StartPciRootPortsOnBridge (
> +  IN EFI_HANDLE                          Controller,
> +  IN PCI_IO_DEVICE                       *RootBridge
> +  )
> +
> +{
> +  PCI_IO_DEVICE             *PciIoDevice;
> +  EFI_STATUS                Status;
> +  LIST_ENTRY                *CurrentLink;
> +  UINT64                    Supports;
> +
> +  PciIoDevice = NULL;
> +  CurrentLink = RootBridge->ChildList.ForwardLink;
> +
> +  while (CurrentLink != NULL && CurrentLink != &RootBridge->ChildList)
> + {
> +
> +    PciIoDevice = PCI_IO_DEVICE_FROM_LINK (CurrentLink);
> +
> +    //
> +    // check if the device has been assigned with required resource
> +    // and registered
> +    //
> +    if (!PciIoDevice->Registered && !PciIoDevice->Allocated) {
> +      return EFI_NOT_READY;
> +    }
> +
> +    if (IS_PCI_BRIDGE (&PciIoDevice->Pci)) {
> +      Status = StartPciRootPortsOnBridge (
> +                 Controller,
> +                 PciIoDevice
> +                 );
> +
> +      PciIoDevice->PciIo.Attributes (
> +                           &(PciIoDevice->PciIo),
> +                           EfiPciIoAttributeOperationSupported,
> +                           0,
> +                           &Supports
> +                         );
> +      Supports &= (UINT64)EFI_PCI_DEVICE_ENABLE;
> +      PciIoDevice->PciIo.Attributes (
> +                           &(PciIoDevice->PciIo),
> +                           EfiPciIoAttributeOperationEnable,
> +                           Supports,
> +                           NULL
> +                         );
> +
> +    }
> +
> +    CurrentLink = CurrentLink->ForwardLink;  }
> +
> +  if (PciIoDevice == NULL) {
> +    return EFI_NOT_FOUND;
> +  } else {
> +    return EFI_SUCCESS;
> +  }
> +}
> +
> +
> +/**
> +  Register to manage the PCI device on the specified root bridge or PCI-PCI
> Bridge.
> +
> +  @param Controller          The root bridge handle.
> +  @param RootBridge          A pointer to the PCI_IO_DEVICE.
> +  @param RemainingDevicePath A pointer to the
> EFI_DEVICE_PATH_PROTOCOL.
> +  @param NumberOfChildren    Children number.
> +  @param ChildHandleBuffer   A pointer to the child handle buffer.
> +
> +  @retval EFI_NOT_READY   Device is not allocated.
> +  @retval EFI_UNSUPPORTED Device only support PCI-PCI bridge.
> +  @retval EFI_NOT_FOUND   Can not find the specific device.
> +  @retval EFI_SUCCESS     Success to start Pci devices on bridge.
> +
> +**/
> +EFI_STATUS
> +RegisterPciDevicesOnBridge (
>    IN EFI_HANDLE                          Controller,
>    IN PCI_IO_DEVICE                       *RootBridge,
>    IN EFI_DEVICE_PATH_PROTOCOL            *RemainingDevicePath,
> @@ -590,7 +665,6 @@ StartPciDevicesOnBridge (
>    EFI_DEVICE_PATH_PROTOCOL  *CurrentDevicePath;
>    EFI_STATUS                Status;
>    LIST_ENTRY                *CurrentLink;
> -  UINT64                    Supports;
> 
>    PciIoDevice = NULL;
>    CurrentLink = RootBridge->ChildList.ForwardLink;
> @@ -645,7 +719,7 @@ StartPciDevicesOnBridge (
>        // If it is a PPB
>        //
>        if (IS_PCI_BRIDGE (&PciIoDevice->Pci)) {
> -        Status = StartPciDevicesOnBridge (
> +        Status = RegisterPciDevicesOnBridge (
>                     Controller,
>                     PciIoDevice,
>                     CurrentDevicePath,
> @@ -653,20 +727,6 @@ StartPciDevicesOnBridge (
>                     ChildHandleBuffer
>                     );
> 
> -        PciIoDevice->PciIo.Attributes (
> -                             &(PciIoDevice->PciIo),
> -                             EfiPciIoAttributeOperationSupported,
> -                             0,
> -                             &Supports
> -                             );
> -        Supports &= (UINT64)EFI_PCI_DEVICE_ENABLE;
> -        PciIoDevice->PciIo.Attributes (
> -                             &(PciIoDevice->PciIo),
> -                             EfiPciIoAttributeOperationEnable,
> -                             Supports,
> -                             NULL
> -                             );
> -
>          return Status;
>        } else {
> 
> @@ -697,28 +757,13 @@ StartPciDevicesOnBridge (
>        }
> 
>        if (IS_PCI_BRIDGE (&PciIoDevice->Pci)) {
> -        Status = StartPciDevicesOnBridge (
> +        Status = RegisterPciDevicesOnBridge (
>                     Controller,
>                     PciIoDevice,
>                     RemainingDevicePath,
>                     NumberOfChildren,
>                     ChildHandleBuffer
>                     );
> -
> -        PciIoDevice->PciIo.Attributes (
> -                             &(PciIoDevice->PciIo),
> -                             EfiPciIoAttributeOperationSupported,
> -                             0,
> -                             &Supports
> -                             );
> -        Supports &= (UINT64)EFI_PCI_DEVICE_ENABLE;
> -        PciIoDevice->PciIo.Attributes (
> -                             &(PciIoDevice->PciIo),
> -                             EfiPciIoAttributeOperationEnable,
> -                             Supports,
> -                             NULL
> -                             );
> -
>        }
> 
>        CurrentLink = CurrentLink->ForwardLink; @@ -732,6 +777,57 @@
> StartPciDevicesOnBridge (
>    }
>  }
> 
> +/**
> +  Start to manage the PCI device on the specified root bridge or PCI-PCI 
> Bridge.
> +
> +  @param Controller          The root bridge handle.
> +  @param RootBridge          A pointer to the PCI_IO_DEVICE.
> +  @param RemainingDevicePath A pointer to the
> EFI_DEVICE_PATH_PROTOCOL.
> +  @param NumberOfChildren    Children number.
> +  @param ChildHandleBuffer   A pointer to the child handle buffer.
> +
> +  @retval EFI_NOT_READY   Device is not allocated.
> +  @retval EFI_UNSUPPORTED Device only support PCI-PCI bridge.
> +  @retval EFI_NOT_FOUND   Can not find the specific device.
> +  @retval EFI_SUCCESS     Success to start Pci devices on bridge.
> +
> +**/
> +EFI_STATUS
> +StartPciDevicesOnBridge (
> +  IN EFI_HANDLE                          Controller,
> +  IN PCI_IO_DEVICE                       *RootBridge,
> +  IN EFI_DEVICE_PATH_PROTOCOL            *RemainingDevicePath,
> +  IN OUT UINT8                           *NumberOfChildren,
> +  IN OUT EFI_HANDLE                      *ChildHandleBuffer
> +  )
> +
> +{
> +  EFI_STATUS                Status;
> +
> +  //
> +  // first register all the PCI devices  //  Status =
> + RegisterPciDevicesOnBridge (
> +             Controller,
> +             RootBridge,
> +             RemainingDevicePath,
> +             NumberOfChildren,
> +             ChildHandleBuffer
> +             );
> +
> +  if (EFI_ERROR (Status) == EFI_NOT_FOUND) {
> +    return Status;
> +  } else {
> +    //
> +    // finally start those PCI bridge port devices only
> +    //
> +    return StartPciRootPortsOnBridge (
> +            Controller,
> +            RootBridge
> +            );
> +  }
> +}
> +
>  /**
>    Start to manage all the PCI devices it found previously under
>    the entire host bridge.
> --
> 2.21.0.windows.1
> 
> 
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#50502): https://edk2.groups.io/g/devel/message/50502
Mute This Topic: https://groups.io/mt/55155883/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to