From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by mx.groups.io with SMTP id smtpd.web10.3592.1574686711845158922 for ; Mon, 25 Nov 2019 04:58:32 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=QxSv7DK3; spf=pass (domain: linaro.org, ip: 209.85.221.68, mailfrom: leif.lindholm@linaro.org) Received: by mail-wr1-f68.google.com with SMTP id s5so17900548wrw.2 for ; Mon, 25 Nov 2019 04:58:31 -0800 (PST) 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=WyoB3tGfZ6EH4ZiwrvK/ub8Our9Fv0bof+/RBAyltC8=; b=QxSv7DK3LzFIxQNryPjccsjEssQppIotDL9ezlrulxJKX9LxNevWbnJNx6vmR0kVQ4 F3WiO6z7/XXdjlb0JtYw/a3f8wEgSFEHc1HQoAZebXfxNNQPCPm8vHYRNvblHOINNnmz 9x8eNM7WdY7couIgXDj7c5g7SVwC3NZs/RhYWIrDOlQHXkrIqbeSG9Xz1rT6jjiWTks2 kXYlwUOE1V0jijoDN4AmJ94E83kB0ovIyAU3dAuxUOLRbiZe7aa6nEO3NE80xTcB+v7W AptHzjLnEgOoa3Qs1hxjH5QDy4wHlwXh2is+YZ5H6XiUgaeYlwjdh2hIuvaadkqoIpXD +xoQ== 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=WyoB3tGfZ6EH4ZiwrvK/ub8Our9Fv0bof+/RBAyltC8=; b=e2YkPMhl8fyypfz82Bhx97P51c1+ivKvL/ru2K/nW4lEQUBBaWsxFO5yUYS/nyzMO+ dikQRZHbh3godrBEE6MYl/vcfkQn1d2dbQgtwpCjHKP5CvX7g30FvlAFKH6vPHkl6E5q +FZp6jO7ScN3rzR428Vt+mQHPZxC2RDeiemre+wVVJEw8yeUm7wa82A8sQyYoQloquBt D03umn3apULS/Kf2GDm7tC1u0VITfVNGDEKefZzRbgmZBQo4R/zvI4IIJFiFeblmTVGc jICoZkfTapfgwl7L+zrGBW6reTDCzhLekSV8i1hn0yg1GoozZb8Y3AtMzpX7TkrHTlA+ P9Uw== X-Gm-Message-State: APjAAAXRgGls8EnbCTwiU4b+z9MYgQ51H4HcR+MRHjxOJDgdb34XLRzz AURN/SF0ZtB6POSJtSsBqtOFZw== X-Google-Smtp-Source: APXvYqwXZ95IC+ox5PGAnRKktbiCBBisXj5I8VSfdMnKHySLsfQrQld41UXL3wdoqfWTfU4EyJ8Ftw== X-Received: by 2002:adf:df0e:: with SMTP id y14mr29224250wrl.377.1574686710321; Mon, 25 Nov 2019 04:58:30 -0800 (PST) Return-Path: Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id 5sm8082363wmk.48.2019.11.25.04.58.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Nov 2019 04:58:29 -0800 (PST) Date: Mon, 25 Nov 2019 12:58:28 +0000 From: "Leif Lindholm" To: Ard Biesheuvel Cc: edk2-devel-groups-io Subject: Re: [PATCH 1/2] EmbeddedPkg/NonCoherentDmaLib: implement support for DMA range limits Message-ID: <20191125125828.GQ7359@bivouac.eciton.net> References: <20191121083227.2850-1-ard.biesheuvel@linaro.org> <20191121083227.2850-2-ard.biesheuvel@linaro.org> <20191125124606.GO7359@bivouac.eciton.net> MIME-Version: 1.0 In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 > > >