From: Marek Vasut Date: Tue, 7 May 2019 15:05:59 +0200 Subject: [U-Boot] [PATCH 2/3] bouncebuf: Add DMA validation check to addr_aligned(). In-Reply-To: <20190507090531.50670-2-christoph.muellner@theobroma-systems.com> References: <20190507090531.50670-1-christoph.muellner@theobroma-systems.com> <20190507090531.50670-2-christoph.muellner@theobroma-systems.com> Message-ID: <6722138c-bbb2-e9eb-4321-4be99b2aee10@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 5/7/19 11:05 AM, Christoph Muellner wrote: > Currently addr_aligned() performs an alignment and a length check > to validate the DMA address. However, some machines have stricter > restrictions of DMA-able addresses. > > This patch adds a call to mach_addr_is_dmaable() to honor this > machine specific restrictions. > > Signed-off-by: Christoph Muellner > --- > > common/bouncebuf.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/common/bouncebuf.c b/common/bouncebuf.c > index a7098e2caf..26ddf30ea2 100644 > --- a/common/bouncebuf.c > +++ b/common/bouncebuf.c > @@ -26,6 +26,12 @@ static int addr_aligned(struct bounce_buffer *state) > return 0; > } > > + /* Check if valid DMA address. */ > + if (!mach_addr_is_dmaable((ulong)state->user_buffer)) { Is the cast necessary ? > + debug("Buffer address is not DMA-able\n"); > + return 0; > + } > + > /* Aligned */ > return 1; > } > -- Best regards, Marek Vasut