<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Consolas, Courier, monospace; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="background-color:rgb(255, 255, 255);display:inline !important">Reviewed-by: Andrei Warkentin <awarkentin@vmware.com></span><br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Jeremy Linton <jeremy.linton@arm.com><br>
<b>Sent:</b> Thursday, August 19, 2021 11:16 PM<br>
<b>To:</b> devel@edk2.groups.io <devel@edk2.groups.io><br>
<b>Cc:</b> pete@akeo.ie <pete@akeo.ie>; ardb+tianocore@kernel.org <ardb+tianocore@kernel.org>; Andrei Warkentin <awarkentin@vmware.com>; Sunny.Wang@arm.com <Sunny.Wang@arm.com>; samer.el-haj-mahmoud@arm.com <samer.el-haj-mahmoud@arm.com>; Jeremy Linton <jeremy.linton@arm.com>;
 René Treffer <treffer+groups.io@measite.de><br>
<b>Subject:</b> [PATCH v3 4/7] Silicon/Broadcom/Bcm27xx: Relax PCIe device restriction</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">The CM4 has an actual PCIe slot, so the device filtering<br>
need to be a little less restrictive WRT busses with more<br>
than 1 device given that switches can now appear in the<br>
topology. Since it is possible to start numbering the<br>
busses with a non-zero value, the bus restriction should<br>
be based on the secondary side of the root port. This<br>
isn't likely but its better than hard-coding the limit.<br>
<br>
Suggested-by: René Treffer <treffer+groups.io@measite.de><br>
Signed-off-by: Jeremy Linton <jeremy.linton@arm.com><br>
---<br>
 .../Library/Bcm2711PciSegmentLib/PciSegmentLib.c    | 21 ++++++++++++++-------<br>
 1 file changed, 14 insertions(+), 7 deletions(-)<br>
<br>
diff --git a/Silicon/Broadcom/Bcm27xx/Library/Bcm2711PciSegmentLib/PciSegmentLib.c b/Silicon/Broadcom/Bcm27xx/Library/Bcm2711PciSegmentLib/PciSegmentLib.c<br>
index 44ce3b4b99..6d15e82fa2 100644<br>
--- a/Silicon/Broadcom/Bcm27xx/Library/Bcm2711PciSegmentLib/PciSegmentLib.c<br>
+++ b/Silicon/Broadcom/Bcm27xx/Library/Bcm2711PciSegmentLib/PciSegmentLib.c<br>
@@ -19,6 +19,7 @@<br>
 #include <Library/PciSegmentLib.h><br>
 #include <Library/UefiLib.h><br>
 #include <IndustryStandard/Bcm2711.h><br>
+#include <IndustryStandard/Pci30.h><br>
 <br>
 typedef enum {<br>
   PciCfgWidthUint8 = 0,<br>
@@ -78,6 +79,9 @@ PciSegmentLibGetConfigBase (<br>
   UINT64        Base;<br>
   UINT64        Offset;<br>
   UINT32        Dev;<br>
+  UINT32        Bus;<br>
+  UINT32        Data;<br>
+  UINT32        HostPortSec;<br>
 <br>
   Base = PCIE_REG_BASE;<br>
   Offset = Address & 0xFFF;         /* Pick off the 4k register offset */<br>
@@ -89,17 +93,20 @@ PciSegmentLibGetConfigBase (<br>
     Base += PCIE_EXT_CFG_DATA;<br>
     if (mPciSegmentLastAccess != Address) {<br>
       Dev = EFI_PCI_ADDR_DEV (Address);<br>
+      Bus = EFI_PCI_ADDR_BUS (Address);<br>
+      HostPortSec = MmioRead8 (PCIE_REG_BASE +<br>
+                               PCI_BRIDGE_SECONDARY_BUS_REGISTER_OFFSET);<br>
+<br>
       /*<br>
-       * Scan things out directly rather than translating the "bus" to a device, etc..<br>
-       * only we need to limit each bus to a single device.<br>
+       * There can only be a single device on bus 1 (downstream of root).<br>
+       * Subsequent busses (behind a PCIe switch) can have more.<br>
        */<br>
-      if (Dev < 1) {<br>
-          MmioWrite32 (PCIE_REG_BASE + PCIE_EXT_CFG_INDEX, Address);<br>
-          mPciSegmentLastAccess = Address;<br>
-      } else {<br>
-          mPciSegmentLastAccess = 0;<br>
+      if (Dev > 0 && (Bus <= HostPortSec)) {<br>
           return 0xFFFFFFFF;<br>
       }<br>
+<br>
+      MmioWrite32 (PCIE_REG_BASE + PCIE_EXT_CFG_INDEX, Address);<br>
+      mPciSegmentLastAccess = Address;<br>
     }<br>
   }<br>
   return Base + Offset;<br>
-- <br>
2.13.7<br>
<br>
</div>
</span></font></div>
</body>
</html>


 <div width="1" style="color:white;clear:both">_._,_._,_</div> <hr>   Groups.io Links:<p>   You receive all messages sent to this group.    <p> <a target="_blank" href="https://edk2.groups.io/g/devel/message/79652">View/Reply Online (#79652)</a> |    |  <a target="_blank" href="https://groups.io/mt/85014307/1813853">Mute This Topic</a>  | <a href="https://edk2.groups.io/g/devel/post">New Topic</a><br>    <a href="https://edk2.groups.io/g/devel/editsub/1813853">Your Subscription</a> | <a href="mailto:devel+owner@edk2.groups.io">Contact Group Owner</a> |  <a href="https://edk2.groups.io/g/devel/unsub">Unsubscribe</a>  [edk2-devel-archive@redhat.com]<br> <div width="1" style="color:white;clear:both">_._,_._,_</div>