Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751104AbdLZN7F (ORCPT ); Tue, 26 Dec 2017 08:59:05 -0500 Received: from smtp3-g21.free.fr ([212.27.42.3]:27042 "EHLO smtp3-g21.free.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750737AbdLZN7E (ORCPT ); Tue, 26 Dec 2017 08:59:04 -0500 Subject: Re: [PATCH 1/3] mtd: spi-nor: add optional DMA-safe bounce buffer for data transfer To: Vignesh R , computersforpeace@gmail.com, dwmw2@infradead.org, richard@nod.at, boris.brezillon@free-electrons.com, marek.vasut@gmail.com, linux-mtd@lists.infradead.org, broonie@kernel.org, linux@armlinux.org.uk Cc: 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 References: <1126731d-cbf7-8fbf-34ab-8ccf1cc8241f@ti.com> From: Cyrille Pitchen Message-ID: Date: Tue, 26 Dec 2017 14:59:00 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <1126731d-cbf7-8fbf-34ab-8ccf1cc8241f@ti.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1429 Lines: 61 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 ? Best regards, Cyrille