From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-it0-x22a.google.com (mail-it0-x22a.google.com [IPv6:2607:f8b0:4001:c0b::22a]) (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 380FB2095A32E for ; Wed, 24 May 2017 07:03:12 -0700 (PDT) Received: by mail-it0-x22a.google.com with SMTP id g126so39537844ith.0 for ; Wed, 24 May 2017 07:03:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=iwN0nFcdabLZnsGLDfumQYZcXg4xT536cMhxCDsKBrA=; b=B0CaTV8SG00Gqo3elW/3aDbnORlKd3ED6gWLQFU5Y+QiWiY4cMgqeIVB3K8O6PZhck 8jlyGahDwYlwfR192HmL47UG/COdiIMWxYIDY1CvU0vuGc1z/sJR3PxMCqyzFodsHJqC cJ5Aq7KmAUOLQ/Iqb+ny5h3sx4t7QNQY7pFuE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=iwN0nFcdabLZnsGLDfumQYZcXg4xT536cMhxCDsKBrA=; b=STmaxAZLoo5/PcvS1V8jB5+bnq+ZUW8xffxBOdPci5jcuoE1/5TAefFuBBNmCVqrP0 Ch/tcg2nmR9KW1gK4VG9W7RZhilYnXH5s8x1l2m/nqI+hCS+QVFdmDrT6yA1YNR6K6kW qyODZ0MbhltziAtd+2vnlhy51ToZKaYwdJMkO8oPjTSu1H344vw847VlBSivYrHtmnI3 /2FTSifx9rssXcFKhcdWlulIdCFhgmZQYFRioMTgukuGgQAPfo/dw14KWzK9xpRZDrF5 egamBPGs+ad3Z3rxC+OpdgUOiwmEKVxBLPW2iLkbliHJor02A4oRp75E4Jqx6yHDYzsk Q/MQ== X-Gm-Message-State: AODbwcBr7IdgVeWJPOU2o5w84Xj0Vmd6vUERwhcFPhcyHSIFSgljN3lw xgiHIbA5QcP9Mp+HdEIbAbgsXtnIJotl X-Received: by 10.36.80.7 with SMTP id m7mr8799265itb.73.1495634591204; Wed, 24 May 2017 07:03:11 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.164.24 with HTTP; Wed, 24 May 2017 07:03:10 -0700 (PDT) In-Reply-To: References: <1495556147-6883-1-git-send-email-stelford@cadence.com> From: Ard Biesheuvel Date: Wed, 24 May 2017 07:03:10 -0700 Message-ID: To: Scott Telford , Leif Lindholm Cc: "edk2-devel@lists.01.org" , "Tian, Feng" , "Zeng, Star" 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: Wed, 24 May 2017 14:03:12 -0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable (+ 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 ed= k2 - sorry, forgot to edit the subject line! > Ah ok. In that case, do whatever you like :-) > The issue is that, without this workaround, PCI(e) bridges and devices wi= ll be detected multiple times during bus scanning, e.g. a bridge at bus 1 d= evice 0 will also be seen at bus 1 device 1, bus 1 device 2 etc and hence a= ll the devices on the other side of the bridge will be duplicated too. I co= pied 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 bee= n 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? >> -----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 =3D PciAddress.Register; >> > } >> > >> > + // The UEFI PCI enumerator scans for devices at all possible addres= ses, >> > + // 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 =3D=3D 0) && ((PciAddress.Device !=3D 0) || >> (PciAddress.Function !=3D 0))) { >> > + *((UINT32 *)Buffer) =3D 0xffffffff; >> > + return EFI_SUCCESS; >> > + } >> > + if ((PciAddress.Bus =3D=3D 1) && ((PciAddress.Device !=3D 0) || >> (PciAddress.Function !=3D 0))) { >> > + *((UINT32 *)Buffer) =3D 0xffffffff; >> > + return EFI_SUCCESS; >> > + } >> > + >> > Address =3D 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=3Dhttps- >> 3A__lists.01.org_mailman_listinfo_edk2- >> 2Ddevel&d=3DDwIBaQ&c=3DaUq983L2pue2FqKFoP6PGHMJQyoJ7kl3s3GZ- >> _haXqY&r=3D0b2qZ7fqn6FWL0d7Bhx7saDL- >> B7sx3Cxz3HPARO7ozc&m=3D7SGL_JTC4ZjVpm7zTv_uO5MHMY48vYsBzhKmKB >> q66zw&s=3DW6S9XFt8B-FdfcvWjCtvHTGo3uddEyMfM6BIEMe8dtY&e=3D