Commit 8f6116fd authored by Thomas Richter's avatar Thomas Richter Committed by Heiko Carstens
Browse files

s390/pai_crypto: Add common pai_read() function



To support one common PAI PMU device driver which handles
both PMUs pai_crypto and pai_ext, use a common naming scheme
for structures and variables suitable for both device drivers.

Add a common usable function pai_read() to read counter values.
The function expects a PAI PMU specific read function as second
parameter.

Signed-off-by: default avatarThomas Richter <tmricht@linux.ibm.com>
Reviewed-by: default avatarJan Polensky <japo@linux.ibm.com>
Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
parent 74466e87
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -365,18 +365,23 @@ static int paicrypt_event_init(struct perf_event *event)
	return rc;
}

static void paicrypt_read(struct perf_event *event)
static void pai_read(struct perf_event *event,
		     u64 (*fct)(struct perf_event *event))
{
	u64 prev, new, delta;

	prev = local64_read(&event->hw.prev_count);
	new = paicrypt_getall(event);
	new = fct(event);
	local64_set(&event->hw.prev_count, new);
	delta = (prev <= new) ? new - prev
			      : (-1ULL - prev) + new + 1;	 /* overflow */
	delta = (prev <= new) ? new - prev : (-1ULL - prev) + new + 1;
	local64_add(delta, &event->count);
}

static void paicrypt_read(struct perf_event *event)
{
	pai_read(event, paicrypt_getall);
}

static void paicrypt_start(struct perf_event *event, int flags)
{
	struct pai_mapptr *mp = this_cpu_ptr(pai_root.mapptr);