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::244; helo=mail-wm0-x244.google.com; envelope-from=roman.bacik@broadcom.com; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x244.google.com (mail-wm0-x244.google.com [IPv6:2a00:1450:400c:c09::244]) (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 4FD15203B9257 for ; Sat, 28 Apr 2018 11:53:47 -0700 (PDT) Received: by mail-wm0-x244.google.com with SMTP id b21so8180841wme.4 for ; Sat, 28 Apr 2018 11:53:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:from:date:message-id:subject:to:cc; bh=URbPovvV4tf+ch1Insr77g4pngMEUEzK462ZeXWlVdE=; b=LrcjRcB+r4y/3wdpnAZFLsBrU/eThIsYblV0/+1sRmoatN9bZrPELongZuow/vtnj4 IZN9qjL8bP7e2vV+ELSer03nhIk8pO6wRydvXKAamlZuFC8nlSr90dH3K4QAZ+KsCIJU zI7o1vuX6ik31W00j0+x/iQeVUfjlWp+b4Qz0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=URbPovvV4tf+ch1Insr77g4pngMEUEzK462ZeXWlVdE=; b=gcBStRyzjBV3YeDYE3ggUa9NOsLtqU7TXG8i3WAQNhaKjzjjJz2ik4cWoo7DOqN4OI eJcyw4f4AatFYxV77lGNSLGhcJ/5iViBDV3TOeDsOnAyix3KWnOJJVUeNmsAK5zhUhMq UWfFsUNMP8hVTUnYnxTjZB/mJyZIhuJytdGnOZObq27S2CL9nd71/BXnIpJWHclp0rMA qtYAAGQ8NiEEjOAaFuVNvzHiVnOjxIutWijCQlDmaRXSdDkrjjcSic7PdaWrTqmXn2Qo COXYMbD2s3F6dpQw/KirC3ti1ITTXHu2C4PC0/Rp/MewZo+yItu7ju8BL6+7/jcwhnGN 9U9w== X-Gm-Message-State: ALQs6tD7oCXYzTm/PcDA/wPAHzcyEdGVYYP2540yjkrWoAMtxzlPKH3u Zv+nldoq/n58vqmylw3uuwBOXB1fXheZ7Te7upthrmYJsQA= X-Google-Smtp-Source: AB8JxZr/5rBFK2qXvS81hE8S+Ey3AcdQIsXeBclt7/JktZomDyfC4FuaWLcALneqgQWKJ5s7jMVmxnzCf2WGknmG1IE= X-Received: by 10.28.193.11 with SMTP id r11mr4268935wmf.120.1524941625387; Sat, 28 Apr 2018 11:53:45 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.210.68 with HTTP; Sat, 28 Apr 2018 11:53:04 -0700 (PDT) From: Roman Bacik Date: Sat, 28 Apr 2018 11:53:04 -0700 Message-ID: To: edk2-devel@lists.01.org Cc: Ruiyu Ni , Vladimir Olovyannikov X-Content-Filtered-By: Mailman/MimeDel 2.1.26 Subject: [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: Sat, 28 Apr 2018 18:53:48 -0000 Content-Type: text/plain; charset="UTF-8" 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) { + 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