Skip to content

Commit 2147783

Browse files
hmynenimpe
authored andcommitted
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 <[email protected]> [mpe: Rework error handling, report any errors as EIO] Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 89ed0b7 commit 2147783

File tree

3 files changed

+45
-14
lines changed

3 files changed

+45
-14
lines changed

arch/powerpc/platforms/pseries/lparcfg.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <asm/drmem.h>
3636

3737
#include "pseries.h"
38+
#include "vas.h" /* pseries_vas_dlpar_cpu() */
3839

3940
/*
4041
* This isn't a module but we expose that to userspace
@@ -748,6 +749,16 @@ static ssize_t lparcfg_write(struct file *file, const char __user * buf,
748749
return -EINVAL;
749750

750751
retval = update_ppp(new_entitled_ptr, NULL);
752+
753+
if (retval == H_SUCCESS || retval == H_CONSTRAINED) {
754+
/*
755+
* The hypervisor assigns VAS resources based
756+
* on entitled capacity for shared mode.
757+
* Reconfig VAS windows based on DLPAR CPU events.
758+
*/
759+
if (pseries_vas_dlpar_cpu() != 0)
760+
retval = H_HARDWARE;
761+
}
751762
} else if (!strcmp(kbuf, "capacity_weight")) {
752763
char *endp;
753764
*new_weight_ptr = (u8) simple_strtoul(tmp, &endp, 10);

arch/powerpc/platforms/pseries/vas.c

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,25 @@ int vas_reconfig_capabilties(u8 type, int new_nr_creds)
852852
mutex_unlock(&vas_pseries_mutex);
853853
return rc;
854854
}
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+
855874
/*
856875
* Total number of default credits available (target_credits)
857876
* in LPAR depends on number of cores configured. It varies based on
@@ -866,7 +885,15 @@ static int pseries_vas_notifier(struct notifier_block *nb,
866885
struct of_reconfig_data *rd = data;
867886
struct device_node *dn = rd->dn;
868887
const __be32 *intserv = NULL;
869-
int new_nr_creds, len, rc = 0;
888+
int len;
889+
890+
/*
891+
* For shared CPU partition, the hypervisor assigns total credits
892+
* based on entitled core capacity. So updating VAS windows will
893+
* be called from lparcfg_write().
894+
*/
895+
if (is_shared_processor())
896+
return NOTIFY_OK;
870897

871898
if ((action == OF_RECONFIG_ATTACH_NODE) ||
872899
(action == OF_RECONFIG_DETACH_NODE))
@@ -878,19 +905,7 @@ static int pseries_vas_notifier(struct notifier_block *nb,
878905
if (!intserv)
879906
return NOTIFY_OK;
880907

881-
rc = h_query_vas_capabilities(H_QUERY_VAS_CAPABILITIES,
882-
vascaps[VAS_GZIP_DEF_FEAT_TYPE].feat,
883-
(u64)virt_to_phys(&hv_cop_caps));
884-
if (!rc) {
885-
new_nr_creds = be16_to_cpu(hv_cop_caps.target_lpar_creds);
886-
rc = vas_reconfig_capabilties(VAS_GZIP_DEF_FEAT_TYPE,
887-
new_nr_creds);
888-
}
889-
890-
if (rc)
891-
pr_err("Failed reconfig VAS capabilities with DLPAR\n");
892-
893-
return rc;
908+
return pseries_vas_dlpar_cpu();
894909
}
895910

896911
static struct notifier_block pseries_vas_nb = {

arch/powerpc/platforms/pseries/vas.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,15 @@ int __init sysfs_pseries_vas_init(struct vas_all_caps *vas_caps);
141141

142142
#ifdef CONFIG_PPC_VAS
143143
int vas_migration_handler(int action);
144+
int pseries_vas_dlpar_cpu(void);
144145
#else
145146
static inline int vas_migration_handler(int action)
146147
{
147148
return 0;
148149
}
150+
static inline int pseries_vas_dlpar_cpu(void)
151+
{
152+
return 0;
153+
}
149154
#endif
150155
#endif /* _VAS_H */

0 commit comments

Comments
 (0)