Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754568AbeAGUHJ convert rfc822-to-8bit (ORCPT + 1 other); Sun, 7 Jan 2018 15:07:09 -0500 Received: from mail.free-electrons.com ([62.4.15.54]:39432 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754356AbeAGUHH (ORCPT ); Sun, 7 Jan 2018 15:07:07 -0500 Date: Sun, 7 Jan 2018 21:07:03 +0100 From: Boris Brezillon To: Cyrille Pitchen Cc: Vignesh R , computersforpeace@gmail.com, dwmw2@infradead.org, richard@nod.at, marek.vasut@gmail.com, linux-mtd@lists.infradead.org, broonie@kernel.org, linux@armlinux.org.uk, linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, robh@kernel.org, devicetree@vger.kernel.org, nicolas.ferre@microchip.com, radu.pirea@microchip.com Subject: Re: [PATCH 1/3] mtd: spi-nor: add optional DMA-safe bounce buffer for data transfer Message-ID: <20180107210703.31fdf0a0@bbrezillon> In-Reply-To: References: <1126731d-cbf7-8fbf-34ab-8ccf1cc8241f@ti.com> X-Mailer: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Tue, 26 Dec 2017 14:59:00 +0100 Cyrille Pitchen wrote: > Hi Vignesh > > Le 26/12/2017 à 14:42, Vignesh R a écrit : > > Hi Cyrille, > > > > Thanks for doing this series! One comment below. > > > > On 24-Dec-17 10:06 AM, Cyrille Pitchen wrote: > > [...] > >> diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c > >> index 8bafd462f0ae..59f9fbd45234 100644 > >> --- a/drivers/mtd/spi-nor/spi-nor.c > >> +++ b/drivers/mtd/spi-nor/spi-nor.c > >> @@ -14,8 +14,10 @@ > >> #include > >> #include > >> #include > >> +#include > >> #include > >> #include > >> +#include > >> #include > >> #include > >> > >> @@ -1232,6 +1234,56 @@ static const struct flash_info spi_nor_ids[] = { > >> { }, > >> }; > >> > >> +static bool spi_nor_is_dma_safe(const void *buf) > >> +{ > >> + if (is_vmalloc_addr(buf)) > >> + return false; > >> + > >> +#ifdef CONFIG_HIGHMEM > >> + if ((unsigned long)buf >= PKMAP_BASE && > >> + (unsigned long)buf < (PKMAP_BASE + (LAST_PKMAP * PAGE_SIZE))) > >> + return false; > >> +#endif > >> + > >> + return true; > >> +} > >> + > > > > Better way would be to use virt_addr_valid(): > > static bool spi_nor_is_dma_safe(const void *buf) > > { > > return virt_addr_valid(buf); > > } > > > > Regards > > Vignesh > > > > Thanks for the advice :) > > https://patchwork.kernel.org/patch/9768341/ > Maybe I could check both virt_addr_valid() and object_is_on_stack() too ? Yep, see the explanation given here [1]. [1]http://elixir.free-electrons.com/linux/v4.15-rc6/source/Documentation/DMA-API-HOWTO.txt#L132