From patchwork Mon Jun 24 15:09:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 167618 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp4348525ilk; Mon, 24 Jun 2019 08:10:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqweGtoop674+HMJ6xJL+ulVt3W/sGH1swAvfV9ietwZlebmQFZ4OWGRw6hD5WcaZLFExXTf X-Received: by 2002:a17:902:f216:: with SMTP id gn22mr129368709plb.118.1561389013546; Mon, 24 Jun 2019 08:10:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561389013; cv=none; d=google.com; s=arc-20160816; b=vzSzLdbIcmZi4gKoC9J+Gh/eYAyQj1yOjorm14g+xkzEKqEtr5ZXSPZSxHgRyyNmY7 IPuu05eYuGuulsjrGat+Yg+cpPVxIz9YDkhlGDf+gqaKBOl2jaq+G3qankBLfjofff4L oOuG93oac4nwxP6iB7jrEUJAUzuZoZ+oYamY8qPMAfAp5m97+ptrlgy6ytHibLe4m5cC e7C6o4ftyFMG+FUv5oZ83VcxQLIRWvJaT5Erim6S4tZg8Kn5XM8kclor2X3fl27WEBxO rXNssrBRY4+t1IYPQhv476nc01VN7B3GKAmEffBuH4Ed4xjEjS98q71k0rHVOmp7nnwt puEg== 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=9p112X5vlP5tM0VhbyYF8Z0EJbyNYhiz5vn1s8E3Loo=; b=uzJ5mcZyZmPAyLKbQNk4oqzTgPSRbbAdlBFFbh6XQl5dCx4XEGVjPvac9f+YlvJLNt cuJSzUmHvkNolc98kSClk6/t3+B1pyDDbDjit4dXVo/mcwVM3uqKm9s7yeKVXq1Bp09b 51Mnb2Ug3OPiCpjDX70uUsYOF0Mtd8DUZiRauFJj933KjqkkWa39pLfKOXISUvkWUSw0 ZzCBYFBU5zf3DMNHYvMpPuhOW/ooxCjGG0ui9iWq4Bn1HvhmlUSOmC6hZmGa7Lzkze51 +7VBgG9WHmgIlPAnk+r3gvHGBiAoCW9bCZbjlghEJFE87Jh/XgIZEUcmioULXjNlgYtz Bybw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0818 header.b=pDf1lpmL; dkim=pass header.i=@marvell.onmicrosoft.com header.s=selector2-marvell-onmicrosoft-com header.b=djqqRsjd; 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 q17si10036322pll.285.2019.06.24.08.10.12; Mon, 24 Jun 2019 08:10:13 -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=pDf1lpmL; dkim=pass header.i=@marvell.onmicrosoft.com header.s=selector2-marvell-onmicrosoft-com header.b=djqqRsjd; 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 S1731009AbfFXPKL (ORCPT + 30 others); Mon, 24 Jun 2019 11:10:11 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:51100 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730741AbfFXPJm (ORCPT ); Mon, 24 Jun 2019 11:09:42 -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 x5OF8Chr025865; Mon, 24 Jun 2019 08:09:37 -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=9p112X5vlP5tM0VhbyYF8Z0EJbyNYhiz5vn1s8E3Loo=; b=pDf1lpmLe+6rWNvk1OROhCjMH62NX6DIMK5aOrVy89578R8rT46e6BLoSRKh5IgJ9Srt C3djJHqkdqZ6Y/pgsyzqNOY9AwujdlaRkb6GJmaloDhP4pV699hABUwq+PGSKXIhQ7mB EZy7qGUgelt6HpnQh3bqa4YGKEEYf+oyH91jc0yUsE04cPryebJmp9vZHEwH0IH1tTB1 iE0rfnJZ16KyluhGSpLlSJVZk+X8qSgmjL39y4tGwQGnLMFoslQRTibRgSJbevOEMp54 3wt4mj6OxWf2e6oMW5hKCwT7qOJw9guuUEkqDXoOvMzqieESUeLpDbK+a27otnrPPEzj WQ== Received: from sc-exch04.marvell.com ([199.233.58.184]) by mx0b-0016f401.pphosted.com with ESMTP id 2t9kujf7u3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 24 Jun 2019 08:09:36 -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; Mon, 24 Jun 2019 08:09:35 -0700 Received: from NAM03-BY2-obe.outbound.protection.outlook.com (104.47.42.54) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Mon, 24 Jun 2019 08:09:35 -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=9p112X5vlP5tM0VhbyYF8Z0EJbyNYhiz5vn1s8E3Loo=; b=djqqRsjd7y3lER55mqP4QWzUpr9J4dSPfMg1BLiBOe8Yb+CB/U5hHGnm6G5fQpi9HiwQSwhcQV9aao9IoGz8GschdmHyL8GsQlmV+BQca2yH5jz/vSuXq7Dts07dHfPlvS9dMrZwP52Jkh9Lkzl0SS/Ql4OiitzaysIdOij+qeA= Received: from MN2PR18MB3408.namprd18.prod.outlook.com (10.255.238.217) by MN2PR18MB2589.namprd18.prod.outlook.com (20.179.82.96) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2008.16; Mon, 24 Jun 2019 15:09:34 +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:34 +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 19/24] EDAC, mc: Introduce edac_mc_alloc_by_dimm() for per dimm allocation Thread-Topic: [PATCH v2 19/24] EDAC, mc: Introduce edac_mc_alloc_by_dimm() for per dimm allocation Thread-Index: AQHVKp7UctlFYfkY5E6kkBd7Mn0FtQ== Date: Mon, 24 Jun 2019 15:09:33 +0000 Message-ID: <20190624150758.6695-20-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: b66c438e-07ad-4954-e3da-08d6f8b5f70d x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:MN2PR18MB2589; x-ms-traffictypediagnostic: MN2PR18MB2589: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4502; x-forefront-prvs: 007814487B x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(39860400002)(346002)(376002)(366004)(136003)(189003)(199004)(2906002)(2616005)(486006)(476003)(52116002)(14444005)(256004)(5660300002)(66446008)(73956011)(66946007)(1076003)(14454004)(6116002)(86362001)(3846002)(99286004)(6486002)(68736007)(81166006)(81156014)(6436002)(4326008)(305945005)(50226002)(53936002)(7736002)(8676002)(8936002)(478600001)(64756008)(66556008)(66476007)(6512007)(107886003)(71190400001)(71200400001)(36756003)(26005)(102836004)(386003)(186003)(11346002)(76176011)(6506007)(110136005)(316002)(54906003)(446003)(25786009)(66066001); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR18MB2589; 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: 4qlKn9DnbpIHx+bdG+86QbFKBdcQLvGZHupBT8CTbcISGaRXqPUgrmbeNlwgcOsb4Aanqm8OasMxHSMkBzX5/OtEjRZYI31Njs337mzgpdPkjASNlIO1x2wJrKqAmba1y68Ghd09rV7TZSJ7DkJ6n+STWZ6XQF+YorpGNgn0oi/O++6TRoy7y79SKTtc3BFLJWobQTQP5dvDn+XIQtvLDlU61ZCFAIf7A/grpOL6E+SaTduEHy9l4Ym7xuP35+hNQl+/i8Cmav4DdJxc0SsCyAbUTfudcJhpMI8ZkIyX3jxs/HW0yKFeoVsGXD+yqIQFGoZ2dHgjjkL1gfGmznBdXc/V6W/3kvYdoAtnK4ufFRHlCtq5NbDulhQ54yYeDSMczlOE6bkVMl6pp27PnDrHOzzMoFGwAS4Qm6DwFh+gaMQ= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: b66c438e-07ad-4954-e3da-08d6f8b5f70d X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Jun 2019 15:09:34.0783 (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: MN2PR18MB2589 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 Systems using ACPI GHES for error detection do not have exact knowledge of the memory hierarchy. Compared to other memory controller drivers the total size of each layer is unknown (card/module, channel/slot, etc.). But there is the total number of dimms. So add a function to allocate an mc device this way. The edac's driver uses internally a dimm index already for data access. Signed-off-by: Robert Richter --- drivers/edac/edac_mc.c | 83 ++++++++++++++++++++++++++++------------ drivers/edac/edac_mc.h | 17 ++++++-- drivers/edac/ghes_edac.c | 7 ++-- 3 files changed, 76 insertions(+), 31 deletions(-) -- 2.20.1 diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c index eea09c6acd3e..3a40496a1973 100644 --- a/drivers/edac/edac_mc.c +++ b/drivers/edac/edac_mc.c @@ -303,10 +303,11 @@ static void _edac_mc_free(struct mem_ctl_info *mci) kfree(mci); } -struct mem_ctl_info *edac_mc_alloc(unsigned mc_num, - unsigned n_layers, - struct edac_mc_layer *layers, - unsigned sz_pvt) +struct mem_ctl_info *__edac_mc_alloc(unsigned mc_num, + unsigned dimm_num, + unsigned n_layers, + struct edac_mc_layer *layers, + unsigned sz_pvt) { struct mem_ctl_info *mci; struct edac_mc_layer *layer; @@ -321,6 +322,7 @@ struct mem_ctl_info *edac_mc_alloc(unsigned mc_num, bool per_rank = false; BUG_ON(n_layers > EDAC_MAX_LAYERS || n_layers == 0); + /* * Calculate the total amount of dimms and csrows/cschannels while * in the old API emulation mode @@ -336,6 +338,26 @@ struct mem_ctl_info *edac_mc_alloc(unsigned mc_num, per_rank = true; } + /* allocate dimm_num DIMMS, layer size must be zero */ + if (dimm_num) { + if (dimm_num <= 0 || + layers[0].size || + (n_layers > 1 && layers[1].size) || + (n_layers > 2 && layers[2].size)) { + edac_printk(KERN_WARNING, EDAC_MC, + "invalid layer data\n"); + return NULL; + } + + /* + * Assume 1 csrow per dimm which also means 1 channel + * per csrow. + */ + tot_dimms = dimm_num; + tot_csrows = dimm_num; + tot_channels = 1; + } + /* Figure out the offsets of the various items from the start of an mc * structure. We want the alignment of each item to be at least as * stringent as what the compiler would provide if we could simply @@ -422,25 +444,10 @@ struct mem_ctl_info *edac_mc_alloc(unsigned mc_num, dimm->mci = mci; dimm->idx = idx; - /* - * Copy DIMM location and initialize it. - */ - len = sizeof(dimm->label); - p = dimm->label; - n = snprintf(p, len, "mc#%u", mc_num); - p += n; - len -= n; - for (j = 0; j < n_layers; j++) { - n = snprintf(p, len, "%s#%u", - edac_layer_name[layers[j].type], - pos[j]); - p += n; - len -= n; - dimm->location[j] = pos[j]; - - if (len <= 0) - break; - } + /* unknown location */ + dimm->location[0] = -1; + dimm->location[1] = -1; + dimm->location[2] = -1; /* Link it to the csrows old API data */ chan->dimm = dimm; @@ -462,6 +469,34 @@ struct mem_ctl_info *edac_mc_alloc(unsigned mc_num, } } + /* + * Copy DIMM location and initialize it. + */ + len = sizeof(dimm->label); + p = dimm->label; + n = snprintf(p, len, "mc#%u", mc_num); + p += n; + len -= n; + + if (dimm_num) { + n = snprintf(p, len, "dimm#%u", idx); + p += n; + len -= n; + continue; + } + + for (j = 0; j < n_layers; j++) { + n = snprintf(p, len, "%s#%u", + edac_layer_name[layers[j].type], + pos[j]); + p += n; + len -= n; + dimm->location[j] = pos[j]; + + if (len <= 0) + break; + } + /* Increment dimm location */ for (j = n_layers - 1; j >= 0; j--) { pos[j]++; @@ -480,7 +515,7 @@ struct mem_ctl_info *edac_mc_alloc(unsigned mc_num, return NULL; } -EXPORT_SYMBOL_GPL(edac_mc_alloc); +EXPORT_SYMBOL_GPL(__edac_mc_alloc); void edac_mc_free(struct mem_ctl_info *mci) { diff --git a/drivers/edac/edac_mc.h b/drivers/edac/edac_mc.h index c4ddd5c1e24c..e8215847f853 100644 --- a/drivers/edac/edac_mc.h +++ b/drivers/edac/edac_mc.h @@ -99,6 +99,10 @@ do { \ * edac_mc_alloc() - Allocate and partially fill a struct &mem_ctl_info. * * @mc_num: Memory controller number + * @dimm_num: Number of DIMMs to allocate. If non-zero the + * @layers' size parameter must be zero. Useful + * if the MC hierarchy is unknown but the number + * of DIMMs is known. * @n_layers: Number of MC hierarchy layers * @layers: Describes each layer as seen by the Memory Controller * @sz_pvt: size of private storage needed @@ -122,10 +126,15 @@ do { \ * On success, return a pointer to struct mem_ctl_info pointer; * %NULL otherwise */ -struct mem_ctl_info *edac_mc_alloc(unsigned mc_num, - unsigned n_layers, - struct edac_mc_layer *layers, - unsigned sz_pvt); +struct mem_ctl_info *__edac_mc_alloc(unsigned mc_num, + unsigned dimm_num, + unsigned n_layers, + struct edac_mc_layer *layers, + unsigned sz_pvt); +#define edac_mc_alloc(mc_num, n_layers, layers, sz_pvt) \ + __edac_mc_alloc(mc_num, 0, n_layers, layers, sz_pvt) +#define edac_mc_alloc_by_dimm(mc_num, dimm_num, n_layers, layers, sz_pvt) \ + __edac_mc_alloc(mc_num, dimm_num, n_layers, layers, sz_pvt) /** * edac_get_owner - Return the owner's mod_name of EDAC MC diff --git a/drivers/edac/ghes_edac.c b/drivers/edac/ghes_edac.c index 9c3495f7365b..97f992006281 100644 --- a/drivers/edac/ghes_edac.c +++ b/drivers/edac/ghes_edac.c @@ -702,11 +702,12 @@ ghes_edac_register_one(int nid, struct ghes *ghes, struct device *parent) struct edac_mc_layer layers[1]; layers[0].type = EDAC_MC_LAYER_ALL_MEM; - layers[0].size = mem_info.dimms_per_node[nid]; + layers[0].size = 0; layers[0].is_virt_csrow = true; - mci = edac_mc_alloc(nid, ARRAY_SIZE(layers), layers, - sizeof(struct ghes_edac_pvt)); + mci = edac_mc_alloc_by_dimm(nid, mem_info.dimms_per_node[nid], + ARRAY_SIZE(layers), layers, + sizeof(struct ghes_edac_pvt)); if (!mci) { pr_err("Can't allocate memory for EDAC data\n"); return -ENOMEM;