From: Haren Myneni <haren@linux.ibm.com>
To: mpe@ellerman.id.au, linuxppc-dev@lists.ozlabs.org,
npiggin@gmail.com, nathanl@linux.ibm.com
Subject: [RFC PATCH 2/3] powerpc/pseries/vas: Add VAS suspend/resume notifier
Date: Fri, 21 Jan 2022 13:49:48 -0800 [thread overview]
Message-ID: <1708397061ea4e7c474a0187437e94d1e288d2af.camel@linux.ibm.com> (raw)
In-Reply-To: <cb790b1d369457eb124ad9daa4b4833fa12e0832.camel@linux.ibm.com>
Since the windows belong to the VAS hardware resource, the
hypervisor expects the partition to close them on source partition
and reopen them after the partition migrated on the destination
machine.
This suspend/resume notifier invokes suspend operation before
and resume operation after migration. All active windows for
both default and QoS types will be closed during suspend and
reopen them during resume. During migration, the user space
should expect paste instruction failure if issues copy/paste
on these active windows.
Signed-off-by: Haren Myneni <haren@linux.ibm.com>
---
arch/powerpc/platforms/pseries/vas.c | 97 +++++++++++++++++++++++++++-
1 file changed, 96 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/platforms/pseries/vas.c b/arch/powerpc/platforms/pseries/vas.c
index e4797fc73553..7087528e4246 100644
--- a/arch/powerpc/platforms/pseries/vas.c
+++ b/arch/powerpc/platforms/pseries/vas.c
@@ -16,6 +16,7 @@
#include <asm/machdep.h>
#include <asm/hvcall.h>
#include <asm/plpar_wrappers.h>
+#include <asm/pseries-suspend.h>
#include <asm/vas.h>
#include "vas.h"
@@ -873,6 +874,98 @@ static struct notifier_block pseries_vas_nb = {
.notifier_call = pseries_vas_notifier,
};
+/*
+ * For LPM, all windows have to be closed on the source partition
+ * before migration and reopen them on the destination partition
+ * after migration. So closing windows during suspend and
+ * reopen them during resume.
+ */
+static int vas_migrate_windows(bool suspend)
+{
+ struct hv_vas_cop_feat_caps *hv_caps;
+ struct vas_cop_feat_caps *caps;
+ int lpar_creds, new_creds = 0;
+ struct vas_caps *vcaps;
+ int i, rc = 0;
+
+ hv_caps = kmalloc(sizeof(*hv_caps), GFP_KERNEL);
+ if (!hv_caps)
+ return -ENOMEM;
+
+ mutex_lock(&vas_pseries_mutex);
+
+ for (i = 0; i < VAS_MAX_FEAT_TYPE; i++) {
+ vcaps = &vascaps[i];
+ caps = &vcaps->caps;
+ lpar_creds = atomic_read(&caps->target_creds);
+
+ rc = h_query_vas_capabilities(H_QUERY_VAS_CAPABILITIES, vcaps->feat,
+ (u64)virt_to_phys(hv_caps));
+ if (!rc) {
+ new_creds = be16_to_cpu(hv_caps->target_lpar_creds);
+ /*
+ * Should not happen. But incase print messages, close all
+ * windows in the list during suspend and reopen windows
+ * based on new lpar_creds on the destination system.
+ */
+ if (lpar_creds != new_creds) {
+ pr_err("%s: lpar creds: %d HV lpar creds: %d\n",
+ suspend ? "Suspend" : "Resume", lpar_creds,
+ new_creds);
+ pr_err("Used creds: %d, Active creds: %d\n",
+ atomic_read(&caps->used_creds),
+ vcaps->num_wins - vcaps->close_wins);
+ }
+ } else {
+ pr_err("%s: Get VAS capabilities failed with %d\n",
+ suspend ? "Suspend" : "Resume", rc);
+ /*
+ * We can not stop migration with the current lpm
+ * implementation. So continue closing all windows in the
+ * list (during suspend) and return without opending windows
+ * (during resume) if VAS capabilities HCALL failed.
+ */
+ if (!suspend)
+ goto out;
+ }
+
+ if (suspend)
+ rc = reconfig_close_windows(vcaps, vcaps->num_wins, true);
+ else {
+ atomic_set(&caps->target_creds, new_creds);
+ rc = reconfig_open_windows(vcaps, new_creds, true);
+ }
+
+ /*
+ * Ignore errors during suspend and return for resume.
+ */
+ if (rc && !suspend)
+ goto out;
+ }
+
+out:
+ mutex_unlock(&vas_pseries_mutex);
+ kfree(hv_caps);
+ return rc;
+}
+
+static int vas_migration_handler(struct notifier_block *nb,
+ unsigned long action, void *data)
+{
+ if (action == PSERIES_RESUMING)
+ return vas_migrate_windows(false);
+ else
+ return vas_migrate_windows(true);
+
+}
+
+static struct pseries_suspend_handler vas_suspend_handler = {
+ .notifier_block = {
+ .notifier_call = vas_migration_handler,
+ },
+};
+
+
static int __init pseries_vas_init(void)
{
struct hv_vas_cop_feat_caps *hv_cop_caps;
@@ -929,8 +1022,10 @@ static int __init pseries_vas_init(void)
}
/* Processors can be added/removed only on LPAR */
- if (copypaste_feat && firmware_has_feature(FW_FEATURE_LPAR))
+ if (copypaste_feat && firmware_has_feature(FW_FEATURE_LPAR)) {
of_reconfig_notifier_register(&pseries_vas_nb);
+ pseries_register_suspend_handler(&vas_suspend_handler);
+ }
pr_info("GZIP feature is available\n");
--
2.27.0
next prev parent reply other threads:[~2022-01-21 21:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-21 21:48 [RFC PATCH 0/3] powerpc/pseries/vas: VAS/NXGZIP support with LPM Haren Myneni
2022-01-21 21:49 ` [RFC PATCH 1/3] powerpc/pseries/vas: Modify reconfig open/close functions for migration Haren Myneni
2022-01-21 21:49 ` Haren Myneni [this message]
2022-01-21 21:50 ` [RFC PATCH 3/3] powerpc/pseries/vas: Disable window open during migration Haren Myneni
-- strict thread matches above, loose matches on Subject: below --
2021-12-27 10:56 [RFC PATCH 0/3] powerpc/pseries/vas: VAS/NXGZIP support with LPM Haren Myneni
2021-12-27 10:59 ` [RFC PATCH 2/3] powerpc/pseries/vas: Add VAS suspend/resume notifier Haren Myneni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1708397061ea4e7c474a0187437e94d1e288d2af.camel@linux.ibm.com \
--to=haren@linux.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=nathanl@linux.ibm.com \
--cc=npiggin@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).