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::242; helo=mail-wm0-x242.google.com; envelope-from=roman.bacik@broadcom.com; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::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 CAF95209603D6 for ; Tue, 15 May 2018 07:40:25 -0700 (PDT) Received: by mail-wm0-x242.google.com with SMTP id a137-v6so16128322wme.1 for ; Tue, 15 May 2018 07:40:25 -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=YnkIbKtS+angI75fZS8MPvMXC8xfcHhWXKlDTCAnB60=; b=Gd8ZlQP/5CN+4oW62uROlLZKGNw8tb5lgEaWtA1qX0Orz7leONDaoKct4/Hzn3Zi6H CNCOvh1Z82ME1k2T4PlDDcLO8UkZKEI+DFohT0bfHk0VkhylfeYPTJ8pttGSezAo0eUr tjF1VoDW6s8LPIi1IwqfeeNLmLzTOT0uDjQq8= 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=YnkIbKtS+angI75fZS8MPvMXC8xfcHhWXKlDTCAnB60=; b=tH76lyCxZS+194JzmJ94BtZmrRyinr12y55QhGGGSZvahSXU87pg6XMPttu9vY57i3 R3j3OOKf7u79QEUoZLl59lFeSNK0oe6iwuXQLMy/H/P+0l9yJiXs0Pn4Ek4avMrPXa/0 H6z5aQZ/g35P0rja27DVNj5qriPrDGUHs7ce7iBxnTrnpl4HB1GE+asHcPmCSQgbZIPZ fD39g/baG/TeDT9ATd+nZDSlRi1VD95cQuIM2yUpFloBKvUbJ2xykUeKVA2IBbg04NwT T1oGm/eDwHMuaTintr8IGog3IqLqEs1xXjpcrfDqy/xxfW6twdnuBRGOtfcSzytzSrVm 1Kwg== X-Gm-Message-State: ALKqPwcF70qe4UF0oKb7bXPswCxTV9J7CWtlrJmaudq16P+P/6U5y0eJ ChS6p0SkkzhbYsFwUfUlTeZmklbLpzJ+jZuIyObT5g== X-Google-Smtp-Source: AB8JxZoB76p9SMOpOOhI9phzdMa5zU46EUtzSp8ISs4zkMrLTX+cfxdXyE6UoyAe5j35seuQxDR8leVgwW57hWLluK0= X-Received: by 2002:a1c:eb0e:: with SMTP id j14-v6mr7594685wmh.87.1526395223285; Tue, 15 May 2018 07:40:23 -0700 (PDT) From: Roman Bacik References: <51c562dc1e3275caf4a87939912e46d5@mail.gmail.com> <7a06065337081fd8f1c160dced72d708@mail.gmail.com> In-Reply-To: MIME-Version: 1.0 X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQHTOO3jGNEM57qjhAzKusnUj2uRYQHDCluqAW5//0gBCzZ6igKxHHx+AgDpetij6s0gQA== Date: Tue, 15 May 2018 07:40:22 -0700 Message-ID: To: Laszlo Ersek Cc: Ard Biesheuvel , Ruiyu Ni , edk2-devel@lists.01.org, 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: Tue, 15 May 2018 14:40:26 -0000 Content-Type: text/plain; charset="UTF-8" Hi Laszlo, Ard, After seeing the commits you have pointed out your comments are starting to be more clear. We will try to follow your suggestions and will let you know if it works for us. Thank you very much for your explanation, Roman > -----Original Message----- > From: Laszlo Ersek [mailto:lersek@redhat.com] > Sent: Monday, May 14, 2018 11:05 AM > To: Roman Bacik > Cc: Ard Biesheuvel; Ruiyu Ni; edk2-devel@lists.01.org; Vladimir > Olovyannikov > Subject: Re: [edk2] [PATCH] Enable using device address when programming > BARs > > 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