From patchwork Wed May 9 16:13:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Bringmann X-Patchwork-Id: 910974 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 40h1h352Tfz9s3D for ; Thu, 10 May 2018 02:16:35 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40h1h33hL8zF2Rd for ; Thu, 10 May 2018 02:16:35 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.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=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com 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 40h1cL1SH0zF2RK for ; Thu, 10 May 2018 02:13:21 +1000 (AEST) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w49G9NL1057922 for ; Wed, 9 May 2018 12:13:18 -0400 Received: from e19.ny.us.ibm.com (e19.ny.us.ibm.com [129.33.205.209]) by mx0b-001b2d01.pphosted.com with ESMTP id 2hv3df38x2-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 09 May 2018 12:13:18 -0400 Received: from localhost by e19.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 9 May 2018 12:13:17 -0400 Received: from b01cxnp23033.gho.pok.ibm.com (9.57.198.28) by e19.ny.us.ibm.com (146.89.104.206) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 9 May 2018 12:13:15 -0400 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w49GDF8w64815352; Wed, 9 May 2018 16:13:15 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 78FC8AC041; Wed, 9 May 2018 12:14:46 -0400 (EDT) Received: from oc5000245537.ibm.com (unknown [9.80.200.26]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP id D2232AC03A; Wed, 9 May 2018 12:14:45 -0400 (EDT) To: linuxppc-dev@lists.ozlabs.org From: Michael Bringmann Subject: [RFC v3 1/3] powerpc migration/drmem: Modify DRMEM code to export more features Openpgp: preference=signencrypt Autocrypt: addr=mwb@linux.vnet.ibm.com; prefer-encrypt=mutual; keydata= xsBNBFcY7GcBCADzw3en+yzo9ASFGCfldVkIg95SAMPK0myXp2XJYET3zT45uBsX/uj9/2nA lBmXXeOSXnPfJ9V3vtiwcfATnWIsVt3tL6n1kqikzH9nXNxZT7MU/7gqzWZngMAWh/GJ9qyg DTOZdjsvdUNUWxtiLvBo7y+reA4HjlQhwhYxxvCpXBeRoF0qDWfQ8DkneemqINzDZPwSQ7zY t4F5iyN1I9GC5RNK8Y6jiKmm6b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ryiXxVx/7kSAJEFQJfA5P06g8NLR25Qpq9BLsN7 ++dxQ+CLKzSEb1X24hYAJZpOhS8ev3ii+M/XIo+olDBKuTaTgB6elrg3CaxUsVgLBJ+jbRkW yQe2S5f/Ja1ThDpSSLLWLiLK/z7+gaqwhnwjQ8Z8Y9D2itJQcj4itHilwImsqwLG7SxzC0NX IQ5KaAFYdRcOgwR8VhhkOIVd70ObSZU+E4pTET1WDz4o65xZ89yfose1No0+r5ht/xWOOrh8 53/hcWvxHVs= Organization: IBM Linux Technology Center In-Reply-To: <5763b190-6b8a-eccb-663a-7d35363c81c8@linux.vnet.ibm.com> Date: Wed, 9 May 2018 11:13:13 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 Content-Language: en-US X-TM-AS-GCONF: 00 x-cbid: 18050916-0056-0000-0000-0000044BD954 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008997; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000259; SDB=6.01029837; UDB=6.00526263; IPR=6.00808971; MB=3.00021013; MTD=3.00000008; XFM=3.00000015; UTC=2018-05-09 16:13:16 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18050916-0057-0000-0000-0000088FE785 Message-Id: <773a0479-6598-beb5-487b-5326835b554f@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-05-09_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 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-1805090150 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 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 , Thomas Falcon , Tyrel Datwyler , John Allen Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" powerpc migration/drmem: Export many of the functions of DRMEM to parse "ibm,dynamic-memory" and "ibm,dynamic-memory-v2" during hotplug operations and for Post Migration events. Also modify the DRMEM initialization code to allow it to, * Be called after system initialization * Provide a separate user copy of the LMB array that is produces * Free the user copy upon request Signed-off-by: Michael Bringmann --- Changes in RFC: -- Separate DRMEM changes into a standalone patch -- Do not export excess functions. Make exported names more explicit. -- Add new iterator to work through a pair of drmem_info arrays. -- Modify DRMEM code to replace usages of dt_root_addr_cells, and dt_mem_next_cell, as these are only available at first boot. --- arch/powerpc/include/asm/drmem.h | 10 +++++ arch/powerpc/mm/drmem.c | 78 +++++++++++++++++++++++++++----------- 2 files changed, 66 insertions(+), 22 deletions(-) diff --git a/arch/powerpc/include/asm/drmem.h b/arch/powerpc/include/asm/drmem.h index ce242b9..c964b89 100644 --- a/arch/powerpc/include/asm/drmem.h +++ b/arch/powerpc/include/asm/drmem.h @@ -35,6 +35,13 @@ struct drmem_lmb_info { &drmem_info->lmbs[0], \ &drmem_info->lmbs[drmem_info->n_lmbs - 1]) +#define for_each_pair_drmem_lmb(dinfo1, lmb1, dinfo2, lmb2) \ + for ((lmb1) = (&dinfo1->lmbs[0]), \ + (lmb2) = (&dinfo2->lmbs[0]); \ + ((lmb1) <= (&dinfo1->lmbs[dinfo1->n_lmbs - 1])) && \ + ((lmb2) <= (&dinfo2->lmbs[dinfo2->n_lmbs - 1])); \ + (lmb1)++, (lmb2)++) + /* * The of_drconf_cell_v1 struct defines the layout of the LMB data * specified in the ibm,dynamic-memory device tree property. @@ -94,6 +101,9 @@ void __init walk_drmem_lmbs(struct device_node *dn, void (*func)(struct drmem_lmb *, const __be32 **)); int drmem_update_dt(void); +struct drmem_lmb_info* drmem_init_lmbs(struct property *prop); +void drmem_lmbs_free(struct drmem_lmb_info *dinfo); + #ifdef CONFIG_PPC_PSERIES void __init walk_drmem_lmbs_early(unsigned long node, void (*func)(struct drmem_lmb *, const __be32 **)); diff --git a/arch/powerpc/mm/drmem.c b/arch/powerpc/mm/drmem.c index 3f18036..d9b281c 100644 --- a/arch/powerpc/mm/drmem.c +++ b/arch/powerpc/mm/drmem.c @@ -20,6 +20,7 @@ static struct drmem_lmb_info __drmem_info; struct drmem_lmb_info *drmem_info = &__drmem_info; +static int n_root_addr_cells; u64 drmem_lmb_memory_max(void) { @@ -193,12 +194,13 @@ int drmem_update_dt(void) return rc; } -static void __init read_drconf_v1_cell(struct drmem_lmb *lmb, +static void read_drconf_v1_cell(struct drmem_lmb *lmb, const __be32 **prop) { const __be32 *p = *prop; - lmb->base_addr = dt_mem_next_cell(dt_root_addr_cells, &p); + lmb->base_addr = of_read_number(p, n_root_addr_cells); + p += n_root_addr_cells; lmb->drc_index = of_read_number(p++, 1); p++; /* skip reserved field */ @@ -209,7 +211,7 @@ static void __init read_drconf_v1_cell(struct drmem_lmb *lmb, *prop = p; } -static void __init __walk_drmem_v1_lmbs(const __be32 *prop, const __be32 *usm, +static void __walk_drmem_v1_lmbs(const __be32 *prop, const __be32 *data, void (*func)(struct drmem_lmb *, const __be32 **)) { struct drmem_lmb lmb; @@ -221,17 +223,18 @@ static void __init __walk_drmem_v1_lmbs(const __be32 *prop, const __be32 *usm, for (i = 0; i < n_lmbs; i++) { read_drconf_v1_cell(&lmb, &prop); - func(&lmb, &usm); + func(&lmb, &data); } } -static void __init read_drconf_v2_cell(struct of_drconf_cell_v2 *dr_cell, +static void read_drconf_v2_cell(struct of_drconf_cell_v2 *dr_cell, const __be32 **prop) { const __be32 *p = *prop; dr_cell->seq_lmbs = of_read_number(p++, 1); - dr_cell->base_addr = dt_mem_next_cell(dt_root_addr_cells, &p); + dr_cell->base_addr = of_read_number(p, n_root_addr_cells); + p += n_root_addr_cells; dr_cell->drc_index = of_read_number(p++, 1); dr_cell->aa_index = of_read_number(p++, 1); dr_cell->flags = of_read_number(p++, 1); @@ -239,7 +242,7 @@ static void __init read_drconf_v2_cell(struct of_drconf_cell_v2 *dr_cell, *prop = p; } -static void __init __walk_drmem_v2_lmbs(const __be32 *prop, const __be32 *usm, +static void __walk_drmem_v2_lmbs(const __be32 *prop, const __be32 *data, void (*func)(struct drmem_lmb *, const __be32 **)) { struct of_drconf_cell_v2 dr_cell; @@ -263,7 +266,7 @@ static void __init __walk_drmem_v2_lmbs(const __be32 *prop, const __be32 *usm, lmb.aa_index = dr_cell.aa_index; lmb.flags = dr_cell.flags; - func(&lmb, &usm); + func(&lmb, &data); } } } @@ -275,6 +278,9 @@ void __init walk_drmem_lmbs_early(unsigned long node, const __be32 *prop, *usm; int len; + if (n_root_addr_cells == 0) + n_root_addr_cells = dt_root_addr_cells; + prop = of_get_flat_dt_prop(node, "ibm,lmb-size", &len); if (!prop || len < dt_root_size_cells * sizeof(__be32)) return; @@ -353,24 +359,26 @@ void __init walk_drmem_lmbs(struct device_node *dn, } } -static void __init init_drmem_v1_lmbs(const __be32 *prop) +static void init_drmem_v1_lmbs(const __be32 *prop, + struct drmem_lmb_info *dinfo) { struct drmem_lmb *lmb; - drmem_info->n_lmbs = of_read_number(prop++, 1); - if (drmem_info->n_lmbs == 0) + dinfo->n_lmbs = of_read_number(prop++, 1); + if (dinfo->n_lmbs == 0) return; - drmem_info->lmbs = kcalloc(drmem_info->n_lmbs, sizeof(*lmb), + dinfo->lmbs = kcalloc(dinfo->n_lmbs, sizeof(*lmb), GFP_KERNEL); - if (!drmem_info->lmbs) + if (!dinfo->lmbs) return; for_each_drmem_lmb(lmb) read_drconf_v1_cell(lmb, &prop); } -static void __init init_drmem_v2_lmbs(const __be32 *prop) +static void init_drmem_v2_lmbs(const __be32 *prop, + struct drmem_lmb_info *dinfo) { struct drmem_lmb *lmb; struct of_drconf_cell_v2 dr_cell; @@ -386,12 +394,12 @@ static void __init init_drmem_v2_lmbs(const __be32 *prop) p = prop; for (i = 0; i < lmb_sets; i++) { read_drconf_v2_cell(&dr_cell, &p); - drmem_info->n_lmbs += dr_cell.seq_lmbs; + dinfo->n_lmbs += dr_cell.seq_lmbs; } - drmem_info->lmbs = kcalloc(drmem_info->n_lmbs, sizeof(*lmb), + dinfo->lmbs = kcalloc(dinfo->n_lmbs, sizeof(*lmb), GFP_KERNEL); - if (!drmem_info->lmbs) + if (!dinfo->lmbs) return; /* second pass, read in the LMB information */ @@ -402,25 +410,51 @@ static void __init init_drmem_v2_lmbs(const __be32 *prop) read_drconf_v2_cell(&dr_cell, &p); for (j = 0; j < dr_cell.seq_lmbs; j++) { - lmb = &drmem_info->lmbs[lmb_index++]; + lmb = &dinfo->lmbs[lmb_index++]; lmb->base_addr = dr_cell.base_addr; - dr_cell.base_addr += drmem_info->lmb_size; + dr_cell.base_addr += dinfo->lmb_size; lmb->drc_index = dr_cell.drc_index; dr_cell.drc_index++; lmb->aa_index = dr_cell.aa_index; - lmb->flags = dr_cell.flags; } } } +void drmem_lmbs_free(struct drmem_lmb_info *dinfo) +{ + if (dinfo) { + kfree(dinfo->lmbs); + kfree(dinfo); + } +} + +struct drmem_lmb_info* drmem_init_lmbs(struct property *prop) +{ + struct drmem_lmb_info *dinfo; + + dinfo = kzalloc(sizeof(*dinfo), GFP_KERNEL); + if (!dinfo) + return NULL; + + if (!strcmp("ibm,dynamic-memory", prop->name)) + init_drmem_v1_lmbs(prop->value, dinfo); + else if (!strcmp("ibm,dynamic-memory-v2", prop->name)) + init_drmem_v2_lmbs(prop->value, dinfo); + + return dinfo; +} + static int __init drmem_init(void) { struct device_node *dn; const __be32 *prop; + if (n_root_addr_cells == 0) + n_root_addr_cells = dt_root_addr_cells; + dn = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory"); if (!dn) { pr_info("No dynamic reconfiguration memory found\n"); @@ -434,11 +468,11 @@ static int __init drmem_init(void) prop = of_get_property(dn, "ibm,dynamic-memory", NULL); if (prop) { - init_drmem_v1_lmbs(prop); + init_drmem_v1_lmbs(prop, drmem_info); } else { prop = of_get_property(dn, "ibm,dynamic-memory-v2", NULL); if (prop) - init_drmem_v2_lmbs(prop); + init_drmem_v2_lmbs(prop, drmem_info); } of_node_put(dn); From patchwork Wed May 9 16:13:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Bringmann X-Patchwork-Id: 910975 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40h1k56Grqz9s3D for ; Thu, 10 May 2018 02:18:21 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40h1k54CT6zF2R2 for ; Thu, 10 May 2018 02:18:21 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.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=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com 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 40h1cS4CGKzF2Qx for ; Thu, 10 May 2018 02:13:28 +1000 (AEST) Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w49G9Etl015770 for ; Wed, 9 May 2018 12:13:24 -0400 Received: from e14.ny.us.ibm.com (e14.ny.us.ibm.com [129.33.205.204]) by mx0b-001b2d01.pphosted.com with ESMTP id 2hv1j79dw3-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 09 May 2018 12:13:24 -0400 Received: from localhost by e14.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 9 May 2018 12:13:23 -0400 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) by e14.ny.us.ibm.com (146.89.104.201) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 9 May 2018 12:13:21 -0400 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w49GDJXK45809830; Wed, 9 May 2018 16:13:20 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4D6D0AC03F; Wed, 9 May 2018 12:14:52 -0400 (EDT) Received: from oc5000245537.ibm.com (unknown [9.80.200.26]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP id 8F651AC040; Wed, 9 May 2018 12:14:51 -0400 (EDT) To: linuxppc-dev@lists.ozlabs.org From: Michael Bringmann Subject: [RFC v3 2/3] powerpc migration/cpu: Associativity & cpu changes Openpgp: preference=signencrypt Autocrypt: addr=mwb@linux.vnet.ibm.com; prefer-encrypt=mutual; keydata= xsBNBFcY7GcBCADzw3en+yzo9ASFGCfldVkIg95SAMPK0myXp2XJYET3zT45uBsX/uj9/2nA lBmXXeOSXnPfJ9V3vtiwcfATnWIsVt3tL6n1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XoYs4RggRRYh6wARAQABwsBfBBgBAgAJBQJX GOxnAhsMAAoJEEhHWoN3abky+RUH/jE08/r5QzaNKYeVhu0uVbgXu5fsxqr2cAxhf+KuwT3T efhEP2alarxzUZdEh4MsG6c+X2NYLbD3cryiXxVx/7kSAJEFQJfA5P06g8NLR25Qpq9BLsN7 ++dxQ+CLKzSEb1X24hYAJZpOhS8ev3ii+M/XIo+olDBKuTaTgB6elrg3CaxUsVgLBJ+jbRkW yQe2S5f/Ja1ThDpSSLLWLiLK/z7+gaqwhnwjQ8Z8Y9D2itJQcj4itHilwImsqwLG7SxzC0NX IQ5KaAFYdRcOgwR8VhhkOIVd70ObSZU+E4pTET1WDz4o65xZ89yfose1No0+r5ht/xWOOrh8 53/hcWvxHVs= Organization: IBM Linux Technology Center In-Reply-To: <5763b190-6b8a-eccb-663a-7d35363c81c8@linux.vnet.ibm.com> Date: Wed, 9 May 2018 11:13:19 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 Content-Language: en-US X-TM-AS-GCONF: 00 x-cbid: 18050916-0052-0000-0000-000002EB46C8 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008997; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000259; SDB=6.01029837; UDB=6.00526263; IPR=6.00808971; MB=3.00021013; MTD=3.00000008; XFM=3.00000015; UTC=2018-05-09 16:13:22 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18050916-0053-0000-0000-00005C9F1412 Message-Id: <5e82fd4a-1e42-ac20-c4e9-56aa012356e9@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-05-09_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 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-1805090150 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 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 , Thomas Falcon , Tyrel Datwyler , John Allen Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" powerpc migration/cpu: Now apply changes to the associativity of cpus for the topology of LPARS in Post Migration events. Recognize more changes to the associativity of memory blocks described by the '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: * Provide hotplug CPU 'readd by index' operation * Checking for changes in cpu associativity and making 'readd' calls when differences are observed. * Queue up changes to CPU properties so that they may take place after all PowerPC device-tree changes have been applied i.e. after the device hotplug is released in the mobility code. Signed-off-by: Michael Bringmann --- Changes include: -- Rearrange patches to co-locate CPU property-related changes. -- Modify dlpar_cpu_add & dlpar_cpu_remove to skip DRC index acquire or release operations during the CPU readd process. -- Correct a bug in DRC index selection for queued operation. --- arch/powerpc/platforms/pseries/hotplug-cpu.c | 123 +++++++++++++++++++------- arch/powerpc/platforms/pseries/mobility.c | 3 + 2 files changed, 95 insertions(+), 31 deletions(-) diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c b/arch/powerpc/platforms/pseries/hotplug-cpu.c index a408217..23d4cb8 100644 --- a/arch/powerpc/platforms/pseries/hotplug-cpu.c +++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c @@ -474,7 +474,7 @@ static bool valid_cpu_drc_index(struct device_node *parent, u32 drc_index) &cdata); } -static ssize_t dlpar_cpu_add(u32 drc_index) +static ssize_t dlpar_cpu_add(u32 drc_index, bool acquire_drc) { struct device_node *dn, *parent; int rc, saved_rc; @@ -499,19 +499,22 @@ static ssize_t dlpar_cpu_add(u32 drc_index) return -EINVAL; } - rc = dlpar_acquire_drc(drc_index); - if (rc) { - pr_warn("Failed to acquire DRC, rc: %d, drc index: %x\n", - rc, drc_index); - of_node_put(parent); - return -EINVAL; + if (acquire_drc) { + rc = dlpar_acquire_drc(drc_index); + if (rc) { + pr_warn("Failed to acquire DRC, rc: %d, drc index: %x\n", + rc, drc_index); + of_node_put(parent); + return -EINVAL; + } } dn = dlpar_configure_connector(cpu_to_be32(drc_index), parent); if (!dn) { pr_warn("Failed call to configure-connector, drc index: %x\n", drc_index); - dlpar_release_drc(drc_index); + if (acquire_drc) + dlpar_release_drc(drc_index); of_node_put(parent); return -EINVAL; } @@ -526,8 +529,9 @@ static ssize_t dlpar_cpu_add(u32 drc_index) pr_warn("Failed to attach node %s, rc: %d, drc index: %x\n", dn->name, rc, drc_index); - rc = dlpar_release_drc(drc_index); - if (!rc) + if (acquire_drc) + rc = dlpar_release_drc(drc_index); + if (!rc || acquire_drc) dlpar_free_cc_nodes(dn); return saved_rc; @@ -540,7 +544,7 @@ static ssize_t dlpar_cpu_add(u32 drc_index) dn->name, rc, drc_index); rc = dlpar_detach_node(dn); - if (!rc) + if (!rc && acquire_drc) dlpar_release_drc(drc_index); return saved_rc; @@ -608,12 +612,13 @@ static int dlpar_offline_cpu(struct device_node *dn) } -static ssize_t dlpar_cpu_remove(struct device_node *dn, u32 drc_index) +static ssize_t dlpar_cpu_remove(struct device_node *dn, u32 drc_index, + bool release_drc) { int rc; - pr_debug("Attempting to remove CPU %s, drc index: %x\n", - dn->name, drc_index); + pr_debug("Attempting to remove CPU %s, drc index: %x (%d)\n", + dn->name, drc_index, release_drc); rc = dlpar_offline_cpu(dn); if (rc) { @@ -621,12 +626,14 @@ static ssize_t dlpar_cpu_remove(struct device_node *dn, u32 drc_index) return -EINVAL; } - rc = dlpar_release_drc(drc_index); - if (rc) { - pr_warn("Failed to release drc (%x) for CPU %s, rc: %d\n", - drc_index, dn->name, rc); - dlpar_online_cpu(dn); - return rc; + if (release_drc) { + rc = dlpar_release_drc(drc_index); + if (rc) { + pr_warn("Failed to release drc (%x) for CPU %s, rc: %d\n", + drc_index, dn->name, rc); + dlpar_online_cpu(dn); + return rc; + } } rc = dlpar_detach_node(dn); @@ -635,7 +642,8 @@ static ssize_t dlpar_cpu_remove(struct device_node *dn, u32 drc_index) pr_warn("Failed to detach CPU %s, rc: %d", dn->name, rc); - rc = dlpar_acquire_drc(drc_index); + if (release_drc) + rc = dlpar_acquire_drc(drc_index); if (!rc) dlpar_online_cpu(dn); @@ -664,7 +672,7 @@ static struct device_node *cpu_drc_index_to_dn(u32 drc_index) return dn; } -static int dlpar_cpu_remove_by_index(u32 drc_index) +static int dlpar_cpu_remove_by_index(u32 drc_index, bool release_drc) { struct device_node *dn; int rc; @@ -676,10 +684,30 @@ static int dlpar_cpu_remove_by_index(u32 drc_index) return -ENODEV; } - rc = dlpar_cpu_remove(dn, drc_index); + rc = dlpar_cpu_remove(dn, drc_index, release_drc); of_node_put(dn); return rc; } + +static int dlpar_cpu_readd_by_index(u32 drc_index) +{ + int rc = 0; + + pr_info("Attempting to re-add CPU, drc index %x\n", drc_index); + + rc = dlpar_cpu_remove_by_index(drc_index, false); + if (!rc) + rc = dlpar_cpu_add(drc_index, false); + + 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) { @@ -741,7 +769,7 @@ static int dlpar_cpu_remove_by_count(u32 cpus_to_remove) } for (i = 0; i < cpus_to_remove; i++) { - rc = dlpar_cpu_remove_by_index(cpu_drcs[i]); + rc = dlpar_cpu_remove_by_index(cpu_drcs[i], true); if (rc) break; @@ -752,7 +780,7 @@ static int dlpar_cpu_remove_by_count(u32 cpus_to_remove) pr_warn("CPU hot-remove failed, adding back removed CPUs\n"); for (i = 0; i < cpus_removed; i++) - dlpar_cpu_add(cpu_drcs[i]); + dlpar_cpu_add(cpu_drcs[i], true); rc = -EINVAL; } else { @@ -843,7 +871,7 @@ static int dlpar_cpu_add_by_count(u32 cpus_to_add) } for (i = 0; i < cpus_to_add; i++) { - rc = dlpar_cpu_add(cpu_drcs[i]); + rc = dlpar_cpu_add(cpu_drcs[i], true); if (rc) break; @@ -854,7 +882,7 @@ static int dlpar_cpu_add_by_count(u32 cpus_to_add) pr_warn("CPU hot-add failed, removing any added CPUs\n"); for (i = 0; i < cpus_added; i++) - dlpar_cpu_remove_by_index(cpu_drcs[i]); + dlpar_cpu_remove_by_index(cpu_drcs[i], true); rc = -EINVAL; } else { @@ -880,7 +908,7 @@ int dlpar_cpu(struct pseries_hp_errorlog *hp_elog) if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_COUNT) rc = dlpar_cpu_remove_by_count(count); else if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_INDEX) - rc = dlpar_cpu_remove_by_index(drc_index); + rc = dlpar_cpu_remove_by_index(drc_index, true); else rc = -EINVAL; break; @@ -888,10 +916,13 @@ int dlpar_cpu(struct pseries_hp_errorlog *hp_elog) if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_COUNT) rc = dlpar_cpu_add_by_count(count); else if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_INDEX) - rc = dlpar_cpu_add(drc_index); + rc = dlpar_cpu_add(drc_index, true); 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; @@ -913,7 +944,7 @@ static ssize_t dlpar_cpu_probe(const char *buf, size_t count) if (rc) return -EINVAL; - rc = dlpar_cpu_add(drc_index); + rc = dlpar_cpu_add(drc_index, true); return rc ? rc : count; } @@ -934,7 +965,7 @@ static ssize_t dlpar_cpu_release(const char *buf, size_t count) return -EINVAL; } - rc = dlpar_cpu_remove(dn, drc_index); + rc = dlpar_cpu_remove(dn, drc_index, true); of_node_put(dn); return rc ? rc : count; @@ -942,12 +973,38 @@ 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) +{ + /* So far, we only handle the 'ibm,associativity' property, + * here. + */ + struct pseries_hp_errorlog *hp_elog; + + hp_elog = kzalloc(sizeof(*hp_elog), GFP_KERNEL); + if(!hp_elog) + return -ENOMEM; + + hp_elog->resource = PSERIES_HP_ELOG_RESOURCE_CPU; + hp_elog->action = PSERIES_HP_ELOG_ACTION_READD; + hp_elog->id_type = PSERIES_HP_ELOG_ID_DRC_INDEX; + hp_elog->_drc_u.drc_index = be32_to_cpu(pr->dn->phandle); + + queue_hotplug_event(hp_elog, NULL, NULL); + + kfree(hp_elog); + + return 0; +} + 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(rd->dn->type, "cpu")) + return notifier_from_errno(err); + switch (action) { case OF_RECONFIG_ATTACH_NODE: err = pseries_add_processor(rd->dn); @@ -955,6 +1012,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/mobility.c b/arch/powerpc/platforms/pseries/mobility.c index 8a8033a..6d98f84 100644 --- a/arch/powerpc/platforms/pseries/mobility.c +++ b/arch/powerpc/platforms/pseries/mobility.c @@ -283,6 +283,8 @@ int pseries_devicetree_update(s32 scope) if (!rtas_buf) return -ENOMEM; + lock_device_hotplug(); + do { rc = mobility_rtas_call(update_nodes_token, rtas_buf, scope); if (rc && rc != 1) @@ -321,6 +323,7 @@ int pseries_devicetree_update(s32 scope) } while (rc == 1); kfree(rtas_buf); + unlock_device_hotplug(); return rc; } From patchwork Wed May 9 16:13:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Bringmann X-Patchwork-Id: 910976 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40h1mN1XJkz9s3D for ; Thu, 10 May 2018 02:20:20 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40h1mM7462zF2RZ for ; Thu, 10 May 2018 02:20:19 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.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=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com 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 40h1cV2J7fzF2RW for ; Thu, 10 May 2018 02:13:30 +1000 (AEST) 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 w49G8r4R027569 for ; Wed, 9 May 2018 12:13:28 -0400 Received: from e16.ny.us.ibm.com (e16.ny.us.ibm.com [129.33.205.206]) by mx0a-001b2d01.pphosted.com with ESMTP id 2hv38uv6ru-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 09 May 2018 12:13:27 -0400 Received: from localhost by e16.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 9 May 2018 12:13:26 -0400 Received: from b01cxnp23032.gho.pok.ibm.com (9.57.198.27) by e16.ny.us.ibm.com (146.89.104.203) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 9 May 2018 12:13:25 -0400 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w49GDOlh47382532; Wed, 9 May 2018 16:13:24 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 17D9EAC03F; Wed, 9 May 2018 12:14:56 -0400 (EDT) Received: from oc5000245537.ibm.com (unknown [9.80.200.26]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP id 710A1AC03A; Wed, 9 May 2018 12:14:55 -0400 (EDT) To: linuxppc-dev@lists.ozlabs.org From: Michael Bringmann Subject: [RFC v3 3/3] powerpc migration/memory: Associativity & memory updates Openpgp: preference=signencrypt Autocrypt: addr=mwb@linux.vnet.ibm.com; prefer-encrypt=mutual; keydata= xsBNBFcY7GcBCADzw3en+yzo9ASFGCfldVkIg95SAMPK0myXp2XJYET3zT45uBsX/uj9/2nA lBmXXeOSXnPfJ9V3vtiwcfATnWIsVt3tL6n1kqikzH9nXNxZT7MU/7gqzWZngMAWh/GJ9qyg DTOZdjsvdUNUWxtiLvBo7y+reA4HjlQhwhYxxvCpXBeRoF0qDWfQ8DkneemqINzDZPwSQ7zY t4F5iyN1I9G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4MsG6c+X2NYLbD3cryiXxVx/7kSAJEFQJfA5P06g8NLR25Qpq9BLsN7 ++dxQ+CLKzSEb1X24hYAJZpOhS8ev3ii+M/XIo+olDBKuTaTgB6elrg3CaxUsVgLBJ+jbRkW yQe2S5f/Ja1ThDpSSLLWLiLK/z7+gaqwhnwjQ8Z8Y9D2itJQcj4itHilwImsqwLG7SxzC0NX IQ5KaAFYdRcOgwR8VhhkOIVd70ObSZU+E4pTET1WDz4o65xZ89yfose1No0+r5ht/xWOOrh8 53/hcWvxHVs= Organization: IBM Linux Technology Center In-Reply-To: <5763b190-6b8a-eccb-663a-7d35363c81c8@linux.vnet.ibm.com> Date: Wed, 9 May 2018 11:13:23 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 Content-Language: en-US X-TM-AS-GCONF: 00 x-cbid: 18050916-0024-0000-0000-00000356687D X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008997; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000259; SDB=6.01029837; UDB=6.00526263; IPR=6.00808971; MB=3.00021013; MTD=3.00000008; XFM=3.00000015; UTC=2018-05-09 16:13:25 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18050916-0025-0000-0000-000047F3D6ED Message-Id: <99a90496-ab8a-31da-fe2f-f1c2f20acf05@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-05-09_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 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-1805090150 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 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 , Thomas Falcon , Tyrel Datwyler , John Allen Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" powerpc migration/memory: This patch adds more recognition for changes to the associativity of memory blocks described by the device-tree properties and updates local and general kernel data structures to reflect those changes. These differences may include: * Evaluating 'ibm,dynamic-memory' 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 for each drc_index of the old/new LMBs and to 'readd' any block for which the setting has changed. * In an LPAR migration scenario, the "ibm,associativity-lookup-arrays" property 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 system routines will update the corresponding entry for the memory in the LMB structures and any other relevant kernel data structures. * Extend the previous work for the 'ibm,associativity-lookup-array' and 'ibm,dynamic-memory' properties to support the property 'ibm,dynamic-memory-v2' by means of the DRMEM LMB interpretation code. Signed-off-by: Michael Bringmann --- Changes in RFC: -- Simplify code to update memory nodes during mobility checks. -- Reuse code from DRMEM changes to scan for LMBs when updating aa_index -- Combine common code for properties 'ibm,dynamic-memory' and 'ibm,dynamic-memory-v2' after integrating DRMEM features. -- Rearrange patches to co-locate memory property-related changes. -- Use new paired list iterator for the drmem info arrays. -- Use direct calls to add/remove memory from the update drconf function as those operations are only intended for user DLPAR ops, and should not occur during Migration reconfig notifier changes. -- Correct processing bug in processing of ibm,associativity-lookup-arrays --- arch/powerpc/platforms/pseries/hotplug-memory.c | 172 +++++++++++++++++++---- 1 file changed, 139 insertions(+), 33 deletions(-) diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c index c1578f5..15c6f74 100644 --- a/arch/powerpc/platforms/pseries/hotplug-memory.c +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c @@ -994,13 +994,29 @@ static int pseries_add_mem_node(struct device_node *np) return (ret < 0) ? -EINVAL : 0; } -static int pseries_update_drconf_memory(struct of_reconfig_data *pr) +static void pseries_queue_memory_event(u32 drc_index, int action) { - struct of_drconf_cell_v1 *new_drmem, *old_drmem; - unsigned long memblock_size; - u32 entries; - __be32 *p; - int i, rc = -EINVAL; + struct pseries_hp_errorlog *hp_elog; + + hp_elog = kzalloc(sizeof(*hp_elog), GFP_KERNEL); + if(!hp_elog) + return; + + hp_elog->resource = PSERIES_HP_ELOG_RESOURCE_MEM; + hp_elog->action = action; + hp_elog->id_type = PSERIES_HP_ELOG_ID_DRC_INDEX; + hp_elog->_drc_u.drc_index = drc_index; + + queue_hotplug_event(hp_elog, NULL, NULL); + + kfree(hp_elog); +} + +static int pseries_update_drconf_memory(struct drmem_lmb_info *new_dinfo) +{ + struct drmem_lmb *old_lmb, *new_lmb; + unsigned long memblock_size; + int rc = 0; if (rtas_hp_event) return 0; @@ -1009,42 +1025,123 @@ static int pseries_update_drconf_memory(struct of_reconfig_data *pr) if (!memblock_size) return -EINVAL; - p = (__be32 *) pr->old_prop->value; - if (!p) - return -EINVAL; + /* Arrays should have the same size and DRC indexes */ + for_each_pair_drmem_lmb(drmem_info, old_lmb, new_dinfo, new_lmb) { - /* 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++); - old_drmem = (struct of_drconf_cell_v1 *)p; - - p = (__be32 *)pr->prop->value; - p++; - new_drmem = (struct of_drconf_cell_v1 *)p; + if (new_lmb->drc_index != old_lmb->drc_index) + continue; - for (i = 0; i < entries; i++) { - if ((be32_to_cpu(old_drmem[i].flags) & DRCONF_MEM_ASSIGNED) && - (!(be32_to_cpu(new_drmem[i].flags) & DRCONF_MEM_ASSIGNED))) { + if ((old_lmb->flags & DRCONF_MEM_ASSIGNED) && + (!(new_lmb->flags & DRCONF_MEM_ASSIGNED))) { rc = pseries_remove_memblock( - be64_to_cpu(old_drmem[i].base_addr), - memblock_size); + old_lmb->base_addr, 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)) { - rc = memblock_add(be64_to_cpu(old_drmem[i].base_addr), - memblock_size); + } else if ((!(old_lmb->flags & DRCONF_MEM_ASSIGNED)) && + (new_lmb->flags & DRCONF_MEM_ASSIGNED)) { + rc = memblock_add(old_lmb->base_addr, + memblock_size); rc = (rc < 0) ? -EINVAL : 0; break; + } else if ((old_lmb->aa_index != new_lmb->aa_index) && + (new_lmb->flags & DRCONF_MEM_ASSIGNED)) { + pseries_queue_memory_event( + new_lmb->drc_index, + PSERIES_HP_ELOG_ACTION_READD); } } return rc; } +static void pseries_update_ala_memory_aai(int aa_index) +{ + struct drmem_lmb *lmb; + + /* Readd all LMBs which were previously using the + * specified aa_index value. + */ + for_each_drmem_lmb(lmb) { + if ((lmb->aa_index == aa_index) && + (lmb->flags & DRCONF_MEM_ASSIGNED)) { + pseries_queue_memory_event(lmb->drc_index, + PSERIES_HP_ELOG_ACTION_READD); + } + } +} + +struct assoc_arrays { + u32 n_arrays; + u32 array_sz; + const __be32 *arrays; +}; + +static int pseries_update_ala_memory(struct of_reconfig_data *pr) +{ + struct assoc_arrays new_ala, old_ala; + __be32 *p; + int i, lim; + + if (rtas_hp_event) + return 0; + + /* + * 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) + 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) + 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) { + + /* Reset any entries where the old and new rows + * the array have changed. + */ + 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); + } + + /* Reset any entries representing the extra rows. + * There shouldn't be any, but just in case ... + */ + for (i = lim; i < new_ala.n_arrays; i++) + pseries_update_ala_memory_aai(i); + + } 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); + } + + return 0; +} + static int pseries_memory_notifier(struct notifier_block *nb, unsigned long action, void *data) { @@ -1059,8 +1156,17 @@ static int pseries_memory_notifier(struct notifier_block *nb, err = pseries_remove_mem_node(rd->dn); break; 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") || + !strcmp(rd->prop->name, "ibm,dynamic-memory-v2")) { + struct drmem_lmb_info *dinfo = + drmem_init_lmbs(rd->prop); + if (!dinfo) + return -EINVAL; + err = pseries_update_drconf_memory(dinfo); + drmem_lmbs_free(dinfo); + } else if (!strcmp(rd->prop->name, + "ibm,associativity-lookup-arrays")) + err = pseries_update_ala_memory(rd); break; } return notifier_from_errno(err);