Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

authored by

Haren Myneni and committed by
Madhavan Srinivasan
6d84f851 39a08a4f

+74
+3
arch/powerpc/platforms/pseries/mobility.c
··· 28 28 #include <asm/rtas.h> 29 29 #include "pseries.h" 30 30 #include "vas.h" /* vas_migration_handler() */ 31 + #include "papr-hvpipe.h" /* hvpipe_migration_handler() */ 31 32 #include "../../kernel/cacheinfo.h" 32 33 33 34 static struct kobject *mobility_kobj; ··· 745 744 * by closing VAS windows at the beginning of this function. 746 745 */ 747 746 vas_migration_handler(VAS_SUSPEND); 747 + hvpipe_migration_handler(HVPIPE_SUSPEND); 748 748 749 749 ret = wait_for_vasi_session_suspending(handle); 750 750 if (ret) ··· 772 770 773 771 out: 774 772 vas_migration_handler(VAS_RESUME); 773 + hvpipe_migration_handler(HVPIPE_RESUME); 775 774 776 775 return ret; 777 776 }
+65
arch/powerpc/platforms/pseries/papr-hvpipe.c
··· 27 27 static struct workqueue_struct *papr_hvpipe_wq; 28 28 static struct work_struct *papr_hvpipe_work; 29 29 static int hvpipe_check_exception_token; 30 + static bool hvpipe_feature; 30 31 31 32 /* 32 33 * New PowerPC FW provides support for partitions and various ··· 234 233 unsigned long ret, len; 235 234 __be64 *area_be; 236 235 236 + /* 237 + * Return -ENXIO during migration 238 + */ 239 + if (!hvpipe_feature) 240 + return -ENXIO; 241 + 237 242 if (!src_info) 238 243 return -EIO; 239 244 ··· 330 323 struct papr_hvpipe_hdr hdr; 331 324 long ret; 332 325 326 + /* 327 + * Return -ENXIO during migration 328 + */ 329 + if (!hvpipe_feature) 330 + return -ENXIO; 331 + 333 332 if (!src_info) 334 333 return -EIO; 335 334 ··· 411 398 struct poll_table_struct *wait) 412 399 { 413 400 struct hvpipe_source_info *src_info = filp->private_data; 401 + 402 + /* 403 + * HVPIPE is disabled during SUSPEND and enabled after migration. 404 + * So return POLLRDHUP during migration 405 + */ 406 + if (!hvpipe_feature) 407 + return POLLRDHUP; 414 408 415 409 if (!src_info) 416 410 return POLLNVAL; ··· 558 538 u32 __user *argp = (void __user *)arg; 559 539 u32 srcID; 560 540 long ret; 541 + 542 + /* 543 + * Return -ENXIO during migration 544 + */ 545 + if (!hvpipe_feature) 546 + return -ENXIO; 561 547 562 548 if (get_user(srcID, argp)) 563 549 return -EFAULT; ··· 723 697 return 0; 724 698 } 725 699 700 + void hvpipe_migration_handler(int action) 701 + { 702 + pr_info("hvpipe migration event %d\n", action); 703 + 704 + /* 705 + * HVPIPE is not used (Failed to create /dev/papr-hvpipe). 706 + * So nothing to do for migration. 707 + */ 708 + if (!papr_hvpipe_work) 709 + return; 710 + 711 + switch (action) { 712 + case HVPIPE_SUSPEND: 713 + if (hvpipe_feature) { 714 + /* 715 + * Disable hvpipe_feature to the user space. 716 + * It will be enabled with RESUME event. 717 + */ 718 + hvpipe_feature = false; 719 + /* 720 + * set system parameter hvpipe 'disable' 721 + */ 722 + set_hvpipe_sys_param(0); 723 + } 724 + break; 725 + case HVPIPE_RESUME: 726 + /* 727 + * set system parameter hvpipe 'enable' 728 + */ 729 + if (!set_hvpipe_sys_param(1)) 730 + hvpipe_feature = true; 731 + else 732 + pr_err("hvpipe is not enabled after migration\n"); 733 + 734 + break; 735 + } 736 + } 737 + 726 738 static const struct file_operations papr_hvpipe_ops = { 727 739 .unlocked_ioctl = papr_hvpipe_dev_ioctl, 728 740 }; ··· 804 740 805 741 if (!ret) { 806 742 pr_info("hvpipe feature is enabled\n"); 743 + hvpipe_feature = true; 807 744 return 0; 808 745 } 809 746
+6
arch/powerpc/platforms/pseries/papr-hvpipe.h
··· 11 11 12 12 #define HVPIPE_HDR_LEN sizeof(struct papr_hvpipe_hdr) 13 13 14 + enum hvpipe_migrate_action { 15 + HVPIPE_SUSPEND, 16 + HVPIPE_RESUME, 17 + }; 18 + 14 19 struct hvpipe_source_info { 15 20 struct list_head list; /* list of sources */ 16 21 u32 srcID; ··· 38 33 /* with specified src ID */ 39 34 }; 40 35 36 + void hvpipe_migration_handler(int action); 41 37 #endif /* _PAPR_HVPIPE_H */