Skip to content

Commit

Permalink
perf: stm32: support the pmu ".read" ops
Browse files Browse the repository at this point in the history
Implement the "event read" ops which is called, for example, when
"perf stat" is called with the "-I" option.

Signed-off-by: Fabien Dessenne <[email protected]>
Change-Id: Ia0a1e16a117b580103bd8f14c72c11471d753488
Reviewed-on: https://gerrit.st.com/c/mpu/oe/st/linux-stm32/+/225339
Reviewed-by: CITOOLS <[email protected]>
Reviewed-by: CIBUILD <[email protected]>
Reviewed-by: Gerald BAEZA <[email protected]>
  • Loading branch information
Fabien Dessenne authored and fourmone committed Jul 5, 2022
1 parent bf42f0b commit 94249eb
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions drivers/perf/stm32_ddr_pmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ static void stm32_ddr_pmu_event_configure(struct perf_event *event)
}
}

static void stm32_ddr_pmu_event_read(struct perf_event *event)
static void stm32_ddr_pmu_event_update(struct perf_event *event)
{
struct stm32_ddr_pmu *stm32_ddr_pmu = pmu_to_stm32_ddr_pmu(event->pmu);
unsigned long config_base = event->hw.config_base;
Expand Down Expand Up @@ -120,6 +120,16 @@ static void stm32_ddr_pmu_event_read(struct perf_event *event)
local64_add(val & mask, &event->count);
}

static void stm32_ddr_pmu_event_read(struct perf_event *event)
{
struct stm32_ddr_pmu *stm32_ddr_pmu = pmu_to_stm32_ddr_pmu(event->pmu);

hrtimer_start(&stm32_ddr_pmu->hrtimer, stm32_ddr_pmu->poll_period,
HRTIMER_MODE_REL_PINNED);

stm32_ddr_pmu_event_update(event);
}

static void stm32_ddr_pmu_event_start(struct perf_event *event, int flags)
{
struct stm32_ddr_pmu *stm32_ddr_pmu = pmu_to_stm32_ddr_pmu(event->pmu);
Expand Down Expand Up @@ -165,7 +175,7 @@ static void stm32_ddr_pmu_event_stop(struct perf_event *event, int flags)
hw->state |= PERF_HES_STOPPED;

if (flags & PERF_EF_UPDATE) {
stm32_ddr_pmu_event_read(event);
stm32_ddr_pmu_event_update(event);
hw->state |= PERF_HES_UPTODATE;
}
}
Expand Down Expand Up @@ -260,7 +270,7 @@ static enum hrtimer_restart stm32_ddr_pmu_poll(struct hrtimer *hrtimer)

for (i = 0; i < PMU_NR_COUNTERS; i++)
if (stm32_ddr_pmu->events[i])
stm32_ddr_pmu_event_read(stm32_ddr_pmu->events[i]);
stm32_ddr_pmu_event_update(stm32_ddr_pmu->events[i]);

hrtimer_forward_now(hrtimer, stm32_ddr_pmu->poll_period);

Expand Down Expand Up @@ -362,6 +372,7 @@ static int stm32_ddr_pmu_device_probe(struct platform_device *pdev)
.stop = stm32_ddr_pmu_event_stop,
.add = stm32_ddr_pmu_event_add,
.del = stm32_ddr_pmu_event_del,
.read = stm32_ddr_pmu_event_read,
.event_init = stm32_ddr_pmu_event_init,
.attr_groups = stm32_ddr_pmu_attr_groups,
};
Expand Down

0 comments on commit 94249eb

Please sign in to comment.