2019-04-18 13:40:07

by Lukasz Luba

[permalink] [raw]
Subject: [PATCH v2 0/4] Exynos Performance Monitoring Counters enhancements

Hi all,

This patch set extends PPMU on Samsung Exynos by choosing type of data
which shell be counter in the PPMU registers.
It is possible to count e.g. read or write requests, read or write data
or latency.
A new field has been added in the DT 'event' node called 'event-data-type'.
It is them used during the setup of the counter. In the prevoius
implementation there was always one option used: count read+write data.
Sometimes we need more precised information and this patch set tries to
address it.

Changes:
v2:
- removed new entry in MAINTAINERS file as suggested by Bartek Zolnierkiewicz
and added new file to existing list for devfreq events
- added in the dt-bindings/pmu/exynos_ppmu.h 2 new entries for RO and WO for
counters in Exynos5433
- changed initialization with default values when data_type is not provided
in DT (as sugessted by Chanwoo)
- added 4th patch which adds 'event-data-type' to 'event' node for Exynos4412
PPMU events (asked by Chanwoo)

Regards,
Lukasz Luba

Lukasz Luba (4):
include: dt-bindings: add Performance Monitoring Unit for Exynos
drivers: devfreq: events: extend events by type of counted data
Documentation: devicetree: add PPMU events description
DT: arm: exynos4412: add event data type which is monitored

.../bindings/devfreq/event/exynos-ppmu.txt | 18 +++++++
MAINTAINERS | 1 +
arch/arm/boot/dts/exynos4412-ppmu-common.dtsi | 10 ++++
drivers/devfreq/event/exynos-ppmu.c | 61 +++++++++++++++-------
include/dt-bindings/pmu/exynos_ppmu.h | 26 +++++++++
include/linux/devfreq-event.h | 6 +++
6 files changed, 103 insertions(+), 19 deletions(-)
create mode 100644 include/dt-bindings/pmu/exynos_ppmu.h

--
2.7.4


2019-04-18 13:40:17

by Lukasz Luba

[permalink] [raw]
Subject: [PATCH v2 4/4] DT: arm: exynos4412: add event data type which is monitored

The patch adds new field in the PPMU event which shows explicitly
what kind of data the event is monitoring. It is possible to change it
using defined values in exynos_ppmu.h file.

Signed-off-by: Lukasz Luba <[email protected]>
---
arch/arm/boot/dts/exynos4412-ppmu-common.dtsi | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/arch/arm/boot/dts/exynos4412-ppmu-common.dtsi b/arch/arm/boot/dts/exynos4412-ppmu-common.dtsi
index 3a3b2fa..549faba 100644
--- a/arch/arm/boot/dts/exynos4412-ppmu-common.dtsi
+++ b/arch/arm/boot/dts/exynos4412-ppmu-common.dtsi
@@ -6,12 +6,16 @@
* Author: Chanwoo Choi <[email protected]>
*/

+#include <dt-bindings/pmu/exynos_ppmu.h>
+
&ppmu_dmc0 {
status = "okay";

events {
ppmu_dmc0_3: ppmu-event3-dmc0 {
event-name = "ppmu-event3-dmc0";
+ event-data-type = <(PPMU_RO_DATA_CNT |
+ PPMU_WO_DATA_CNT)>;
};
};
};
@@ -22,6 +26,8 @@
events {
ppmu_dmc1_3: ppmu-event3-dmc1 {
event-name = "ppmu-event3-dmc1";
+ event-data-type = <(PPMU_RO_DATA_CNT |
+ PPMU_WO_DATA_CNT)>;
};
};
};
@@ -32,6 +38,8 @@
events {
ppmu_leftbus_3: ppmu-event3-leftbus {
event-name = "ppmu-event3-leftbus";
+ event-data-type = <(PPMU_RO_DATA_CNT |
+ PPMU_WO_DATA_CNT)>;
};
};
};
@@ -42,6 +50,8 @@
events {
ppmu_rightbus_3: ppmu-event3-rightbus {
event-name = "ppmu-event3-rightbus";
+ event-data-type = <(PPMU_RO_DATA_CNT |
+ PPMU_WO_DATA_CNT)>;
};
};
};
--
2.7.4

2019-04-18 13:40:33

by Lukasz Luba

[permalink] [raw]
Subject: [PATCH v2 1/4] include: dt-bindings: add Performance Monitoring Unit for Exynos

This patch add support of a new feature which can be used in DT:
Performance Monitoring Unit with defined event data type.
In this patch the event data types are defined for Exynos PPMU.
The patch also updates the MAINTAINERS file accordingly and
adds the header file to devfreq event subsystem.

Signed-off-by: Lukasz Luba <[email protected]>
---
MAINTAINERS | 1 +
include/dt-bindings/pmu/exynos_ppmu.h | 26 ++++++++++++++++++++++++++
2 files changed, 27 insertions(+)
create mode 100644 include/dt-bindings/pmu/exynos_ppmu.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 3671fde..1ba4b9b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4560,6 +4560,7 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/mzx/devfreq.git
S: Supported
F: drivers/devfreq/event/
F: drivers/devfreq/devfreq-event.c
+F: include/dt-bindings/pmu/exynos_ppmu.h
F: include/linux/devfreq-event.h
F: Documentation/devicetree/bindings/devfreq/event/

diff --git a/include/dt-bindings/pmu/exynos_ppmu.h b/include/dt-bindings/pmu/exynos_ppmu.h
new file mode 100644
index 0000000..08fdce9
--- /dev/null
+++ b/include/dt-bindings/pmu/exynos_ppmu.h
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Samsung Exynos PPMU event types for counting in regs
+ *
+ * Copyright (c) 2019, Samsung
+ * Author: Lukasz Luba <[email protected]>
+ */
+
+#ifndef __DT_BINDINGS_PMU_EXYNOS_PPMU_H
+#define __DT_BINDINGS_PMU_EXYNOS_PPMU_H
+
+
+#define PPMU_RO_BUSY_CYCLE_CNT 0x0
+#define PPMU_WO_BUSY_CYCLE_CNT 0x1
+#define PPMU_RW_BUSY_CYCLE_CNT 0x2
+#define PPMU_RO_REQUEST_CNT 0x3
+#define PPMU_WO_REQUEST_CNT 0x4
+#define PPMU_RO_DATA_CNT 0x5
+#define PPMU_WO_DATA_CNT 0x6
+#define PPMU_RO_LATENCY 0x12
+#define PPMU_WO_LATENCY 0x16
+#define PPMU_V2_RO_DATA_CNT 0x4
+#define PPMU_V2_WO_DATA_CNT 0x5
+#define PPMU_V2_EVT3_RW_DATA_CNT 0x22
+
+#endif
--
2.7.4

2019-04-18 13:40:41

by Lukasz Luba

[permalink] [raw]
Subject: [PATCH v2 3/4] Documentation: devicetree: add PPMU events description

Extend the documenation by events description with new 'event-data-type'
field. Add example how the event might be defined in DT.

Signed-off-by: Lukasz Luba <[email protected]>
---
.../devicetree/bindings/devfreq/event/exynos-ppmu.txt | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)

diff --git a/Documentation/devicetree/bindings/devfreq/event/exynos-ppmu.txt b/Documentation/devicetree/bindings/devfreq/event/exynos-ppmu.txt
index 3e36c1d..47feb5f 100644
--- a/Documentation/devicetree/bindings/devfreq/event/exynos-ppmu.txt
+++ b/Documentation/devicetree/bindings/devfreq/event/exynos-ppmu.txt
@@ -145,3 +145,21 @@ Example3 : PPMUv2 nodes in exynos5433.dtsi are listed below.
reg = <0x104d0000 0x2000>;
status = "disabled";
};
+
+The 'event' type specified in the PPMU node defines 'event-name'
+which also contains 'id' number and optionally 'event-data-type'.
+
+Example:
+
+ events {
+ ppmu_leftbus_0: ppmu-event0-leftbus {
+ event-name = "ppmu-event0-leftbus";
+ event-data-type = <PPMU_RO_DATA_CNT>;
+ };
+ };
+
+The 'event-data-type' defines the type of data which shell be counted
+by the counter. You can check include/dt-bindings/pmu/exynos_ppmu.h for
+all possible type, i.e. count read requests, count write data in bytes,
+etc. This field is optional and when it is missing, the driver code will
+use default data type.
--
2.7.4

2019-04-18 13:41:34

by Lukasz Luba

[permalink] [raw]
Subject: [PATCH v2 2/4] drivers: devfreq: events: extend events by type of counted data

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 <[email protected]>
---
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;
--
2.7.4

2019-04-19 18:24:57

by Lukasz Luba

[permalink] [raw]
Subject: Re: [PATCH v2 2/4] drivers: devfreq: events: extend events by type of counted data

Hi Chanwoo,

please ignore this patch there is a comment below.
It wrongly sets the default value.

On 4/18/19 3:38 PM, 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 <[email protected]>
> ---
> 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) {
It should be: if (ret)
then it means we do not have a value in DT and we are using
our defaults taking into account the right register type.

I am going to send v3 with this fix.

Regards,
Lukasz
> + /* 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;
>