Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751295AbdL2OMc (ORCPT ); Fri, 29 Dec 2017 09:12:32 -0500 Received: from mail-qt0-f196.google.com ([209.85.216.196]:36873 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750820AbdL2OM2 (ORCPT ); Fri, 29 Dec 2017 09:12:28 -0500 X-Google-Smtp-Source: ACJfBovbKDYHP2tEuLC+oXYEgrMRmyfC86fqPCDurJwWv062BWk2C1V0wjv4P1DNn2Sbjmn9z2J8WfxjjoUe379cy7w= MIME-Version: 1.0 In-Reply-To: <20171229081911.2802-28-hch@lst.de> References: <20171229081911.2802-1-hch@lst.de> <20171229081911.2802-28-hch@lst.de> From: Geert Uytterhoeven Date: Fri, 29 Dec 2017 15:12:25 +0100 X-Google-Sender-Auth: wcKVmMK08b2zo5wlCfuCt2n51Yw Message-ID: Subject: Re: [PATCH 27/67] dma-direct: add dma address sanity checks To: Christoph Hellwig Cc: iommu@lists.linux-foundation.org, Linux MIPS Mailing List , linux-ia64@vger.kernel.org, Linux-sh list , sparclinux , Guan Xuetao , Linux-Arch , linux-s390 , linux-c6x-dev@linux-c6x.org, "open list:QUALCOMM HEXAGON..." , "the arch/x86 maintainers" , arcml , adi-buildroot-devel@lists.sourceforge.net, linux-m68k , patches@groups.riscv.org, "open list:METAG ARCHITECTURE" , linux-arm-kernel@lists.infradead.org, Michal Simek , Parisc List , Cris , Linux Kernel Mailing List , alpha , linuxppc-dev@lists.ozlabs.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1403 Lines: 47 Hi Christoph, On Fri, Dec 29, 2017 at 9:18 AM, Christoph Hellwig wrote: > Roughly based on the x86 pci-nommu implementation. > > Signed-off-by: Christoph Hellwig Thanks for your patch! > --- a/lib/dma-direct.c > +++ b/lib/dma-direct.c > @@ -9,6 +9,24 @@ > #include > #include > > +#define DIRECT_MAPPING_ERROR 0 > + > +static bool > +check_addr(struct device *dev, dma_addr_t dma_addr, size_t size, > + const char *caller) > +{ > + if (unlikely(dev && !dma_capable(dev, dma_addr, size))) { > + if (*dev->dma_mask >= DMA_BIT_MASK(32)) { > + dev_err(dev, > + "%s: overflow %llx+%zu of device mask %llx\n", Please use "%pad" to format dma_addr_t ... > + caller, (long long)dma_addr, size, ... and use &dma_addr. > + (long long)*dev->dma_mask); This cast is not needed, as u64 is unsigned long long in kernelspace on all architectures. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds