From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c09::22f; helo=mail-wm0-x22f.google.com; envelope-from=roman.bacik@broadcom.com; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x22f.google.com (mail-wm0-x22f.google.com [IPv6:2a00:1450:400c:c09::22f]) (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 C53A0203B8BF0 for ; Mon, 30 Apr 2018 08:49:23 -0700 (PDT) Received: by mail-wm0-x22f.google.com with SMTP id j5so15029858wme.5 for ; Mon, 30 Apr 2018 08:49:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=yyhCSDSWuHFba6ec6jLM2F57Z/yC88reXouvPJecFSc=; b=JzP3bI/B4zO8NED6ugHwWMUJ3u76G/E0xNUl6UsOaEiF7/dJeWPQhzY7siqqrdqWdP RCiUON0QsTAJDbuhXrltK6A9QUAR7XAb3KzD29hHPgFsVJ9s5SUGPZ4ihcv8N7iuknaA UBmIAtr8eeM+b9f/u9F+objps7wSPM3ffnzbA= 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; bh=yyhCSDSWuHFba6ec6jLM2F57Z/yC88reXouvPJecFSc=; b=PvdnSaiWoUdzgvZ81n2RCkkCo8uNpV1IjNy7R3hfdLKZtShOkpTuF/Hl3VJV1WJydV aG8F8cDUy318MVFp4tRANvdLsRakXMXOIVBrg0IwqnYHWgVxvGlGDGtk3gYOJBOImqPt jXFQi6UgNMubBzPyJan3Tg7DqcSAB00g9T0FPWbPRYbN3fNOFr/H+iRxdJcDP6OPn8cN zj8W6aZLUfxeDxfXhjoCws/jP7QlWSkOZJiNJ7FEAoDEw7LIZYYylPebN6iZLi/kL3mn sCTp31QJC/9MRirikbRPXUyBI8fvWYw84oaYpg0eKwrF0TPNaGvMapuTyMdQY9Rfd3/L 0G+w== X-Gm-Message-State: ALQs6tC56hsLJVpO1uv367khPwmii2OULhqpDIUTzZZg15FGmKmfBu0y lgnKopxfKHNlVXUAQqlWiHjpiy4Fm1402PUSZ8D1V4f9Vlk= X-Google-Smtp-Source: AB8JxZqbMilNNqCa4KC8VdizDCeY8bGRo8iQW7YnNtKe/6HAOGNzgYR8zZyd3Vy30rArOd1aMokX6c7OrtrB4a6FxCw= X-Received: by 10.28.235.14 with SMTP id j14mr7280673wmh.87.1525103362098; Mon, 30 Apr 2018 08:49:22 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.210.68 with HTTP; Mon, 30 Apr 2018 08:48:41 -0700 (PDT) In-Reply-To: References: From: Roman Bacik Date: Mon, 30 Apr 2018 08:48:41 -0700 Message-ID: To: edk2-devel@lists.01.org Cc: Ruiyu Ni , Vladimir Olovyannikov X-Content-Filtered-By: Mailman/MimeDel 2.1.26 Subject: Re: [PATCH v1] MdeModulePkg/Bus: Enable ascending resource list X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2018 15:49:24 -0000 Content-Type: text/plain; charset="UTF-8" On Sat, Apr 28, 2018 at 11:53 AM, Roman Bacik wrote: > Enable resource list sorted in ascending order required by some SoCs. > > Cc: Vladimir Olovyannikov > Cc: Ruiyu Ni > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Roman Bacik > --- > MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf | 1 + > .../Bus/Pci/PciBusDxe/PciResourceSupport.c | 43 > ++++++++++++++++++---- > MdeModulePkg/MdeModulePkg.dec | 3 ++ > MdeModulePkg/MdeModulePkg.dsc | 1 + > 4 files changed, 41 insertions(+), 7 deletions(-) > > diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf > b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf > index 97608bf..5cb3761 100644 > --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf > +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf > @@ -110,6 +110,7 @@ > gEfiMdeModulePkgTokenSpaceGuid.PcdAriSupport ## > CONSUMES > gEfiMdeModulePkgTokenSpaceGuid.PcdMrIovSupport ## > CONSUMES > gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration ## > SOMETIMES_CONSUMES > + gEfiMdeModulePkgTokenSpaceGuid.PcdListAscending ## > CONSUMES > > [UserExtensions.TianoCore."ExtraFiles"] > PciBusDxeExtra.uni > diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c > b/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c > index 2f713fc..45575fa 100644 > --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c > +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c > @@ -106,19 +106,30 @@ InsertResourceNode ( > PCI_RESOURCE_NODE *Temp; > UINT64 ResNodeAlignRest; > UINT64 TempAlignRest; > + BOOLEAN Ascending; > > ASSERT (Bridge != NULL); > ASSERT (ResNode != NULL); > > - InsertHeadList (&Bridge->ChildList, &ResNode->Link); > + Ascending = FeaturePcdGet (PcdListAscending); > + > + if (Ascending) { > The line above should be: if (!Ascending) { + InsertHeadList (&Bridge->ChildList, &ResNode->Link); > + CurrentLink = Bridge->ChildList.ForwardLink->ForwardLink; > + } else { > + CurrentLink = Bridge->ChildList.BackLink; > + InsertTailList (&Bridge->ChildList, &ResNode->Link); > + } > > - CurrentLink = Bridge->ChildList.ForwardLink->ForwardLink; > while (CurrentLink != &Bridge->ChildList) { > Temp = RESOURCE_NODE_FROM_LINK (CurrentLink); > > - if (ResNode->Alignment > Temp->Alignment) { > + if ((Ascending && Temp->Alignment >= ResNode->Alignment) || > + (!Ascending && ResNode->Alignment > Temp->Alignment)) { > break; > - } else if (ResNode->Alignment == Temp->Alignment) { > + } > + > + if (!Ascending && ResNode->Alignment == Temp->Alignment) { > ResNodeAlignRest = ResNode->Length & ResNode->Alignment; > TempAlignRest = Temp->Length & Temp->Alignment; > if ((ResNodeAlignRest == 0) || (ResNodeAlignRest >= TempAlignRest)) > { > @@ -128,7 +139,11 @@ InsertResourceNode ( > > SwapListEntries (&ResNode->Link, CurrentLink); > > - CurrentLink = ResNode->Link.ForwardLink; > + if (Ascending) { > + CurrentLink = ResNode->Link.BackLink; > + } else { > + CurrentLink = ResNode->Link.ForwardLink; > + } > } > } > > @@ -1269,6 +1284,7 @@ ProgramBar ( > EFI_PCI_IO_PROTOCOL *PciIo; > UINT64 Address; > UINT32 Address32; > + BOOLEAN Ascending; > > ASSERT (Node->Bar < PCI_MAX_BAR); > > @@ -1282,6 +1298,7 @@ ProgramBar ( > > Address = 0; > PciIo = &(Node->PciDev->PciIo); > + Ascending = FeaturePcdGet (PcdListAscending); > > Address = Base + Node->Offset; > > @@ -1300,6 +1317,10 @@ ProgramBar ( > case PciBarTypeMem32: > case PciBarTypePMem32: > > + if (Ascending) { > + Node->PciDev->PciBar[Node->Bar].BaseAddress = Address; > + Address %= Base; > + } > PciIo->Pci.Write ( > PciIo, > EfiPciIoWidthUint32, > @@ -1308,13 +1329,19 @@ ProgramBar ( > &Address > ); > > - Node->PciDev->PciBar[Node->Bar].BaseAddress = Address; > + if (!Ascending) { > + Node->PciDev->PciBar[Node->Bar].BaseAddress = Address; > + } > > break; > > case PciBarTypeMem64: > case PciBarTypePMem64: > > + if (Ascending) { > + Node->PciDev->PciBar[Node->Bar].BaseAddress = Address; > + Address %= Base; > + } > Address32 = (UINT32) (Address & 0x00000000FFFFFFFF); > > PciIo->Pci.Write ( > @@ -1335,7 +1362,9 @@ ProgramBar ( > &Address32 > ); > > - Node->PciDev->PciBar[Node->Bar].BaseAddress = Address; > + if (!Ascending) { > + Node->PciDev->PciBar[Node->Bar].BaseAddress = Address; > + } > > break; > > diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec > index cc39718..911f33a 100644 > --- a/MdeModulePkg/MdeModulePkg.dec > +++ b/MdeModulePkg/MdeModulePkg.dec > @@ -1005,6 +1005,9 @@ > # @Prompt Enable UEFI Stack Guard. > gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard|FALSE| > BOOLEAN|0x30001055 > > + ## Indicates if the resource list is sorted in ascending order > + gEfiMdeModulePkgTokenSpaceGuid.PcdListAscending|FALSE| > BOOLEAN|0x30001056 > + > [PcdsFixedAtBuild, PcdsPatchableInModule] > ## Dynamic type PCD can be registered callback function for Pcd setting > action. > # PcdMaxPeiPcdCallBackNumberPerPcdEntry indicates the maximum number > of callback function > diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc > index ec24a50..2dee860 100644 > --- a/MdeModulePkg/MdeModulePkg.dsc > +++ b/MdeModulePkg/MdeModulePkg.dsc > @@ -200,6 +200,7 @@ > gEfiMdeModulePkgTokenSpaceGuid.PcdMaxSizeNonPopulateCapsule|0x0 > gEfiMdeModulePkgTokenSpaceGuid.PcdMaxSizePopulateCapsule|0x0 > gEfiMdeModulePkgTokenSpaceGuid.PcdMaxPeiPerformanceLogEntries|28 > + gEfiMdeModulePkgTokenSpaceGuid.PcdListAscending|FALSE > > [PcdsFixedAtBuild.IPF] > gEfiMdePkgTokenSpaceGuid.PcdIoBlockBaseAddressForIpf|0x0ffffc000000 > -- > 2.7.4 > >