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: 138309 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp5190119lji; Tue, 12 Jun 2018 03:55:53 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLHWiglCMdqeX/s27/pmmKWJg2S/GgdeZ2BAdU5yS4yZd8NJXBk+OhXGAy+FwgpVdMhPFVX X-Received: by 2002:a65:4aca:: with SMTP id c10-v6mr2726320pgu.327.1528800953199; Tue, 12 Jun 2018 03:55:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528800953; cv=none; d=google.com; s=arc-20160816; b=pvVpabld/ch7Mq7PDKmyAVd5TT7yQCxQV2SOYz/GQUwIAgzRKjgxhKzw1S0Mw3Ra8i 0jzoufLQ+JjkgP9rWbuZJcN4Kifxap2k0myEsMb+A5avHewMxxB3GtrMiXsxLy9FVrGM DSiHcGLsJ/3aQqY4OyH9sEkMfhYV/4gsv9decTx0wJAo5U+99GxXSja6pL2Qa2DCJwTs HJnNxwVswBIdsfEFEy+BNmxClc57vbDKFRYl0YqZyHYQsLxN5s7Gmnc4RQbEY49mh8eJ uN9i3DYNje3nb3e2l9tvxJ6fz9EyvyKp0Yo0Yqmxf4MibFkj2AqyJW6ckLsgpJEbmXJ5 XiEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=lM7SoF8sP5JCqE4Wb7LDPJukbo4/jidgSuwinhEO5U8=; b=Utth0U1fu9SMZXn1RKlqZPo1WkPsoUrdSG9EuCNwvEfGk8xxpcq1i9mzwq7vzhLvgL d6GuGr2/IAApZh7A2KCCp+hr2JQYiHCvE41EmnaY1xfftlX6SXk1hW9A1Jh73dsb9FMI RS+1WJs10qgMpkxluSC3/8UjrbF9GuDv6F/9Bqzx11+lAsiGpVvGEZP47fLuML0pvRUH YgCC4Ip61Ll7JV8cQBwVSJyvDtp30Dm7ehGEDP+zbjJ6BNzhxA8HQ2lccOeCkuFQRtTZ OWQR826lPnenfN0kjKoGwnSH9E/MVCTlBRU07Po64NYUsU9zHWr+gf2z8ALda0Ej/JFn mo3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=V67oRQ+X; spf=pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-samsung-soc-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s24-v6si500503pgv.494.2018.06.12.03.55.52; Tue, 12 Jun 2018 03:55:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=V67oRQ+X; spf=pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-samsung-soc-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933279AbeFLKzv (ORCPT + 3 others); 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-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org 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(-) -- 2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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 = {