From 47b7478583aa0ba7b85a88d5ece78a21a7c846c5 Mon Sep 17 00:00:00 2001 From: Thomas Richter Date: Tue, 22 Jan 2019 10:55:18 +0000 Subject: [PATCH] s390/cpum_cf: Handle EBUSY return code from CPU counter facility reservation Rservation of the CPU Measurement Counter facility may fail if it is already in use by the cf_diag device driver. This is indicated by a non zero return code (-EBUSY). However this return code is ignored and the counter facility may be used in parallel by different device drivers. Handle the failing reservation and return an error to the caller. Signed-off-by: Thomas Richter Signed-off-by: Martin Schwidefsky --- arch/s390/kernel/perf_cpum_cf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/s390/kernel/perf_cpum_cf.c b/arch/s390/kernel/perf_cpum_cf.c index 670ff98acb62..e1c54d28713a 100644 --- a/arch/s390/kernel/perf_cpum_cf.c +++ b/arch/s390/kernel/perf_cpum_cf.c @@ -197,7 +197,7 @@ static int __hw_perf_event_init(struct perf_event *event) struct perf_event_attr *attr = &event->attr; struct hw_perf_event *hwc = &event->hw; enum cpumf_ctr_set set; - int err; + int err = 0; u64 ev; switch (attr->type) { @@ -273,6 +273,8 @@ static int __hw_perf_event_init(struct perf_event *event) atomic_inc(&num_events); mutex_unlock(&pmc_reserve_mutex); } + if (err) + return err; event->destroy = hw_perf_event_destroy; /* Finally, validate version and authorization of the counter set */