public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Leif Lindholm <leif.lindholm@linaro.org>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: edk2-devel@lists.01.org
Subject: Re: [PATCH 2/6] EmbeddedPkg/CoherentDmaLib: add support for non-1:1 DMA translation
Date: Wed, 30 Aug 2017 11:51:40 +0100	[thread overview]
Message-ID: <20170830105140.5gglqu3ftedfbu2y@bivouac.eciton.net> (raw)
In-Reply-To: <20170830082108.7470-3-ard.biesheuvel@linaro.org>

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 <ard.biesheuvel@linaro.org>
> ---
>  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 <Library/MemoryAllocationLib.h>
>  
>  
> +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
> 


  reply	other threads:[~2017-08-30 10:49 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-30  8:21 [PATCH 0/6] ArmPkg EmbeddedPkg: clean up DmaLib implementations Ard Biesheuvel
2017-08-30  8:21 ` [PATCH 1/6] EmbeddedPkg: rename NullDmaLib to CoherentDmaLib Ard Biesheuvel
2017-08-30 10:46   ` Leif Lindholm
2017-08-30 10:52     ` Ard Biesheuvel
2017-08-30 11:37       ` Leif Lindholm
2017-08-30  8:21 ` [PATCH 2/6] EmbeddedPkg/CoherentDmaLib: add support for non-1:1 DMA translation Ard Biesheuvel
2017-08-30 10:51   ` Leif Lindholm [this message]
2017-08-30 10:54     ` Ard Biesheuvel
2017-08-30 11:47       ` Leif Lindholm
2017-08-30  8:21 ` [PATCH 3/6] EmbeddedPkg: implement NonCoherentDmaLib based on ArmDmaLib Ard Biesheuvel
2017-08-30 13:05   ` Leif Lindholm
2017-08-30  8:21 ` [PATCH 4/6] Omap35xxPkg: switch to EmbeddedPkg's NonCoherentDmaLib Ard Biesheuvel
2017-08-30  8:21 ` [PATCH 5/6] BeagleBoardPkg: switch to generic non-coherent DmaLib Ard Biesheuvel
2017-08-30  8:21 ` [PATCH 6/6] ArmPkg: remove ArmDmaLib Ard Biesheuvel
2017-08-30 13:06 ` [PATCH 0/6] ArmPkg EmbeddedPkg: clean up DmaLib implementations Leif Lindholm
2017-08-30 13:17   ` Ard Biesheuvel
2017-09-01 12:01     ` Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170830105140.5gglqu3ftedfbu2y@bivouac.eciton.net \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox