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-groups-io <devel@edk2.groups.io>
Subject: Re: [PATCH 1/2] EmbeddedPkg/NonCoherentDmaLib: implement support for DMA range limits
Date: Mon, 25 Nov 2019 12:58:28 +0000	[thread overview]
Message-ID: <20191125125828.GQ7359@bivouac.eciton.net> (raw)
In-Reply-To: <CAKv+Gu-1zYsboH61y=VcrXo0+31616BrXCPcshpsjZSJyXOWbw@mail.gmail.com>

On Mon, Nov 25, 2019 at 13:52:24 +0100, Ard Biesheuvel wrote:
> > > -  if (MemoryType == EfiBootServicesData) {
> > > -    Allocation = AllocateAlignedPages (Pages, Alignment);
> > > -  } else if (MemoryType == EfiRuntimeServicesData) {
> > > -    Allocation = AllocateAlignedRuntimePages (Pages, Alignment);
> > > +  if (MemoryType == EfiBootServicesData ||
> > > +      MemoryType == EfiRuntimeServicesData) {
> > > +    Allocation = InternalAllocateAlignedPages (MemoryType, Pages, Alignment);
> > >    } else {
> > >      return EFI_INVALID_PARAMETER;
> > >    }
> > > @@ -479,6 +596,15 @@ NonCoherentDmaLibConstructor (
> > >  {
> > >    InitializeListHead (&UncachedAllocationList);
> > >
> > > +  //
> > > +  // Ensure that the combination of DMA addressing offset and limit produces
> > > +  // a sane value.
> > > +  //
> > > +  ASSERT (PcdGet64 (PcdDmaDeviceLimit) > PcdGet64 (PcdDmaDeviceOffset));
> >
> > Is this worth turning into a hard conditional and error return rather
> > than an assert? The following statement will end up wrapping downwards
> > if this condition is not true.
>
> 
> Constructor return values are only used in ASSERT_EFI_ERROR() calls in
> the ProcessLibraryConstructorList() routine that gets generated by the
> build tools (in AutoGen.c), so returning an error here would
> essentially be dead code, given that we would only make it to this
> point on builds that are known to ignore it.

Hmm, ack.
Print error message?

/
    Leif

> > > +
> > > +  mDmaHostAddressLimit = PcdGet64 (PcdDmaDeviceLimit) -
> > > +                         PcdGet64 (PcdDmaDeviceOffset);
> > > +
> >
> > /
> >     Leif
> >
> > >    // Get the Cpu protocol for later use
> > >    return gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID **)&mCpu);
> > >  }
> > > diff --git a/EmbeddedPkg/Library/NonCoherentDmaLib/NonCoherentDmaLib.inf b/EmbeddedPkg/Library/NonCoherentDmaLib/NonCoherentDmaLib.inf
> > > index 2db751afee91..1a21cfe4ff23 100644
> > > --- a/EmbeddedPkg/Library/NonCoherentDmaLib/NonCoherentDmaLib.inf
> > > +++ b/EmbeddedPkg/Library/NonCoherentDmaLib/NonCoherentDmaLib.inf
> > > @@ -38,6 +38,7 @@ [Protocols]
> > >
> > >  [Pcd]
> > >    gEmbeddedTokenSpaceGuid.PcdDmaDeviceOffset
> > > +  gEmbeddedTokenSpaceGuid.PcdDmaDeviceLimit
> > >
> > >  [Depex]
> > >    gEfiCpuArchProtocolGuid
> > > --
> > > 2.17.1
> > >

  reply	other threads:[~2019-11-25 12:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-21  8:32 [PATCH 0/2] EmbeddedPkg: support for RPi4 PCI and platform DMA Ard Biesheuvel
2019-11-21  8:32 ` [PATCH 1/2] EmbeddedPkg/NonCoherentDmaLib: implement support for DMA range limits Ard Biesheuvel
2019-11-25 12:46   ` Leif Lindholm
2019-11-25 12:52     ` Ard Biesheuvel
2019-11-25 12:58       ` Leif Lindholm [this message]
2019-11-25 13:13         ` Ard Biesheuvel
2019-11-25 14:38           ` Leif Lindholm
2019-11-21  8:32 ` [PATCH 2/2] EmbeddedPkg: implement EDK2 IoMmu protocol wrapping DmaLib Ard Biesheuvel
2019-11-25 12:49   ` Leif Lindholm
2019-11-25 12:53     ` 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=20191125125828.GQ7359@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