Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755911AbcCBPwh (ORCPT ); Wed, 2 Mar 2016 10:52:37 -0500 Received: from mail-bn1bon0059.outbound.protection.outlook.com ([157.56.111.59]:35872 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755715AbcCBPwc (ORCPT ); Wed, 2 Mar 2016 10:52:32 -0500 Authentication-Results: spf=none (sender IP is 165.204.84.221) smtp.mailfrom=amd.com; alien8.de; dkim=none (message not signed) header.d=none;alien8.de; dmarc=permerror action=none header.from=amd.com; X-WSS-ID: 0O3F5FD-07-YJT-02 X-M-MSG: Subject: Re: [PATCH 2/3] x86/mce/AMD, EDAC: Simplify SMCA decoding To: Borislav Petkov References: <1456785179-14378-1-git-send-email-Aravind.Gopalakrishnan@amd.com> <1456785179-14378-3-git-send-email-Aravind.Gopalakrishnan@amd.com> <20160302105032.GC16954@pd.tnic> <20160302105353.GE16954@pd.tnic> CC: , , , , , , , , , , , , , , From: Aravind Gopalakrishnan Message-ID: <56D70C37.1090902@amd.com> Date: Wed, 2 Mar 2016 09:52:23 -0600 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <20160302105353.GE16954@pd.tnic> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.180.168.240] X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:165.204.84.221;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(2980300002)(428002)(164054003)(377454003)(189002)(199003)(479174004)(86362001)(59896002)(5004730100002)(83506001)(5008740100001)(11100500001)(105586002)(106466001)(19580405001)(19580395003)(80316001)(81156010)(65816999)(189998001)(110136002)(23676002)(77096005)(2950100001)(50986999)(76176999)(92566002)(54356999)(87266999)(230700001)(4001350100001)(64126003)(586003)(6116002)(3846002)(87936001)(5001960100004)(1220700001)(1096002)(4326007)(2906002)(36756003)(93886004)(50466002)(47776003)(101416001)(33656002);DIR:OUT;SFP:1101;SCL:1;SRVR:SN1PR12MB0861;H:atltwp01.amd.com;FPR:;SPF:None;MLV:sfv;MX:1;A:1;LANG:en; X-MS-Office365-Filtering-Correlation-Id: 4d634e35-04c3-45d6-c886-08d342b2a8a3 X-Microsoft-Exchange-Diagnostics: 1;SN1PR12MB0861;2:oOcs1SgZdN1EOENF1AOQtYPibo4/pxxjrXJgT4DSRDUdDdvxF7nC3m+hsGJfuDpLqEWU4yZGnMDzvhm7ktY+QdUZxZC+Aw2WtnArd4N6jQIftu63pOnl92RxntpQUeYNQ4+5u6JYrariMq7aVC+hDOxecaYuY//SYlEAnO5CqMTCr2thIA32nVbsp1IuZmdO;3:t7ecZvAmjND5QnTUlR2NNeHppNv/0Aw/6/YGhY/UKi1KY78KEsn2485nwtbLs87xVKLZVEcq64QxpOwh0gz8MBms749mZlup82dIXsGA9P24/RDpjkgAeNwgQazhlI5EYeoiH8OXkZhSXRfG7/enVx8156f1MxH6uLZUecO17LSJIekTgwPARGb7TTmJJN9mCw+2GrHTVCOWfuwjgoxjp6/6HrxuWgZQgkBFt1oy8Mo=;25:XFs9EpteIku/X0Aw+qt1grCH+bhwdykwYld6wWkmTCZXhcjNd1/uU5lAILjdEkLLHbNcj1YlknqMD9MtD4KO8ZzMemwW5RKWypM4kWaAUnRVbVkrRGlcWPOX/KJwa56tuTZaTGesQtRfVdRXmgJOIXj0lPDZb/mBG/d/yk0TqBSTmHvZeoqtLCHbQCzN5x2NEw57p8pNiyWD9LKrsRhkY3lvo7LZGyVpzBb1s+CaNSGU6HLkNQ0gxt9wclbwvkTodkyb/lloJuzWPMP4OgfopGU5W9QyqXjedJKlMZ6f3ynU4AE9XXb8dmDCjdgl5bDj+8yLvPF/HgflfmFfj2S6EQ== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SN1PR12MB0861; X-Microsoft-Exchange-Diagnostics: 1;SN1PR12MB0861;20:9/oajbn9fYriH2vEDBjL+XGq5ebne3sPOe7fxJGJmmYu3KXGba/FCfqf7UHlgsD+EL8GyHFgSgdz0DZcF3lcTk/EI16E10eosrwRR5FI+yBQbZ5HcFCtxcrmlzdk6NytT82kyokJf/vNyBMwYYvrofrhXXM8SnTnPG0cOHQeLZuomGaIqEIePig97g7xtxHteGUcUw7oWyRwc3E5g3lp/TChrDts++EHRajx6l+RGdXUNk1AkNjFe+ftiREEuDzbghm53jFs2wL/F6zaMNZ8EBt5fmkVeUaofVRI69DxGp+txtBUQ1jtWkmmUiXdwsYdBCmUfDD5Dbxk0lSiBieXCRvh0kSjcgfzngwUv+Sd8QD/a3sKLDmP7ZGPCOe7xfPZKTxPsd+wN9j3oDoIh1zftKvDFzYmhIoSYDJlXQI77998tia3uDwLdNkCOvhrIc9qlMF3CtLUClKKvwA+kLBFQHZ1LZxDpXK6WxsCfKCHA7+jN1oBEEgz2gFSKawsMxbK X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(13015025)(13017025)(13023025)(13024025)(5005006)(8121501046)(13018025)(3002001)(10201501046);SRVR:SN1PR12MB0861;BCL:0;PCL:0;RULEID:;SRVR:SN1PR12MB0861; X-Microsoft-Exchange-Diagnostics: 1;SN1PR12MB0861;4:9srhP1qiGdH6vDPAa+BdFmbfqzrbmykyBDXYcYVCkaOXqsgdkuL+XrnUouBPbbT+l5ULhRGNhHyuuMJTjb0CICfXpfKKui6/UzT0jcXvG8yPDV97BXsW4btwV6ktWBlZlGdHqaYRcAcaXJFLi2Nsn6uCgRzjewhrlUnky+Xx2A+Z/bnfk1zNvoTENCvn9risCgIbOsb8bpOKMlWes6y9V5x/UxChVm7ylUsAJtMjDl6gCDfN+7IJQNNsj5e/D9aa881+269NFWF3AaIRmy+f8LMAGH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JZDZMODkwcm9uVFZX?= =?utf-8?B?SnJLQVRwN1daaFFMaDIvZ1A0dkFhUWlJSGRaakY3QmVqTnNIaFh4di9peG5i?= =?utf-8?Q?bCDAk1lB8Ovvz8v419xxq7F4ZDPqmBJMuhSoekn?= X-Microsoft-Exchange-Diagnostics: 1;SN1PR12MB0861;5:mg6eQfBVq2lWSU5qzFGBIj9dFiAsF8fCXR/41zuD6qw7s3j96EgCVxn0estuJ1jZ9J+Rnt7qnTMsY1GP/17PxImGX5z+zB0A+m66Z/MtXND165oixbN4sUcvlEioTF9is9bUM5IxX6IA3z9fnZaKPA==;24:6nNItVzJXOZiSqwsLDwyfQrvI+l2ni6859FXgiX6yT5L2TPT2Vp/zVzc5hFtpL5kJuSQLy9bZ3fKrlf2XTXZzVzoYURZWAKU5w2yrYfEErU=;20:7X0sFaG2KZPX7t57Qnihzg6m1l2Ge8w1cUWAMfFozTSECgUB63j28gC0Gu7iJ5HL4WCSWllRuHi2pOqVsury2I7m1+gCbhV6KlAQm9LiclW4GznAgDSVJM+tqnj74wgkvjsg1I3smLhsfn0bKre13Sobd8zdMuEP2oV4OupOphTQYFObC3xIc349q8xnJp7eEWuIsd6a07rZuyrycxWQNa5zuOaKMPtyvtFFyXtl6b6VU6KRVfwm7m0sPfHXokFR SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2016 15:52:27.6539 (UTC) X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.221];Helo=[atltwp01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0861 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5337 Lines: 166 On 3/2/2016 4:53 AM, Borislav Petkov wrote: > Merge all IP blocks into a single enum. This allows for easier block > name use later. Drop superfluous "_BLOCK" from the enum names. > > Signed-off-by: Borislav Petkov > Cc: Aravind Gopalakrishnan > > enum amd_ip_types { > - SMCA_F17H_CORE_BLOCK = 0, /* Core errors */ > - SMCA_DF_BLOCK, /* Data Fabric */ > - SMCA_UMC_BLOCK, /* Unified Memory Controller */ > - SMCA_PB_BLOCK, /* Parameter Block */ > - SMCA_PSP_BLOCK, /* Platform Security Processor */ > - SMCA_SMU_BLOCK, /* System Management Unit */ > + SMCA_F17H_CORE = 0, /* Core errors */ > + SMCA_LS, /* - Load Store */ > + SMCA_IF, /* - Instruction Fetch */ > + SMCA_L2_CACHE, /* - L2 cache */ > + SMCA_DE, /* - Decoder unit */ > + RES, /* - Reserved */ > + SMCA_EX, /* - Execution unit */ > + SMCA_FP, /* - Floating Point */ > + SMCA_L3_CACHE, /* - L3 cache */ > + > + SMCA_DF, /* Data Fabric */ > + SMCA_CS, /* - Coherent Slave */ > + SMCA_PIE, /* - Power management, Interrupts, etc */ > + > + SMCA_UMC, /* Unified Memory Controller */ > + SMCA_PB, /* Parameter Block */ > + SMCA_PSP, /* Platform Security Processor */ > + SMCA_SMU, /* System Management Unit */ > N_AMD_IP_TYPES > }; > No, this would break the logic in EDAC. The main reason I placed it in separate enums is because the "mca_type" values map to the enum. These blocks- + SMCA_LS, /* - Load Store */ + SMCA_IF, /* - Instruction Fetch */ + SMCA_L2_CACHE, /* - L2 cache */ + SMCA_DE, /* - Decoder unit */ + RES, /* - Reserved */ + SMCA_EX, /* - Execution unit */ + SMCA_FP, /* - Floating Point */ + SMCA_L3_CACHE, /* - L3 cache */ have the same hwid value (0xb0). But they differ in mca_type values. And in exactly that order. (LS is mca_type 0, IF is mca_type 1 and so on..) So, after we get mca_type value from the MSR (mca_type = (high & MCI_IPID_MCATYPE) >> 16), We check for LS (=0) or IF (=1) ... With this change, LS block is assigned 1 due to the ordering in enum. And this logic applies to "DF" block as well. (whose component blocks are "coherent slave" and "pie" which have mca_type values of 0 and 1 respectively) "DF" and "F17h_core" are essentially parent blocks and CS, PIE, LS, IF etc are children. hwid indicates the parent, mca_type indicates the child.. > > > /* Define HWID to IP type mappings for Scalable MCA */ > -struct amd_hwid amd_hwid_mappings[] = > -{ > - [SMCA_F17H_CORE_BLOCK] = { "f17h_core", 0xB0 }, > - [SMCA_DF_BLOCK] = { "data fabric", 0x2E }, > - [SMCA_UMC_BLOCK] = { "UMC", 0x96 }, > - [SMCA_PB_BLOCK] = { "param block", 0x5 }, > - [SMCA_PSP_BLOCK] = { "PSP", 0xFF }, > - [SMCA_SMU_BLOCK] = { "SMU", 0x1 }, > +struct amd_hwid amd_hwids[] = > +{ > + [SMCA_F17H_CORE] = { "F17h core", 0xB0 }, > + [SMCA_LS] = { "Load-Store", 0x0 }, > + [SMCA_IF] = { "IFetch", 0x0 }, > + [SMCA_L2_CACHE] = { "L2 Cache", 0x0 }, > + [SMCA_DE] = { "Decoder", 0x0 }, > + [SMCA_EX] = { "Execution", 0x0 }, > + [SMCA_FP] = { "Floating Point", 0x0 }, > + [SMCA_L3_CACHE] = { "L3 Cache", 0x0 }, > + [SMCA_DF] = { "Data Fabric", 0x2E }, > + [SMCA_CS] = { "Coherent Slave", 0x0 }, > + [SMCA_PIE] = { "PwrMan/Intr", 0x0 }, > + [SMCA_UMC] = { "UMC", 0x96 }, > + [SMCA_PB] = { "Param Block", 0x5 }, > + [SMCA_PSP] = { "PSP", 0xFF }, > + [SMCA_SMU] = { "SMU", 0x1 }, > }; > -EXPORT_SYMBOL_GPL(amd_hwid_mappings); > +EXPORT_SYMBOL_GPL(amd_hwids); > These strings are what I intend to use for the sysfs interface. So, I am not sure if "PwrMan/Intr" would work when I need to create the kobj.. Also, the legacy names use snake_case- static const char * const th_names[] = { "load_store", "insn_fetch", "combined_unit", "", "northbridge", "execution_unit", }; So, I think we should continue this approach and have something like this- static const char * const amd_core_mcablock_names[] = { [SMCA_LS] = "load_store", [SMCA_IF] = "insn_fetch", [SMCA_L2_CACHE] = "l2_cache", [SMCA_DE] = "decode_unit", [RES] = "", [SMCA_EX] = "execution_unit", [SMCA_FP] = "floating_point", [SMCA_L3_CACHE] = "l3_cache", }; static const char * const amd_df_mcablock_names[] = { [SMCA_CS] = "coherent_slave", [SMCA_PIE] = "pie", }; (Split arrays again because I feel it'd be better to have arrays ordered according to mca_type values) Expanding "df" to "data_fabric" and "pb" to "param_block" is fine with me. > > > if (xec > len) { > - pr_cont("Unrecognized error code from %s MCA bank\n", ip_name); > + pr_cont("Unrecognized error code from %s MCA bank\n", amd_hwids[mca_type].name); This wouldn't work because of the mca_type ordering as mentioned above. (Or it should be amd_core_mcablock_names[mca_type]) > > if (xec > len) { > - pr_cont("Unrecognized error code from %s MCA bank\n", ip_name); > + pr_cont("Unrecognized error code from %s MCA bank\n", amd_hwids[mca_type].name); > return; > } > Ditto. > > > - pr_emerg(HW_ERR "%s Error: ", ip_name); > + ip_name = amd_hwids[mca_type].name; This should be amd_hwids[i].name We shouldn't be using mca_type value as index.. Thanks, -Aravind.