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

powerpc/pseries: Use lparcfg to reconfig VAS windows for DLPAR CPU

The hypervisor assigns VAS (Virtual Accelerator Switchboard)
windows depends on cores configured in LPAR. The kernel uses
OF reconfig notifier to reconfig VAS windows for DLPAR CPU event.
In the case of shared CPU mode partition, the hypervisor assigns
VAS windows depends on CPU entitled capacity, not based on vcpus.
When the user changes CPU entitled capacity for the partition,
drmgr uses /proc/ppc64/lparcfg interface to notify the kernel.

This patch adds the following changes to update VAS resources
for shared mode:
- Call vas reconfig windows from lparcfg_write()
- Ignore reconfig changes in the VAS notifier

Signed-off-by: Haren Myneni <haren@linux.ibm.com>
[mpe: Rework error handling, report any errors as EIO]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/efa9c16e4a78dda4567a16f13dabfd73cb4674a2.camel@linux.ibm.com

authored by

Haren Myneni and committed by
Michael Ellerman
2147783d 89ed0b76

+45 -14
+11
arch/powerpc/platforms/pseries/lparcfg.c
··· 35 35 #include <asm/drmem.h> 36 36 37 37 #include "pseries.h" 38 + #include "vas.h" /* pseries_vas_dlpar_cpu() */ 38 39 39 40 /* 40 41 * This isn't a module but we expose that to userspace ··· 749 748 return -EINVAL; 750 749 751 750 retval = update_ppp(new_entitled_ptr, NULL); 751 + 752 + if (retval == H_SUCCESS || retval == H_CONSTRAINED) { 753 + /* 754 + * The hypervisor assigns VAS resources based 755 + * on entitled capacity for shared mode. 756 + * Reconfig VAS windows based on DLPAR CPU events. 757 + */ 758 + if (pseries_vas_dlpar_cpu() != 0) 759 + retval = H_HARDWARE; 760 + } 752 761 } else if (!strcmp(kbuf, "capacity_weight")) { 753 762 char *endp; 754 763 *new_weight_ptr = (u8) simple_strtoul(tmp, &endp, 10);
+29 -14
arch/powerpc/platforms/pseries/vas.c
··· 852 852 mutex_unlock(&vas_pseries_mutex); 853 853 return rc; 854 854 } 855 + 856 + int pseries_vas_dlpar_cpu(void) 857 + { 858 + int new_nr_creds, rc; 859 + 860 + rc = h_query_vas_capabilities(H_QUERY_VAS_CAPABILITIES, 861 + vascaps[VAS_GZIP_DEF_FEAT_TYPE].feat, 862 + (u64)virt_to_phys(&hv_cop_caps)); 863 + if (!rc) { 864 + new_nr_creds = be16_to_cpu(hv_cop_caps.target_lpar_creds); 865 + rc = vas_reconfig_capabilties(VAS_GZIP_DEF_FEAT_TYPE, new_nr_creds); 866 + } 867 + 868 + if (rc) 869 + pr_err("Failed reconfig VAS capabilities with DLPAR\n"); 870 + 871 + return rc; 872 + } 873 + 855 874 /* 856 875 * Total number of default credits available (target_credits) 857 876 * in LPAR depends on number of cores configured. It varies based on ··· 885 866 struct of_reconfig_data *rd = data; 886 867 struct device_node *dn = rd->dn; 887 868 const __be32 *intserv = NULL; 888 - int new_nr_creds, len, rc = 0; 869 + int len; 870 + 871 + /* 872 + * For shared CPU partition, the hypervisor assigns total credits 873 + * based on entitled core capacity. So updating VAS windows will 874 + * be called from lparcfg_write(). 875 + */ 876 + if (is_shared_processor()) 877 + return NOTIFY_OK; 889 878 890 879 if ((action == OF_RECONFIG_ATTACH_NODE) || 891 880 (action == OF_RECONFIG_DETACH_NODE)) ··· 905 878 if (!intserv) 906 879 return NOTIFY_OK; 907 880 908 - rc = h_query_vas_capabilities(H_QUERY_VAS_CAPABILITIES, 909 - vascaps[VAS_GZIP_DEF_FEAT_TYPE].feat, 910 - (u64)virt_to_phys(&hv_cop_caps)); 911 - if (!rc) { 912 - new_nr_creds = be16_to_cpu(hv_cop_caps.target_lpar_creds); 913 - rc = vas_reconfig_capabilties(VAS_GZIP_DEF_FEAT_TYPE, 914 - new_nr_creds); 915 - } 916 - 917 - if (rc) 918 - pr_err("Failed reconfig VAS capabilities with DLPAR\n"); 919 - 920 - return rc; 881 + return pseries_vas_dlpar_cpu(); 921 882 } 922 883 923 884 static struct notifier_block pseries_vas_nb = {
+5
arch/powerpc/platforms/pseries/vas.h
··· 141 141 142 142 #ifdef CONFIG_PPC_VAS 143 143 int vas_migration_handler(int action); 144 + int pseries_vas_dlpar_cpu(void); 144 145 #else 145 146 static inline int vas_migration_handler(int action) 147 + { 148 + return 0; 149 + } 150 + static inline int pseries_vas_dlpar_cpu(void) 146 151 { 147 152 return 0; 148 153 }