From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3zqvFb5x8bzF14T for ; Tue, 27 Feb 2018 07:54:11 +1100 (AEDT) Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w1QKs4XY074383 for ; Mon, 26 Feb 2018 15:54:09 -0500 Received: from e12.ny.us.ibm.com (e12.ny.us.ibm.com [129.33.205.202]) by mx0a-001b2d01.pphosted.com with ESMTP id 2gcp1wgmev-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 26 Feb 2018 15:54:09 -0500 Received: from localhost by e12.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 26 Feb 2018 15:54:08 -0500 From: Michael Bringmann To: linuxppc-dev@lists.ozlabs.org Subject: [RFC v2 2/3] postmigration/memory: Review assoc lookup array changes Cc: Michael Bringmann , Nathan Fontenot , John Allen , Tyrel Datwyler , Thomas Falcon In-Reply-To: <9cf9df97-6934-c9b5-4f07-417fad6e43d1@linux.vnet.ibm.com> Date: Mon, 26 Feb 2018 14:53:21 -0600 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Message-Id: <02fbce66-e91a-e553-21da-b9deedc2c528@linux.vnet.ibm.com> List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , postmigration/memory: In an LPAR migration scenario, the property "ibm,associativity-lookup-arrays" may change. In the event that a row of the array differs, locate all assigned memory blocks with that 'aa_index' and 're-add' them to the system memory block data structures. In the process of the 're-add', the appropriate entry of the property 'ibm,dynamic-memory' would be updated as well as any other applicable system data structures. Signed-off-by: Michael Bringmann --- Changes in RFC v2: -- Simplify code to update memory nodes during mobility checks. Remove functions to generate extra HP_ELOG messages in favor of direct function calls to dlpar_memory_readd_by_index. --- arch/powerpc/platforms/pseries/hotplug-memory.c | 120 +++++++++++++++++++++++ 1 file changed, 120 insertions(+) diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c index 2341eae..b63181d 100644 --- a/arch/powerpc/platforms/pseries/hotplug-memory.c +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c @@ -1051,6 +1051,123 @@ static int pseries_update_drconf_memory(struct of_reconfig_data *pr) return rc; } +struct assoc_arrays { + u32 n_arrays; + u32 array_sz; + const __be32 *arrays; +}; + +static int pseries_update_ala_memory_aai(int aa_index, + struct property *dmprop) +{ + struct of_drconf_cell *drmem; + u32 entries; + __be32 *p; + int i; + int rc = 0; + + p = (__be32 *) dmprop->value; + if (!p) + return -EINVAL; + + /* The first int of the property is the number of lmb's + * described by the property. This is followed by an array + * of of_drconf_cell entries. Get the number of entries + * and skip to the array of of_drconf_cell's. + */ + entries = be32_to_cpu(*p++); + drmem = (struct of_drconf_cell *)p; + + for (i = 0; i < entries; i++) { + if ((be32_to_cpu(drmem[i].aa_index) != aa_index) && + (be32_to_cpu(drmem[i].flags) & DRCONF_MEM_ASSIGNED)) { + rc = dlpar_memory_readd_by_index( + be32_to_cpu(drmem[i].drc_index)); + } + } + + return rc; +} + +static int pseries_update_ala_memory(struct of_reconfig_data *pr) +{ + struct assoc_arrays new_ala, old_ala; + struct device_node *dn; + struct property *dmprop; + __be32 *p; + int i, lim; + + if (rtas_hp_event) + return 0; + + dn = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory"); + if (!dn) + return -ENODEV; + + dmprop = of_find_property(dn, "ibm,dynamic-memory", NULL); + if (!dmprop) { + of_node_put(dn); + return -ENODEV; + } + + /* + * The layout of the ibm,associativity-lookup-arrays + * property is a number N indicating the number of + * associativity arrays, followed by a number M + * indicating the size of each associativity array, + * followed by a list of N associativity arrays. + */ + + p = (__be32 *) pr->old_prop->value; + if (!p) { + of_node_put(dn); + return -EINVAL; + } + old_ala.n_arrays = of_read_number(p++, 1); + old_ala.array_sz = of_read_number(p++, 1); + old_ala.arrays = p; + + p = (__be32 *) pr->prop->value; + if (!p) { + of_node_put(dn); + return -EINVAL; + } + new_ala.n_arrays = of_read_number(p++, 1); + new_ala.array_sz = of_read_number(p++, 1); + new_ala.arrays = p; + + lim = (new_ala.n_arrays > old_ala.n_arrays) ? old_ala.n_arrays : + new_ala.n_arrays; + + if (old_ala.array_sz == new_ala.array_sz) { + + for (i = 0; i < lim; i++) { + int index = (i * new_ala.array_sz); + + if (!memcmp(&old_ala.arrays[index], + &new_ala.arrays[index], + new_ala.array_sz)) + continue; + + pseries_update_ala_memory_aai(i, dmprop); + } + + for (i = lim; i < new_ala.n_arrays; i++) + pseries_update_ala_memory_aai(i, dmprop); + + } else { + /* Update all entries representing these rows; + * as all rows have different sizes, none can + * have equivalent values. + */ + for (i = 0; i < lim; i++) + pseries_update_ala_memory_aai(i, dmprop); + } + + of_node_put(dn); + return 0; +} + static int pseries_memory_notifier(struct notifier_block *nb, unsigned long action, void *data) { @@ -1067,6 +1184,9 @@ static int pseries_memory_notifier(struct notifier_block *nb, case OF_RECONFIG_UPDATE_PROPERTY: if (!strcmp(rd->prop->name, "ibm,dynamic-memory")) err = pseries_update_drconf_memory(rd); + if (!strcmp(rd->prop->name, + "ibm,associativity-lookup-arrays")) + err = pseries_update_ala_memory(rd); break; } return notifier_from_errno(err);