From patchwork Tue May 19 10:44:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 11557413 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 13239912 for ; Tue, 19 May 2020 10:45:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EA0E0207D8 for ; Tue, 19 May 2020 10:45:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=marvell.com header.i=@marvell.com header.b="LDygkSvn"; dkim=pass (1024-bit key) header.d=marvell.onmicrosoft.com header.i=@marvell.onmicrosoft.com header.b="uX1uM6go" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726949AbgESKpf (ORCPT ); Tue, 19 May 2020 06:45:35 -0400 Received: from mx0a-0016f401.pphosted.com ([67.231.148.174]:58320 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726494AbgESKpf (ORCPT ); Tue, 19 May 2020 06:45:35 -0400 Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 04JAedaq031351; Tue, 19 May 2020 03:45:22 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=pfpt0818; bh=lLCAHuSobwIEK/Wiic+M3Y+HJjZXSuwrKpFZxVRimaE=; b=LDygkSvnzxnbL3fR6KkYsQPEWye/3U8ebeXWRiCcwrMHgkCDyx3UFnrqUOePr91Zgk9l z8QytF+XoQmEgEwZTDrl3EM/nWT25RvTWiYGXQYW6zFLq7XtXW3oqwfwOVh1/qQdvxe+ jdmZ3wkaAuZiGnGWSErNWWUNLsLBvydezBMGCZvjPfzlG7aPhaETPDh24IDw5Lrn1SZq 5TUYqsg0sLLlufKXh6I8ysoBf7aKjXF2NaU1nbF9q+rgKH3NsUSxTyanycl58ofycILx KvZzumcr3qdNl+Yjqn81Xvc4i2fEM+3lptz/J9a6lu6cSPOrGOHTVwHL6K8BD0XD5ib7 qQ== Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0a-0016f401.pphosted.com with ESMTP id 312dhqkgnb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 19 May 2020 03:45:21 -0700 Received: from SC-EXCH04.marvell.com (10.93.176.84) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 19 May 2020 03:45:20 -0700 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.177) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Tue, 19 May 2020 03:45:20 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gFryiegkaEq3t2S0bQGheKmwMqFJDnIv1QKbF5/jZcMokt9eHqFYkGOGz3mgNW5jwtXUwmoc7mgMrJyG9Lp0a4k052uXAvlmaRPQd5vI1ECKIabRF9DDBUiAqgQ2Y5grDkNdrROIWhrT+JMt9IlN671a2WMMuRJsi2gUosBrlIR7A0lQR2flD8pVy62Uv5sSeDiuG2d4yVnn02gQe82XrHdpnG4WZn5kTvIle5CGc9bQNRQtnOPqP/RF1meGW5gEjdiCDzHqKY33Hbf8LqltHX1tzgrhnd5IaW4CVIAR1jPTHC4t5oMIjkX3SOULV/OmHdaACjhnUW7qFv4zkC/EvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lLCAHuSobwIEK/Wiic+M3Y+HJjZXSuwrKpFZxVRimaE=; b=hnMP/ErzaXQY6AzqUXooEZShdWA+N92W4hdSsCL0Y5NPzPWlOcl7kmyI+l96qZrfhwbbnyDEzan2V1p7xIbIy4033lNafLDpVubE5/aW/ADW1mo69zGMqNpln1poerNPuCdIO+1USIlAlbDHrs2qA0ELK9ULzCH5J/TUsn16z3hc0hFZF19e2lAw6gJrOkKufbiEo53g5BfmldgwjbxhEJcfmPoU9SHfkocymltZcaDgjn84D8eMmTCq/6SAbAM4ivQA6k1gmbq4Al9uP4NOgOn1T8ek0yDBil5af1d1RjtVrQHHTNgPf6No11CE7adNkmE1uzjTdG4VYVXgKEuUXQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector1-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lLCAHuSobwIEK/Wiic+M3Y+HJjZXSuwrKpFZxVRimaE=; b=uX1uM6goISqhS+B7JzAmXuHVtOXJ0np/jHkb8tyLmJw7GJaJytAyOoD55ix3NphodRBdix/1vA7Fysy8iq1xrWCnAJz4VbgLiiL3OXrbZHE3y9ifSv6wnuF4UFtelgvxWlbZU673lseCvuR4l5kv3FucuzRT0nlg+UK+cqyFYds= Authentication-Results: alien8.de; dkim=none (message not signed) header.d=none;alien8.de; dmarc=none action=none header.from=marvell.com; Received: from BYAPR18MB2661.namprd18.prod.outlook.com (2603:10b6:a03:136::26) by BYAPR18MB2455.namprd18.prod.outlook.com (2603:10b6:a03:132::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.27; Tue, 19 May 2020 10:45:19 +0000 Received: from BYAPR18MB2661.namprd18.prod.outlook.com ([fe80::a165:ffa5:f3eb:d62d]) by BYAPR18MB2661.namprd18.prod.outlook.com ([fe80::a165:ffa5:f3eb:d62d%7]) with mapi id 15.20.3021.020; Tue, 19 May 2020 10:45:19 +0000 From: Robert Richter To: Borislav Petkov , Mauro Carvalho Chehab , Tony Luck CC: James Morse , Aristeu Rozanski , Robert Richter , Matthias Brugger , , Subject: [PATCH v3 1/5] EDAC/ghes: Remove unused members of struct ghes_edac_pvt, rename it to ghes_pvt Date: Tue, 19 May 2020 12:44:39 +0200 Message-ID: <20200519104443.15673-2-rrichter@marvell.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200519104443.15673-1-rrichter@marvell.com> References: <20200519104443.15673-1-rrichter@marvell.com> X-ClientProxiedBy: HE1P189CA0023.EURP189.PROD.OUTLOOK.COM (2603:10a6:7:53::36) To BYAPR18MB2661.namprd18.prod.outlook.com (2603:10b6:a03:136::26) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from rric.localdomain (31.208.96.227) by HE1P189CA0023.EURP189.PROD.OUTLOOK.COM (2603:10a6:7:53::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.24 via Frontend Transport; Tue, 19 May 2020 10:45:17 +0000 X-Mailer: git-send-email 2.20.1 X-Originating-IP: [31.208.96.227] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 40020fce-f882-4471-76ad-08d7fbe1b954 X-MS-TrafficTypeDiagnostic: BYAPR18MB2455: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1107; X-Forefront-PRVS: 040866B734 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7FJVj1WTU2JGafnQUuJBgVtcxI7lUsu+rsDt09qH7mvO/1If+nDzhkfJaASlNYNBaOna/owo69z+TF9fYVXEWHmgctAoSTWFurfnVWvwXu5l0K9DsP10ikYRRH35Kbrd7SSrnE9W9DzA3tdhZt0lXXhOr/RwmD9kl7Coa8AMGUr6/JLpqqNlhLeTaNksLMVOEv7CCtx9L+tcd8pe0jimzxTdSBWj02asG/EZGRuLdw0vJpc5vfLf4ECXvnmiPo88c+IWSL1ceSVQMER8rg4+wA+UCgClfEvDwrNHyCfItxMPUFIkaE0mAIFQRyVm2DMRBCSSddv2+z5jpUIu4UQtaYMefWkksv2n4CT9t+tGn55oXj3HUv15AxgQZy3ts56CfNvUId+HjFRjK9SwKt+s+bSddjx7caak+8XCaMe9+uckBQRwxGdEgHPK8bUXJkA3 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR18MB2661.namprd18.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(396003)(39860400002)(136003)(376002)(346002)(366004)(186003)(316002)(16526019)(6666004)(956004)(2616005)(36756003)(8936002)(110136005)(86362001)(66946007)(6486002)(54906003)(26005)(5660300002)(6506007)(66556008)(6512007)(66476007)(52116002)(478600001)(8676002)(1076003)(4326008)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: MfySS82USyBrU5vlpT4c+0jGSVW+1a7PH4JCz9ZOPg5LXDaVM9CI182GVhwPHY+9ymU40ltiFadlcsopb4jANBRneBWTMrG6VF0Iebbb4T465Ln8ZrffO7P883GZxM77mLlFNr3dFI7IvB0P1fB7S1tQQD1xzNDL5UJ/6YNa0/ndpqr/BTlZSlSpNwQBU6TLG0vOBVqUpkjZFa0ac9YRkvcbPYwKoSFz2jlkHkB1SQ3e3llXkURnftGdmz48+M78/Vgzv77S70Hw5ZBuCaGhAlzFLBwuUDsnemz8PWiwS9UCborjmUdgAI9dYo+7BMGO8lcBwzt1c3mJVgsow9Gk61mAKrEGldtN/KKbLzE/YqgRNbh26UUniwOjwX2GK7Ds2cqtHHMWUgCKl9jZzU13PQ02CzlKRnI60V5YFjQzB+X8fPcO0SEsdhGf+mhfvy1CxUCmW5jDojyfJGMb/Fml+n1HJn3ui82FVFaj3luqk30= X-MS-Exchange-CrossTenant-Network-Message-Id: 40020fce-f882-4471-76ad-08d7fbe1b954 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2020 10:45:19.5086 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: uHdkdjq8zFxBGAx0qmT6PXhmpogdx1FcbRucYIkBBTFhkJXBbAuP2QnbOo37DhtUneI1gJdbKVoKzf4fHnCyNQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR18MB2455 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216,18.0.676 definitions=2020-05-19_03:2020-05-19,2020-05-19 signatures=0 Sender: linux-edac-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org The struct members list and ghes of struct ghes_edac_pvt are unused, remove them. On that occasion, rename it to the shorter name struct ghes_pvt. Signed-off-by: Robert Richter --- drivers/edac/ghes_edac.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/edac/ghes_edac.c b/drivers/edac/ghes_edac.c index c7d404629863..2ed48a5d48d6 100644 --- a/drivers/edac/ghes_edac.c +++ b/drivers/edac/ghes_edac.c @@ -15,9 +15,7 @@ #include "edac_module.h" #include -struct ghes_edac_pvt { - struct list_head list; - struct ghes *ghes; +struct ghes_pvt { struct mem_ctl_info *mci; /* Buffers for the error handling routine */ @@ -32,7 +30,7 @@ static refcount_t ghes_refcount = REFCOUNT_INIT(0); * also provides the necessary (implicit) memory barrier for the SMP * case to make the pointer visible on another CPU. */ -static struct ghes_edac_pvt *ghes_pvt; +static struct ghes_pvt *ghes_pvt; /* GHES registration mutex */ static DEFINE_MUTEX(ghes_reg_mutex); @@ -216,7 +214,7 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err) { struct edac_raw_error_desc *e; struct mem_ctl_info *mci; - struct ghes_edac_pvt *pvt; + struct ghes_pvt *pvt; unsigned long flags; char *p; @@ -468,7 +466,7 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev) bool fake = false; int rc = 0, num_dimm = 0; struct mem_ctl_info *mci; - struct ghes_edac_pvt *pvt; + struct ghes_pvt *pvt; struct edac_mc_layer layers[1]; struct ghes_edac_dimm_fill dimm_fill; unsigned long flags; @@ -505,7 +503,7 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev) layers[0].size = num_dimm; layers[0].is_virt_csrow = true; - mci = edac_mc_alloc(0, ARRAY_SIZE(layers), layers, sizeof(struct ghes_edac_pvt)); + mci = edac_mc_alloc(0, ARRAY_SIZE(layers), layers, sizeof(struct ghes_pvt)); if (!mci) { pr_info("Can't allocate memory for EDAC data\n"); rc = -ENOMEM; @@ -513,7 +511,6 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev) } pvt = mci->pvt_info; - pvt->ghes = ghes; pvt->mci = mci; mci->pdev = dev; From patchwork Tue May 19 10:44:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 11557419 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 73D17913 for ; Tue, 19 May 2020 10:45:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5A6A520829 for ; Tue, 19 May 2020 10:45:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=marvell.com header.i=@marvell.com header.b="A+lW433M"; dkim=pass (1024-bit key) header.d=marvell.onmicrosoft.com header.i=@marvell.onmicrosoft.com header.b="GklB5EyK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728672AbgESKpn (ORCPT ); Tue, 19 May 2020 06:45:43 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:50342 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728675AbgESKpm (ORCPT ); Tue, 19 May 2020 06:45:42 -0400 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 04JAeUiC030302; Tue, 19 May 2020 03:45:30 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=pfpt0818; bh=3goDE3ssYNCKrYs7A6T5G4XmNzhTU+H7VajfjPnbkWA=; b=A+lW433MACmQ7fwLxK4GaT8cDdXhsH5xTYWG1mH57mKrTrizLatFPFabBhYFsh+uCEGk qdBHJgW2/xFpn0NFJnTdWtyI9dbyQd2rvhgIgTd70ZDdy0knXhc72bVWkfZe8YswVUiD nFZizvgdX2HlafTnolXx+IPLFJdAOuBO+CGzlQd7X8PNKYjuU3q3LH5ZtWmS/mCivPcZ mrMgmm4yabE0nFhKfi82iuH+LTqi4KjYTvp8IrW9DGASbZSCyN0a7JLjubsUARV5kN9I OZuq1nH3/VvKKN7HNozpRJzMmBGHohnnb95N2IKtyttZKs3kGvhY86/qx3uOWEb9POum Ng== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0b-0016f401.pphosted.com with ESMTP id 312fpp2ybm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 19 May 2020 03:45:25 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 19 May 2020 03:45:23 -0700 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.177) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Tue, 19 May 2020 03:45:23 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VYlTXHDEuUscaSEvUjGxtgZZivDvKCfamvR1AUltbXwvcYRroSWyYd5rCOlLjQHdgzVY70JwD6L1TYZJLpW3pm2CF8GJ8MsbNnugJnH8Sl++3+EBwZ6kFLLjUUUZ4TejOIItgoXlKXBORdYOLpUXzGlZ1AnmAWAz1yX1/I1hl7pu0cqWjRENLJoUJdBSeWUZsAfmLxupL1e8fCk7hgi5lCs0RLutbpRiXulZ2SRkbARQRin4zCYm7bwVj1eSEH32LhguCMaEdfocsMNaehXhO3q3G/1GBfHr+lpxOfiNPMr3J+Qoj8QbwftPesYD/biYTR9AprckV/G8BJqrVE7uhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3goDE3ssYNCKrYs7A6T5G4XmNzhTU+H7VajfjPnbkWA=; b=KZvj5kPkH5vFJ93IiZ1YXzaFTfUxOR9+temou0nWy08pknc9GjyD/6iQUl1UZ5XHK/5teZI8cRcXiazdPWsytt6UiPIOCeJMMFqoBhLm8I04E9ciiPnl6R3MavQ2Kyq85EH5guqOA8BaFOadFsSfoUwaDKmgfTH/HemlOoKdfLy+oJkHmrXjJrGRmIWp6KkqFE5LKtshk7QVz2S3+0S2B0lNsRio6IuUqgE2HNDFzEgZjWXMYLiUOW6fuvwY7x4P6StNxft+TdDJenATO41sDcbJUoldho4T3DLho0HSNbyxxJ1dzTQK1C0wf9EHJHaEYZqwoHXb86qZN1/AgsEIQQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector1-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3goDE3ssYNCKrYs7A6T5G4XmNzhTU+H7VajfjPnbkWA=; b=GklB5EyK4zILj5jOo8Ozwi/HbdHdczvNdLcO7BpAYnbj97XQS0gk0z6rTKh+uZOf9/l4Vr/kU02/KHf3f/0Mv0ikGMKb4O+lWEqvOyj1pMO4UYs6hwzOAys/TT6XdevApDUQPle41x4GzFHD/gbzuRwEBiaTS01cklIjYbM32Rw= Authentication-Results: alien8.de; dkim=none (message not signed) header.d=none;alien8.de; dmarc=none action=none header.from=marvell.com; Received: from BYAPR18MB2661.namprd18.prod.outlook.com (2603:10b6:a03:136::26) by BYAPR18MB2455.namprd18.prod.outlook.com (2603:10b6:a03:132::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.27; Tue, 19 May 2020 10:45:22 +0000 Received: from BYAPR18MB2661.namprd18.prod.outlook.com ([fe80::a165:ffa5:f3eb:d62d]) by BYAPR18MB2661.namprd18.prod.outlook.com ([fe80::a165:ffa5:f3eb:d62d%7]) with mapi id 15.20.3021.020; Tue, 19 May 2020 10:45:22 +0000 From: Robert Richter To: Borislav Petkov , Mauro Carvalho Chehab , Tony Luck CC: James Morse , Aristeu Rozanski , Robert Richter , Matthias Brugger , , Subject: [PATCH v3 2/5] EDAC/ghes: Cleanup struct dimm_fill Date: Tue, 19 May 2020 12:44:40 +0200 Message-ID: <20200519104443.15673-3-rrichter@marvell.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200519104443.15673-1-rrichter@marvell.com> References: <20200519104443.15673-1-rrichter@marvell.com> X-ClientProxiedBy: HE1P189CA0023.EURP189.PROD.OUTLOOK.COM (2603:10a6:7:53::36) To BYAPR18MB2661.namprd18.prod.outlook.com (2603:10b6:a03:136::26) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from rric.localdomain (31.208.96.227) by HE1P189CA0023.EURP189.PROD.OUTLOOK.COM (2603:10a6:7:53::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.24 via Frontend Transport; Tue, 19 May 2020 10:45:20 +0000 X-Mailer: git-send-email 2.20.1 X-Originating-IP: [31.208.96.227] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a82a9aea-c59f-4b9b-b8d6-08d7fbe1bb30 X-MS-TrafficTypeDiagnostic: BYAPR18MB2455: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:326; X-Forefront-PRVS: 040866B734 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JlER1HU1taNiTJ3Mu2wgOjbGRYFHi0bJG05AgHd3I3jX9+JYK1hr3qLGSUV/RK9E+r5eqnWSpVSkd3Q1NTmYoseFjM2Spthph7uSsw64EtxKAFRTWmihUwb0plD8BSWdiO51LbErua5tBfa0+Z4SGCstRyDq3ZH1TYpCEeXqAAVzUEZBwNYy3fP3M9RDyXdtoeC2flMO5l/o4iOUDFP7SMxMcA7m10eKBMiJSCShOfGp7bhSYE0hPjIGfUbHO/jXHtsgDjOtnXNlD4mGBv7JwylO0NLDvGg7p/4903+tNLLd2YkDjtPt1lW2ggPVfZJS2dnVlBVrPtbBp1T5aHT27n8a+gNVN3M9WKYfwdchzWHCpntlrj6lchJArnqvEPeYyidJf5bjsVWLQpYl+YsP0bmAmfifti5V6BwQH1oW99rjiePte6e2HD2zTtbvRjn9 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR18MB2661.namprd18.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(396003)(39860400002)(136003)(376002)(346002)(366004)(186003)(316002)(16526019)(6666004)(956004)(2616005)(36756003)(8936002)(110136005)(86362001)(66946007)(6486002)(54906003)(26005)(5660300002)(6506007)(66556008)(6512007)(66476007)(52116002)(478600001)(8676002)(1076003)(4326008)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: pW30Cxza0dKqD5JfG6ghXwI33/B+rw9KR9mF1bmIUPi4IzmRmf8qzGfU0CCM8glsiudcj7AN+gf/nSBehuMY2U6Mvdi4bN5URVXsQ0MgZtisLc1oaGsvtdIpdKhqlOu6HdgCRW3AcCd243k0DDlj0lgEdw4ZyDLi5FFaMDw27IgNwt3bZBTxB8Y0geN7ri30pweBRrexVQY2CQrPaQevS1jhvK5zDsyXpqODTpGWGKL9Hb04M6VZ3EWqtQOKEFcwSUQatvLrelj2bQlbmPzGoTyJ0WG3J0xny4Tv0IRGXARq17QM+nnCw2LDSlxNZ1wQkvD5LeB0XoE13OHgML54RZcZoa+fk7KHCHT4Wv8dGvQTLfbTTiT62ZOJX7txdPAxQ2T5EfIjy9TSwFP/0ECoyaK/UMv0HPBPckr1VS6Gx+YMHGSS2Q29fkaRpmTuhUfioCeHePYMZ69t4uGTeRYfPiVCuJ8ArKV+xeq4kGd/5TY= X-MS-Exchange-CrossTenant-Network-Message-Id: a82a9aea-c59f-4b9b-b8d6-08d7fbe1bb30 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2020 10:45:22.5239 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 9ed+GiAVJnBRi9aex8h6zmrKoJsabu4gpVYA3tg1uqUALx6QIY1ugXvPUl9h41cNmIb7RYZOuKGnCe1i3ojIQQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR18MB2455 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216,18.0.676 definitions=2020-05-19_03:2020-05-19,2020-05-19 signatures=0 Sender: linux-edac-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org The struct is used to store temporary data for the dmidecode callback. Clean this up a bit: 1) Rename member count to index since this is what it is used for. 2) Move code close to ghes_edac_dmidecode() where it is used. 3) While at it, use edac_get_dimm_by_index(). Signed-off-by: Robert Richter --- drivers/edac/ghes_edac.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/edac/ghes_edac.c b/drivers/edac/ghes_edac.c index 2ed48a5d48d6..b72fe10b84d4 100644 --- a/drivers/edac/ghes_edac.c +++ b/drivers/edac/ghes_edac.c @@ -72,11 +72,6 @@ struct memdev_dmi_entry { u16 conf_mem_clk_speed; } __attribute__((__packed__)); -struct ghes_edac_dimm_fill { - struct mem_ctl_info *mci; - unsigned int count; -}; - static void ghes_edac_count_dimms(const struct dmi_header *dh, void *arg) { int *num_dimm = arg; @@ -112,19 +107,24 @@ static void dimm_setup_label(struct dimm_info *dimm, u16 handle) "unknown memory (handle: 0x%.4x)", handle); } +struct dimm_fill { + struct mem_ctl_info *mci; + int index; +}; + static void ghes_edac_dmidecode(const struct dmi_header *dh, void *arg) { - struct ghes_edac_dimm_fill *dimm_fill = arg; + struct dimm_fill *dimm_fill = arg; struct mem_ctl_info *mci = dimm_fill->mci; if (dh->type == DMI_ENTRY_MEM_DEVICE) { struct memdev_dmi_entry *entry = (struct memdev_dmi_entry *)dh; - struct dimm_info *dimm = edac_get_dimm(mci, dimm_fill->count, 0, 0); + struct dimm_info *dimm = edac_get_dimm_by_index(mci, dimm_fill->index); u16 rdr_mask = BIT(7) | BIT(13); if (entry->size == 0xffff) { pr_info("Can't get DIMM%i size\n", - dimm_fill->count); + dimm_fill->index); dimm->nr_pages = MiB_TO_PAGES(32);/* Unknown */ } else if (entry->size == 0x7fff) { dimm->nr_pages = MiB_TO_PAGES(entry->extended_size); @@ -196,7 +196,7 @@ static void ghes_edac_dmidecode(const struct dmi_header *dh, void *arg) if (dimm->nr_pages) { edac_dbg(1, "DIMM%i: %s size = %d MB%s\n", - dimm_fill->count, edac_mem_types[dimm->mtype], + dimm_fill->index, edac_mem_types[dimm->mtype], PAGES_TO_MiB(dimm->nr_pages), (dimm->edac_mode != EDAC_NONE) ? "(ECC)" : ""); edac_dbg(2, "\ttype %d, detail 0x%02x, width %d(total %d)\n", @@ -206,7 +206,7 @@ static void ghes_edac_dmidecode(const struct dmi_header *dh, void *arg) dimm->smbios_handle = entry->handle; - dimm_fill->count++; + dimm_fill->index++; } } @@ -468,7 +468,7 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev) struct mem_ctl_info *mci; struct ghes_pvt *pvt; struct edac_mc_layer layers[1]; - struct ghes_edac_dimm_fill dimm_fill; + struct dimm_fill dimm_fill; unsigned long flags; int idx = -1; @@ -535,11 +535,11 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev) } if (!fake) { - dimm_fill.count = 0; + dimm_fill.index = 0; dimm_fill.mci = mci; dmi_walk(ghes_edac_dmidecode, &dimm_fill); } else { - struct dimm_info *dimm = edac_get_dimm(mci, 0, 0, 0); + struct dimm_info *dimm = edac_get_dimm_by_index(mci, 0); dimm->nr_pages = 1; dimm->grain = 128; From patchwork Tue May 19 10:44:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 11557423 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A955A912 for ; Tue, 19 May 2020 10:46:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8714F20674 for ; Tue, 19 May 2020 10:46:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=marvell.com header.i=@marvell.com header.b="BJBCx8ue"; dkim=pass (1024-bit key) header.d=marvell.onmicrosoft.com header.i=@marvell.onmicrosoft.com header.b="CfrvRA4m" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726121AbgESKpk (ORCPT ); Tue, 19 May 2020 06:45:40 -0400 Received: from mx0a-0016f401.pphosted.com ([67.231.148.174]:46826 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728686AbgESKpj (ORCPT ); Tue, 19 May 2020 06:45:39 -0400 Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 04JAedar031351; Tue, 19 May 2020 03:45:28 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=pfpt0818; bh=6mh5/15VVIazqil+75t5NdX7QulhHezbMe2gqlPiFeU=; b=BJBCx8ueq9yF/0xdGIv8HF3UvUL2mHBhNM5amvsoMCN0OUqMNFV8sLgdo8knBMMguEWJ +1jXDZwlmBNW/5oOHYxwAQjglIu2tWcuwBzcWcUvLQb3Ss/RQVEFdQe03qU9xFPMj03e n5N6bjXLkw+SmDmrNbHsLJ2T/L3YxEdrVKeuZgrYSG5rVTpNd/gjPXQswZ/bQXWDjN/u CePgn3rbZvxEIfqWturvWfhXcXX78DUKs0gaCBwKcllpEHb38OWJ2AFQDMf3SxP7+x99 ppy1t1HN5sTmrGrMc25FoEP0SPGEIjPCZVQ2E6brrHwMaAnSP4UVG3WmcEFEkG1x2aCy fg== Received: from sc-exch04.marvell.com ([199.233.58.184]) by mx0a-0016f401.pphosted.com with ESMTP id 312dhqkgnt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 19 May 2020 03:45:27 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 19 May 2020 03:45:26 -0700 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.171) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Tue, 19 May 2020 03:45:26 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U6pYZDx/H3m6umFuCDhIpZCYN/BnUqZh8qqGT8FcC1T+pad78WVLuP5T7ur7CKNeFxLIScbCHSIoefp1CaOInsjpF5qKP0AvsFMrDpXQVGyyG2QYdr+SE6b+9nu4Ew72YOqKam+Js5hmDVtV9ll8jcnqaRZOQZ6ZfX4df/G5wAfYbkH8J1QdimobJ96jzDzviyljQUNfUSp4nOL4bGsNs4QODOtACFjEIKgk+iGQKYLcffxBRb/W5wPAt+6u/N46QENWW6+W2d4z4Rc22+DhSSBOj+I9ZCBARYEOxGclbBQk5wxjCQS+1T1TUcbKZQM8R5+427mJy3b9ou17WoPdVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6mh5/15VVIazqil+75t5NdX7QulhHezbMe2gqlPiFeU=; b=JkqsoCjNkVpJ7semhyupQlczM1B5sJqL7elO+/g0L8+FZwfwafyeetSF5+U2trE9tlBV/8owJXLfyhwlvDIGnyiHmIxEA6xmaeGhClCwPE/R5j5d7CWbhGDaGDtwaEmd6mF1MONSNNwzLYGIUajP4sDRCqk2q49S/H1ozul55KMSwaiK0A8FyYTSd4yz3q3friOBI4g3i0bOaR8oLZ47qhrQWJF5nBT6/fw0ZMKUfrdD0vnAv6RhrJ1Uxm35TKvFNQztIV7hg0QpPAX4aEWv0Xhk7aU5qjjuOWZM+CD9SQb8rnwztw5IuXrdgFWKgBE5t5xQSeqkfQeG6iX8fAfMuw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector1-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6mh5/15VVIazqil+75t5NdX7QulhHezbMe2gqlPiFeU=; b=CfrvRA4mnjnYLXXJWH0w5w3qgj5qQbtmk/f+UMiXVJWU31jODl/2jGc7bAmUqsFsS6+kPTPQV/RWFgUW6DCOLWRjOvbYwIcCUIyT5cv6KMm3xwobU/WEsXN6Z6cFQVmP5L31sQNf/7715V9SiLLyRGYv0g0UuDs3btV9/X/Q8oM= Authentication-Results: alien8.de; dkim=none (message not signed) header.d=none;alien8.de; dmarc=none action=none header.from=marvell.com; Received: from BYAPR18MB2661.namprd18.prod.outlook.com (2603:10b6:a03:136::26) by BYAPR18MB2455.namprd18.prod.outlook.com (2603:10b6:a03:132::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.27; Tue, 19 May 2020 10:45:25 +0000 Received: from BYAPR18MB2661.namprd18.prod.outlook.com ([fe80::a165:ffa5:f3eb:d62d]) by BYAPR18MB2661.namprd18.prod.outlook.com ([fe80::a165:ffa5:f3eb:d62d%7]) with mapi id 15.20.3021.020; Tue, 19 May 2020 10:45:25 +0000 From: Robert Richter To: Borislav Petkov , Mauro Carvalho Chehab , Tony Luck CC: James Morse , Aristeu Rozanski , Robert Richter , Matthias Brugger , , Subject: [PATCH v3 3/5] EDAC/ghes: Carve out MC device handling into separate functions Date: Tue, 19 May 2020 12:44:41 +0200 Message-ID: <20200519104443.15673-4-rrichter@marvell.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200519104443.15673-1-rrichter@marvell.com> References: <20200519104443.15673-1-rrichter@marvell.com> X-ClientProxiedBy: HE1P189CA0023.EURP189.PROD.OUTLOOK.COM (2603:10a6:7:53::36) To BYAPR18MB2661.namprd18.prod.outlook.com (2603:10b6:a03:136::26) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from rric.localdomain (31.208.96.227) by HE1P189CA0023.EURP189.PROD.OUTLOOK.COM (2603:10a6:7:53::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.24 via Frontend Transport; Tue, 19 May 2020 10:45:23 +0000 X-Mailer: git-send-email 2.20.1 X-Originating-IP: [31.208.96.227] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a6935bb9-7bc2-4a38-71fe-08d7fbe1bcf2 X-MS-TrafficTypeDiagnostic: BYAPR18MB2455: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:843; X-Forefront-PRVS: 040866B734 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pWfwayL+SJtGhz0CJt46wmZCWDv8TR5wDQntmrrpBMZLkLsv7X41puqe5EIDN3U22T2Fvw7FFMNx7AVYmuKMo/4zj0DoukdSUf+Kal5TdXSUIkbmNPTqPrXFvjS5PONGKNuPunxt8Jf7dgAuPaMYjrsKpHPUy1rjb5Jr9R7kc5zQrHVe5OhuqT7J1RQAztcyH0+n21Z2iv7x9RA41MNXxa04z2+Y8WznJ/QYsL+45+9akUgqk+80gioWrw8pL8kYtAwHL0xC7DeG/59hSQb4jXCLfgb6txQgZBrs7QVgIufejAGeSK4HObLQja6Zw5tO2Ob0iqHzWXeWnLuIs182bGtlPXowPCwKQ1WiBqewnA/yO4FhtFsBfIWLLPb28kMRLPMRKI7RvOxSGkK9A9lZ2R1iS6FNNduUq0tBNgxkyDbAuu4y+wTxKMMFlTyuN3HD X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR18MB2661.namprd18.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(396003)(39860400002)(136003)(376002)(346002)(366004)(186003)(316002)(16526019)(6666004)(956004)(2616005)(36756003)(8936002)(110136005)(86362001)(66946007)(6486002)(54906003)(26005)(5660300002)(6506007)(66556008)(6512007)(66476007)(52116002)(478600001)(8676002)(1076003)(4326008)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: kpKyRSV9fn5SPmzrPurz4OR06EmxPTbs8VToT6Ack4FwTY18vQpxeXQprORg83E61QEffGmB+7i2qboX7To6b4ftMCm0x/abiCZKI0BYE3acGwaw4CuomphRmDzAXgqCVOZMgDuYiY94CBerlRhuNTxuIi9NQm8WlhUdTGxWMuQyKhdlYV5IlPFUHMMCxWtBQAPpwWMr7YRDpMw0ZcI3WX6KOc2oZsT6nPV1rMUbF1x1WVjEYD9aLM2mk5TNoxEr61IT0OSqEsjCFSslwf/nZL+HHhEGB8blhLzKCekKpTKucLnK3ScBsYAB+yFM7F76UugCYgiBZKENLqtu9XFyrtN+Nfbf0zPhrAVzDHCM6kQdp1lL6MhNXt5LLtBlsvgnfJ2xPxoOYQCxK9JUTAblDTj/la4mgxw1tOyPzQbnUcc4C4w8fWbM/kiZh2iUHrrezcMa4gYSelWrLaJxUG0edgeB0r6yHh3uHWAoTQJPV5I= X-MS-Exchange-CrossTenant-Network-Message-Id: a6935bb9-7bc2-4a38-71fe-08d7fbe1bcf2 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2020 10:45:25.4772 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Mb1KoDnftiAfB2PS2niKoIP9dCRvWAqdFOEEbjTzo/NEwGfWZEfLRyLYlX7SplyLn5GJBNsAdnlAYPElDhOTwA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR18MB2455 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216,18.0.676 definitions=2020-05-19_03:2020-05-19,2020-05-19 signatures=0 Sender: linux-edac-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org The functions are too long, carve out code that handles MC devices into the new functions ghes_mc_create(), ghes_mc_add_or_free() and ghes_mc_free(). Apart from better code readability the functions can be reused and the implementation of the error paths becomes easier. Signed-off-by: Robert Richter --- drivers/edac/ghes_edac.c | 128 ++++++++++++++++++++++++--------------- 1 file changed, 80 insertions(+), 48 deletions(-) diff --git a/drivers/edac/ghes_edac.c b/drivers/edac/ghes_edac.c index b72fe10b84d4..8329af037fbe 100644 --- a/drivers/edac/ghes_edac.c +++ b/drivers/edac/ghes_edac.c @@ -461,16 +461,83 @@ static struct acpi_platform_list plat_list[] = { { } /* End */ }; -int ghes_edac_register(struct ghes *ghes, struct device *dev) +static struct mem_ctl_info *ghes_mc_create(struct device *dev, int mc_idx, + int num_dimm) { - bool fake = false; - int rc = 0, num_dimm = 0; + struct edac_mc_layer layers[1]; struct mem_ctl_info *mci; struct ghes_pvt *pvt; - struct edac_mc_layer layers[1]; - struct dimm_fill dimm_fill; + + layers[0].type = EDAC_MC_LAYER_ALL_MEM; + layers[0].size = num_dimm; + layers[0].is_virt_csrow = true; + + mci = edac_mc_alloc(mc_idx, ARRAY_SIZE(layers), layers, sizeof(struct ghes_pvt)); + if (!mci) + return NULL; + + pvt = mci->pvt_info; + pvt->mci = mci; + + mci->pdev = dev; + mci->mtype_cap = MEM_FLAG_EMPTY; + mci->edac_ctl_cap = EDAC_FLAG_NONE; + mci->edac_cap = EDAC_FLAG_NONE; + mci->mod_name = "ghes_edac.c"; + mci->ctl_name = "ghes_edac"; + mci->dev_name = "ghes"; + + return mci; +} + +static void ghes_mc_destroy(struct mem_ctl_info *mci) +{ + if (mci) + edac_mc_free(mci); +} + +static int ghes_mc_add(struct mem_ctl_info *mci) +{ unsigned long flags; - int idx = -1; + int rc; + + rc = edac_mc_add_mc(mci); + if (rc < 0) + return rc; + + spin_lock_irqsave(&ghes_lock, flags); + ghes_pvt = mci->pvt_info; + spin_unlock_irqrestore(&ghes_lock, flags); + + return 0; +} + +static struct mem_ctl_info *ghes_mc_del(void) +{ + struct mem_ctl_info *mci; + unsigned long flags; + + /* + * Wait for the irq handler being finished. + */ + spin_lock_irqsave(&ghes_lock, flags); + mci = ghes_pvt ? ghes_pvt->mci : NULL; + ghes_pvt = NULL; + spin_unlock_irqrestore(&ghes_lock, flags); + + if (mci) + mci = edac_mc_del_mc(mci->pdev); + + return mci; +} + +int ghes_edac_register(struct ghes *ghes, struct device *dev) +{ + struct dimm_fill dimm_fill; + int rc = 0, num_dimm = 0; + struct mem_ctl_info *mci; + bool fake = false; + int idx; if (IS_ENABLED(CONFIG_X86)) { /* Check if safe to enable on this system */ @@ -499,28 +566,13 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev) num_dimm = 1; } - layers[0].type = EDAC_MC_LAYER_ALL_MEM; - layers[0].size = num_dimm; - layers[0].is_virt_csrow = true; - - mci = edac_mc_alloc(0, ARRAY_SIZE(layers), layers, sizeof(struct ghes_pvt)); + mci = ghes_mc_create(dev, 0, num_dimm); if (!mci) { pr_info("Can't allocate memory for EDAC data\n"); rc = -ENOMEM; goto unlock; } - pvt = mci->pvt_info; - pvt->mci = mci; - - mci->pdev = dev; - mci->mtype_cap = MEM_FLAG_EMPTY; - mci->edac_ctl_cap = EDAC_FLAG_NONE; - mci->edac_cap = EDAC_FLAG_NONE; - mci->mod_name = "ghes_edac.c"; - mci->ctl_name = "ghes_edac"; - mci->dev_name = "ghes"; - if (fake) { pr_info("This system has a very crappy BIOS: It doesn't even list the DIMMS.\n"); pr_info("Its SMBIOS info is wrong. It is doubtful that the error report would\n"); @@ -548,18 +600,13 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev) dimm->edac_mode = EDAC_SECDED; } - rc = edac_mc_add_mc(mci); + rc = ghes_mc_add(mci); if (rc < 0) { pr_info("Can't register at EDAC core\n"); - edac_mc_free(mci); - rc = -ENODEV; + ghes_mc_destroy(mci); goto unlock; } - spin_lock_irqsave(&ghes_lock, flags); - ghes_pvt = pvt; - spin_unlock_irqrestore(&ghes_lock, flags); - /* only set on success */ refcount_set(&ghes_refcount, 1); @@ -572,28 +619,13 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev) void ghes_edac_unregister(struct ghes *ghes) { struct mem_ctl_info *mci; - unsigned long flags; mutex_lock(&ghes_reg_mutex); - if (!refcount_dec_and_test(&ghes_refcount)) - goto unlock; - - /* - * Wait for the irq handler being finished. - */ - spin_lock_irqsave(&ghes_lock, flags); - mci = ghes_pvt ? ghes_pvt->mci : NULL; - ghes_pvt = NULL; - spin_unlock_irqrestore(&ghes_lock, flags); - - if (!mci) - goto unlock; - - mci = edac_mc_del_mc(mci->pdev); - if (mci) - edac_mc_free(mci); + if (refcount_dec_and_test(&ghes_refcount)) { + mci = ghes_mc_del(); + ghes_mc_destroy(mci); + } -unlock: mutex_unlock(&ghes_reg_mutex); } From patchwork Tue May 19 10:44:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 11557417 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4CDEF912 for ; Tue, 19 May 2020 10:45:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2FA2420758 for ; Tue, 19 May 2020 10:45:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=marvell.com header.i=@marvell.com header.b="EhnsoZyD"; dkim=pass (1024-bit key) header.d=marvell.onmicrosoft.com header.i=@marvell.onmicrosoft.com header.b="MxMn91Br" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726735AbgESKpr (ORCPT ); Tue, 19 May 2020 06:45:47 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:59142 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728686AbgESKpn (ORCPT ); Tue, 19 May 2020 06:45:43 -0400 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 04JAepe6030448; Tue, 19 May 2020 03:45:32 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=pfpt0818; bh=egmW+7fOU3wI49v5Mo473K16edes6eXSnfW6okNrywk=; b=EhnsoZyDdkCfY/PGnY4N7V+ZUOnQVUpVDv122BXagX3SIqF+skzx29BCZehJBO3D/SUe dnl2sr9YIWx5hhuxQgrgflRpPbkSJvx8Wr2cNCIWdu2wMMZx7q0ir1S4d9IW2WzitI/d zQ2SjEqS0bcVTGUYsdOwRQbFGaI7IElUBw4IGV0KjmMLGnEAFJe0vDhEMWWsIoLrmLue npcxmas53UJQTnQiKjInrPn5NGTOJuSTWNKdih2S38nov0G263OqUFWVwLSAHZDdlS1L yBy3PuHsSNCyE0UjRVowRrHk8J8hv+6ylT1p+i9kOdy4pEpCvStdK90DF9VoUH0F0yLx uQ== Received: from sc-exch04.marvell.com ([199.233.58.184]) by mx0b-0016f401.pphosted.com with ESMTP id 312fpp2ybw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 19 May 2020 03:45:31 -0700 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 19 May 2020 03:45:30 -0700 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.106) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Tue, 19 May 2020 03:45:29 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jCL2s68V8HCmpvP7VUA5KD7onxkEAbOjO4RmQh2kevD8yI+ItT24Pd+Fq8yFXsovF21dsZ+HME7ox6Kp//RxWxTP2Up4VbdWBTDGsJ8oJwuZ4Da5bE2yR10XUsLJrYCdJk16SbEKCXG6/spPhJB1bHOvLbHXt9aAZnRBzqDUmj4of+XCxi1HVastQH1PbC0EUN19FqQzPSPoecaVRCsMk3JsJ2We6EAM5rY/UwoubIuUAM3Du5PP/0XBftHZREFoRob/aX17P7Rxl43c/s8TLz+of4bmW+crm2Etd/VCD3ro+anv42+H0N5Q0l8Zl/T7gAc0Moj2ERZwMWs7yplQ4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=egmW+7fOU3wI49v5Mo473K16edes6eXSnfW6okNrywk=; b=QkeQ/92kq0ksYH6h0iQfE//OpLorFWgEF3aeQ+3pZLRtUYh2a+BQbDg6MC/GpnljNlBgSobMw9iOEz29ztRnWBWWyk0UIr+iitUAYRSpiDs3R1coXWWKQ4tVN64PAoftdN1sQI6D+mkRK7emJ0Q/zmr8H3TYNFqSqHCM7wEyF5ORHkkXnFSfCcmw0NWTNAhfW4u2ObNrR0QI7zZWMmu3bZWIXQvj4JfrtjnsPnk4J+8TWZzjDnLPCPis6YXlORShJ/k/iOGGyJJ9AD940ySNXA4NSfh+rG61SHsJA0nq/Poiinu0CI6LPMk59o5w53dWs1MysFFfAfWVhKpQjZiAYw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector1-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=egmW+7fOU3wI49v5Mo473K16edes6eXSnfW6okNrywk=; b=MxMn91BrGRdyi/yBeQEbFM2UqGgjcALWWAxWyMXYtjaZmeXiSJH0nzzLXyopQiMzR3SObdVPVUZAsOTf/pVfe8h/hKWPzrhnOC2rhqFZdp6uFec2yQ6lNqvMaM2eyx7ovCiHYFokfNuo1Krm3FnTgRF41CFqYDMrlFi0wCfisCA= Authentication-Results: alien8.de; dkim=none (message not signed) header.d=none;alien8.de; dmarc=none action=none header.from=marvell.com; Received: from BYAPR18MB2661.namprd18.prod.outlook.com (2603:10b6:a03:136::26) by BYAPR18MB2455.namprd18.prod.outlook.com (2603:10b6:a03:132::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.27; Tue, 19 May 2020 10:45:28 +0000 Received: from BYAPR18MB2661.namprd18.prod.outlook.com ([fe80::a165:ffa5:f3eb:d62d]) by BYAPR18MB2661.namprd18.prod.outlook.com ([fe80::a165:ffa5:f3eb:d62d%7]) with mapi id 15.20.3021.020; Tue, 19 May 2020 10:45:28 +0000 From: Robert Richter To: Borislav Petkov , Mauro Carvalho Chehab , Tony Luck CC: James Morse , Aristeu Rozanski , Robert Richter , Matthias Brugger , , Subject: [PATCH v3 4/5] EDAC/ghes: Have a separate code path for creating the fake MC Date: Tue, 19 May 2020 12:44:42 +0200 Message-ID: <20200519104443.15673-5-rrichter@marvell.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200519104443.15673-1-rrichter@marvell.com> References: <20200519104443.15673-1-rrichter@marvell.com> X-ClientProxiedBy: HE1P189CA0023.EURP189.PROD.OUTLOOK.COM (2603:10a6:7:53::36) To BYAPR18MB2661.namprd18.prod.outlook.com (2603:10b6:a03:136::26) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from rric.localdomain (31.208.96.227) by HE1P189CA0023.EURP189.PROD.OUTLOOK.COM (2603:10a6:7:53::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.24 via Frontend Transport; Tue, 19 May 2020 10:45:26 +0000 X-Mailer: git-send-email 2.20.1 X-Originating-IP: [31.208.96.227] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2318a0b3-6a75-4cb5-3379-08d7fbe1beb9 X-MS-TrafficTypeDiagnostic: BYAPR18MB2455: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:303; X-Forefront-PRVS: 040866B734 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fvAqKAXzZaU+eDnBXSrsB5yB6kyja+V+aA7CLbTwibNOrwncUCqFWsZAd33hhOZIQAgVxq9Ywl2tIRfq5hONAm0+9qow3dXeCBUlUCwaVSJOxg6ApEYTix6NAERH/qCGrzA9kKw6R2b9QzM7DHcJzC4gvXns1jubzFCoXrLbegvDIHLuCLmGLqxBkkn8MA1seaF3mwdd32KPj4hktwbE/Z0IPXYs5MNELmRxMHK/gjnbUlAvf3n4diCWbGBp0YWFWqwQLscFaMiRThNWXaZmNYuooRf3TxskwxfDvdBy7jC9WmnzK/ngH9yvkmQa8dPlPreiCaa0OjOvLnkulqxRQbfXxwIWguWF4fhatJEkXr/wx6dktRja2Zzd6QF4bcGycADifPGGrhzGWnAWF/y9a8TyEQcSQl9ZKH6yg4/ofwgEs7lLPo6UK8HF5sa5sSk0 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR18MB2661.namprd18.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(396003)(39860400002)(136003)(376002)(346002)(366004)(186003)(316002)(16526019)(6666004)(956004)(2616005)(36756003)(8936002)(110136005)(86362001)(66946007)(6486002)(54906003)(26005)(5660300002)(6506007)(66556008)(6512007)(66476007)(52116002)(478600001)(8676002)(1076003)(4326008)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: GAqqQDUfuGnAygXCVhjny3AMmmJTW5Y3Y1IivmWo1VuE5yps6TSbTVMmUm/HZbpkF9vL8mq4jRJF9K9JwQII1iJPmCPyuL4DgdWU9CeshW6bB9dX8MBUW8rl0JtwBNf3UxPdZbzLccUKufkm4hvTTRKhx5NjqhUQEgMwtl6nTyl4AVeGyv2BX3mUbSX4vn8X7QMvXfKkiovTyqen4eREHDDJyGjZSXDgt2jee1a579RvXumayaE75zROmDanTL2941VCnwZOTAgknYHkWgsU02Jpxs87WODUUI265ZBp85OcNK/lthHqxvZ5SprUSTVa49wl+Wn5Rd1woFvxWH5pFilxq6ap6JWZ9WphZ044QaK0CYjrFK7cYFXA84Ju6PGvnNo1zeNsPCgK6WB7aPnDdq4Zt9l61OcugXh39sPHo0FMgAX7dkC8HV9J132aZQP7IJKaK6GBa7MudUg+XdcQ2e7J2SUGMcLphX5dKfF/xlE= X-MS-Exchange-CrossTenant-Network-Message-Id: 2318a0b3-6a75-4cb5-3379-08d7fbe1beb9 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2020 10:45:28.5094 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: DbH/WlSN+z7F8c5UciqlSbXQzUlVoLsbRFrbk8vgzvHJRgHLk54/LC8wP0dac4FJ/pXIS7ryYqARAT2+OwvhgQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR18MB2455 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216,18.0.676 definitions=2020-05-19_03:2020-05-19,2020-05-19 signatures=0 Sender: linux-edac-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org The code in ghes_edac_register() switches back and forth between standard and fake controller creation. Do one thing only and separate the code path that creates the fake MC. Note: For better review the code is not yet carved out in separate functions. Signed-off-by: Robert Richter --- drivers/edac/ghes_edac.c | 73 +++++++++++++++++++++++++--------------- 1 file changed, 46 insertions(+), 27 deletions(-) diff --git a/drivers/edac/ghes_edac.c b/drivers/edac/ghes_edac.c index 8329af037fbe..47b99e0fea6d 100644 --- a/drivers/edac/ghes_edac.c +++ b/drivers/edac/ghes_edac.c @@ -536,7 +536,6 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev) struct dimm_fill dimm_fill; int rc = 0, num_dimm = 0; struct mem_ctl_info *mci; - bool fake = false; int idx; if (IS_ENABLED(CONFIG_X86)) { @@ -560,24 +559,44 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev) /* Get the number of DIMMs */ dmi_walk(ghes_edac_count_dimms, &num_dimm); - /* Check if we've got a bogus BIOS */ - if (num_dimm == 0) { - fake = true; - num_dimm = 1; - } + if (!num_dimm) { + /* + * Bogus BIOS: Ignore DMI topology and use a single MC + * with only one DIMM for the whole address range to + * catch all errros. + */ + struct dimm_info *dimm; - mci = ghes_mc_create(dev, 0, num_dimm); - if (!mci) { - pr_info("Can't allocate memory for EDAC data\n"); - rc = -ENOMEM; - goto unlock; - } + mci = ghes_mc_create(dev, 0, 1); + if (!mci) { + rc = -ENOMEM; + goto unlock; + } + + dimm = edac_get_dimm_by_index(mci, 0); + + dimm->nr_pages = 1; + dimm->grain = 128; + dimm->mtype = MEM_UNKNOWN; + dimm->dtype = DEV_UNKNOWN; + dimm->edac_mode = EDAC_SECDED; + + snprintf(dimm->label, sizeof(dimm->label), "unknown memory"); + + rc = ghes_mc_add(mci); + if (rc) { + ghes_mc_destroy(mci); + goto unlock; + } - if (fake) { pr_info("This system has a very crappy BIOS: It doesn't even list the DIMMS.\n"); pr_info("Its SMBIOS info is wrong. It is doubtful that the error report would\n"); pr_info("work on such system. Use this driver with caution\n"); - } else if (idx < 0) { + + goto out; + } + + if (idx < 0) { pr_info("This EDAC driver relies on BIOS to enumerate memory and get error reports.\n"); pr_info("Unfortunately, not all BIOSes reflect the memory layout correctly.\n"); pr_info("So, the end result of using this driver varies from vendor to vendor.\n"); @@ -586,31 +605,31 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev) pr_info("This system has %d DIMM sockets.\n", num_dimm); } - if (!fake) { - dimm_fill.index = 0; - dimm_fill.mci = mci; - dmi_walk(ghes_edac_dmidecode, &dimm_fill); - } else { - struct dimm_info *dimm = edac_get_dimm_by_index(mci, 0); - - dimm->nr_pages = 1; - dimm->grain = 128; - dimm->mtype = MEM_UNKNOWN; - dimm->dtype = DEV_UNKNOWN; - dimm->edac_mode = EDAC_SECDED; + mci = ghes_mc_create(dev, 0, num_dimm); + if (!mci) { + rc = -ENOMEM; + goto unlock; } + dimm_fill.index = 0; + dimm_fill.mci = mci; + + dmi_walk(ghes_edac_dmidecode, &dimm_fill); + rc = ghes_mc_add(mci); if (rc < 0) { - pr_info("Can't register at EDAC core\n"); ghes_mc_destroy(mci); goto unlock; } +out: /* only set on success */ refcount_set(&ghes_refcount, 1); unlock: + if (rc < 0) + pr_info("Can't register at EDAC core\n"); + mutex_unlock(&ghes_reg_mutex); return rc; From patchwork Tue May 19 10:44:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 11557421 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B72E114C0 for ; Tue, 19 May 2020 10:45:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9D39F207D8 for ; Tue, 19 May 2020 10:45:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=marvell.com header.i=@marvell.com header.b="Hy18dqwi"; dkim=pass (1024-bit key) header.d=marvell.onmicrosoft.com header.i=@marvell.onmicrosoft.com header.b="aFviab6Z" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728769AbgESKp4 (ORCPT ); Tue, 19 May 2020 06:45:56 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:43060 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728733AbgESKpr (ORCPT ); Tue, 19 May 2020 06:45:47 -0400 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 04JAeaW8030400; Tue, 19 May 2020 03:45:35 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=pfpt0818; bh=s1V3Liiq1EnrziFxJrIeqdKByYPhjiOM9qxgg3deTyc=; b=Hy18dqwig8kmfTIHwDMnhCYJAgmyw++jKnvucpXi2XAIpz13Mx2pr2muOisu5zV+kZ6m BAFOZtUgXropcmQl9mPHws3qbEimk/hY7QfK12hT8Hf4yQGhEFpITu6zMVHdVQxImh9q t027J9FVnzh7fBuY8zDWuolU26C693VzCapVTY32mCOGjJA5q3pQqqdddAeOvx+IPuLJ jH92e+Ki2kM3eoc5gfFwPrR3/XA9NB/l6oK78lY0l5qkgjv3NyM534UXV6S76Ntjzjiu I9+DEeJtclcihc79sx3LbFJjESJfugGm+OeP1LBRJ0Y9ou3gM30FJiEILbeagHpo60L5 VA== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0b-0016f401.pphosted.com with ESMTP id 312fpp2ybx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 19 May 2020 03:45:35 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 19 May 2020 03:45:33 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 19 May 2020 03:45:33 -0700 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.106) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Tue, 19 May 2020 03:45:32 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HZ+jD1Qu7AR3jbgbZhwQ073ywKxTpx6YAdm887U7+YytwXtn34O3CaQHNm5fMVhipHl1CLEUQdVZiH/Fw+VB8ww3BnAcrD7JWI6A1ZAxMbJ2PTBxFeURqLGuLQgsFNBcdgwLj70JkmKHgFjT/J+C6ZK5yl1F294unE6gez8Nk6I0/MsrG2NMc1HtlEdcYl+2aaVT3nmJMJmDyDpDOVMTmwlB4ku8MCuwNd2bNfkNa9wM0m2AXR1cz27ngeqxoSbw5juyORaU7Y4fFGc90xIcAdh3duzLxb5w4ECzkPtgiXpa75E7vETQox9XTCGJsCBhfzisW2ti6LLiWHXioXN/GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=s1V3Liiq1EnrziFxJrIeqdKByYPhjiOM9qxgg3deTyc=; b=cT9XaWtI0+pl0+lF5X32mDs4exOhU2ELcXkz4S1fTIaAbgaRisss/5aIpyS2Uy4hfFYawrr5NHciwBahlrQFQi1PjjrOtkcX8GsuHDpbgdeRSl1upRCQ/CDjhlLCLhTRezUSFUMfgOtgIgrfYT7JmBwejRfR3/QlYENEQr51IrQtpo31+7vdrWNaSGY6/H33sdllx7F7RQ49bDpYhRaP6iWPQEDRFCsO/Ez2+vQqviadb8m1I+FgicmCpPtwOURsQL4xhddSOnIY78471tjVJgjiyf1bU550eNqe/iyg/akuuF0MmjSMcDURs2Y/TN06x7W+7sGzZHLTTHg2BMwbjw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector1-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=s1V3Liiq1EnrziFxJrIeqdKByYPhjiOM9qxgg3deTyc=; b=aFviab6Ze0mueWW0w3G7cuzwUeHE0W6oc/+2pIb/m9c0qH9YxTQJmTqr9o4U0lr0RhJGl5Q2/hcJlYwKTuqGc+WAvFL4EBE91gmZlgpRq0fsUk47tojpBnGXwI4LGbEtue4G71JA6i2hBPAanAlYskfO8fSL/aA3c1yC0gI1BJY= Authentication-Results: alien8.de; dkim=none (message not signed) header.d=none;alien8.de; dmarc=none action=none header.from=marvell.com; Received: from BYAPR18MB2661.namprd18.prod.outlook.com (2603:10b6:a03:136::26) by BYAPR18MB2455.namprd18.prod.outlook.com (2603:10b6:a03:132::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.27; Tue, 19 May 2020 10:45:31 +0000 Received: from BYAPR18MB2661.namprd18.prod.outlook.com ([fe80::a165:ffa5:f3eb:d62d]) by BYAPR18MB2661.namprd18.prod.outlook.com ([fe80::a165:ffa5:f3eb:d62d%7]) with mapi id 15.20.3021.020; Tue, 19 May 2020 10:45:31 +0000 From: Robert Richter To: Borislav Petkov , Mauro Carvalho Chehab , Tony Luck CC: James Morse , Aristeu Rozanski , Robert Richter , Matthias Brugger , , Subject: [PATCH v3 5/5] EDAC/ghes: Carve out code into ghes_edac_register_{one,fake}() Date: Tue, 19 May 2020 12:44:43 +0200 Message-ID: <20200519104443.15673-6-rrichter@marvell.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200519104443.15673-1-rrichter@marvell.com> References: <20200519104443.15673-1-rrichter@marvell.com> X-ClientProxiedBy: HE1P189CA0023.EURP189.PROD.OUTLOOK.COM (2603:10a6:7:53::36) To BYAPR18MB2661.namprd18.prod.outlook.com (2603:10b6:a03:136::26) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from rric.localdomain (31.208.96.227) by HE1P189CA0023.EURP189.PROD.OUTLOOK.COM (2603:10a6:7:53::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.24 via Frontend Transport; Tue, 19 May 2020 10:45:29 +0000 X-Mailer: git-send-email 2.20.1 X-Originating-IP: [31.208.96.227] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c9ffd946-8380-49a3-6a12-08d7fbe1c080 X-MS-TrafficTypeDiagnostic: BYAPR18MB2455: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3044; X-Forefront-PRVS: 040866B734 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qCoUeHOJHl3JgWUVu8OpPdTE7O8MwNYPu+4aSvaOm6XSxeAB9+5Udk+Mz3jm2cw9Nw9Q3hzD9MgrkWAK+5/cmY0gtXGeFQC490SIqTjpK/bJ3EnbPcsyYKXemf1L/BHGlWnmNRNMwYyeL2+Rvgb7Q7Ie+/wjI9KUaqtD+N7NfUeUEU87h1FtoajCd9bz0OeuHNx9SPyu3RLwntOtaYgi1rocijQ9OtFOuQdHpYrgdRgbVos/h6kjrAcQYm2/CC+Rxe1DZjuAh/s6Jk6tk4wqd0Qwr6h0Neaf/47LjmeOWiJFlBMJLhO/PcTRM+QkJhJz6uaBBPGz6/mu/6QFb80ZiRj3Kvlnhkuqk9qQlDLhrzyTz7tmMjQQMYUaOpnCL37f60fe6u9VkhatqCssgI/lFz2Nc9HIUfuNSBALnjQTx9ywW+TAHMRCOdmJ8eJZO+f8wkkEMJAtK76U/ymaOLOr/zZ70NH7X5aGIUKPtFW6M23jYPTLvWawiOWoYBANO03b X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR18MB2661.namprd18.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(396003)(39860400002)(136003)(376002)(346002)(366004)(186003)(316002)(16526019)(6666004)(956004)(2616005)(36756003)(8936002)(110136005)(86362001)(66946007)(6486002)(54906003)(26005)(5660300002)(6506007)(66556008)(6512007)(66476007)(52116002)(478600001)(8676002)(1076003)(4326008)(2906002)(142933001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 5Ig+CT2yfMC+whWcG8KQOXi8Du3kc3Z/MSfd5/NqLlyHeUfX2CuEtEmb8ZQdSykby5rzaWs6DV59/qC9FwMBYATW+zEDUYEgzI3LGwkMtB64wtOXqQxY6/PKWUhuHqoSEeysz6AJNJWPr+0r6d7IcLDeKR6WLq8CXAp6wIgOAUWKyny/LTgnV35GbkQPeKSHYW6M6WLZCyhIeRlFFfSRXFFVKHaGMTcKI2caPW5i7MlUKUJ5Xpvqhe5gg+GnUxOmob6ql3jsTn31NauhkPXiLhHkf6Va61h1HvYjXGqu+PINIixdv3XtfN2U1u/AqgOFZg00EKBUrtFmfq7+qmzXr0+MG38JUxquJjZTHRC55FZN58vEkYRCHqoSOc6sl3s98azmZryY6k/jvJVW2Kjz6l5rlFQ5qQqu21rI9iXlGMaM5mX6UW6+iVoQLqPGQUA/x7AnQ4VbAF7uoh2EMtOL6H5dqLArUiQ9LpDp7dusNFQ= X-MS-Exchange-CrossTenant-Network-Message-Id: c9ffd946-8380-49a3-6a12-08d7fbe1c080 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2020 10:45:31.5067 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: FLEHjdPKMRYh0mqd0rA6oLVc0m0l9p4O0b3Ceu94Cuy6jffGI/oonpgORFO8efSLK2Hvz0JLowTr2BKYq8r06A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR18MB2455 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216,18.0.676 definitions=2020-05-19_03:2020-05-19,2020-05-19 signatures=0 Sender: linux-edac-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org Factor out code to register a memory controller including DIMMs. Do this for standard and fake memory controller in the two functions ghes_edac_register_one() and ghes_edac_register_fake(). Function ghes_edac_register_one() could be reused to register multiple *mci structs. Signed-off-by: Robert Richter --- drivers/edac/ghes_edac.c | 94 +++++++++++++++++++++++----------------- 1 file changed, 55 insertions(+), 39 deletions(-) diff --git a/drivers/edac/ghes_edac.c b/drivers/edac/ghes_edac.c index 47b99e0fea6d..b68cd22e68bf 100644 --- a/drivers/edac/ghes_edac.c +++ b/drivers/edac/ghes_edac.c @@ -531,11 +531,60 @@ static struct mem_ctl_info *ghes_mc_del(void) return mci; } -int ghes_edac_register(struct ghes *ghes, struct device *dev) +static int ghes_edac_register_fake(struct device *dev) +{ + struct mem_ctl_info *mci; + struct dimm_info *dimm; + int rc; + + mci = ghes_mc_create(dev, 0, 1); + if (!mci) + return -ENOMEM; + + dimm = edac_get_dimm_by_index(mci, 0); + + dimm->nr_pages = 1; + dimm->grain = 128; + dimm->mtype = MEM_UNKNOWN; + dimm->dtype = DEV_UNKNOWN; + dimm->edac_mode = EDAC_SECDED; + + snprintf(dimm->label, sizeof(dimm->label), "unknown memory"); + + rc = ghes_mc_add(mci); + + if (rc < 0) + ghes_mc_destroy(mci); + + return rc; +} + +static int ghes_edac_register_one(struct device *dev, int mc_idx, int num_dimm) { struct dimm_fill dimm_fill; - int rc = 0, num_dimm = 0; struct mem_ctl_info *mci; + int rc; + + mci = ghes_mc_create(dev, mc_idx, num_dimm); + if (!mci) + return -ENOMEM; + + dimm_fill.index = 0; + dimm_fill.mci = mci; + + dmi_walk(ghes_edac_dmidecode, &dimm_fill); + + rc = ghes_mc_add(mci); + + if (rc < 0) + ghes_mc_destroy(mci); + + return rc; +} + +int ghes_edac_register(struct ghes *ghes, struct device *dev) +{ + int rc = 0, num_dimm = 0; int idx; if (IS_ENABLED(CONFIG_X86)) { @@ -565,29 +614,9 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev) * with only one DIMM for the whole address range to * catch all errros. */ - struct dimm_info *dimm; - - mci = ghes_mc_create(dev, 0, 1); - if (!mci) { - rc = -ENOMEM; + rc = ghes_edac_register_fake(dev); + if (rc < 0) goto unlock; - } - - dimm = edac_get_dimm_by_index(mci, 0); - - dimm->nr_pages = 1; - dimm->grain = 128; - dimm->mtype = MEM_UNKNOWN; - dimm->dtype = DEV_UNKNOWN; - dimm->edac_mode = EDAC_SECDED; - - snprintf(dimm->label, sizeof(dimm->label), "unknown memory"); - - rc = ghes_mc_add(mci); - if (rc) { - ghes_mc_destroy(mci); - goto unlock; - } pr_info("This system has a very crappy BIOS: It doesn't even list the DIMMS.\n"); pr_info("Its SMBIOS info is wrong. It is doubtful that the error report would\n"); @@ -605,22 +634,9 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev) pr_info("This system has %d DIMM sockets.\n", num_dimm); } - mci = ghes_mc_create(dev, 0, num_dimm); - if (!mci) { - rc = -ENOMEM; - goto unlock; - } - - dimm_fill.index = 0; - dimm_fill.mci = mci; - - dmi_walk(ghes_edac_dmidecode, &dimm_fill); - - rc = ghes_mc_add(mci); - if (rc < 0) { - ghes_mc_destroy(mci); + rc = ghes_edac_register_one(dev, 0, num_dimm); + if (rc < 0) goto unlock; - } out: /* only set on success */