From patchwork Tue Apr 13 11:31:55 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anders Larsen X-Patchwork-Id: 50062 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id DF282B7CF3 for ; Tue, 13 Apr 2010 21:34:05 +1000 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1O1eLi-000443-ON; Tue, 13 Apr 2010 11:32:10 +0000 Received: from de01.mail.all-tld.net ([195.140.232.8]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1O1eLf-00043Y-RD for linux-mtd@lists.infradead.org; Tue, 13 Apr 2010 11:32:08 +0000 Received: from mail.alarsen.net (dslb-092-075-214-074.pools.arcor-ip.net [92.75.214.74]) by de01.mail.all-tld.net (Postfix) with ESMTP id 343504CF10E; Tue, 13 Apr 2010 13:32:04 +0200 (CEST) Received: from i-dmzi_al.realan.de ([192.168.96.15]) by mail.alarsen.net (8.13.3/8.13.3/AL/2007-04-18) with ESMTP id o3DBVtm5032323; Tue, 13 Apr 2010 13:32:01 +0200 Date: Tue, 13 Apr 2010 13:31:55 +0200 From: Anders Larsen Subject: [PATCH] Fix Oops with Atmel SPI To: linux-mtd@lists.infradead.org X-Mailer: Balsa 2.3.14 Message-Id: <1271158315l.25331l.9l@i-dmzi_al.realan.de> MIME-Version: 1.0 Content-Disposition: inline X-Scanned-By: MIMEDefang 2.61 on 192.168.96.254 X-ALL-TLD-GmbH-Information: AEV Virus and Spam Secure Mail System X-ALL-TLD-GmbH-VirusScanner: Found to be clean X-ALL-TLD-GmbH-SpamCheck: X-MailScanner-From: al@alarsen.net X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20100413_073208_025963_CFF1DB7A X-CRM114-Status: UNSURE ( 5.59 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.3.1 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- Cc: Artem Bityutskiy , Ian McDonnell , Nicolas Pitre , linux-kernel@vger.kernel.org, Matthias Kaehlcke , David Woodhouse X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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); }