From patchwork Wed Nov 6 01:24:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 11229103 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 C66BA1986 for ; Wed, 6 Nov 2019 01:25:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8A1A42245C for ; Wed, 6 Nov 2019 01:25:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="MfW3qRK8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730687AbfKFBZE (ORCPT ); Tue, 5 Nov 2019 20:25:04 -0500 Received: from mail-eopbgr820079.outbound.protection.outlook.com ([40.107.82.79]:36833 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730054AbfKFBZE (ORCPT ); Tue, 5 Nov 2019 20:25:04 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QEZ0eTi/sEk4Vg3r2hQc4IuMZlgHT+pdEsq1Lvl9bdi2ex/TG/e48HP/PtTY8jGVZtzqVptKVeCfRwNFQnDxVOSg0DqLowVVI8Q/twWQNzJ7+OsT5mmCdQi2o3YCx+Ktdn9t0VDrYjPiBvA0mm+G6DNG2IZauu0Jp1xeps94qba8OMTNFak3rMrnxSmWe5xwNiBRC1INfqiKDS8MexPKAHE6SIgqASKplT8I0gqX8DJbxCe1Saa7Gf9iQ3DRm28rvQFU70jiN4szXe7o10QdgqvWnA53j/o46LjzITNXFGQu5ekrsNvB62ARK6f5Ep5ZDqt8rL2+lPCU3hud/UlYoA== 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=iHERqkCl4oWJ5edRkO+YBZo8QaAqpmfQq7g/2YRQIx0=; b=HYkGTGttWUfRTH6t3qpdukn4+/FUzMeBiZxqYNDcxzt5Ey18MJuP5Q4nWSY43ICcGZF/PcnbEPUxZf5ClgAaGSsJLnEks8PIpHopXeWfGm2W/p6Rp9+3hyRvgfn7JSAZSMqQzh0R+zBmm/nzHHd0w1aIwQO8TFVYWgTd6wM/jSV1ZvXx3RTtab7UiKdtiCmmKv6fZ6axtMPrvT2k9Uj+nyOwrVIYiTwQkNLJrSbzYivv3OW+D+K3AOIG2Yx0TrNJdfOaE9yCPevmF7ml3jSfGij7lzdodI/sXJGjZaTYFZykJHcB3VUFN9s0FTtAaIxe45kaO2GtU7lwZXtDRkVIbA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iHERqkCl4oWJ5edRkO+YBZo8QaAqpmfQq7g/2YRQIx0=; b=MfW3qRK8Qh4amsR+AmkRkuk+pAL+5KE81hn5HJjcvO1Go2rvgOl1fwncvf5GI0HXHo/HfTSRsp1aYGjVCw/VoP44BvNJlqbIBqzY0LolNAPvWUNSn5zj5wk9aHLQTJLR7WUH3CxKOxcPeNlgcH/ZT8kESF8P/zlaeEqvbsmqsR4= Received: from SN6PR12MB2639.namprd12.prod.outlook.com (52.135.103.16) by SN6PR12MB2783.namprd12.prod.outlook.com (52.135.107.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2408.24; Wed, 6 Nov 2019 01:24:59 +0000 Received: from SN6PR12MB2639.namprd12.prod.outlook.com ([fe80::2819:e697:4314:56ba]) by SN6PR12MB2639.namprd12.prod.outlook.com ([fe80::2819:e697:4314:56ba%3]) with mapi id 15.20.2408.024; Wed, 6 Nov 2019 01:24:59 +0000 From: "Ghannam, Yazen" To: "linux-edac@vger.kernel.org" CC: "Ghannam, Yazen" , "linux-kernel@vger.kernel.org" , "bp@alien8.de" Subject: [PATCH v3 1/5] EDAC/amd64: Make struct amd64_family_type global Thread-Topic: [PATCH v3 1/5] EDAC/amd64: Make struct amd64_family_type global Thread-Index: AQHVlEEBJDivVc3XwEWsaKCwbdqNsQ== Date: Wed, 6 Nov 2019 01:24:59 +0000 Message-ID: <20191106012448.243970-2-Yazen.Ghannam@amd.com> References: <20191106012448.243970-1-Yazen.Ghannam@amd.com> In-Reply-To: <20191106012448.243970-1-Yazen.Ghannam@amd.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: SN1PR12CA0064.namprd12.prod.outlook.com (2603:10b6:802:20::35) To SN6PR12MB2639.namprd12.prod.outlook.com (2603:10b6:805:6f::16) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Yazen.Ghannam@amd.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-originating-ip: [165.204.78.2] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 86458a82-ac4a-43d9-4f56-08d7625823d8 x-ms-traffictypediagnostic: SN6PR12MB2783: x-ms-exchange-purlcount: 1 x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2733; x-forefront-prvs: 02135EB356 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(4636009)(376002)(366004)(396003)(346002)(39860400002)(136003)(189003)(199004)(186003)(5660300002)(86362001)(386003)(4326008)(102836004)(6506007)(1076003)(52116002)(966005)(6306002)(2906002)(5640700003)(99286004)(6116002)(36756003)(54906003)(14454004)(25786009)(486006)(66556008)(446003)(11346002)(81156014)(6916009)(76176011)(305945005)(7736002)(26005)(6512007)(2616005)(66066001)(2501003)(66946007)(316002)(64756008)(478600001)(50226002)(71190400001)(71200400001)(81166006)(8676002)(256004)(2351001)(8936002)(6436002)(476003)(6486002)(66446008)(66476007)(3846002);DIR:OUT;SFP:1101;SCL:1;SRVR:SN6PR12MB2783;H:SN6PR12MB2639.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 5uTfBlvGrkTGh/pIBKSiTnNjm/v1XTyCVjwrYVN2ZfIoj4cNKk3/N9DWGj1GrQPeghj1ayTEEgp78AAH75cV564he+Yi+Q/CZ8khPqJ60bCwkMh6ynph0KYUQ5Dqz6KAKcybTeaods6tyG7dBXzhtGGLgAwsn92tVksYKmw6rJXWjCF5Hh4m+0v7i0hTX8YmAm67IqdvJCbbR0n3AJu/81TUfDcn1kx2ZLd7RPVDzyKDVJXa8HQxr4d6gPWmiL5kiOvft274818zdwjpT52yRB0Oy5HBTcDkkCVhmdvDuew2YSyhSzz1SIw+fvHfUsheiV977+r6VK0JzZm7thC8p8FZ25YxkL7KqaciA4Zq0K74/vrD4vwdtgK/6ApxqA73rlzqBZEbeb6s7w1LxG++ol+z750SJfFRO/+k7e36OSe43CBhDMQC/8rKwRR9AAEpjsi96pRc03ytDAvfW4bT+ePTxQJMFJdDMJz1Tv8UC+w= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 86458a82-ac4a-43d9-4f56-08d7625823d8 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Nov 2019 01:24:59.6705 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: M3HTRXLVtxyzRhvzBuGdzbtDOpg8HuUyU1r6QjOwYNDXB5jQiFhZONJi6WAlLesNivlzuHm8gbl0l/csJ+Uz2Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2783 Sender: linux-edac-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org From: Yazen Ghannam The struct amd64_family_type doesn't change between multiple nodes and instances of the modules, so make it global. Signed-off-by: Yazen Ghannam --- Link: https://lkml.kernel.org/r/20191022203448.13962-2-Yazen.Ghannam@amd.com v2 -> v3: * No change. v1 -> v2: * No change. rfc -> v1: * New patch based on suggestion from Boris. drivers/edac/amd64_edac.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c index cc5e56d752c8..83c659e38084 100644 --- a/drivers/edac/amd64_edac.c +++ b/drivers/edac/amd64_edac.c @@ -16,6 +16,8 @@ module_param(ecc_enable_override, int, 0644); static struct msr __percpu *msrs; +static struct amd64_family_type *fam_type; + /* Per-node stuff */ static struct ecc_settings **ecc_stngs; @@ -3280,8 +3282,7 @@ f17h_determine_edac_ctl_cap(struct mem_ctl_info *mci, struct amd64_pvt *pvt) } } -static void setup_mci_misc_attrs(struct mem_ctl_info *mci, - struct amd64_family_type *fam) +static void setup_mci_misc_attrs(struct mem_ctl_info *mci) { struct amd64_pvt *pvt = mci->pvt_info; @@ -3300,7 +3301,7 @@ static void setup_mci_misc_attrs(struct mem_ctl_info *mci, mci->edac_cap = determine_edac_cap(pvt); mci->mod_name = EDAC_MOD_STR; - mci->ctl_name = fam->ctl_name; + mci->ctl_name = fam_type->ctl_name; mci->dev_name = pci_name(pvt->F3); mci->ctl_page_to_phys = NULL; @@ -3314,8 +3315,6 @@ static void setup_mci_misc_attrs(struct mem_ctl_info *mci, */ static struct amd64_family_type *per_family_init(struct amd64_pvt *pvt) { - struct amd64_family_type *fam_type = NULL; - pvt->ext_model = boot_cpu_data.x86_model >> 4; pvt->stepping = boot_cpu_data.x86_stepping; pvt->model = boot_cpu_data.x86_model; @@ -3422,7 +3421,6 @@ static void compute_num_umcs(void) static int init_one_instance(unsigned int nid) { struct pci_dev *F3 = node_to_amd_nb(nid)->misc; - struct amd64_family_type *fam_type = NULL; struct mem_ctl_info *mci = NULL; struct edac_mc_layer layers[2]; struct amd64_pvt *pvt = NULL; @@ -3499,7 +3497,7 @@ static int init_one_instance(unsigned int nid) mci->pvt_info = pvt; mci->pdev = &pvt->F3->dev; - setup_mci_misc_attrs(mci, fam_type); + setup_mci_misc_attrs(mci); if (init_csrows(mci)) mci->edac_cap = EDAC_FLAG_NONE; From patchwork Wed Nov 6 01:25:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 11229099 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 D5EE0112B for ; Wed, 6 Nov 2019 01:25:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8E42A2247A for ; Wed, 6 Nov 2019 01:25:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="4RzGRfdm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730743AbfKFBZG (ORCPT ); Tue, 5 Nov 2019 20:25:06 -0500 Received: from mail-eopbgr820079.outbound.protection.outlook.com ([40.107.82.79]:36833 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729614AbfKFBZF (ORCPT ); Tue, 5 Nov 2019 20:25:05 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gzzbLaKTh/1tAFCEEXbaKBY1lInBHbpss/8Bvm4PA94m80KHZPerCV4lNQk7WL7wVb+n39rpf7sxv8hWYCjSDer8O/svz3V8O61vQBPjuieHDwT68sjY67H04A37gnpiFYPeCHFpp96vRMyTA6AUt5BDglfwc6+lLPL+niDcNAeW4BHJsjW7bVZymlas/tLNpidUOPTj+R9U/xcFHy01uZh4bQjRdYl0fPbetfOuamHdmzecCAihWrDrGoNC9NC00hS3a3T3+Zb0LSF8J0EnvcNvipaGpSjweiVJpHszCfq3J9bVpfBAeoV4CQIKcmV9V2jrNmxaQ7+FRZ62RjAnUQ== 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=cTUIlgKvu96fUXRcN9kCejWE/AP4ehwwz3pi+3/k1gY=; b=gTXBBmjdTwzijwhNJk5356CyBkz7ZqW83Q1xL945u/hepaSAdAaqrPoVgbMAGlc/Zx/A+mBqHmzyfE1v0HXJCUqM++9/9wtEiP/ptYtmZWMddWyDXpzI+QYHIPQH50XhsBirM8y6J6fbhzofTQ0/bRQvVzqQn26rWnSBJABO0EDSSSwsBqOUBk+khQ6GRprF/ItzdZxt8FqONh6SpCrMrafCVBczbc4vTYkyxGUqannYlObwdxYMcDsaanLv813z8bN9PYTTONno1f07trN+c4/LOOGKMjg1IS+swzIZ8y78kO+Y4MrxbrQMBIKsjo0nl5sAE0qR6jOR3fvvK9tpSw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cTUIlgKvu96fUXRcN9kCejWE/AP4ehwwz3pi+3/k1gY=; b=4RzGRfdmwlZ/bUoNqvjQj3sS02NW6sb6hBU00vqxmBH8m6zbFPZJsF5P2FzkGZjJcD9wmmcJ5HOsarF+ubzI7NuWnp3tok1cklmoAm7tFlx267ldbDlFB7AO8M8ryrfgaUncyQF1NBwFOH73bsi74Yo8EAcjkdbSFh2/DZReqvE= Received: from SN6PR12MB2639.namprd12.prod.outlook.com (52.135.103.16) by SN6PR12MB2783.namprd12.prod.outlook.com (52.135.107.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2408.24; Wed, 6 Nov 2019 01:25:00 +0000 Received: from SN6PR12MB2639.namprd12.prod.outlook.com ([fe80::2819:e697:4314:56ba]) by SN6PR12MB2639.namprd12.prod.outlook.com ([fe80::2819:e697:4314:56ba%3]) with mapi id 15.20.2408.024; Wed, 6 Nov 2019 01:25:00 +0000 From: "Ghannam, Yazen" To: "linux-edac@vger.kernel.org" CC: "Ghannam, Yazen" , "linux-kernel@vger.kernel.org" , "bp@alien8.de" Subject: [PATCH v3 2/5] EDAC/amd64: Gather hardware information early Thread-Topic: [PATCH v3 2/5] EDAC/amd64: Gather hardware information early Thread-Index: AQHVlEEBohvFV9eryESXXaIu8+8MoQ== Date: Wed, 6 Nov 2019 01:25:00 +0000 Message-ID: <20191106012448.243970-3-Yazen.Ghannam@amd.com> References: <20191106012448.243970-1-Yazen.Ghannam@amd.com> In-Reply-To: <20191106012448.243970-1-Yazen.Ghannam@amd.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: SN1PR12CA0064.namprd12.prod.outlook.com (2603:10b6:802:20::35) To SN6PR12MB2639.namprd12.prod.outlook.com (2603:10b6:805:6f::16) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Yazen.Ghannam@amd.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-originating-ip: [165.204.78.2] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 86d8486e-fa01-45c0-a7ee-08d76258243c x-ms-traffictypediagnostic: SN6PR12MB2783: x-ms-exchange-purlcount: 1 x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2449; x-forefront-prvs: 02135EB356 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(4636009)(376002)(366004)(396003)(346002)(39860400002)(136003)(189003)(199004)(186003)(5660300002)(86362001)(386003)(4326008)(102836004)(6506007)(1076003)(52116002)(966005)(6306002)(2906002)(5640700003)(99286004)(6116002)(36756003)(54906003)(14454004)(25786009)(486006)(66556008)(446003)(11346002)(81156014)(6916009)(76176011)(305945005)(7736002)(26005)(6512007)(2616005)(66066001)(2501003)(66946007)(316002)(64756008)(478600001)(50226002)(71190400001)(71200400001)(81166006)(8676002)(256004)(14444005)(2351001)(8936002)(6436002)(476003)(6486002)(66446008)(66476007)(3846002);DIR:OUT;SFP:1101;SCL:1;SRVR:SN6PR12MB2783;H:SN6PR12MB2639.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: lKHoQOueNrQmntmEvi1UPmp6fjWq1MkSXBD4xmducWHO+J5XuWgQXfC05i61/nQFZ9sgT8zn9s6TaZ4ZRlTDQqsjyVYcyhi+d+V7AW2OW/tt5Np2z7m+rpxHjI3R+8XKBlWb2c3Gnp5P5iYR726+C/fZbXcSSSIexHVSXvX6iBQ+nRcKdUtgVWXtYYYmMH8iZm0aLj3gulWEbpPHO1cGwZanK+SfcQ5+wuiX2IaPDvnQjQgECZZ50BGHeKBCIYe7hEJUGOodDHCoz0XI6XBVx0ZbHTVrfLcQj3iPpF6L3wNXlTGkzAsHqutTvbjUQOdOcDvsEq1wN22TR1PzOPFAu2CttnMOlKB0vudDwKHa0MDLzhWOA5gi/vLMANdAjtH0bxZDdNH9fcv74w5LSJDSqUdkNhhpnh2d2L4PgJDFjjsQtho9JVael+p0P5O9qdqe9kRmTghGdu1WaE52LLziGCR0BUHPUoY7gjMQfPNq6sQ= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 86d8486e-fa01-45c0-a7ee-08d76258243c X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Nov 2019 01:25:00.2892 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 6lNL+hzZkLXdixpvmhtdwDxDrBLSgUFofG9uSsQAD51zj+72dTCOgeFA0XfX4qX8w9+W7BillCUcY16AE9Ff9w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2783 Sender: linux-edac-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org From: Yazen Ghannam Split out gathering hardware information from init_one_instance() into a separate function hw_info_get(). This is necessary so that the information can be cached earlier and used to check if memory is populated and if ECC is enabled on a node. Also, define a function hw_info_put() to back out changes made in hw_info_get(). Currently, this includes two actions: freeing reserved PCI device siblings and freeing the allocated struct amd64_umc. Check for an allocated PCI device (Function 0 for Family 17h or Function 1 for pre-Family 17h) before freeing, since hw_info_put() may be called before PCI siblings are reserved. Drop the family check when freeing pvt->umc. This will be NULL on pre-Family 17h systems. However, kfree() is safe and will check for a NULL pointer before freeing. Signed-off-by: Yazen Ghannam --- Link: https://lkml.kernel.org/r/20191022203448.13962-3-Yazen.Ghannam@amd.com v2 -> v3: * No change. v1 -> v2: * Change get_hardware_info() to hw_info_get(). * Add hw_info_put() to backout changes from hw_info_get(). rfc -> v1: * Fixup after making struct amd64_family_type fam_type global. drivers/edac/amd64_edac.c | 101 +++++++++++++++++++------------------- 1 file changed, 51 insertions(+), 50 deletions(-) diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c index 83c659e38084..6e1c739b7fad 100644 --- a/drivers/edac/amd64_edac.c +++ b/drivers/edac/amd64_edac.c @@ -3418,34 +3418,15 @@ static void compute_num_umcs(void) edac_dbg(1, "Number of UMCs: %x", num_umcs); } -static int init_one_instance(unsigned int nid) +static int hw_info_get(struct amd64_pvt *pvt) { - struct pci_dev *F3 = node_to_amd_nb(nid)->misc; - struct mem_ctl_info *mci = NULL; - struct edac_mc_layer layers[2]; - struct amd64_pvt *pvt = NULL; u16 pci_id1, pci_id2; - int err = 0, ret; - - ret = -ENOMEM; - pvt = kzalloc(sizeof(struct amd64_pvt), GFP_KERNEL); - if (!pvt) - goto err_ret; - - pvt->mc_node_id = nid; - pvt->F3 = F3; - - ret = -EINVAL; - fam_type = per_family_init(pvt); - if (!fam_type) - goto err_free; + int ret = -EINVAL; if (pvt->fam >= 0x17) { pvt->umc = kcalloc(num_umcs, sizeof(struct amd64_umc), GFP_KERNEL); - if (!pvt->umc) { - ret = -ENOMEM; - goto err_free; - } + if (!pvt->umc) + return -ENOMEM; pci_id1 = fam_type->f0_id; pci_id2 = fam_type->f6_id; @@ -3454,21 +3435,37 @@ static int init_one_instance(unsigned int nid) pci_id2 = fam_type->f2_id; } - err = reserve_mc_sibling_devs(pvt, pci_id1, pci_id2); - if (err) - goto err_post_init; + ret = reserve_mc_sibling_devs(pvt, pci_id1, pci_id2); + if (ret) + return ret; read_mc_regs(pvt); + return 0; +} + +static void hw_info_put(struct amd64_pvt *pvt) +{ + if (pvt->F0 || pvt->F1) + free_mc_sibling_devs(pvt); + + kfree(pvt->umc); +} + +static int init_one_instance(struct amd64_pvt *pvt) +{ + struct mem_ctl_info *mci = NULL; + struct edac_mc_layer layers[2]; + int ret = -EINVAL; + /* * We need to determine how many memory channels there are. Then use * that information for calculating the size of the dynamic instance * tables in the 'mci' structure. */ - ret = -EINVAL; pvt->channel_count = pvt->ops->early_channel_count(pvt); if (pvt->channel_count < 0) - goto err_siblings; + return ret; ret = -ENOMEM; layers[0].type = EDAC_MC_LAYER_CHIP_SELECT; @@ -3490,9 +3487,9 @@ static int init_one_instance(unsigned int nid) layers[1].size = 2; layers[1].is_virt_csrow = false; - mci = edac_mc_alloc(nid, ARRAY_SIZE(layers), layers, 0); + mci = edac_mc_alloc(pvt->mc_node_id, ARRAY_SIZE(layers), layers, 0); if (!mci) - goto err_siblings; + return ret; mci->pvt_info = pvt; mci->pdev = &pvt->F3->dev; @@ -3505,31 +3502,17 @@ static int init_one_instance(unsigned int nid) ret = -ENODEV; if (edac_mc_add_mc_with_groups(mci, amd64_edac_attr_groups)) { edac_dbg(1, "failed edac_mc_add_mc()\n"); - goto err_add_mc; + edac_mc_free(mci); + return ret; } return 0; - -err_add_mc: - edac_mc_free(mci); - -err_siblings: - free_mc_sibling_devs(pvt); - -err_post_init: - if (pvt->fam >= 0x17) - kfree(pvt->umc); - -err_free: - kfree(pvt); - -err_ret: - return ret; } static int probe_one_instance(unsigned int nid) { struct pci_dev *F3 = node_to_amd_nb(nid)->misc; + struct amd64_pvt *pvt = NULL; struct ecc_settings *s; int ret; @@ -3540,6 +3523,21 @@ static int probe_one_instance(unsigned int nid) ecc_stngs[nid] = s; + pvt = kzalloc(sizeof(struct amd64_pvt), GFP_KERNEL); + if (!pvt) + goto err_settings; + + pvt->mc_node_id = nid; + pvt->F3 = F3; + + fam_type = per_family_init(pvt); + if (!fam_type) + goto err_enable; + + ret = hw_info_get(pvt); + if (ret < 0) + goto err_enable; + if (!ecc_enabled(F3, nid)) { ret = 0; @@ -3556,7 +3554,7 @@ static int probe_one_instance(unsigned int nid) goto err_enable; } - ret = init_one_instance(nid); + ret = init_one_instance(pvt); if (ret < 0) { amd64_err("Error probing instance: %d\n", nid); @@ -3569,6 +3567,10 @@ static int probe_one_instance(unsigned int nid) return ret; err_enable: + hw_info_put(pvt); + kfree(pvt); + +err_settings: kfree(s); ecc_stngs[nid] = NULL; @@ -3595,14 +3597,13 @@ static void remove_one_instance(unsigned int nid) restore_ecc_error_reporting(s, nid, F3); - free_mc_sibling_devs(pvt); - kfree(ecc_stngs[nid]); ecc_stngs[nid] = NULL; /* Free the EDAC CORE resources */ mci->pvt_info = NULL; + hw_info_put(pvt); kfree(pvt); edac_mc_free(mci); } From patchwork Wed Nov 6 01:25:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 11229101 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 37A7E112B for ; Wed, 6 Nov 2019 01:25:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E506322478 for ; Wed, 6 Nov 2019 01:25:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="L9gYh4X7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730834AbfKFBZQ (ORCPT ); Tue, 5 Nov 2019 20:25:16 -0500 Received: from mail-eopbgr800054.outbound.protection.outlook.com ([40.107.80.54]:39808 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730596AbfKFBZF (ORCPT ); Tue, 5 Nov 2019 20:25:05 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dzgIkQUDFUUgmhlVBoyD/6Ob1v78eu5gcyWaCp98+qBvVIqwbcUzlEwZXJlKzb3up5UYIgjCyAc4rNYVrB+f4h7TJcik8aKgt5wR/b1PFn3sM2WUWH/LpaTFLp6MYRzC8wtq9KyV82GOwY5jpXiY5wpIC3POyC0+Urce/fVV/vL0hRWvQRnKOL3ftHZUGbNXPTOep0anCXjSoIJhUiSbcwgdvTJiuOmTiWvL2Jc1HrOfwzEgefp8YRiAroEWG270jBmjEawzb5RT72hLmywnSE6hshmzgXyMIbez/InNKdZMGIMuaZi++pW9w8R24vJFL8aXM924XN3ddqX/6vb+4g== 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=yFnFpeiHLxHuwwAQPvDusAhpZzbpRMDC5IDK4TU+I44=; b=B23gOIy4Hoi+/ZfuImj2Tj5KOXKVqcehk6D5AfIl/f5tFqM4NbcZ8bhoszvGMYNk2401mX4aJHaCQWxyMk58Ggk7TakS8GQGipw0+iN01KHry3Yu2guozqHSIL/keDmEJgaUY2gwNuyJ8mNQCQfWKWttK4tqLu41K3K5MS4Ppv82f1Rv0PoNELmrDPYAowjeDAXcUE5LNs7Do/e90nQO0QWWKKDdBOPR2QaIR7m9XXUpEZEq6z012EPcUdHSNjpJh+lnNAgy2APkpZ+uw3aO2i1Yo+0CsleJ/NTGzSmhu6RzAjOittXWyuDUM7NpOjRAKMgk8MWf7GtY2ET7Dek8VA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yFnFpeiHLxHuwwAQPvDusAhpZzbpRMDC5IDK4TU+I44=; b=L9gYh4X7BMHjiMZZUgKQFfMs1dImR4ej22nDWT7LqX96zq7IbwaqzWLbHKv/RVvEFepMOt7k8IM4K1kSWR+PcgN2keiNS/CEI2yeos55q38VscRmnZ+8pXuTzKN8SBrpYzlsK9GlAFH4vumStlSzES+cdlpjR55EFc73PFOFg5Q= Received: from SN6PR12MB2639.namprd12.prod.outlook.com (52.135.103.16) by SN6PR12MB2701.namprd12.prod.outlook.com (52.135.103.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2408.24; Wed, 6 Nov 2019 01:25:01 +0000 Received: from SN6PR12MB2639.namprd12.prod.outlook.com ([fe80::2819:e697:4314:56ba]) by SN6PR12MB2639.namprd12.prod.outlook.com ([fe80::2819:e697:4314:56ba%3]) with mapi id 15.20.2408.024; Wed, 6 Nov 2019 01:25:01 +0000 From: "Ghannam, Yazen" To: "linux-edac@vger.kernel.org" CC: "Ghannam, Yazen" , "linux-kernel@vger.kernel.org" , "bp@alien8.de" Subject: [PATCH v3 3/5] EDAC/amd64: Save max number of controllers to family type Thread-Topic: [PATCH v3 3/5] EDAC/amd64: Save max number of controllers to family type Thread-Index: AQHVlEEC70osO2cD0kWlJdLy5vMoKg== Date: Wed, 6 Nov 2019 01:25:00 +0000 Message-ID: <20191106012448.243970-4-Yazen.Ghannam@amd.com> References: <20191106012448.243970-1-Yazen.Ghannam@amd.com> In-Reply-To: <20191106012448.243970-1-Yazen.Ghannam@amd.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: SN1PR12CA0064.namprd12.prod.outlook.com (2603:10b6:802:20::35) To SN6PR12MB2639.namprd12.prod.outlook.com (2603:10b6:805:6f::16) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Yazen.Ghannam@amd.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-originating-ip: [165.204.78.2] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: b7b3fe88-c0e2-46a3-1828-08d762582485 x-ms-traffictypediagnostic: SN6PR12MB2701: x-ms-exchange-purlcount: 1 x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-forefront-prvs: 02135EB356 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(4636009)(366004)(136003)(39860400002)(396003)(346002)(376002)(199004)(189003)(6116002)(81156014)(36756003)(3846002)(6486002)(6306002)(476003)(81166006)(6512007)(66946007)(1076003)(54906003)(2616005)(6506007)(4326008)(76176011)(71200400001)(71190400001)(2501003)(7736002)(11346002)(305945005)(52116002)(2906002)(256004)(5660300002)(446003)(99286004)(186003)(316002)(102836004)(26005)(6916009)(64756008)(66446008)(2351001)(66556008)(66066001)(8676002)(386003)(25786009)(14454004)(966005)(478600001)(50226002)(6436002)(86362001)(8936002)(5640700003)(486006)(66476007);DIR:OUT;SFP:1101;SCL:1;SRVR:SN6PR12MB2701;H:SN6PR12MB2639.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: aHcyY+4U3xAbTCLc24NS/jT7BvmYnz3V1RnjVr1PQQn/vGkoM2xW/FyR9bXjr+41C3739Im4m3SMK3oJgMvCKIBgbHVCfsCVYh/phOxd7rm/KMlK0FQIjbhdhqqc1JIHv/yFkAfLCujK7bJL5gXW3pqXhPdmM0dZYQ81P7P/Fmw8iYi36mWolRfWkQPsMHXHz/LN2xh5ruL7/EJNQRjhKssvSgcTmOVbGXsu0QUrAQ6EyAaw7WoTAc6/+ZpuqnScPXa7rB4d0LyV6Z89Su2iNbHfQEWLcImXKj039Sgq1WxKnmbknheT/sG7WJDrI/aQfV3RLrJpRYUupfhjMOMD2GHy7A6z7fsvy7hwu2m5JojuU1nLe9FeJRj9f/q+R6kluat5foFbCsFyLFWyhTbaCh2OsNgMwL3Bw88m8+4fqws6zj8ClYdYkkJkjgFqPx5OUFXthNdsHuoFppvE3sCaldKjwXPZtJYJRQtdA/Oc2rM= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: b7b3fe88-c0e2-46a3-1828-08d762582485 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Nov 2019 01:25:00.7439 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: SONIPVr05ZeV3AsR6ZhZu1xv3yvQwCiJ9y8YFDcjuOm7jPP8fxH4qEkN4i60q9kOCcxw32quat5aK/GB43BQAw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2701 Sender: linux-edac-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org From: Yazen Ghannam The maximum number of memory controllers is fixed within a family/model group. In most cases, this has been fixed at 2, but some systems may have up to 8. The struct amd64_family_type already contains family/model-specific information, and this can be used rather than adding model checks to various functions. Create a new field in struct amd64_family_type for max_mcs. Set this when setting other family type information, and use this when needing the maximum number of memory controllers possible for a system. Signed-off-by: Yazen Ghannam --- Link: https://lkml.kernel.org/r/20191022203448.13962-4-Yazen.Ghannam@amd.com v2 -> v3: * No change. v1 -> v2: * Change max_num_controllers to max_mcs. rfc -> v1: * New patch. * Idea came up from Boris' comment about compute_num_umcs(). drivers/edac/amd64_edac.c | 44 +++++++++++++-------------------------- drivers/edac/amd64_edac.h | 2 ++ 2 files changed, 16 insertions(+), 30 deletions(-) diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c index 6e1c739b7fad..110ed0d27998 100644 --- a/drivers/edac/amd64_edac.c +++ b/drivers/edac/amd64_edac.c @@ -21,9 +21,6 @@ static struct amd64_family_type *fam_type; /* Per-node stuff */ static struct ecc_settings **ecc_stngs; -/* Number of Unified Memory Controllers */ -static u8 num_umcs; - /* * Valid scrub rates for the K8 hardware memory scrubber. We map the scrubbing * bandwidth to a valid bit pattern. The 'set' operation finds the 'matching- @@ -456,7 +453,7 @@ static void get_cs_base_and_mask(struct amd64_pvt *pvt, int csrow, u8 dct, for (i = 0; i < pvt->csels[dct].m_cnt; i++) #define for_each_umc(i) \ - for (i = 0; i < num_umcs; i++) + for (i = 0; i < fam_type->max_mcs; i++) /* * @input_addr is an InputAddr associated with the node given by mci. Return the @@ -2226,6 +2223,7 @@ static struct amd64_family_type family_types[] = { .ctl_name = "K8", .f1_id = PCI_DEVICE_ID_AMD_K8_NB_ADDRMAP, .f2_id = PCI_DEVICE_ID_AMD_K8_NB_MEMCTL, + .max_mcs = 2, .ops = { .early_channel_count = k8_early_channel_count, .map_sysaddr_to_csrow = k8_map_sysaddr_to_csrow, @@ -2236,6 +2234,7 @@ static struct amd64_family_type family_types[] = { .ctl_name = "F10h", .f1_id = PCI_DEVICE_ID_AMD_10H_NB_MAP, .f2_id = PCI_DEVICE_ID_AMD_10H_NB_DRAM, + .max_mcs = 2, .ops = { .early_channel_count = f1x_early_channel_count, .map_sysaddr_to_csrow = f1x_map_sysaddr_to_csrow, @@ -2246,6 +2245,7 @@ static struct amd64_family_type family_types[] = { .ctl_name = "F15h", .f1_id = PCI_DEVICE_ID_AMD_15H_NB_F1, .f2_id = PCI_DEVICE_ID_AMD_15H_NB_F2, + .max_mcs = 2, .ops = { .early_channel_count = f1x_early_channel_count, .map_sysaddr_to_csrow = f1x_map_sysaddr_to_csrow, @@ -2256,6 +2256,7 @@ static struct amd64_family_type family_types[] = { .ctl_name = "F15h_M30h", .f1_id = PCI_DEVICE_ID_AMD_15H_M30H_NB_F1, .f2_id = PCI_DEVICE_ID_AMD_15H_M30H_NB_F2, + .max_mcs = 2, .ops = { .early_channel_count = f1x_early_channel_count, .map_sysaddr_to_csrow = f1x_map_sysaddr_to_csrow, @@ -2266,6 +2267,7 @@ static struct amd64_family_type family_types[] = { .ctl_name = "F15h_M60h", .f1_id = PCI_DEVICE_ID_AMD_15H_M60H_NB_F1, .f2_id = PCI_DEVICE_ID_AMD_15H_M60H_NB_F2, + .max_mcs = 2, .ops = { .early_channel_count = f1x_early_channel_count, .map_sysaddr_to_csrow = f1x_map_sysaddr_to_csrow, @@ -2276,6 +2278,7 @@ static struct amd64_family_type family_types[] = { .ctl_name = "F16h", .f1_id = PCI_DEVICE_ID_AMD_16H_NB_F1, .f2_id = PCI_DEVICE_ID_AMD_16H_NB_F2, + .max_mcs = 2, .ops = { .early_channel_count = f1x_early_channel_count, .map_sysaddr_to_csrow = f1x_map_sysaddr_to_csrow, @@ -2286,6 +2289,7 @@ static struct amd64_family_type family_types[] = { .ctl_name = "F16h_M30h", .f1_id = PCI_DEVICE_ID_AMD_16H_M30H_NB_F1, .f2_id = PCI_DEVICE_ID_AMD_16H_M30H_NB_F2, + .max_mcs = 2, .ops = { .early_channel_count = f1x_early_channel_count, .map_sysaddr_to_csrow = f1x_map_sysaddr_to_csrow, @@ -2296,6 +2300,7 @@ static struct amd64_family_type family_types[] = { .ctl_name = "F17h", .f0_id = PCI_DEVICE_ID_AMD_17H_DF_F0, .f6_id = PCI_DEVICE_ID_AMD_17H_DF_F6, + .max_mcs = 2, .ops = { .early_channel_count = f17_early_channel_count, .dbam_to_cs = f17_addr_mask_to_cs_size, @@ -2305,6 +2310,7 @@ static struct amd64_family_type family_types[] = { .ctl_name = "F17h_M10h", .f0_id = PCI_DEVICE_ID_AMD_17H_M10H_DF_F0, .f6_id = PCI_DEVICE_ID_AMD_17H_M10H_DF_F6, + .max_mcs = 2, .ops = { .early_channel_count = f17_early_channel_count, .dbam_to_cs = f17_addr_mask_to_cs_size, @@ -2314,6 +2320,7 @@ static struct amd64_family_type family_types[] = { .ctl_name = "F17h_M30h", .f0_id = PCI_DEVICE_ID_AMD_17H_M30H_DF_F0, .f6_id = PCI_DEVICE_ID_AMD_17H_M30H_DF_F6, + .max_mcs = 8, .ops = { .early_channel_count = f17_early_channel_count, .dbam_to_cs = f17_addr_mask_to_cs_size, @@ -2323,6 +2330,7 @@ static struct amd64_family_type family_types[] = { .ctl_name = "F17h_M70h", .f0_id = PCI_DEVICE_ID_AMD_17H_M70H_DF_F0, .f6_id = PCI_DEVICE_ID_AMD_17H_M70H_DF_F6, + .max_mcs = 2, .ops = { .early_channel_count = f17_early_channel_count, .dbam_to_cs = f17_addr_mask_to_cs_size, @@ -3402,29 +3410,13 @@ static const struct attribute_group *amd64_edac_attr_groups[] = { NULL }; -/* Set the number of Unified Memory Controllers in the system. */ -static void compute_num_umcs(void) -{ - u8 model = boot_cpu_data.x86_model; - - if (boot_cpu_data.x86 < 0x17) - return; - - if (model >= 0x30 && model <= 0x3f) - num_umcs = 8; - else - num_umcs = 2; - - edac_dbg(1, "Number of UMCs: %x", num_umcs); -} - static int hw_info_get(struct amd64_pvt *pvt) { u16 pci_id1, pci_id2; int ret = -EINVAL; if (pvt->fam >= 0x17) { - pvt->umc = kcalloc(num_umcs, sizeof(struct amd64_umc), GFP_KERNEL); + pvt->umc = kcalloc(fam_type->max_mcs, sizeof(struct amd64_umc), GFP_KERNEL); if (!pvt->umc) return -ENOMEM; @@ -3477,14 +3469,8 @@ static int init_one_instance(struct amd64_pvt *pvt) * Always allocate two channels since we can have setups with DIMMs on * only one channel. Also, this simplifies handling later for the price * of a couple of KBs tops. - * - * On Fam17h+, the number of controllers may be greater than two. So set - * the size equal to the maximum number of UMCs. */ - if (pvt->fam >= 0x17) - layers[1].size = num_umcs; - else - layers[1].size = 2; + layers[1].size = fam_type->max_mcs; layers[1].is_virt_csrow = false; mci = edac_mc_alloc(pvt->mc_node_id, ARRAY_SIZE(layers), layers, 0); @@ -3669,8 +3655,6 @@ static int __init amd64_edac_init(void) if (!msrs) goto err_free; - compute_num_umcs(); - for (i = 0; i < amd_nb_num(); i++) { err = probe_one_instance(i); if (err) { diff --git a/drivers/edac/amd64_edac.h b/drivers/edac/amd64_edac.h index 8c3cda81e619..9be31688110b 100644 --- a/drivers/edac/amd64_edac.h +++ b/drivers/edac/amd64_edac.h @@ -479,6 +479,8 @@ struct low_ops { struct amd64_family_type { const char *ctl_name; u16 f0_id, f1_id, f2_id, f6_id; + /* Maximum number of memory controllers per die/node. */ + u8 max_mcs; struct low_ops ops; }; From patchwork Wed Nov 6 01:25:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 11229097 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 9267B14E5 for ; Wed, 6 Nov 2019 01:25:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5455E2245C for ; Wed, 6 Nov 2019 01:25:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="Oo4yQ7xq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730769AbfKFBZM (ORCPT ); Tue, 5 Nov 2019 20:25:12 -0500 Received: from mail-eopbgr820079.outbound.protection.outlook.com ([40.107.82.79]:36833 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730054AbfKFBZG (ORCPT ); Tue, 5 Nov 2019 20:25:06 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FgJ+uxPDG5dnghBLyTIABUY9TXsvomDszrr//hsPJNDUynbu1Agqh//fFFR97Fm/FXVA82kPCbalzLNqWxA/DlJhsxTC8s018XjIdWyLpPwqtC3shQM5ZLWy8m2QDzM4upJC/Rj8orwVXSD0/hhtKVcjr1s9Bs999c2UKKIlEFHl5gdLk9I6lA9N8SFy76kwqD9jVh+SERwQd4aMHkJdpWm7B9aCH+Ff8tT1OjZutaYeYI9LWNFyhUfokcrXo+y1fIXNWzByVLZlS9Xill/847b2NOFGDdHEGyrt/Lcq5KGCKrlRyqAqHuFfaYBZ+lH85oPtXn9BTmn2Eo3gEfrAIA== 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=zqtSPXqdjK5wC9DWxR4RJpgEYpj1wC54IHBLfa85jRc=; b=asbpBeYKP+Fkx7lWnXvJeafcsjMBcxIAe+Ed91C/ixUr64BAWYDFwjjZw569qr0EIqkUf4aArfWi87nSpoqKjkR9+wGKVBVZoJXCEqQqq4zwxiAFoRwN4RlTdgDKDrvQoYP533UazUeCVSdW4hiJXUHwR9gePwoDPTLHecnubCD4MKPugiIN2KHY9CVZosz8EbEDkXYBNRL3W6BSwg/Fap8Tuz9A/6W1ujvywcoaZJEql7NxExctufEpAnm2n85WfweF09mnO6Xy55Vt+Xp330KP72HmkyQ1Qf5BJqe8Wyzr4pNqZzlOBeHkZccEb208E0sevyXybKZ/wxOqroH2Hw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zqtSPXqdjK5wC9DWxR4RJpgEYpj1wC54IHBLfa85jRc=; b=Oo4yQ7xquYDYwUv9dLuUF/+ZvQviiI56OCnGbzGMPO7q76ucbHq7hjEuMDu3FM/zeQ6ijA1EU3lwX1ulRzErARg76KIEBNHAr3e+MjI6M93GYOK8JOjcj5uq5Y5+f+z9GvMPTC+9XLVmiGd0R4H6yImUXP2ch2bqooTJBChHkQ8= Received: from SN6PR12MB2639.namprd12.prod.outlook.com (52.135.103.16) by SN6PR12MB2783.namprd12.prod.outlook.com (52.135.107.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2408.24; Wed, 6 Nov 2019 01:25:01 +0000 Received: from SN6PR12MB2639.namprd12.prod.outlook.com ([fe80::2819:e697:4314:56ba]) by SN6PR12MB2639.namprd12.prod.outlook.com ([fe80::2819:e697:4314:56ba%3]) with mapi id 15.20.2408.024; Wed, 6 Nov 2019 01:25:01 +0000 From: "Ghannam, Yazen" To: "linux-edac@vger.kernel.org" CC: "Ghannam, Yazen" , "linux-kernel@vger.kernel.org" , "bp@alien8.de" Subject: [PATCH v3 4/5] EDAC/amd64: Use cached data when checking for ECC Thread-Topic: [PATCH v3 4/5] EDAC/amd64: Use cached data when checking for ECC Thread-Index: AQHVlEECgc88AWnQWkqibLrNCrTHWQ== Date: Wed, 6 Nov 2019 01:25:01 +0000 Message-ID: <20191106012448.243970-5-Yazen.Ghannam@amd.com> References: <20191106012448.243970-1-Yazen.Ghannam@amd.com> In-Reply-To: <20191106012448.243970-1-Yazen.Ghannam@amd.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: SN1PR12CA0064.namprd12.prod.outlook.com (2603:10b6:802:20::35) To SN6PR12MB2639.namprd12.prod.outlook.com (2603:10b6:805:6f::16) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Yazen.Ghannam@amd.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-originating-ip: [165.204.78.2] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: d08ebf06-a274-403f-99a0-08d7625824ce x-ms-traffictypediagnostic: SN6PR12MB2783: x-ms-exchange-purlcount: 1 x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3513; x-forefront-prvs: 02135EB356 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(979002)(4636009)(376002)(366004)(396003)(346002)(39860400002)(136003)(189003)(199004)(186003)(5660300002)(86362001)(386003)(4326008)(102836004)(6506007)(1076003)(52116002)(966005)(6306002)(2906002)(5640700003)(99286004)(6116002)(36756003)(54906003)(14454004)(25786009)(486006)(66556008)(446003)(11346002)(81156014)(6916009)(76176011)(305945005)(7736002)(26005)(6512007)(2616005)(66066001)(2501003)(66946007)(316002)(64756008)(478600001)(50226002)(71190400001)(71200400001)(81166006)(8676002)(256004)(2351001)(8936002)(6436002)(476003)(6486002)(66446008)(66476007)(3846002)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1101;SCL:1;SRVR:SN6PR12MB2783;H:SN6PR12MB2639.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: noBr0V/W2TFX22UJWxkSJ4N9RhLWNpxi1HFtkbHfR4/V1NkHtmzNJetlf6EC9ao69nF7sBiL+LhCFtZhsUjXcLU6+KhbyX3FUSfdpONkfSgapDIhOG74ZapZB53cxYJwlEGJfM/hG+hz9Zdemxdm/c0HZLfbAB8SVeWGH/eRajC/22RjaUNqyPtoOOGHwTDpcWhdyOQ5SRH9Z0/DN7e+KrgA9NPEs1vxEpyrDd14gsh9vF4IohZ+CbZqmKkste69UQAVV4EmZXcfhKYDpczuQZjN0D544bLX0ByFv4rRDZ0lNcqzh1TQO+NhSYZFmlNtppXa+qwepKCuOLBQa0JnH/3NUYsfIxDA0eUz90HY5SUOHV/1xhVLh/xD9Ru1vOfMmNpxgC34ZDePpYPGknI17Nh2d23OHaX1cocDewDg5C7tokB7quK9RXQNazGqqBflTkATBxvIEhP0gHJlr5f2/RY5zvTYOLy/PGNm5e1pS7U= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: d08ebf06-a274-403f-99a0-08d7625824ce X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Nov 2019 01:25:01.3246 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 84LzIeRkW1OUi3YTvngu/CfFyJ0lMPEBkRj5eT0RKOkKYN3wAuofUSV+Q4WKvaeBxz6R6hF2BLZ3MJMg8i7tdQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2783 Sender: linux-edac-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org From: Yazen Ghannam ...now that the data is available earlier. Signed-off-by: Yazen Ghannam --- Link: https://lkml.kernel.org/r/20191022203448.13962-5-Yazen.Ghannam@amd.com v2 -> v3: * No change. v1 -> v2: * No change. rfc -> v1: * No change. drivers/edac/amd64_edac.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c index 110ed0d27998..d38ba7f17753 100644 --- a/drivers/edac/amd64_edac.c +++ b/drivers/edac/amd64_edac.c @@ -3202,31 +3202,27 @@ static const char *ecc_msg = "'ecc_enable_override'.\n" " (Note that use of the override may cause unknown side effects.)\n"; -static bool ecc_enabled(struct pci_dev *F3, u16 nid) +static bool ecc_enabled(struct amd64_pvt *pvt) { + u16 nid = pvt->mc_node_id; bool nb_mce_en = false; u8 ecc_en = 0, i; u32 value; if (boot_cpu_data.x86 >= 0x17) { u8 umc_en_mask = 0, ecc_en_mask = 0; + struct amd64_umc *umc; for_each_umc(i) { - u32 base = get_umc_base(i); + umc = &pvt->umc[i]; /* Only check enabled UMCs. */ - if (amd_smn_read(nid, base + UMCCH_SDP_CTRL, &value)) - continue; - - if (!(value & UMC_SDP_INIT)) + if (!(umc->sdp_ctrl & UMC_SDP_INIT)) continue; umc_en_mask |= BIT(i); - if (amd_smn_read(nid, base + UMCCH_UMC_CAP_HI, &value)) - continue; - - if (value & UMC_ECC_ENABLED) + if (umc->umc_cap_hi & UMC_ECC_ENABLED) ecc_en_mask |= BIT(i); } @@ -3239,7 +3235,7 @@ static bool ecc_enabled(struct pci_dev *F3, u16 nid) /* Assume UMC MCA banks are enabled. */ nb_mce_en = true; } else { - amd64_read_pci_cfg(F3, NBCFG, &value); + amd64_read_pci_cfg(pvt->F3, NBCFG, &value); ecc_en = !!(value & NBCFG_ECC_ENABLE); @@ -3524,7 +3520,7 @@ static int probe_one_instance(unsigned int nid) if (ret < 0) goto err_enable; - if (!ecc_enabled(F3, nid)) { + if (!ecc_enabled(pvt)) { ret = 0; if (!ecc_enable_override) From patchwork Wed Nov 6 01:25:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 11229095 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 F2B65112B for ; Wed, 6 Nov 2019 01:25:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B58122247B for ; Wed, 6 Nov 2019 01:25:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="tJlAKsaR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729614AbfKFBZI (ORCPT ); Tue, 5 Nov 2019 20:25:08 -0500 Received: from mail-eopbgr820079.outbound.protection.outlook.com ([40.107.82.79]:36833 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730769AbfKFBZH (ORCPT ); Tue, 5 Nov 2019 20:25:07 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B1nuv38WwZJnbEczTqPaZ4qTRxD3/zxLRUUx2RAVnxzQdlLl0HLXRT6cCBCg3YTGKSidcrzoqVmvr/zyNaSsZlYMeR098i0oQTq3x83GmEXf2ZVQ84SyM7BWObqkiNZFf4MuNP8jSjcuyXSjZgYNFV6BwG8CnzjgTucOSG9nVpU9F+E+zGddFEHV4NL3yh6gD83ecx/kePYdfse6a1AuqYI5TeHx85TQYebjY1JejhSYJ3xgzIs2dr3+4CKPpmpwWCotWeGDKDnw0YEXVs2D2D9ThcQ+D8ur0Bu/Mvs31zFDzDACg3/E9RJFxMDvWWm9TjgjboSrobS0FHH8a8nEgA== 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=xPdFnmmQ0WisiQ0Q2OwvnHI7ffddDpTtaxufw+gY9Ng=; b=QKPYw3bQHr48/mWhTR3xvzyad1v1dq7gOJW0hBJM3j2Zf/PNzJRzk31OMvEE5PsbUJFZpwDMFufUwcUu5/IgEJ5zr+FaI9c+F9um0IFD/Foa3riVgOPcp6wEprs8sn1uXj2cOQSoLNiGfQ0SOmxojiOqKisrBzJ9PE9xrnkcLJIQo27xyTxLlo5AktijZmqwQ5Y53b13hy4g3R1j3j4KII2hmWuDPn5ERXyEO0o+8Wju94cihTi5Phe/SbfAiLf9tfabtuLHFUfvSCkSix8Xc3xiEV/U/YqJLGTN3rRTIAK6gSknUL5OgtdCWiKssFvnImgtseMFV1YMf7yGlZl5kQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xPdFnmmQ0WisiQ0Q2OwvnHI7ffddDpTtaxufw+gY9Ng=; b=tJlAKsaR3sf8rbxxlc+RkQAczVwwLAU2W/rD5akdkp/tpQfXbIWpPuKYPXINGHjaoLZ5yglaj6wd4S1iZD13PM4NUw3uY9aW7JPB416tXlCAYkxkf81PbZc6UEI7Jg4zwoDKwsFaBbij2o82/HH7TBce5US6h5J8yEPPuWDsR4g= Received: from SN6PR12MB2639.namprd12.prod.outlook.com (52.135.103.16) by SN6PR12MB2783.namprd12.prod.outlook.com (52.135.107.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2408.24; Wed, 6 Nov 2019 01:25:02 +0000 Received: from SN6PR12MB2639.namprd12.prod.outlook.com ([fe80::2819:e697:4314:56ba]) by SN6PR12MB2639.namprd12.prod.outlook.com ([fe80::2819:e697:4314:56ba%3]) with mapi id 15.20.2408.024; Wed, 6 Nov 2019 01:25:02 +0000 From: "Ghannam, Yazen" To: "linux-edac@vger.kernel.org" CC: "Ghannam, Yazen" , "linux-kernel@vger.kernel.org" , "bp@alien8.de" Subject: [PATCH v3 5/5] EDAC/amd64: Check for memory before fully initializing an instance Thread-Topic: [PATCH v3 5/5] EDAC/amd64: Check for memory before fully initializing an instance Thread-Index: AQHVlEECwn3bnSYYRUK/Y8obdVXQEg== Date: Wed, 6 Nov 2019 01:25:01 +0000 Message-ID: <20191106012448.243970-6-Yazen.Ghannam@amd.com> References: <20191106012448.243970-1-Yazen.Ghannam@amd.com> In-Reply-To: <20191106012448.243970-1-Yazen.Ghannam@amd.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: SN1PR12CA0064.namprd12.prod.outlook.com (2603:10b6:802:20::35) To SN6PR12MB2639.namprd12.prod.outlook.com (2603:10b6:805:6f::16) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Yazen.Ghannam@amd.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-originating-ip: [165.204.78.2] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 9490d007-b841-40b9-5b25-08d762582527 x-ms-traffictypediagnostic: SN6PR12MB2783: x-ms-exchange-purlcount: 1 x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8882; x-forefront-prvs: 02135EB356 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(979002)(4636009)(376002)(366004)(396003)(346002)(39860400002)(136003)(189003)(199004)(186003)(5660300002)(86362001)(386003)(4326008)(102836004)(6506007)(1076003)(52116002)(966005)(6306002)(2906002)(5640700003)(99286004)(6116002)(36756003)(54906003)(14454004)(25786009)(486006)(66556008)(446003)(11346002)(81156014)(6916009)(76176011)(305945005)(7736002)(26005)(6512007)(2616005)(66066001)(2501003)(66946007)(316002)(64756008)(478600001)(50226002)(71190400001)(71200400001)(81166006)(8676002)(256004)(14444005)(2351001)(8936002)(6436002)(476003)(6486002)(66446008)(66476007)(3846002)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1101;SCL:1;SRVR:SN6PR12MB2783;H:SN6PR12MB2639.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: FXdAP/lf7i1CaFONqkSjRlbTHRp1IzTJZDNw8rH0akyRQC3R1C+MsgYV0dRyjGP3Zn621exBVhVQpEdPpKUigoqVPRYiw14FIdfFT5mp1U4WgH7SGOD4u9Lzjn8BQnPXfX3FzWi8hf9CkQs4/CORdGAYZFRsKXHQH1iyvnoBcmjGbHnyMG9gJRZj0e7yraI5Tq/FUofWZMGKeMFwChTBP/zQJnk7sBR+4MRStU4+iA4Nlytqp78mlRmA7CyLneTzaKULBrHcia23LZ3H4oXnz84GNH3rI1LDqqvgZX4f48OJgM0OOvqP9qic/Vamo8MLwE0tt4TMAc8G+8FVpJIgTTVSDBQiowO1Pe0O0/VxJjmnjWUOMt7wcX9Q9Uw5u0cy+98mQD1BDho2nuVZVxdoVZZRgwdrBb7boPAOgeFzxLQgghIbeFfP4cVhEQzFXz1KETS4bsJIT8OWAEXAKoZ8q776+8T0icPXFyOkyzjjUoI= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9490d007-b841-40b9-5b25-08d762582527 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Nov 2019 01:25:01.8663 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: fr3XO24ZneFR/53ODEKtq0TjjlSPV2G0lQIx39A8fKdIpDKsveTshO5Qz/h+PJtWuz/nG9elsrKrJFshfS+12w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2783 Sender: linux-edac-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org From: Yazen Ghannam Return early before checking for ECC if the node does not have any populated memory. Free any cached hardware data before returning. Also, return 0 in this case since this is not a failure. Other nodes may have memory and the module should attempt to load an instance for them. Move printing of hardware information to after the instance is initialized, so that the information is only printed for nodes with memory. Return an error code when ECC is disabled. This check happens after checking for memory. The module should explicitly fail to load if memory is populated on a node and ECC is disabled. Signed-off-by: Yazen Ghannam --- Link: https://lkml.kernel.org/r/20191022203448.13962-6-Yazen.Ghannam@amd.com v2 -> v3: * Add error code to !ecc_enabled() path. v1 -> v2: * No change. rfc -> v1: * Change message severity to "info". * Nodes without memory is a valid configuration. The user doesn't need to be warned. * Drop "DRAM ECC disabled" from message. * The message is given when no memory was detected on a node. * The state of DRAM ECC is not checked here. drivers/edac/amd64_edac.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c index d38ba7f17753..3aeb5173e200 100644 --- a/drivers/edac/amd64_edac.c +++ b/drivers/edac/amd64_edac.c @@ -2848,8 +2848,6 @@ static void read_mc_regs(struct amd64_pvt *pvt) edac_dbg(1, " DIMM type: %s\n", edac_mem_types[pvt->dram_type]); determine_ecc_sym_sz(pvt); - - dump_misc_regs(pvt); } /* @@ -3491,6 +3489,19 @@ static int init_one_instance(struct amd64_pvt *pvt) return 0; } +static bool instance_has_memory(struct amd64_pvt *pvt) +{ + bool cs_enabled = false; + int cs = 0, dct = 0; + + for (dct = 0; dct < fam_type->max_mcs; dct++) { + for_each_chip_select(cs, dct, pvt) + cs_enabled |= csrow_enabled(cs, dct, pvt); + } + + return cs_enabled; +} + static int probe_one_instance(unsigned int nid) { struct pci_dev *F3 = node_to_amd_nb(nid)->misc; @@ -3520,8 +3531,14 @@ static int probe_one_instance(unsigned int nid) if (ret < 0) goto err_enable; + ret = 0; + if (!instance_has_memory(pvt)) { + amd64_info("Node %d: No DIMMs detected.\n", nid); + goto err_enable; + } + if (!ecc_enabled(pvt)) { - ret = 0; + ret = -ENODEV; if (!ecc_enable_override) goto err_enable; @@ -3546,6 +3563,8 @@ static int probe_one_instance(unsigned int nid) goto err_enable; } + dump_misc_regs(pvt); + return ret; err_enable: