render / rpms / edk2

Forked from rpms/edk2 3 months ago
Clone

Blame 0019-MdeModulePkg-PciBus-Fix-bug-that-PCI-BUS-claims-too-much-resource.patch

Paolo Bonzini 2e34e0
From: Ruiyu Ni <ruiyu.ni@intel.com>
Paolo Bonzini 2e34e0
Subject: [PATCH] MdeModulePkg/PciBus: Fix bug that PCI BUS claims too much resource
Paolo Bonzini 2e34e0
Date: Thu, 16 Nov 2017 18:15:14 +0100
Paolo Bonzini 2e34e0
Paolo Bonzini 2e34e0
The bug was caused by 728d74973c9262b6c7b7ef4be213223d55affec3
Paolo Bonzini 2e34e0
"MdeModulePkg/PciBus: Count multiple hotplug resource paddings".
Paolo Bonzini 2e34e0
Paolo Bonzini 2e34e0
The patch firstly updated the Bridge->Alignment to the maximum
Paolo Bonzini 2e34e0
alignment of all devices under the bridge, then aligned the
Paolo Bonzini 2e34e0
Bridge->Length to Bridge->Alignment.
Paolo Bonzini 2e34e0
It caused too much resources were claimed.
Paolo Bonzini 2e34e0
Paolo Bonzini 2e34e0
The new patch firstly aligns Bridge->Length to Bridge->Alignment,
Paolo Bonzini 2e34e0
then updates the Bridge->Alignment to the maximum alignment of all
Paolo Bonzini 2e34e0
devices under the bridge.
Paolo Bonzini 2e34e0
Because the step to update the Bridge->Alignment is to make sure
Paolo Bonzini 2e34e0
the resource allocated to the bus under the Bridge meets all
Paolo Bonzini 2e34e0
devices alignment. But the Bridge->Length doesn't have to align
Paolo Bonzini 2e34e0
to the maximum alignment.
Paolo Bonzini 2e34e0
Paolo Bonzini 2e34e0
Contributed-under: TianoCore Contribution Agreement 1.1
Paolo Bonzini 2e34e0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Paolo Bonzini 2e34e0
Reviewed-by: Eric Dong <eric.dong@intel.com>
Paolo Bonzini 2e34e0
(cherry picked from commit 6e3287442774c1a4bc83f127694700eeb07c18dc)
Paolo Bonzini 2e34e0
---
Paolo Bonzini 2e34e0
 MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c | 24 ++++++++++----------
Paolo Bonzini 2e34e0
 1 file changed, 12 insertions(+), 12 deletions(-)
Paolo Bonzini 2e34e0
Paolo Bonzini 2e34e0
diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c
Paolo Bonzini 2e34e0
index 8dbe9a00380f..2f713fcee95e 100644
Paolo Bonzini 2e34e0
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c
Paolo Bonzini 2e34e0
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c
Paolo Bonzini 2e34e0
@@ -389,18 +389,7 @@ CalculateResourceAperture (
Paolo Bonzini 2e34e0
   }
Paolo Bonzini 2e34e0
 
Paolo Bonzini 2e34e0
   //
Paolo Bonzini 2e34e0
-  // Adjust the bridge's alignment to the MAX (first) alignment of all children.
Paolo Bonzini 2e34e0
-  //
Paolo Bonzini 2e34e0
-  CurrentLink = Bridge->ChildList.ForwardLink;
Paolo Bonzini 2e34e0
-  if (CurrentLink != &Bridge->ChildList) {
Paolo Bonzini 2e34e0
-    Node = RESOURCE_NODE_FROM_LINK (CurrentLink);
Paolo Bonzini 2e34e0
-    if (Node->Alignment > Bridge->Alignment) {
Paolo Bonzini 2e34e0
-      Bridge->Alignment = Node->Alignment;
Paolo Bonzini 2e34e0
-    }
Paolo Bonzini 2e34e0
-  }
Paolo Bonzini 2e34e0
-
Paolo Bonzini 2e34e0
-  //
Paolo Bonzini 2e34e0
-  // At last, adjust the aperture with the bridge's alignment
Paolo Bonzini 2e34e0
+  // Adjust the aperture with the bridge's alignment
Paolo Bonzini 2e34e0
   //
Paolo Bonzini 2e34e0
   Aperture[PciResUsageTypical] = ALIGN_VALUE (Aperture[PciResUsageTypical], Bridge->Alignment + 1);
Paolo Bonzini 2e34e0
   Aperture[PciResUsagePadding] = ALIGN_VALUE (Aperture[PciResUsagePadding], Bridge->Alignment + 1);
Paolo Bonzini 2e34e0
@@ -410,6 +399,17 @@ CalculateResourceAperture (
Paolo Bonzini 2e34e0
   // Use the larger one between the padding resource and actual occupied resource.
Paolo Bonzini 2e34e0
   //
Paolo Bonzini 2e34e0
   Bridge->Length = MAX (Aperture[PciResUsageTypical], Aperture[PciResUsagePadding]);
Paolo Bonzini 2e34e0
+
Paolo Bonzini 2e34e0
+  //
Paolo Bonzini 2e34e0
+  // Adjust the bridge's alignment to the MAX (first) alignment of all children.
Paolo Bonzini 2e34e0
+  //
Paolo Bonzini 2e34e0
+  CurrentLink = Bridge->ChildList.ForwardLink;
Paolo Bonzini 2e34e0
+  if (CurrentLink != &Bridge->ChildList) {
Paolo Bonzini 2e34e0
+    Node = RESOURCE_NODE_FROM_LINK (CurrentLink);
Paolo Bonzini 2e34e0
+    if (Node->Alignment > Bridge->Alignment) {
Paolo Bonzini 2e34e0
+      Bridge->Alignment = Node->Alignment;
Paolo Bonzini 2e34e0
+    }
Paolo Bonzini 2e34e0
+  }
Paolo Bonzini 2e34e0
 }
Paolo Bonzini 2e34e0
 
Paolo Bonzini 2e34e0
 /**
Paolo Bonzini 2e34e0
-- 
Paolo Bonzini 2e34e0
2.14.1.3.gb7cf6e02401b
Paolo Bonzini 2e34e0