Skip to content

Commit 278fe1c

Browse files
hmynenimpe
authored andcommitted
powerpc/pseries/vas: Define global hv_cop_caps struct
The coprocessor capabilities struct is used to get default and QoS capabilities from the hypervisor during init, DLPAR event and migration. So instead of allocating this struct for each event, define global struct and reuse it which allows the migration code to avoid adding an error path. Also disable copy/paste feature flag if any capabilities HCALL is failed. Signed-off-by: Haren Myneni <[email protected]> Reviewed-by: Nicholas Piggin <[email protected]> Acked-by: Nathan Lynch <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 45f06ea commit 278fe1c

File tree

1 file changed

+20
-27
lines changed
  • arch/powerpc/platforms/pseries

1 file changed

+20
-27
lines changed

arch/powerpc/platforms/pseries/vas.c

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
static struct vas_all_caps caps_all;
2828
static bool copypaste_feat;
29+
static struct hv_vas_cop_feat_caps hv_cop_caps;
2930

3031
static struct vas_caps vascaps[VAS_MAX_FEAT_TYPE];
3132
static DEFINE_MUTEX(vas_pseries_mutex);
@@ -724,7 +725,6 @@ static int reconfig_close_windows(struct vas_caps *vcap, int excess_creds)
724725
*/
725726
int vas_reconfig_capabilties(u8 type)
726727
{
727-
struct hv_vas_cop_feat_caps *hv_caps;
728728
struct vas_cop_feat_caps *caps;
729729
int old_nr_creds, new_nr_creds;
730730
struct vas_caps *vcaps;
@@ -738,17 +738,13 @@ int vas_reconfig_capabilties(u8 type)
738738
vcaps = &vascaps[type];
739739
caps = &vcaps->caps;
740740

741-
hv_caps = kmalloc(sizeof(*hv_caps), GFP_KERNEL);
742-
if (!hv_caps)
743-
return -ENOMEM;
744-
745741
mutex_lock(&vas_pseries_mutex);
746742
rc = h_query_vas_capabilities(H_QUERY_VAS_CAPABILITIES, vcaps->feat,
747-
(u64)virt_to_phys(hv_caps));
743+
(u64)virt_to_phys(&hv_cop_caps));
748744
if (rc)
749745
goto out;
750746

751-
new_nr_creds = be16_to_cpu(hv_caps->target_lpar_creds);
747+
new_nr_creds = be16_to_cpu(hv_cop_caps.target_lpar_creds);
752748

753749
old_nr_creds = atomic_read(&caps->nr_total_credits);
754750

@@ -780,7 +776,6 @@ int vas_reconfig_capabilties(u8 type)
780776

781777
out:
782778
mutex_unlock(&vas_pseries_mutex);
783-
kfree(hv_caps);
784779
return rc;
785780
}
786781
/*
@@ -822,9 +817,8 @@ static struct notifier_block pseries_vas_nb = {
822817

823818
static int __init pseries_vas_init(void)
824819
{
825-
struct hv_vas_cop_feat_caps *hv_cop_caps;
826820
struct hv_vas_all_caps *hv_caps;
827-
int rc;
821+
int rc = 0;
828822

829823
/*
830824
* Linux supports user space COPY/PASTE only with Radix
@@ -850,38 +844,37 @@ static int __init pseries_vas_init(void)
850844

851845
sysfs_pseries_vas_init(&caps_all);
852846

853-
hv_cop_caps = kmalloc(sizeof(*hv_cop_caps), GFP_KERNEL);
854-
if (!hv_cop_caps) {
855-
rc = -ENOMEM;
856-
goto out;
857-
}
858847
/*
859848
* QOS capabilities available
860849
*/
861850
if (caps_all.feat_type & VAS_GZIP_QOS_FEAT_BIT) {
862851
rc = get_vas_capabilities(VAS_GZIP_QOS_FEAT,
863-
VAS_GZIP_QOS_FEAT_TYPE, hv_cop_caps);
852+
VAS_GZIP_QOS_FEAT_TYPE, &hv_cop_caps);
864853

865854
if (rc)
866-
goto out_cop;
855+
goto out;
867856
}
868857
/*
869858
* Default capabilities available
870859
*/
871-
if (caps_all.feat_type & VAS_GZIP_DEF_FEAT_BIT) {
860+
if (caps_all.feat_type & VAS_GZIP_DEF_FEAT_BIT)
872861
rc = get_vas_capabilities(VAS_GZIP_DEF_FEAT,
873-
VAS_GZIP_DEF_FEAT_TYPE, hv_cop_caps);
874-
if (rc)
875-
goto out_cop;
876-
}
862+
VAS_GZIP_DEF_FEAT_TYPE, &hv_cop_caps);
877863

878-
if (copypaste_feat && firmware_has_feature(FW_FEATURE_LPAR))
879-
of_reconfig_notifier_register(&pseries_vas_nb);
864+
if (!rc && copypaste_feat) {
865+
if (firmware_has_feature(FW_FEATURE_LPAR))
866+
of_reconfig_notifier_register(&pseries_vas_nb);
880867

881-
pr_info("GZIP feature is available\n");
868+
pr_info("GZIP feature is available\n");
869+
} else {
870+
/*
871+
* Should not happen, but only when get default
872+
* capabilities HCALL failed. So disable copy paste
873+
* feature.
874+
*/
875+
copypaste_feat = false;
876+
}
882877

883-
out_cop:
884-
kfree(hv_cop_caps);
885878
out:
886879
kfree(hv_caps);
887880
return rc;

0 commit comments

Comments
 (0)