Commit cb1259b7 authored by Thomas Richter's avatar Thomas Richter Committed by Alexander Gordeev

s390/pai: rework paiXXX_start and paiXXX_stop functions

The PAI crypto counter and PAI NNPA counters start and stop functions
are streamlined. Move the conditions to invoke start and stop functions
to its respective function body and call them unconditionally.
The start and stop functions now determine how to proceed.
No functional change.
Signed-off-by: default avatarThomas Richter <tmricht@linux.ibm.com>
Acked-by: default avatarMete Durlu <meted@linux.ibm.com>
Signed-off-by: default avatarAlexander Gordeev <agordeev@linux.ibm.com>
parent 0578a541
......@@ -317,10 +317,14 @@ static void paicrypt_start(struct perf_event *event, int flags)
* Events are added, deleted and re-added when 2 or more events
* are active at the same time.
*/
if (!event->hw.last_tag) {
event->hw.last_tag = 1;
sum = paicrypt_getall(event); /* Get current value */
local64_set(&event->hw.prev_count, sum);
if (!event->attr.sample_period) { /* Counting */
if (!event->hw.last_tag) {
event->hw.last_tag = 1;
sum = paicrypt_getall(event); /* Get current value */
local64_set(&event->hw.prev_count, sum);
}
} else { /* Sampling */
perf_sched_cb_inc(event->pmu);
}
}
......@@ -336,19 +340,18 @@ static int paicrypt_add(struct perf_event *event, int flags)
local_ctl_set_bit(0, CR0_CRYPTOGRAPHY_COUNTER_BIT);
}
cpump->event = event;
if (flags & PERF_EF_START && !event->attr.sample_period) {
/* Only counting needs initial counter value */
if (flags & PERF_EF_START)
paicrypt_start(event, PERF_EF_RELOAD);
}
event->hw.state = 0;
if (event->attr.sample_period)
perf_sched_cb_inc(event->pmu);
return 0;
}
static void paicrypt_stop(struct perf_event *event, int flags)
{
paicrypt_read(event);
if (!event->attr.sample_period) /* Counting */
paicrypt_read(event);
else /* Sampling */
perf_sched_cb_dec(event->pmu);
event->hw.state = PERF_HES_STOPPED;
}
......@@ -357,11 +360,7 @@ static void paicrypt_del(struct perf_event *event, int flags)
struct paicrypt_mapptr *mp = this_cpu_ptr(paicrypt_root.mapptr);
struct paicrypt_map *cpump = mp->mapptr;
if (event->attr.sample_period)
perf_sched_cb_dec(event->pmu);
if (!event->attr.sample_period)
/* Only counting needs to read counter */
paicrypt_stop(event, PERF_EF_UPDATE);
paicrypt_stop(event, PERF_EF_UPDATE);
if (--cpump->active_events == 0) {
local_ctl_clear_bit(0, CR0_CRYPTOGRAPHY_COUNTER_BIT);
WRITE_ONCE(S390_lowcore.ccd, 0);
......
......@@ -321,11 +321,15 @@ static void paiext_start(struct perf_event *event, int flags)
{
u64 sum;
if (event->hw.last_tag)
return;
event->hw.last_tag = 1;
sum = paiext_getall(event); /* Get current value */
local64_set(&event->hw.prev_count, sum);
if (!event->attr.sample_period) { /* Counting */
if (!event->hw.last_tag) {
event->hw.last_tag = 1;
sum = paiext_getall(event); /* Get current value */
local64_set(&event->hw.prev_count, sum);
}
} else { /* Sampling */
perf_sched_cb_inc(event->pmu);
}
}
static int paiext_add(struct perf_event *event, int flags)
......@@ -342,21 +346,19 @@ static int paiext_add(struct perf_event *event, int flags)
debug_sprintf_event(paiext_dbg, 4, "%s 1508 %llx acc %llx\n",
__func__, S390_lowcore.aicd, pcb->acc);
}
if (flags & PERF_EF_START && !event->attr.sample_period) {
/* Only counting needs initial counter value */
cpump->event = event;
if (flags & PERF_EF_START)
paiext_start(event, PERF_EF_RELOAD);
}
event->hw.state = 0;
if (event->attr.sample_period) {
cpump->event = event;
perf_sched_cb_inc(event->pmu);
}
return 0;
}
static void paiext_stop(struct perf_event *event, int flags)
{
paiext_read(event);
if (!event->attr.sample_period) /* Counting */
paiext_read(event);
else /* Sampling */
perf_sched_cb_dec(event->pmu);
event->hw.state = PERF_HES_STOPPED;
}
......@@ -366,12 +368,7 @@ static void paiext_del(struct perf_event *event, int flags)
struct paiext_map *cpump = mp->mapptr;
struct paiext_cb *pcb = cpump->paiext_cb;
if (event->attr.sample_period)
perf_sched_cb_dec(event->pmu);
if (!event->attr.sample_period) {
/* Only counting needs to read counter */
paiext_stop(event, PERF_EF_UPDATE);
}
paiext_stop(event, PERF_EF_UPDATE);
if (--cpump->active_events == 0) {
/* Disable CPU instruction lookup for PAIE1 control block */
local_ctl_clear_bit(0, CR0_PAI_EXTENSION_BIT);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment