From patchwork Tue Jun 12 10:55:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 10459991 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 E25B3601A0 for ; Tue, 12 Jun 2018 10:55:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE2D628699 for ; Tue, 12 Jun 2018 10:55:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C2D34286BD; Tue, 12 Jun 2018 10:55:54 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, 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 5508C28699 for ; Tue, 12 Jun 2018 10:55:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933249AbeFLKzv (ORCPT ); Tue, 12 Jun 2018 06:55:51 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:53631 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933135AbeFLKzs (ORCPT ); Tue, 12 Jun 2018 06:55:48 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20180612105546euoutp01dc60d0eebc538d2512105ef88a8a657b~3ZFxgvweg1725817258euoutp01L; Tue, 12 Jun 2018 10:55:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20180612105546euoutp01dc60d0eebc538d2512105ef88a8a657b~3ZFxgvweg1725817258euoutp01L DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1528800946; bh=dJU9sGjeMDd5GQ13khqIkoLMmudKdfua5SrdxDGqYzI=; h=From:To:Cc:Subject:Date:References:From; b=V67oRQ+Xg5d4HNcEnd6AKsmQYmEefHMnjowfEFp2hHduWkxbAoC0p3ADi4j85WNoc DgcRAmawAb5bHGP8Vy6ZZ+btYjjyMudoSrE0D1q1mvX/pYP1PcKuEzHF0Y5qmyoJTH /jJH7ANjGQllZcriyEWFgT10sC2jRJQjf7IlvzK4= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180612105544eucas1p167aa0450d740a130b3ec34eebd613860~3ZFv6KOVC1137011370eucas1p1a; Tue, 12 Jun 2018 10:55:44 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 92.B2.17380.EA6AF1B5; Tue, 12 Jun 2018 11:55:42 +0100 (BST) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180612105540eucas1p181de7376152db045be40a8258f8b56a4~3ZFsAXt8e1139411394eucas1p1I; Tue, 12 Jun 2018 10:55:40 +0000 (GMT) X-AuditID: cbfec7f4-b4fc79c0000043e4-09-5b1fa6aeae2c Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 29.D1.04178.CA6AF1B5; Tue, 12 Jun 2018 11:55:40 +0100 (BST) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0PA7002VDICOBA90@eusync4.samsung.com>; Tue, 12 Jun 2018 11:55:40 +0100 (BST) From: Marek Szyprowski To: linux-mmc@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: Marek Szyprowski , Jaehoon Chung , Ulf Hansson , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz Subject: [PATCH v2] mmc: dw_mmc-exynos: fix potential external abort in resume_noirq() Date: Tue, 12 Jun 2018 12:55:23 +0200 Message-id: <20180612105523.30243-1-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprKIsWRmVeSWpSXmKPExsWy7djP87rrlslHG8zbzmyxccZ6Vosbv9pY Lc6f38BuceR/P6PFjPP7mCzWHrnLbnF8bbgDu8emVZ1sHneu7WHz6NuyitHj8ya5AJYoLpuU 1JzMstQifbsErozFKxazFPwXqzh1+hdbA+N84S5GDg4JAROJD8fCuxi5OIQEVjBKTH73lQnC +cwocf7fR/YuRk6wopmHTzBDJJYxSnxqWsUK4TQwSTTfaGcDqWITMJToetvFBjJWRMBB4sV5 J5AaZoEHjBJHn7xiAYkLC0RInP5hCVLOIqAqsebEQ7AFvAK2Ek+/P2CFWCYvsXrDAbBlEgJP WSW+nd3KCJFwkZj8aycLhC0s8er4FqjrZCQ6Ow4yQTQ0M0q0z5jFDuH0MEpsnbODDaLKWuLw 8YtgK5gF+CQmbZvODAkAXomONiGIEg+Jt4+esYKEhQRiJQ4fdJjAKLGAkWEVo3hqaXFuemqx UV5quV5xYm5xaV66XnJ+7iZGYGSd/nf8yw7GXX+SDjEKcDAq8fBGVMpFC7EmlhVX5h5ilOBg VhLhzdWRjxbiTUmsrEotyo8vKs1JLT7EKM3BoiTOG6dRFyUkkJ5YkpqdmlqQWgSTZeLglGpg bKn4bLjpgtJPnaYitfoHX//LBf+/fvIS107h2Lm2pclzi/Yl3oxcEfZXc+PB3pkbPh5ZduV/ vzpXZG8Cn+mJ6vDlOnK/5hy36/ZyiKk+vf3u69/fLstqfUqJ/x36iOcII/P6PVNvHJr008n+ rEbsgY0Ljmukd907+pHfREFfT3s+9027A5kfNymxFGckGmoxFxUnAgCYD8ToqAIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOJMWRmVeSWpSXmKPExsVy+t/xa7prlslHGzT9lrbYOGM9q8WNX22s FufPb2C3OPK/n9Fixvl9TBZrj9xltzi+NtyB3WPTqk42jzvX9rB59G1ZxejxeZNcAEsUl01K ak5mWWqRvl0CV8biFYtZCv6LVZw6/YutgXG+cBcjJ4eEgInEzMMnmLsYuTiEBJYwSly62csK khASaGKSOLyJBcRmEzCU6HrbxdbFyMEhIuAg8eK8E0g9s8ADRolFGyezgsSFBSIkTv+wBCln EVCVWHPiITuIzStgK/H0+wNWiF3yEqs3HGCewMi1gJFhFaNIamlxbnpusaFecWJucWleul5y fu4mRqD3tx37uXkH46WNwYcYBTgYlXh4IyrlooVYE8uKK3MPMUpwMCuJ8ObqyEcL8aYkVlal FuXHF5XmpBYfYpTmYFES5z1vUBklJJCeWJKanZpakFoEk2Xi4JRqYBQ5/0Xt0TuVdT8rr3Nv CZ5teLLJzO225sN7v1cG3Q74uWHbqzk8WnskOvfpf3M9zj61tKaAcU325qI8HhUr5uLACXW1 n4LeztgTI/TBm/+UlizHteIW5ydmYZ6XGSSzP3VkuPdtYjJlDVs+u2/bgQyFa5s2xJXN2P6q /y+Pj9aLsNw87ph4fSWW4oxEQy3mouJEABESSLr6AQAA X-CMS-MailID: 20180612105540eucas1p181de7376152db045be40a8258f8b56a4 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180612105540eucas1p181de7376152db045be40a8258f8b56a4 References: 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 dw_mci_exynos_resume_noirq() performs DWMMC register access without ensuring that respective clocks are enabled. This might cause external abort on some systems (observed on Exynos5433 based boards). Fix this by forcing a PM runtime active state before register access. Using SET_NOIRQ_SYSTEM_SLEEP_PM_OPS allows also to cleanup conditional code a bit. Suggested-by: Ulf Hansson Signed-off-by: Marek Szyprowski --- drivers/mmc/host/dw_mmc-exynos.c | 33 +++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/drivers/mmc/host/dw_mmc-exynos.c b/drivers/mmc/host/dw_mmc-exynos.c index 3164681108ae..b430db905bb5 100644 --- a/drivers/mmc/host/dw_mmc-exynos.c +++ b/drivers/mmc/host/dw_mmc-exynos.c @@ -175,6 +175,20 @@ static int dw_mci_exynos_runtime_resume(struct device *dev) return ret; } +#endif /* CONFIG_PM */ + +#ifdef CONFIG_PM_SLEEP +/** + * dw_mci_exynos_suspend_noirq - Exynos-specific suspend code + * + * This ensures that device will be in runtime active state in + * dw_mci_exynos_resume_noirq after calling pm_runtime_force_resume() + */ +static int dw_mci_exynos_suspend_noirq(struct device *dev) +{ + pm_runtime_get_noresume(dev); + return pm_runtime_force_suspend(dev); +} /** * dw_mci_exynos_resume_noirq - Exynos-specific resume code @@ -186,12 +200,16 @@ static int dw_mci_exynos_runtime_resume(struct device *dev) * * We run this code on all exynos variants because it doesn't hurt. */ - static int dw_mci_exynos_resume_noirq(struct device *dev) { struct dw_mci *host = dev_get_drvdata(dev); struct dw_mci_exynos_priv_data *priv = host->priv; u32 clksel; + int ret; + + ret = pm_runtime_force_resume(dev); + if (ret) + return ret; if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS7 || priv->ctrl_type == DW_MCI_TYPE_EXYNOS7_SMU) @@ -207,11 +225,11 @@ static int dw_mci_exynos_resume_noirq(struct device *dev) mci_writel(host, CLKSEL, clksel); } + pm_runtime_put(dev); + return 0; } -#else -#define dw_mci_exynos_resume_noirq NULL -#endif /* CONFIG_PM */ +#endif /* CONFIG_PM_SLEEP */ static void dw_mci_exynos_config_hs400(struct dw_mci *host, u32 timing) { @@ -556,14 +574,11 @@ static int dw_mci_exynos_remove(struct platform_device *pdev) } static const struct dev_pm_ops dw_mci_exynos_pmops = { - SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, - pm_runtime_force_resume) + SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(dw_mci_exynos_suspend_noirq, + dw_mci_exynos_resume_noirq) SET_RUNTIME_PM_OPS(dw_mci_runtime_suspend, dw_mci_exynos_runtime_resume, NULL) - .resume_noirq = dw_mci_exynos_resume_noirq, - .thaw_noirq = dw_mci_exynos_resume_noirq, - .restore_noirq = dw_mci_exynos_resume_noirq, }; static struct platform_driver dw_mci_exynos_pltfm_driver = {