Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4589201yba; Tue, 30 Apr 2019 00:34:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqzdO4C3K5TIilQPu1irOcdUhk/NellKpdDDIp+Kiq1kftyYNUEb4fvzfejSjXE5YwIXN6cS X-Received: by 2002:a17:902:5a3:: with SMTP id f32mr64632865plf.82.1556609684378; Tue, 30 Apr 2019 00:34:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556609684; cv=none; d=google.com; s=arc-20160816; b=s6h9FlySQYwQObWpxQUBEtJeCgXuZTVopLh/TA5zgbIMEZvjHs9EwHJwkx3KRbcMfR S8/5ObSu37kBpqEXo5uaCHwbGb9xhu9u6EwtKmqV7sxokTxYELmigNg7nTzVJLIDXkMj As/shejjILqteb5GhpZ0Gi5Qz9BUxswFLlgtTwovZP7pKRG0Kll4qslZ+wz50t1xOesV Ua22jm8sazCdDdpKSV/C2GdzqTWN0ePM+Hf8zpvjuSVIPiE9EZAVct1rnesiA0idFQw5 TB/KMunWrR/W0ngq0kub/oZBktZEYVthAxU69tv/49wucf2+Dkg6oXFHZ+jxt6im4WZd j1iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:dlp-filter:cms-type :content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:organization:from:cc:to:subject :dkim-signature:dkim-filter; bh=e34k/yVofLPdOOX6XLtJ1nlpeN11FL4odbRWUg/xKsE=; b=hAllFV9humxJxJ8VrOMhFe+Jsh6C8vGaMMzSZn6Fb6P2zNua1IZKasXky4jC25ciXl UPHS4YsKC+UFLIOkUb5Kctqh527VtKUKQmWLCfLedDIzHv1SO/zDk5Hb1rdVRL5U7ZME JDtThSKg+98heB4GLfmpGNEnbBKnXk+r1e9vnpqxstM1iQsKxBqo6+yzBqU/5YtGtiR4 fd8ABQfiFNDmfxdB5HBK74gn7F2fSJaGNbXNWta72QfW4XJu7ZMTH+fysikSM6IS5NOB X3IxJaILx2XBt7Oiu659prm5dxoE/ybtbPMSu9qcHmCYBEGZhTfX3vQxpcaueQ4pmfrP Hc8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=C09iPBFt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 n8si16563898pgq.568.2019.04.30.00.34.28; Tue, 30 Apr 2019 00:34:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=C09iPBFt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S1726384AbfD3HdY (ORCPT + 99 others); Tue, 30 Apr 2019 03:33:24 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:52719 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725996AbfD3HdX (ORCPT ); Tue, 30 Apr 2019 03:33:23 -0400 Received: from epcas1p1.samsung.com (unknown [182.195.41.45]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20190430073319epoutp042d5b8974da9c2acadfb6373eab25a4f8~aMC7u-D590822708227epoutp04R for ; Tue, 30 Apr 2019 07:33:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20190430073319epoutp042d5b8974da9c2acadfb6373eab25a4f8~aMC7u-D590822708227epoutp04R DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1556609599; bh=e34k/yVofLPdOOX6XLtJ1nlpeN11FL4odbRWUg/xKsE=; h=Subject:To:Cc:From:Date:In-Reply-To:References:From; b=C09iPBFtB/qBwwP9DqEKJ9SudDeEv6GjWNtohAVKHpEJ6GVl5nnPWW6ahJM7Aa4bZ XWpp4yeG0/tVgtlLp1OuEfRhafgUMbR4TGRnT1KC2KPKtRMux5cTV9J4wY1SpuffcU lldQbZrGFkFF2BmkCiyvnZEff4rta+W4z3fSHzdI= Received: from epsmges1p5.samsung.com (unknown [182.195.40.153]) by epcas1p1.samsung.com (KnoxPortal) with ESMTP id 20190430073316epcas1p115013adba89d57243ab2883855e9a86e~aMC4oH7Ue1033710337epcas1p13; Tue, 30 Apr 2019 07:33:16 +0000 (GMT) Received: from epcas1p1.samsung.com ( [182.195.41.45]) by epsmges1p5.samsung.com (Symantec Messaging Gateway) with SMTP id 32.37.04108.B3AF7CC5; Tue, 30 Apr 2019 16:33:15 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas1p3.samsung.com (KnoxPortal) with ESMTPA id 20190430073315epcas1p362e81786c257ddeace6be27afa1332fd~aMC38Hk5a0610506105epcas1p3E; Tue, 30 Apr 2019 07:33:15 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20190430073315epsmtrp23a1daa0b667fdf7f0025e5ccb8be04fe~aMC37Mfwh2858628586epsmtrp2K; Tue, 30 Apr 2019 07:33:15 +0000 (GMT) X-AuditID: b6c32a39-d0c179c00000100c-71-5cc7fa3b2f53 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 26.EA.03692.B3AF7CC5; Tue, 30 Apr 2019 16:33:15 +0900 (KST) Received: from [10.113.221.102] (unknown [10.113.221.102]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20190430073314epsmtip1c91c030ccb46c91972456cba60effb23~aMC3p85_71626316263epsmtip1V; Tue, 30 Apr 2019 07:33:14 +0000 (GMT) Subject: Re: [PATCH v3 2/4] drivers: devfreq: events: extend events by type of counted data To: Lukasz Luba , 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, kyungmin.park@samsung.com, m.szyprowski@samsung.com, s.nawrocki@samsung.com, myungjoo.ham@samsung.com, kgene@kernel.org, willy.mh.wolff.ml@gmail.com From: Chanwoo Choi Organization: Samsung Electronics Message-ID: <3557d507-0463-89de-4025-fbeaaef78bed@samsung.com> Date: Tue, 30 Apr 2019 16:34:30 +0900 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <1555681688-19643-3-git-send-email-l.luba@partner.samsung.com> Content-Language: en-US Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrNJsWRmVeSWpSXmKPExsWy7bCmrq71r+MxBt8+m1lsnLGe1WL+kXOs Fv2PXzNbnD+/gd3ibNMbdotbDTIWmx5fY7W4vGsOm8Xn3iOMFjPO72OyWHvkLrvF0usXmSxu N65gs2jde4Td4vCbdlaLbyceMToIeKyZt4bRY+esu+wem1Z1snlsXlLvcfDdHiaPvi2rGD0+ b5ILYI/KtslITUxJLVJIzUvOT8nMS7dV8g6Od443NTMw1DW0tDBXUshLzE21VXLxCdB1y8wB ul1JoSwxpxQoFJBYXKykb2dTlF9akqqQkV9cYquUWpCSU2BZoFecmFtcmpeul5yfa2VoYGBk ClSYkJ3xZEcbY8Em84qmSdvZGhi3aXQxcnJICJhINH59y9TFyMUhJL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ETCT+3m9j7mLk4hAS 2M0osXnBcnaIhKTEtItHgRIcQLawxOHDxRA1bxklrtycwAZSIywQKzF/8T5GkISIwFlGiUWT FrCDOMwCnxklpq+5DDX2PqPEo2ftTCAtbAJaEvtf3ABr5xdQlLj64zEjiM0rYCdx4chvVpB1 LAKqElueu4CERQUiJM68X8ECUSIocXLmEzCbU8BbYvrrLrAxzALqEn/mXWKGsMUlbj2ZzwRh y0s0b53NPIFReBaS9llIWmYhaZmFpGUBI8sqRsnUguLc9NxiwwLDvNRyveLE3OLSvHS95Pzc TYzg2NXS3MF4eUn8IUYBDkYlHl6Pd8dihFgTy4orcw8xSnAwK4nwehw/GiPEm5JYWZValB9f VJqTWnyIUZqDRUmc92nesUghgfTEktTs1NSC1CKYLBMHp1QDo7/77AWrLefJL88Q/P5VKPlu QOAN5ycu79L6ly6cxn1vbdBF27oLDdqCRuzzPVy3nZnziNPHWEqDqUFOqJe/SuhHqNRpKYdP l2+vsPrx6GaM3ZfZix1cjhdnZaydeXXTtNUBc16+zJyz4YdVBc93jpB/mYuyLu+9+77uqK4r 846dST+ftC1fb67EUpyRaKjFXFScCABR6hro2QIAAA== X-CMS-MailID: 20190430073315epcas1p362e81786c257ddeace6be27afa1332fd X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20190419134821eucas1p2461a27e28387ff2b87c149f09582d2a0 References: <1555681688-19643-1-git-send-email-l.luba@partner.samsung.com> <1555681688-19643-3-git-send-email-l.luba@partner.samsung.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Lukasz, On 19. 4. 19. 오후 10:48, Lukasz Luba wrote: > 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..073bf2c 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")) { It is not proper to compare the compatible string again in the device driver. Instead, you can define the ppmu device type as following and then use 'struct of_device_id' in order to identify the device type. enum exynos_ppmu_type { EXYNOS_TYPE_PPMU, EXYNOS_TYPE_PPMU_V2, }; static const struct of_device_id exynos_ppmu_id_match[] = { { .compatible = "samsung,exynos-ppmu", - .data = (void *)&exynos_ppmu_ops, + .data = (void *)EXYNOS_TYPE_PPMU, }, { .compatible = "samsung,exynos-ppmu-v2", - .data = (void *)&exynos_ppmu_v2_ops, + .data = (void *)EXYNOS_TYPE_PPMU_V2, }, The many device drivers in the mainline uses this code in order to get the device type. You can refer the example in the drivers/mfd/max14577.c. (snip) Example, I add the example. but it is not tested. --- a/drivers/devfreq/event/exynos-ppmu.c +++ b/drivers/devfreq/event/exynos-ppmu.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -23,6 +24,11 @@ #include "exynos-ppmu.h" +enum exynos_ppmu_type { + EXYNOS_TYPE_PPMU, + EXYNOS_TYPE_PPMU_V2, +}; + struct exynos_ppmu_data { struct clk *clk; }; @@ -36,6 +42,7 @@ struct exynos_ppmu { struct regmap *regmap; struct exynos_ppmu_data ppmu; + enum exynos_ppmu_type ppmu_type; }; #define PPMU_EVENT(name) \ /* Reset cycle counter/performance counter and enable PPMU */ ret = regmap_read(info->regmap, PPMU_V2_PMNC, &pmnc); @@ -483,31 +476,23 @@ static const struct devfreq_event_ops exynos_ppmu_v2_ops = { static const struct of_device_id exynos_ppmu_id_match[] = { { .compatible = "samsung,exynos-ppmu", - .data = (void *)&exynos_ppmu_ops, + .data = (void *)EXYNOS_TYPE_PPMU, }, { .compatible = "samsung,exynos-ppmu-v2", - .data = (void *)&exynos_ppmu_v2_ops, + .data = (void *)EXYNOS_TYPE_PPMU_V2, }, { /* sentinel */ }, }; MODULE_DEVICE_TABLE(of, exynos_ppmu_id_match); -static struct devfreq_event_ops *exynos_bus_get_ops(struct device_node *np) -{ - const struct of_device_id *match; - - match = of_match_node(exynos_ppmu_id_match, np); - return (struct devfreq_event_ops *)match->data; -} - static int of_get_devfreq_events(struct device_node *np, struct exynos_ppmu *info) { struct devfreq_event_desc *desc; - struct devfreq_event_ops *event_ops; struct device *dev = info->dev; struct device_node *events_np, *node; int i, j, count; events_np = of_get_child_by_name(np, "events"); if (!events_np) { @@ -515,7 +500,6 @@ static int of_get_devfreq_events(struct device_node *np, "failed to get child node of devfreq-event devices\n"); return -EINVAL; } - event_ops = exynos_bus_get_ops(np); count = of_get_child_count(events_np); desc = devm_kcalloc(dev, count, sizeof(*desc), GFP_KERNEL); @@ -540,11 +524,38 @@ static int of_get_devfreq_events(struct device_node *np, continue; } - desc[j].ops = event_ops; + switch (info->ppmu_type) { + case EXYNOS_TYPE_PPMU: + desc[j].ops = &exynos_ppmu_ops; + break; + case EXYNOS_TYPE_PPMU_V2: + desc[j].ops = &exynos_ppmu_v2_ops; + break; + } + -- Best Regards, Chanwoo Choi Samsung Electronics