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: 213590 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10BFAC2D0DB 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 D6A7C21556 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/Jx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KNDkfGNd5JfGGpobmFpaG5sbmxmYWSuK8HQIHY4QE 0hNLUrNTUwtSi2D6mDg4pRoYZTJFuBVvr5A4rVkyz2vv8ul52ZMkVn7NY3ql1aOixL5kppbn vQqLV3VMzbsvW3TFBXLOtGRpdtaadaYn/ohTzGX+7any3MEc2t9lLYJ+PO9ibDSaKZolJX1N Qm5vueXKaR9+xvG0LDjY6v6fx3wV68m0oNPz9vHf5JpjYKBy6+z7KytLa7mVWIozEg21mIuK 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: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: 213591 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55F14C2D0DB 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 21DA22075D 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/OoX8wRGxVlIvpmF5JtZCHsXMDKvYhRPLS3OTU8tNspLLdcrTsw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c/2S1qP w3vf/qrvC7evSV1WvWdJub7mqu9hEauubbl7N2JS0pldBWna16ZJyldpOJ49cLumUbpZkj9H OfbKmicBPbslLeSFJ7xk+W9U18Jjo9PgcfbbUpNv4QsOJjQcUf956LoSS3FGoqEWc1FxIgAB VReisgIAAA== X-CMS-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;