From mboxrd@z Thu Jan 1 00:00:00 1970 From: Boris Brezillon Subject: Re: [PATCH 1/3] mtd: spi-nor: add optional DMA-safe bounce buffer for data transfer Date: Sun, 7 Jan 2018 21:07:03 +0100 Message-ID: <20180107210703.31fdf0a0@bbrezillon> References: <1126731d-cbf7-8fbf-34ab-8ccf1cc8241f@ti.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Return-path: In-Reply-To: Sender: linux-spi-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Cyrille Pitchen Cc: Vignesh R , computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org, richard-/L3Ra7n9ekc@public.gmane.org, marek.vasut-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, linux-I+IVW8TIWO2tmTQ+vhA3Yw@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, nicolas.ferre-UWL1GkI3JZL3oGB3hsPCZA@public.gmane.org, radu.pirea-UWL1GkI3JZL3oGB3hsPCZA@public.gmane.org List-Id: devicetree@vger.kernel.org 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 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html