Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751130AbdLZNnV (ORCPT ); Tue, 26 Dec 2017 08:43:21 -0500 Received: from fllnx210.ext.ti.com ([198.47.19.17]:10753 "EHLO fllnx210.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750876AbdLZNnT (ORCPT ); Tue, 26 Dec 2017 08:43:19 -0500 Subject: Re: [PATCH 1/3] mtd: spi-nor: add optional DMA-safe bounce buffer for data transfer To: Cyrille Pitchen , , , , , , , , CC: , , , , , References: From: Vignesh R Message-ID: <1126731d-cbf7-8fbf-34ab-8ccf1cc8241f@ti.com> Date: Tue, 26 Dec 2017 19:12:09 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1136 Lines: 48 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