From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:400e:c01::235; helo=mail-pl0-x235.google.com; envelope-from=heyi.guo@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pl0-x235.google.com (mail-pl0-x235.google.com [IPv6:2607:f8b0:400e:c01::235]) (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 C14952219BC84 for ; Wed, 20 Dec 2017 07:12:22 -0800 (PST) Received: by mail-pl0-x235.google.com with SMTP id b96so9169138pli.2 for ; Wed, 20 Dec 2017 07:17:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=EUbWqtDC7cfC0jNNN3MKoeaAajuRqaqSLgQzipEYa8E=; b=TwQCciIH68jMxBITrUkeMdVKAccUhELWQ4GjRcUwtwS1pJv4Q1kzBG/3DTWnVactZp /ZYSYRKP8RgWKwuiYa+UoF54FwdBXAPHRrwFCKepui4Hx9NnvHydrg5cj2cCxmnfvHla /jkxmonLpeMuF1D4Xhno+nb4UIWf8tgEZVW3E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=EUbWqtDC7cfC0jNNN3MKoeaAajuRqaqSLgQzipEYa8E=; b=nhaWbmxvLdWv9nM/g3QQGRSJBsX/oGeY7+oJscAN7I29kOYGaWp5+1gNT4MwUlGuYi JcvTmzVexbhym5A2Ux5H1lwSjUvIGROiJjquq5XsfUSFNP2IOvxhxXWshRh9cwSafAwY yKvChT3lwdlgYgwaYUCNX7EIlHYVYcJcfwQWlbw4KRc1zk37iCwLHF75pwqIFxacr4s7 GfOBk7ZdQUBFJGzYrAQy8OANzCXiOHmBClJMoymrYl8wtoI0dSA2Cic0GFejEphjaiMy gPM5pp5YJqX0FwNXe8g10o/SQqkHbCIRae4/PFFQqKRsKOx5lZbW+Nro4N5stCyvwWuq y6sQ== X-Gm-Message-State: AKGB3mIMITMfNkGlX6xQEAXUCYLKzN8eyXGXvhGwsEY1ttwKeW1Uf0Ol /mDvGdK8VG62qyl2jDRyVbZ1kw== X-Google-Smtp-Source: ACJfBosiLYw9YyH5TSZyvWYzaB10NQdyD+9T/kvGK86Q/hBBYbv2unAt9XqOH/O/ZZv+nCPBKejyxQ== X-Received: by 10.159.207.132 with SMTP id z4mr7240221plo.440.1513783029581; Wed, 20 Dec 2017 07:17:09 -0800 (PST) Received: from iwish ([45.56.152.181]) by smtp.gmail.com with ESMTPSA id e22sm39293990pfb.176.2017.12.20.07.17.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Dec 2017 07:17:08 -0800 (PST) From: gary guo X-Google-Original-From: gary guo Date: Wed, 20 Dec 2017 23:17:04 +0800 To: Ard Biesheuvel Cc: Heyi Guo , linaro-uefi , "edk2-devel@lists.01.org" , Star Zeng , Eric Dong , Ruiyu Ni , Jason Zhang Message-ID: <20171220151704.GA2482@iwish> References: <1513758078-99534-1-git-send-email-heyi.guo@linaro.org> MIME-Version: 1.0 In-Reply-To: User-Agent: Mutt/1.9.1 (2017-09-22) Subject: Re: [RFC] MdeModulePkg/PciHostBridge: Add address translation support X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Dec 2017 15:12:23 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Dec 20, 2017 at 09:13:58AM +0000, Ard Biesheuvel wrote: > Hi Heyi, > > On 20 December 2017 at 08:21, Heyi Guo wrote: > > PCIe on some ARM platforms requires address translation, not only for > > legacy IO access, but also for 32bit memory BAR access as well. There > > will be "Address Translation Unit" or something similar in PCI host > > bridges to translation CPU address to PCI address and vice versa. So > > we think it may be useful to add address translation support to the > > generic PCI host bridge driver. > > > > I agree. While unusual on a PC, it is quite common on other > architectures to have more complex non 1:1 topologies, which currently > require a forked PciHostBridgeDxe driver with local changes applied. > > > This RFC only contains one minor change to the definition of > > PciHostBridgeLib, and there certainly will be a lot of other changes > > to make it work, including: > > > > 1. Use CPU address for GCD space add and allocate operations, instead > > of PCI address; also IO space will be changed to memory space if > > translation exists. > > > > For I/O space, the translation should simply be applied to the I/O > range. I don't think it makes sense to use memory space here, given > that it is specific to architectures that lack native port I/O. > I made an assumption here that platforms supporting real port IO space do not need address translation, like IA32 and X64, and port IO translation implies the platform does not support real port IO space. Indeed the assumption is not so "generic", so I'll agree if you recommend to support IO to IO translation as well. But I still hope to have IO to memory translation support in PCI host bridge driver, rather than in CPU IO protocol, since the faked IO space might only be used for PCI host bridge and we may have overlapping IO ranges for each host bridge, which is compatible with PCIe specification and PCIe ACPI description. How about adding a flag to indicate whether port IO is translated to real port IO space or system memory space? Thanks and regards, Heyi > > 2. RootBridgeIoMemRead/Write, RootBridgeIoRead/Write need to get > > translation of the corresponding aperture, add the translation to the > > input address, and then call CpuIo2 protocol; IO access will also be > > converted to memory access if IO translation exists. > > > > Again, why is this necessary? A host bridge that implements a non 1:1 > translation for port I/O ranges may be part of a system that has > native port I/O, and so the translation should be based on that. > > > 3. RootBridgeIoConfiguration needs to fill AddrTranslationOffset in > > the discriptor. > > > > Indeed. Note that this has been a source of much confusion lately, > should we should discuss this carefully before spending time on an > implementation. > > > If it makes sense, then I'll continue to prepare the formal patch. > > > > Any comments? > > > > Thanks, > > > > Gary (Heyi Guo) > > > > Cc: Star Zeng > > Cc: Eric Dong > > Cc: Ruiyu Ni > > Cc: Ard Biesheuvel > > Cc: Jason Zhang > > > > --- > > MdeModulePkg/Include/Library/PciHostBridgeLib.h | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/MdeModulePkg/Include/Library/PciHostBridgeLib.h b/MdeModulePkg/Include/Library/PciHostBridgeLib.h > > index d42e9ec..b9e8c0f 100644 > > --- a/MdeModulePkg/Include/Library/PciHostBridgeLib.h > > +++ b/MdeModulePkg/Include/Library/PciHostBridgeLib.h > > @@ -22,6 +22,7 @@ > > typedef struct { > > UINT64 Base; > > UINT64 Limit; > > + UINT64 Translation; > > } PCI_ROOT_BRIDGE_APERTURE; > > > > typedef struct { > > -- > > 2.7.4 > >