Commit Graph

36 Commits

Author SHA1 Message Date
Maurice Ma c03faf59c3 Enhance PCI enumeration policy for resource downgrade
On TGL platform, when enable SR_IOV for PCI enumeration, system
hung due to insufficient PCI resource. GFX VF needs lots of MMIO
resource and it cannot be satisfied by SBL in 32 bit mode.

To address this issue, this patch extends the bus 0 downgrade
policy to further allow downgrading PCI bus 0 devices except for
GFX. Now the DowngradeBus0 policy has following values:
  0: Do not downgrade PCI devices on bus 0
  1: Downgrade all PCI devices on bus 0
  2: Downgrade all PCI devices on bus 0 but GFX
  3: Reserved
By default, it has the same behavior as before. If platform needs
to download bus 0 devices but GFX, the new value 2 can be used.

This has been tested on TGL, and it worked as expected.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-18 09:14:52 -07:00
Maurice Ma 22447f0618 Adjust PCI resource check condition
Current PciBus lib expects the root bridge resource base should not be
greater than limit. It is true for normal case. However, to mark the
source is unavailable, the base could be less than the limit in some
case. PCI bus lib should only validate the resource that does have a
request.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-09-27 08:58:05 -07:00
stalamudupula f1b98384a2
Add a Pci Enum Hook function (#1185)
This patch adds a platform hook function ability
in Pci Enum Lib to enable platform to perform
PCI Enum specific work-around routines.

Signed-off-by: Talamudupula <stalamudupula@gmail.com>
2021-06-09 15:53:26 -07:00
Vincent Chen 8bb52daaca [QEMU] Fix compiler error for NOOPT build in Windows
- fix __aullshr link error due to compiler intrinsics functions
  for NOOPT build in Windows
- adjust Stage1A/TopSwap/OsLoader FD size for NOOPT target
- adjust Stage2 size for NOOPT target when DEBUG FSP is used

Signed-off-by: Vincent Chen <vincent.chen@intel.com>
2021-05-25 21:20:38 -07:00
Aiden Park 209a159176 [PCI] Disable PCI devices bus master by default
This will disable all PCI bus master by default, and enable it only if
- the original bus master was enabled before PCI enumeration
- Or the device is PCI Bridge

Signed-off-by: Aiden Park <aiden.park@intel.com>
2021-04-06 13:30:59 -07:00
Talamudupula a005a5772c Program BAR0/1 for PPB
Current PCI Enum Lib scopes for only Apperture resources
for a PPB. But some OSes (like ESXi) expect BAR0 & BAR1
(Offset 0x10/0x14) to be allocated resources accordingly.
Otherwise, PPB enumeration doesnt happen correctly and
devices behind PPB are not registered at all.

This patch adds the functionality to assign valid resources
to BAR0(0x10) and BAR1(0x14) for a PPB also.

Signed-off-by: Talamudupula <stalamudupula@gmail.com>
2021-03-02 20:28:07 -08:00
Aiden Park 2aade4dddb
Fix new Klocwork scanning issues (#1012)
This patch addresses new reported klocwork scanning issues.

Signed-off-by: Aiden Park <aiden.park@intel.com>
2021-02-10 08:55:00 -08:00
Aiden Park 680cab980b [PCI] Add an option to allocate PCI PMEM resource first
This introduces an additional PCI Enumeration option.
- self._PCI_ENUM_FLAG_ALLOC_PMEM_FIRST

By deafult, the option will allocate PCI resource by ascending order
(MEM32->PMEM32->MEM64->PMEM64). If it's set to 1, by reversed order.

Signed-off-by: Aiden Park <aiden.park@intel.com>
2021-02-03 17:14:51 -08:00
Maurice Ma 1771e3a35e
Change PCI resource PCD to patchable type (#979)
Current PCI resource PCD bases are defined as fixed type. It
makes it impossible to dynamically adjust the base at runtime.
This patch changed it to be module patchable so that platform
can update when required.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-01-25 09:54:32 -08:00
Talamudupula c62c995e49 Update correct BarType field for VF Bar program
ProgramBar() routine uses 'OrgBarType' field to
determine BarType. So, if a BarType is valid, copy
it to OrgBarType for VF also.

Signed-off-by: Talamudupula <stalamudupula@gmail.com>
2021-01-07 20:22:54 -08:00
Aiden Park eabaac12ad Add PCI Resource Allocation Table
This introduces a new PCD 'PcdPciResAllocTableBase' to allow a platform
to provide its specific PCI resource allocation pool at runtime.
PCI Enumerator will allocate required resources in the range.
If the PCD is not provided, a default range will be used.

Signed-off-by: Aiden Park <aiden.park@intel.com>
2020-12-15 14:05:25 -08:00
Aiden Park 2d7c2b920f Add PCI resource downgrade option for all Bus-0 devices
In 64-bit operation, some PCI devices have high mmio BARs,
but 32-bit FSP can only access 32-bit memory space.
This introduces and additional PCI resource downgrade option
to downgrade all PCI devices under Bus-0.
- self._PCI_ENUM_DOWNGRADE_BUS0 = 1
  Force to have 32-bit BAR for all Bus-0 devices

Signed-off-by: Aiden Park <aiden.park@intel.com>
2020-11-02 10:57:15 -08:00
Aiden Park 21e9d1a51e Check PPB decode space and assign BAR accordingly
All child devices under a PPB must be in scope of its PPB's decode space.
Therefore, all PPB checks the decode capability and downgrades its child
devices' resources accordingly.

Signed-off-by: Aiden Park <aiden.park@intel.com>
2020-08-12 17:18:04 -07:00
Maurice Ma 1ed701be11 Fix P2P bridge alignement issue
The following commit 9fcb3a6be1
caused a regression on PCI bridge resource allocation. At minimum
the PCI bridge needs to have IO apperture aligned at 4KB and MMIO
apperture aligned at 1MB. The new code did not adjust the
alignment for P2P bridge following this rule.  This patch fixed
this issue.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2020-08-10 17:19:51 -07:00
Maurice Ma 9fcb3a6be1 PCI resource allocation minor adjustment
This patch adjusted some alignment on PCI resource allocation so
that PCI resource is more efficently utilized. It aslo adjusted
the framebuffer MTRR range to match PCI resource allocation.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2020-08-08 06:53:25 -07:00
Maurice Ma 36b8e0a3c4
Fix PCI enumeration issue with multiple PCI bridges (#801)
When multiple level of PCI bridges exists on a platform, current
SBL PCI bus library could not find all devices. This issue was
caused by incorrect root bridge bus limit got from the data
structure. This patch fixed this issue.
It also fixed #800.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2020-08-06 11:32:53 -07:00
Aiden Park 745555ede5
Fix invalid PPB check in PciGetMaxBusNumber() (#747)
A PPB PCI_IO_DEVICE instance has BIT31 in its Address field to identify
the device as PPB type. But, the bit is set after scanning the PPB.
This skips PPB type check in PciGetMaxBusNumber() and let a caller
guarantee PPB type check instead of adding a field in PCI_IO_DEVICE
for PPB device.

Signed-off-by: Aiden Park <aiden.park@intel.com>
2020-06-15 13:14:17 -07:00
Aiden Park 9704eaecec Add PciGetMaxBusNumber for PCI Bridge Subordinate Bus
At PciScanBus, a PCI bridge sets PCI Bridge Subordinate Bus to 0xFF
temporary to go thru any PPB. But, a platform has some reserved buses
(ex. 0xFB-0xFF) on PCI hierarchy, and writing 0xFF regardless of
reserved bus ranges causes system hang.

Therefore, PciGetMaxBusNumber will be used for PCI Bridge Subordinate
Bus and it gets the number of buses from PCI Enum Policy to skip the
reserved buses.

Signed-off-by: Aiden Park <aiden.park@intel.com>
2020-06-11 11:55:55 -07:00
Aiden Park 9309f21857
Suppress KW warnings (#725)
Signed-off-by: Aiden Park <aiden.park@intel.com>
2020-05-27 15:41:39 -07:00
Aiden Park 9f146afd47
Add PCI SR-IOV Support (#714)
This will support PCI SR-IOV(Single Root I/O Virtualization).
- Controlled by PcdSrIovSupport (SUPPORT_SR_IOV in BoardConfig)
- Disabled by default

Signed-off-by: Aiden Park <aiden.park@intel.com>
2020-05-14 09:57:10 -07:00
Aiden Park 163d60408f
Add PCI ARI Support (#712)
This will enable ARI(Alternative Routing-ID Interpretation).
- Controlled by PcdAriSupport (SUPPORT_ARI in BoardConfig)
- Disabled by default

Signed-off-by: Aiden Park <aiden.park@intel.com>
2020-05-12 19:27:24 -07:00
stalamudupula 3c26520a50
Fix the BarType reported in PciResource Dump (#672)
Correct the index reported while dumping the
PCI resource information.

Signed-off-by: Sai Talamudupula <sai.kiran.talamudupula@intel.com>

Co-authored-by: Sai Talamudupula <sai.kiran.talamudupula@intel.com>
2020-04-14 10:22:48 -07:00
stalamudupula a61b39fdd7
Fix windows build error when DEBUG_PCI_ENUM=1 (#655)
Fix unresolved external and type-cast issues for X64 build.

Signed-off-by: Sai Talamudupula <sai.kiran.talamudupula@intel.com>

Co-authored-by: Sai Talamudupula <sai.kiran.talamudupula@intel.com>
2020-04-10 11:40:23 -07:00
Aiden Park 123ccd06db
Build PCI Root Bridge Resource Info Hob (#649)
This will create a HOB for PCI Root Bridge Resource information.
The PciRootBridgeInfo Hob can be used to update resource ranges of multiple
root bridges in platform PCI tree ASL.
A payload can also use this info to skip duplicated root bridge scan.

Signed-off-by: Aiden Park <aiden.park@intel.com>
2020-04-09 12:27:26 -07:00
Aiden Park 29446a1c2a
Pointer type cast for both 32/64-bit operation (#615)
This patch allows both 32/64-bit addressing properly.
- Pointer type cast with UINTN
- Add missing EFIAPI for APIs

Signed-off-by: Aiden Park <aiden.park@intel.com>
2020-03-26 17:30:55 -07:00
Maurice Ma 1d4a9c5886 Preserve PCI some command/control register bits during enumeration
SBL PCI enumeration code will zero out all PCI command registers and
PCI bridge control registers. However, FSP might have programmed some
of the registers already, and some of the bits are expected to be
preserved through the PCI enumeration. This patch addressed this issue
by only clearing the bits that are required during the PCI enumeration.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2020-03-02 15:24:33 -08:00
Aiden Park b49cc15163 Fix a build failure on Windows
A build fails on Windows due to PCI Enum Policy patch (#559).
This will resolve the build failure.

Signed-off-by: Aiden Park <aiden.park@intel.com>
2020-02-20 17:08:50 -07:00
Aiden Park 0dfed64e6f
Add PCI Enumeration policy info (#559)
PciEnumeration() scans a single PCI root bridge currently.
The PCI_ENUM_POLICY_INFO structure will be generated at build time,
and this will allow PCI enumeration more flexible.

typedef struct {
  UINT8           DowngradeIo32;// default:1
  UINT8           DowngradeMem64; // default:1
  UINT8           DowngradePMem64;// default:1
  UINT8           Reserved;
  UINT8           BusScanType;    // default:0 (0: list, 1: range)
  UINT8           NumOfBus;       // the number of BusScanItems
  UINT8           BusScanItems[0];
} PCI_ENUM_POLICY_INFO;

Signed-off-by: Aiden Park <aiden.park@intel.com>
2020-02-20 14:22:36 -08:00
Guo Dong 833ecbc46b Format update by coding style
1)  Replace TAB with spaces
2)  Convert CR, LF or LFCR to CRLF
3)  Remove trailing spaces
4)  Updated below strings:
       "EFI_D_INFO"  -> "DEBUG_INFO",
       "EFI_D_WARN"  -> "DEBUG_WARN",
       "EFI_D_ERROR" -> "DEBUG_ERROR",

Signed-off-by: Guo Dong <guo.dong@intel.com>
2020-02-07 22:43:45 -07:00
Aiden Park 72262b4722
Misc Klocwork scanning fixes (#484)
This patch fixes klocwork scanning reports in qemu, apl and cfl builds.

Signed-off-by: Aiden Park <aiden.park@intel.com>
2019-12-04 15:17:04 -08:00
Aiden Park b24fd2759c Cosmetic: Convert LF to CRLF
This will fully support PatchCheck.py.
- Remove all trailing whitespace
- Convert LF to CRLF by default
- Update EFI_D_* to DEBUG_*
- Re-enable CRLF check in PatchCheck.py

Signed-off-by: Aiden Park <aiden.park@intel.com>
2019-12-02 16:21:19 -08:00
Aiden Park d2ea80b5c9
Add InsertionSort for Linked List (#454)
This provides basic insertion sort API for Linked List. As part of change,
this insertion sort is used for PCI BAR calculation by its alignment
and for shell commands list by its name.

Signed-off-by: Aiden Park <aiden.park@intel.com>
2019-11-14 11:26:31 -08:00
Guo Dong 5e10bd1e07 Update BSD license to BSD+Patent license
To align with EDK2, update file license
to use BSD+Patent license

Signed-off-by: Guo Dong <guo.dong@intel.com>
2019-06-13 10:46:49 -07:00
Maurice Ma 6f8c44b375 Sync up with EDK2 stable tag edk2-stable201905
Synced up MdePkg, IntelFsp2Pkg and BaseTools to EDK2 stable tag
edk2-stable201905.

There are several changes for MdePkg and BaseTools.
MdePkg:
 - Support light print to reduce SBL size
   MdePkg\Library\BasePrintLib\PrintLibInternal.c
   MdePkg\Include\Library\DebugLib.h
 - TCG TPM2 spec changes and remove dependencies
   MdePkg\Include\IndustryStandard\UefiTcgPlatform.h
   MdePkg\Include\IndustryStandard\Tpm2Acpi.h
 - Use old NVM protocol file
   MdePkg\Include\Protocol\NvmExpressPassthru.h
 - Removed unused files

BaseTools:
 - Added LZ4 support
 - Removed unused files

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-06-12 08:29:06 -07:00
James Gutbub 7a325d18ea Add BaseMemoryLibSse2 library
Copying the MdePkg BaseMemoryLibSse2 library into
SBL for faster CopyMem and other routines to improve
boot performance every where except for Stage1A &
Stage1B due to 'movntdq' usage limitation in earlier
stages. Remove all of the X64 files since SBL is compiled
as 32-bit. Also patch PCI enumeration code to perform
manual memory copying (using SSE2 CopyMem gives some
issue as tested on APL).

The BaseMemoryLibSse2 folder was copied from EDK2
GitHub based on the following commit ID:

9344f0921518309295da89c221d10cbead8531aa

Signed-off-by: James Gutbub <james.gutbub@intel.com>
2019-05-14 14:56:29 -07:00
Maurice Ma c6999f497a Initial check-in for Slim Bootloader source 2018-09-13 16:11:07 -07:00