From patchwork Thu Nov 16 17:51:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Bringmann X-Patchwork-Id: 838739 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yd8sc1cRGz9s03 for ; Fri, 17 Nov 2017 05:29:24 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3yd8sc0B3LzDrFp for ; Fri, 17 Nov 2017 05:29:24 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=mwb@linux.vnet.ibm.com; receiver=) 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 3yd81S2Rk4zDrD3 for ; Fri, 17 Nov 2017 04:51:08 +1100 (AEDT) Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vAGHnJqI080334 for ; Thu, 16 Nov 2017 12:51:06 -0500 Received: from e37.co.us.ibm.com (e37.co.us.ibm.com [32.97.110.158]) by mx0a-001b2d01.pphosted.com with ESMTP id 2e9etfj25b-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 16 Nov 2017 12:51:06 -0500 Received: from localhost by e37.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 16 Nov 2017 10:51:05 -0700 Received: from b03cxnp08026.gho.boulder.ibm.com (9.17.130.18) by e37.co.us.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 16 Nov 2017 10:51:02 -0700 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id vAGHp2u860817594; Thu, 16 Nov 2017 10:51:02 -0700 Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F014A6E035; Thu, 16 Nov 2017 10:51:01 -0700 (MST) Received: from oc2832402873.ibm.com (unknown [9.53.92.243]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP id 6A6856E040; Thu, 16 Nov 2017 10:51:01 -0700 (MST) To: linuxppc-dev@lists.ozlabs.org From: Michael Bringmann Subject: [PATCH V2 2/3] postmigration/memory: Review assoc lookup array changes Organization: IBM Linux Technology Center In-Reply-To: <030d7727-9b39-f9ab-53e6-6a47605ac6b3@linux.vnet.ibm.com> Date: Thu, 16 Nov 2017 11:51:01 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 Content-Language: en-US X-TM-AS-GCONF: 00 x-cbid: 17111617-0024-0000-0000-0000177F85EE X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008075; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000240; SDB=6.00946793; UDB=6.00477951; IPR=6.00727084; BA=6.00005694; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00018048; XFM=3.00000015; UTC=2017-11-16 17:51:03 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17111617-0025-0000-0000-00004D872B62 Message-Id: <5b03bced-529c-9712-ccd1-05e55a6c8f15@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-11-16_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1711160238 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.24 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Falcon , John Allen , Michael Bringmann , Tyrel Datwyler , Nathan Fontenot Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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 V2: -- Remove unnecessary spacing changes --- arch/powerpc/platforms/pseries/hotplug-memory.c | 119 +++++++++++++++++++++++ 1 file changed, 119 insertions(+) diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c index c61cfc6..b37e6ad 100644 --- a/arch/powerpc/platforms/pseries/hotplug-memory.c +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c @@ -1171,6 +1171,122 @@ 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; + + 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)) { + pseries_memory_readd_by_index( + be32_to_cpu(drmem[i].drc_index)); + } + } + + return 0; +} + +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) { @@ -1187,6 +1303,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);