From patchwork Fri Oct 20 03:12:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 10018877 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0AC1960211 for ; Fri, 20 Oct 2017 03:16:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0287828E96 for ; Fri, 20 Oct 2017 03:16:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EB50C28E98; Fri, 20 Oct 2017 03:16:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E64728E97 for ; Fri, 20 Oct 2017 03:16:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751379AbdJTDQs (ORCPT ); Thu, 19 Oct 2017 23:16:48 -0400 Received: from relmlor2.renesas.com ([210.160.252.172]:36072 "EHLO relmlie1.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751125AbdJTDQr (ORCPT ); Thu, 19 Oct 2017 23:16:47 -0400 Received: from unknown (HELO relmlir4.idc.renesas.com) ([10.200.68.154]) by relmlie1.idc.renesas.com with ESMTP; 20 Oct 2017 12:16:46 +0900 Received: from relmlii1.idc.renesas.com (relmlii1.idc.renesas.com [10.200.68.65]) by relmlir4.idc.renesas.com (Postfix) with ESMTP id A8FA24E1D0; Fri, 20 Oct 2017 12:16:41 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.43,404,1503327600"; d="scan'208";a="259899041" Received: from mail-sg2apc01lp0247.outbound.protection.outlook.com (HELO APC01-SG2-obe.outbound.protection.outlook.com) ([65.55.88.247]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA256; 20 Oct 2017 12:16:41 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesasgroup.onmicrosoft.com; s=selector1-renesas-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=vf2HZVathyP9XVrCm60T+2FIgzVPzyyOpvbkWJCv+w8=; b=FpD56RFsBqZmQGyLFDhfu/RtuTZgaF2KbWnoipmjsZnBWqIEXJTY4ykBdKoQtOIgGhlGFKlc2BhsyjGrmdnPQ6R+/AuX6v17E8oDBpShfvOo4efoSaA9xuG6XwiBgCvNMxTcNQjYvWZLBHKL0GK9L3MFwaMAD9CfDq39M1+IfsM= Received: from localhost.localdomain (211.11.155.138) by SG2PR06MB0983.apcprd06.prod.outlook.com (2a01:111:e400:5213::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.156.4; Fri, 20 Oct 2017 03:16:39 +0000 From: Yoshihiro Shimoda To: wsa+renesas@sang-engineering.com, ulf.hansson@linaro.org Cc: linux-mmc@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Yoshihiro Shimoda Subject: [PATCH v2 2/2] mmc: renesas_sdhi: fix kernel panic in _internal_dmac.c Date: Fri, 20 Oct 2017 12:12:42 +0900 Message-Id: <1508469162-12322-3-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1508469162-12322-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> References: <1508469162-12322-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> MIME-Version: 1.0 X-Originating-IP: [211.11.155.138] X-ClientProxiedBy: KAXPR01CA0004.jpnprd01.prod.outlook.com (2603:1096:402:19::14) To SG2PR06MB0983.apcprd06.prod.outlook.com (2a01:111:e400:5213::25) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0b300dfa-024b-47c6-4acc-08d51768fae7 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(4534020)(4602075)(4627075)(201703031133081)(48565401081)(2017052603229); SRVR:SG2PR06MB0983; X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB0983; 3:ho79w0ggsy79B/g6FooPfDmkIEa8rzOXLamM9Dht57drOqOudPLgXP8gmZeMMQofHz+F7/8Y572imiHeQ8rWzTxn5zbLsnEFr4MuAJzJSjy1mGwJBvNGrQgIXG+icvWrus61Zu1z5jRsoskJ8uPBMIQub//DNqSZmF4X5WScSIeMDeF7nzRaliqSzKp/Rum8yxJtyvfvKCz4Hg28osAyGNjNmrarzDWTCea1bODcjXcMm1zqKSANg2H92RysSmva; 25:59w9/u19JSsnLWpVaMwxOR4ywKh501RckLp84zceXuBQTY/rgisfOz77PAJv95v0k6xG9XkdK3NhisXfizDM/bA7LtznbuZ6Agrv+5J+ezr+UK6kcuQbnzuz9ctv1EQm0xGGwhflY48R4mMbZjqhFrxGwAkmewtqFAfcp0pOXLUZwTIKnMukk3xQVRS8C2qoassEo2yZfaHbVqpygxdlarsbPaxjm5637oIXsvjp2vUkDW5XJaFVtMfE7mfTRw27OUELzDKKGxh6urGV2cxxUFsS7jFxSbFQhVrWbhNjqB6PJxDvRI/aGg+eLDcqgoM36qc51Oxbz7Rgs7NBuhLRww==; 31:yidqYFQw6QTyPzO9ESjQy7yD1XQqYaJs+eW5ebSWyVrpInvvdpQWdzdG83CDSiCwQhWLua7cqdlyU1x6RCyTjISm3XKQY6tuEpMsyv9SPk6dEYbUA1Zet6GwcCyC4UWlxiCZgZg1CmDCrm2opP8TcoGtEHa9L2Zh6aSCLllhSlfYdIJS81RVsXaslEQoN3hujJN157w58z4PC7wm2RqVaGFlEgQcGg422cTv1PX2fZM= X-MS-TrafficTypeDiagnostic: SG2PR06MB0983: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=<>; X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB0983; 20:jg8KZjzWg3smgaiGE/7czko7Fahm+4GH3ZBbDft+6v318ct0Ua5MWcOdtXt/QXLWjtHBFCyerF44Xeqsu1U5NW1uwXFAHbc0/zgSMg+yHMbe4HEa1dx69nhvGXoabOg3Yab2JyWPTN1XcGaPnEeVAypua/dRJtJUo0dZbJQCPFRDgfNot56PGLQSK5ZqSmOi8IHw0xy1NbjbxLMdwWfPqqAp2sXZd0ZAOmKssBdZfEANrgzSTD+jYvgYRuYY//B6aEt8X2ZAyIy4DLDi1kHRJSlY4PoL6eCrnx/rS4a1us720s3n0wZZz8JpHDmIJFJ9Njj/QcQlweuHkGo7Ebp4D6ZnPC7aVyPCQAqaIBnSuzZmI7np89hKcfREqt2nlDHlj7Ek8DvCyEnbAYZ2CWScuzHu/5ImJCSWAYR3GbapkefxrQhXsQl/Was3GWYJNHzlzTNzNK9sGddAoWh0aq1prfL6l8qHdorPwyWw8TNYg8VLc2bzptBRx1qFJuzqk1cO; 4:YccvMY7O0NV/JefkD9QopR7IeTCjXpGuTziS4DiH8qETGdOTc4/bIK7Afi/znU/sLtAzpunfSjjQ+HchMMB8QZNp2rdieWx02j0EDmJBir+mkPWYxI66RxTnB9pAhhm9I5lfHIPZZnCAhY3TpXgHLgyihXbQ4pyAs5E6W0l6LjQ5kKgQapquhJqNvwe/t0zBFqdfh1lSDU8vnhaSHFg4bjnN5DdJnYRhNtOd+ARiFmc8aUYGPAc80bWE1eraTO7b X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(100000703101)(100105400095)(3231020)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061750153)(20161123555025)(20161123558100)(20161123562025)(20161123560025)(20161123564025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SG2PR06MB0983; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SG2PR06MB0983; X-Forefront-PRVS: 0466CA5A45 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6069001)(6009001)(39860400002)(346002)(376002)(189002)(199003)(3846002)(50226002)(53936002)(6116002)(6666003)(78352004)(42882006)(2950100002)(106356001)(105586002)(5003940100001)(68736007)(498600001)(16526018)(107886003)(6512007)(97736004)(4326008)(189998001)(33646002)(48376002)(25786009)(66066001)(16586007)(76176999)(50986999)(36756003)(101416001)(316002)(5660300001)(81156014)(81166006)(6506006)(8676002)(6486002)(8936002)(50466002)(7736002)(305945005)(47776003)(2906002)(3720700003); DIR:OUT; SFP:1102; SCL:1; SRVR:SG2PR06MB0983; H:localhost.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; MX:0; A:0; LANG:en; Received-SPF: None (protection.outlook.com: localhost.localdomain does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SG2PR06MB0983; 23:Mm9R9V03vchFoT9UuPAG2vy02V0blJIxQwbL2xIXs?= =?us-ascii?Q?pM5eQQmpmYerM9Imyp6ByXRAu2jCO/pdvKeNQS8iCP2ji8+pAsyXjtM+VtYw?= =?us-ascii?Q?uMZ1Hq9DXsvjQhjVX2POfVTxvmyrfIepcCI57AHg48e6+nLoBG4uy4h8JpA1?= =?us-ascii?Q?KoJSq6HYos2OSnBTSnJ4Jflg2HL3DMAcPn7uToLXf1Okc2niM12J4SugMsxU?= =?us-ascii?Q?zO3+EHDwDmKbc1nG5pssKO0HwYp3yttneE/QzL+thWY/0pXcxiNcx5w0iSjy?= =?us-ascii?Q?ObCOhIqyPusXhtC+8DrIP7y79wpku7/MIp48F5wGA8iuLa0LF6oukfosen9O?= =?us-ascii?Q?fthqETBLQ2wJsKG919HPwwAWYkakl4LcLY77YK13QhsyJvpZ++2wtaf4vpLk?= =?us-ascii?Q?/M0lIO6Z49jITDAKf8ehj9EhhycrMh0/ouQj6QXNlfgPzuHRAElCHCSB1E+5?= =?us-ascii?Q?EQe7LP07+ykOBPmtvdfn3BItnuKPMjLk0UCalcpLUx+kECa+mQvGi0z4zvTl?= =?us-ascii?Q?6dwdh5fIo5u9Myn9u7zNho4F8lma+OFfZlf9GDXG10bXNDReZRQ6og6spH/J?= =?us-ascii?Q?7OgG4ji7xeuwjBR6+j+CBAmK0wHBZpi1ebf3UO+CKxeucUyAjJL9JwLV8/Vd?= =?us-ascii?Q?wJTUtLTbabWRPPxTOzVnxPJMeOfFxPv9W2rA8MFhVwqtdZOQZdUMFlOUCY/1?= =?us-ascii?Q?zofksd7cQP/JwxLy/B25vjXMW3wiX4HlNAjXw3l2FHMbOy0XJB/K3VkGp11Z?= =?us-ascii?Q?zYX7KWhBmYFIr+UUljXHybHWkya+DarfUX1cZnFf76cdzRe8vAWIfZnn38iL?= =?us-ascii?Q?R2rfqXkXlfTuxCITn60DS6UBC9SiR6ObsF1nKHDwIcjE3letFguGgVQoZYXp?= =?us-ascii?Q?XJFIcBlvn/T9n5GBjyIssR6P3t1eU+diUYeElge79IN4CSX7k4RLtQBt5qcd?= =?us-ascii?Q?jr1Y/CdNv4yMHQPD31R66CYqp7Ihka9sJZuZRSjVH8A3S1M0fKn5n8nbqatC?= =?us-ascii?Q?HOoEihelJjuQVfnddndJPqp6gNjvaqafxx38XQ8ZQfXh47gWLXB9WInRhbPe?= =?us-ascii?Q?4o1ymtPKM82nGVeVGE9LOcFwuNFG06Q9+LR4j0rSuy4So7Um4N1Kxc4xRxmY?= =?us-ascii?Q?0UZY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t/y+pU6OJ24rY84MkUoPu143EZrOPfU66amuRNNjlF7wgz7TxMycKny/AtpRjk5GbaJgJfkK/hpSLbjYVVblbSZqe6DYUc6q9DyXAPGH2D9dI6tLcXtA7B7+EU= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2017 03:16:39.0667 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0b300dfa-024b-47c6-4acc-08d51768fae7 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR06MB0983 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since this driver checks if the return value of dma_map_sg() is minus or not and keeps to enable the DMAC, it may cause kernel panic when the dma_map_sg() returns 0. So, this patch fixes the issue. Reported-by: Dirk Behme Fixes: 2a68ea7896e3 ("mmc: renesas-sdhi: add support for R-Car Gen3 SDHI DMAC") Signed-off-by: Yoshihiro Shimoda Reviewed-by: Geert Uytterhoeven Acked-by: Wolfram Sang --- drivers/mmc/host/renesas_sdhi_internal_dmac.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/mmc/host/renesas_sdhi_internal_dmac.c b/drivers/mmc/host/renesas_sdhi_internal_dmac.c index f905f23..8bae88a 100644 --- a/drivers/mmc/host/renesas_sdhi_internal_dmac.c +++ b/drivers/mmc/host/renesas_sdhi_internal_dmac.c @@ -146,11 +146,8 @@ WARN_ON(host->sg_len > 1); /* This DMAC cannot handle if buffer is not 8-bytes alignment */ - if (!IS_ALIGNED(sg->offset, 8)) { - host->force_pio = true; - renesas_sdhi_internal_dmac_enable_dma(host, false); - return; - } + if (!IS_ALIGNED(sg->offset, 8)) + goto force_pio; if (data->flags & MMC_DATA_READ) { dtran_mode |= DTRAN_MODE_CH_NUM_CH1; @@ -163,8 +160,8 @@ } ret = dma_map_sg(&host->pdev->dev, sg, host->sg_len, dir); - if (ret < 0) - return; + if (ret == 0) + goto force_pio; renesas_sdhi_internal_dmac_enable_dma(host, true); @@ -176,6 +173,12 @@ dtran_mode); renesas_sdhi_internal_dmac_dm_write(host, DM_DTRAN_ADDR, sg->dma_address); + + return; + +force_pio: + host->force_pio = true; + renesas_sdhi_internal_dmac_enable_dma(host, false); } static void renesas_sdhi_internal_dmac_issue_tasklet_fn(unsigned long arg)