From patchwork Thu Apr 18 13:38:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Luba X-Patchwork-Id: 10907339 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B8C2E922 for ; Thu, 18 Apr 2019 13:39:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A3D5627D0C for ; Thu, 18 Apr 2019 13:39:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 97A4128852; Thu, 18 Apr 2019 13:39:40 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 1DE8328789 for ; Thu, 18 Apr 2019 13:39:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389178AbfDRNje (ORCPT ); Thu, 18 Apr 2019 09:39:34 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:34211 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389097AbfDRNi4 (ORCPT ); Thu, 18 Apr 2019 09:38:56 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20190418133855euoutp0194e6900dfcea737769e64ac4197ddbde~WlStyEVQ70326203262euoutp010 for ; Thu, 18 Apr 2019 13:38:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20190418133855euoutp0194e6900dfcea737769e64ac4197ddbde~WlStyEVQ70326203262euoutp010 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1555594735; bh=LrbUWDzhuJDtHdKSva67o1iOv3VtXmTRaWWQwUjY1pM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ldW7LNjwdx1Kqvc/j/ukyoqrNK8RMgc8+0i9sCEspxFI5q/GFhajEjC2oviONS/ac 0raY05TlsoZMrb/VwxdV2itiGo8hYdwTiG+ThsKymhV6XWgLawRpSEjQ6jVjW1Vs/x DVGBhMM9NFngVNNFpDyUJWU8HRQZdSBsMVB7E0gg= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20190418133854eucas1p2d5463cd3b63b6f93c21bd90db022a7d2~WlSs_5OPt0537305373eucas1p2i; Thu, 18 Apr 2019 13:38:54 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 2F.C2.04298.DED78BC5; Thu, 18 Apr 2019 14:38:53 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20190418133853eucas1p21ff5f58f5446b8452698910923524524~WlSr9o19I0331003310eucas1p22; Thu, 18 Apr 2019 13:38:53 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20190418133852eusmtrp21704a2739ef7553b7df6dfa3bfd8fe81~WlSrvlX_v2812628126eusmtrp29; Thu, 18 Apr 2019 13:38:52 +0000 (GMT) X-AuditID: cbfec7f2-f2dff700000010ca-8c-5cb87dedccc7 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 78.55.04140.CED78BC5; Thu, 18 Apr 2019 14:38:52 +0100 (BST) Received: from AMDC3778.DIGITAL.local (unknown [106.120.51.20]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20190418133852eusmtip2ad8f4ab232e5b7c5094bd18437997a6a~WlSrCI27N1989619896eusmtip2S; Thu, 18 Apr 2019 13:38:52 +0000 (GMT) From: Lukasz Luba To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: b.zolnierkie@samsung.com, krzk@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, cw00.choi@samsung.com, kyungmin.park@samsung.com, m.szyprowski@samsung.com, s.nawrocki@samsung.com, myungjoo.ham@samsung.com, kgene@kernel.org, l.luba@partner.samsung.com, willy.mh.wolff.ml@gmail.com Subject: [PATCH v2 2/4] drivers: devfreq: events: extend events by type of counted data Date: Thu, 18 Apr 2019 15:38:30 +0200 Message-Id: <1555594712-18341-3-git-send-email-l.luba@partner.samsung.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1555594712-18341-1-git-send-email-l.luba@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrMKsWRmVeSWpSXmKPExsWy7djPc7pva3fEGPz/ZWGxccZ6VovrX56z Wsw/co7Vov/xa2aL8+c3sFucbXrDbnGrQcZi0+NrrBaXd81hs/jce4TRYsb5fUwWa4/cZbdY ev0ik8XtxhVsFq17j7BbHH7Tzmrx7cQjRgdBjzXz1jB67Jx1l91j06pONo/NS+o9Dr7bw+TR t2UVo8fnTXIB7FFcNimpOZllqUX6dglcGZf/vmYtaFCpWHi9g62BcYNMFyMHh4SAicSJD8Jd jFwcQgIrGCVWHrjD3MXICeR8YZTYdrYcIvGZUaJj8kxWkARIw9Lr55kgEssZJWa3P2WEcIA6 zv05wggylk1AT2LHqkKQBhGBxYwS3w5HgdQwCyxjktjX/IkJJCEsECkx6cYTFhCbRUBVYsuB e2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YQm1PAW+LLrn2sEMu8JPbt +MEygZFvASPDKkaR1NLi3PTcYiO94sTc4tK8dL3k/NxNjMA42Xbs55YdjF3vgg8xCnAwKvHw SmTuiBFiTSwrrsw9xCjBwawkwuuYsiVGiDclsbIqtSg/vqg0J7X4EKMp0FETmaVEk/OBMZxX Em9oamhuYWlobmxubGahJM573qAySkggPbEkNTs1tSC1CKaPiYNTqoFx49TQHZ+2Xcn5WPVw brL11qrrK/wF5lQ84jb+Jp75798sXZHkpjzD4O+z3Fqcpk3un+fO037sXJIvJ9d/z1tlHnwe iqcCe7lkcwqrVBJn+0g2rNrwVrRCzni5xrILLALO+3tbD+gULTgoe8yi3SD5gcGeingLx7cT jaZ+Oji96cO7pTEKUaxKLMUZiYZazEXFiQC1UeXtqQIAAA== X-CMS-MailID: 20190418133853eucas1p21ff5f58f5446b8452698910923524524 X-Msg-Generator: CA X-RootMTR: 20190418133853eucas1p21ff5f58f5446b8452698910923524524 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20190418133853eucas1p21ff5f58f5446b8452698910923524524 References: <1555594712-18341-1-git-send-email-l.luba@partner.samsung.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds posibility to choose what type of data should be counted by the PPMU counter. Now the type comes from DT where the event has been defined. When there is no 'event-data-type' the default value is used, which is 'read data in bytes'. It is needed when you want to know not only read+write data bytes but i.e. only write data in byte, or number of read requests, etc. Signed-off-by: Lukasz Luba --- drivers/devfreq/event/exynos-ppmu.c | 61 +++++++++++++++++++++++++------------ include/linux/devfreq-event.h | 6 ++++ 2 files changed, 48 insertions(+), 19 deletions(-) diff --git a/drivers/devfreq/event/exynos-ppmu.c b/drivers/devfreq/event/exynos-ppmu.c index c61de0b..9f12201 100644 --- a/drivers/devfreq/event/exynos-ppmu.c +++ b/drivers/devfreq/event/exynos-ppmu.c @@ -154,9 +154,9 @@ static int exynos_ppmu_set_event(struct devfreq_event_dev *edev) if (ret < 0) return ret; - /* Set the event of Read/Write data count */ + /* Set the event of proper data type monitoring */ ret = regmap_write(info->regmap, PPMU_BEVTxSEL(id), - PPMU_RO_DATA_CNT | PPMU_WO_DATA_CNT); + edev->desc->data_type); if (ret < 0) return ret; @@ -368,23 +368,11 @@ static int exynos_ppmu_v2_set_event(struct devfreq_event_dev *edev) if (ret < 0) return ret; - /* Set the event of Read/Write data count */ - switch (id) { - case PPMU_PMNCNT0: - case PPMU_PMNCNT1: - case PPMU_PMNCNT2: - ret = regmap_write(info->regmap, PPMU_V2_CH_EVx_TYPE(id), - PPMU_V2_RO_DATA_CNT | PPMU_V2_WO_DATA_CNT); - if (ret < 0) - return ret; - break; - case PPMU_PMNCNT3: - ret = regmap_write(info->regmap, PPMU_V2_CH_EVx_TYPE(id), - PPMU_V2_EVT3_RW_DATA_CNT); - if (ret < 0) - return ret; - break; - } + /* Set the event of proper data type monitoring */ + ret = regmap_write(info->regmap, PPMU_V2_CH_EVx_TYPE(id), + edev->desc->data_type); + if (ret < 0) + return ret; /* Reset cycle counter/performance counter and enable PPMU */ ret = regmap_read(info->regmap, PPMU_V2_PMNC, &pmnc); @@ -508,6 +496,7 @@ static int of_get_devfreq_events(struct device_node *np, struct device *dev = info->dev; struct device_node *events_np, *node; int i, j, count; + int ret; events_np = of_get_child_by_name(np, "events"); if (!events_np) { @@ -544,6 +533,40 @@ static int of_get_devfreq_events(struct device_node *np, desc[j].driver_data = info; of_property_read_string(node, "event-name", &desc[j].name); + ret = of_property_read_u32(node, "event-data-type", + &desc[j].data_type); + if (!ret) { + /* Set the event of proper data type counting. + * Check if the data type has been defined in DT, + * use default if not. + */ + if (of_device_is_compatible(np, + "samsung,exynos-ppmu-v2")) { + struct devfreq_event_dev edev; + int id; + /* Not all registers take the same value for + * read+write data count. + */ + edev.desc = &desc[j]; + id = exynos_ppmu_find_ppmu_id(&edev); + + switch (id) { + case PPMU_PMNCNT0: + case PPMU_PMNCNT1: + case PPMU_PMNCNT2: + desc[j].data_type = PPMU_V2_RO_DATA_CNT + | PPMU_V2_WO_DATA_CNT; + break; + case PPMU_PMNCNT3: + desc[j].data_type = + PPMU_V2_EVT3_RW_DATA_CNT; + break; + } + } else { + desc[j].data_type = PPMU_RO_DATA_CNT | + PPMU_WO_DATA_CNT; + } + } j++; } diff --git a/include/linux/devfreq-event.h b/include/linux/devfreq-event.h index 4db00b0..cc160b1 100644 --- a/include/linux/devfreq-event.h +++ b/include/linux/devfreq-event.h @@ -81,14 +81,20 @@ struct devfreq_event_ops { * struct devfreq_event_desc - the descriptor of devfreq-event device * * @name : the name of devfreq-event device. + * @data_type : the data type which is going to be counted in the register. * @driver_data : the private data for devfreq-event driver. * @ops : the operation to control devfreq-event device. * * Each devfreq-event device is described with a this structure. * This structure contains the various data for devfreq-event device. + * The data_type describes what is going to be counted in the register. + * It might choose to count e.g. read requests, write data in bytes, etc. + * The full supported list of types is present in specyfic header in: + * include/dt-bindings/pmu/. */ struct devfreq_event_desc { const char *name; + u32 data_type; void *driver_data; const struct devfreq_event_ops *ops;