From patchwork Tue Nov 12 10:47:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 179178 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp7931139ilf; Tue, 12 Nov 2019 02:48:14 -0800 (PST) X-Google-Smtp-Source: APXvYqyhHH1LRvkAz+xJgSGtKs+udNJcIfIfJxC+d5J/ECTu9g8c9RiJ36qxW3AQVy31hFFOGTZj X-Received: by 2002:a17:906:8591:: with SMTP id v17mr27768870ejx.185.1573555694387; Tue, 12 Nov 2019 02:48:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573555694; cv=none; d=google.com; s=arc-20160816; b=alPM4o4sIuXUjwQCbZlGE29hogPfvETvRLHeqZ+9o3IPikNbT91VebkUHDiMcjsDQP 5GX4t/wBIKpy/o2wtUj0jzJsuggVVvwcAvuoOO5+NBmkg9GDTwwDjibwfrq2NzSHifTE vAD/JB3jDaKMgk68axBsKtTwjf7KmxSrIrCK8VYcDQgSzNKlSVrf7IKg9NUVQ3NIbY6n /26l29cwJOB0FeOl1DHKiSSPEZCzbcTRCWm1veIhNvvXSaNkjRaLWbY/AhpUMXLszj51 PzF4FF0E9My4t4k0rME0cau7MPSppdlFLxVQoc16G6txEEZ72XSE6AV45e9v1W9yref9 wmRg== 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; bh=t8KznA7MRgrnEYRKvcDPTJukI3s+wjik+zG/HLqSrhE=; b=nTrzhUzJ2egE/0ixq1z08dIFovLOVlH4bgbYzXoKuHSgsQ+kDESUZJm+/vuAtpD+0F d8kKK5zlYm4w6055guheNkfv4R8orIfg4FT6yKhsHVJjtfI0qfOShsezyHOuE7OM/ZA9 KBeqU7JuBMkKAuTWpGJTkOuUp2GzEBk7ztOOKJouZgpNrTs29kx/8ukfR1hppECz/LnJ cs9RSdo6DYL9ZVNKopTJavZP0NWVEXNrAUttNY8XyOMwsg/srALuxYSqPAABZwg1ABIR nnQ9vu0l9brshFxdH/KNrWeNl02Og7cGCcvV1SekaNKbyXJfn13FBjSWYI11Ge5Do22q /FLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=BlgpjxZK; 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=pass (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 c6si10229504ejm.157.2019.11.12.02.48.14; Tue, 12 Nov 2019 02:48:14 -0800 (PST) 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=pass header.i=@samsung.com header.s=mail20170921 header.b=BlgpjxZK; 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=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726980AbfKLKsM (ORCPT + 3 others); Tue, 12 Nov 2019 05:48:12 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:59177 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725834AbfKLKsM (ORCPT ); Tue, 12 Nov 2019 05:48:12 -0500 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20191112104810euoutp0154e3106b557318aee4c34d27986dbc97~WZJA5DtBS2446224462euoutp01d for ; Tue, 12 Nov 2019 10:48:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20191112104810euoutp0154e3106b557318aee4c34d27986dbc97~WZJA5DtBS2446224462euoutp01d DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1573555690; bh=t8KznA7MRgrnEYRKvcDPTJukI3s+wjik+zG/HLqSrhE=; h=From:To:Cc:Subject:Date:References:From; b=BlgpjxZKPvpQKov/BRNZTTGrQDQ/CALe4BJGUnP3HTCYxMKdLHCewMcSErYgC7OhK lkxA2rAZIPzoEB1kPj3sIEYGaFOg10RTRl3CKjPsUcD9PZWDi4gV4nB1eQ98D3Qz9O 4rT2wDiBSye7x6Z9UM8jNICJA8NRPyKKsHLMLK2I= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20191112104810eucas1p268ae9639c29066621d052902a18533e7~WZJAgxx0h3014730147eucas1p2J; Tue, 12 Nov 2019 10:48:10 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id D8.55.04374.9ED8ACD5; Tue, 12 Nov 2019 10:48:09 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20191112104809eucas1p14d5d364021a359861788472b513e43e5~WZJAKlszV0983309833eucas1p1o; Tue, 12 Nov 2019 10:48:09 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20191112104809eusmtrp2d07a4e70cace8fc02e31669927b654b4~WZJAJ9p_90713307133eusmtrp2l; Tue, 12 Nov 2019 10:48:09 +0000 (GMT) X-AuditID: cbfec7f5-4f7ff70000001116-27-5dca8de999f1 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id F4.36.04117.9ED8ACD5; Tue, 12 Nov 2019 10:48:09 +0000 (GMT) Received: from AMDC2765.digital.local (unknown [106.120.51.73]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20191112104809eusmtip288c305a2268c9a86e11a8b17ad1701fc~WZI-t-Z1V2537125371eusmtip2w; Tue, 12 Nov 2019 10:48:09 +0000 (GMT) From: Marek Szyprowski To: linux-pm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Marek Szyprowski , Chanwoo Choi , MyungJoo Ham , Leonard Crestez , Matthias Kaehlcke , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz Subject: [PATCH] PM / devfreq: Add missing locking while setting suspend_freq Date: Tue, 12 Nov 2019 11:47:34 +0100 Message-Id: <20191112104734.31074-1-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrLIsWRmVeSWpSXmKPExsWy7djPc7ove0/FGmxdYG2xccZ6VovrX56z Wpw/v4HdYsXdj6wWl3fNYbP43HuE0WLG+X1MFmuP3GW3+LzhMaPF7cYVbA5cHrMbLrJ4bFrV yeax8d0OJo++LasYPT5vkgtgjeKySUnNySxLLdK3S+DKaPyQWDBXpuLdqh72BsYzEl2MnBwS AiYSFy8/Y+li5OIQEljBKLF59hd2COcLo8SVX3+ZIJzPjBKrDn1igmmZfvwVVMtyRomtL36z wLXMODoPrIpNwFCi620XWxcjB4eIQLzE+q9WIDXMAluYJM7/7mUEqREW8Jd4+vkDO4jNIqAq 0TW/iRXE5hWwlVh99wgzxDZ5idUbDjCDNEsIvGaT+L1tK9QZLhLz5hxggbCFJV4d38IOYctI /N85nwmioZlR4uG5tewQTg+jxOWmGYwQVdYSh49fZAU5j1lAU2L9Ln2IsKPE+tu7wMISAnwS N94KgoSZgcxJ26YzQ4R5JTrahCCq1SRmHV8Ht/bghUtQJR4S1z7qgoSFBGIl2s9sZZ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eh/eiRkVV53MsSmsMH6adk/kQNCGFv61t/Z1P3a9cDz0IK5F8 G67M/3f5tL+VizZE+T8NaPh63HmneKBsC+vRsxI7CrYuPJwVYbqrydGa2UZ4szqrtPMBI0Ul luKMREMt5qLiRAD23Ue2ZgIAAA== X-CMS-MailID: 20191112104809eucas1p14d5d364021a359861788472b513e43e5 X-Msg-Generator: CA X-RootMTR: 20191112104809eucas1p14d5d364021a359861788472b513e43e5 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20191112104809eucas1p14d5d364021a359861788472b513e43e5 References: Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org Commit 2abb0d5268ae ("PM / devfreq: Lock devfreq in trans_stat_show") revealed a missing locking while calling devfreq_update_status() function during suspend/resume cycle. Code analysis revealed that devfreq_set_target() function was called without needed locks held for setting device specific suspend_freq if such has been defined. This patch fixes that by adding the needed locking, what fixes following kernel warning on Exynos4412-based OdroidU3 board during system suspend: PM: suspend entry (deep) Filesystems sync: 0.002 seconds Freezing user space processes ... (elapsed 0.001 seconds) done. OOM killer disabled. Freezing remaining freezable tasks ... (elapsed 0.001 seconds) done. ------------[ cut here ]------------ WARNING: CPU: 2 PID: 1385 at drivers/devfreq/devfreq.c:204 devfreq_update_status+0xc0/0x188 Modules linked in: CPU: 2 PID: 1385 Comm: rtcwake Not tainted 5.4.0-rc6-next-20191111 #6848 Hardware name: SAMSUNG EXYNOS (Flattened Device Tree) [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [] (show_stack) from [] (dump_stack+0xb4/0xe0) [] (dump_stack) from [] (__warn+0xf4/0x10c) [] (__warn) from [] (warn_slowpath_fmt+0xb0/0xb8) [] (warn_slowpath_fmt) from [] (devfreq_update_status+0xc0/0x188) [] (devfreq_update_status) from [] (devfreq_set_target+0xb0/0x15c) [] (devfreq_set_target) from [] (devfreq_suspend+0x2c/0x64) [] (devfreq_suspend) from [] (dpm_suspend+0xa4/0x57c) [] (dpm_suspend) from [] (dpm_suspend_start+0x98/0xa0) [] (dpm_suspend_start) from [] (suspend_devices_and_enter+0xec/0xc74) [] (suspend_devices_and_enter) from [] (pm_suspend+0x340/0x410) [] (pm_suspend) from [] (state_store+0x6c/0xc8) [] (state_store) from [] (kernfs_fop_write+0x10c/0x228) [] (kernfs_fop_write) from [] (__vfs_write+0x30/0x1d0) [] (__vfs_write) from [] (vfs_write+0xa4/0x180) [] (vfs_write) from [] (ksys_write+0x60/0xd8) [] (ksys_write) from [] (ret_fast_syscall+0x0/0x28) Exception stack(0xed3d7fa8 to 0xed3d7ff0) ... irq event stamp: 9667 hardirqs last enabled at (9679): [] _raw_spin_unlock_irq+0x20/0x58 hardirqs last disabled at (9698): [] __schedule+0xd8/0x818 softirqs last enabled at (9694): [] __do_softirq+0x4fc/0x5fc softirqs last disabled at (9719): [] irq_exit+0x16c/0x170 ---[ end trace 41ac5b57d046bdbc ]--- ------------[ cut here ]------------ Signed-off-by: Marek Szyprowski --- drivers/devfreq/devfreq.c | 4 ++++ 1 file changed, 4 insertions(+) -- 2.17.1 Acked-by: Chanwoo Choi diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 94fb8e821e12..65a4b6cf3fa5 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -957,7 +957,9 @@ int devfreq_suspend_device(struct devfreq *devfreq) } if (devfreq->suspend_freq) { + mutex_lock(&devfreq->lock); ret = devfreq_set_target(devfreq, devfreq->suspend_freq, 0); + mutex_unlock(&devfreq->lock); if (ret) return ret; } @@ -985,7 +987,9 @@ int devfreq_resume_device(struct devfreq *devfreq) return 0; if (devfreq->resume_freq) { + mutex_lock(&devfreq->lock); ret = devfreq_set_target(devfreq, devfreq->resume_freq, 0); + mutex_unlock(&devfreq->lock); if (ret) return ret; }