From patchwork Mon Jun 24 15:09:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 167606 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp4347425ilk; Mon, 24 Jun 2019 08:09:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqyX+HYw9YXu/sgnSRW2bt2bNdFVI/rOozxdJzfY8YC5jHjyETzwpxmFCbpB3t1ZCUGsX3O0 X-Received: by 2002:a17:902:8609:: with SMTP id f9mr137796932plo.252.1561388963570; Mon, 24 Jun 2019 08:09:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561388963; cv=none; d=google.com; s=arc-20160816; b=sa2cvhDx1OrNWIdYDaZACsVyM3Dfx52a2Fo9fuK84wNyXjzkwYaHAqmkZwWxjwSD3Y pZyA0T7FD1b4JEv84lv/jbZ5w4R2Xx5OEmxf8vzI8MLbxVhYJ50cPKBQXO1Rc/zh2t/t 5Of07wWTt1GONOq4RZPvIY6Vq2oBxZmpK2J/Bf1O2iTAHqMYcjfFqGh8FDRmXcaLWPb5 i5XPObEatXPtod1tfjYgiHgaW6h7wN9bguAbalJCq9swTRs60DkFTgLAEeRZovEZRPCI kmxOAHx3WIi9KGKb8Kw0Y4krC4Air4eFfiT5JHShAXh15Pe4K2/VKznyy+tEqAwtLttB skeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:dkim-signature :dkim-signature; bh=jFsFLKHCcJPeWPXNzKZ4zNh9o3eVIQkcVZvv8t0zFMo=; b=YZICFoviql37PV0itJkeb3oVkKyv4CQSIMyMHwUxGto2n8171trI3XBdekNKTCCS44 ZBNQSxmREtx64RYo2bxdpmqHp0OuMB69Q0cpU+LZA4958bBpIc6wgYGQ80/8EloAvC34 CCT4x+1zlS7LG9lJCSc8W2g/LA9qkoNXEjeblfN8MrDYE7MiGKBGVPGutmHtQGMvz3Xz G/TXFAxQRm7JHWG1ouG0F+IszYHevUYKKCNupPArOU4hATqXxUX4oUm1XFa3wU7xsYdW V8cSUpY8U1UTBNp/vIb1WD9MRxNX/BOmayBYPRsL8xKg3L06nFgbgPnTQWuTPgc+dpGK wKSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0818 header.b=MZn0SVV6; dkim=pass header.i=@marvell.onmicrosoft.com header.s=selector2-marvell-onmicrosoft-com header.b="Xa9nqIF/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=marvell.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g10si10697753pjp.74.2019.06.24.08.09.23; Mon, 24 Jun 2019 08:09:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0818 header.b=MZn0SVV6; dkim=pass header.i=@marvell.onmicrosoft.com header.s=selector2-marvell-onmicrosoft-com header.b="Xa9nqIF/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=marvell.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730519AbfFXPJV (ORCPT + 30 others); Mon, 24 Jun 2019 11:09:21 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:8656 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729578AbfFXPJS (ORCPT ); Mon, 24 Jun 2019 11:09:18 -0400 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x5OF8DQp025885; Mon, 24 Jun 2019 08:09:12 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pfpt0818; bh=jFsFLKHCcJPeWPXNzKZ4zNh9o3eVIQkcVZvv8t0zFMo=; b=MZn0SVV6XBDYYgTKGAHbdWJFivnj47h/iXRTD5TTduViqKlhPPfBb7u0sqUw5ECIKjL8 TYdHNMNWeRDPRaiIxaAiu23E+frCyEjbnQ33j6kl7dUIboBq5BICB9G+wMObgHDXQVvh hO708bwWIccOsI1qau8UZEoLzaPQIdzBHH7wmINZ4Fphq/4P0x03VxP9pdfA6n5sETx6 Ew3ks1E+C+FfQIW6xLo3SWfWQ0RxivCpn+UPGeQplRohSRQtQAdB8hwYgr6C0xedlm3V gBU0tHyMTsArJs+yf+vKbX5oSoxKIrZooQLz9H6anwZsKGuS9XZEhvLPo5BetoLb8JRa Pg== Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0b-0016f401.pphosted.com with ESMTP id 2t9kujf7rr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 24 Jun 2019 08:09:11 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 24 Jun 2019 08:09:10 -0700 Received: from NAM03-BY2-obe.outbound.protection.outlook.com (104.47.42.55) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Mon, 24 Jun 2019 08:09:10 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector2-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jFsFLKHCcJPeWPXNzKZ4zNh9o3eVIQkcVZvv8t0zFMo=; b=Xa9nqIF/IKzbzRW6WjwTp39ibzQaNKTeHyA9mvdFNEV+lYcgWVj9QWBoOrxbbtg+7q2DLcBUeona5tPeajRwWZfoBejzcbcl6l9ieUA9jTGX1NFlzsxzND9APVc9yD+XUm+GA8RYz5HKSBej0VAQ3g2zvBTLNAoV98DX+x8Dg8A= Received: from MN2PR18MB3408.namprd18.prod.outlook.com (10.255.238.217) by MN2PR18MB3197.namprd18.prod.outlook.com (10.255.236.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2008.13; Mon, 24 Jun 2019 15:09:09 +0000 Received: from MN2PR18MB3408.namprd18.prod.outlook.com ([fe80::d3:794c:1b94:cf3]) by MN2PR18MB3408.namprd18.prod.outlook.com ([fe80::d3:794c:1b94:cf3%4]) with mapi id 15.20.2008.014; Mon, 24 Jun 2019 15:09:09 +0000 From: Robert Richter To: Borislav Petkov , James Morse , "Mauro Carvalho Chehab" CC: "linux-edac@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Robert Richter Subject: [PATCH v2 07/24] EDAC: Kill EDAC_DIMM_OFF() macro Thread-Topic: [PATCH v2 07/24] EDAC: Kill EDAC_DIMM_OFF() macro Thread-Index: AQHVKp7Fo1m2H4puVkaf5rh/3X0l2A== Date: Mon, 24 Jun 2019 15:09:09 +0000 Message-ID: <20190624150758.6695-8-rrichter@marvell.com> References: <20190624150758.6695-1-rrichter@marvell.com> In-Reply-To: <20190624150758.6695-1-rrichter@marvell.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1P190CA0035.EURP190.PROD.OUTLOOK.COM (2603:10a6:7:52::24) To MN2PR18MB3408.namprd18.prod.outlook.com (2603:10b6:208:16c::25) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-originating-ip: [92.254.182.202] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: f70a0cf3-f19d-41f5-4679-08d6f8b5e7ed x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:MN2PR18MB3197; x-ms-traffictypediagnostic: MN2PR18MB3197: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5797; x-forefront-prvs: 007814487B x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(366004)(136003)(396003)(346002)(376002)(199004)(189003)(36756003)(110136005)(107886003)(54906003)(81156014)(81166006)(68736007)(8676002)(25786009)(5660300002)(8936002)(305945005)(7736002)(4326008)(1076003)(186003)(6116002)(14454004)(476003)(486006)(2616005)(11346002)(256004)(14444005)(446003)(3846002)(50226002)(26005)(2906002)(52116002)(76176011)(71200400001)(71190400001)(99286004)(386003)(6506007)(102836004)(478600001)(316002)(86362001)(6512007)(66066001)(53936002)(6486002)(73956011)(66946007)(66476007)(66556008)(64756008)(66446008)(6436002); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR18MB3197; H:MN2PR18MB3408.namprd18.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: marvell.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: oSCVQIkoSnlySzEazvoh8ZzQo39H2STsk+PJLkhHxNchehmLbvwqmXZHmZ0qG/DTvxo0T1bM1I0+hzs1/abfrS6NX8cM5O6OMmHjV/u2FVH+g/n6Cgrlh2XGd6FJ/emNFPoLp77B2amgbPwooX1E4XlK/qulOTse8MP00WMlBIBPVEImtQyO49r+7RVERcFWLbhWnL9/RDdE4D3PedqNXEwPQwz2RUvvWK1LpMl4AISof+B9pGePzSaSYDf6E7mAqftr+8FWvC4KwTs18//EhpWfczeCvXIhSBdoY3w2CzDwOBTUGUVBhz4zlCkKQsZxGkq27b+j70ywtdR+b4f8txnOrhqSFi2o3haE8Ok5Pgrp9Ys/DLpbKUZTWQDd2T2IVIEBtthQW4IO9nhd1yhhq633m1JcJVg6tVUfbIVrvaU= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: f70a0cf3-f19d-41f5-4679-08d6f8b5e7ed X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Jun 2019 15:09:09.0505 (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: rrichter@marvell.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR18MB3197 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-06-24_10:, , signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We do not need to calculate the offset in the mc's dimm array, let's just store the index in struct dimm_info and we can get rid of this macro. Signed-off-by: Robert Richter --- drivers/edac/edac_mc.c | 13 ++++-------- drivers/edac/edac_mc_sysfs.c | 20 ++++-------------- include/linux/edac.h | 41 ------------------------------------ 3 files changed, 8 insertions(+), 66 deletions(-) -- 2.20.1 diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c index c959e8b1643c..c44bc83e8502 100644 --- a/drivers/edac/edac_mc.c +++ b/drivers/edac/edac_mc.c @@ -318,7 +318,7 @@ struct mem_ctl_info *edac_mc_alloc(unsigned mc_num, unsigned size, tot_dimms = 1, count = 1; unsigned tot_csrows = 1, tot_channels = 1, tot_errcount = 0; void *pvt, *p, *ptr = NULL; - int i, j, row, chn, n, len, off; + int idx, i, j, row, chn, n, len; bool per_rank = false; BUG_ON(n_layers > EDAC_MAX_LAYERS || n_layers == 0); @@ -426,20 +426,15 @@ struct mem_ctl_info *edac_mc_alloc(unsigned mc_num, memset(&pos, 0, sizeof(pos)); row = 0; chn = 0; - for (i = 0; i < tot_dimms; i++) { + for (idx = 0; idx < tot_dimms; idx++) { chan = mci->csrows[row]->channels[chn]; - off = EDAC_DIMM_OFF(layer, n_layers, pos[0], pos[1], pos[2]); - if (off < 0 || off >= tot_dimms) { - edac_mc_printk(mci, KERN_ERR, "EDAC core bug: EDAC_DIMM_OFF is trying to do an illegal data access\n"); - goto error; - } dimm = kzalloc(sizeof(**mci->dimms), GFP_KERNEL); if (!dimm) goto error; - mci->dimms[off] = dimm; + mci->dimms[idx] = dimm; dimm->mci = mci; - dimm->idx = off; + dimm->idx = idx; /* * Copy DIMM location and initialize it. diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c index 29dd9719f82f..a69e99206a6f 100644 --- a/drivers/edac/edac_mc_sysfs.c +++ b/drivers/edac/edac_mc_sysfs.c @@ -559,14 +559,8 @@ static ssize_t dimmdev_ce_count_show(struct device *dev, { struct dimm_info *dimm = to_dimm(dev); u32 count; - int off; - - off = EDAC_DIMM_OFF(dimm->mci->layers, - dimm->mci->n_layers, - dimm->location[0], - dimm->location[1], - dimm->location[2]); - count = dimm->mci->ce_per_layer[dimm->mci->n_layers-1][off]; + + count = dimm->mci->ce_per_layer[dimm->mci->n_layers-1][dimm->idx]; return sprintf(data, "%u\n", count); } @@ -576,14 +570,8 @@ static ssize_t dimmdev_ue_count_show(struct device *dev, { struct dimm_info *dimm = to_dimm(dev); u32 count; - int off; - - off = EDAC_DIMM_OFF(dimm->mci->layers, - dimm->mci->n_layers, - dimm->location[0], - dimm->location[1], - dimm->location[2]); - count = dimm->mci->ue_per_layer[dimm->mci->n_layers-1][off]; + + count = dimm->mci->ue_per_layer[dimm->mci->n_layers-1][dimm->idx]; return sprintf(data, "%u\n", count); } diff --git a/include/linux/edac.h b/include/linux/edac.h index 1367a3fc544f..2ee9b8598ae0 100644 --- a/include/linux/edac.h +++ b/include/linux/edac.h @@ -362,47 +362,6 @@ struct edac_mc_layer { */ #define EDAC_MAX_LAYERS 3 -/** - * EDAC_DIMM_OFF - Macro responsible to get a pointer offset inside a pointer - * array for the element given by [layer0,layer1,layer2] - * position - * - * @layers: a struct edac_mc_layer array, describing how many elements - * were allocated for each layer - * @nlayers: Number of layers at the @layers array - * @layer0: layer0 position - * @layer1: layer1 position. Unused if n_layers < 2 - * @layer2: layer2 position. Unused if n_layers < 3 - * - * For 1 layer, this macro returns "var[layer0] - var"; - * - * For 2 layers, this macro is similar to allocate a bi-dimensional array - * and to return "var[layer0][layer1] - var"; - * - * For 3 layers, this macro is similar to allocate a tri-dimensional array - * and to return "var[layer0][layer1][layer2] - var". - * - * A loop could be used here to make it more generic, but, as we only have - * 3 layers, this is a little faster. - * - * By design, layers can never be 0 or more than 3. If that ever happens, - * a NULL is returned, causing an OOPS during the memory allocation routine, - * with would point to the developer that he's doing something wrong. - */ -#define EDAC_DIMM_OFF(layers, nlayers, layer0, layer1, layer2) ({ \ - int __i; \ - if ((nlayers) == 1) \ - __i = layer0; \ - else if ((nlayers) == 2) \ - __i = (layer1) + ((layers[1]).size * (layer0)); \ - else if ((nlayers) == 3) \ - __i = (layer2) + ((layers[2]).size * ((layer1) + \ - ((layers[1]).size * (layer0)))); \ - else \ - __i = -EINVAL; \ - __i; \ -}) - struct dimm_info { struct device dev;