From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com ([134.134.136.20]:12614 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726759AbeIRNap (ORCPT ); Tue, 18 Sep 2018 09:30:45 -0400 Subject: Re: [PATCH v2] mtd: devices: m25p80: Make sure the buffer passed in op is DMA-able To: Boris Brezillon , David Woodhouse , Brian Norris , Marek Vasut , Richard Weinberger , linux-mtd@lists.infradead.org Cc: stable@vger.kernel.org References: <20180917143130.23007-1-boris.brezillon@bootlin.com> From: Jarkko Nikula Message-ID: <8e5e8113-b091-6d3e-50d4-3e70e9372016@linux.intel.com> Date: Tue, 18 Sep 2018 10:59:17 +0300 MIME-Version: 1.0 In-Reply-To: <20180917143130.23007-1-boris.brezillon@bootlin.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: stable-owner@vger.kernel.org List-ID: On 09/17/2018 05:31 PM, Boris Brezillon wrote: > As documented in spi-mem.h, spi_mem_op->data.buf.{in,out} must be > DMA-able, and commit 4120f8d158ef ("mtd: spi-nor: Use the spi_mem_xx() > API") failed to follow this rule as buffers passed to > ->{read,write}_reg() are usually placed on the stack. > > Fix that by allocating a scratch buffer and copying the data around. > > Fixes: 4120f8d158ef ("mtd: spi-nor: Use the spi_mem_xx() API") > Reported-by: Jarkko Nikula > Cc: > Signed-off-by: Boris Brezillon > --- > Note that the ->{read,write}() path is still buggy since nothing > guarantees that buffers passed by the MTD layer to the SPI NOR layer > are DMA-able, but this is a long-standing issue which we'll have to > address at the spi-nor level (this layer can choose the bounce buffer > size based on nor->page_size). > > Changes in v2: > - Copy the data from scratchbuf in the ->read_reg() path > --- > drivers/mtd/devices/m25p80.c | 26 +++++++++++++++++++++++--- > 1 file changed, 23 insertions(+), 3 deletions(-) > Tested-by: Jarkko Nikula Reviewed-by: Jarkko Nikula