From patchwork Tue Oct 22 20:35:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 11205335 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 109E8913 for ; Tue, 22 Oct 2019 20:35:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D95CB21872 for ; Tue, 22 Oct 2019 20:35:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="RzPdn86f" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731554AbfJVUfO (ORCPT ); Tue, 22 Oct 2019 16:35:14 -0400 Received: from mail-eopbgr760059.outbound.protection.outlook.com ([40.107.76.59]:62979 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729810AbfJVUfO (ORCPT ); Tue, 22 Oct 2019 16:35:14 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R08m2pNNv8J7oEFIVpTBd62bgz8ztAGCoSfktIyetGllnPy5IK1yBYq9akLESEJYbTiz8msUzvroysZnW2vzcEBCZT4HI2z7oirj/qkLr9Lv0l2uQJGZPFO1QUK1jP4H/i91UwAjx2JyIcub2BPfJbyA96BcYw5dme+aYf0ttXl3+U31kevxytWCq/AX/cMXWwViIOcpRicDwCOgqcvolteR3PVI+1gqvyR1esSBJos2VvQftwoTysCGZenYHXjuNz3kGGX9K0HJDkgGEJSsYVL4v25vkEW0qJiwZTLubKpGiKd68seB7F9lkjuBBCFdTsoWl9gqDNadb47MctCXFw== 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=Yq82o3FgHVKRzVw1/5MctqnCCsJnOPGhbY5Y87iN/fc=; b=XKFcHooh+8bBfFcFJBPDurRPXXtzHSQSOoFZN3nAs/Y4xYOQWUL/DGUGNKIrBpnk7vedbTa5SV0j85sLDuSNCuDIpr8V3WwPmDTuTerKUAW8nkwabjjXQwo3/Pv6DGxFi/D7rkHtu3r3C9JvIquTjJOCQWjtWlHD+HwZI0ZNN7QzJ21p+XiinjH/Vt43sitXh7IMJrDvKMWTcspNbgOp/uJ4xxYxL9pDhsvLHxvLya7Y/tpM0qbCeyyFXcAAZzlijwfzGwstsjhCRSRKP2AKfGtNw+XAq7dKm0iUuZvwDj6Oxatf9o6mlCiQKicgiEgd3H6uekrvKCzpUwgAy30lXA== 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=Yq82o3FgHVKRzVw1/5MctqnCCsJnOPGhbY5Y87iN/fc=; b=RzPdn86fj5yvSui/Dn9sKEkawQaawDSN3nU1+ynltYNmOWxu7lD9iBkTycMwk3jxMTWPpyMzzJAISdSOEsl5A2NIu2ZIBcBf5WSN3yBEWMbzc75lZkBpGsmy+eJGsIzH2wViwkAwy+x+ZG3kEFlFTl62fVfKdkJwAAmjDGdMZEA= Received: from BN7PR12MB2628.namprd12.prod.outlook.com (20.176.178.20) by BN7PR12MB2723.namprd12.prod.outlook.com (20.176.177.94) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.20; Tue, 22 Oct 2019 20:35:10 +0000 Received: from BN7PR12MB2628.namprd12.prod.outlook.com ([fe80::2115:dffc:44b6:e53a]) by BN7PR12MB2628.namprd12.prod.outlook.com ([fe80::2115:dffc:44b6:e53a%6]) with mapi id 15.20.2347.029; Tue, 22 Oct 2019 20:35:10 +0000 From: "Ghannam, Yazen" To: "linux-edac@vger.kernel.org" CC: "Ghannam, Yazen" , "linux-kernel@vger.kernel.org" , "bp@alien8.de" Subject: [PATCH v2 1/6] EDAC/amd64: Make struct amd64_family_type global Thread-Topic: [PATCH v2 1/6] EDAC/amd64: Make struct amd64_family_type global Thread-Index: AQHViRgyvXbCdcnQ7Uid7ACBemIPaA== Date: Tue, 22 Oct 2019 20:35:09 +0000 Message-ID: <20191022203448.13962-2-Yazen.Ghannam@amd.com> References: <20191022203448.13962-1-Yazen.Ghannam@amd.com> In-Reply-To: <20191022203448.13962-1-Yazen.Ghannam@amd.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: SN4PR0501CA0024.namprd05.prod.outlook.com (2603:10b6:803:40::37) To BN7PR12MB2628.namprd12.prod.outlook.com (2603:10b6:408:30::20) 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: 8aa48e0a-28f7-424d-18a8-08d7572f54cf x-ms-traffictypediagnostic: BN7PR12MB2723: x-ms-exchange-purlcount: 1 x-ld-processed: 3dd8961f-e488-4e60-8e11-a82d994e183d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2733; x-forefront-prvs: 01986AE76B x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(4636009)(346002)(136003)(39860400002)(366004)(396003)(376002)(199004)(189003)(6306002)(476003)(2616005)(26005)(102836004)(186003)(966005)(6436002)(81166006)(81156014)(52116002)(99286004)(50226002)(6512007)(11346002)(486006)(446003)(8936002)(36756003)(6486002)(305945005)(8676002)(7736002)(2501003)(14454004)(5660300002)(478600001)(4326008)(25786009)(2351001)(316002)(2906002)(54906003)(6116002)(86362001)(256004)(66066001)(1076003)(5640700003)(66946007)(6916009)(6506007)(66476007)(3846002)(66446008)(71190400001)(71200400001)(64756008)(66556008)(386003)(76176011);DIR:OUT;SFP:1101;SCL:1;SRVR:BN7PR12MB2723;H:BN7PR12MB2628.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: iAKOe4eDL9JpaUInupjmvnYs0T8OXW28DKsNDIE8leLn2XqhyFA7VI4QuiZEIYxqRTHROpP0fnE9Yr9IVviANlLj0vpQ39zL2f8pS04850zvi4CWcLrY0HG5WjKwsBYEG5VcTToqTffuh9LINjzhT0XequjfFRtC8s7GvJlUqa3By/7+Dx2z/eHx57SntNXjLGzm7hqBeZ4TFu06+oHnf0avVcgjlVwW+C49j3+FoxlwfFByDRKomNIiou9VRMCRDi2LgfQwTSAnj7UU97kOS2xGRPHLxNKENVKJH96BR43w/UbFKhl0zmFNOvQ9kfCCKuIBhThWhwRg7PmZCMCr/LnPw5p4mhRZU8aTn0CRJfRNEs0PgKlDbf8hxTVSI5CqQXbKYYg/7Nzetb57K1wUKMojAx8CRfcsj9ehqBIiee900KdjuzMmForklx6XxHAuejc3BAiqTvhce2HC1SnETKumz+WaVGFL50E1/VdgHfc= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8aa48e0a-28f7-424d-18a8-08d7572f54cf X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Oct 2019 20:35:09.7010 (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: vFkoY54KAaFROg6KPvQLhdDDMKw9MF4IwLPfBOU+P50+oYOy5bgtnXeOniDmxe7AG3IcMKLEC8CVS/qc9TS9NQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR12MB2723 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/20191018153114.39378-2-Yazen.Ghannam@amd.com 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 c1d4536ae466..b9a712819c68 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; @@ -3278,8 +3280,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; @@ -3298,7 +3299,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; @@ -3312,8 +3313,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; @@ -3420,7 +3419,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; @@ -3497,7 +3495,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 Tue Oct 22 20:35:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 11205339 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 2055114ED for ; Tue, 22 Oct 2019 20:35:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E08AA21906 for ; Tue, 22 Oct 2019 20:35:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="JqCEsM3g" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389526AbfJVUf1 (ORCPT ); Tue, 22 Oct 2019 16:35:27 -0400 Received: from mail-eopbgr790088.outbound.protection.outlook.com ([40.107.79.88]:26304 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1733029AbfJVUf1 (ORCPT ); Tue, 22 Oct 2019 16:35:27 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UMtv/JrBhYcscQyq3Pcst7LN+zvpRVezcbATJtOv7WrztyY9ljRERr6rWEjVUbhrx+nQb9ZoTy4jK2VNB914zUVxROxQk0xIIAvbBDyl8f8oUttRcpwjQHALzoov4paBCCVeIBvNapLRQI3Hfy3/Ugu4hNa6aVpVQjAjoWLiqccMtl3CrqRrne7Ke1KzktUV/IB2fXxSECJ9t16vM3so7vyLyCHtPjEsNtnoWiChdPP5ZW+j+5EGthz/+2P1TzhwxtYWgVUeWJdGt3NVaVBo29yOTUmKvnyDr6GdbqFPYDwiS9BYSRsw9qFySK8fca6Id6YgRI2MM3CLq06Ek+WAXg== 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=EgCc5pf7X5sup0KHq2d+oCcHxJEr48xR8rNjCQtdH+8=; b=ZUvg6t6zR0dHcZkfvg57ecIf4rptGPt1T+kagyQhw+OuMZx+g8EAyiFYzKY8HgbA3chwHbyX/D8oUEeluWozz3eytNYmzMKjCbWsWxs06Eq858u4TR7yue/PTOelR8DJM2Dv0dr8yQMeEbavpnMK+lhtXdlAn0qQBY2Jycg+gJldSQxw5i8ItVU1tq1kAb7YD76PLs/qlEZ5hjNEvXx5fS/YVVS+zTFByh6J69tsbvy6VYYlUcxx6biwmmZnNDhDzYO4+dwNntICoNbeiFyEMeasnLTWvLO9IRnde+v3vqdIwDgISvL84MSFbLkDDXsxPN14D/gdfn/BLUAgw7ewhQ== 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=EgCc5pf7X5sup0KHq2d+oCcHxJEr48xR8rNjCQtdH+8=; b=JqCEsM3gb6S0Q0CaIbiwWloFfBMrB8t17q57OFCHOzMiRsKaddX53z5m3xu1EYfN3yHHMkh/+qQXtRKXl0AKfpLdeWhIiSMALP1iNZzdmNrfZggBL2QOSi9rgMjJQf7TBAXp+fZ2jahUdV63QzLhnSwgjGeseUZScavV3Yey4Ig= Received: from BN7PR12MB2628.namprd12.prod.outlook.com (20.176.178.20) by BN7PR12MB2724.namprd12.prod.outlook.com (20.176.178.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2367.24; Tue, 22 Oct 2019 20:35:10 +0000 Received: from BN7PR12MB2628.namprd12.prod.outlook.com ([fe80::2115:dffc:44b6:e53a]) by BN7PR12MB2628.namprd12.prod.outlook.com ([fe80::2115:dffc:44b6:e53a%6]) with mapi id 15.20.2347.029; Tue, 22 Oct 2019 20:35:10 +0000 From: "Ghannam, Yazen" To: "linux-edac@vger.kernel.org" CC: "Ghannam, Yazen" , "linux-kernel@vger.kernel.org" , "bp@alien8.de" Subject: [PATCH v2 2/6] EDAC/amd64: Gather hardware information early Thread-Topic: [PATCH v2 2/6] EDAC/amd64: Gather hardware information early Thread-Index: AQHViRgyyNCGlOIlVkadvQJY7cn6Hg== Date: Tue, 22 Oct 2019 20:35:10 +0000 Message-ID: <20191022203448.13962-3-Yazen.Ghannam@amd.com> References: <20191022203448.13962-1-Yazen.Ghannam@amd.com> In-Reply-To: <20191022203448.13962-1-Yazen.Ghannam@amd.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: SN4PR0501CA0024.namprd05.prod.outlook.com (2603:10b6:803:40::37) To BN7PR12MB2628.namprd12.prod.outlook.com (2603:10b6:408:30::20) 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: efb29278-b192-4660-c1df-08d7572f554c x-ms-traffictypediagnostic: BN7PR12MB2724: x-ms-exchange-purlcount: 1 x-ld-processed: 3dd8961f-e488-4e60-8e11-a82d994e183d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2449; x-forefront-prvs: 01986AE76B x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(4636009)(396003)(39860400002)(136003)(366004)(346002)(376002)(189003)(199004)(25786009)(36756003)(54906003)(316002)(2906002)(14444005)(256004)(66066001)(6916009)(52116002)(71200400001)(71190400001)(76176011)(2351001)(2501003)(6116002)(26005)(99286004)(186003)(6512007)(4326008)(6436002)(966005)(1076003)(102836004)(305945005)(5640700003)(7736002)(6486002)(386003)(6506007)(6306002)(14454004)(3846002)(478600001)(2616005)(486006)(476003)(8936002)(66446008)(11346002)(446003)(50226002)(66476007)(81166006)(66556008)(64756008)(8676002)(81156014)(5660300002)(86362001)(66946007);DIR:OUT;SFP:1101;SCL:1;SRVR:BN7PR12MB2724;H:BN7PR12MB2628.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: RjMkhtqzigTi+l6swn4IuME8cz0+NDLscK5S6pVxsavgwHzt5v+9Atrvtv2wxPL1snQKjBbh7180sRSKx3ECposBK7acsZuz9uZ0w4OHyguO4yu/H2xrxhQCmRVRhpnwNY+kak3ZwfXBKpjhJEL3QKpjGDmgSlLXlyFFkaIATwdJcTZJy6QI/FjyS/yByH2n+Xy7ubpa14TDV9sMvyVdItMrOEsKtPvwqnECVkjagk2ZjxXQH060Y+86SR2Xh8RPPUOF8juHFfgER4+4lshFt94S9Z/Qc6QsaC/E9bccHkRlJKi4L6Z/sbYXclyg5xVbL5yM0dDUFeopf/zt/U1PM9UvH21uwhU9g6Ps5EdcYIaifyAKe5hwWBscKUK6UhYqZSdCW+do+DUrSu1dyNULjvofEWJ5KtEBjBxYJDnSNpFkLdsH9Gn5etTz/kRhudMdg/arawryK/cLcN89ICMbEI3TkECnvjaUqr3ur+jA9WA= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: efb29278-b192-4660-c1df-08d7572f554c X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Oct 2019 20:35:10.4776 (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: MaVaM5ejpgYkX08b6Pt2IncqNlCTSUcetya0+6tZPuM59L1dZIcGm/GzZsthEFtWcQ/Osvu3u7J5rxNWOm7aUA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR12MB2724 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/20191018153114.39378-3-Yazen.Ghannam@amd.com 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 b9a712819c68..df7dd9604bb2 100644 --- a/drivers/edac/amd64_edac.c +++ b/drivers/edac/amd64_edac.c @@ -3416,34 +3416,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; @@ -3452,21 +3433,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; @@ -3488,9 +3485,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; @@ -3503,31 +3500,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; @@ -3538,6 +3521,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; @@ -3554,7 +3552,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); @@ -3567,6 +3565,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; @@ -3593,14 +3595,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 Tue Oct 22 20:35:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 11205345 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 B3FDD14ED for ; Tue, 22 Oct 2019 20:35:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 895C521925 for ; Tue, 22 Oct 2019 20:35:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="BH1174rJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388931AbfJVUfW (ORCPT ); Tue, 22 Oct 2019 16:35:22 -0400 Received: from mail-eopbgr790088.outbound.protection.outlook.com ([40.107.79.88]:26304 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731110AbfJVUfV (ORCPT ); Tue, 22 Oct 2019 16:35:21 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ofHJFZ/bD9PTONAAJiIWiDSJao76I8UGG0JcYh315ybdwBUVP7m9/22gn1mqEWdtbIPch9nAqskEW8z1Cs/OZpoPpNSr7E8sDNFUQqtp+DrXTereduxTgE9yWOEBd1ymOoziyw4o+xULo45tYP4ZTORjLEQWS4ltjBM9YuyF+2HBGQ6fSK50BG1XbwDSwhcxROiboFwjJKTsjrt6n+vYcwPyd/tGqnp2TEhb8Mgm+iiROldFUx3ewIZ8Yn2CvEmcP1NAz2QoQzdhKnp0jYPdV7rPeysB/QAuOCAr4r8KA+MtkrXf2hRl0M/inz0Ou9YX/Dqvk11dOlg7u3y/bP8vLw== 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=zO9bVOotzprOucOpMOuK8V+3gINZ+LiG3RgkAEcvtb4=; b=CJ6C8iQs5SDmJ9fEb/2i/Ay8ImFGztzqLMpfjNqx3BbQe6jr0fE82ljZLiprX5SkJtNKGE4LhuN3OThGkU3lgoLwicw14W0LNIZ5lAWkPD07aC4bg4NR8w6ZtlgqYZE5ZD9Nzb84FlR/NfLs1J2Okk6eNJhi0Dd2aTMzQ8JgMAArGAVATchCD0aMULft6hZBOUBQEUOL+816LW8HO3vGZUtzva3RgPHMn6SDA/kIY3/C0KqET1lpIh4rPZPhrmqbD6zmuim3YR+42idnv2cg9M/VGTf+6GUyNlmYav+AgCyoooA7DO+AVYypRrEuHjhshvBidbbTzAvgG9AkF8l2mg== 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=zO9bVOotzprOucOpMOuK8V+3gINZ+LiG3RgkAEcvtb4=; b=BH1174rJLXQ32oyYLu8FEZB2mfV38ok5HvEdwiDa9llbVnu+OPV6L1lAMr1kK1NMJJXUoNSy5M7IVrGSPIH+glYvoueHJ+8MQ/s2ZTJIdw9IlAGk1+iAEYu3g/1+CqJusSr90IpV05CiD4zJ6jOTGpyypsQMt+E7UkhjjY3ZcXY= Received: from BN7PR12MB2628.namprd12.prod.outlook.com (20.176.178.20) by BN7PR12MB2724.namprd12.prod.outlook.com (20.176.178.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2367.24; Tue, 22 Oct 2019 20:35:11 +0000 Received: from BN7PR12MB2628.namprd12.prod.outlook.com ([fe80::2115:dffc:44b6:e53a]) by BN7PR12MB2628.namprd12.prod.outlook.com ([fe80::2115:dffc:44b6:e53a%6]) with mapi id 15.20.2347.029; Tue, 22 Oct 2019 20:35:11 +0000 From: "Ghannam, Yazen" To: "linux-edac@vger.kernel.org" CC: "Ghannam, Yazen" , "linux-kernel@vger.kernel.org" , "bp@alien8.de" Subject: [PATCH v2 3/6] EDAC/amd64: Save max number of controllers to family type Thread-Topic: [PATCH v2 3/6] EDAC/amd64: Save max number of controllers to family type Thread-Index: AQHViRgzk6Mt/xzuLkO1rf5vfT5Wag== Date: Tue, 22 Oct 2019 20:35:11 +0000 Message-ID: <20191022203448.13962-4-Yazen.Ghannam@amd.com> References: <20191022203448.13962-1-Yazen.Ghannam@amd.com> In-Reply-To: <20191022203448.13962-1-Yazen.Ghannam@amd.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: SN4PR0501CA0024.namprd05.prod.outlook.com (2603:10b6:803:40::37) To BN7PR12MB2628.namprd12.prod.outlook.com (2603:10b6:408:30::20) 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: 58befb58-9e51-46c8-9b0e-08d7572f55c6 x-ms-traffictypediagnostic: BN7PR12MB2724: x-ms-exchange-purlcount: 1 x-ld-processed: 3dd8961f-e488-4e60-8e11-a82d994e183d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-forefront-prvs: 01986AE76B x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(4636009)(396003)(39860400002)(136003)(366004)(346002)(376002)(189003)(199004)(25786009)(36756003)(54906003)(316002)(2906002)(256004)(66066001)(6916009)(52116002)(71200400001)(71190400001)(76176011)(2351001)(2501003)(6116002)(26005)(99286004)(186003)(6512007)(4326008)(6436002)(966005)(1076003)(102836004)(305945005)(5640700003)(7736002)(6486002)(386003)(6506007)(6306002)(14454004)(3846002)(478600001)(2616005)(486006)(476003)(8936002)(66446008)(11346002)(446003)(50226002)(66476007)(81166006)(66556008)(64756008)(8676002)(81156014)(5660300002)(86362001)(66946007);DIR:OUT;SFP:1101;SCL:1;SRVR:BN7PR12MB2724;H:BN7PR12MB2628.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: uBRNYlc9Z9YPSBLx05NWqHGdcuRliO7a7m9TKreWGYq3LrQ7OM83Yfxa3XqXqd70HNp7moJmUhtJ6QPg202jMr71nQ5HjbxvCnSpzwn9//uobE4+qce/kV6kAuIuFjsQFSrru957Q+JnNa0/MOGQw+KuZVxSQatZUE6T44cA1gMCMUBP6pKiwKFeGObr8znOnPG9wzGTyL1QE4AODaZT9k3UrryPzEcSMaVc2L/wvPq4RzuJbsTt2S/TYqf97Snuk5mKksT+v6K4N0ImgmjECgcHTZ/s5JFKV2RWOm/fY0B6pukEEY0rktbNCSUDhhrl6lcJMH97ngST9hVP3uv0v0M4jPktuB7Tz7Me10QUpPz5Z9wcIoor7YNo3IYBD3b71f35i1w2aj6DkCTxdwLg5AQMo82XfGgDYQL/5j0cjo26MtrP53c7Qg5RMekLG3T7unrDg+CRPdCzIKNZUEekhZkG2L5qLcYGHoSKrDr38js= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 58befb58-9e51-46c8-9b0e-08d7572f55c6 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Oct 2019 20:35:11.2691 (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: 4OQMKXQEBLJkJyM2lZqFGZsYXs3Q2PQ5y/+QY1qPVogTj6tz8sVOKrgYNaHPUEQZ9I6GadVhPlz0cacwl/LJ0g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR12MB2724 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/20191018153114.39378-4-Yazen.Ghannam@amd.com 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 df7dd9604bb2..2d8129c8d183 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, @@ -3400,29 +3408,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; @@ -3475,14 +3467,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); @@ -3667,8 +3653,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 Tue Oct 22 20:35:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 11205343 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 D72211895 for ; Tue, 22 Oct 2019 20:35:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B4A7821906 for ; Tue, 22 Oct 2019 20:35:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="foSoNi3o" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731110AbfJVUfY (ORCPT ); Tue, 22 Oct 2019 16:35:24 -0400 Received: from mail-eopbgr790088.outbound.protection.outlook.com ([40.107.79.88]:26304 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2388799AbfJVUfX (ORCPT ); Tue, 22 Oct 2019 16:35:23 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LgoOEzdNyXlD5aY3+9W3ESwtcnIkMC8e2jr7cO71lrOnRV4K6npBj6dp4s4ZYnOPpGafB8WzqvCnVHDTXb/C6YBWHRzMxj2bUypNJIQNud0WNPl+FihUcDuY5QDK7NffZDgpBRqn65w+rUj2gjCRQV+GW6E3/ErJ6hqmB7U9fkmEQkDeKBtdND8ioDYVKkwCe9C9heSsADJoSR6JWun14PZsQrwGbzvQswnc2KD8nQmHnBeV0MFXH66qCq++PEp11SRAtVRvaF3oBqND6Jt+Tzyr/yQifoY99s5/8l46IZgXw4UZPd/3sjSRTqgf/4ZoPkXWU8sVtfpISF6vXBSPpQ== 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=TihJG6dFmN5GD0edAU7KW6s+D7DH1wOrhZOcyziEIU0=; b=cWtFd2PtuVxOOaHVwfS/akQq+BOEtJ/+in2xHrcNj9pP6rp4qoKZPHM6mwVR+RzMkNtdo374F2xMGRKU5x3ELPLLa2wJVQk47SG/wXPPrqb/8AvbuJxDwg84kdf4qVfnZ2evrIMFSfxGfnLx126zlf38g0LqeUK5b+6GGnQJqgPwHMcg+nK1999OLzAHU2Tfcr3w8F0S9Wb7bAIo3u4TphXaSIHzD8WoqyoKY8YDyh43eTmIcVc+ik1b5eHlHcYnNEwuFsGSAXxJ7IJQJHqpYGqqL0TyKCMDNFvHlWWbEyRcJHd+0uiG3WwvOgq4lKEZgOASHS9RdkyqI6fX1luvrA== 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=TihJG6dFmN5GD0edAU7KW6s+D7DH1wOrhZOcyziEIU0=; b=foSoNi3oOHQpU0JiBgFDZ4ar94vnsZ1dfB7Ahp1fuXOIDrEz1hwFsjVAC01dptUaBPhDvim21nemiK+cOAyhDxVThBt5mlSJuf2w2z++dLWp4fp5nw7Ndvo3JBsmunUT4X4+wGWBdzlO2H+EVditkQUXhcMVt4dJ3nGks+1CPzo= Received: from BN7PR12MB2628.namprd12.prod.outlook.com (20.176.178.20) by BN7PR12MB2724.namprd12.prod.outlook.com (20.176.178.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2367.24; Tue, 22 Oct 2019 20:35:12 +0000 Received: from BN7PR12MB2628.namprd12.prod.outlook.com ([fe80::2115:dffc:44b6:e53a]) by BN7PR12MB2628.namprd12.prod.outlook.com ([fe80::2115:dffc:44b6:e53a%6]) with mapi id 15.20.2347.029; Tue, 22 Oct 2019 20:35:12 +0000 From: "Ghannam, Yazen" To: "linux-edac@vger.kernel.org" CC: "Ghannam, Yazen" , "linux-kernel@vger.kernel.org" , "bp@alien8.de" Subject: [PATCH v2 4/6] EDAC/amd64: Use cached data when checking for ECC Thread-Topic: [PATCH v2 4/6] EDAC/amd64: Use cached data when checking for ECC Thread-Index: AQHViRgzqUXQe6JrSUGwHvuLMkPd5g== Date: Tue, 22 Oct 2019 20:35:12 +0000 Message-ID: <20191022203448.13962-5-Yazen.Ghannam@amd.com> References: <20191022203448.13962-1-Yazen.Ghannam@amd.com> In-Reply-To: <20191022203448.13962-1-Yazen.Ghannam@amd.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: SN4PR0501CA0024.namprd05.prod.outlook.com (2603:10b6:803:40::37) To BN7PR12MB2628.namprd12.prod.outlook.com (2603:10b6:408:30::20) 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: dc1e556a-bd72-4df2-3be6-08d7572f563f x-ms-traffictypediagnostic: BN7PR12MB2724: x-ms-exchange-purlcount: 1 x-ld-processed: 3dd8961f-e488-4e60-8e11-a82d994e183d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3513; x-forefront-prvs: 01986AE76B x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(4636009)(396003)(39860400002)(136003)(366004)(346002)(376002)(189003)(199004)(25786009)(36756003)(54906003)(316002)(2906002)(256004)(66066001)(6916009)(52116002)(71200400001)(71190400001)(76176011)(2351001)(2501003)(6116002)(26005)(99286004)(186003)(6512007)(4326008)(6436002)(966005)(1076003)(102836004)(305945005)(5640700003)(7736002)(6486002)(386003)(6506007)(6306002)(14454004)(3846002)(478600001)(2616005)(486006)(476003)(8936002)(66446008)(11346002)(446003)(50226002)(66476007)(81166006)(66556008)(64756008)(8676002)(81156014)(5660300002)(86362001)(66946007);DIR:OUT;SFP:1101;SCL:1;SRVR:BN7PR12MB2724;H:BN7PR12MB2628.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: wV2eUPRmMfqpB4eaACiNWDzB/NLGYj1ZPxHlpHeXbJhWWX3foqhOOARx1qu0mFtV3WqFGTbNRtwjoSi44QLM45W+AizJorpmLkpjonrngfvrnVOUBfJ75/co5HTUB9h/NSvmp26FACsJN2iKCGhA4QoxA0sQPfYJZvyFar2II4xGCPqI1ufgEhnE+NIa6js9ucyHQd8CyMc1ZzmUizkZzGqUCYuqaOjxZTGRFkexqqggLX4EGRyEBBwR7bq+Kjc+QGw71Hre9ta0QNFj8sBBW45IX4VYHNSh6qMAsJkk+9HhGhyVs7ThOGSiXMWOJHEZ+SgFJ/HpE9Yz4Uc7Mji+6lngPYQscg6b350K9g+tZEazW6dsJRVSBzSjWJWxptFMSQgm1AdlkqRR9cJzms6np3my8vCcAgKpr94la0CAdtxEgUd7yQGQaETNBWiXtJU5RewQ2nG+WoUoQ6/+AfI06yOHp6QqVOMcHm0p4XLE5Q8= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: dc1e556a-bd72-4df2-3be6-08d7572f563f X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Oct 2019 20:35:12.1616 (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: KWIyBJQnfbjoB9ss8MMrmLGSTLlaxglN5BTVuQ2vC/o58kArukLu0BRZssKl+KzsffAeZE1j8xtFOsgjfWmjxA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR12MB2724 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/20191018153114.39378-5-Yazen.Ghannam@amd.com 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 2d8129c8d183..6b6df53e8ae7 100644 --- a/drivers/edac/amd64_edac.c +++ b/drivers/edac/amd64_edac.c @@ -3200,31 +3200,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); } @@ -3237,7 +3233,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); @@ -3522,7 +3518,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 Tue Oct 22 20:35:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 11205341 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 94AB2913 for ; Tue, 22 Oct 2019 20:35:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 69B1321925 for ; Tue, 22 Oct 2019 20:35:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="l7IRJ3GO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732995AbfJVUfZ (ORCPT ); Tue, 22 Oct 2019 16:35:25 -0400 Received: from mail-eopbgr790088.outbound.protection.outlook.com ([40.107.79.88]:26304 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2389525AbfJVUfY (ORCPT ); Tue, 22 Oct 2019 16:35:24 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lKDUFYpGv+peMVNFAUfHMVqkPXxt/TbnSgVIrPYSv3soqUPamUSJVvm2/IrFZaEa6Df5B914/bJdK4c6RPQQUnYW0flOKmf3G1GBBy60/7McWcLBeqDcVF/Pb/VhXNBAtoxX3GM+/E6pxWVBJSg3sC9r60u/cWyfnflC2Qj64jmHLG7PnUHKsUiaMlnCvnWwACRbS79Q3ZcQMH/c8v2SySvn4jMppg0psbs8kiGH/ge8oV1I9+9R4595D2l5FYFGwaqavjKp1Fafzw89dHwI2A8n5eI4hX6xrrA4jyt3Dw6Zu+N8fr02wHu8NfwbEQQVGZT5k1cbUVhMK+1ALE1qAw== 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=M6mVHruVvrlSgNK5fP1y4irI0RNe/7mYnoODfU6YX+0=; b=a6Bq0RxJQcFViIQCMobWI90QZK9yvhlU1s+8xEM3VN+Z7WAQ8Eh2YOItW2UUe8/34pefW6nab+sCfsQPLLJJPBl1XfA6+7hn6V13NBveyeTLFMWqmpdGMIn0USAwX28WpoCW2ow9Ns9v57EMtvCqbwp3fzYmv3X0jas+HnBetVh5l/gdl4YmnpJn06O0Y1Zu8IwXdGAHdZ9b/fnIOlvoVaoZOvh69pqU1zNorsIWjQRUl4p0Y6tZLqAnCu2qT1ZAJxT1yQD5EYGCoAHL/Sa0fbn+4lKQfjSjWBv3+TvstAo/puR39QE75lGNy39EMHR2HKv2OtALStB2aY6s0rGviw== 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=M6mVHruVvrlSgNK5fP1y4irI0RNe/7mYnoODfU6YX+0=; b=l7IRJ3GONiZbTe8wQWzG3bpbiOOG8mfidmdN9cvtVIUyx3RkMVtsVrQil0cyGB7+azC8AUMw2OxzDw7I9HhUtOQoBrgNt7eNrpL03Nn0hBH8lf/HE6afusmr46tZ9zpxpfJhCliX6wws6cif4TWNvS3lXVYST209g+dG/pJsQyU= Received: from BN7PR12MB2628.namprd12.prod.outlook.com (20.176.178.20) by BN7PR12MB2724.namprd12.prod.outlook.com (20.176.178.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2367.24; Tue, 22 Oct 2019 20:35:13 +0000 Received: from BN7PR12MB2628.namprd12.prod.outlook.com ([fe80::2115:dffc:44b6:e53a]) by BN7PR12MB2628.namprd12.prod.outlook.com ([fe80::2115:dffc:44b6:e53a%6]) with mapi id 15.20.2347.029; Tue, 22 Oct 2019 20:35:13 +0000 From: "Ghannam, Yazen" To: "linux-edac@vger.kernel.org" CC: "Ghannam, Yazen" , "linux-kernel@vger.kernel.org" , "bp@alien8.de" Subject: [PATCH v2 5/6] EDAC/amd64: Check for memory before fully initializing an instance Thread-Topic: [PATCH v2 5/6] EDAC/amd64: Check for memory before fully initializing an instance Thread-Index: AQHViRg0iEJ85ugwuE2Gps0HSGXHgQ== Date: Tue, 22 Oct 2019 20:35:13 +0000 Message-ID: <20191022203448.13962-6-Yazen.Ghannam@amd.com> References: <20191022203448.13962-1-Yazen.Ghannam@amd.com> In-Reply-To: <20191022203448.13962-1-Yazen.Ghannam@amd.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: SN4PR0501CA0024.namprd05.prod.outlook.com (2603:10b6:803:40::37) To BN7PR12MB2628.namprd12.prod.outlook.com (2603:10b6:408:30::20) 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: 31b1de93-726a-4e5f-7714-08d7572f56d3 x-ms-traffictypediagnostic: BN7PR12MB2724: x-ms-exchange-purlcount: 1 x-ld-processed: 3dd8961f-e488-4e60-8e11-a82d994e183d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8882; x-forefront-prvs: 01986AE76B x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(4636009)(396003)(39860400002)(136003)(366004)(346002)(376002)(189003)(199004)(25786009)(36756003)(54906003)(316002)(2906002)(14444005)(256004)(66066001)(6916009)(52116002)(71200400001)(71190400001)(76176011)(2351001)(2501003)(6116002)(26005)(99286004)(186003)(6512007)(4326008)(6436002)(966005)(1076003)(102836004)(305945005)(5640700003)(7736002)(6486002)(386003)(6506007)(6306002)(14454004)(3846002)(478600001)(2616005)(486006)(476003)(8936002)(66446008)(11346002)(446003)(50226002)(66476007)(81166006)(66556008)(64756008)(8676002)(81156014)(5660300002)(86362001)(66946007);DIR:OUT;SFP:1101;SCL:1;SRVR:BN7PR12MB2724;H:BN7PR12MB2628.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: ULNF4jVRwagW9Kls/WLl/YvaNtNVGJ2Nu/SBafi68ycTB4ojSIlZWWNPnkWjAY8kNEVNjEp3DftpWgrJ4k5o2w6+F9LAS9u4sIrtizAXQoqHkvxiBnRpsxKZwWxOnHLFnCaOXQsKnyMjwoZzOvTzmFdWtzA5heGcwLE44aoNxYG/P7+2hNO8pnrl3eTF+FocsVzcRYwyFPJLWS5o33gVFzQDi66EcQ3/u/fnBb92D5oPRcIGXEQTE8L1MLGE1SJRuUbSF+sRhLhZN9OLNd7L+Tu0nKP/wqsO4ClqJfL8PVSD/W2OgJbh/yuzr/2+lAbZzfzSZMEvkfJTRY0h/B6Clu4h724AebWvbz507o+y9wP/utbHRTc1TW9Ro2tfVuD8KSi26EtIcgVBdknLrTjTWj9suOaY6YG3NoEFBzVL5WAx7tbb0yO72gMVJ1ISCFPNiKss8cNvCEynGzjP07pPt6NgaqzjqPd82ISepoVPr6c= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 31b1de93-726a-4e5f-7714-08d7572f56d3 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Oct 2019 20:35:13.1790 (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: l88VY4K0oL3IjT+jpfVfevNDsGK6KwYhfetzNwfUgCeslovxrNSM0EdNEFQyf63+Gf1y6jwiDtS3Z+Se16mUHw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR12MB2724 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. Signed-off-by: Yazen Ghannam --- Link: https://lkml.kernel.org/r/20191018153114.39378-6-Yazen.Ghannam@amd.com 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 | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c index 6b6df53e8ae7..114e7395daab 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); } /* @@ -3489,6 +3487,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; @@ -3518,6 +3529,12 @@ 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; @@ -3544,6 +3561,8 @@ static int probe_one_instance(unsigned int nid) goto err_enable; } + dump_misc_regs(pvt); + return ret; err_enable: From patchwork Tue Oct 22 20:35:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 11205347 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 A254A14ED for ; Tue, 22 Oct 2019 20:35:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7F90B2184C for ; Tue, 22 Oct 2019 20:35:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="vnu0RBzw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731226AbfJVUfT (ORCPT ); Tue, 22 Oct 2019 16:35:19 -0400 Received: from mail-eopbgr790088.outbound.protection.outlook.com ([40.107.79.88]:26304 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2388799AbfJVUfS (ORCPT ); Tue, 22 Oct 2019 16:35:18 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SLLTZ0+CH/Ek7YlKWXhWl31aO5ox/RUqYzmwrgTMic03dK1VgwxSQMXaBYFKl0gjg5aT09nC+eVFZrbLz9j6slls2vPwnR0n3FIZy7pDbXDYq8lFci8KaTtF9r3XdOv9ziLP+aX7t6/PjV/9XYywmske8se5LFY33AHqDnzxwtSB7bx/Kv62zcJkJjKbEn/YuJhEuE7uleaz3Qd9eo7dM5I1F0LKnGGQ8npPkVCTNh2qwjpLuiTNivf2Euv/WhgQwOMZ3Mu1Sv5tneMkc4Gde7QenHVjA0q9Ik2155MmaGzhxO1TttM/siciZxQ+pg1046KZtcB/Uc+bDyf/CaaB5Q== 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=UhvSniPJqHhCkbX/6S4WV/74EbWc5MQVRBlQayYM7eo=; b=Yf0CfId+baBs5Ibd+QETDzktrIlB2o5mgHXn+pSagOEzOiyMinRf+Z2pJl4YC4bFm2bDOWlq1oMS7YM02qoGl+BBB0FHM2kYKvtgTmUFyKTsnpJe5MnkjJuoMRjyhJBrPKV0ekDGPgFFqpv6VCl36G4fWm+LJtxbqjE/pA38AjJgpYHGLNcrN8q8D6u357ldGvSTyMMva9Y7FtJ9YpuPmEroDBTH6aJzVd1PGAblFZS8y8FKIawUlCbthXWi8bdw9PGCpJj85kYBfhWlRMARFSIMjt1ZdjdBMHf8Q5/4G0EmQxk0VMG1xIJ79eSaNQc+vXxARudYIXoHGmvAitvAjA== 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=UhvSniPJqHhCkbX/6S4WV/74EbWc5MQVRBlQayYM7eo=; b=vnu0RBzw3mozl+/0fVlgO9KRsEa8wTq/UqcnuILmCPl0IzsGrLH1xbjBRn2xjK2GZY4VpQzjq8l954l9Z6IMAa/iGXbgnoAzSOjnp3sNL17HhJclp8q6lpTIpMJpkJtYL0F/JV//DHFumEvGhvrzJNjao6kDlEoHpJNMMa48G8o= Received: from BN7PR12MB2628.namprd12.prod.outlook.com (20.176.178.20) by BN7PR12MB2724.namprd12.prod.outlook.com (20.176.178.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2367.24; Tue, 22 Oct 2019 20:35:14 +0000 Received: from BN7PR12MB2628.namprd12.prod.outlook.com ([fe80::2115:dffc:44b6:e53a]) by BN7PR12MB2628.namprd12.prod.outlook.com ([fe80::2115:dffc:44b6:e53a%6]) with mapi id 15.20.2347.029; Tue, 22 Oct 2019 20:35:14 +0000 From: "Ghannam, Yazen" To: "linux-edac@vger.kernel.org" CC: "Ghannam, Yazen" , "linux-kernel@vger.kernel.org" , "bp@alien8.de" Subject: [PATCH v2 6/6] EDAC/amd64: Set grain per DIMM Thread-Topic: [PATCH v2 6/6] EDAC/amd64: Set grain per DIMM Thread-Index: AQHViRg118VjawBx7USLkrvdKMSY1w== Date: Tue, 22 Oct 2019 20:35:14 +0000 Message-ID: <20191022203448.13962-7-Yazen.Ghannam@amd.com> References: <20191022203448.13962-1-Yazen.Ghannam@amd.com> In-Reply-To: <20191022203448.13962-1-Yazen.Ghannam@amd.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: SN4PR0501CA0024.namprd05.prod.outlook.com (2603:10b6:803:40::37) To BN7PR12MB2628.namprd12.prod.outlook.com (2603:10b6:408:30::20) 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: 45b51806-4e25-4131-49ec-08d7572f576a x-ms-traffictypediagnostic: BN7PR12MB2724: x-ms-exchange-purlcount: 1 x-ld-processed: 3dd8961f-e488-4e60-8e11-a82d994e183d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:240; x-forefront-prvs: 01986AE76B x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(4636009)(396003)(39860400002)(136003)(366004)(346002)(376002)(189003)(199004)(25786009)(36756003)(54906003)(316002)(2906002)(14444005)(256004)(66066001)(6916009)(52116002)(71200400001)(71190400001)(76176011)(2351001)(2501003)(6116002)(26005)(99286004)(186003)(6512007)(4326008)(6436002)(966005)(1076003)(102836004)(305945005)(5640700003)(7736002)(6486002)(386003)(6506007)(6306002)(14454004)(3846002)(478600001)(2616005)(486006)(476003)(8936002)(66446008)(11346002)(446003)(50226002)(66476007)(81166006)(66556008)(64756008)(8676002)(81156014)(5660300002)(86362001)(66946007);DIR:OUT;SFP:1101;SCL:1;SRVR:BN7PR12MB2724;H:BN7PR12MB2628.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: 9swULN8TSv3ssNx4y4InDi9/ysK3jSsCj0c3oJV0GygVHMRfKuvz3dClvKP5BY8ORnZhAFntlKhFl5C/Bh3euOkM0a7xX0S3rN4HxJfUs3X6xt1A0ibthX8Nu5f7n74Q90WTvUFXCKa8a6nax6Ex+yO5tIUUITP78kf/WHASje3E7R+uMupa54uYXPJbIomTkXr/EYGKUqfj5XOwmfvaCvbFx2cV7LRFBmaX29E0bCnzqmIRF1Etgzchq6Qk/opzcWMy/BoDRficmZWWTu5kT30sSGS+PSE1fZF3Dh5ayTaGtBDEzK7DaugO01FXZyBl732pk9ihdaz4pdTXLbvcdMkJdMJzGWHB7XRjbnoBhTBC5DFGSoatH+LAYCJmlNabTBD1/hvpCZfrrLkdPgYYg2iUJWv47vpGhJEHClngtLPqrfFkrEfJ8jKISYyA2A9C5V0qLTKaRQeRG50O1Gw0b9AJ/KWNgGgK8+k159e3WuI= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 45b51806-4e25-4131-49ec-08d7572f576a X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Oct 2019 20:35:14.2624 (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: xl2GYBZEpunrLh/nujQtmjSxtXhVk6FzBUOMYDXCcTegSf6pXIZHqcPdBN7iG/ckpGcoqwVKbsKE3gN5d9LjTg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR12MB2724 Sender: linux-edac-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org From: Yazen Ghannam The following commit introduced a warning on error reports without a non-zero grain value. 3724ace582d9 ("EDAC/mc: Fix grain_bits calculation") The amd64_edac_mod module does not provide a value, so the warning will be given on the first reported memory error. Set the grain per DIMM to cacheline size (64 bytes). This is the current recommendation. Fixes: 3724ace582d9 ("EDAC/mc: Fix grain_bits calculation") Signed-off-by: Yazen Ghannam --- Link: https://lkml.kernel.org/r/20191018153114.39378-7-Yazen.Ghannam@amd.com v1 -> v2: * No change. rfc -> v1: * New patch. drivers/edac/amd64_edac.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c index 114e7395daab..4ab7bcdede51 100644 --- a/drivers/edac/amd64_edac.c +++ b/drivers/edac/amd64_edac.c @@ -2944,6 +2944,7 @@ static int init_csrows_df(struct mem_ctl_info *mci) dimm->mtype = pvt->dram_type; dimm->edac_mode = edac_mode; dimm->dtype = dev_type; + dimm->grain = 64; } } @@ -3020,6 +3021,7 @@ static int init_csrows(struct mem_ctl_info *mci) dimm = csrow->channels[j]->dimm; dimm->mtype = pvt->dram_type; dimm->edac_mode = edac_mode; + dimm->grain = 64; } }