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:c0c::241; helo=mail-wr0-x241.google.com; envelope-from=roman.bacik@broadcom.com; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x241.google.com (mail-wr0-x241.google.com [IPv6:2a00:1450:400c:c0c::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 D618A203B8C94 for ; Thu, 3 May 2018 15:55:25 -0700 (PDT) Received: by mail-wr0-x241.google.com with SMTP id v15-v6so19177534wrm.10 for ; Thu, 03 May 2018 15:55:25 -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=NrFQeB2yqcgBTq6pN/+QS+5E4ZOOHAlZTcEDd558hq8=; b=IKdtQ3wLj28EbodoHhhNwPOA09FAe9Ub/0YlR8IwnHSLKsak0hupgJ9sAHPZs6lvH7 UZxoMvLU6/24z0n0yw/SF2nB1ESw6I+Czci7jfsFw2PnRAmjiPtyup6XhgjRBEk8YSMX Ii6BSEZrQht4R88uNDY7Zr+6djqxuO6tYM+SU= 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=NrFQeB2yqcgBTq6pN/+QS+5E4ZOOHAlZTcEDd558hq8=; b=JFoNOa6xpC7SUyiXygrsJ/y0Q5UAxjK1jQFvWjmFQnnpqNveWDawh3Mk60QnSMchAC 39i6bzu17Y8R+0gcH0qLSWC9y6o/SAdiPb0Sh9vJ3YjBTASICk9PU/pLEy5Legl1YaE0 HpCYUROqqRt9VV+ng+QkuJhI1ZsFVwIk3vmKryTPm8Ry/TKO7jk9wdsoINPEAG8nzLvj mF9tHDUDnp/DHihGbSv3c709785tzvm6CIq75OtL0JgqKNwTeJ+tKCCklrUDQNR794v9 StdLDhJwIN00OsKZUcQ9m5myXwZEEj6SN9zwXtcHb94UTeorH0bBP/QsXea9y1ZlW73s 6cCA== X-Gm-Message-State: ALQs6tA+fnTiLiAgV7w0jef8VgAMBqNlvgW/IDy4UBsomHgk0/t0RhhB xsx+SS8cKKznpa2RrusPZwCrNYTKeBm4nCHSdHn0wCvAUto= X-Google-Smtp-Source: AB8JxZpkKZnSdrIBmlRk4Jv3e68wjcJDFPZ3ntLQ9D2dPyVAubFRkML+vy0VL7x09D0471s/hozrVszRc2yNKq1QCCo= X-Received: by 2002:adf:c3cd:: with SMTP id d13-v6mr15415219wrg.282.1525388123667; Thu, 03 May 2018 15:55:23 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.210.68 with HTTP; Thu, 3 May 2018 15:54:43 -0700 (PDT) From: Roman Bacik Date: Thu, 3 May 2018 15:54:43 -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] 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: Thu, 03 May 2018 22:55:26 -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