public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ard Biesheuvel" <ard.biesheuvel@linaro.org>
To: Leif Lindholm <leif.lindholm@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 14:13:19 +0100	[thread overview]
Message-ID: <CAKv+Gu81sTucPqGSquQkv-iQi9-50OTaHLhid1u3Zxj=HbYWCg@mail.gmail.com> (raw)
In-Reply-To: <20191125125828.GQ7359@bivouac.eciton.net>

On Mon, 25 Nov 2019 at 13:58, Leif Lindholm <leif.lindholm@linaro.org> wrote:
>
> 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?
>

How? Using DEBUG()? That would be dead code as well, since it is only
active in DEBUG builds, which means the ASSERT() would fire first and
prevent the DEBUG() from ever being reached.

So that leaves printing to the console using boot services, which is
not something we should be doing from a DXE_DRIVER type module.

Given that these are both platform specific values defined at platform
creation time, I think policing them only in a DEBUG build is quite
appropriate, tbh.

  reply	other threads:[~2019-11-25 13:13 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
2019-11-25 13:13         ` Ard Biesheuvel [this message]
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='CAKv+Gu81sTucPqGSquQkv-iQi9-50OTaHLhid1u3Zxj=HbYWCg@mail.gmail.com' \
    --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