From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4001:c0b::242; helo=mail-it0-x242.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-it0-x242.google.com (mail-it0-x242.google.com [IPv6:2607:f8b0:4001:c0b::242]) (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 247B720969654 for ; Mon, 14 May 2018 10:35:24 -0700 (PDT) Received: by mail-it0-x242.google.com with SMTP id e185-v6so4435040ita.0 for ; Mon, 14 May 2018 10:35:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=ewP8qXC7Ts190pL+ZTz4AgZCsnrW+5nOIPFAzDO2OuY=; b=RejwNOWsDNPn7lWGMm9wCWUUJElExNe3D77nmcbm3KqSqH0NoTYhlcutlyDJ63pky4 P1xuv9AcaGc6DBfNxVTKe9lawGjVyXWYb21RIkiBkIBIdTAS4alQ9GGI9xuFkpZFUTKI g9hRd0k2vs1rYdKz3u9smTxxPQg7g4X76MFFM= 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=ewP8qXC7Ts190pL+ZTz4AgZCsnrW+5nOIPFAzDO2OuY=; b=BKhqnP8s21zZHy1Ph8OYiKd2L6IpCS243DldkNbD0avFT41P/47hdYOe0GwIoBXiL8 dlsnp696g+tGA9BQrDmRUzIIw0wHSN10xsIUlOTQ0cxe01ucQhQ+Aq9OrilAOgwQTmbE tIfNiF1gS55b9Ns+VKILxbSGs3eXUodsZUKFUytoNz4DASzdEFHYixgxrMwiX1O0qvu9 wYSbZP/vlyemdU9WpqgzEDPWDx0oXt8w/01yzGB4V7i91oxQbtFQfpAar0CfDLb9fBIw OJ0gQRxMIzWlQAxmqy0cRgnIRXOQFO5ZE6qaJtKgn50AZ3LmaAUfobBeSzi/Dmnwngbo RqZQ== X-Gm-Message-State: ALKqPwepB54mCxSZNw1T1ubTKCzoMsAqs4bALNbOxuMZo0gEoJ4dRZGo fRn/V4RkpS4yTQDzOBxuDIAnDXZLNRjNxuRJOUEmQQ== X-Google-Smtp-Source: AB8JxZp2Cn9mWz3H+ewadAa6oXpF1zXcfA7d1PDg3E1CfjQduAbGaZVcQ8vm4h//5zdUdyj4J6LPjg1BfKczLkbnrPI= X-Received: by 2002:a24:af45:: with SMTP id l5-v6mr10657023iti.106.1526319324148; Mon, 14 May 2018 10:35:24 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.187.134 with HTTP; Mon, 14 May 2018 10:35:23 -0700 (PDT) In-Reply-To: <7a06065337081fd8f1c160dced72d708@mail.gmail.com> References: <51c562dc1e3275caf4a87939912e46d5@mail.gmail.com> <7a06065337081fd8f1c160dced72d708@mail.gmail.com> From: Ard Biesheuvel Date: Mon, 14 May 2018 19:35:23 +0200 Message-ID: To: Roman Bacik Cc: "edk2-devel@lists.01.org" , Ruiyu Ni , Vladimir Olovyannikov 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: Mon, 14 May 2018 17:35:25 -0000 Content-Type: text/plain; charset="UTF-8" On 14 May 2018 at 19:28, Roman Bacik wrote: > Ard, > > Thank you very much for your comment. > >> -----Original Message----- >> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org] >> Sent: Sunday, May 13, 2018 3:25 AM >> To: Roman Bacik >> Cc: edk2-devel@lists.01.org; Ruiyu Ni; Vladimir Olovyannikov >> Subject: Re: [edk2] [PATCH] Enable using device address when programming >> BARs >> >> On 9 May 2018 at 22:17, Roman Bacik wrote: >> > I will upload v2 with the corrected subject - add package name >> > MdeModulePkg/Bus . >> > >> >> I don't think this is the correct approach. Please use the address >> translation >> support that has been added recently to PciHostBridgeDxe and >> PciHostBridgeLib. >> > > Would you like to see this change: > > Address = Base + Node->Offset; > + if (UseDeviceAddress) > + Address = TO_DEVICE_ADDRESS(Address, -Base); > > Instead of: > > - Address = Base + Node->Offset; > + Address = UseDeviceAddress? Node->Offset: Base + Node->Offset; > No. Programming BARs should always involve device addresses, never CPU addresses. If you wire up the MMIO translation support correctly, the existing code will already do what you want. >> > >> > >> > *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|0 >> x300010 >> > 55 >> > >> > + ## Indicates whether the device address should be used for BAR >> > programming >> > + >> > >> > >> gEfiMdeModulePkgTokenSpaceGuid.PcdUseDeviceAddress|FALSE|BOOLEA >> N|0x300 >> > 01056 >> > + >> > [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 >> > _______________________________________________ >> > edk2-devel mailing list >> > edk2-devel@lists.01.org >> > https://lists.01.org/mailman/listinfo/edk2-devel > > Thanks, > > Roman