Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755605Ab0D0NCI (ORCPT ); Tue, 27 Apr 2010 09:02:08 -0400 Received: from smtp.nokia.com ([192.100.122.230]:39793 "EHLO mgw-mx03.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755587Ab0D0NCB (ORCPT ); Tue, 27 Apr 2010 09:02:01 -0400 Subject: Re: [PATCH] Fix Oops with Atmel SPI From: Artem Bityutskiy Reply-To: dedekind1@gmail.com To: Anders Larsen Cc: linux-mtd@lists.infradead.org, Ian McDonnell , David Woodhouse , Matthias Kaehlcke , Nicolas Pitre , linux-kernel@vger.kernel.org In-Reply-To: <1271158315l.25331l.9l@i-dmzi_al.realan.de> References: <1271158315l.25331l.9l@i-dmzi_al.realan.de> Content-Type: text/plain; charset="UTF-8" Date: Tue, 27 Apr 2010 15:57:29 +0300 Message-ID: <1272373049.7750.4.camel@localhost> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 (2.28.3-1.fc12) Content-Transfer-Encoding: 8bit X-OriginalArrivalTime: 27 Apr 2010 13:01:43.0363 (UTC) FILETIME=[C8EE3930:01CAE609] X-Nokia-AV: Clean Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2178 Lines: 58 On Tue, 2010-04-13 at 13:31 +0200, Anders Larsen wrote: > Tweak MTD's cache allocation to make it work with the atmel DMA'ed SPI. > Substitute kmalloc for vmalloc so the cache buffer is mappable as per > the Atmel SPI driver's requirements, otherwise an Oops would occur. > > The original patch by Ian McDonnell was found here: > http://lists.infradead.org/pipermail/linux-mtd/2007-December/020184.html > > Signed-off-by: Anders Larsen > Cc: Ian McDonnell > Cc: David Woodhouse > Cc: Matthias Kaehlcke > Cc: Artem Bityutskiy > Cc: Nicolas Pitre > --- > drivers/mtd/mtdblock.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > Index: b/drivers/mtd/mtdblock.c > =================================================================== > --- a/drivers/mtd/mtdblock.c > +++ b/drivers/mtd/mtdblock.c > @@ -253,7 +253,11 @@ static int mtdblock_writesect(struct mtd > { > struct mtdblk_dev *mtdblk = mtdblks[dev->devnum]; > if (unlikely(!mtdblk->cache_data && mtdblk->cache_size)) { > +#ifdef CONFIG_SPI_ATMEL > + mtdblk->cache_data = kmalloc(mtdblk->mtd->erasesize, GFP_KERNEL); > +#else > mtdblk->cache_data = vmalloc(mtdblk->mtd->erasesize); > +#endif > if (!mtdblk->cache_data) > return -EINTR; > /* -EINTR is not really correct, but it is the best match > @@ -322,7 +326,11 @@ static int mtdblock_release(struct mtd_b > mtdblks[dev] = NULL; > if (mtdblk->mtd->sync) > mtdblk->mtd->sync(mtdblk->mtd); > +#ifdef CONFIG_SPI_ATMEL > + kfree(mtdblk->cache_data); > +#else > vfree(mtdblk->cache_data); > +#endif > kfree(mtdblk); > } This is an old problem. Instead of doing this dirty hack, change the code and teach it to work with array of 1-4 pages , not with buffers. -- Best Regards, Artem Bityutskiy (Артём Битюцкий) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/