Skip to content

Commit ad3ca43

Browse files
author
Mamatha Inamdar
committed
powerpc/pseries: HVPIPE changes to support migration
JIRA: https://issues.redhat.com/browse/RHEL-101849 commit 6d84f85 Author: Haren Myneni <haren@linux.ibm.com> Date: Tue Sep 9 01:44:01 2025 -0700 powerpc/pseries: HVPIPE changes to support migration The hypervisor assigns one pipe per partition for all sources and assigns new pipe after migration. Also the partition ID that is used by source as its target ID may be changed after the migration. So disable hvpipe during SUSPEND event with ‘hvpipe enable’ system parameter value = 0 and enable it after migration during RESUME event with hvpipe enable’ system parameter value = 1. The user space calls such as ioctl()/ read() / write() / poll() returns -ENXIO between SUSPEND and RESUME events. The user space process can close FD and reestablish connection with new FD after migration if needed (Example: source IDs are changed). Signed-off-by: Haren Myneni <haren@linux.ibm.com> Tested-by: Shashank MS <shashank.gowda@in.ibm.com> Reviewed-by: Mahesh Salgaonkar <mahesh@linux.ibm.com> Reviewed-by: Tyrel Datwyler <tyreld@linux.ibm.com> Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com> Link: https://patch.msgid.link/20250909084402.1488456-10-haren@linux.ibm.com Signed-off-by: Mamatha Inamdar <minamdar@redhat.com>
1 parent 028c874 commit ad3ca43

File tree

3 files changed

+74
-0
lines changed

3 files changed

+74
-0
lines changed

arch/powerpc/platforms/pseries/mobility.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <asm/rtas.h>
2828
#include "pseries.h"
2929
#include "vas.h" /* vas_migration_handler() */
30+
#include "papr-hvpipe.h" /* hvpipe_migration_handler() */
3031
#include "../../kernel/cacheinfo.h"
3132

3233
static struct kobject *mobility_kobj;
@@ -752,6 +753,7 @@ static int pseries_migrate_partition(u64 handle)
752753
* by closing VAS windows at the beginning of this function.
753754
*/
754755
vas_migration_handler(VAS_SUSPEND);
756+
hvpipe_migration_handler(HVPIPE_SUSPEND);
755757

756758
ret = wait_for_vasi_session_suspending(handle);
757759
if (ret)
@@ -778,6 +780,7 @@ static int pseries_migrate_partition(u64 handle)
778780

779781
out:
780782
vas_migration_handler(VAS_RESUME);
783+
hvpipe_migration_handler(HVPIPE_RESUME);
781784

782785
return ret;
783786
}

arch/powerpc/platforms/pseries/papr-hvpipe.c

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ static unsigned char hvpipe_ras_buf[RTAS_ERROR_LOG_MAX];
2727
static struct workqueue_struct *papr_hvpipe_wq;
2828
static struct work_struct *papr_hvpipe_work;
2929
static int hvpipe_check_exception_token;
30+
static bool hvpipe_feature;
3031

3132
/*
3233
* New PowerPC FW provides support for partitions and various
@@ -233,6 +234,12 @@ static ssize_t papr_hvpipe_handle_write(struct file *file,
233234
unsigned long ret, len;
234235
__be64 *area_be;
235236

237+
/*
238+
* Return -ENXIO during migration
239+
*/
240+
if (!hvpipe_feature)
241+
return -ENXIO;
242+
236243
if (!src_info)
237244
return -EIO;
238245

@@ -323,6 +330,12 @@ static ssize_t papr_hvpipe_handle_read(struct file *file,
323330
struct papr_hvpipe_hdr hdr;
324331
long ret;
325332

333+
/*
334+
* Return -ENXIO during migration
335+
*/
336+
if (!hvpipe_feature)
337+
return -ENXIO;
338+
326339
if (!src_info)
327340
return -EIO;
328341

@@ -399,6 +412,13 @@ static __poll_t papr_hvpipe_handle_poll(struct file *filp,
399412
{
400413
struct hvpipe_source_info *src_info = filp->private_data;
401414

415+
/*
416+
* HVPIPE is disabled during SUSPEND and enabled after migration.
417+
* So return POLLRDHUP during migration
418+
*/
419+
if (!hvpipe_feature)
420+
return POLLRDHUP;
421+
402422
if (!src_info)
403423
return POLLNVAL;
404424

@@ -539,6 +559,12 @@ static long papr_hvpipe_dev_ioctl(struct file *filp, unsigned int ioctl,
539559
u32 srcID;
540560
long ret;
541561

562+
/*
563+
* Return -ENXIO during migration
564+
*/
565+
if (!hvpipe_feature)
566+
return -ENXIO;
567+
542568
if (get_user(srcID, argp))
543569
return -EFAULT;
544570

@@ -697,6 +723,44 @@ static int __init enable_hvpipe_IRQ(void)
697723
return 0;
698724
}
699725

726+
void hvpipe_migration_handler(int action)
727+
{
728+
pr_info("hvpipe migration event %d\n", action);
729+
730+
/*
731+
* HVPIPE is not used (Failed to create /dev/papr-hvpipe).
732+
* So nothing to do for migration.
733+
*/
734+
if (!papr_hvpipe_work)
735+
return;
736+
737+
switch (action) {
738+
case HVPIPE_SUSPEND:
739+
if (hvpipe_feature) {
740+
/*
741+
* Disable hvpipe_feature to the user space.
742+
* It will be enabled with RESUME event.
743+
*/
744+
hvpipe_feature = false;
745+
/*
746+
* set system parameter hvpipe 'disable'
747+
*/
748+
set_hvpipe_sys_param(0);
749+
}
750+
break;
751+
case HVPIPE_RESUME:
752+
/*
753+
* set system parameter hvpipe 'enable'
754+
*/
755+
if (!set_hvpipe_sys_param(1))
756+
hvpipe_feature = true;
757+
else
758+
pr_err("hvpipe is not enabled after migration\n");
759+
760+
break;
761+
}
762+
}
763+
700764
static const struct file_operations papr_hvpipe_ops = {
701765
.unlocked_ioctl = papr_hvpipe_dev_ioctl,
702766
};
@@ -740,6 +804,7 @@ static int __init papr_hvpipe_init(void)
740804

741805
if (!ret) {
742806
pr_info("hvpipe feature is enabled\n");
807+
hvpipe_feature = true;
743808
return 0;
744809
}
745810

arch/powerpc/platforms/pseries/papr-hvpipe.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111

1212
#define HVPIPE_HDR_LEN sizeof(struct papr_hvpipe_hdr)
1313

14+
enum hvpipe_migrate_action {
15+
HVPIPE_SUSPEND,
16+
HVPIPE_RESUME,
17+
};
18+
1419
struct hvpipe_source_info {
1520
struct list_head list; /* list of sources */
1621
u32 srcID;
@@ -33,4 +38,5 @@ struct hvpipe_event_buf {
3338
/* with specified src ID */
3439
};
3540

41+
void hvpipe_migration_handler(int action);
3642
#endif /* _PAPR_HVPIPE_H */

0 commit comments

Comments
 (0)