From patchwork Wed May 29 08:44:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 165332 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp9579876ili; Wed, 29 May 2019 01:44:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqySVks0dnIo+JtFDdQ0Fwyg9tO3kr1FNZL4Kkrx7qHi6N3KrYlFZ52hctK4bwMbcMnPAb/E X-Received: by 2002:a17:902:f81:: with SMTP id 1mr90527496plz.242.1559119477737; Wed, 29 May 2019 01:44:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559119477; cv=none; d=google.com; s=arc-20160816; b=xOMmNdCacgrvB1yUzdI5j9gZKmh/CwpM+h2yc385mDzuEGxnTCyAamJRXHluPXV47d wAy5ymTHZfPUjXq5wxLjv08ZAklOYIUzoMTV3I4sU0BJ8UH1rRDkvMlCF0+ZDbHmr9y+ O/qc6VRFVhRkm94rNukqI962zgH3wKOscl1cQczS3dxC15k5gI3yT3T2P8JlQYcdPV2c OID2UIwjry+JfiYzUcOpPobZ0BF1sf7OBpZTBWMfklVEn6ql9kJardD1dhEnO6fPfH/w Z4gxXJz4a4y6MeUyafJNtS4BAZfCKOCqfWx8nZ5BWM8fOCSg4az/5snn0NQg4PB66GcP 1yAg== 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=aMNfwpkrfZlAQGOhWkeFqTQ7b5LUQt+8tswNsduhmqQ=; b=H1NaoEKaDRKG5TAB02mRUmG+tJHUEatg8+SoJw3LuOyimCAkC0YR9YmrLySfhSFsOa xTmO6xhzKFGwF1vtKH+hPYAUCbMeIl5ap0qAtN0FZir0Cl6p7hZsRPWD0ePZlpP6GfPQ oZs6hJisJn/bTWfyDsZQHGnamsipPZQrDKcCxf26NPkT/KrSv4igIsztpifKcbFlmnP0 bXrfCyasOfUOtVTdEWa/7ygNA4OlXc+b7EuO1CJp+gVorAyonteZjg8esQm3hVJhsWJr NAiC1xTZ7/IZxVSqCNre2IOc2M7PsYM8sk7xBsclZNpGiYmmZH2K7dc4vLel3E0LZAwS InCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0818 header.b=KIrs5vXX; dkim=pass header.i=@marvell.onmicrosoft.com header.s=selector2-marvell-onmicrosoft-com header.b=wioOTkbe; 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 s36si24801212pld.278.2019.05.29.01.44.37; Wed, 29 May 2019 01:44:37 -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=KIrs5vXX; dkim=pass header.i=@marvell.onmicrosoft.com header.s=selector2-marvell-onmicrosoft-com header.b=wioOTkbe; 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 S1726557AbfE2Iog (ORCPT + 30 others); Wed, 29 May 2019 04:44:36 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:49466 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726057AbfE2Io0 (ORCPT ); Wed, 29 May 2019 04:44:26 -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 x4T8do5C017769; Wed, 29 May 2019 01:44:18 -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=aMNfwpkrfZlAQGOhWkeFqTQ7b5LUQt+8tswNsduhmqQ=; b=KIrs5vXX7NrJfTP0c3HDpMKKFfhgCzmsapOntFDME2J7mZq9tJLqhl0RzKl+SgMf7Ner ibeHrruNa3thVnp/dZ3XQdSwel2tPpZz8N2UQkGLB72dkpef+wOM6AZ5ff3O1ZSIDOOY ggKxM08uEEYDHRprA/UhkOVyL7RDac5/qec3lWGgSG3jT8AXTD/YjMD3/IwyoASE9K4h Kui777PfSlgLphzBQKEyzmfBFA9In/3MckSwYk7w5dOAuVjxwmyuk3HsB8FN48jgdtVo /tAa1EOObDmGsUh5gw/EjgP88JGkpaDM4h51kbPByqdJrT768wtD0ZV8ROthSo+PZUaf 6g== Received: from sc-exch04.marvell.com ([199.233.58.184]) by mx0b-0016f401.pphosted.com with ESMTP id 2sskp88p49-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 29 May 2019 01:44:17 -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.1367.3; Wed, 29 May 2019 01:44:16 -0700 Received: from NAM03-CO1-obe.outbound.protection.outlook.com (104.47.40.54) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Wed, 29 May 2019 01:44:16 -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=aMNfwpkrfZlAQGOhWkeFqTQ7b5LUQt+8tswNsduhmqQ=; b=wioOTkbeE4MiLGChj8q5+gCSbDbX1HsgIWaUCthYiDHmjT/820myuomB4YeBaFjwdTroBaD5lClI7QcWzclgYf0WvrjbeViPGcTy9soa/MdJqcwedebSUDG3BMiPczGjEdzTdpGFqv1HP/6MGT1qt6SZdKR8OKR9hoMnKRnsJVM= Received: from MN2PR18MB3408.namprd18.prod.outlook.com (10.255.238.217) by MN2PR18MB3437.namprd18.prod.outlook.com (10.255.239.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1922.20; Wed, 29 May 2019 08:44:12 +0000 Received: from MN2PR18MB3408.namprd18.prod.outlook.com ([fe80::7c9a:f3bf:fe2e:fe4a]) by MN2PR18MB3408.namprd18.prod.outlook.com ([fe80::7c9a:f3bf:fe2e:fe4a%4]) with mapi id 15.20.1922.021; Wed, 29 May 2019 08:44:12 +0000 From: Robert Richter To: Borislav Petkov , Tony Luck , "James Morse" , Mauro Carvalho Chehab CC: "linux-edac@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Robert Richter Subject: [PATCH 04/21] EDAC: Kill EDAC_DIMM_OFF() macro Thread-Topic: [PATCH 04/21] EDAC: Kill EDAC_DIMM_OFF() macro Thread-Index: AQHVFfqwIhFAZb80vEOV8UDI5b72FA== Date: Wed, 29 May 2019 08:44:12 +0000 Message-ID: <20190529084344.28562-5-rrichter@marvell.com> References: <20190529084344.28562-1-rrichter@marvell.com> In-Reply-To: <20190529084344.28562-1-rrichter@marvell.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM6PR01CA0046.eurprd01.prod.exchangelabs.com (2603:10a6:20b:e0::23) 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: [78.54.13.57] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: b27cfab3-a333-4011-5f1c-08d6e411d2fa x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:MN2PR18MB3437; x-ms-traffictypediagnostic: MN2PR18MB3437: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5797; x-forefront-prvs: 0052308DC6 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(346002)(396003)(376002)(39860400002)(136003)(189003)(199004)(8936002)(4326008)(53936002)(50226002)(110136005)(107886003)(68736007)(36756003)(5660300002)(54906003)(11346002)(26005)(186003)(52116002)(2906002)(2616005)(476003)(446003)(6506007)(14454004)(66476007)(25786009)(478600001)(386003)(86362001)(486006)(81166006)(81156014)(8676002)(305945005)(316002)(7736002)(14444005)(256004)(99286004)(76176011)(6512007)(6436002)(73956011)(64756008)(66446008)(66556008)(66066001)(3846002)(66946007)(1076003)(6486002)(102836004)(71190400001)(71200400001)(6116002); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR18MB3437; H:MN2PR18MB3408.namprd18.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: VFBK6KvWCj4o7Hi09AsGc6wEZmq7hf2G9oU1EKldWCnsAYa9lDJGecikawtuQL9zdiwPHFL8j02Fiiuel9GLJB7PCdA1Sl1so3go1Ie+T/J8qitreG9yPTTUvb3DHaksS5+jaPtULevJv/WQN+aYUCQ7OR1mk+eq/bbqadyuUlT22j+c11qcH3xqqe9sgZMS/Wo023Vm5WGeoBssJWdeL1uW2sYDOqvdjWNRA29z1PbzxMRB6jk7g+zPz3CBaJLh+6FTxqSJkcfPBkv6dOc0HLYqUSUa0csR9yqRMnT8ci5sP1QPLLaShwpXDRB4FOL+QinHpFYn25M8Cdum9O3c9X/T5P4okvdcMjN7ukoSEUQ5fo9I8Dy0V7zUQCzE+s5hmB3h0k1SthDdntpYKBRKoBC0SPfUfSj1cA6od2lmkDw= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: b27cfab3-a333-4011-5f1c-08d6e411d2fa X-MS-Exchange-CrossTenant-originalarrivaltime: 29 May 2019 08:44:12.7436 (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: MN2PR18MB3437 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-05-29_05:, , 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 5f565e5949b3..07edbd80af07 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 dbef699162a8..8beefa699a49 100644 --- a/drivers/edac/edac_mc_sysfs.c +++ b/drivers/edac/edac_mc_sysfs.c @@ -558,14 +558,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); } @@ -575,14 +569,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;