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 DDE83203B8595 for ; Wed, 9 May 2018 13:17:36 -0700 (PDT) Received: by mail-wm0-x244.google.com with SMTP id a67-v6so524645wmf.3 for ; Wed, 09 May 2018 13:17:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:references:in-reply-to:mime-version:thread-index:date :message-id:subject:to:cc; bh=NmfQZuFF35Dxb2bDHt4HS42/8NdjXD3stRasKNs3Kak=; b=P4Xa6M4v/caZUWivvLsrgd/1SlZRAV/Rb2XJbMhxvT504n4eLcdmw+6747r4Lj35Gr 2u0uKYvcyYSlyYEC3HLmGv+XkscQtkYO4xoUt6LkFnqFFexQKiVi60nXEZZvdniLxKOl 2V9ZjAPdas2Tn3S+faNuNUBEd8iijb4TVCags= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:references:in-reply-to:mime-version :thread-index:date:message-id:subject:to:cc; bh=NmfQZuFF35Dxb2bDHt4HS42/8NdjXD3stRasKNs3Kak=; b=fC78twTNu9IK0eHLnDSPwrQa0uTza/+plGbAA1CJ8KIdC424d/yYmpnfXo17YF1vYW +k9URQMOSke1rlmniOI5NFCEJh2P7d5Dfb6Hr55pSOfH4jr2qgR8pCERr8/CYvXOIjrn cDp1JJf+y5cWYXgOaVS12oiMoVruLieKWojCtR/FyRDUIqMt85lksDV9EI8hKCYZZHPB +76nbMPjp5Rgp3IzcWPo93PME6MQmQQD5qWdhvvDgsuJIuhLqENQSAmWX9lrmGJq2EX5 Qu5pTSqQXnTTlNh24b54viKMVDD2sQresWbJmWTlrCsmusRoVAyiW3vcQ8jrOors+5VI Psxw== X-Gm-Message-State: ALQs6tDnuFjZ690SRPYPJaZqvzmP3vK/qBekCn+s3L6jE+ZBy1tycFfB w4d5SAK0VJHCNgAte0wZ3vhRQ7o+qPrvWKl6pgDAhnlL X-Google-Smtp-Source: AB8JxZp4CSogkNbXfhPnnqUlgReCOaHhe0ZtXSxaFRnDdIL2Hkn1lEWZciEMLG33ZFSAJNiDzEeRY4M6GKERrLWTfo8= X-Received: by 10.28.54.204 with SMTP id y73mr6772678wmh.28.1525897054546; Wed, 09 May 2018 13:17:34 -0700 (PDT) From: Roman Bacik References: In-Reply-To: MIME-Version: 1.0 X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQHTOO3jGNEM57qjhAzKusnUj2uRYaQpMt4w Date: Wed, 9 May 2018 13:17:33 -0700 Message-ID: <51c562dc1e3275caf4a87939912e46d5@mail.gmail.com> To: edk2-devel@lists.01.org Cc: Ruiyu Ni , Vladimir Olovyannikov X-Content-Filtered-By: Mailman/MimeDel 2.1.26 Subject: Re: [PATCH] Enable using 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:17:37 -0000 Content-Type: text/plain; charset="UTF-8" I will upload v2 with the corrected subject - add package name MdeModulePkg/Bus . *From:* Roman Bacik [mailto:roman.bacik@broadcom.com] *Sent:* Thursday, May 3, 2018 3:55 PM *To:* edk2-devel@lists.01.org *Cc:* Ruiyu Ni; Vladimir Olovyannikov *Subject:* [edk2] [PATCH] Enable using device address when programming BARs 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