From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=66.187.233.73; helo=mx1.redhat.com; envelope-from=lersek@redhat.com; receiver=edk2-devel@lists.01.org Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B266E2063D74A for ; Mon, 14 May 2018 11:04:54 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D68687CBBA; Mon, 14 May 2018 18:04:53 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-253.rdu2.redhat.com [10.10.120.253]) by smtp.corp.redhat.com (Postfix) with ESMTP id B2BE863AF7; Mon, 14 May 2018 18:04:52 +0000 (UTC) To: Roman Bacik Cc: Ard Biesheuvel , Ruiyu Ni , "edk2-devel@lists.01.org" , Vladimir Olovyannikov References: <51c562dc1e3275caf4a87939912e46d5@mail.gmail.com> <7a06065337081fd8f1c160dced72d708@mail.gmail.com> From: Laszlo Ersek Message-ID: Date: Mon, 14 May 2018 20:04:51 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 14 May 2018 18:04:53 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 14 May 2018 18:04:53 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'lersek@redhat.com' RCPT:'' 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 18:04:54 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Hi Roman, On 05/14/18 19:35, Ard Biesheuvel wrote: > 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. To clarify a bit, please look at the following commits: 1 5bb1866e5383 MdeModulePkg/PciHostBridgeLib.h: add address Translation 2 74d0a339b832 MdeModulePkg/PciHostBridgeDxe: Add support for address translation 3 c03860d05233 MdeModulePkg/PciBus: convert host address to device address 4 dc080d3b61e5 MdeModulePkg/PciBus: return CPU address for GetBarAttributes in particular, as Ard's first response suggests, the new field introduced in commit 5bb1866e5383. The PciHostBridgeLib instance that your platform plugs into MdeModulePkg/PciHostBridgeDxe should populate this field correctly. Then PciHostBridgeDxe and PciBusDxe will do the right thing for you. Thanks Laszlo