From patchwork Mon Jan 8 17:32:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Bringmann X-Patchwork-Id: 856957 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 3zFjCP41KHz9t0m for ; Tue, 9 Jan 2018 04:37:37 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3zFjCP1LZ5zF0cp for ; Tue, 9 Jan 2018 04:37:37 +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 3zFj622NM2zF0T0 for ; Tue, 9 Jan 2018 04:32:58 +1100 (AEDT) Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.21) with SMTP id w08HWRfB001330 for ; Mon, 8 Jan 2018 12:32:56 -0500 Received: from e38.co.us.ibm.com (e38.co.us.ibm.com [32.97.110.159]) by mx0a-001b2d01.pphosted.com with ESMTP id 2fccfkswt3-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 08 Jan 2018 12:32:55 -0500 Received: from localhost by e38.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 8 Jan 2018 10:32:54 -0700 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e38.co.us.ibm.com (192.168.1.138) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 8 Jan 2018 10:32:53 -0700 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w08HWqkl10223996; Mon, 8 Jan 2018 10:32:52 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A8E8578037; Mon, 8 Jan 2018 10:32:52 -0700 (MST) Received: from oc5000245537.ibm.com (unknown [9.53.92.226]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP id 40F7F7803F; Mon, 8 Jan 2018 10:32:52 -0700 (MST) To: linuxppc-dev@lists.ozlabs.org From: Michael Bringmann Organization: IBM Linux Technology Center Subject: [PATCH V3 1/3] hotplug/mobility: Apply assoc updates for Post Migration Topo In-Reply-To: <0658ebca-aa3c-9251-9d74-b645633a750a@linux.vnet.ibm.com> Date: Mon, 8 Jan 2018 11:32:25 -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: 18010817-0028-0000-0000-000008F59432 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008342; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000245; SDB=6.00972101; UDB=6.00492442; IPR=6.00752052; MB=3.00018927; MTD=3.00000007; XFM=3.00000015; UTC=2018-01-08 17:32:54 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18010817-0029-0000-0000-0000390CB273 Message-Id: <991e6ef3-f1b9-acf6-4f71-ccf00aaeea24@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-01-08_11:, , 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-1801080250 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: Nathan Fontenot , Michael Bringmann Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" hotplug/mobility: Recognize more changes to the associativity of memory blocks described by the 'ibm,dynamic-memory' and 'cpu' properties when processing the topology of LPARS in Post Migration events. Previous efforts only recognized whether a memory block's assignment had changed in the property. Changes here include: * Checking the aa_index values of the old/new properties and 'readd' any block for which the setting has changed. * Checking for changes in cpu associativity and making 'readd' calls when differences are observed. Signed-off-by: Michael Bringmann --- Changes in V3: -- Simplify code to update CPU nodes during mobility checks. Remove functions to generate extra HP_ELOG messages in favor of direct function calls to dlpar_cpu_readd_by_index. -- Move check for "cpu" node type from pseries_update_cpu to pseries_smp_notifier in 'hotplug-cpu.c' -- Remove functions 'pseries_memory_readd_by_index' and 'pseries_cpu_readd_by_index' as no longer needed outside of 'mobility.c'. --- arch/powerpc/platforms/pseries/hotplug-cpu.c | 69 +++++++++++++++++++++++ arch/powerpc/platforms/pseries/hotplug-memory.c | 7 ++ 2 files changed, 76 insertions(+) diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c b/arch/powerpc/platforms/pseries/hotplug-cpu.c index a7d14aa7..64e29d76 100644 --- a/arch/powerpc/platforms/pseries/hotplug-cpu.c +++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c @@ -636,6 +636,27 @@ static int dlpar_cpu_remove_by_index(u32 drc_index) return rc; } +static int dlpar_cpu_readd_by_index(u32 drc_index) +{ + int rc = 0; + + pr_info("Attempting to update CPU, drc index %x\n", drc_index); + + if (dlpar_cpu_remove_by_index(drc_index)) + rc = -EINVAL; + else if (dlpar_cpu_add(drc_index)) + rc = -EINVAL; + + if (rc) + pr_info("Failed to update cpu at drc_index %lx\n", + (unsigned long int)drc_index); + else + pr_info("CPU at drc_index %lx was updated\n", + (unsigned long int)drc_index); + + return rc; +} + static int find_dlpar_cpus_to_remove(u32 *cpu_drcs, int cpus_to_remove) { struct device_node *dn; @@ -826,6 +847,9 @@ int dlpar_cpu(struct pseries_hp_errorlog *hp_elog) else rc = -EINVAL; break; + case PSERIES_HP_ELOG_ACTION_READD: + rc = dlpar_cpu_readd_by_index(drc_index); + break; default: pr_err("Invalid action (%d) specified\n", hp_elog->action); rc = -EINVAL; @@ -876,12 +900,53 @@ static ssize_t dlpar_cpu_release(const char *buf, size_t count) #endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */ +static int pseries_update_cpu(struct of_reconfig_data *pr) +{ + u32 old_entries, new_entries; + __be32 *p, *old_assoc, *new_assoc; + int rc = 0; + + /* So far, we only handle the 'ibm,associativity' property, + * here. + * The first int of the property is the number of domains + * described. This is followed by an array of level values. + */ + p = (__be32 *) pr->old_prop->value; + if (!p) + return -EINVAL; + old_entries = be32_to_cpu(*p++); + old_assoc = p; + + p = (__be32 *)pr->prop->value; + if (!p) + return -EINVAL; + new_entries = be32_to_cpu(*p++); + new_assoc = p; + + if (old_entries == new_entries) { + int sz = old_entries * sizeof(int); + + if (!memcmp(old_assoc, new_assoc, sz)) + rc = dlpar_cpu_readd_by_index( + be32_to_cpu(pr->dn->phandle)); + + } else { + rc = dlpar_cpu_readd_by_index( + be32_to_cpu(pr->dn->phandle)); + } + + return rc; +} + static int pseries_smp_notifier(struct notifier_block *nb, unsigned long action, void *data) { struct of_reconfig_data *rd = data; int err = 0; + if (strcmp(pr->dn->type, "cpu")) + return notifier_from_errno(err); + switch (action) { case OF_RECONFIG_ATTACH_NODE: err = pseries_add_processor(rd->dn); @@ -889,6 +954,10 @@ static int pseries_smp_notifier(struct notifier_block *nb, case OF_RECONFIG_DETACH_NODE: pseries_remove_processor(rd->dn); break; + case OF_RECONFIG_UPDATE_PROPERTY: + if (!strcmp(rd->prop->name, "ibm,associativity")) + err = pseries_update_cpu(rd); + break; } return notifier_from_errno(err); } diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c index 1d48ab4..0e2ae20 100644 --- a/arch/powerpc/platforms/pseries/hotplug-memory.c +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c @@ -1160,6 +1160,13 @@ static int pseries_update_drconf_memory(struct of_reconfig_data *pr) memblock_size); rc = (rc < 0) ? -EINVAL : 0; break; + } else if ((be32_to_cpu(old_drmem[i].aa_index) != + be32_to_cpu(new_drmem[i].aa_index)) && + (be32_to_cpu(new_drmem[i].flags) & + DRCONF_MEM_ASSIGNED)) { + rc = dlpar_memory_readd_by_index( + be32_to_cpu(new_drmem[i].drc_index), + pr->prop); } } return rc; From patchwork Mon Jan 8 17:32:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Bringmann X-Patchwork-Id: 856963 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 3zFjFt1Qmwz9sNV for ; Tue, 9 Jan 2018 04:39:46 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3zFjFs6GGRzDr1M for ; Tue, 9 Jan 2018 04:39:45 +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.158.5; helo=mx0a-001b2d01.pphosted.com; envelope-from=mwb@linux.vnet.ibm.com; receiver=) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 3zFj6D3fdKzF0TB for ; Tue, 9 Jan 2018 04:33:08 +1100 (AEDT) Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.21) with SMTP id w08HTxK8004970 for ; Mon, 8 Jan 2018 12:33:05 -0500 Received: from e32.co.us.ibm.com (e32.co.us.ibm.com [32.97.110.150]) by mx0b-001b2d01.pphosted.com with ESMTP id 2fcc46u4dq-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 08 Jan 2018 12:33:04 -0500 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 8 Jan 2018 10:33:04 -0700 Received: from b03cxnp07029.gho.boulder.ibm.com (9.17.130.16) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 8 Jan 2018 10:33:02 -0700 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w08HX17v11796920; Mon, 8 Jan 2018 10:33:01 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B800B78038; Mon, 8 Jan 2018 10:33:01 -0700 (MST) Received: from oc5000245537.ibm.com (unknown [9.53.92.226]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP id 484C27803F; Mon, 8 Jan 2018 10:33:01 -0700 (MST) To: linuxppc-dev@lists.ozlabs.org From: Michael Bringmann Subject: [PATCH V3 2/3] postmigration/memory: Review assoc lookup array changes Organization: IBM Linux Technology Center In-Reply-To: <0658ebca-aa3c-9251-9d74-b645633a750a@linux.vnet.ibm.com> Date: Mon, 8 Jan 2018 11:32:34 -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: 18010817-0004-0000-0000-0000137D02DC X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008342; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000245; SDB=6.00972101; UDB=6.00492442; IPR=6.00752051; BA=6.00005767; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00018927; XFM=3.00000015; UTC=2018-01-08 17:33:03 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18010817-0005-0000-0000-00008592D742 Message-Id: <0119412e-6384-815b-a0b3-042612f53c05@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-01-08_11:, , 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=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1801080250 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: Nathan Fontenot , Michael Bringmann 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 V3: -- 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 | 121 +++++++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c index 0e2ae20..04208b0 100644 --- a/arch/powerpc/platforms/pseries/hotplug-memory.c +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c @@ -1172,6 +1172,124 @@ 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), + dmprop); + } + } + + 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) { @@ -1188,6 +1306,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); From patchwork Mon Jan 8 17:32:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Bringmann X-Patchwork-Id: 856966 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zFjJQ22p8z9s74 for ; Tue, 9 Jan 2018 04:41:58 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3zFjJQ05FMzDqw7 for ; Tue, 9 Jan 2018 04:41:58 +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 3zFj6Q6q2mzF0bL for ; Tue, 9 Jan 2018 04:33:18 +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.21) with SMTP id w08HTQph115727 for ; Mon, 8 Jan 2018 12:33:16 -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 2fc9pftht9-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 08 Jan 2018 12:33:16 -0500 Received: from localhost by e37.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 8 Jan 2018 10:33:15 -0700 Received: from b03cxnp08027.gho.boulder.ibm.com (9.17.130.19) by e37.co.us.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 8 Jan 2018 10:33:12 -0700 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w08HXB8Y9503126; Mon, 8 Jan 2018 10:33:11 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B0D3078038; Mon, 8 Jan 2018 10:33:11 -0700 (MST) Received: from oc5000245537.ibm.com (unknown [9.53.92.226]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP id 64FA078037; Mon, 8 Jan 2018 10:33:11 -0700 (MST) To: linuxppc-dev@lists.ozlabs.org From: Michael Bringmann Subject: [PATCH V3 3/3] postmigration/memory: Associativity & ibm,dynamic-memory-v2 Organization: IBM Linux Technology Center In-Reply-To: <0658ebca-aa3c-9251-9d74-b645633a750a@linux.vnet.ibm.com> Date: Mon, 8 Jan 2018 11:32:44 -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: 18010817-0024-0000-0000-000017C30D43 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008342; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000245; SDB=6.00972101; UDB=6.00492442; IPR=6.00752051; BA=6.00005767; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00018927; XFM=3.00000015; UTC=2018-01-08 17:33:13 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18010817-0025-0000-0000-00004E347B0A Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-01-08_11:, , 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-1801080250 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: Nathan Fontenot , Michael Bringmann Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" postmigration/memory: Now apply changes to the associativity of memory blocks described by the 'ibm,dynamic-memory-v2' property regarding the topology of LPARS in Post Migration events. * Extend the previous work done for the 'ibm,associativity-lookup-array' to apply to either property 'ibm,dynamic-memory' or 'ibm,dynamic-memory-v2', whichever is present. * Add new code to parse the 'ibm,dynamic-memory-v2' property looking for differences in block 'assignment', associativity indexes per block, and any other difference currently known. When block differences are recognized, the memory block may be removed, added, or updated depending upon the state of the new device tree property and differences from the migrated value of the property. Signed-off-by: Michael Bringmann --- Changes in V3: -- Remove unnecessary spacing changes from patch. -- Improve patch description. --- arch/powerpc/include/asm/prom.h | 12 ++ arch/powerpc/platforms/pseries/hotplug-memory.c | 169 ++++++++++++++++++++++- 2 files changed, 172 insertions(+), 9 deletions(-) + if (!dmprop) { + of_node_put(dn); + return -ENODEV; + } } /* @@ -1271,19 +1409,30 @@ static int pseries_update_ala_memory(struct of_reconfig_data *pr) new_ala.array_sz)) continue; - pseries_update_ala_memory_aai(i, dmprop); + if (v1) + pseries_update_ala_memory_aai_v1(i, dmprop); + else + pseries_update_ala_memory_aai_v2(i, dmprop); } - for (i = lim; i < new_ala.n_arrays; i++) - pseries_update_ala_memory_aai(i, dmprop); + for (i = lim; i < new_ala.n_arrays; i++) { + if (v1) + pseries_update_ala_memory_aai_v1(i, dmprop); + else + pseries_update_ala_memory_aai_v2(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); + for (i = 0; i < lim; i++) { + if (v1) + pseries_update_ala_memory_aai_v1(i, dmprop); + else + pseries_update_ala_memory_aai_v2(i, dmprop); + } } of_node_put(dn); @@ -1306,6 +1455,8 @@ 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,dynamic-memory-v2")) + err = pseries_update_drconf_memory_v2(rd); if (!strcmp(rd->prop->name, "ibm,associativity-lookup-arrays")) err = pseries_update_ala_memory(rd); diff --git a/arch/powerpc/include/asm/prom.h b/arch/powerpc/include/asm/prom.h index 825bd59..e16ef0f 100644 --- a/arch/powerpc/include/asm/prom.h +++ b/arch/powerpc/include/asm/prom.h @@ -92,6 +92,18 @@ struct of_drconf_cell { u32 flags; }; +/* The of_drconf_cell_v2 struct defines the layout of the LMB array + * specified in the device tree property + * ibm,dynamic-reconfiguration-memory/ibm,dynamic-memory-v2 + */ +struct of_drconf_cell_v2 { + u32 num_seq_lmbs; + u64 base_address; + u32 drc_index; + u32 aa_index; + u32 flags; +} __attribute__((packed)); + #define DRCONF_MEM_ASSIGNED 0x00000008 #define DRCONF_MEM_AI_INVALID 0x00000040 #define DRCONF_MEM_RESERVED 0x00000080 diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c index 04208b0..d406b41 100644 --- a/arch/powerpc/platforms/pseries/hotplug-memory.c +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c @@ -1172,14 +1172,111 @@ static int pseries_update_drconf_memory(struct of_reconfig_data *pr) return rc; } +static inline int pseries_memory_v2_find_drc(u32 drc_index, + u64 *base_addr, unsigned long memblock_size, + struct of_drconf_cell_v2 **drmem, + struct of_drconf_cell_v2 *last_drmem) +{ + struct of_drconf_cell_v2 *dm = (*drmem); + + while (dm < last_drmem) { + if ((be32_to_cpu(dm->drc_index) <= drc_index) && + (drc_index <= (be32_to_cpu(dm->drc_index)+ + be32_to_cpu(dm->num_seq_lmbs)-1))) { + int offset = drc_index - be32_to_cpu(dm->drc_index); + (*base_addr) = be64_to_cpu(dm->base_address) + + (offset * memblock_size); + break; + } else if (drc_index > (be32_to_cpu(dm->drc_index)+ + be32_to_cpu(dm->num_seq_lmbs)-1)) { + dm++; + (*drmem) = dm; + } else if (be32_to_cpu(dm->drc_index) > drc_index) { + return -1; + } + } + + return 0; +} + +static int pseries_update_drconf_memory_v2(struct of_reconfig_data *pr) +{ + struct of_drconf_cell_v2 *new_drmem, *old_drmem, *last_old_drmem; + unsigned long memblock_size; + u32 new_entries, old_entries; + u64 old_base_addr; + __be32 *p; + int i, rc = 0; + + if (rtas_hp_event) + return 0; + + memblock_size = pseries_memory_block_size(); + if (!memblock_size) + 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_v2 entries. Get the number of entries + * and skip to the array of of_drconf_cell_v2's. + */ + p = (__be32 *) pr->old_prop->value; + if (!p) + return -EINVAL; + old_entries = be32_to_cpu(*p++); + old_drmem = (struct of_drconf_cell_v2 *)p; + last_old_drmem = old_drmem + + (sizeof(struct of_drconf_cell_v2) * old_entries); + + p = (__be32 *)pr->prop->value; + new_entries = be32_to_cpu(*p++); + new_drmem = (struct of_drconf_cell_v2 *)p; + + for (i = 0; i < new_entries; i++) { + int j; + u32 new_drc_index = be32_to_cpu(new_drmem->drc_index); + + for (j = 0; j < new_drmem->num_seq_lmbs; j++) { + if (!pseries_memory_v2_find_drc(new_drc_index+j, + &old_base_addr, + memblock_size, + &old_drmem, + last_old_drmem)) { + if ((be32_to_cpu(old_drmem->flags) & + DRCONF_MEM_ASSIGNED) && + (!(be32_to_cpu(new_drmem->flags) & + DRCONF_MEM_ASSIGNED))) { + rc = pseries_remove_memblock( + old_base_addr, + memblock_size); + } else if ((!(be32_to_cpu(old_drmem->flags) & + DRCONF_MEM_ASSIGNED)) && + (be32_to_cpu(new_drmem->flags) & + DRCONF_MEM_ASSIGNED)) { + rc = memblock_add( + old_base_addr, memblock_size); + } else if ((be32_to_cpu(old_drmem->aa_index) != + be32_to_cpu(new_drmem->aa_index)) && + (be32_to_cpu(new_drmem->flags) & + DRCONF_MEM_ASSIGNED)) { + pseries_memory_readd_by_index( + new_drc_index+j); + } + } + } + } + + return 0; +} + 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) +static int pseries_update_ala_memory_aai_v1(int aa_index, + struct property *dmprop) { struct of_drconf_cell *drmem; u32 entries; @@ -1211,11 +1308,47 @@ static int pseries_update_ala_memory_aai(int aa_index, return rc; } +static int pseries_update_ala_memory_aai_v2(int aa_index, + struct property *dmprop) +{ + struct of_drconf_cell_v2 *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_v2 entries. Get the number of entries + * and skip to the array of of_drconf_cell_v2's. + */ + entries = be32_to_cpu(*p++); + drmem = (struct of_drconf_cell_v2 *)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)) { + int j; + int lim = be32_to_cpu(drmem->num_seq_lmbs); + u32 drc_index = be32_to_cpu(drmem->drc_index); + + for (j = 0; j < lim; j++) + pseries_memory_readd_by_index(drc_index+j); + } + } + + 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; + bool v1 = true; __be32 *p; int i, lim; @@ -1228,8 +1361,13 @@ static int pseries_update_ala_memory(struct of_reconfig_data *pr) dmprop = of_find_property(dn, "ibm,dynamic-memory", NULL); if (!dmprop) { - of_node_put(dn); -- Michael W. Bringmann Linux Technology Center IBM Corporation Tie-Line 363-5196 External: (512) 286-5196 Cell: (512) 466-0650 mwb@linux.vnet.ibm.com - return -ENODEV; + v1 = false; + dmprop = of_find_property(dn, "ibm,dynamic-memory-v2", + NULL);