From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 89F2F2095B9D7 for ; Thu, 17 Aug 2017 02:16:24 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 00120C0860AA; Thu, 17 Aug 2017 09:18:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 00120C0860AA Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=lersek@redhat.com Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-76.phx2.redhat.com [10.3.116.76]) by smtp.corp.redhat.com (Postfix) with ESMTP id B4EEC5C6C9; Thu, 17 Aug 2017 09:18:49 +0000 (UTC) To: Eric Song , "edk2-devel@lists.01.org" Cc: Tiger Liu , "Ni, Ruiyu" References: <41761EF483901349B2FAB9B696E9F0B905066FC3@ZXBJMBX01.zhaoxin.com> From: Laszlo Ersek Message-ID: <2915a7f4-3f13-f16f-cf36-03a90ed0a681@redhat.com> Date: Thu, 17 Aug 2017 11:18:48 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <41761EF483901349B2FAB9B696E9F0B905066FC3@ZXBJMBX01.zhaoxin.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 17 Aug 2017 09:18:51 +0000 (UTC) Subject: Re: PCI bus do 2 Enumeration when 2 root bridges under 1 host bridge X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Aug 2017 09:16:24 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Adding Ray On 08/17/17 06:50, Eric Song wrote: > Hi, experts > If there is 2 root bridges under 1 host bridge on the PCI hierarchy, > whether EDK2 Pci bus driver can support it ? the answer is YES, but > some confused things in it. > > 1) On BDS phase, ConnectController is called for every root > bridge, so Pci bus start() will be called for every root bridge. > > VisitAllInstancesOfProtocol (&gEfiPciRootBridgeIoProtocolGuid, ConnectRootBridge, NULL); > > 2) In PCI bus driver, Pci start() will do enumeration on the > entire host bridge > > PciEnumerator()->PciHostBridgeEnumerator->PciResAlloc->GetNextRootBridge() > > That means Do enumeration on entire host bridge for every one root > bridge. So there are 2 enumerations on entire host bridge for my PCI > hierarchy. > What I confused is why do 2 enumerations on entire host bridge by > every one root bridge. Since BDS connect controller by one root bridge > , Pci bus driver should enumerate corresponding root bridge, But it do > the entire host bridge which is the parent of the root bridge. Or BDS > should connect controller by one host bridge, then it will match the > pci bus driver s enumeration policy. In a word, I think it is > illogical for current EDKII code. > > Well, the current code execution will do 2 enumerations on host bridge > for 2 root bridges under 1 host bridge. Even though 2rd enumeration > would be not full enumeration, but do PciEnumeratorLight(), I think it > is still not necessary. Whether there is any side effect ? In another > word, current PCI bus driver enumeration cant be Suitable for 2 > root bridges under 1 host bridge or not? It indeed match the PCI > hierarchy of 2 host bridges and 1 root bridge under 1 host bridge. While I don't know the internals of this host bridge-level enumeration, it is worth looking at: (a) in what context PciEnumerator() is called, and (b) how PciEnumerator() works across multiple calls. Regarding (a): PciEnumerator() is called from PciBusDriverBindingStart(), that is, when the PciBusDxe driver is binding a root brirdge. This is the code: // // Enumerate the entire host bridge // After enumeration, a database that records all the device information will be created // // Status = PciEnumerator (Controller); Regarding (b): the PciEnumerator() function depends on a global variable called "gFullEnumeration". This is what we have at the beginning and at the end of PciEnumerator(), respectively: // // If PCI bus has already done the full enumeration, never do it again // if (!gFullEnumeration) { return PciEnumeratorLight (Controller); } ... gFullEnumeration = FALSE; Status = gBS->InstallProtocolInterface ( &HostBridgeHandle, &gEfiPciEnumerationCompleteProtocolGuid, EFI_NATIVE_INTERFACE, NULL ); The above seems to imply that PciBusDxe needs host bridge-level information to do its job. This information is apparently collected when the first root bridge is bound. When binding further root bridges (under the same host bridge), the same information collecting is not repeated; PciEnumerator() branches to PciEnumeratorLight() instead. Hope this helps, Laszlo