From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-x233.google.com (mail-wm0-x233.google.com [IPv6:2a00:1450:400c:c09::233]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id CC14B2195FD5B for ; Fri, 26 May 2017 07:50:33 -0700 (PDT) Received: by mail-wm0-x233.google.com with SMTP id b84so130690763wmh.0 for ; Fri, 26 May 2017 07:50:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=ghl1lZRxjRy2lnMcLNJ5StHZtwffDlq0VqqfHOtIWkM=; b=QCryo5/xGCdQeZjo9ieJiKtjlJXh0MHitlLytZTjlUWzE+NK5ovZUlzd1mmXbd4T+n 4gzy4r+N8QAiNhrajaqZyulPB5bpldmHAOZ6D/7ouV0plu8MxBA0216vT2frWwjnCT/i y7nXBabi5OY8aGBB946ifEJHQIy7aDUtIeQg8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=ghl1lZRxjRy2lnMcLNJ5StHZtwffDlq0VqqfHOtIWkM=; b=La1XNIq8X3G2HFYRtnTUth1Ixxv9mhh5kbsJV/1UAwjFeuFS+bmxjbJBOMeojREb9v WWD6hg9eW3fbV2vji/4kkjF8ZPzbGgYlxI5CvqTMw7UcbU/Zz0cGVrKOz6Csy3+OSvSM Vk6Jb4I9lTzlk8qjOqNMCclOpgnK0SeZFdCzLSGbpqKUnjR4yup3z82OtCxn6Y65UVmB 0EgQweGG3dyGPhc2NHG0I1bmJ5AHqa+UhJncvR6oE8rxuj2sekFc5L6uPbyrxKKt4acN 5iN3JBFQ8PcobB94WRo+QPgUq/iECHgsAM2/cCyeUAo81MUJNH2a339Uyp2mZ2GE2VIQ v7Uw== X-Gm-Message-State: AODbwcBSClJsWvsrQxHlWi3vGJi2Ap+xqD7Aj8kBZ9Plcu0Q8RcYP2lf QEADG8rgZh4DEviw X-Received: by 10.28.58.143 with SMTP id h137mr14113144wma.72.1495810232188; Fri, 26 May 2017 07:50:32 -0700 (PDT) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id d7sm810904wrb.10.2017.05.26.07.50.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 May 2017 07:50:31 -0700 (PDT) Date: Fri, 26 May 2017 15:50:29 +0100 From: Leif Lindholm To: Ard Biesheuvel Cc: Scott Telford , "edk2-devel@lists.01.org" , "Tian, Feng" , "Zeng, Star" Message-ID: <20170526145029.GM32240@bivouac.eciton.net> References: <1495556147-6883-1-git-send-email-stelford@cadence.com> MIME-Version: 1.0 In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [PATCH] Copy bus scanning workaround from ARM Juno PCIe driver. 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: Fri, 26 May 2017 14:50:34 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, May 24, 2017 at 07:03:10AM -0700, Ard Biesheuvel wrote: > (+ Leif) > > On 24 May 2017 at 01:34, Scott Telford wrote: > > Hi Ard, > > > > Firstly, this patch was meant for my edk2-staging branch, not > > mainline edk2 - sorry, forgot to edit the subject line! > > Ah ok. In that case, do whatever you like :-) Well, let's try to get keep the staging branch in a state that doesn't require too heavy reworking before final upstreaming. > > The issue is that, without this workaround, PCI(e) bridges and > > devices will be detected multiple times during bus scanning, > > e.g. a bridge at bus 1 device 0 will also be seen at bus 1 device > > 1, bus 1 device 2 etc and hence all the devices on the other side > > of the bridge will be duplicated too. I copied this workaround > > from the old Juno PCIe driver as I was seeing the same problem > > when I was testing the Cadence PCIe host bridge library I have > > been working on. I agree there should probably be a more elegant > > solution, but I don't know the generic PCI driver code well enough > > to suggest one at the moment. > > As I said, the workaround belongs in PciExpressLib. You can just clone > that and put the workaround in there. > > Interestingly, though, this PCIe IP works fine with the generic ECAM > driver in Linux, so I wonder what the difference is. > > Leif, were you aware of this issue? I was not aware of this issue. So a clone of PciExpressLib, whilst suboptimal, sounds like the way to go for now. Regards, Leif > >> -----Original Message----- > >> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org] > >> Sent: 23 May 2017 17:42 > >> To: Scott Telford > >> Cc: edk2-devel@lists.01.org ; Tian, Feng > >> ; Zeng, Star > >> Subject: Re: [edk2] [PATCH] Copy bus scanning workaround from ARM Juno > >> PCIe driver. > >> > >> On 23 May 2017 at 09:15, Scott Telford wrote: > >> > Copy workaround previously in > >> > > >> ArmPlatformPkg/ArmJunoPkg/Drivers/PciHostBridgeDxe/PciRootBridge.c:Pci > >> RbPciRead() > >> > to RootBridgeIoPciAccess(), to avoid spurious multiple detections when > >> > scanning buses. > >> > > >> > Contributed-under: TianoCore Contribution Agreement 1.0 > >> > Signed-off-by: Scott Telford > >> > --- > >> > MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c | 13 > >> +++++++++++++ > >> > >> This does not belong in the generic driver. > >> > >> Could you please explain in more detail what the issue is? In any > >> case, we will need to put this workaround in a Juno specific > >> implementation of PciExpressLib > >> > >> > 1 file changed, 13 insertions(+) > >> > > >> > diff --git a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c > >> b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c > >> > index a0e7e5b..3cca3c1 100644 > >> > --- a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c > >> > +++ b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c > >> > @@ -945,6 +945,19 @@ RootBridgeIoPciAccess ( > >> > PciAddress.ExtendedRegister = PciAddress.Register; > >> > } > >> > > >> > + // The UEFI PCI enumerator scans for devices at all possible addresses, > >> > + // and ignores some PCI rules - this results in some hardware being > >> > + // detected multiple times. We work around this by faking absent > >> > + // devices > >> > + if ((PciAddress.Bus == 0) && ((PciAddress.Device != 0) || > >> (PciAddress.Function != 0))) { > >> > + *((UINT32 *)Buffer) = 0xffffffff; > >> > + return EFI_SUCCESS; > >> > + } > >> > + if ((PciAddress.Bus == 1) && ((PciAddress.Device != 0) || > >> (PciAddress.Function != 0))) { > >> > + *((UINT32 *)Buffer) = 0xffffffff; > >> > + return EFI_SUCCESS; > >> > + } > >> > + > >> > Address = PCI_SEGMENT_LIB_ADDRESS ( > >> > RootBridge->RootBridgeIo.SegmentNumber, > >> > PciAddress.Bus, > >> > -- > >> > 2.2.2 > >> > > >> > _______________________________________________ > >> > edk2-devel mailing list > >> > edk2-devel@lists.01.org > >> > https://urldefense.proofpoint.com/v2/url?u=https- > >> 3A__lists.01.org_mailman_listinfo_edk2- > >> 2Ddevel&d=DwIBaQ&c=aUq983L2pue2FqKFoP6PGHMJQyoJ7kl3s3GZ- > >> _haXqY&r=0b2qZ7fqn6FWL0d7Bhx7saDL- > >> B7sx3Cxz3HPARO7ozc&m=7SGL_JTC4ZjVpm7zTv_uO5MHMY48vYsBzhKmKB > >> q66zw&s=W6S9XFt8B-FdfcvWjCtvHTGo3uddEyMfM6BIEMe8dtY&e=