+++ /dev/null
-From 87a0b1ca036b032bcf1626ca015b8d8948b1096d Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Mon, 30 Oct 2023 11:41:33 +0100
-Subject: s390/pai: cleanup event initialization
-
-From: Thomas Richter <tmricht@linux.ibm.com>
-
-[ Upstream commit 4711b7b8f99583f6105a33e91f106125134beacb ]
-
-Setting event::hw.last_tag to zero is not necessary. The memory
-for each event is dynamically allocated by the kernel common code and
-initialized to zero already. Remove this unnecessary assignment.
-Move the comment to function paicrypt_start() for clarification.
-
-Suggested-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
-Acked-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
-Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
-Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
-Stable-dep-of: e9f3af02f639 ("s390/pai: fix sampling event removal for PMU device driver")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- arch/s390/kernel/perf_pai_crypto.c | 11 +++++------
- arch/s390/kernel/perf_pai_ext.c | 1 -
- 2 files changed, 5 insertions(+), 7 deletions(-)
-
-diff --git a/arch/s390/kernel/perf_pai_crypto.c b/arch/s390/kernel/perf_pai_crypto.c
-index 4b773653a951b..3758e972bb5f9 100644
---- a/arch/s390/kernel/perf_pai_crypto.c
-+++ b/arch/s390/kernel/perf_pai_crypto.c
-@@ -207,12 +207,6 @@ static int paicrypt_event_init(struct perf_event *event)
- if (rc)
- return rc;
-
-- /* Event initialization sets last_tag to 0. When later on the events
-- * are deleted and re-added, do not reset the event count value to zero.
-- * Events are added, deleted and re-added when 2 or more events
-- * are active at the same time.
-- */
-- event->hw.last_tag = 0;
- event->destroy = paicrypt_event_destroy;
-
- if (a->sample_period) {
-@@ -246,6 +240,11 @@ static void paicrypt_start(struct perf_event *event, int flags)
- {
- u64 sum;
-
-+ /* Event initialization sets last_tag to 0. When later on the events
-+ * are deleted and re-added, do not reset the event count value to zero.
-+ * 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 */
-diff --git a/arch/s390/kernel/perf_pai_ext.c b/arch/s390/kernel/perf_pai_ext.c
-index 663cd37f8b293..53915401c3f63 100644
---- a/arch/s390/kernel/perf_pai_ext.c
-+++ b/arch/s390/kernel/perf_pai_ext.c
-@@ -267,7 +267,6 @@ static int paiext_event_init(struct perf_event *event)
- rc = paiext_alloc(a, event);
- if (rc)
- return rc;
-- event->hw.last_tag = 0;
- event->destroy = paiext_event_destroy;
-
- if (a->sample_period) {
---
-2.43.0
-
+++ /dev/null
-From b84fb561495269f13d0648b2172d33be7727a059 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Thu, 29 Feb 2024 15:00:28 +0100
-Subject: s390/pai: fix sampling event removal for PMU device driver
-
-From: Thomas Richter <tmricht@linux.ibm.com>
-
-[ Upstream commit e9f3af02f63909f41b43c28330434cc437639c5c ]
-
-In case of a sampling event, the PAI PMU device drivers need a
-reference to this event. Currently to PMU device driver reference
-is removed when a sampling event is destroyed. This may lead to
-situations where the reference of the PMU device driver is removed
-while being used by a different sampling event.
-Reset the event reference pointer of the PMU device driver when
-a sampling event is deleted and before the next one might be added.
-
-Fixes: 39d62336f5c1 ("s390/pai: add support for cryptography counters")
-Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
-Acked-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
-Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- arch/s390/kernel/perf_pai_crypto.c | 10 +++++++---
- arch/s390/kernel/perf_pai_ext.c | 10 +++++++---
- 2 files changed, 14 insertions(+), 6 deletions(-)
-
-diff --git a/arch/s390/kernel/perf_pai_crypto.c b/arch/s390/kernel/perf_pai_crypto.c
-index ba2d2e61df747..93ccb5c955530 100644
---- a/arch/s390/kernel/perf_pai_crypto.c
-+++ b/arch/s390/kernel/perf_pai_crypto.c
-@@ -53,7 +53,6 @@ static void paicrypt_event_destroy(struct perf_event *event)
- {
- struct paicrypt_map *cpump = per_cpu_ptr(&paicrypt_map, event->cpu);
-
-- cpump->event = NULL;
- static_branch_dec(&pai_key);
- mutex_lock(&pai_reserve_mutex);
- debug_sprintf_event(cfm_dbg, 5, "%s event %#llx cpu %d users %d"
-@@ -275,10 +274,15 @@ static int paicrypt_add(struct perf_event *event, int flags)
-
- static void paicrypt_stop(struct perf_event *event, int flags)
- {
-- if (!event->attr.sample_period) /* Counting */
-+ struct paicrypt_mapptr *mp = this_cpu_ptr(paicrypt_root.mapptr);
-+ struct paicrypt_map *cpump = mp->mapptr;
-+
-+ if (!event->attr.sample_period) { /* Counting */
- paicrypt_read(event);
-- else /* Sampling */
-+ } else { /* Sampling */
- perf_sched_cb_dec(event->pmu);
-+ cpump->event = NULL;
-+ }
- event->hw.state = PERF_HES_STOPPED;
- }
-
-diff --git a/arch/s390/kernel/perf_pai_ext.c b/arch/s390/kernel/perf_pai_ext.c
-index 09aebfcf679df..bbaad21123d38 100644
---- a/arch/s390/kernel/perf_pai_ext.c
-+++ b/arch/s390/kernel/perf_pai_ext.c
-@@ -128,7 +128,6 @@ static void paiext_event_destroy(struct perf_event *event)
- struct paiext_map *cpump = mp->mapptr;
-
- mutex_lock(&paiext_reserve_mutex);
-- cpump->event = NULL;
- if (refcount_dec_and_test(&cpump->refcnt)) /* Last reference gone */
- paiext_free(mp);
- paiext_root_free();
-@@ -361,10 +360,15 @@ static int paiext_add(struct perf_event *event, int flags)
-
- static void paiext_stop(struct perf_event *event, int flags)
- {
-- if (!event->attr.sample_period) /* Counting */
-+ struct paiext_mapptr *mp = this_cpu_ptr(paiext_root.mapptr);
-+ struct paiext_map *cpump = mp->mapptr;
-+
-+ if (!event->attr.sample_period) { /* Counting */
- paiext_read(event);
-- else /* Sampling */
-+ } else { /* Sampling */
- perf_sched_cb_dec(event->pmu);
-+ cpump->event = NULL;
-+ }
- event->hw.state = PERF_HES_STOPPED;
- }
-
---
-2.43.0
-
+++ /dev/null
-From 55b461e5f747fc1f06b6471715d60394d34dfb78 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 11 Oct 2023 12:09:30 +0200
-Subject: s390/pai: initialize event count once at initialization
-
-From: Thomas Richter <tmricht@linux.ibm.com>
-
-[ Upstream commit b286997e83dcf7b498329a66a8a22fc8a5bf50f0 ]
-
-Event count value is initialized and set to zero in function
-paicrypt_start(). This function is called once per CPU when an
-event is started on that CPU. This leads to event count value
-being set to zero as many times as there are online CPUs.
-This is not necessary. The event count value is bound to the event
-and it is sufficient to initialize the event counter once at
-event creation time. This is done when the event structure
-is dynamicly allocated with __GFP_ZERO flag. This sets
-member count to zero.
-
-Acked-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
-Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
-Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
-Stable-dep-of: e9f3af02f639 ("s390/pai: fix sampling event removal for PMU device driver")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- arch/s390/kernel/perf_pai_crypto.c | 1 -
- arch/s390/kernel/perf_pai_ext.c | 1 -
- 2 files changed, 2 deletions(-)
-
-diff --git a/arch/s390/kernel/perf_pai_crypto.c b/arch/s390/kernel/perf_pai_crypto.c
-index a7e815563f411..7eb138b07e7be 100644
---- a/arch/s390/kernel/perf_pai_crypto.c
-+++ b/arch/s390/kernel/perf_pai_crypto.c
-@@ -250,7 +250,6 @@ static void paicrypt_start(struct perf_event *event, int flags)
- if (!event->hw.last_tag) {
- event->hw.last_tag = 1;
- sum = paicrypt_getall(event); /* Get current value */
-- local64_set(&event->count, 0);
- local64_set(&event->hw.prev_count, sum);
- }
- }
-diff --git a/arch/s390/kernel/perf_pai_ext.c b/arch/s390/kernel/perf_pai_ext.c
-index d6bc919530143..663cd37f8b293 100644
---- a/arch/s390/kernel/perf_pai_ext.c
-+++ b/arch/s390/kernel/perf_pai_ext.c
-@@ -333,7 +333,6 @@ static void paiext_start(struct perf_event *event, int flags)
- event->hw.last_tag = 1;
- sum = paiext_getall(event); /* Get current value */
- local64_set(&event->hw.prev_count, sum);
-- local64_set(&event->count, 0);
- }
-
- static int paiext_add(struct perf_event *event, int flags)
---
-2.43.0
-
+++ /dev/null
-From f0ecea58cbe224aa614e12a7d24d14cfb5e6ef10 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Thu, 20 Oct 2022 11:55:52 +0200
-Subject: s390/pai: rename structure member users to active_events
-
-From: Thomas Richter <tmricht@linux.ibm.com>
-
-[ Upstream commit 58354c7d35d35dd119ada18ff84a6686ccc8743f ]
-
-Rename structure member users to active_events to make it consistent
-with PMU pai_ext. Also use the same prefix syntax for increment and
-decrement operators in both PMUs.
-
-Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
-Acked-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
-Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
-Stable-dep-of: e9f3af02f639 ("s390/pai: fix sampling event removal for PMU device driver")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- arch/s390/kernel/perf_pai_crypto.c | 12 ++++++------
- 1 file changed, 6 insertions(+), 6 deletions(-)
-
-diff --git a/arch/s390/kernel/perf_pai_crypto.c b/arch/s390/kernel/perf_pai_crypto.c
-index 68a6132937f3e..a7e815563f411 100644
---- a/arch/s390/kernel/perf_pai_crypto.c
-+++ b/arch/s390/kernel/perf_pai_crypto.c
-@@ -35,7 +35,7 @@ struct pai_userdata {
- struct paicrypt_map {
- unsigned long *page; /* Page for CPU to store counters */
- struct pai_userdata *save; /* Page to store no-zero counters */
-- unsigned int users; /* # of PAI crypto users */
-+ unsigned int active_events; /* # of PAI crypto users */
- unsigned int refcnt; /* Reference count mapped buffers */
- enum paievt_mode mode; /* Type of event */
- struct perf_event *event; /* Perf event for sampling */
-@@ -58,8 +58,8 @@ static void paicrypt_event_destroy(struct perf_event *event)
- mutex_lock(&pai_reserve_mutex);
- debug_sprintf_event(cfm_dbg, 5, "%s event %#llx cpu %d users %d"
- " mode %d refcnt %d\n", __func__,
-- event->attr.config, event->cpu, cpump->users,
-- cpump->mode, cpump->refcnt);
-+ event->attr.config, event->cpu,
-+ cpump->active_events, cpump->mode, cpump->refcnt);
- if (!--cpump->refcnt) {
- debug_sprintf_event(cfm_dbg, 4, "%s page %#lx save %p\n",
- __func__, (unsigned long)cpump->page,
-@@ -174,7 +174,7 @@ static int paicrypt_busy(struct perf_event_attr *a, struct paicrypt_map *cpump)
- }
- debug_sprintf_event(cfm_dbg, 5, "%s sample_period %#llx users %d"
- " mode %d refcnt %d page %#lx save %p rc %d\n",
-- __func__, a->sample_period, cpump->users,
-+ __func__, a->sample_period, cpump->active_events,
- cpump->mode, cpump->refcnt,
- (unsigned long)cpump->page, cpump->save, rc);
- mutex_unlock(&pai_reserve_mutex);
-@@ -260,7 +260,7 @@ static int paicrypt_add(struct perf_event *event, int flags)
- struct paicrypt_map *cpump = this_cpu_ptr(&paicrypt_map);
- unsigned long ccd;
-
-- if (cpump->users++ == 0) {
-+ if (++cpump->active_events == 1) {
- ccd = virt_to_phys(cpump->page) | PAI_CRYPTO_KERNEL_OFFSET;
- WRITE_ONCE(S390_lowcore.ccd, ccd);
- __ctl_set_bit(0, 50);
-@@ -291,7 +291,7 @@ static void paicrypt_del(struct perf_event *event, int flags)
- if (!event->attr.sample_period)
- /* Only counting needs to read counter */
- paicrypt_stop(event, PERF_EF_UPDATE);
-- if (cpump->users-- == 1) {
-+ if (--cpump->active_events == 0) {
- __ctl_clear_bit(0, 50);
- WRITE_ONCE(S390_lowcore.ccd, 0);
- }
---
-2.43.0
-
+++ /dev/null
-From b21fc658137f411a84e75faa091cb425e53616d3 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Thu, 20 Oct 2022 11:38:05 +0200
-Subject: s390/pai: rework pai_crypto mapped buffer reference count
-
-From: Thomas Richter <tmricht@linux.ibm.com>
-
-[ Upstream commit d3db4ac3c761def3d3a8e5ea6d05d1636c44c2ba ]
-
-Rework the mapped buffer reference count in PMU pai_crypto
-to match the same technique as in PMU pai_ext.
-This simplifies the logic.
-Do not count the individual number of counter and sampling
-processes. Remember the type of access and the total number of
-references to the buffer.
-
-Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
-Acked-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
-Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
-Stable-dep-of: e9f3af02f639 ("s390/pai: fix sampling event removal for PMU device driver")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- arch/s390/kernel/perf_pai_crypto.c | 42 ++++++++++++++----------------
- 1 file changed, 20 insertions(+), 22 deletions(-)
-
-diff --git a/arch/s390/kernel/perf_pai_crypto.c b/arch/s390/kernel/perf_pai_crypto.c
-index f61a652046cfb..68a6132937f3e 100644
---- a/arch/s390/kernel/perf_pai_crypto.c
-+++ b/arch/s390/kernel/perf_pai_crypto.c
-@@ -36,8 +36,8 @@ struct paicrypt_map {
- unsigned long *page; /* Page for CPU to store counters */
- struct pai_userdata *save; /* Page to store no-zero counters */
- unsigned int users; /* # of PAI crypto users */
-- unsigned int sampler; /* # of PAI crypto samplers */
-- unsigned int counter; /* # of PAI crypto counters */
-+ unsigned int refcnt; /* Reference count mapped buffers */
-+ enum paievt_mode mode; /* Type of event */
- struct perf_event *event; /* Perf event for sampling */
- };
-
-@@ -56,15 +56,11 @@ static void paicrypt_event_destroy(struct perf_event *event)
- cpump->event = NULL;
- static_branch_dec(&pai_key);
- mutex_lock(&pai_reserve_mutex);
-- if (event->attr.sample_period)
-- cpump->sampler -= 1;
-- else
-- cpump->counter -= 1;
-- debug_sprintf_event(cfm_dbg, 5, "%s event %#llx cpu %d"
-- " sampler %d counter %d\n", __func__,
-- event->attr.config, event->cpu, cpump->sampler,
-- cpump->counter);
-- if (!cpump->counter && !cpump->sampler) {
-+ debug_sprintf_event(cfm_dbg, 5, "%s event %#llx cpu %d users %d"
-+ " mode %d refcnt %d\n", __func__,
-+ event->attr.config, event->cpu, cpump->users,
-+ cpump->mode, cpump->refcnt);
-+ if (!--cpump->refcnt) {
- debug_sprintf_event(cfm_dbg, 4, "%s page %#lx save %p\n",
- __func__, (unsigned long)cpump->page,
- cpump->save);
-@@ -72,6 +68,7 @@ static void paicrypt_event_destroy(struct perf_event *event)
- cpump->page = NULL;
- kvfree(cpump->save);
- cpump->save = NULL;
-+ cpump->mode = PAI_MODE_NONE;
- }
- mutex_unlock(&pai_reserve_mutex);
- }
-@@ -136,17 +133,14 @@ static u64 paicrypt_getall(struct perf_event *event)
- */
- static int paicrypt_busy(struct perf_event_attr *a, struct paicrypt_map *cpump)
- {
-- unsigned int *use_ptr;
- int rc = 0;
-
- mutex_lock(&pai_reserve_mutex);
- if (a->sample_period) { /* Sampling requested */
-- use_ptr = &cpump->sampler;
-- if (cpump->counter || cpump->sampler)
-+ if (cpump->mode != PAI_MODE_NONE)
- rc = -EBUSY; /* ... sampling/counting active */
- } else { /* Counting requested */
-- use_ptr = &cpump->counter;
-- if (cpump->sampler)
-+ if (cpump->mode == PAI_MODE_SAMPLING)
- rc = -EBUSY; /* ... and sampling active */
- }
- if (rc)
-@@ -172,12 +166,16 @@ static int paicrypt_busy(struct perf_event_attr *a, struct paicrypt_map *cpump)
- rc = 0;
-
- unlock:
-- /* If rc is non-zero, do not increment counter/sampler. */
-- if (!rc)
-- *use_ptr += 1;
-- debug_sprintf_event(cfm_dbg, 5, "%s sample_period %#llx sampler %d"
-- " counter %d page %#lx save %p rc %d\n", __func__,
-- a->sample_period, cpump->sampler, cpump->counter,
-+ /* If rc is non-zero, do not set mode and reference count */
-+ if (!rc) {
-+ cpump->refcnt++;
-+ cpump->mode = a->sample_period ? PAI_MODE_SAMPLING
-+ : PAI_MODE_COUNTING;
-+ }
-+ debug_sprintf_event(cfm_dbg, 5, "%s sample_period %#llx users %d"
-+ " mode %d refcnt %d page %#lx save %p rc %d\n",
-+ __func__, a->sample_period, cpump->users,
-+ cpump->mode, cpump->refcnt,
- (unsigned long)cpump->page, cpump->save, rc);
- mutex_unlock(&pai_reserve_mutex);
- return rc;
---
-2.43.0
-
+++ /dev/null
-From 35023a996c2aa5ff04d6bb194d1acd3280dc0d11 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 15 Nov 2023 11:04:25 +0100
-Subject: s390/pai: rework paiXXX_start and paiXXX_stop functions
-
-From: Thomas Richter <tmricht@linux.ibm.com>
-
-[ Upstream commit cb1259b7b574bd90ef22dac2c6282327cdae31c6 ]
-
-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: Thomas Richter <tmricht@linux.ibm.com>
-Acked-by: Mete Durlu <meted@linux.ibm.com>
-Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
-Stable-dep-of: e9f3af02f639 ("s390/pai: fix sampling event removal for PMU device driver")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- arch/s390/kernel/perf_pai_crypto.c | 29 ++++++++++++-------------
- arch/s390/kernel/perf_pai_ext.c | 35 ++++++++++++++----------------
- 2 files changed, 30 insertions(+), 34 deletions(-)
-
-diff --git a/arch/s390/kernel/perf_pai_crypto.c b/arch/s390/kernel/perf_pai_crypto.c
-index 3758e972bb5f9..ba2d2e61df747 100644
---- a/arch/s390/kernel/perf_pai_crypto.c
-+++ b/arch/s390/kernel/perf_pai_crypto.c
-@@ -245,10 +245,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);
- }
- }
-
-@@ -263,19 +267,18 @@ static int paicrypt_add(struct perf_event *event, int flags)
- __ctl_set_bit(0, 50);
- }
- 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;
- }
-
-@@ -283,11 +286,7 @@ static void paicrypt_del(struct perf_event *event, int flags)
- {
- struct paicrypt_map *cpump = this_cpu_ptr(&paicrypt_map);
-
-- 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) {
- __ctl_clear_bit(0, 50);
- WRITE_ONCE(S390_lowcore.ccd, 0);
-diff --git a/arch/s390/kernel/perf_pai_ext.c b/arch/s390/kernel/perf_pai_ext.c
-index 53915401c3f63..09aebfcf679df 100644
---- a/arch/s390/kernel/perf_pai_ext.c
-+++ b/arch/s390/kernel/perf_pai_ext.c
-@@ -327,11 +327,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)
-@@ -348,21 +352,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;
- }
-
-@@ -372,12 +374,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 */
- __ctl_clear_bit(0, 49);
---
-2.43.0
-
+++ /dev/null
-From e5bbc512d2fc789681c85eb201df45b763749612 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 18 Oct 2023 11:53:52 +0200
-Subject: s390/pai_crypto: remove per-cpu variable assignement in event
- initialization
-
-From: Thomas Richter <tmricht@linux.ibm.com>
-
-[ Upstream commit aecd5a37b5ef4de4f6402dc079672e4243cc4c13 ]
-
-Function paicrypt_event_init() initializes the PMU device driver
-specific details for an event. It is called once per event creation.
-The function paicrypt_event_init() is not necessarily executed on
-that CPU the event will be used for.
-When an event is activated, function paicrypt_start() is used to
-start the event on that CPU.
-The per CPU data structure struct paicrypt_map has a pointer to
-the event which is active for a particular CPU. This pointer is
-set in function paicrypt_start() to point to the currently installed
-event. There is no need to also set this pointer in function
-paicrypt_event_init() where is might be assigned to the wrong CPU.
-Therefore remove this assignment in paicrypt_event_init().
-
-Acked-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
-Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
-Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
-Stable-dep-of: e9f3af02f639 ("s390/pai: fix sampling event removal for PMU device driver")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- arch/s390/kernel/perf_pai_crypto.c | 1 -
- 1 file changed, 1 deletion(-)
-
-diff --git a/arch/s390/kernel/perf_pai_crypto.c b/arch/s390/kernel/perf_pai_crypto.c
-index 7eb138b07e7be..4b773653a951b 100644
---- a/arch/s390/kernel/perf_pai_crypto.c
-+++ b/arch/s390/kernel/perf_pai_crypto.c
-@@ -213,7 +213,6 @@ static int paicrypt_event_init(struct perf_event *event)
- * are active at the same time.
- */
- event->hw.last_tag = 0;
-- cpump->event = event;
- event->destroy = paicrypt_event_destroy;
-
- if (a->sample_period) {
---
-2.43.0
-
+++ /dev/null
-From 117b4dfc411cc5896e800a18ff9469c9f9db7da2 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Thu, 27 Apr 2023 10:33:31 +0200
-Subject: s390/pai_ext: replace atomic_t with refcount_t
-
-From: Thomas Richter <tmricht@linux.ibm.com>
-
-[ Upstream commit 1f2597cd3686955a4d64e01909dbfe625a2a35a1 ]
-
-The s390 PMU of PAI extension 1 NNPA counters uses atomic_t for
-reference counting. Replace this with the proper data type
-refcount_t.
-
-No functional change.
-
-Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
-Acked-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
-Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
-Stable-dep-of: e9f3af02f639 ("s390/pai: fix sampling event removal for PMU device driver")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- arch/s390/kernel/perf_pai_ext.c | 23 +++++++++++++----------
- 1 file changed, 13 insertions(+), 10 deletions(-)
-
-diff --git a/arch/s390/kernel/perf_pai_ext.c b/arch/s390/kernel/perf_pai_ext.c
-index b4d89654183a2..d6bc919530143 100644
---- a/arch/s390/kernel/perf_pai_ext.c
-+++ b/arch/s390/kernel/perf_pai_ext.c
-@@ -56,7 +56,7 @@ struct paiext_map {
- struct pai_userdata *save; /* Area to store non-zero counters */
- enum paiext_mode mode; /* Type of event */
- unsigned int active_events; /* # of PAI Extension users */
-- unsigned int refcnt;
-+ refcount_t refcnt;
- struct perf_event *event; /* Perf event for sampling */
- struct paiext_cb *paiext_cb; /* PAI extension control block area */
- };
-@@ -66,14 +66,14 @@ struct paiext_mapptr {
- };
-
- static struct paiext_root { /* Anchor to per CPU data */
-- int refcnt; /* Overall active events */
-+ refcount_t refcnt; /* Overall active events */
- struct paiext_mapptr __percpu *mapptr;
- } paiext_root;
-
- /* Free per CPU data when the last event is removed. */
- static void paiext_root_free(void)
- {
-- if (!--paiext_root.refcnt) {
-+ if (refcount_dec_and_test(&paiext_root.refcnt)) {
- free_percpu(paiext_root.mapptr);
- paiext_root.mapptr = NULL;
- }
-@@ -86,7 +86,7 @@ static void paiext_root_free(void)
- */
- static int paiext_root_alloc(void)
- {
-- if (++paiext_root.refcnt == 1) {
-+ if (!refcount_inc_not_zero(&paiext_root.refcnt)) {
- /* The memory is already zeroed. */
- paiext_root.mapptr = alloc_percpu(struct paiext_mapptr);
- if (!paiext_root.mapptr) {
-@@ -97,6 +97,7 @@ static int paiext_root_alloc(void)
- */
- return -ENOMEM;
- }
-+ refcount_set(&paiext_root.refcnt, 1);
- }
- return 0;
- }
-@@ -128,7 +129,7 @@ static void paiext_event_destroy(struct perf_event *event)
-
- mutex_lock(&paiext_reserve_mutex);
- cpump->event = NULL;
-- if (!--cpump->refcnt) /* Last reference gone */
-+ if (refcount_dec_and_test(&cpump->refcnt)) /* Last reference gone */
- paiext_free(mp);
- paiext_root_free();
- mutex_unlock(&paiext_reserve_mutex);
-@@ -169,7 +170,7 @@ static int paiext_alloc(struct perf_event_attr *a, struct perf_event *event)
- rc = -ENOMEM;
- cpump = kzalloc(sizeof(*cpump), GFP_KERNEL);
- if (!cpump)
-- goto unlock;
-+ goto undo;
-
- /* Allocate memory for counter area and counter extraction.
- * These are
-@@ -189,8 +190,9 @@ static int paiext_alloc(struct perf_event_attr *a, struct perf_event *event)
- GFP_KERNEL);
- if (!cpump->save || !cpump->area || !cpump->paiext_cb) {
- paiext_free(mp);
-- goto unlock;
-+ goto undo;
- }
-+ refcount_set(&cpump->refcnt, 1);
- cpump->mode = a->sample_period ? PAI_MODE_SAMPLING
- : PAI_MODE_COUNTER;
- } else {
-@@ -201,15 +203,15 @@ static int paiext_alloc(struct perf_event_attr *a, struct perf_event *event)
- if (cpump->mode == PAI_MODE_SAMPLING ||
- (cpump->mode == PAI_MODE_COUNTER && a->sample_period)) {
- rc = -EBUSY;
-- goto unlock;
-+ goto undo;
- }
-+ refcount_inc(&cpump->refcnt);
- }
-
- rc = 0;
- cpump->event = event;
-- ++cpump->refcnt;
-
--unlock:
-+undo:
- if (rc) {
- /* Error in allocation of event, decrement anchor. Since
- * the event in not created, its destroy() function is never
-@@ -217,6 +219,7 @@ static int paiext_alloc(struct perf_event_attr *a, struct perf_event *event)
- */
- paiext_root_free();
- }
-+unlock:
- mutex_unlock(&paiext_reserve_mutex);
- /* If rc is non-zero, no increment of counter/sampler was done. */
- return rc;
---
-2.43.0
-
scsi-mylex-fix-sysfs-buffer-lengths.patch
scsi-sd-unregister-device-if-device_add_disk-failed-.patch
cifs-fix-caching-to-try-to-do-open-o_wronly-as-rdwr-.patch
-s390-pai-rework-pai_crypto-mapped-buffer-reference-c.patch
-s390-pai-rename-structure-member-users-to-active_eve.patch
-s390-pai_ext-replace-atomic_t-with-refcount_t.patch
-s390-pai-initialize-event-count-once-at-initializati.patch
-s390-pai_crypto-remove-per-cpu-variable-assignement-.patch
-s390-pai-cleanup-event-initialization.patch
-s390-pai-rework-paixxx_start-and-paixxx_stop-functio.patch
-s390-pai-fix-sampling-event-removal-for-pmu-device-d.patch
ata-sata_mv-fix-pci-device-id-table-declaration-comp.patch
nfsd-hold-a-lighter-weight-client-reference-over-cb_.patch
x86-retpoline-add-noendbr-annotation-to-the-srso-dummy-return-thunk.patch