From patchwork Fri Aug 30 15:13:59 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seungwon Jeon X-Patchwork-Id: 2852123 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 116D1C0AB5 for ; Fri, 30 Aug 2013 15:14:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5779B2018D for ; Fri, 30 Aug 2013 15:14:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 19E7720182 for ; Fri, 30 Aug 2013 15:14:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756567Ab3H3POD (ORCPT ); Fri, 30 Aug 2013 11:14:03 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:47295 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756321Ab3H3POB (ORCPT ); Fri, 30 Aug 2013 11:14:01 -0400 Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MSC00GDENNBHW40@mailout1.samsung.com> for linux-mmc@vger.kernel.org; Sat, 31 Aug 2013 00:13:59 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [203.254.230.50]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id 71.17.22755.7B6B0225; Sat, 31 Aug 2013 00:13:59 +0900 (KST) X-AuditID: cbfee68f-b7f656d0000058e3-3a-5220b6b7e99f Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 09.0C.05832.7B6B0225; Sat, 31 Aug 2013 00:13:59 +0900 (KST) Received: from DOTGIHJUN01 ([12.23.118.161]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MSC001ECNNBYA10@mmp1.samsung.com>; Sat, 31 Aug 2013 00:13:59 +0900 (KST) From: Seungwon Jeon To: linux-mmc@vger.kernel.org Cc: 'Chris Ball' , 'Jaehoon Chung' References: In-reply-to: Subject: [PATCH 17/22] mmc: dw_mmc: fix error handling on response error Date: Sat, 31 Aug 2013 00:13:59 +0900 Message-id: <001401cea593$8d6ed6b0$a84c8410$%jun@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-transfer-encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-index: Ac03z3aCvVFr8FaITt2vKVQKst76fw3OcIrwS9fJ1BAByUIdcA== Content-language: ko X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrAIsWRmVeSWpSXmKPExsVy+t8zI93t2xSCDK7ulLHY/nojm8WNX22s Fkf+9zM6MHscurKW0aNvyypGj8+b5AKYo7hsUlJzMstSi/TtErgyFr5/zl7wR7Ji2rVJTA2M +0S7GDk5JARMJF48XMwIYYtJXLi3nq2LkYtDSGAZo8TET72MMEWTb31mgUgsYpSYeecRM4Tz h1Hi6pVXLCBVbAJaEn/fvGEGsUUEZCV+/rnABmIzC3hLvJq/BmgSB1ADt8Tq5iCQMKcAj8S6 P51g5cICHhJb9y5gArFZBFQldq2aywRSzitgK3FuDwdImFdAUOLH5HssIGFmAXWJKVNyIYbL S2xe85YZJCwBFH70Vxdiv5PE2aaDjBAlIhL7XrxjBDlYQuAQu0RPz0+oTQIS3yYfYoHolZXY dIAZ4ltJiYMrbrBMYJSYhWTxLITFs5AsnoVkwwJGllWMoqkFyQXFSelFxnrFibnFpXnpesn5 uZsYIbHXv4Px7gHrQ4zJQNsnMkuJJucDYzevJN7Q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MaFKzt8maIq23ptdrRtbcGaLWodurcey+8msXv893xRpNGi9WBgZLWj4Te+LtJzKlHduvy43 id4S9vCwS1RiKc5INNRiLipOBABgUQjYMAMAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Even if response error is detected in case data command, data transfer is continued. It means that data can live in FIFO. Current handling just breaks out the request when seeing the command error. This causes kernel panic in dw_mci_read_data_pio() [host->data = NULL]. And also, FIFO should be guaranteed to be empty. Unable to handle kernel NULL pointer dereference at virtual address 00000018 <...> [] (dw_mci_read_data_pio+0x68/0x198) from [] (dw_mci_interrupt+0x374/0x3a0) [] (dw_mci_interrupt+0x374/0x3a0) from [] (handle_irq_event_percpu+0x50/0x194) [] (handle_irq_event_percpu+0x50/0x194) from [] (handle_irq_event+0x3c/0x5c) [] (handle_irq_event+0x3c/0x5c) from [] (handle_fasteoi_irq+0xa4/0x148) [] (handle_fasteoi_irq+0xa4/0x148) from [] (generic_handle_irq+0x20/0x30) [] (generic_handle_irq+0x20/0x30) from [] (handle_IRQ+0x38/0x90) [] (handle_IRQ+0x38/0x90) from [] (gic_handle_irq+0x34/0x68) [] (gic_handle_irq+0x34/0x68) from [] (__irq_svc+0x40/0x70) Exception stack(0xef0b1c00 to 0xef0b1c48) 1c00: 000eb0cf ffffffff 00001300 c01a7738 ef295e10 0000000a c04df298 ef0b1dc0 1c20: ef295ec0 00000000 00000000 00000006 00000000 ef0b1c48 c02b1274 c01a7764 1c40: 20000113 ffffffff [] (__irq_svc+0x40/0x70) from [] (__loop_delay+0x0/0xc) Code: e1a00005 e0891006 e0662004 e12fff33 (e59a3018) ---[ end trace a7043b9ba9aed1db ]--- Kernel panic - not syncing: Fatal exception in interrupt Signed-off-by: Seungwon Jeon Tested-by: Alim Akhtar --- drivers/mmc/host/dw_mmc.c | 26 +++++++++++++++++++++----- 1 files changed, 21 insertions(+), 5 deletions(-) diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index 23c4c3c..abe4d21 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -1148,11 +1148,6 @@ static void dw_mci_command_complete(struct dw_mci *host, struct mmc_command *cmd /* newer ip versions need a delay between retries */ if (host->quirks & DW_MCI_QUIRK_RETRY_DELAY) mdelay(20); - - if (cmd->data) { - dw_mci_stop_dma(host); - host->data = NULL; - } } } @@ -1193,6 +1188,17 @@ static void dw_mci_tasklet_func(unsigned long priv) goto unlock; } + if (cmd->data && cmd->error) { + dw_mci_stop_dma(host); + if (data->stop) { + send_stop_cmd(host, data); + state = STATE_SENDING_STOP; + break; + } else { + host->data = NULL; + } + } + if (!host->mrq->data || cmd->error) { dw_mci_request_end(host, host->mrq); goto unlock; @@ -1287,7 +1293,17 @@ static void dw_mci_tasklet_func(unsigned long priv) &host->pending_events)) break; + /* CMD error in data command */ + if (host->mrq->cmd->error && host->mrq->data) { + sg_miter_stop(&host->sg_miter); + host->sg = NULL; + ctrl = mci_readl(host, CTRL); + ctrl |= SDMMC_CTRL_FIFO_RESET; + mci_writel(host, CTRL, ctrl); + } + host->cmd = NULL; + host->data = NULL; dw_mci_command_complete(host, host->mrq->stop); dw_mci_request_end(host, host->mrq); goto unlock;