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::241; helo=mail-wm0-x241.google.com; envelope-from=roman.bacik@broadcom.com; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) (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 450D2203B8595 for ; Wed, 9 May 2018 13:25:51 -0700 (PDT) Received: by mail-wm0-x241.google.com with SMTP id a137-v6so24796659wme.1 for ; Wed, 09 May 2018 13:25:51 -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=eudZWaNBPA5p+2YqcXhg2b8woxFOfW12qr8bqZK3gpQ=; b=aKKkFTvH40y6mDLbvoYiDxQxa/Cu6xhy0wkqvXuitcVTbas/A+cqO4K8qPOs9AB1ha Euep7IAb9WN0KxmIr9MonYJLxi+GQBcLvR/NSbmcX3TAFApEIgTtzZFWs6wp2g6rHS4E fbSuHMFMP7DVwKjheNekiD/4uxyNf2BFgdnDc= 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=eudZWaNBPA5p+2YqcXhg2b8woxFOfW12qr8bqZK3gpQ=; b=OLEorwK+T4sJggH7NYk752tUP9bTST+wzXRLGcKaL340tAYGxF3zy3nueUkXUtAXFw bHnFivQaLb7R5Cy5xVqrOkr7WUR+iGgJ6TJRYj67QBT9m9BogccikC+nYwf0/xVHu4KP Pu873e2vFIMnQuzciPNUjV6KPAoiO4pZLUiyul456sKG9pNVLvHGDfd2e/vJHwhuTCQR 9BIrcq2DX00c36C2XO4UMA4BNzUH3qaHEVwkJdEdNTNQtXmKd12duIGguErcGapsiwRM jePUooGvXkhFUst/AQd/Lcgf3GBFhkG/32WfmjUfSVmWTeuIdObn5KrdOlfmZlhCi65J 0HXQ== X-Gm-Message-State: ALKqPwfInh6bQr0yncBFiMsHjKrU4SDeALJe4+5XyYMLeLQLWtmAk5Nn dVykmA3T/jRbUw6cXhYXaL3BJZ0ovUgl8sGRTgViuqEbH3Y= X-Google-Smtp-Source: AB8JxZrkGVTmvaay/2mD9MCORNLdisPA5couvB/uSqi8lt15fCaR/hCGF2VZ1Af2wONMrhz7mhmRqTv2XdvplIzgF7Q= X-Received: by 10.28.183.215 with SMTP id h206mr7043836wmf.2.1525897549840; Wed, 09 May 2018 13:25:49 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.188.78 with HTTP; Wed, 9 May 2018 13:25:09 -0700 (PDT) From: Roman Bacik Date: Wed, 9 May 2018 13:25:09 -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 v2] MdeModulePkg/Bus: Enable to use device address when programming BARs 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: Wed, 09 May 2018 20:25:52 -0000 Content-Type: text/plain; charset="UTF-8" Some SoCs require to use device address when BARs are programmed: https://bugzilla.tianocore.org/show_bug.cgi?id=948 Cc: Ruiyu Ni Cc: Vladimir Olovyannikov Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Roman Bacik --- MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf | 1 + MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c | 8 +++++--- MdeModulePkg/MdeModulePkg.dec | 3 +++ MdeModulePkg/MdeModulePkg.dsc | 1 + 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf index 97608bfcf245..1368e5068574 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.PcdUseDeviceAddress ## CONSUMES [UserExtensions.TianoCore."ExtraFiles"] PciBusDxeExtra.uni diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c index 2f713fcee95e..a23bd1e258ef 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c @@ -1269,6 +1269,7 @@ ProgramBar ( EFI_PCI_IO_PROTOCOL *PciIo; UINT64 Address; UINT32 Address32; + BOOLEAN UseDeviceAddress; ASSERT (Node->Bar < PCI_MAX_BAR); @@ -1282,8 +1283,9 @@ ProgramBar ( Address = 0; PciIo = &(Node->PciDev->PciIo); + UseDeviceAddress = FeaturePcdGet (PcdUseDeviceAddress); - Address = Base + Node->Offset; + Address = UseDeviceAddress? Node->Offset: Base + Node->Offset; // // Indicate pci bus driver has allocated @@ -1308,7 +1310,7 @@ ProgramBar ( &Address ); - Node->PciDev->PciBar[Node->Bar].BaseAddress = Address; + Node->PciDev->PciBar[Node->Bar].BaseAddress = UseDeviceAddress? Base + Address: Address; break; @@ -1335,7 +1337,7 @@ ProgramBar ( &Address32 ); - Node->PciDev->PciBar[Node->Bar].BaseAddress = Address; + Node->PciDev->PciBar[Node->Bar].BaseAddress = UseDeviceAddress? Base + Address: Address; break; diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index cc397185f7b9..58425ee0d57f 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -1005,6 +1005,9 @@ # @Prompt Enable UEFI Stack Guard. gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard|FALSE|BOOLEAN|0x30001055 + ## Indicates whether the device address should be used for BAR programming + gEfiMdeModulePkgTokenSpaceGuid.PcdUseDeviceAddress|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 ec24a50c7d0a..39b397cb13d9 100644 --- a/MdeModulePkg/MdeModulePkg.dsc +++ b/MdeModulePkg/MdeModulePkg.dsc @@ -200,6 +200,7 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdMaxSizeNonPopulateCapsule|0x0 gEfiMdeModulePkgTokenSpaceGuid.PcdMaxSizePopulateCapsule|0x0 gEfiMdeModulePkgTokenSpaceGuid.PcdMaxPeiPerformanceLogEntries|28 + gEfiMdeModulePkgTokenSpaceGuid.PcdUseDeviceAddress|FALSE [PcdsFixedAtBuild.IPF] gEfiMdePkgTokenSpaceGuid.PcdIoBlockBaseAddressForIpf|0x0ffffc000000 -- 1.9.1