]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
s390/pai_crypto: Add common pai_read() function
authorThomas Richter <tmricht@linux.ibm.com>
Wed, 5 Nov 2025 14:38:53 +0000 (15:38 +0100)
committerHeiko Carstens <hca@linux.ibm.com>
Fri, 14 Nov 2025 10:30:06 +0000 (11:30 +0100)
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: Thomas Richter <tmricht@linux.ibm.com>
Reviewed-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
arch/s390/kernel/perf_pai_crypto.c

index 59b18f86b8ae86fcda862b0b92b94b367c2850e8..4eb1a09c36bd255ee5893b40f9c43c6b17d7f32d 100644 (file)
@@ -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);