From patchwork Fri Jan 24 14:14:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamil Konieczny X-Patchwork-Id: 11350355 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 05C9A6C1 for ; Fri, 24 Jan 2020 14:15:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D70E921734 for ; Fri, 24 Jan 2020 14:15:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="ZO49T1yL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390246AbgAXOPI (ORCPT ); Fri, 24 Jan 2020 09:15:08 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:54074 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388749AbgAXOPH (ORCPT ); Fri, 24 Jan 2020 09:15:07 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200124141506euoutp02b016c28eaf56bb44205acc76cf3c9d1f~s2DiMRKzt3020930209euoutp02l for ; Fri, 24 Jan 2020 14:15:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200124141506euoutp02b016c28eaf56bb44205acc76cf3c9d1f~s2DiMRKzt3020930209euoutp02l DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1579875306; bh=gUt0xdJYsjZMQC8Hykq0BgkZD7XebHRDKl7WMh5ImJE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZO49T1yL06/mM2n5FsBo810KcxfRGw8xy28NTxLBfn/w4rw8nAiqes9lOIaXBjWSR oCDFyvpZKq793vZqIp4a1o9BehyeFBH50ScK5jCULTHAOfPU2AHkKgiYFZnnkK9yEF Z7H5I4DAyseRsgxtuKWURo3aK0xAQfZHw21crvik= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200124141506eucas1p21db2b7c7be7c579acfc5fae3595436cc~s2Dh5JXm41251612516eucas1p2q; Fri, 24 Jan 2020 14:15:06 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id CB.AE.60698.AEBFA2E5; Fri, 24 Jan 2020 14:15:06 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200124141506eucas1p2da00cf4424a6b5e5e6d3e245eda586a5~s2DhoVgFe1252312523eucas1p2f; Fri, 24 Jan 2020 14:15:06 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200124141506eusmtrp2e052e19e4278ccea00a85bb157bf775c~s2Dhnpy7W1590315903eusmtrp2u; Fri, 24 Jan 2020 14:15:06 +0000 (GMT) X-AuditID: cbfec7f5-a29ff7000001ed1a-0c-5e2afbeae9b0 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 7D.E1.08375.9EBFA2E5; Fri, 24 Jan 2020 14:15:06 +0000 (GMT) Received: from AMDC3218.digital.local (unknown [106.120.51.18]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200124141505eusmtip16ceddbc58b4567e65dfa3a0e0decfdd6~s2Dg_cmfc3274532745eusmtip1e; Fri, 24 Jan 2020 14:15:05 +0000 (GMT) From: Kamil Konieczny To: k.konieczny@samsung.com Cc: Bartlomiej Zolnierkiewicz , Chanwoo Choi , Krzysztof Kozlowski , Kukjin Kim , Kyungmin Park , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, Marek Szyprowski , MyungJoo Ham Subject: [PATCH RESEND 1/3] PM / devfreq: exynos-nocp: fix debug print type Date: Fri, 24 Jan 2020 15:14:47 +0100 Message-Id: <20200124141449.19844-2-k.konieczny@samsung.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200124141449.19844-1-k.konieczny@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA01Sa0hTcRTvv3t373U4u87B/rgwXPhBIzXsw4W0EhIW9kEIhISsW15U2qbs Tpcm+cp3qWXpfOET1Fk+lprug+GaiU6dFZr20EDF8kU6C9LKdFfLb+ec3+scOAQiMvBdiWiV hlGraIUME6Bdr35aTyxueYX7Fo6KqXZdK596t7HAp6rXdXyqYHYJoazWNpwaSVvGKcPsBJ96 a6zAKNt9M6B01l4e9dT8Cac+pDZi5xzlBn0OJn9WnyzP79ADuc3gFoKGCfwjGEV0PKP2OXNN EFWd8hKPzcdvWYva0RSQg+UCBwKSp2BNzWs0FwgIEdkIYGfeOMY1GwBOz78AXGMDcCWvir8v WW+e4nFAA4BptgzwT2Kc/wZ2WRjpA/tGBtHdWkxKYU7tA7sCIQ0InFlatQMuZDDc7Bm1C1DS A45V1tq3EpL+MMtYvxd3FJanWuxzBzIA6of1OMdxhoOlc3YfZIeT3lmO7AZAUo9D83LmThqx 05yH7WlqzscFLg504Fx9BG73VPG4Wgvna/JxTnsXwM9ZaygHnIYfRzexXR+E9IStRh9uHAgH KiZRzt4JTq44cys4wYddJQg3FsLsTBHH9oALQ/f2kqQwd7tl7yo5fDLdjxUC97IDx5QdOKbs f241QPRAwsSxykiG9VMxWm+WVrJxqkjvGzFKA9j5JMufge/doPfXdRMgCSBzFOqmvcJFfDqe TVCaACQQmVgIQj3DRcIIOiGRUcdcVccpGNYEpAQqkwj9ar9eEZGRtIa5yTCxjHof5REOrikg dIScqRQ8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mIuK EwHshtpWswIAAA== X-CMS-MailID: 20200124141506eucas1p2da00cf4424a6b5e5e6d3e245eda586a5 X-Msg-Generator: CA X-RootMTR: 20200124141506eucas1p2da00cf4424a6b5e5e6d3e245eda586a5 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200124141506eucas1p2da00cf4424a6b5e5e6d3e245eda586a5 References: <20200124141449.19844-1-k.konieczny@samsung.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org Values printed in dev_dbg are both unsigned long, but were printed as signed decimals. Change this to unsigned long. Signed-off-by: Kamil Konieczny --- drivers/devfreq/event/exynos-nocp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/devfreq/event/exynos-nocp.c b/drivers/devfreq/event/exynos-nocp.c index ccc531ee6938..ebe9cdf94f54 100644 --- a/drivers/devfreq/event/exynos-nocp.c +++ b/drivers/devfreq/event/exynos-nocp.c @@ -167,7 +167,7 @@ static int exynos_nocp_get_event(struct devfreq_event_dev *edev, edata->load_count = ((counter[1] << 16) | counter[0]); edata->total_count = ((counter[3] << 16) | counter[2]); - dev_dbg(&edev->dev, "%s (event: %ld/%ld)\n", edev->desc->name, + dev_dbg(&edev->dev, "%s (event: %lu/%lu)\n", edev->desc->name, edata->load_count, edata->total_count); return 0; From patchwork Fri Jan 24 14:14:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamil Konieczny X-Patchwork-Id: 11350343 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B5D3617EF for ; Fri, 24 Jan 2020 14:15:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8995221556 for ; Fri, 24 Jan 2020 14:15:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="oZ7Y+9+B" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390294AbgAXOPJ (ORCPT ); Fri, 24 Jan 2020 09:15:09 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:54081 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390241AbgAXOPI (ORCPT ); Fri, 24 Jan 2020 09:15:08 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200124141507euoutp021ff5679b696df8998dc5a8fbc20ab46f~s2Di43akF2958929589euoutp02X for ; Fri, 24 Jan 2020 14:15:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200124141507euoutp021ff5679b696df8998dc5a8fbc20ab46f~s2Di43akF2958929589euoutp02X DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1579875307; bh=SyUER5XtPQaR5PqGkKYS+jSgkqDS6pK5BSu+qlUCJYk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oZ7Y+9+BtznngctigeIfqyrwg73fDmKNSzev+TZGgrOmkuD1XrvefeVkQTA4XQG2p t34FzZxTyiGW0RiWgSE7LRQh5xhpF0OztPvbknyrJ9MhKDhEO0o8yn4u37vfljbK+K b4IkfRw7Wb/IesdBLZJaalAQXy+XpJgfwEHwOGaE= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20200124141507eucas1p172a87a1033df439ed837dc0b47b57b1b~s2DinRh-E2191621916eucas1p1q; Fri, 24 Jan 2020 14:15:07 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id B6.5F.61286.BEBFA2E5; Fri, 24 Jan 2020 14:15:07 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20200124141506eucas1p1d2fdb3b5d26d123272cafeddecd5708a~s2DiVyscR2198621986eucas1p1z; Fri, 24 Jan 2020 14:15:06 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200124141506eusmtrp135a260c16c8b2bb95fb23a90621d2573~s2DiVJB9j1786817868eusmtrp1e; Fri, 24 Jan 2020 14:15:06 +0000 (GMT) X-AuditID: cbfec7f2-f0bff7000001ef66-4c-5e2afbeb61a9 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id A6.C2.07950.AEBFA2E5; Fri, 24 Jan 2020 14:15:06 +0000 (GMT) Received: from AMDC3218.digital.local (unknown [106.120.51.18]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200124141506eusmtip1eea5f29f451889f60fd8d12840c623cc~s2DhoZx_00071400714eusmtip1C; Fri, 24 Jan 2020 14:15:06 +0000 (GMT) From: Kamil Konieczny To: k.konieczny@samsung.com Cc: Bartlomiej Zolnierkiewicz , Chanwoo Choi , Krzysztof Kozlowski , Kukjin Kim , Kyungmin Park , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Marek Szyprowski , MyungJoo Ham Subject: [PATCH RESEND 2/3] PM / devfreq: exynos-bus: prepare for change in load calc in exynos-nocp Date: Fri, 24 Jan 2020 15:14:48 +0100 Message-Id: <20200124141449.19844-3-k.konieczny@samsung.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200124141449.19844-1-k.konieczny@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrAKsWRmVeSWpSXmKPExsWy7djPc7qvf2vFGbx9zWaxcc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MHm wOOxaVUnm8fmJfUefVtWMXp83iQXwBKlZ1OUX1qSqpCRX1xiqxRtaGGkZ2hpoWdkYqlnaGwe a2VkqqRvZ5OSmpNZllqkb5egl3GxYzZzwT+Rij0rVjA2ME4T7GLk5JAQMJFYMWk9cxcjF4eQ wFJGie55S9ghEtISjadXM0HYwhJ/rnWxQRR9YpTYO30DI0iCTUBf4uDZkywgtghQQ+eiiUwg RcwCu5gltly+yAqSEBZIkXjzdypYA4uAqsS2M83MIDavgI3ErpZzzBAb5CVmN55mA7E5BWwl Vp1ZBXaFEFDNlK2rGCHqBSVOznwCtowZqL5562zmCYwCs5CkZiFJLWBkWsUoklpanJueW2yk V5yYW1yal66XnJ+7iREYPduO/dyyg7HrXfAhRgEORiUeXoc7WnFCrIllxZW5hxglOJiVRHgZ wzTjhHhTEiurUovy44tKc1KLDzGaAj0xkVlKNDkfGNl5JfGGpobmFpaG5sbmxmYWSuK8HQIH Y4QE0hNLUrNTUwtSi2D6mDg4pRoYG8Kn690oDXPpdLE3amA8Ea/Uf8lGNcevhZvBc8HDpgPz eBdvFRH9onn29Kfncqaiy/5KT3G5cTK5R7ddicF86W1BtXQ7Zd2szMW/jtb9rmY//+/8t8OL 1XZEKuqn3rwsYvFnz6nURw+Vpsf4aR+c41cUJNw//+mOJqlm9d2L5ISybtx6en+CEktxRqKh FnNRcSIAEuiY97QCAAA= X-CMS-MailID: 20200124141506eucas1p1d2fdb3b5d26d123272cafeddecd5708a X-Msg-Generator: CA X-RootMTR: 20200124141506eucas1p1d2fdb3b5d26d123272cafeddecd5708a X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200124141506eucas1p1d2fdb3b5d26d123272cafeddecd5708a References: <20200124141449.19844-1-k.konieczny@samsung.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org Add time to struct exynos_bus and time and current frequency to struct devfreq_event_data. This will allow to calculate load and max bandwidth in exynos-nocp driver. Signed-off-by: Kamil Konieczny --- drivers/devfreq/exynos-bus.c | 21 ++++++++++++++++++++- include/linux/devfreq-event.h | 4 ++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/drivers/devfreq/exynos-bus.c b/drivers/devfreq/exynos-bus.c index 8fa8eb541373..f04ce5b84e75 100644 --- a/drivers/devfreq/exynos-bus.c +++ b/drivers/devfreq/exynos-bus.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -31,6 +32,7 @@ struct exynos_bus { struct mutex lock; unsigned long curr_freq; + unsigned long prev_time; struct opp_table *opp_table; struct clk *clk; @@ -57,7 +59,22 @@ static int exynos_bus_##ops(struct exynos_bus *bus) \ } exynos_bus_ops_edev(enable_edev); exynos_bus_ops_edev(disable_edev); -exynos_bus_ops_edev(set_event); + +static int exynos_bus_set_event(struct exynos_bus *bus) +{ + int i, ret; + + bus->prev_time = jiffies; + for (i = 0; i < bus->edev_count; i++) { + if (!bus->edev[i]) + continue; + ret = devfreq_event_set_event(bus->edev[i]); + if (ret < 0) + return ret; + } + + return 0; +} static int exynos_bus_get_event(struct exynos_bus *bus, struct devfreq_event_data *edata) @@ -66,6 +83,8 @@ static int exynos_bus_get_event(struct exynos_bus *bus, unsigned long load_count = 0, total_count = 0; int i, ret = 0; + event_data.curr_freq = bus->curr_freq; + event_data.prev_time = bus->prev_time; for (i = 0; i < bus->edev_count; i++) { if (!bus->edev[i]) continue; diff --git a/include/linux/devfreq-event.h b/include/linux/devfreq-event.h index f14f17f8cb7f..b57ccfcb775b 100644 --- a/include/linux/devfreq-event.h +++ b/include/linux/devfreq-event.h @@ -41,12 +41,16 @@ struct devfreq_event_dev { * each count may represent a clock cycle, a time unit * (ns/us/...), or anything the device driver wants. * Generally, utilization is load_count / total_count. + * @prev_time : jiffies for interval calculations with polling. + * @curr_freq : current frequency for calculating max bandwidth. * * This structure contains the data of devfreq-event device for polling period. */ struct devfreq_event_data { unsigned long load_count; unsigned long total_count; + unsigned long prev_time; + unsigned long curr_freq; }; /** From patchwork Fri Jan 24 14:14:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamil Konieczny X-Patchwork-Id: 11350349 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 75C5517EF for ; Fri, 24 Jan 2020 14:15:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4012020838 for ; Fri, 24 Jan 2020 14:15:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="KiDDUY6Z" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390241AbgAXOPK (ORCPT ); Fri, 24 Jan 2020 09:15:10 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:54097 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388687AbgAXOPJ (ORCPT ); Fri, 24 Jan 2020 09:15:09 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200124141508euoutp0252817459516a854973d873d0e93ed4c3~s2DjoNafS3020930209euoutp02p for ; Fri, 24 Jan 2020 14:15:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200124141508euoutp0252817459516a854973d873d0e93ed4c3~s2DjoNafS3020930209euoutp02p DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1579875308; bh=Zj9SGg4W8FGzvWUQwtrRGP6fordYE7UZIdbAgofZujY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KiDDUY6ZtZ3aAcaABU/t0Ow41dHF28uCWtO7txhAYmbALDmUCAklV77THGROGP9Ev l6RsbBXnqZGDGacIqgWktV40a9ODH4Q3SeTT1Eph+1CvZgHPDlHBNFmo9/NRDjrewk iqjBmkNKmDv9BCGmQkHW+PdLW1o6BeNgp4Rx9WSs= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200124141507eucas1p231bc3e48f10952c8fa771f8a5374fe4d~s2DjW26tR1252412524eucas1p2v; Fri, 24 Jan 2020 14:15:07 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id CB.0B.60679.BEBFA2E5; Fri, 24 Jan 2020 14:15:07 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20200124141507eucas1p115e87fdd6eda4a5f320d5145f5960889~s2Di-fSuP3110831108eucas1p1i; Fri, 24 Jan 2020 14:15:07 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200124141507eusmtrp1adb748a469d514b3f3ca96c976818340~s2Di_3ceG1786817868eusmtrp1k; Fri, 24 Jan 2020 14:15:07 +0000 (GMT) X-AuditID: cbfec7f4-0e5ff7000001ed07-b4-5e2afbeb85e1 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id C7.C2.07950.BEBFA2E5; Fri, 24 Jan 2020 14:15:07 +0000 (GMT) Received: from AMDC3218.digital.local (unknown [106.120.51.18]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200124141506eusmtip1f051cc28dd1857f2a39bff28b3fb3e93~s2DiUv6gu0071400714eusmtip1D; Fri, 24 Jan 2020 14:15:06 +0000 (GMT) From: Kamil Konieczny To: k.konieczny@samsung.com Cc: Bartlomiej Zolnierkiewicz , Chanwoo Choi , Krzysztof Kozlowski , Kukjin Kim , Kyungmin Park , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, Marek Szyprowski , MyungJoo Ham Subject: [PATCH RESEND 3/3] PM / devfreq: exynos-nocp: change load and total calculations Date: Fri, 24 Jan 2020 15:14:49 +0100 Message-Id: <20200124141449.19844-4-k.konieczny@samsung.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200124141449.19844-1-k.konieczny@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrMKsWRmVeSWpSXmKPExsWy7djPc7qvf2vFGZzrMrXYOGM9q8X1L89Z LRZ8msFq0f/4NbPF+fMb2C3ONr1ht9j0+BqrxeVdc9gsPvceYbSYcX4fk8XaI3fZLW43rmBz 4PHYtKqTzWPzknqPvi2rGD0+b5ILYInisklJzcksSy3St0vgyrg+5TVLwS2lis5j/awNjMtl uhg5OSQETCTWflvP3MXIxSEksIJRYuKpJewQzhdGieuTGtkgnM+MErtv7GeEafm0ZjNUy3JG icVLTjPCtey5v5kdpIpNQF/i4NmTLCC2iIC0ROeiiUwgRcwCm5gl7r9+B5YQFoiWWL1tJ5jN IqAq8aNxITOIzStgI9F85y0TxDp5idmNp9lAbE4BW4lVZ1axQ9QISpyc+QSslxmopnnrbLCT JASWsUu8nHyTDaLZRWLp7UYWCFtY4tXxLewQtozE6ck9UPFyiacL+9ghmlsYJR60f4RKWEvc OfcLaBAH0AZNifW79CHCjhLHvrQwgoQlBPgkbrwVhLiBT2LStunMEGFeiY42IYhqVYnnp3qg XpGW6Pq/jhXC9pB4/OoX8wRGxVlIvpmF5JtZCHsXMDKvYhRPLS3OTU8tNspLLdcrTswtLs1L 10vOz93ECExKp/8d/7KDcdefpEOMAhyMSjy8M+5pxQmxJpYVV+YeYpTgYFYS4WUM04wT4k1J rKxKLcqPLyrNSS0+xCjNwaIkzmu86GWskEB6YklqdmpqQWoRTJaJg1OqgbHz1OOG3Wt49+3+ HfKxjvW/h5Z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MailID: 20200124141507eucas1p115e87fdd6eda4a5f320d5145f5960889 X-Msg-Generator: CA X-RootMTR: 20200124141507eucas1p115e87fdd6eda4a5f320d5145f5960889 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200124141507eucas1p115e87fdd6eda4a5f320d5145f5960889 References: <20200124141449.19844-1-k.konieczny@samsung.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org There are two problems with exynos-nocp driver. First one is reading bytes and cycle counters and comparing them one to one without taking into account wcore bus width. Second one is that cycle counter depends on DREX DRAM clock, not on wcore clock. The latter problem was exposed by commit 6e7674c3c6df5 ("memory: Add DMC driver for Exynos5422"), which changes DRAM clock depending on memory read/write pressure and when it gets at higher freqency, NoCP cycle counter also increases. Note that both of these problems was there before this commit. The proposed solution is to use byte counter from NoCP h/w registers for current wcore bandwidth calculations and derive max bandwidth from current frequency. While at it, change from bytes to kilobytes to avoid overflow in later calculations in exynos-bus and devfreq drivers. Also while at it, remove cycle counters setting and reading and extend dev_dbg with time interval in miliseconds, percent of load, raw counter value in hex. Signed-off-by: Kamil Konieczny --- drivers/devfreq/event/exynos-nocp.c | 61 ++++++++++++----------------- 1 file changed, 24 insertions(+), 37 deletions(-) diff --git a/drivers/devfreq/event/exynos-nocp.c b/drivers/devfreq/event/exynos-nocp.c index ebe9cdf94f54..979ec094cf26 100644 --- a/drivers/devfreq/event/exynos-nocp.c +++ b/drivers/devfreq/event/exynos-nocp.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -60,19 +61,6 @@ static int exynos_nocp_set_event(struct devfreq_event_dev *edev) if (ret < 0) goto out; - ret = regmap_update_bits(nocp->regmap, NOCP_COUNTERS_2_SRC, - NOCP_CNT_SRC_INTEVENT_MASK, - NOCP_CNT_SRC_INTEVENT_CYCLE_MASK); - if (ret < 0) - goto out; - - ret = regmap_update_bits(nocp->regmap, NOCP_COUNTERS_3_SRC, - NOCP_CNT_SRC_INTEVENT_MASK, - NOCP_CNT_SRC_INTEVENT_CHAIN_MASK); - if (ret < 0) - goto out; - - /* Set an alarm with a max/min value of 0 to generate StatALARM */ ret = regmap_write(nocp->regmap, NOCP_STAT_ALARM_MIN, 0x0); if (ret < 0) @@ -95,18 +83,6 @@ static int exynos_nocp_set_event(struct devfreq_event_dev *edev) if (ret < 0) goto out; - ret = regmap_update_bits(nocp->regmap, NOCP_COUNTERS_2_ALARM_MODE, - NOCP_CNT_ALARM_MODE_MASK, - NOCP_CNT_ALARM_MODE_MIN_MAX_MASK); - if (ret < 0) - goto out; - - ret = regmap_update_bits(nocp->regmap, NOCP_COUNTERS_3_ALARM_MODE, - NOCP_CNT_ALARM_MODE_MASK, - NOCP_CNT_ALARM_MODE_MIN_MAX_MASK); - if (ret < 0) - goto out; - /* Enable the measurements by setting AlarmEn and StatEn */ ret = regmap_update_bits(nocp->regmap, NOCP_MAIN_CTL, NOCP_MAIN_CTL_STATEN_MASK | NOCP_MAIN_CTL_ALARMEN_MASK, @@ -145,6 +121,7 @@ static int exynos_nocp_get_event(struct devfreq_event_dev *edev, { struct exynos_nocp *nocp = devfreq_event_get_drvdata(edev); unsigned int counter[4]; + unsigned long dt; int ret; /* Read cycle count */ @@ -156,19 +133,29 @@ static int exynos_nocp_get_event(struct devfreq_event_dev *edev, if (ret < 0) goto out; - ret = regmap_read(nocp->regmap, NOCP_COUNTERS_2_VAL, &counter[2]); - if (ret < 0) - goto out; - - ret = regmap_read(nocp->regmap, NOCP_COUNTERS_3_VAL, &counter[3]); - if (ret < 0) - goto out; - edata->load_count = ((counter[1] << 16) | counter[0]); - edata->total_count = ((counter[3] << 16) | counter[2]); - - dev_dbg(&edev->dev, "%s (event: %lu/%lu)\n", edev->desc->name, - edata->load_count, edata->total_count); + dt = jiffies_to_msecs((long)jiffies - (long)edata->prev_time); + if (dt == 0) + dt = 1; + + /* + * count load in kB/s + * load = load / 1000 * 1000 / dt + */ + edata->load_count = edata->load_count / dt; + + /* + * count max bandwidth in kB/s: + * bw = freq * ((bus width in bits / 8) / nr of mem channels) / 1000 + * where 128 bits / 8 bits per byte / 4 channels = 4 + * so it is: bw = freq * 4 / 1000 + */ + edata->total_count = edata->curr_freq / 250; + + dev_dbg(&edev->dev, "%s (event: %lu/%lu) %lums %lu%% 0x%08x\n", + edev->desc->name, edata->load_count, edata->total_count, dt, + edata->load_count * 100 / edata->total_count, + (counter[1] << 16) | counter[0]); return 0;