From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (NAM10-BN7-obe.outbound.protection.outlook.com [40.107.92.84]) by mx.groups.io with SMTP id smtpd.web12.3056.1629490618176193742 for ; Fri, 20 Aug 2021 13:16:58 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@vmware.com header.s=selector2 header.b=RMrCRdLI; spf=pass (domain: vmware.com, ip: 40.107.92.84, mailfrom: awarkentin@vmware.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JM4GhInIEgS/aQHqbU2wspsELTNUc52gd5RQdu8/POovaFpwUdGUOF+HMQnqc1t5XI54r9WmBL3KLXNpqAmn2DkRVPdyrDqcoDCLD5Lscil1zmUreJ6cmKPrdme+NJNedMpWcarJ+/GhUcJU6rnlfC4XaVgT7cgwzPjG2Sv98dgWRU2UH6hb6hxqwgixCipLOyq702AVNtsVr72a2MpVWKPDEjk8IRiow/FoB1VUhqpHxvEM+6gW+D7B+YdA3ydMIKbFDTtmKZ2n9ILz7nMj3JtHoEM5GbnoRx9EMNdfFlsW4Ky6HKlYzYm/680WrOreuSi0SEb/IX1SgNZFL2AeKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oKCCBBT6qUAebn60y24nssDFZ7AgeheUdJB0BAHRiEI=; b=MauW2JzDRG5GfyVVMc+3nC0lpK2+E4AYZV7RtaT7zTx/GPf8Gq93hHy9e/rVBDHACNhvr7WyKQl71piW3ukFk8cPSXG3f0W6wLitkctbfDFEEbkIHgx5aPvxhnFa/+Dl7kUEIbbvS/Fk1Qd4zfbVUc6MSuW77QFiTMQJQJ7v/npSJMI1cCNO9is1ZsL3CjNU6uIm95uQcPcIfGOQCQ6/MtS4KjD7LAlvMvgVwD0l2m0pBI0kwleSF8G3XcLicfx7RCFfFykJT/HRrepvy9f72MyidLBqpEvFAtUXv77TxPasx4tqhQeGNv6K+aF2hBprv+0UIxDZ5YK1hPuDyoML+Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vmware.com; dmarc=pass action=none header.from=vmware.com; dkim=pass header.d=vmware.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vmware.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oKCCBBT6qUAebn60y24nssDFZ7AgeheUdJB0BAHRiEI=; b=RMrCRdLIuLJHUETap4g+WcFx35CazgDhczcjsN27VZoUKyf6v5EwTV0hm1VaeEoeBEjFJeFt9JouDST1slxV/B/dAvTdNMq2jkzfOieYUoG1LlMMrjK3zeLFGyu0OxOcQtytTDRYH3zZBW4fXU2KTeiOQ7VlYXo1Ceyt7sa0PwA= Received: from PH0PR05MB8702.namprd05.prod.outlook.com (2603:10b6:510:b2::21) by PH0PR05MB7980.namprd05.prod.outlook.com (2603:10b6:510:77::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.9; Fri, 20 Aug 2021 20:16:56 +0000 Received: from PH0PR05MB8702.namprd05.prod.outlook.com ([fe80::c88e:73c1:db37:5b94]) by PH0PR05MB8702.namprd05.prod.outlook.com ([fe80::c88e:73c1:db37:5b94%6]) with mapi id 15.20.4457.005; Fri, 20 Aug 2021 20:16:56 +0000 From: "Andrei Warkentin" To: Jeremy Linton , "devel@edk2.groups.io" CC: "pete@akeo.ie" , "ardb+tianocore@kernel.org" , "Sunny.Wang@arm.com" , "samer.el-haj-mahmoud@arm.com" , =?iso-8859-1?Q?Ren=E9_Treffer?= Subject: Re: [PATCH v3 4/7] Silicon/Broadcom/Bcm27xx: Relax PCIe device restriction Thread-Topic: [PATCH v3 4/7] Silicon/Broadcom/Bcm27xx: Relax PCIe device restriction Thread-Index: AQHXlXolhgliMuEg2EifaLxIf3gJQ6t81a5h Date: Fri, 20 Aug 2021 20:16:56 +0000 Message-ID: References: <20210820041619.87248-1-jeremy.linton@arm.com> <20210820041619.87248-5-jeremy.linton@arm.com> In-Reply-To: <20210820041619.87248-5-jeremy.linton@arm.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=vmware.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 086a95d9-e69f-435f-72ec-08d96417754c x-ms-traffictypediagnostic: PH0PR05MB7980: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8882; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: QsR+TZZ0GTGv8hLcpnuRXQ1AYoYIjMaVIZpOyAi+/Ia0La+u/eZc0wihCXZGTcFDIqh97XTKDs5eOfKOPqn9a7mEN4VjhKKhHWY3X6dKRQSPTQTvDW0E0UndjGVfd66XRk7yZWIIOcc/Oi78Wf2Go2qFmigneRKVGUjQTbypGifjefydPDyoDCUXy+MQgNLkw9cKmAvc63VTdo5Z3b9KcnTbE1BBuufWQLhrccFW0XLy2sC7YgTfMIUY0qA4G24bnIWXq+rQsFbuFOdUYOlMVyEq7JML3pf0slMQWrMpjHbEfsCoG63quWP7mWxb0pTl4Aq3zsCTH9r8T9dnHDBuNmvUuXH52dk4IudlKRP6QLqYGARCY2aW4HgMvvc8KyfyAjV10lipcnZHUpgnkBlWbiNM7iqYFZV9/dcmQZKf4UvGPeIaw14RrYi1iZAi8G/rvU/m/NeBVrQFmK/HgDBzCLK6ViuYyeV9PIswooZVZUBjrQlvyRHfwRJCMSppojc1ZzXh2f/2+3TCNPRShSmSs/jWcSkdJTHytqgRba/VgD4n5oR8iaMjCVpl05nxBlC2vYKZEiiqmcs3ZrlwAiZ5ENpD7/nnRoI5jU0ShDuZm59A8TruZL0JEVdA1E7XFd1SHIwVHRcXzoI/h4punE2W73qUKeL1OZj0V14+ZN70W7gB0Z32aKNJ26J7jczOfMj4DNMJQXydZazH0eFtRYMIGg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR05MB8702.namprd05.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(8936002)(86362001)(8676002)(83380400001)(19627405001)(33656002)(54906003)(110136005)(66446008)(316002)(508600001)(2906002)(4326008)(55016002)(9686003)(64756008)(66556008)(66476007)(6506007)(53546011)(186003)(26005)(76116006)(66946007)(91956017)(5660300002)(7696005)(122000001)(38100700002)(38070700005)(71200400001)(52536014);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?yENdBzj8XnXhKEw8XR2hP/DgOzE60ZpqDH9uZx0lKMyvV7seiuPkdwWvpU?= =?iso-8859-1?Q?ptsCE7cg70FUOPpjoXv66AMRLhvIQbl1JunEGqSpd1u0hIaay4v0vjqp50?= =?iso-8859-1?Q?yUmFQQfhSDupMrAI59opJUyKWNLuVd9JwuvEu9CLS54js/8Bk0WwZtgEAm?= =?iso-8859-1?Q?mcEIwMVzaTIbWjM0/2btAeUykaFHZZvb1FJWr4jNz3jpEl+hmUEQXDtyhZ?= =?iso-8859-1?Q?TAFoudL86SVWViOvyJ94iyiNF2Ch4JODgPQcMHa9N7eEp3zm+Pux9kAq7b?= =?iso-8859-1?Q?RYuEIj/TVBPRdJIbk3+5FlTeQTPJgs9ENWsjriBJCVD3/vCgyxNbwifpA3?= =?iso-8859-1?Q?AFasK4DyWsLeNx/vYRs65SQnXeKv2M7zPiirpxjuBcvCy1CNb6FED3Dmuj?= =?iso-8859-1?Q?tVeWuaiX9mnVnx0eF3iFxrDhRqYq8rUOF8+lrnoSBV7llpdm72pPczDaiH?= =?iso-8859-1?Q?nvWxNq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=?iso-8859-1?Q?wODQEEjaUo?= x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH0PR05MB8702.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 086a95d9-e69f-435f-72ec-08d96417754c X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Aug 2021 20:16:56.4077 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: cV+1H0R1I+bGquLLk03GcgvuAmDNMNw17IfqOr0ImHekDOiZ04XOPZqqnz1RIfB9GDKS/d1i5FlszCkH/hTYQg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR05MB7980 Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_PH0PR05MB8702094CD8F4E78E627E9F85B9C19PH0PR05MB8702namp_" --_000_PH0PR05MB8702094CD8F4E78E627E9F85B9C19PH0PR05MB8702namp_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Reviewed-by: Andrei Warkentin ________________________________ From: Jeremy Linton Sent: Thursday, August 19, 2021 11:16 PM To: devel@edk2.groups.io Cc: pete@akeo.ie ; ardb+tianocore@kernel.org ; Andrei Warkentin ; Sunny.Wang@arm.com <= Sunny.Wang@arm.com>; samer.el-haj-mahmoud@arm.com ; Jeremy Linton ; Ren=E9 Treffer Subject: [PATCH v3 4/7] Silicon/Broadcom/Bcm27xx: Relax PCIe device restric= tion The CM4 has an actual PCIe slot, so the device filtering need to be a little less restrictive WRT busses with more than 1 device given that switches can now appear in the topology. Since it is possible to start numbering the busses with a non-zero value, the bus restriction should be based on the secondary side of the root port. This isn't likely but its better than hard-coding the limit. Suggested-by: Ren=E9 Treffer Signed-off-by: Jeremy Linton --- .../Library/Bcm2711PciSegmentLib/PciSegmentLib.c | 21 ++++++++++++++---= ---- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Silicon/Broadcom/Bcm27xx/Library/Bcm2711PciSegmentLib/PciSegme= ntLib.c b/Silicon/Broadcom/Bcm27xx/Library/Bcm2711PciSegmentLib/PciSegmentL= ib.c index 44ce3b4b99..6d15e82fa2 100644 --- a/Silicon/Broadcom/Bcm27xx/Library/Bcm2711PciSegmentLib/PciSegmentLib.c +++ b/Silicon/Broadcom/Bcm27xx/Library/Bcm2711PciSegmentLib/PciSegmentLib.c @@ -19,6 +19,7 @@ #include #include #include +#include typedef enum { PciCfgWidthUint8 =3D 0, @@ -78,6 +79,9 @@ PciSegmentLibGetConfigBase ( UINT64 Base; UINT64 Offset; UINT32 Dev; + UINT32 Bus; + UINT32 Data; + UINT32 HostPortSec; Base =3D PCIE_REG_BASE; Offset =3D Address & 0xFFF; /* Pick off the 4k register offset *= / @@ -89,17 +93,20 @@ PciSegmentLibGetConfigBase ( Base +=3D PCIE_EXT_CFG_DATA; if (mPciSegmentLastAccess !=3D Address) { Dev =3D EFI_PCI_ADDR_DEV (Address); + Bus =3D EFI_PCI_ADDR_BUS (Address); + HostPortSec =3D MmioRead8 (PCIE_REG_BASE + + PCI_BRIDGE_SECONDARY_BUS_REGISTER_OFFSET); + /* - * Scan things out directly rather than translating the "bus" to a d= evice, etc.. - * only we need to limit each bus to a single device. + * There can only be a single device on bus 1 (downstream of root). + * Subsequent busses (behind a PCIe switch) can have more. */ - if (Dev < 1) { - MmioWrite32 (PCIE_REG_BASE + PCIE_EXT_CFG_INDEX, Address); - mPciSegmentLastAccess =3D Address; - } else { - mPciSegmentLastAccess =3D 0; + if (Dev > 0 && (Bus <=3D HostPortSec)) { return 0xFFFFFFFF; } + + MmioWrite32 (PCIE_REG_BASE + PCIE_EXT_CFG_INDEX, Address); + mPciSegmentLastAccess =3D Address; } } return Base + Offset; -- 2.13.7 --_000_PH0PR05MB8702094CD8F4E78E627E9F85B9C19PH0PR05MB8702namp_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Reviewed-by: Andrei Warkentin <awarkentin@vmware.com>

From: Jeremy Linton <jer= emy.linton@arm.com>
Sent: Thursday, August 19, 2021 11:16 PM
To: devel@edk2.groups.io <devel@edk2.groups.io>
Cc: pete@akeo.ie <pete@akeo.ie>; ardb+tianocore@kernel.org <= ;ardb+tianocore@kernel.org>; Andrei Warkentin <awarkentin@vmware.com&= gt;; Sunny.Wang@arm.com <Sunny.Wang@arm.com>; samer.el-haj-mahmoud@ar= m.com <samer.el-haj-mahmoud@arm.com>; Jeremy Linton <jeremy.linton= @arm.com>; Ren=E9 Treffer <treffer+groups.io@measite.de>
Subject: [PATCH v3 4/7] Silicon/Broadcom/Bcm27xx: Relax PCIe device = restriction
 
The CM4 has an actual PCIe slot, so the device fil= tering
need to be a little less restrictive WRT busses with more
than 1 device given that switches can now appear in the
topology. Since it is possible to start numbering the
busses with a non-zero value, the bus restriction should
be based on the secondary side of the root port. This
isn't likely but its better than hard-coding the limit.

Suggested-by: Ren=E9 Treffer <treffer+groups.io@measite.de>
Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
---
 .../Library/Bcm2711PciSegmentLib/PciSegmentLib.c    | = 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/Silicon/Broadcom/Bcm27xx/Library/Bcm2711PciSegmentLib/PciSegme= ntLib.c b/Silicon/Broadcom/Bcm27xx/Library/Bcm2711PciSegmentLib/PciSegmentL= ib.c
index 44ce3b4b99..6d15e82fa2 100644
--- a/Silicon/Broadcom/Bcm27xx/Library/Bcm2711PciSegmentLib/PciSegmentLib.c=
+++ b/Silicon/Broadcom/Bcm27xx/Library/Bcm2711PciSegmentLib/PciSegmentLib.c=
@@ -19,6 +19,7 @@
 #include <Library/PciSegmentLib.h>
 #include <Library/UefiLib.h>
 #include <IndustryStandard/Bcm2711.h>
+#include <IndustryStandard/Pci30.h>
 
 typedef enum {
   PciCfgWidthUint8 =3D 0,
@@ -78,6 +79,9 @@ PciSegmentLibGetConfigBase (
   UINT64        Base;
   UINT64        Offset;
   UINT32        Dev;
+  UINT32        Bus;
+  UINT32        Data;
+  UINT32        HostPortSec;
 
   Base =3D PCIE_REG_BASE;
   Offset =3D Address & 0xFFF;     &= nbsp;   /* Pick off the 4k register offset */
@@ -89,17 +93,20 @@ PciSegmentLibGetConfigBase (
     Base +=3D PCIE_EXT_CFG_DATA;
     if (mPciSegmentLastAccess !=3D Address) {
       Dev =3D EFI_PCI_ADDR_DEV (Address); +      Bus =3D EFI_PCI_ADDR_BUS (Address);
+      HostPortSec =3D MmioRead8 (PCIE_REG_BASE +<= br> +            &n= bsp;            = ;      PCI_BRIDGE_SECONDARY_BUS_REGISTER_OFFSET);<= br> +
       /*
-       * Scan things out directly rather tha= n translating the "bus" to a device, etc..
-       * only we need to limit each bus to a= single device.
+       * There can only be a single device o= n bus 1 (downstream of root).
+       * Subsequent busses (behind a PCIe sw= itch) can have more.
        */
-      if (Dev < 1) {
-          MmioWrite32 (PCIE_R= EG_BASE + PCIE_EXT_CFG_INDEX, Address);
-          mPciSegmentLastAcce= ss =3D Address;
-      } else {
-          mPciSegmentLastAcce= ss =3D 0;
+      if (Dev > 0 && (Bus <=3D Host= PortSec)) {
           return 0xFFFFF= FFF;
       }
+
+      MmioWrite32 (PCIE_REG_BASE + PCIE_EXT_CFG_I= NDEX, Address);
+      mPciSegmentLastAccess =3D Address;
     }
   }
   return Base + Offset;
--
2.13.7

--_000_PH0PR05MB8702094CD8F4E78E627E9F85B9C19PH0PR05MB8702namp_--