Received: by 10.223.164.221 with SMTP id h29csp2602404wrb; Thu, 2 Nov 2017 13:54:34 -0700 (PDT) X-Google-Smtp-Source: ABhQp+REI3oJbmpUWbn9HU3jXdzskDksG6/bWSnoTkofrlfjAPGvkdiMIyh1TkdTfGSAf7LuYwvX X-Received: by 10.99.178.86 with SMTP id t22mr4889604pgo.382.1509656074530; Thu, 02 Nov 2017 13:54:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509656074; cv=none; d=google.com; s=arc-20160816; b=bprf24vs+VjYLUwD7bAv0nVbuYjAwgwZ0bb2A1UcQ322Qer0wnapgrraovqZKOt39e BotWtO4+/WicrHffqUfCF3hxJb59gBXaCoF4gQR4asmozanaTePIP2xH3cbAq2UtC0O5 5/RG+LMZ1eJ56hjUfncOv2Wco0rxUTs9P5XG/e0kZfZFocEka74HhBwIa15vQ8L5TGUs LtrmZBmc5JNgAjxKX+sK4YXyu3iA6UxoWGVJylX27jWDzsl99lHODqK3NseR1Mkflkkp wCPkaPUyxunsBjXaodGg26evWTK7ejK0eye7NQcVYgWmNTZ4KGvVbBvXjBrQ727bZlIJ 0i2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :content-language:mime-version:user-agent:date:organization:subject :from:in-reply-to:cc:to:arc-authentication-results; bh=Q5OuWGPZhpF7cvtyy9mOq1viLjdkApH1GNtax2184gI=; b=Aq/W07Vg02DTv02fY5EBq2znZX+lvomGmwWJI9eQTkMK2K0kspQHB2rDvdoi7cJh1+ 7Gu0HpyK0YF9FAstcqg476cFA4R8cRJ4sdSjOZJTjpgQVH5kc/IE7moUrQBIziiz3bdn LODApYyasLxXyzDnn81m9igEp+ECuNm+Xp9VmHtpmAqp6ki351hIoJsA9ljIN4FfPkUz jwP+KQpW9WCec3laphSdr6DtRGZj+mgZb/lKGuhPkOfmIcM/pLEKChOCrD22MuHrC2Zb /cjxxzNRwXrsWz5f5XijGVd/8wJtKN+ddC/l0/Z9igtqXUF/DMNny8SzNFcXJVtGMEcL gYMw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ay2si2801959plb.434.2017.11.02.13.54.20; Thu, 02 Nov 2017 13:54:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934566AbdKBUxb (ORCPT + 99 others); Thu, 2 Nov 2017 16:53:31 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:60298 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934538AbdKBUx0 (ORCPT ); Thu, 2 Nov 2017 16:53:26 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vA2KlcvY009315 for ; Thu, 2 Nov 2017 16:53:26 -0400 Received: from e11.ny.us.ibm.com (e11.ny.us.ibm.com [129.33.205.201]) by mx0a-001b2d01.pphosted.com with ESMTP id 2e06d6wsa4-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 02 Nov 2017 16:53:26 -0400 Received: from localhost by e11.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 2 Nov 2017 16:53:25 -0400 Received: from b01cxnp22034.gho.pok.ibm.com (9.57.198.24) by e11.ny.us.ibm.com (146.89.104.198) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 2 Nov 2017 16:53:22 -0400 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp22034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id vA2KrMNb53346446; Thu, 2 Nov 2017 20:53:22 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F370FB2054; Thu, 2 Nov 2017 16:50:34 -0400 (EDT) Received: from oc1554177480.ibm.com (unknown [9.53.92.194]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP id 55525B204E; Thu, 2 Nov 2017 16:50:34 -0400 (EDT) To: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Cc: Michael Ellerman , Michael Bringmann , Nathan Fontenot , John Allen , Tyrel Datwyler , Thomas Falcon In-Reply-To: From: Michael Bringmann Subject: [PATCH 3/3] postmigration/memory: Associativity & ibm,dynamic-memory-v2 Organization: IBM Linux Technology Center Date: Thu, 2 Nov 2017 15:53:21 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 17110220-2213-0000-0000-00000235913E X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008000; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000239; SDB=6.00940226; UDB=6.00474101; IPR=6.00720482; BA=6.00005668; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017838; XFM=3.00000015; UTC=2017-11-02 20:53:23 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17110220-2214-0000-0000-0000580B3EF9 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-11-02_07:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 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-1707230000 definitions=main-1711020256 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org powerpc/hotplug/memory: 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. Previous efforts only recognized whether a block's assignment had changed in the property. Topology migration requires us to compare the 'aa_index' values of the old/new properties and 'readd' any block for which the setting has changed. Signed-off-by: Michael Bringmann --- arch/powerpc/include/asm/prom.h | 12 ++ arch/powerpc/platforms/pseries/hotplug-memory.c | 175 +++++++++++++++++++++-- 2 files changed, 175 insertions(+), 12 deletions(-) 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 7aba515..aa44011 100644 --- a/arch/powerpc/platforms/pseries/hotplug-memory.c +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c @@ -1153,9 +1153,9 @@ static int pseries_update_drconf_memory(struct of_reconfig_data *pr) memblock_size); break; } else if ((!(be32_to_cpu(old_drmem[i].flags) & - DRCONF_MEM_ASSIGNED)) && - (be32_to_cpu(new_drmem[i].flags) & - DRCONF_MEM_ASSIGNED)) { + DRCONF_MEM_ASSIGNED)) && + (be32_to_cpu(new_drmem[i].flags) & + DRCONF_MEM_ASSIGNED)) { rc = memblock_add(be64_to_cpu(old_drmem[i].base_addr), memblock_size); rc = (rc < 0) ? -EINVAL : 0; @@ -1171,14 +1171,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; @@ -1208,11 +1305,47 @@ static int pseries_update_ala_memory_aai(int aa_index, return 0; } +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; @@ -1225,8 +1358,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); - return -ENODEV; + v1 = false; + dmprop = of_find_property(dn, "ibm,dynamic-memory-v2", + NULL); + if (!dmprop) { + of_node_put(dn); + return -ENODEV; + } } /* @@ -1268,19 +1406,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); @@ -1303,6 +1452,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); From 1582981712332644200@xxx Thu Nov 02 18:56:42 +0000 2017 X-GM-THRID: 1581165149326875379 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread