From patchwork Wed Feb 21 10:36:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bharata B Rao X-Patchwork-Id: 876021 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 3zmYqN3zCcz9ry4 for ; Wed, 21 Feb 2018 21:38:24 +1100 (AEDT) Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3zmYqN2NWXzF0WJ for ; Wed, 21 Feb 2018 21:38: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=bharata@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 3zmYnW6vWnzDrLQ for ; Wed, 21 Feb 2018 21:36:44 +1100 (AEDT) Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w1LAZ4BK121848 for ; Wed, 21 Feb 2018 05:36:42 -0500 Received: from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110]) by mx0a-001b2d01.pphosted.com with ESMTP id 2g964mapau-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 21 Feb 2018 05:36:42 -0500 Received: from localhost by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 21 Feb 2018 10:36:40 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 21 Feb 2018 10:36:38 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w1LAabsH52101334; Wed, 21 Feb 2018 10:36:37 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E6A3DAE051; Wed, 21 Feb 2018 10:27:31 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CA5E0AE055; Wed, 21 Feb 2018 10:27:30 +0000 (GMT) Received: from bharata.in.ibm.com (unknown [9.79.237.169]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 21 Feb 2018 10:27:30 +0000 (GMT) From: Bharata B Rao To: linuxppc-dev@lists.ozlabs.org Subject: [RFC PATCH v0 1/2] powerpc, drmem: Fix unexpected flag value in ibm, dynamic-memory-v2 Date: Wed, 21 Feb 2018 16:06:26 +0530 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519209387-29767-1-git-send-email-bharata@linux.vnet.ibm.com> References: <1519209387-29767-1-git-send-email-bharata@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18022110-0016-0000-0000-00000527FD0C X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18022110-0017-0000-0000-000028641097 Message-Id: <1519209387-29767-2-git-send-email-bharata@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-02-21_03:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 lowpriorityscore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1802210131 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: nfont@linux.vnet.ibm.com, mwb@linux.vnet.ibm.com, Bharata B Rao Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Memory addtion and removal by count and indexed-count methods temporarily mark the LMBs that are being added/removed by a special flag value DRMEM_LMB_RESERVED. Accessing flags value directly at a few places without proper accessor method is causing two unexpected side-effects: - DRMEM_LMB_RESERVED bit is becoming part of the flags word of drconf_cell_v2 entries in ibm,dynamic-memory-v2 DT property. - This results in extra drconf_cell entries in ibm,dynamic-memory-v2. For example if 1G memory is added, it leads to one entry for 3 LMBs and 1 separate entry for the last LMB. All the 4 LMBs should be defined by one entry here. Fix this by always accessing the flags by its accessor method drmem_lmb_flags(). Signed-off-by: Bharata B Rao Reviewed-by: Nathan Fontenot --- arch/powerpc/mm/drmem.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/mm/drmem.c b/arch/powerpc/mm/drmem.c index 916844f..3f18036 100644 --- a/arch/powerpc/mm/drmem.c +++ b/arch/powerpc/mm/drmem.c @@ -98,7 +98,7 @@ static void init_drconf_v2_cell(struct of_drconf_cell_v2 *dr_cell, dr_cell->base_addr = cpu_to_be64(lmb->base_addr); dr_cell->drc_index = cpu_to_be32(lmb->drc_index); dr_cell->aa_index = cpu_to_be32(lmb->aa_index); - dr_cell->flags = cpu_to_be32(lmb->flags); + dr_cell->flags = cpu_to_be32(drmem_lmb_flags(lmb)); } static int drmem_update_dt_v2(struct device_node *memory, @@ -121,7 +121,7 @@ static int drmem_update_dt_v2(struct device_node *memory, } if (prev_lmb->aa_index != lmb->aa_index || - prev_lmb->flags != lmb->flags) + drmem_lmb_flags(prev_lmb) != drmem_lmb_flags(lmb)) lmb_sets++; prev_lmb = lmb; @@ -150,7 +150,7 @@ static int drmem_update_dt_v2(struct device_node *memory, } if (prev_lmb->aa_index != lmb->aa_index || - prev_lmb->flags != lmb->flags) { + drmem_lmb_flags(prev_lmb) != drmem_lmb_flags(lmb)) { /* end of one set, start of another */ dr_cell->seq_lmbs = cpu_to_be32(seq_lmbs); dr_cell++; From patchwork Wed Feb 21 10:36:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bharata B Rao X-Patchwork-Id: 876022 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 3zmYtj2qrcz9ry4 for ; Wed, 21 Feb 2018 21:41:17 +1100 (AEDT) Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3zmYtj0lGFzF0f4 for ; Wed, 21 Feb 2018 21:41:17 +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=bharata@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 3zmYnY0sWXzDrM8 for ; Wed, 21 Feb 2018 21:36:48 +1100 (AEDT) Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w1LAYaIF131127 for ; Wed, 21 Feb 2018 05:36:47 -0500 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0a-001b2d01.pphosted.com with ESMTP id 2g96mt19v7-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 21 Feb 2018 05:36:44 -0500 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 21 Feb 2018 10:36:41 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 21 Feb 2018 10:36:40 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w1LAaeAx43450620; Wed, 21 Feb 2018 10:36:40 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 630B6AE051; Wed, 21 Feb 2018 10:27:34 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4852AAE045; Wed, 21 Feb 2018 10:27:33 +0000 (GMT) Received: from bharata.in.ibm.com (unknown [9.79.237.169]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 21 Feb 2018 10:27:33 +0000 (GMT) From: Bharata B Rao To: linuxppc-dev@lists.ozlabs.org Subject: [RFC PATCH v0 2/2] powerpc, drmem: Rename DRMEM_LMB_RESERVED to DRMEM_LMB_ISOLATED Date: Wed, 21 Feb 2018 16:06:27 +0530 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519209387-29767-1-git-send-email-bharata@linux.vnet.ibm.com> References: <1519209387-29767-1-git-send-email-bharata@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18022110-0012-0000-0000-000005B2FDD4 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18022110-0013-0000-0000-0000192F117A Message-Id: <1519209387-29767-3-git-send-email-bharata@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-02-21_03:, , 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-1802210131 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: nfont@linux.vnet.ibm.com, mwb@linux.vnet.ibm.com, Bharata B Rao Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Memory hotplug code uses a temporary LMB flags bit DRMEM_LMB_RESERVED to mark the LMB which is currently undergoing hotplug or unplug. It is easy to confuse DRMEM_LMB_RESERVED to mean the LMB is reserved for which a separate flag bit already exists DRCONF_MEM_RESERVED. Since both DRMEM_LMB_RESERVED and DRCONF_MEM_RESERVED operate on the same LMB flags word, rename the former to DRMEM_LMB_ISOLATED. Signed-off-by: Bharata B Rao Reviewed-by: Nathan Fontenot --- arch/powerpc/include/asm/drmem.h | 14 ++++----- arch/powerpc/mm/drmem.c | 2 +- arch/powerpc/platforms/pseries/hotplug-memory.c | 40 ++++++++++++------------- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/arch/powerpc/include/asm/drmem.h b/arch/powerpc/include/asm/drmem.h index ce242b9..b3fa3f7 100644 --- a/arch/powerpc/include/asm/drmem.h +++ b/arch/powerpc/include/asm/drmem.h @@ -72,21 +72,21 @@ static inline u32 drmem_lmb_size(void) return drmem_info->lmb_size; } -#define DRMEM_LMB_RESERVED 0x80000000 +#define DRMEM_LMB_ISOLATED 0x80000000 -static inline void drmem_mark_lmb_reserved(struct drmem_lmb *lmb) +static inline void drmem_mark_lmb_isolated(struct drmem_lmb *lmb) { - lmb->flags |= DRMEM_LMB_RESERVED; + lmb->flags |= DRMEM_LMB_ISOLATED; } -static inline void drmem_remove_lmb_reservation(struct drmem_lmb *lmb) +static inline void drmem_remove_lmb_isolation(struct drmem_lmb *lmb) { - lmb->flags &= ~DRMEM_LMB_RESERVED; + lmb->flags &= ~DRMEM_LMB_ISOLATED; } -static inline bool drmem_lmb_reserved(struct drmem_lmb *lmb) +static inline bool drmem_lmb_isolated(struct drmem_lmb *lmb) { - return lmb->flags & DRMEM_LMB_RESERVED; + return lmb->flags & DRMEM_LMB_ISOLATED; } u64 drmem_lmb_memory_max(void); diff --git a/arch/powerpc/mm/drmem.c b/arch/powerpc/mm/drmem.c index 3f18036..652bf3a 100644 --- a/arch/powerpc/mm/drmem.c +++ b/arch/powerpc/mm/drmem.c @@ -35,7 +35,7 @@ static u32 drmem_lmb_flags(struct drmem_lmb *lmb) * Return the value of the lmb flags field minus the reserved * bit used internally for hotplug processing. */ - return lmb->flags & ~DRMEM_LMB_RESERVED; + return lmb->flags & ~DRMEM_LMB_ISOLATED; } static struct property *clone_property(struct property *prop, u32 prop_sz) diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c index c1578f5..2f5ca29 100644 --- a/arch/powerpc/platforms/pseries/hotplug-memory.c +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c @@ -467,7 +467,7 @@ static int dlpar_memory_remove_by_count(u32 lmbs_to_remove) /* Mark this lmb so we can add it later if all of the * requested LMBs cannot be removed. */ - drmem_mark_lmb_reserved(lmb); + drmem_mark_lmb_isolated(lmb); lmbs_removed++; if (lmbs_removed == lmbs_to_remove) @@ -478,7 +478,7 @@ static int dlpar_memory_remove_by_count(u32 lmbs_to_remove) pr_err("Memory hot-remove failed, adding LMB's back\n"); for_each_drmem_lmb(lmb) { - if (!drmem_lmb_reserved(lmb)) + if (!drmem_lmb_isolated(lmb)) continue; rc = dlpar_add_lmb(lmb); @@ -486,20 +486,20 @@ static int dlpar_memory_remove_by_count(u32 lmbs_to_remove) pr_err("Failed to add LMB back, drc index %x\n", lmb->drc_index); - drmem_remove_lmb_reservation(lmb); + drmem_remove_lmb_isolation(lmb); } rc = -EINVAL; } else { for_each_drmem_lmb(lmb) { - if (!drmem_lmb_reserved(lmb)) + if (!drmem_lmb_isolated(lmb)) continue; dlpar_release_drc(lmb->drc_index); pr_info("Memory at %llx was hot-removed\n", lmb->base_addr); - drmem_remove_lmb_reservation(lmb); + drmem_remove_lmb_isolation(lmb); } rc = 0; } @@ -608,7 +608,7 @@ static int dlpar_memory_remove_by_ic(u32 lmbs_to_remove, u32 drc_index) if (rc) break; - drmem_mark_lmb_reserved(lmb); + drmem_mark_lmb_isolated(lmb); } if (rc) { @@ -616,7 +616,7 @@ static int dlpar_memory_remove_by_ic(u32 lmbs_to_remove, u32 drc_index) for_each_drmem_lmb_in_range(lmb, start_lmb, end_lmb) { - if (!drmem_lmb_reserved(lmb)) + if (!drmem_lmb_isolated(lmb)) continue; rc = dlpar_add_lmb(lmb); @@ -624,19 +624,19 @@ static int dlpar_memory_remove_by_ic(u32 lmbs_to_remove, u32 drc_index) pr_err("Failed to add LMB, drc index %x\n", lmb->drc_index); - drmem_remove_lmb_reservation(lmb); + drmem_remove_lmb_isolation(lmb); } rc = -EINVAL; } else { for_each_drmem_lmb_in_range(lmb, start_lmb, end_lmb) { - if (!drmem_lmb_reserved(lmb)) + if (!drmem_lmb_isolated(lmb)) continue; dlpar_release_drc(lmb->drc_index); pr_info("Memory at %llx (drc index %x) was hot-removed\n", lmb->base_addr, lmb->drc_index); - drmem_remove_lmb_reservation(lmb); + drmem_remove_lmb_isolation(lmb); } } @@ -760,7 +760,7 @@ static int dlpar_memory_add_by_count(u32 lmbs_to_add) /* Mark this lmb so we can remove it later if all of the * requested LMBs cannot be added. */ - drmem_mark_lmb_reserved(lmb); + drmem_mark_lmb_isolated(lmb); lmbs_added++; if (lmbs_added == lmbs_to_add) @@ -771,7 +771,7 @@ static int dlpar_memory_add_by_count(u32 lmbs_to_add) pr_err("Memory hot-add failed, removing any added LMBs\n"); for_each_drmem_lmb(lmb) { - if (!drmem_lmb_reserved(lmb)) + if (!drmem_lmb_isolated(lmb)) continue; rc = dlpar_remove_lmb(lmb); @@ -781,17 +781,17 @@ static int dlpar_memory_add_by_count(u32 lmbs_to_add) else dlpar_release_drc(lmb->drc_index); - drmem_remove_lmb_reservation(lmb); + drmem_remove_lmb_isolation(lmb); } rc = -EINVAL; } else { for_each_drmem_lmb(lmb) { - if (!drmem_lmb_reserved(lmb)) + if (!drmem_lmb_isolated(lmb)) continue; pr_info("Memory at %llx (drc index %x) was hot-added\n", lmb->base_addr, lmb->drc_index); - drmem_remove_lmb_reservation(lmb); + drmem_remove_lmb_isolation(lmb); } rc = 0; } @@ -874,14 +874,14 @@ static int dlpar_memory_add_by_ic(u32 lmbs_to_add, u32 drc_index) break; } - drmem_mark_lmb_reserved(lmb); + drmem_mark_lmb_isolated(lmb); } if (rc) { pr_err("Memory indexed-count-add failed, removing any added LMBs\n"); for_each_drmem_lmb_in_range(lmb, start_lmb, end_lmb) { - if (!drmem_lmb_reserved(lmb)) + if (!drmem_lmb_isolated(lmb)) continue; rc = dlpar_remove_lmb(lmb); @@ -891,17 +891,17 @@ static int dlpar_memory_add_by_ic(u32 lmbs_to_add, u32 drc_index) else dlpar_release_drc(lmb->drc_index); - drmem_remove_lmb_reservation(lmb); + drmem_remove_lmb_isolation(lmb); } rc = -EINVAL; } else { for_each_drmem_lmb_in_range(lmb, start_lmb, end_lmb) { - if (!drmem_lmb_reserved(lmb)) + if (!drmem_lmb_isolated(lmb)) continue; pr_info("Memory at %llx (drc index %x) was hot-added\n", lmb->base_addr, lmb->drc_index); - drmem_remove_lmb_reservation(lmb); + drmem_remove_lmb_isolation(lmb); } }