From patchwork Mon Apr 11 15:18:27 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sven Krauss X-Patchwork-Id: 90609 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 0D18AB6EED for ; Tue, 12 Apr 2011 01:19:51 +1000 (EST) Received: from canuck.infradead.org ([2001:4978:20e::1]) by bombadil.infradead.org with esmtps (Exim 4.72 #1 (Red Hat Linux)) id 1Q9Iss-0000Zk-F9; Mon, 11 Apr 2011 15:18:34 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1Q9Isq-0006xM-Ct; Mon, 11 Apr 2011 15:18:32 +0000 Received: from fmmailgate05.web.de ([217.72.192.243]) by canuck.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1Q9Isn-0006x5-Oo for linux-mtd@lists.infradead.org; Mon, 11 Apr 2011 15:18:30 +0000 Received: from mwmweb014 ( [172.20.18.23]) by fmmailgate05.web.de (Postfix) with ESMTP id 6B8A765367A0 for ; Mon, 11 Apr 2011 17:18:27 +0200 (CEST) Received: from [213.173.165.130] by mwmweb014 with HTTP; Mon Apr 11 17:18:27 CEST 2011 Date: Mon, 11 Apr 2011 17:18:27 +0200 (CEST) From: "Sven Krauss" To: linux-mtd@lists.infradead.org Message-ID: <1631427694.1700754.1302535107434.JavaMail.fmail@mwmweb014> Subject: DMA misaligned error with device 4 MIME-Version: 1.0 X-Priority: 3 Importance: normal Sensitivity: Normal X-Provags-ID: V01U2FsdGVkX1+5kRsw/+4Qvp9SWQF4uxTlppz88yA+Jh9sz+aJxeK2xSrn4wCI5Ztr 30ia6RC5jVhj1/qgzXdTisKy6ECjJLFurMuatKnY//E= X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110411_111830_110171_37203E8C X-CRM114-Status: UNSURE ( 9.58 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is freemail (sven.krauss[at]web.de) -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, low trust [217.72.192.243 listed in list.dnswl.org] 0.0 T_TO_NO_BRKTS_FREEMAIL T_TO_NO_BRKTS_FREEMAIL 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 Hello! I am working on a TI-OMAP (OMAP3530 Kernel 2.6.33.7) board and with heavy load i got the following error.  DMA misaligned error with device 4 BUG: soft lockup - CPU#0 stuck for 61s! [jffs2_gcd_mtd4:419] Modules linked in:   Pid: 419, comm:       jffs2_gcd_mtd4 CPU: 0    Not tainted  (2.6.33.7 #1) PC is at omap_write_buf_dma_pref+0x184/0x230 LR is at omap_write_buf_dma_pref+0x178/0x230 pc : []    lr : []    psr: 20000013 sp : cfafdc30  ip : cfafdb80  fp : cf8d2010 r10: 00000800  r9 : 00000100  r8 : c711b5be r7 : 00000800  r6 : cf8d2000  r5 : 00000001  r4 : 00000000 r3 : fe000000  r2 : 00000001  r1 : cf8cb1c0  r0 : 00000800 Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment kernel Control: 10c5387d  Table: 8fb40019  DAC: 00000017 From this moment the cpu is dead. I went down to the kernel and found the following problem. I will start in jffs2_flash_writev() from fs/jffs2/wbuf.c. There is a for loop running through a vector invec. Inside the loop data is written to the write buffer (wbuf). If the buffer is full __jffs2_flush_wbuf will be called. If now an unaligned amount of data was written the next call c->mtd->write() inside the next condition will fail, because the pointer (v) is not aligned. This pointer is directly written to the dma. This results in the crash above. I suggest the following patch. For me this works fine. Thanks very much! --- linux-2.6.33.7.orig/drivers/mtd/nand/omap2.c 2010-08-02 19:27:18.000000000 +0200 +++ linux-2.6.33.7/drivers/mtd/nand/omap2.c 2011-04-11 17:11:53.000000000 +0200 @@ -503,9 +506,11 @@  {   if (len <= mtd->oobsize)   omap_write_buf_pref(mtd, buf, len); + else if (!IS_ALIGNED((unsigned long)buf, 4)) + omap_write_buf_pref(mtd, buf, len);   else   /* start transfer in DMA mode */ - omap_nand_dma_transfer(mtd, buf, len, 0x1); + omap_nand_dma_transfer(mtd, (void*)buf, len, 0x1);  }    /**