From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-x236.google.com (mail-wm0-x236.google.com [IPv6:2a00:1450:400c:c09::236]) (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 7705221E95E0F for ; Wed, 30 Aug 2017 03:49:03 -0700 (PDT) Received: by mail-wm0-x236.google.com with SMTP id a80so7451625wma.0 for ; Wed, 30 Aug 2017 03:51:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=W31e4nd6EdCsRafSiwh4MEmNlSKCNlKZkOe3UM3xMbw=; b=S19lr/ryLLpmi4gwLJNqxh/8iaT6iXkpa9q8itdh/Vb/R5nxumyedMcTZErMmmZpqM TKPLm67GeitGk09uTEXWuBzXxsy70nCI33ALyg6s6WC6R+VG99Japo6RgMCVFLacpNy6 tnjibx47T7OdRg+jyK2T6q5vkaMVmPJ5Cle5E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=W31e4nd6EdCsRafSiwh4MEmNlSKCNlKZkOe3UM3xMbw=; b=J9jiGazF1g2SkGjGwYftmvG2Lepy9herYsEszFciXbyFRtjn1z4lmIXyheYEgBk6zm RXG64PdEHzLCtJRZyOSd5tpOL72K+hgubEskjV3wn5MEMZc/v4J4jQjg+EtIYjoEOn5t dxa2Fs+VKJvpQkwh8BMwqQ1p8FRQjicn05t+33W7vOYZqAzlp08MRXME0wTKvLmn5aKU 8rNBliaiVSxnzlKPZ28tA8N0LR+Tb8Rd3/fL2No3K2BFcoge+rOuY+WApaYbGgnrWmwG 6VjnZO485n8kJAVGceSVwnpLpYbwsQK6sFwh2GPJNq0r+OxjdiC6Kh0TTzkt4RLUG8dp VYJA== X-Gm-Message-State: AHYfb5h2xZfspcyoFIZeE3OdinmVTn02hYvGj2H1XZVihMuqLJbVEfR6 T2fQngykcR9xu2V2f4rFMw== X-Received: by 10.28.139.207 with SMTP id n198mr1024619wmd.181.1504090303528; Wed, 30 Aug 2017 03:51:43 -0700 (PDT) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id j62sm3187268wmf.4.2017.08.30.03.51.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 30 Aug 2017 03:51:43 -0700 (PDT) Date: Wed, 30 Aug 2017 11:51:40 +0100 From: Leif Lindholm To: Ard Biesheuvel Cc: edk2-devel@lists.01.org Message-ID: <20170830105140.5gglqu3ftedfbu2y@bivouac.eciton.net> References: <20170830082108.7470-1-ard.biesheuvel@linaro.org> <20170830082108.7470-3-ard.biesheuvel@linaro.org> MIME-Version: 1.0 In-Reply-To: <20170830082108.7470-3-ard.biesheuvel@linaro.org> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [PATCH 2/6] EmbeddedPkg/CoherentDmaLib: add support for non-1:1 DMA translation X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Aug 2017 10:49:03 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Aug 30, 2017 at 09:21:04AM +0100, Ard Biesheuvel wrote: > Bring CoherentDmaLib in line with ArmDmaLib, and add support for > defining a static offset between the host's and the bus master's > view of memory. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ard Biesheuvel > --- > EmbeddedPkg/EmbeddedPkg.dec | 7 +++++++ > EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.c | 10 +++++++++- > EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.inf | 3 +++ > 3 files changed, 19 insertions(+), 1 deletion(-) > > diff --git a/EmbeddedPkg/EmbeddedPkg.dec b/EmbeddedPkg/EmbeddedPkg.dec > index 8ad2a84c045c..ccdf38e36a8c 100644 > --- a/EmbeddedPkg/EmbeddedPkg.dec > +++ b/EmbeddedPkg/EmbeddedPkg.dec > @@ -208,3 +208,10 @@ [PcdsFixedAtBuild.X64] > > [PcdsFixedAtBuild.common, PcdsDynamic.common] > gEmbeddedTokenSpaceGuid.PcdFdtDevicePaths|L""|VOID*|0x00000055 > + > + # > + # Value to add to a host address to obtain a device address, using > + # unsigned 64-bit integer arithmetic. This means we can rely on > + # truncation on overflow to specify negative offsets. Is that promotion-safe on 32-bit archs? / Leif > + # > + gEmbeddedTokenSpaceGuid.PcdDmaDeviceOffset|0x0|UINT64|0x0000058 > diff --git a/EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.c b/EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.c > index 4cbe349190a9..564db83c901c 100644 > --- a/EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.c > +++ b/EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.c > @@ -19,6 +19,14 @@ > #include > > > +STATIC > +PHYSICAL_ADDRESS > +HostToDeviceAddress ( > + IN VOID *Address > + ) > +{ > + return (PHYSICAL_ADDRESS)(UINTN)Address + PcdGet64 (PcdDmaDeviceOffset); > +} > > /** > Provides the DMA controller-specific addresses needed to access system memory. > @@ -50,7 +58,7 @@ DmaMap ( > OUT VOID **Mapping > ) > { > - *DeviceAddress = (PHYSICAL_ADDRESS)(UINTN)HostAddress; > + *DeviceAddress = HostToDeviceAddress (HostAddress); > *Mapping = NULL; > return EFI_SUCCESS; > } > diff --git a/EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.inf b/EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.inf > index c40a600cf6a3..f64d780e16ed 100644 > --- a/EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.inf > +++ b/EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.inf > @@ -31,3 +31,6 @@ [Packages] > [LibraryClasses] > DebugLib > MemoryAllocationLib > + > +[Pcd] > + gEmbeddedTokenSpaceGuid.PcdDmaDeviceOffset > -- > 2.11.0 >