From patchwork Wed Aug 21 13:50:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seungwon Jeon X-Patchwork-Id: 2847753 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 B1511BF546 for ; Wed, 21 Aug 2013 13:51:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 79D5E204CD for ; Wed, 21 Aug 2013 13:51:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1A4B420490 for ; Wed, 21 Aug 2013 13:51:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752088Ab3HUNvL (ORCPT ); Wed, 21 Aug 2013 09:51:11 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:12620 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751957Ab3HUNu6 (ORCPT ); Wed, 21 Aug 2013 09:50:58 -0400 Received: from epcpsbgr5.samsung.com (u145.gpu120.samsung.co.kr [203.254.230.145]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MRV009LWVSWTOC0@mailout4.samsung.com> for linux-mmc@vger.kernel.org; Wed, 21 Aug 2013 22:50:57 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [203.254.230.50]) by epcpsbgr5.samsung.com (EPCPMTA) with SMTP id 40.1B.11618.1C5C4125; Wed, 21 Aug 2013 22:50:57 +0900 (KST) X-AuditID: cbfee691-b7fef6d000002d62-de-5214c5c179a6 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 70.3B.32250.1C5C4125; Wed, 21 Aug 2013 22:50:57 +0900 (KST) Received: from DOTGIHJUN01 ([12.23.118.161]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MRV000ZRVSWY940@mmp2.samsung.com>; Wed, 21 Aug 2013 22:50:57 +0900 (KST) From: Seungwon Jeon To: linux-mmc@vger.kernel.org Cc: 'Chris Ball' , 'Jaehoon Chung' , 'Alim Akhtar' References: In-reply-to: Subject: [PATCH 09/14] mmc: dw_mmc: fix error handling on response error Date: Wed, 21 Aug 2013 22:50:56 +0900 Message-id: <002e01ce9e75$762a29c0$627e7d40$%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: Ac03z3aCvVFr8FaITt2vKVQKst76fw3OcIrwS9fJ1BA= Content-language: ko X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrGIsWRmVeSWpSXmKPExsVy+t8zI92DR0WCDJ71Clo8mLeNzWL7641s Fjd+tbFaHPnfz+jA4nHoylpGj74tqxg9Pm+SC2CO4rJJSc3JLEst0rdL4MqYtn8HS8EJyYqf x98wNTD2i3YxcnJICJhItE29wQ5hi0lcuLeerYuRi0NIYBmjxMm1Zxhhihqmf2WHSExnlJjV sgzK+cMocWjuTbB2NgEtib9v3jCD2CICshI//1xgA7GZBcok3t65DxTnAGrglljdHAQS5hTg kVj3pxOsXFjAQ2LpsUdg5SwCqhIfTp4As3kFbCVmd19lhrAFJX5MvscCMoZZQF1iypRciOny EpvXvAWbLgEUfvRXF+IAK4nDy4+wQpSISOx78Y4R5GIJgUPsEmc2/maBWCUg8W3yIRaIXlmJ TQeYId6VlDi44gbLBKBHkSyehbB4FpLFs5BsWMDIsopRNLUguaA4Kb3IVK84Mbe4NC9dLzk/ dxMjJA4n7mC8f8D6EGMy0PaJzFKiyfnAOM4riTc0N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y5lPJ7xysdKXVnHO7SpUWNQy5xlfRZGw4TTP10XSidu22e9443D7vumu tdX/ki3sA8yVWIozEg21mIuKEwEQ05PPNgMAAA== 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.7 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 --- 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 486024c..9c3205e 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -1140,11 +1140,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; - } } } @@ -1185,6 +1180,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; @@ -1279,7 +1285,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;