From patchwork Fri May 7 19:01:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 12245077 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60665C433ED for ; Fri, 7 May 2021 19:01:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3AFA261404 for ; Fri, 7 May 2021 19:01:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229662AbhEGTC5 (ORCPT ); Fri, 7 May 2021 15:02:57 -0400 Received: from mail-co1nam11on2077.outbound.protection.outlook.com ([40.107.220.77]:61345 "EHLO NAM11-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229645AbhEGTC4 (ORCPT ); Fri, 7 May 2021 15:02:56 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ne5jMXGRjQDENk1jzsLMmeK80ASgLy5sQxCCnk8aWnjq0QP8hX0wUQZygfNdfhN8t8xTdvu8K5bYToYH+qBhZmG1uktpENm/QyrOWY4q2OSCXLO+JKBQ8r4b/52CZ4lbt1w3Y+LmsPi3or4XiU1/wbkZ/bXxrOQvhukjdtvq4TMiG+TVkt8IYUNwqEWxA2XcQML+bKo0NkNoaM6atWU76qCYea0sf19uIPH8t+mRl2/MBR1EJ7NHiKe+dWlNzYFPCQoxnOnYXKrkhxzTeJHaifi7QwtC7Lzw8LSpgrY04qD5giEGIwwctexUIwdGdNVlBXlylVKphMiZ+E0w6z2Rhw== 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=pSGX2Rygmy40gWDJR73lDXcT3+k4+dSYRiP9R15XfrM=; b=YYpZO1uwN76JsPfD82iP1VMfDOlHGIf+FFjED7xWSmPBvBSbHKyNaVgHvMo9BSyS8nUNdFJ1CHvSaMMCMiabEXIFBhlkMRdI0YJ2G6NtonmcuqohpOgnnsG75anuYYSBM/bsWWcBx/H792bLSithnj9wR9fe5rXEzog93jMjZapeK/db+P9Rwq9ozSlr2wP0vaYt7EpA7kL7dNA20GRzVKLl/vsu8th7OEQ5w6TQKBEftEnqTmDeloJ1eUQIZWnKQhvZ1MtlBcDJI4cXfL9XM4XuyMj8HzwaJcM8I8UKpRgCH5lnAyOADWEAH7tpFizfymIZSzPnd7wH8lGwRIf+IA== 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=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pSGX2Rygmy40gWDJR73lDXcT3+k4+dSYRiP9R15XfrM=; b=mZl0+K2mfb2REL0t3AxXx0WQzGdVTig4Q2mWMkgvsLiBElA50ooVpNYFEdjucZcqPfpaJQRqyqJSfw0vAH9In3QIfOXxD6enrvPhqx4VvG9/iAjaAC4lttYnBJC/Gy7DcQ6S3IBczVEo93rqOb4seNPl5aW1w/T31xEACnxe5PE= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) by BN8PR12MB3073.namprd12.prod.outlook.com (2603:10b6:408:66::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25; Fri, 7 May 2021 19:01:53 +0000 Received: from BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211]) by BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211%6]) with mapi id 15.20.4108.029; Fri, 7 May 2021 19:01:53 +0000 From: Yazen Ghannam To: linux-edac@vger.kernel.org Cc: Yazen Ghannam , linux-kernel@vger.kernel.org, tony.luck@intel.com, x86@kernel.org, Smita.KoralahalliChannabasappa@amd.com Subject: [PATCH 01/25] x86/MCE/AMD: Don't use naked values for DF registers Date: Fri, 7 May 2021 15:01:16 -0400 Message-Id: <20210507190140.18854-2-Yazen.Ghannam@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210507190140.18854-1-Yazen.Ghannam@amd.com> References: <20210507190140.18854-1-Yazen.Ghannam@amd.com> X-Originating-IP: [165.204.25.250] X-ClientProxiedBy: BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) To BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from aus-x-yghannam.amd.com (165.204.25.250) by BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.3 via Frontend Transport; Fri, 7 May 2021 19:01:52 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 26732031-a034-4768-f03b-08d9118a93d7 X-MS-TrafficTypeDiagnostic: BN8PR12MB3073: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kWCa9BQ6GDk+exYV00vphKqbacchnAH2xzNCtADvwBq97YRUJQwb2c0n3I9ozohwinvidu5fN1xqS3LdjAOiclZZzouLWVpBoP5qlpKx78nKpkP8z1/XXI0ASsOvtTuqGRK0pN8wKLV0CLCy/f2MDqn/xpTXIOvlG5SKF/lhpeTjsDdEGjljlKUP6p77JmqMMe9nNlBO1kewJTtqXp2wPUfBjtpRcN8CgggwTFSm7UcccuwlbbwVJINW/Zp4o/qw36jh+TJVx9ABpT7a2ugrqQSPRT/8icdGZaNA1JbsR5jPC+ZVqDPRwTRiFf7rTlZD3U9AWrB7YAEbT7WcVEPEP1BMewigzpgYJsASVRcDCRkTR7obSgBftNwrZ58cEb1fZoAcR9vbwYo2XMSGNNRx58KfdWKsbp2bUP9gTcTpc+Ak3KVBxcsXdoUhzNBbN9tgC5Endo7P2XFGo1FfW4gkBUPFCdbg3fIiV3fOnLXbP95PZ7f9EYyr5iOFiat3ypkxZqJdeBhDfM8ToOLEdiMVnc2NJyYdhBSvJYEyaUKL9DI/SJevXdz5/2Yw73+h3QPz5wctbVtvse/Y4kp1xaQS9iTRgPG19rF6xpaeRAzTXDutwQ351PHPNiD9x1JVn6CaZesM90p52fP2y9eW4Zm2vKWRxiVfe6uRi4KdCLRwJs3W0WdOw2ULPektkbjFXaPu X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR12MB3108.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(136003)(376002)(366004)(39860400002)(396003)(346002)(316002)(6486002)(8936002)(8676002)(16526019)(2906002)(6666004)(186003)(83380400001)(26005)(6916009)(36756003)(52116002)(86362001)(66556008)(38100700002)(38350700002)(66476007)(66946007)(4326008)(5660300002)(1076003)(7696005)(2616005)(956004)(478600001)(41403002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: FjLxsSq+jAjobZ2R9aYRi8w0WkAb9ntUNqpXxaOfpTQO2yfIO5I/ThoJGhm8cucK3uFugcFcl2Q0tRIdsrj8JcbuzYXvSd2JJ5ZSS+os9YIKMq0/vNlmrFO5MSsHH43VbQ1KpHmN54pMlAGc5OueZ4SsnknLI//WF+yi/f/LASbSA4Odr2erZdvjS+D0/FVT/cUCcOTed7epnmB04pH2KO2PdSOY5jzQiYX31/jQABbgWvLQqdJrJZ3WUVFoAulyiaSPINGy5kMD5+oQceYYSACAS0YuWs37ZRl4uVDNWQLDQdED2hOLSdESAwE1l+tfC2B+WR6UnjYmjzeDeyM45GCt5PaBW/L4BxVqcmv3IxGlpdI2CqBOeldaprk/Ce9eJjM8y93HhylNf2ey6wsBWTH63pve2uZFtmpU04ps7qNdcestcAZvJaiSSLyVzhcckU+qFSyU7WG2d6OmFkw9QpdUfE+pBbpD0kYAQP1trbIze0srGI4LNSdq7c+dIDgHe6LU89RrytC4TTJFa7Rn33n92daxmkSXNW31l3rQyvd8vAPRK6uvhb568sCUYdd+LQjjAZ1nkFrHO8Ko/uWI1UsWwhi4I7cZny50LrszTu/l6cCxyx6rF2+yi5wNe7TqpYioZaRp83zcffBxFpMCYV2jJd4oEWXHVWNKl8n2KRqtvfUGhFKSvhuC13WwLc2xMCKH3COkhNHlp5/7XwFP6ZuPreJybOyloC606hfkhUvAt32dAgCTLZz8IFKvZPhCxULuTMLwMHBfRVFNyjgWDdfYwTxSgaXXrJUrbDQVo2Tvf8A+Tg4oik6zie817UiVNWkhDxrcAxcwlh5bj8sQQaLxLQ04RMsadDV4XeVw761Y155IXNG0nVQqE5X6MiK95e/rGnlH1Dt2H2zHGBEv96aAGvpfWcwEFX8himkM69Hpp90QIs+BVzVczAq990jhNwIEa6ApO1jvQw6tiJlarrm5NBtwcNlPApEhHrPApBC7U0NyYQ6xSMdPHe0Cq3gjJwcYKQJbkW2eIDz2o4rAG6rFJl3YmA4Q8O4dDIIFF4n2miFb2jk1BXD8PgaATEsuYZlzenWRePKPkda16iF4XJzbCclr+4reRMcjSJ66znm67jMG31urOc9GrzHtfDHS0Ft1mYH1gIVGhwMQv6nyzuNcULj9sxv2kk4ciNwnY2o+unv0kMAoSHDIVroO1JJ2CJ2OB9Z02RHcrT/EXLJ7/z1OLusGOPf0g7mk5QFiaMv5igTospzeTuo8Jd/UZue0hVdzVcerv3noivKufgCETh+c/KnrkgPPSAw3+5uwKA5DyY/dp5oRPKYmdX/TyYde X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 26732031-a034-4768-f03b-08d9118a93d7 X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3108.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2021 19:01:53.6395 (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: j70QGUmgy7UIgQlKK4ShPfLLau4xXufbngPxldop9tieDA+oQnF83l7UoF+9/MYqfOBjhlDZWDxVIyhxhZ8mfg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB3073 Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org From: Yazen Ghannam AMD Data Fabric registers are defined using a combination of PCI function number and offset. Define a struct to hold these values, and update the DF Indirect Access function to accept a struct of this type. Update the address translation code to include a list of the needed DF registers using this new format. Define an enumeration to give the registers more human-readable names. Signed-off-by: Yazen Ghannam --- arch/x86/include/asm/amd_nb.h | 7 ++++- arch/x86/kernel/amd_nb.c | 6 ++--- arch/x86/kernel/cpu/mce/amd.c | 51 ++++++++++++++++++++++++++++------- 3 files changed, 50 insertions(+), 14 deletions(-) diff --git a/arch/x86/include/asm/amd_nb.h b/arch/x86/include/asm/amd_nb.h index 455066a06f60..a5644c119317 100644 --- a/arch/x86/include/asm/amd_nb.h +++ b/arch/x86/include/asm/amd_nb.h @@ -22,9 +22,14 @@ extern int amd_numa_init(void); extern int amd_get_subcaches(int); extern int amd_set_subcaches(int, unsigned long); +struct df_reg { + u8 func; + u16 offset; +}; + extern int amd_smn_read(u16 node, u32 address, u32 *value); extern int amd_smn_write(u16 node, u32 address, u32 value); -extern int amd_df_indirect_read(u16 node, u8 func, u16 reg, u8 instance_id, u32 *lo); +extern int amd_df_indirect_read(u16 node, struct df_reg reg, u8 instance_id, u32 *lo); struct amd_l3_cache { unsigned indices; diff --git a/arch/x86/kernel/amd_nb.c b/arch/x86/kernel/amd_nb.c index 09083094eb57..f06924093ae4 100644 --- a/arch/x86/kernel/amd_nb.c +++ b/arch/x86/kernel/amd_nb.c @@ -184,7 +184,7 @@ EXPORT_SYMBOL_GPL(amd_smn_write); * Fabric Indirect Configuration Access Data (FICAD): There are FICAD LO * and FICAD HI registers but so far we only need the LO register. */ -int amd_df_indirect_read(u16 node, u8 func, u16 reg, u8 instance_id, u32 *lo) +int amd_df_indirect_read(u16 node, struct df_reg reg, u8 instance_id, u32 *lo) { struct pci_dev *F4; u32 ficaa; @@ -198,8 +198,8 @@ int amd_df_indirect_read(u16 node, u8 func, u16 reg, u8 instance_id, u32 *lo) goto out; ficaa = 1; - ficaa |= reg & 0x3FC; - ficaa |= (func & 0x7) << 11; + ficaa |= reg.offset & 0x3FC; + ficaa |= (reg.func & 0x7) << 11; ficaa |= instance_id << 16; mutex_lock(&smn_mutex); diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index e486f96b3cb3..1b459c143886 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -675,6 +675,37 @@ void mce_amd_feature_init(struct cpuinfo_x86 *c) deferred_error_interrupt_enable(c); } +enum df_reg_names { + /* Function 0 */ + FAB_BLK_INST_INFO_3, + DRAM_HOLE_CTL, + DRAM_BASE_ADDR_0, + DRAM_LIMIT_ADDR_0, + DRAM_BASE_ADDR_1, + DRAM_LIMIT_ADDR_1, + DRAM_OFFSET, + + /* Function 1 */ + SYS_FAB_ID_MASK, +}; + +static struct df_reg df_regs[] = { + /* D18F0x50 (FabricBlockInstanceInformation3_CS) */ + [FAB_BLK_INST_INFO_3] = {0, 0x50}, + /* D18F0x104 (DramHoleControl) */ + [DRAM_HOLE_CTL] = {0, 0x104}, + /* D18F0x110 (DramBaseAddress) */ + [DRAM_BASE_ADDR_0] = {0, 0x110}, + /* D18F0x114 (DramLimitAddress) */ + [DRAM_LIMIT_ADDR_0] = {0, 0x114}, + [DRAM_BASE_ADDR_1] = {0, 0x118}, + [DRAM_LIMIT_ADDR_1] = {0, 0x11C}, + /* D18F0x1B4 (DramOffset) */ + [DRAM_OFFSET] = {0, 0x1B4}, + /* D18F1x208 (SystemFabricIdMask) */ + [SYS_FAB_ID_MASK] = {1, 0x208}, +}; + int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) { u64 dram_base_addr, dram_limit_addr, dram_hole_base; @@ -691,8 +722,9 @@ int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) u8 cs_mask, cs_id = 0; bool hash_enabled = false; - /* Read D18F0x1B4 (DramOffset), check if base 1 is used. */ - if (amd_df_indirect_read(nid, 0, 0x1B4, umc, &tmp)) + struct df_reg reg; + + if (amd_df_indirect_read(nid, df_regs[DRAM_OFFSET], umc, &tmp)) goto out_err; /* Remove HiAddrOffset from normalized address, if enabled: */ @@ -705,8 +737,8 @@ int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) } } - /* Read D18F0x110 (DramBaseAddress). */ - if (amd_df_indirect_read(nid, 0, 0x110 + (8 * base), umc, &tmp)) + reg = base ? df_regs[DRAM_BASE_ADDR_1] : df_regs[DRAM_BASE_ADDR_0]; + if (amd_df_indirect_read(nid, reg, umc, &tmp)) goto out_err; /* Check if address range is valid. */ @@ -728,8 +760,8 @@ int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) goto out_err; } - /* Read D18F0x114 (DramLimitAddress). */ - if (amd_df_indirect_read(nid, 0, 0x114 + (8 * base), umc, &tmp)) + reg = base ? df_regs[DRAM_LIMIT_ADDR_1] : df_regs[DRAM_LIMIT_ADDR_0]; + if (amd_df_indirect_read(nid, reg, umc, &tmp)) goto out_err; intlv_num_sockets = (tmp >> 8) & 0x1; @@ -785,7 +817,7 @@ int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) * umc/channel# as instance id of the coherent slave * for FICAA. */ - if (amd_df_indirect_read(nid, 0, 0x50, umc, &tmp)) + if (amd_df_indirect_read(nid, df_regs[FAB_BLK_INST_INFO_3], umc, &tmp)) goto out_err; cs_fabric_id = (tmp >> 8) & 0xFF; @@ -800,9 +832,8 @@ int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) sock_id_bit = die_id_bit; - /* Read D18F1x208 (SystemFabricIdMask). */ if (intlv_num_dies || intlv_num_sockets) - if (amd_df_indirect_read(nid, 1, 0x208, umc, &tmp)) + if (amd_df_indirect_read(nid, df_regs[SYS_FAB_ID_MASK], umc, &tmp)) goto out_err; /* If interleaved over more than 1 die. */ @@ -841,7 +872,7 @@ int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) /* If legacy MMIO hole enabled */ if (lgcy_mmio_hole_en) { - if (amd_df_indirect_read(nid, 0, 0x104, umc, &tmp)) + if (amd_df_indirect_read(nid, df_regs[DRAM_HOLE_CTL], umc, &tmp)) goto out_err; dram_hole_base = tmp & GENMASK(31, 24); From patchwork Fri May 7 19:01:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 12245079 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 318AFC43460 for ; Fri, 7 May 2021 19:01:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1314060E0C for ; Fri, 7 May 2021 19:01:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229694AbhEGTC5 (ORCPT ); Fri, 7 May 2021 15:02:57 -0400 Received: from mail-co1nam11on2077.outbound.protection.outlook.com ([40.107.220.77]:61345 "EHLO NAM11-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229470AbhEGTC5 (ORCPT ); Fri, 7 May 2021 15:02:57 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V1L/ge3tiAZwG2hTIANBjR5cV2Be6J34o0Zu4JZJmS3K3cNnYcQWdiutHA13EDjVRpc0B4vW0ArJnR5MZO1qtK6LZ2XcRDQcG9vZ7J7jjD5qwUsz/Il620KKnhit2xen2JUj9iice6X42USpYJg9Q9+atuMWBziepmA2cBiwq2rll4DeP/KM5NRahamuqSuktc+FKue5ctgVdArc7/hZaMUVVZTtb7eMAhiy2c6jiSG/F73tqnwDEwzg0xs7jRhTDVW8rWSpezVHEiH5fK0FShP3MI12d9FTpt3XsmgXI2LGtZHIxCj6WE1PBh7/qECwuA70y76v8vQZIuatEID6Jw== 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=vLG0OYzquNIBre8C+jfIP/xMfyxACL7XSpKs1t0oYPk=; b=ipUoyM+VXTilmxk5K9Z+ZTAxR9M2EeEPMS/Q4kEqPHSSiQFd9Nmj6Lp+tNzvXq0fTBhzpSVKQOxvPlk86lNw3SsbjG0YNTGY6W5nyiyRN1V+6NEqoPy/D7wBJ/WFeEd8yBv968NUy9lmXKlVGh3sDPYV9UePybBdbIKnQxi0kjDnQHbFDMMabvQvQ0yDj+8NW8JaLwWmkj897aLgqEM8AWncQJWF/A0rF8qeUgNl5ar5LUeHEIDDszgpWecAYYuAapSbkSqLjKsGqlcSGsbmr4+m/wH8tt4roHPSX7dbU1ub7664xH3MZ2F3bmt9HnrSBidb/7RhBso9fj/MruqbDg== 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=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vLG0OYzquNIBre8C+jfIP/xMfyxACL7XSpKs1t0oYPk=; b=m0yURBQLcRNibPhB0ByAYsoOAjAYE+hvzXf1Mm+FjiawfbC3rdJC417I8YVOupcZQKT55prtcONSZd9XE+OX6qGhaHNAkQG5w4hZDPX9b1JScuCSgFO0RZZvgIiphu7vMibuVdHeJAXbuu4UYCan1f/Yk5qYCYZOl2/jh2Rb8/o= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) by BN8PR12MB3073.namprd12.prod.outlook.com (2603:10b6:408:66::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25; Fri, 7 May 2021 19:01:54 +0000 Received: from BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211]) by BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211%6]) with mapi id 15.20.4108.029; Fri, 7 May 2021 19:01:54 +0000 From: Yazen Ghannam To: linux-edac@vger.kernel.org Cc: Yazen Ghannam , linux-kernel@vger.kernel.org, tony.luck@intel.com, x86@kernel.org, Smita.KoralahalliChannabasappa@amd.com Subject: [PATCH 02/25] x86/MCE/AMD: Add context struct Date: Fri, 7 May 2021 15:01:17 -0400 Message-Id: <20210507190140.18854-3-Yazen.Ghannam@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210507190140.18854-1-Yazen.Ghannam@amd.com> References: <20210507190140.18854-1-Yazen.Ghannam@amd.com> X-Originating-IP: [165.204.25.250] X-ClientProxiedBy: BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) To BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from aus-x-yghannam.amd.com (165.204.25.250) by BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.3 via Frontend Transport; Fri, 7 May 2021 19:01:53 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 450bd8a9-05f6-4669-0f8e-08d9118a9481 X-MS-TrafficTypeDiagnostic: BN8PR12MB3073: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Wst62H6K31qg7vr78luDKj4SU7AIHYch4k6UNdCJhxilX3PG4/g/YWHPOMXFHs0mz3nBdrYQPW5TizKav2hpqqM6zqZtx2ibhBYc+RAkTOOqz8g1/ZKe+usn9pK8IDjuJrfbJFHRyShpeS9EU1L48WWmiUyjGqYdeZppdoQa0cPo3+k/rmT6V1gGRVhu61vlS8Z3DfNA31zqFagfC/lDDBGlIQhq/bQ78/rCekKKiqVZx3/ACcmOkPtsQVI7L5R9Pmm3Y2n3RhgwCAk8f77WEDIB2HkGc8fyBNZN8KjdTXbYL5yFBlYSZYf23nc5MbDcZMnssJ/7ZaESj2hV9MruLYa3/eo2qE1/Bfl0Xdq4aDieoO4GAnn9/2tAGY+frtG26Jr3voRgpnX7N09WwPxenp6h3/s/1qcFIwHewu6a+r3yQTu1gjzkIyBCxjYaQIzQ0zVIh7xpyT7JfWUTE5vRbBjQDRnjgTeQhLaM8z2fEhGSMUdtcVo1uuTaIJ5ON64H5A3zapTTt7NRQLqaeK4r7dgjc8Jy3uXfhJtLUvniV98ef9G0gScGV7IFguvMasihQ5l4FKfFsx1L1bzutTYdwp/mvG14jA++VJFOG+X0KhfUeSefbmqxL5Us6E6jzXMZNMiGgC0XJpBiGFTsu8Mq6wpxb2/PeY/67l4cyA8IU2E= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR12MB3108.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(136003)(376002)(366004)(39860400002)(396003)(346002)(316002)(6486002)(8936002)(8676002)(16526019)(2906002)(6666004)(186003)(83380400001)(26005)(6916009)(36756003)(52116002)(86362001)(66556008)(38100700002)(38350700002)(66476007)(66946007)(4326008)(5660300002)(1076003)(7696005)(2616005)(956004)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 8sbFZtZMY3CyLJBakFBkGL55S24hcAVGOKRFXUBuGdqJK4rnKLgmV9Jpg8h6rwniY41CNCOpAJ8Grd/LG3GAUPW8Iqh7E5HfCbeoznfVPaHN3ReCuadYvs/Ti8BYXJp0SXdK2poOElZtHP92Qgz4vvQLR3eDOJCqSmNvt/8r3Io/O7CgR1fyW5nQJpWRmYHpi5xFwXwwKot6QbuTKucvdjd4M9pHXATesOWGTB8abykoq22eGNQdtL5jAruQxXFLp+hzO3S8SZPgj8BoEkEz7gGj06Lq87kURTIOzQLJiHHvwsPpHJS4tj1KnAeErJ7sORxjDBH6Sj8MD7apmCu2zOFN7bhDaDzCuvtII0Kk/1gSpdmHsuLGwBBkBAESZwo1WyXoO8BLrd1ciDqG0r5mnuTmk1hkgK7razvN+vi8AmQHCLMaTQn8OVQnBPiIV4Llm/AOnfPB7Tt47F3VH6LQT5/B+DIu+uE3IwV81wtArXFruXk679TS2w/5nUf+T244jisRgpBEceV6W+0xC86/QCTCMFjbypY0lR0d+hPwjWmQZCSQUxtStr4wMlqi38vBlXCk/BA82SgfsRunDcU6lxLAsyflGuX5gNDYM8zUtHddI43YV6rN9kSywnb27POJadQOmM8dYOeFlbRlCp9mCncDJJtRytLJ67D17801vYMNMysyrawlXTLFz94LnHuqVk6TSXytsHGo33awkuQ0Ps31wczbw+NVhw6l1/UVJRYtainH3RbCsqwAghSKIxVWk/QPty4tIgORq3g1zBChDaoFPmDtYPTP+WrJt20Q2V+3kIVVnswppdVcCOqOX8Y5ZL6So8+14Qhv1eT4nojqxWh2g0Wz+SQ/Jcn0z8DOqahL/K9PGtg3Y5lmwXCFKp8Z8eWNfJ/VyWYzOrdgmBeRNrfrUeQpvfUoQFT4qpdOvLz/PHGWwurvfAQrTslzHptADVwk5ZzaprBYN61QwU8Z6P+PXBmvCBpy+Kl62WLF1xukQR8OYqAxdP4HN1r/GFl8ADOuJZVdAjCJO4bZk5HC4KG50rO+UemN8DHF8CTrqm3ko86kNolCLHiyX4wAh+X2NjKJZzJQ4GodhOs2sYEn7J7l+muCiuNMlyX8kjuybb8DrL6BoXSp2Ut2ryqODj0qbvTxERIG+Ofu4h0OM8HNg/UIHvCeeJFUpZ0gq4826kurcUDxWzkrsZHFnwUjg3qU0EeuCS65iTmwVW6RErBDFQAkdyNtLglYj91vrrIdMstiINaz3C7hAvhE5VGhiLj7nN6Qkh+tFfbThLGlsa7eZxPd7Y9d593TpHR211Me6bi3/nK+gWsaDI448tAAXNck X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 450bd8a9-05f6-4669-0f8e-08d9118a9481 X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3108.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2021 19:01:54.6679 (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: c9749cUE+xcfPRe7fwh6l5xU85WMHQPiXCk44bzQZDruQkheqJy+RI7kB3Q5Ng1jg2mfSpNdNWO0d8iL4oItiw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB3073 Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org From: Yazen Ghannam Define an address translation context struct. This will hold values that will be passed between multiple functions. Save DF type, return address, Node ID, and UMC number to start. Add stub function to get DF type. Return DF2 type for now. This will be updated with new DF types. Signed-off-by: Yazen Ghannam --- arch/x86/kernel/cpu/mce/amd.c | 61 ++++++++++++++++++++++++----------- 1 file changed, 43 insertions(+), 18 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index 1b459c143886..86df58b1051a 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -706,12 +706,25 @@ static struct df_reg df_regs[] = { [SYS_FAB_ID_MASK] = {1, 0x208}, }; +enum df_types { + DF2, +}; + +struct addr_ctx { + enum df_types df_type; + u64 ret_addr; + u16 nid; + u8 umc; +}; + +static enum df_types get_df_type(struct addr_ctx *ctx) +{ + return DF2; +} + int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) { u64 dram_base_addr, dram_limit_addr, dram_hole_base; - /* We start from the normalized address */ - u64 ret_addr = norm_addr; - u32 tmp; u8 die_id_shift, die_id_mask, socket_id_shift, socket_id_mask; @@ -724,6 +737,18 @@ int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) struct df_reg reg; + struct addr_ctx ctx; + + memset(&ctx, 0, sizeof(ctx)); + + /* We start from the normalized address */ + ctx.ret_addr = norm_addr; + + ctx.nid = nid; + ctx.umc = umc; + + ctx.df_type = get_df_type(&ctx); + if (amd_df_indirect_read(nid, df_regs[DRAM_OFFSET], umc, &tmp)) goto out_err; @@ -732,7 +757,7 @@ int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) u64 hi_addr_offset = (tmp & GENMASK_ULL(31, 20)) << 8; if (norm_addr >= hi_addr_offset) { - ret_addr -= hi_addr_offset; + ctx.ret_addr -= hi_addr_offset; base = 1; } } @@ -861,14 +886,14 @@ int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) * bits there are. "intlv_addr_bit" tells us how many "Y" bits * there are (where "I" starts). */ - temp_addr_y = ret_addr & GENMASK_ULL(intlv_addr_bit-1, 0); + temp_addr_y = ctx.ret_addr & GENMASK_ULL(intlv_addr_bit - 1, 0); temp_addr_i = (cs_id << intlv_addr_bit); - temp_addr_x = (ret_addr & GENMASK_ULL(63, intlv_addr_bit)) << num_intlv_bits; - ret_addr = temp_addr_x | temp_addr_i | temp_addr_y; + temp_addr_x = (ctx.ret_addr & GENMASK_ULL(63, intlv_addr_bit)) << num_intlv_bits; + ctx.ret_addr = temp_addr_x | temp_addr_i | temp_addr_y; } /* Add dram base address */ - ret_addr += dram_base_addr; + ctx.ret_addr += dram_base_addr; /* If legacy MMIO hole enabled */ if (lgcy_mmio_hole_en) { @@ -876,29 +901,29 @@ int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) goto out_err; dram_hole_base = tmp & GENMASK(31, 24); - if (ret_addr >= dram_hole_base) - ret_addr += (BIT_ULL(32) - dram_hole_base); + if (ctx.ret_addr >= dram_hole_base) + ctx.ret_addr += (BIT_ULL(32) - dram_hole_base); } if (hash_enabled) { /* Save some parentheses and grab ls-bit at the end. */ - hashed_bit = (ret_addr >> 12) ^ - (ret_addr >> 18) ^ - (ret_addr >> 21) ^ - (ret_addr >> 30) ^ + hashed_bit = (ctx.ret_addr >> 12) ^ + (ctx.ret_addr >> 18) ^ + (ctx.ret_addr >> 21) ^ + (ctx.ret_addr >> 30) ^ cs_id; hashed_bit &= BIT(0); - if (hashed_bit != ((ret_addr >> intlv_addr_bit) & BIT(0))) - ret_addr ^= BIT(intlv_addr_bit); + if (hashed_bit != ((ctx.ret_addr >> intlv_addr_bit) & BIT(0))) + ctx.ret_addr ^= BIT(intlv_addr_bit); } /* Is calculated system address is above DRAM limit address? */ - if (ret_addr > dram_limit_addr) + if (ctx.ret_addr > dram_limit_addr) goto out_err; - *sys_addr = ret_addr; + *sys_addr = ctx.ret_addr; return 0; out_err: From patchwork Fri May 7 19:01:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 12245081 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6493EC433ED for ; Fri, 7 May 2021 19:02:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 472C16141F for ; Fri, 7 May 2021 19:02:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229717AbhEGTC7 (ORCPT ); Fri, 7 May 2021 15:02:59 -0400 Received: from mail-co1nam11on2077.outbound.protection.outlook.com ([40.107.220.77]:61345 "EHLO NAM11-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229675AbhEGTC6 (ORCPT ); Fri, 7 May 2021 15:02:58 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WsCo0/jiGnU2HPFyskrJHYcfP3HXkHCtaJnw9vKcEWScyWLC2mGmpvrXwf6HIcro/6DJ0t94DFX8hyxSJR4z7juWEIysOrBucizcWLSh7E42bPQv2xSbRQteIQXfHLrMEo5WKl/vbxAP2HwgoxaDzsCczLlrFzpFInn1kkMkWdAjf/BoeZyoMIBqxmUT1LExf+lLzrSDD40kIR4DxZPVeE5cjCsvBeQJWEVPOF+W2wCdcHXmC5YNb+oFaxGAVwzCWajIKrjege6W88q14TX6DXMq48Hh+FRG+Q3u+a0PFRTzv4Ywxti+8hgiiuZBJn0mFPYuEAT7m85hfrlxkmyimQ== 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=zLo7cqT4X01tMGPACbRkE0lmzckIglAEDeikafiQVn4=; b=PDssA1WfnHeZ9/cD8zhmpNAwUSM+TLFTORkCPesWMtlSQ8OoKrqcneoZ6l9T8CiolucEHzZQ3Q5NMqGb/g0MwQbSXBRqntZJp6h7LlO167Nh8I4YtY4kapUockHuD1BMueEkRLqvzhjOJD4VCyCUlKfF0HtPL9KFFgkko7UR3eIEFVUFOtTKhibZvUPuOCFtaJh6lz0dfDs+j9kFmOVejY97EicH445eUCiGcAyEcFW5aiM7lZKy9EiNZqPF7wzPOuWpaZYEiU6fLQ1TGj4ejpAu/qfKXT0qgvqV/Ym7bnMQnlsxztTjSPT6EKMrRsuP8CCfYDwoxIMmzX0hg7qfPg== 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=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zLo7cqT4X01tMGPACbRkE0lmzckIglAEDeikafiQVn4=; b=23eGGPQxBrVmhM+vyXCHpTheVpN4/fpXa475qa/PeAjVTfb5YOj8cTFgIUomkvP2tBCQPefx4USI4Mtq3IoqXbJx5i23HO2wBW36Kurji3ftpGj0EMkBQC4wN2KgzcBPGZG0ZTG9lKp9Ij6f/A+HzCit4GcQ5xAEApSUOBO3vmc= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) by BN8PR12MB3073.namprd12.prod.outlook.com (2603:10b6:408:66::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25; Fri, 7 May 2021 19:01:55 +0000 Received: from BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211]) by BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211%6]) with mapi id 15.20.4108.029; Fri, 7 May 2021 19:01:55 +0000 From: Yazen Ghannam To: linux-edac@vger.kernel.org Cc: Yazen Ghannam , linux-kernel@vger.kernel.org, tony.luck@intel.com, x86@kernel.org, Smita.KoralahalliChannabasappa@amd.com Subject: [PATCH 03/25] x86/MCE/AMD: Define functions for DramOffset Date: Fri, 7 May 2021 15:01:18 -0400 Message-Id: <20210507190140.18854-4-Yazen.Ghannam@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210507190140.18854-1-Yazen.Ghannam@amd.com> References: <20210507190140.18854-1-Yazen.Ghannam@amd.com> X-Originating-IP: [165.204.25.250] X-ClientProxiedBy: BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) To BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from aus-x-yghannam.amd.com (165.204.25.250) by BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.3 via Frontend Transport; Fri, 7 May 2021 19:01:54 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 10c30a5a-7a25-4456-2733-08d9118a951c X-MS-TrafficTypeDiagnostic: BN8PR12MB3073: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HHzyuiTEVpKknE21jy8e45hXbdRVSuE1i0jC5JYHqpY1jlAqNG5KWXppjDMyWhoBaxcpPdUH50rOsqyZCzidMKgBqKv4BHrm5vsHI18/tC8q32TIhHNQJvcvqMxyWAajbl3fohl5q6NhGKY9j6JoSDkF5+xWXIhPcFruLEAvsgbHUjX0vROpsN0P5t4iqGUuQW7pPnkG+s9MDcBRNXaVG/m+byGQxXQJl5iVWMaldaUKQXpKckgW9vcQL9RHgPfJNYN32LNIbr3WsqDI+U9ImJWdrOXjM8vHV4GIL4rX2196yG32WiU1C+KabhmYMhPR5rE0Di/E3e1eiqvwK8lP8kKcexYZ9BXTG2lstw2+nzOKlbhox0+vZHqg2Ltvncmocx0F9U7mEg39NYQ16WjDmHmk0qSapOFH3sEZmvxBJevfJRLC7o92/vhyKE+UYtKoHkrq4ZO5j6ToDqQfoM0lE7CLa01S4yTCkmeR3iteoPeuMK0Uz1SQsTwWbwLxlA3wUI4qwrMZQTOnD4eyhwfivrr7HfQMAPNUECVWkt7uyDKysp+2So9aQl2bcy3J19yavJJJdaxJ3BcbR4TgLnpupSZYTrqmJ+mKZa+LAPcaDY50ZhIxIJRP0mgm4ASo5pw5NRX9Lrn0t+SdSX7xVaotwMLW2onqrF1Dfcdc6QXEigg= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR12MB3108.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(136003)(376002)(366004)(39860400002)(396003)(346002)(316002)(6486002)(8936002)(8676002)(16526019)(2906002)(6666004)(186003)(83380400001)(26005)(6916009)(36756003)(52116002)(86362001)(66556008)(38100700002)(38350700002)(66476007)(66946007)(4326008)(5660300002)(1076003)(7696005)(2616005)(956004)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: CT1yrd8EaaNELqoYEdZG/2eibcNS/GdeLSIDYqRpWY2bqYmvBOLWBCAGT/o0llpPkYtsguyxmWy9hB7f5UxUlKMW/MpjWIJ/zeHnoHAx1alZhKWO55nfulugOvrseOzRJZTMSE7kk2fvT1kCDd2pX+jrtR6Vhw8LV9jiBK+u32QvUx2KLWpa9rxY971EdwYKFrToqUgKaVFGdPtQcWczhfHbfKUg7P/O/A8YH3xTLf2Vk9CCn1RZM+qJY8WTJ/WzF5Sc+Jo/FAG/0fL6jn4DfMDsoCfsCalXhOK/MkMxgtiPwO5B2UgTVxxF7qF6Sf5kP2MmVVxlAG+kg2tgUCSkyVHtFiSgiH/cCCfqH6WkqNc6UQhZm7e9tuHtbCByVzzs6x90BTV5LlBiUFRWh34P5HCAYxzAsC9CNR93MWELsFqUVuG03rC9zhaE9DwnkuHMBC5GwdBDSEIpQ6vmTQYeFEp/HB0wuBRieFk9jqP2CXHArsZlOU4Dk0FihZEylAFdHyZjWeT/0wnEvv/PePudjigy5YrQUfpyM5P6SUa7MLkYewlDsGKemHb6Yrey9mSYXbj9Hc5ZNmJI5JMWPXC6JkxgM5UmQnVIsyzjmhwYWrtE0lC9dyVFZJ2M/suLdnkxsGiTf4YMU9iGJ5aYsPvoa608hMsqJ4RJ5ibtj6shsh9E8Og7Y2PxQCJA0oM0tnV/HakB19ZQv52sTm9oaxKWch+Yz/K0HQ0qdUC6lM/gWpZZjCW2WbB5NSUaOB3FRxUpHFKJ3Qc7iC/jNHcldR8dD5iOTRh/pXY64a9xpcujaLC8YqTqbUh4j5ZbAQuWKPvyiyK+Eg4Qyh52OUbZpsvD/29sQQHrwX4BKlTcT4v45gfm4mC5jc++WFV4F+U71MJDT86MAcCvfz60sjaBE7SdG8QhOIFCSo3qiPm6NANz+62lYxGQAQaKnlRC9KKjULd66Vl3moy0c74hBDIVrIBB+Asvt4DaJdRzK9ab9nN7mAvpsip0y0iFqjoCSj7YWM6+7nVkGoheI2dL4xCJGRdOfehWZmbMp4jK9exqZbGiAwhq0pesiiwOwzajlbZZD+iU3WdtAhsw62F5KMc9zfuyLfdxU1MKUBvy4NWRZqtoJ/zA81+kWqeX1aH2H2SyMJoE3bPEngiJ+1GuV8qxAMuSAwIA1gWiRao+ApmhLpxOu3IgzAf9qTseTEB75cdSTk7nvDrq0+/prba7pyMUB4OALCKntTu+JqS5XGUZtqHk+KO2oTQvWotl3eNIRHWFhoE2Kti4stpB4eF48R3+QkqgSys0QfFwF7sOoacOjPmiJF/9yCldnL+Ise9lCxYtSegq X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 10c30a5a-7a25-4456-2733-08d9118a951c X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3108.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2021 19:01:55.6863 (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: RS1qkzpgrRD91gWeMj1OoDjt/HD/76RoDrb+MlYfH5dF80tjgoAxGNbJd0wcGN58EQBZU3/XZ+TDip+Xun9LDw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB3073 Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org From: Yazen Ghannam Add helper functions to read the DramOffset register and to remove the offset from the calculated address. The helper functions will be expanded in future DF versions. Rename the "base" variable to "map_num" to indicate that this is the address map number. An address map is defined with a base and limit value. The map_num variable is used to select the proper base and limit registers to use for the address translation. Signed-off-by: Yazen Ghannam --- arch/x86/kernel/cpu/mce/amd.c | 54 ++++++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 14 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index 86df58b1051a..20a6f34143f6 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -710,11 +710,14 @@ enum df_types { DF2, }; +/* Use "reg_" prefix for raw register values. */ struct addr_ctx { enum df_types df_type; u64 ret_addr; + u32 reg_dram_offset; u16 nid; u8 umc; + u8 map_num; }; static enum df_types get_df_type(struct addr_ctx *ctx) @@ -722,6 +725,39 @@ static enum df_types get_df_type(struct addr_ctx *ctx) return DF2; } +static int get_dram_offset_reg(struct addr_ctx *ctx) +{ + if (amd_df_indirect_read(ctx->nid, df_regs[DRAM_OFFSET], ctx->umc, &ctx->reg_dram_offset)) + return -EINVAL; + + return 0; +} + +static u64 get_hi_addr_offset(struct addr_ctx *ctx) +{ + return (ctx->reg_dram_offset & GENMASK_ULL(31, 20)) << 8; +} + +static int remove_dram_offset(struct addr_ctx *ctx) +{ + if (get_dram_offset_reg(ctx)) + return -EINVAL; + + ctx->map_num = 0; + + /* Remove HiAddrOffset from normalized address, if enabled: */ + if (ctx->reg_dram_offset & BIT(0)) { + u64 hi_addr_offset = get_hi_addr_offset(ctx); + + if (ctx->ret_addr >= hi_addr_offset) { + ctx->ret_addr -= hi_addr_offset; + ctx->map_num = 1; + } + } + + return 0; +} + int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) { u64 dram_base_addr, dram_limit_addr, dram_hole_base; @@ -731,7 +767,7 @@ int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) u8 intlv_num_dies, intlv_num_chan, intlv_num_sockets; u8 intlv_addr_sel, intlv_addr_bit; u8 num_intlv_bits, hashed_bit; - u8 lgcy_mmio_hole_en, base = 0; + u8 lgcy_mmio_hole_en; u8 cs_mask, cs_id = 0; bool hash_enabled = false; @@ -749,20 +785,10 @@ int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) ctx.df_type = get_df_type(&ctx); - if (amd_df_indirect_read(nid, df_regs[DRAM_OFFSET], umc, &tmp)) + if (remove_dram_offset(&ctx)) goto out_err; - /* Remove HiAddrOffset from normalized address, if enabled: */ - if (tmp & BIT(0)) { - u64 hi_addr_offset = (tmp & GENMASK_ULL(31, 20)) << 8; - - if (norm_addr >= hi_addr_offset) { - ctx.ret_addr -= hi_addr_offset; - base = 1; - } - } - - reg = base ? df_regs[DRAM_BASE_ADDR_1] : df_regs[DRAM_BASE_ADDR_0]; + reg = ctx.map_num ? df_regs[DRAM_BASE_ADDR_1] : df_regs[DRAM_BASE_ADDR_0]; if (amd_df_indirect_read(nid, reg, umc, &tmp)) goto out_err; @@ -785,7 +811,7 @@ int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) goto out_err; } - reg = base ? df_regs[DRAM_LIMIT_ADDR_1] : df_regs[DRAM_LIMIT_ADDR_0]; + reg = ctx.map_num ? df_regs[DRAM_LIMIT_ADDR_1] : df_regs[DRAM_LIMIT_ADDR_0]; if (amd_df_indirect_read(nid, reg, umc, &tmp)) goto out_err; From patchwork Fri May 7 19:01:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 12245085 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51CEDC43462 for ; Fri, 7 May 2021 19:02:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2D12761482 for ; Fri, 7 May 2021 19:02:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229482AbhEGTDF (ORCPT ); Fri, 7 May 2021 15:03:05 -0400 Received: from mail-co1nam11on2077.outbound.protection.outlook.com ([40.107.220.77]:61345 "EHLO NAM11-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229699AbhEGTC7 (ORCPT ); Fri, 7 May 2021 15:02:59 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V0LyrlokWd+n9Bpu/HvB1pKbnwIDb92HOlub9ByuO7n5NqqXj7zzrEbXg8QOGIzFuPV3lpVoJm2S992zbPWjyG541HQyr3001AU1IVlrftrYumWPO3g0IP/EUaCNSdcvprD6LfujSdDodetc0dhU3boITnnqUtGbArTbgOB5frOLTgaer0M5wlVRkOS/Fmj46q86WjlGUPmcovswD3OHXnK5OZrDfjOoRb0PU8sHZHSNFG37M2QODgu+9i8UsD95ZK6+0d1qX2Yq6wDthIMXMmpB2PGSPcOjhNaRncu46DEHNqlsDBV1aNOr2+pCU2Y0449uQIBPY04dbQi1Wd+jwQ== 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=7/VfQneShCGPB3pX9VjtKwYyKQjmb04gQQtPCKWlJ8Y=; b=QsC9FIpz03z8cdHFssNOzMXTKCfFewNP9VsFsWlRjj7KwyjMUYC0PnEQgDm2UkNpsJBReJSO2Q32t/JORY5lAB3tfhQR0QPSeSkERQYpDMK+0C7eXd3E+tQFAP4d3T1MEnWb0ZUuIqi7RELB34yOTCzmQcFVGB2merEmvWXzztCOLtTA9Z/nlvsZotQ7pZCfPhKs/U+2SbT5SW/ba0E3ucBk3CCd4LobBPEjAlHJW4auhCvo9cmETonrIjxDtkrzx9lqQ4OheNs+J2C2SF4vnlYpqZT/NzGVB+1Hw/yFtWm3j9ub3fMZoo/B9ZDnLnTq6xQtmNsZfL5MFE9nu1L5fw== 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=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7/VfQneShCGPB3pX9VjtKwYyKQjmb04gQQtPCKWlJ8Y=; b=tElAOgmHhgPrwZ98zv/kc8cOX1HIRSSY8HdmGInD+Fx5p4+0D9bOWAT6FsyZItcQZwrUHd2DAJfxE8yyU4022dHpnVzdDbBUbxhGbTHmVRhMIdX0tUD1yGbR45q3n5ZNgO20PhgVLNIzfmMI72dFLed/vEgcR3fGL4sD1r9x3lg= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) by BN8PR12MB3073.namprd12.prod.outlook.com (2603:10b6:408:66::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25; Fri, 7 May 2021 19:01:56 +0000 Received: from BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211]) by BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211%6]) with mapi id 15.20.4108.029; Fri, 7 May 2021 19:01:56 +0000 From: Yazen Ghannam To: linux-edac@vger.kernel.org Cc: Yazen Ghannam , linux-kernel@vger.kernel.org, tony.luck@intel.com, x86@kernel.org, Smita.KoralahalliChannabasappa@amd.com Subject: [PATCH 04/25] x86/MCE/AMD: Define function to read DRAM address map registers Date: Fri, 7 May 2021 15:01:19 -0400 Message-Id: <20210507190140.18854-5-Yazen.Ghannam@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210507190140.18854-1-Yazen.Ghannam@amd.com> References: <20210507190140.18854-1-Yazen.Ghannam@amd.com> X-Originating-IP: [165.204.25.250] X-ClientProxiedBy: BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) To BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from aus-x-yghannam.amd.com (165.204.25.250) by BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.3 via Frontend Transport; Fri, 7 May 2021 19:01:55 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 06bab993-0a93-4654-f916-08d9118a95bb X-MS-TrafficTypeDiagnostic: BN8PR12MB3073: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:873; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3i9Ah+3Nr8z/hjFYJdbaB4kvERRMQouhjCfLifcXslKDHq5KR04NuQHJw1d2F1V/Sl80Hi/ZKfE7JdwmlahCFXM1xLrMcfN1EmdFzIKB7FqtCZIaDh1nxMdtjZ+hfXuDC+BGaiHNgYgSpgEB8HEMkxnHgX0U/85UrPyscvlC1pfWr99mBeSONSPFY8cJ/hzB+g5I2rL5ycponzDyeC1IB3TXTb3EUj/AZnk4yqoZxWgkttTadIIHvcVOeS/JEUJdWZ5onRL8IXBec+JIItESffbKvd3Gc4Qt0lfTRo7/mchffqEyjnFvegyy8s4BFCJWBbkacm+RwqJlJQWE6Jfn0nowqyPcku3E30VnBgsj5LAyGxwqSC84UtsG/bXiM3PLfpSdnvtl0UCMup2CgBEpT0Ty/YwA3XjxnfZQkbSCAP0FZISghYb+gNi7jledd0LPtqctKc+DLW3LW8+gNLREGW4p6jqHrEQXbdPbBqrW3Zqs7orRyL7UrX+0pKun9S1q7UZAG51T2twtsMUyEoSn7hN63Fhmm0K9DSx7SVXqmDVjZadVF2RdDzl9DTz53tXFwiNrhMkBqTYsm1I7b+D2XbnajoJTpElnKm4w6B90g434lTn6YxmwYhtwrkkFlR+Y6rWnaNbhi6f6vY2heqcROg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR12MB3108.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(136003)(376002)(366004)(39860400002)(396003)(346002)(316002)(6486002)(8936002)(8676002)(16526019)(2906002)(6666004)(186003)(83380400001)(26005)(6916009)(36756003)(52116002)(86362001)(66556008)(38100700002)(38350700002)(66476007)(66946007)(4326008)(5660300002)(1076003)(7696005)(2616005)(956004)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: qwkQ9csYGPT+ivzGDd8C5881dnCcJ5lAnVaBwo6pomyLe5nEyjq7Bpht29VBfMbthHzC/labNtId+cqjtjLG0QdW6kZZRWUG7GmlnqXslqeRaDpooWHHsx8UbTqHrQ0J9UIZS9g0Vg+XWJmdoNPE908twg+ouKvrpEdSxSDhPV0NacqahDIA/p3ZI0Bu6xaobQAeEXLJiZlC8lBl3rOF6L+kipTHRgWzvcnFjoSESZ2jiPoVz/MvRmJaUOGfGEIGNQBUXpK7dViQJb+xHAKwqdoFNKU8mfd0yM464dfvPPPDTv1ZY1NTdPIT8ooeATYVewkCRwYIgXal2bEKyw/OrSn5QMtQeOeLtMA3IY5YhaMbR6Tg0qKojLopK2sJvXuHannkWDWCxDn+YN1iwX6ZxaXASfMdNr61BHuwGRWN4iXszzPP/Eq8d9BOge2INzSOXUI8s9FUgHJGofIjUXwrnK0Lj2EyV7hj7l4xVQ5B13cH8lSuUidxIR8+5CLE5xTMST3T4A7gkW68EfseTI1066b5vNfC2JOus6CGIJLpl/tZ1UbYPcVPyTjkQeCjbcl+8Jzo8/846F+jmmuAMIQlnVy/uwrWLmGT2FnldySrvEGjRKWkeofvkSFT3ZZFXRCrLwZzEoOE11Jc/hjYz1fXXRx5LO9sWO9sVzGn3B7EUyuITgHOW0lpQLx3SHA2i2qirNyceiDUuNPcBaqJL4ZldyOyz43gyo9Lcq/EuOSNdMNXPeuSsIHvACkSaRe5NB/vxwES/szHWLynH383fxmX2/f6zECEHI0noKvntyaOCcDz+npM0h7N2mcM6Q9gsbc1cmNwgVhTilNEr241CtX5rgxIYik7UeDep1UFRoADaS2jEyzxVWHSozNqsPFcDd3Ke763/ef0TS2M27vtbEj4u4W/FAyO7hh5miJkDryYb47/hpH1H93mNh4cJk5qCCznsiOSzJVoxN9EiL7AkHGci3vkBOvSfG0xVKVnvE2bz3zr3VYo1W1rCRonK8mmRayZyae70xKE89b7zrDB99RXmBv3FAI41UuHu/i34OLmlKDyGNo1iMoEfXWHb5JaQTS+HXEvpw/x2+QzHshjMRIOvlV9n0syMSf2EGXRwaclpSCPQDiDZ9d1erTEkvOR8ZeyOnU6QO41tl1fMeN1fX5ihoNeU9wbQ3+os+O/EzjqU6GjwyCO6XYOAfD7x3cWDCYTA2hqPx13oAXvNYrH2bu5ZcRfIRKKaJTWoIDmdaiXkb2lMei3ccubo9vmE0c97UeVKrQGjm3R8XInCDe08q6exYMPKsHgVT5UafcGFZdVBRjKptMbtMwXF4ALp/YP3QwU X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 06bab993-0a93-4654-f916-08d9118a95bb X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3108.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2021 19:01:56.7517 (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: OcslAmI8+56SgojjngK6fGQG7ht0Ju7PuuZwe94N56XyyeB0u45yxdAI1zGwifE67+Y0QSUa5VedF5fGlbelCg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB3073 Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org From: Yazen Ghannam Move the reading of the base and limit registers into a helper function. Save the raw values in the context struct as they will be parsed later. Signed-off-by: Yazen Ghannam --- arch/x86/kernel/cpu/mce/amd.c | 53 ++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index 20a6f34143f6..0957f11a4c84 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -715,6 +715,8 @@ struct addr_ctx { enum df_types df_type; u64 ret_addr; u32 reg_dram_offset; + u32 reg_base_addr; + u32 reg_limit_addr; u16 nid; u8 umc; u8 map_num; @@ -758,6 +760,27 @@ static int remove_dram_offset(struct addr_ctx *ctx) return 0; } +static int get_dram_addr_map(struct addr_ctx *ctx) +{ + struct df_reg reg = ctx->map_num ? df_regs[DRAM_BASE_ADDR_1] : df_regs[DRAM_BASE_ADDR_0]; + + if (amd_df_indirect_read(ctx->nid, reg, ctx->umc, &ctx->reg_base_addr)) + return -EINVAL; + + reg = ctx->map_num ? df_regs[DRAM_LIMIT_ADDR_1] : df_regs[DRAM_LIMIT_ADDR_0]; + if (amd_df_indirect_read(ctx->nid, reg, ctx->umc, &ctx->reg_limit_addr)) + return -EINVAL; + + /* Check if address range is valid. */ + if (!(ctx->reg_base_addr & BIT(0))) { + pr_err("%s: Invalid DramBaseAddress range: 0x%x.\n", + __func__, ctx->reg_base_addr); + return -EINVAL; + } + + return 0; +} + int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) { u64 dram_base_addr, dram_limit_addr, dram_hole_base; @@ -771,8 +794,6 @@ int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) u8 cs_mask, cs_id = 0; bool hash_enabled = false; - struct df_reg reg; - struct addr_ctx ctx; memset(&ctx, 0, sizeof(ctx)); @@ -788,21 +809,13 @@ int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) if (remove_dram_offset(&ctx)) goto out_err; - reg = ctx.map_num ? df_regs[DRAM_BASE_ADDR_1] : df_regs[DRAM_BASE_ADDR_0]; - if (amd_df_indirect_read(nid, reg, umc, &tmp)) + if (get_dram_addr_map(&ctx)) goto out_err; - /* Check if address range is valid. */ - if (!(tmp & BIT(0))) { - pr_err("%s: Invalid DramBaseAddress range: 0x%x.\n", - __func__, tmp); - goto out_err; - } - - lgcy_mmio_hole_en = tmp & BIT(1); - intlv_num_chan = (tmp >> 4) & 0xF; - intlv_addr_sel = (tmp >> 8) & 0x7; - dram_base_addr = (tmp & GENMASK_ULL(31, 12)) << 16; + lgcy_mmio_hole_en = ctx.reg_base_addr & BIT(1); + intlv_num_chan = (ctx.reg_base_addr >> 4) & 0xF; + intlv_addr_sel = (ctx.reg_base_addr >> 8) & 0x7; + dram_base_addr = (ctx.reg_base_addr & GENMASK_ULL(31, 12)) << 16; /* {0, 1, 2, 3} map to address bits {8, 9, 10, 11} respectively */ if (intlv_addr_sel > 3) { @@ -811,13 +824,9 @@ int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) goto out_err; } - reg = ctx.map_num ? df_regs[DRAM_LIMIT_ADDR_1] : df_regs[DRAM_LIMIT_ADDR_0]; - if (amd_df_indirect_read(nid, reg, umc, &tmp)) - goto out_err; - - intlv_num_sockets = (tmp >> 8) & 0x1; - intlv_num_dies = (tmp >> 10) & 0x3; - dram_limit_addr = ((tmp & GENMASK_ULL(31, 12)) << 16) | GENMASK_ULL(27, 0); + intlv_num_sockets = (ctx.reg_limit_addr >> 8) & 0x1; + intlv_num_dies = (ctx.reg_limit_addr >> 10) & 0x3; + dram_limit_addr = ((ctx.reg_limit_addr & GENMASK_ULL(31, 12)) << 16) | GENMASK_ULL(27, 0); intlv_addr_bit = intlv_addr_sel + 8; From patchwork Fri May 7 19:01:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 12245083 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F51BC43461 for ; Fri, 7 May 2021 19:02:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4424B60232 for ; Fri, 7 May 2021 19:02:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229768AbhEGTDE (ORCPT ); Fri, 7 May 2021 15:03:04 -0400 Received: from mail-co1nam11on2077.outbound.protection.outlook.com ([40.107.220.77]:61345 "EHLO NAM11-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229727AbhEGTC7 (ORCPT ); Fri, 7 May 2021 15:02:59 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g8rN3ajNvPnvfStCWro/0gC3P8w/eEWh3uk9W0ZeCdhxhsI8IVa2rm8jYXCV39bsOzBOHjOcn1CE/SWHx78346kf6+dJrkR8WcDGlr7kTMnMqpMskSLR4tuzwrLImR3TAlBVthHxosY4JhoZJTZXjuE0VtBR/bWrRpUgrYL08+MMHH42BdOYos9/GsLTASmTQSg7i984fv+Vs773twOd6IIMki7SN4o2HTPJ0SGYdJ2GdubPmMUYREo+eqytftzWv0Sf9BJvZvVCWdWNlMvT6HP/H/0wnyzVNg5yChkIh0bCQnM9ydvhCDIm7/V73BhLa97OhSMrjewTEMffVHkGmg== 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=QFySVG65h31y5l5wtRKKzoTT9gHw5LTv8obZFqb/Y/k=; b=h4ITEvcDSxruU/V0BjbMT4Z2k1oMoJaBIbaJq6G+UK/yMm3ndUUgkwqNmNEA6ftP/R1Qik5s7WbR1daNKfnAmV8Nf0dhRH1D6aKBcHATvYf0i1/zfgQf8BbpwOldwBf26S7NIojRTIYVRad0f08kNdR8jweLXZ6xv3GhQS6DUmWlyeQbJEHpX8a9ne5G6o5PydlZ/m8GdCJ/5E7DdVi32z0rvVJayXNfODRfowZMuvOE0WQTyIjrk2Cy6HaH3tCXVGTqUQQYDuqo0Kilpf9XMtU4xEsEoByRWZQ7e9pVv+NkYFsIjhW4y/VV5FPjPROS+1xu0JZFzXC9ZZ8sjaSnYw== 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=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QFySVG65h31y5l5wtRKKzoTT9gHw5LTv8obZFqb/Y/k=; b=OFIvhNaqrwhh2W3kFd09Sh2rPqErHbK9XSYN75N2XFw4BqpApXAZzjT0hbwTK3jlADNJIS97a1DTgyFK2xYH+W+Tzz3buQh8Q8FBpsYHQap7hyULtLi7MvVmHfXvQY4tHCbVX2j0WYq3ZxYTdxM451HvzMKtvLyXAJMP98ggEyo= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) by BN8PR12MB3073.namprd12.prod.outlook.com (2603:10b6:408:66::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25; Fri, 7 May 2021 19:01:57 +0000 Received: from BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211]) by BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211%6]) with mapi id 15.20.4108.029; Fri, 7 May 2021 19:01:57 +0000 From: Yazen Ghannam To: linux-edac@vger.kernel.org Cc: Yazen Ghannam , linux-kernel@vger.kernel.org, tony.luck@intel.com, x86@kernel.org, Smita.KoralahalliChannabasappa@amd.com Subject: [PATCH 05/25] x86/MCE/AMD: Define function to find interleaving mode Date: Fri, 7 May 2021 15:01:20 -0400 Message-Id: <20210507190140.18854-6-Yazen.Ghannam@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210507190140.18854-1-Yazen.Ghannam@amd.com> References: <20210507190140.18854-1-Yazen.Ghannam@amd.com> X-Originating-IP: [165.204.25.250] X-ClientProxiedBy: BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) To BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from aus-x-yghannam.amd.com (165.204.25.250) by BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.3 via Frontend Transport; Fri, 7 May 2021 19:01:57 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 54ac9515-cc80-4f8a-9ece-08d9118a9666 X-MS-TrafficTypeDiagnostic: BN8PR12MB3073: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PyDvXKcBbHXWr0FnBPuTr7YMF0qScUcHOApNMiP/fYk6D3TowXEvHxNjZGpMGitIIYyiCRw3HBi9Qhv1VnCdURzY6A692LrP4Xgwpp7qWihjeXc3MmXk3CaGktFcGfYjaTcmgd2JTyTqcMoXwnnGTsuA0sr6HbLQgbfF5oZE7+W9Z1Z7LuGjGJkhkCKnPTIHITnZSYPhY3PNmpKVVKduC5AI21xWt4w6lfAvq5auaQtSvTB4UG47K0UwZ30FELt2gQDjWS7IDb8f4vZjElSwDY86E4l129jglgvFmCxZuk4aX7YdspbpGe+tWm2jthf6uAYqVf3IGvSmje0gkju3BTK8PmY8nGOZveIf9fxypFYwy+vDcPMRkmjgJBz/Nu9p5rytvHb0UbD7loq1G7z7YGJQkNH5APkECil0cPWdaNCDbV7ZBmwJWwPyK2ib99xas7xfm3Q6DYhEhDMqiTXVaox6O1nal6e94l3Ff2ku9+9PtZ7t8aeRvElhVDyRMm74SfEDn6poFQf9Uzrvapww8IeBHmzFW9b9CbCbGPfCGl9MCosVQMkB4sOjNKDNDKtXn5Vg5ppRwIsrvzun4WVLBPny3MDxan7gdmUN83c9B2shjVS3qh7R2Ml08KJoKOtC1nhqxU5L5IKiVfCqjgyHbTlMJYpYL0ZxRuIxjZNQ2Vu7oWdN8xUxOCFpBvo/WXKo X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR12MB3108.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(136003)(376002)(366004)(39860400002)(396003)(346002)(316002)(6486002)(8936002)(8676002)(16526019)(2906002)(6666004)(186003)(83380400001)(26005)(6916009)(36756003)(52116002)(86362001)(66556008)(38100700002)(38350700002)(66476007)(66946007)(4326008)(5660300002)(1076003)(7696005)(2616005)(956004)(478600001)(37363001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: UxYkoDvDTTyqPBYautrbA6z9Gy6kPQDs3sltm9icspW5ZiNg59iN70kWYhG3PDNChmlA8xC0STL6TYxGmHiTSQRYciG+dq2xQ3+J4/s2OeBGzmXDq5LP3glZDOQqXG/WkMY9f3OfruhB+c3EeqMJFBpet0BSUFWT1FZpSfeXqJKMme+hXOHpa0bp2q+HwZCFfUCOwLy/u2pegv0lSC+jt0tBdbHxVsbKvCgFbEk/UuRqgMCQHzNiTMtdpzl1crdD7JJLxb5HizJcWwR1Wdqv9QFwJqjKRVGnRyiG/qEsLllTpNeIX0FPseeWA7lcO3Sijl6N+OzWsr1Nwijp4s0gIUbLSoHxZatsic1qXV2EH3gwH4EIKLgJeBbNDnGC1mIh/aPTKzoiCh3vIYSaLYnFF5Qpw6Qsvx3oQ7tWjbaz2AYrN6H3FWCxQZETgnxoF9qKHn3qwAHdLBANf1YbKjY2OxI8uV3mZ+Ze8bpMx0t0iTqmDqwnx/+Yc8JZ8rwSn+PoKanwmrxIfqJYkufUMuCzk/oQr4bpb+wM6cp2sJ7JE9edF6xc93wUl1CEUT3QQ0B4EmfHtPQxYTEgBp9pb1fmfPPOfvS9YW9SnwbcbciJrds6iYXOBkVhytnszRZkwHydmISnO0loTjm/XsmGWsgEnVDGqHG9FaMz3hHcpfwGPA/YjAwKydZ+1VIqKn4boyTIlkEBzJO4fFWbY5hyldKlp3RQOB+ZcrRrIykOipwueCLfqP3/8hjr1M2brIWEDEdP92YJavLKlwRR95jFFkeR2mYJtd9PLwBATFdRjAMuWpvpTm1cLnLGTv691su9mf6jWYggBcs+3OtamXZSk8z1CgbyEtOUUaE04sNQamcaEhPgLrD8V0ddqITbFphWQXFgZ+fxb36MXRc6GaooK76TwCM8SD6nhie87JaoqiSuydZFd0kri9vcYvZz1PeI/Vwpz8TTsY9chwtpz+ZDRGMnM5ucDiEtPM+K8M5nJScjMYASdnHZxRbDi4jOyQWFePmDUULYqKs6kgUDHenHsGdtAT8w2wV9UqKFcbnD7NP2U069rKTv/1aFteojNSaBFF3Ege0Y9iEn9CqqbGvvkqXnyqWKVJQ0+deI8enCenluU8XVT8bzU86ur7n3C/sj+wTAvCJ3imSc6yqwsVCSt5bijAYt2Acaf8KXTwCYsCR337vG5ZhW2nfukGpODcf47vx1P1ZWW+T9DFqeeWVqLHnRwKXVHXQkQ51BTckxFpUHoNlHYKdPrYpHD6Z/jzNBdVjnAvF4QpI5VpnVKkrhfv5m3tqItETu/ZK2RRQfvUwrB/Cx9Xz++cIDGLhk88g9fqNV X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 54ac9515-cc80-4f8a-9ece-08d9118a9666 X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3108.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2021 19:01:57.7891 (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: 8FvfNSmR7a4PpsoAXXJyedz2V47L4botTALWFaN/Y+z00pfCq2qvqXYFgs5mA/OyvJIsJKQHGjhfx+waidR/IQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB3073 Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org From: Yazen Ghannam Define a helper function to find the interleaving mode. Define a DF2-specific function now. Future DF versions will have their own functions. Use an enumeration for the interleaving modes to give a human-readable value. Save the interleaving mode in the context struct, since this will be used in multiple functions. Multiple interleaving modes support hashing, so save a boolean in the context struct to check if hashing is enabled. Signed-off-by: Yazen Ghannam --- arch/x86/kernel/cpu/mce/amd.c | 38 ++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index 0957f11a4c84..f1a467cb74e6 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -710,9 +710,17 @@ enum df_types { DF2, }; +/* These are mapped 1:1 to the hardware values. Special cases are set at > 0x20. */ +enum intlv_modes { + NONE = 0x00, + NOHASH_2CH = 0x01, + DF2_HASH_2CH = 0x21, +}; + /* Use "reg_" prefix for raw register values. */ struct addr_ctx { enum df_types df_type; + enum intlv_modes intlv_mode; u64 ret_addr; u32 reg_dram_offset; u32 reg_base_addr; @@ -720,6 +728,7 @@ struct addr_ctx { u16 nid; u8 umc; u8 map_num; + bool hash_enabled; }; static enum df_types get_df_type(struct addr_ctx *ctx) @@ -727,6 +736,28 @@ static enum df_types get_df_type(struct addr_ctx *ctx) return DF2; } +static int get_intlv_mode_df2(struct addr_ctx *ctx) +{ + ctx->intlv_mode = (ctx->reg_base_addr >> 4) & 0xF; + + if (ctx->intlv_mode == 8) { + ctx->intlv_mode = DF2_HASH_2CH; + ctx->hash_enabled = true; + } + + if (ctx->intlv_mode != NONE && + ctx->intlv_mode != NOHASH_2CH && + ctx->intlv_mode != DF2_HASH_2CH) + return -EINVAL; + + return 0; +} + +static int get_intlv_mode(struct addr_ctx *ctx) +{ + return get_intlv_mode_df2(ctx); +} + static int get_dram_offset_reg(struct addr_ctx *ctx) { if (amd_df_indirect_read(ctx->nid, df_regs[DRAM_OFFSET], ctx->umc, &ctx->reg_dram_offset)) @@ -792,7 +823,6 @@ int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) u8 num_intlv_bits, hashed_bit; u8 lgcy_mmio_hole_en; u8 cs_mask, cs_id = 0; - bool hash_enabled = false; struct addr_ctx ctx; @@ -812,6 +842,9 @@ int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) if (get_dram_addr_map(&ctx)) goto out_err; + if (get_intlv_mode(&ctx)) + goto out_err; + lgcy_mmio_hole_en = ctx.reg_base_addr & BIT(1); intlv_num_chan = (ctx.reg_base_addr >> 4) & 0xF; intlv_addr_sel = (ctx.reg_base_addr >> 8) & 0x7; @@ -839,7 +872,6 @@ int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) case 7: intlv_num_chan = 4; break; case 8: intlv_num_chan = 1; - hash_enabled = true; break; default: pr_err("%s: Invalid number of interleaved channels %d.\n", @@ -940,7 +972,7 @@ int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) ctx.ret_addr += (BIT_ULL(32) - dram_hole_base); } - if (hash_enabled) { + if (ctx.hash_enabled) { /* Save some parentheses and grab ls-bit at the end. */ hashed_bit = (ctx.ret_addr >> 12) ^ (ctx.ret_addr >> 18) ^ From patchwork Fri May 7 19:01:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 12245087 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0B61C43460 for ; Fri, 7 May 2021 19:02:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C4C5761493 for ; Fri, 7 May 2021 19:02:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229795AbhEGTDF (ORCPT ); Fri, 7 May 2021 15:03:05 -0400 Received: from mail-co1nam11on2077.outbound.protection.outlook.com ([40.107.220.77]:61345 "EHLO NAM11-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229470AbhEGTDA (ORCPT ); Fri, 7 May 2021 15:03:00 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Hov8Ya5sxNH1LOzkL+fvBEz5/h81CIiyq9whzbvKrKLT7WS8/Y4+Z9AdF5ZjQS5w9t3sXOqf4DiRoKUdQ/E0mbIJtSzibRyQedsywAOq0AMjGO6jcQstpe/G8tl1GZJ0UW5zihS6Zglh38SV226ps62dM1b+3wQe82NzlVSRl3PtZNRdR1bPEGfMwpYQsqT6WUMtLKtB1vrVCPr3LxzW0J2JBO5IIwuK5kjROPWloWBY0kyn1yGTKeN5yNKbuQOJ+P5OxgZMI6z0nq52Lwtm0SKuW3RLxn367Mf4cukSnLFqtXGovnv5RisglE5hZF1Zh1wFtmu7MjsbqldL++Wuew== 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=F2nJhjNZS4qcdWg97yu+0TAq0wZsFfBnJ5JtN7P6jc8=; b=dy3O+YbLAPK9X/owIioXqohmVxqbuLYfsKGr3iNLCkHhYu0IwPxBms98XVxusjbZCuSam1eun1XrKZ+unUjzMcic/IOjymr0o2JvMPesMyQsnl0LnhJnnZAMBUK+2lF6ihOHsbC/+Fl3zZlZcHB9w41rv3Fbz5DKcymF4+/wahy7Jff+6fDbt/tWQLj5Y74FlPZrjgDGFnO0igxz93/nHf9r1i0K7NeviLXb6vFsGcetBQqGJHj5SEhW+ydpBsYUYnmtryVnL5tKOEK+K6866NPq4WEWHg4jRwhNvlL5gZFqwX6t+U/3dNILTj/KfXLAJv8i61A53mnT389XAMosJw== 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=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=F2nJhjNZS4qcdWg97yu+0TAq0wZsFfBnJ5JtN7P6jc8=; b=ULnt1wfCcGtb8Te8QWriI/Nk/+7CIsEydryu1u04DH+x9rL2ivlK1tYRH8NRTHQT0Uii5iyCD+gDpMMDl61fRVOaNtq+uUqW1xErZzbqur8k0fxUtGOuemGeHXu9L4W7YJ9EzD0lqWWoqcPkfopLHCS5CGixCWXC1BaWaV7UgqQ= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) by BN8PR12MB3073.namprd12.prod.outlook.com (2603:10b6:408:66::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25; Fri, 7 May 2021 19:01:58 +0000 Received: from BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211]) by BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211%6]) with mapi id 15.20.4108.029; Fri, 7 May 2021 19:01:58 +0000 From: Yazen Ghannam To: linux-edac@vger.kernel.org Cc: Yazen Ghannam , linux-kernel@vger.kernel.org, tony.luck@intel.com, x86@kernel.org, Smita.KoralahalliChannabasappa@amd.com Subject: [PATCH 06/25] x86/MCE/AMD: Define function to denormalize address Date: Fri, 7 May 2021 15:01:21 -0400 Message-Id: <20210507190140.18854-7-Yazen.Ghannam@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210507190140.18854-1-Yazen.Ghannam@amd.com> References: <20210507190140.18854-1-Yazen.Ghannam@amd.com> X-Originating-IP: [165.204.25.250] X-ClientProxiedBy: BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) To BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from aus-x-yghannam.amd.com (165.204.25.250) by BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.3 via Frontend Transport; Fri, 7 May 2021 19:01:58 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 20ebc95c-9c6e-4da4-a153-08d9118a96f9 X-MS-TrafficTypeDiagnostic: BN8PR12MB3073: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3513; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vrfZsDIaMOjX1q6ox8xl6XozC5lmS6NVV+qA2EF5AZ8bCF91jeF6463I9S7/vkQRz2QqcI27zgZFz/53cS1NAIJLwNF54GjT4YLCtwoyi1g5WSbdlW8dmMPyBiniKFubdyhQLr21nLVGegewPy1Q73U+rgdW2uMTlIYNdoIOxcXkwcvD/E7WfJrrE1vCmHBWFEmj8iFW7JDdhRy8S7/bgtb2Jy89plwH/Vjkl/pw+y3NmkjDKcEjJVaJfIBGsTMKwe5ZSkrAQpDV++rXrPAu5rAMpbJTR28zzVlt322X5bD1QzOdWp/stbqN82zb6k36oJU7h4DsAFcqHIF/Wlpk7XpAIjtAofKpIuyTdvvbgy+jSmvAQuE1oaKz0ggRrb+G9jobZDy801AoBauY3lW5QjN5AJqRusg0m2RX6+AUEyeQWqSsbBSiWf1onojdkb1ktysRd7HNv9PKu/jFxC+XXqagLDgHn0mTLXSO1csdyifZzIHYDyZ1KVknjkruT5n4xkw5JjH4aUzqmkTLtFjUmIYJxmrldRlNNlnA6fmHiSnIz2xcgBh0QJAy6iWyOaKWh09V9MZxcNcFtvG150eWqKaE6yeiDJHO6ev1tHrOouD2MtmJuvo/1l0pLXg7F2yq0NFwZqsAVm13wW7R2FFGn8p4luFAI3zofuFG19cArMQ= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR12MB3108.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(136003)(376002)(366004)(39860400002)(396003)(346002)(316002)(6486002)(8936002)(8676002)(16526019)(2906002)(6666004)(186003)(83380400001)(26005)(6916009)(36756003)(52116002)(86362001)(66556008)(38100700002)(38350700002)(66476007)(66946007)(4326008)(5660300002)(1076003)(7696005)(2616005)(956004)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: fEmQZQhalMKk4TF87SmCqKB3gDT1jDNBdRJaDcrzE2anuyvwG9Id/6eCrd4dEimpcltQfgKSo5iSH/AYI2Figa0+fYXRImQEDEx7UxZgWvpJx9xHcad5k3X7JCQ+IipQRp4WSL2ngqr13hX3CVcsQngVkL6SFwNp1nTL5Xa203eWGU91Y4MX5IvgKc8vtyGEdq8rcwKy3B2/hDvooV49Ak/YmZ+BIILHxANhaOKa8IONuclxvtFe5ei4NoEhQXVmsAA37red8wnz+ILxev5uO5tgBEok/6hmT11NAfQ1U2tKKZqtvc9pV7IT6NipOu3gMsg0gYLwyn476ZvWOxQmmYAfO6loL9Q3Vndthi8zfvrdxu4qY+Y6BbtejNPI7Di3r2syHB1bp5+vPCt3GeG9UQaxSDHFNnIXMY2f+Xb34k4rvhBXFK8V3vZMkDomZZWAVa4J6IPgQUAHrBxtuiAkX1hMrVon4A2PzotJSlT3jYnz/EY1evV7EZ7gYDbeNFUNnGn4941MLsd7qWM2jdFBABTvqicbrWswbppxbCpOFLaXLetNeYPJGjuB1+XlRQtwrwNgIgmmNwXNnAnX81tjKNxFKranBNC4AlDAes1B37dugIOS4v8rKqVjl0m8CnWsBn+kko9JNggSeYbA5U9+5hTwdN9imiiIsSXWH3Dx4ZUSWTVUA7O63SRoNFg5YZ228cKifFKy9m3mUx8YhZu9DOHNeV7ZbnM0IR177UB5DAAl/Sxfwo8pDKvrXm4k+xhx7NARLO1zzZDbdOUbLl+60/Ny7HXS3DzmRzMh6KDF042yUBPSiF3j/RnffLexIAgA3xM2sl/+PYswoowxFxhJiOX5cZzSY6G1nU7oA5qMUvnxKqU28tLYfJOKgUaer/8ZD3H37tObhl4cWdSFNNLIRmIJxUwj7oKt7pLnkYcOREENKnlAJbw3MPq6ECRg9x2uNhIAVco7lbz9MAVIiNdswqzg4b0iqKZAGfv2fPX1fa/+5pgzt8MPdApJbfZQWJ+cWOqwECN4iejTJ7hHgF0NizUn4hD+Tnx8yD4hQANeXIjRbFyOwgJ6aegZR7rVs0dAZbfemtJkoSVovVmJvlM/d17HlKLxnM+ABI+GMWDk0WhEADG3UHzgKAOAd0096MUBtQjoOPIc5Ssul13bayeqx9I7j+9vudEj+g/tY8Be0B6VhSyIrcaa7BGZ9nF6G01W75vyY9ipxy7OZwLC4Ntq6U0CTecvK+Jg9AQoVJhMvTpGSoiQABabctY126itKeVjULIeIsXh+fqtPTZ8EscIrmysgbhyGNJPLhuiySU49MYnN2AlR7/Hw4WqnZImsHyE X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 20ebc95c-9c6e-4da4-a153-08d9118a96f9 X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3108.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2021 19:01:58.7605 (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: 5WoyMwI6wOHiyLcR1W7R5lQoxXhyLiITWGMSV9xB8nYaRFJfVt8dj4/KJewah/eOka/9oJlttQmB7s147s5TSQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB3073 Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org From: Yazen Ghannam Move the address denormalization into a separate helper function. This will be further refactored in later patches. Add the interleave address bit and the CS ID to the context struct. These values will be used by multiple functions. Signed-off-by: Yazen Ghannam --- arch/x86/kernel/cpu/mce/amd.c | 125 +++++++++++++++++++--------------- 1 file changed, 71 insertions(+), 54 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index f1a467cb74e6..263d419d4175 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -728,6 +728,8 @@ struct addr_ctx { u16 nid; u8 umc; u8 map_num; + u8 intlv_addr_bit; + u8 cs_id; bool hash_enabled; }; @@ -812,56 +814,26 @@ static int get_dram_addr_map(struct addr_ctx *ctx) return 0; } -int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) +static int denormalize_addr(struct addr_ctx *ctx) { - u64 dram_base_addr, dram_limit_addr, dram_hole_base; u32 tmp; u8 die_id_shift, die_id_mask, socket_id_shift, socket_id_mask; u8 intlv_num_dies, intlv_num_chan, intlv_num_sockets; - u8 intlv_addr_sel, intlv_addr_bit; - u8 num_intlv_bits, hashed_bit; - u8 lgcy_mmio_hole_en; - u8 cs_mask, cs_id = 0; - - struct addr_ctx ctx; - - memset(&ctx, 0, sizeof(ctx)); - - /* We start from the normalized address */ - ctx.ret_addr = norm_addr; - - ctx.nid = nid; - ctx.umc = umc; - - ctx.df_type = get_df_type(&ctx); - - if (remove_dram_offset(&ctx)) - goto out_err; - - if (get_dram_addr_map(&ctx)) - goto out_err; - - if (get_intlv_mode(&ctx)) - goto out_err; - - lgcy_mmio_hole_en = ctx.reg_base_addr & BIT(1); - intlv_num_chan = (ctx.reg_base_addr >> 4) & 0xF; - intlv_addr_sel = (ctx.reg_base_addr >> 8) & 0x7; - dram_base_addr = (ctx.reg_base_addr & GENMASK_ULL(31, 12)) << 16; + u8 intlv_addr_sel = (ctx->reg_base_addr >> 8) & 0x7; + u8 num_intlv_bits, cs_mask = 0; /* {0, 1, 2, 3} map to address bits {8, 9, 10, 11} respectively */ if (intlv_addr_sel > 3) { pr_err("%s: Invalid interleave address select %d.\n", __func__, intlv_addr_sel); - goto out_err; + return -EINVAL; } - intlv_num_sockets = (ctx.reg_limit_addr >> 8) & 0x1; - intlv_num_dies = (ctx.reg_limit_addr >> 10) & 0x3; - dram_limit_addr = ((ctx.reg_limit_addr & GENMASK_ULL(31, 12)) << 16) | GENMASK_ULL(27, 0); + intlv_num_sockets = (ctx->reg_limit_addr >> 8) & 0x1; + intlv_num_dies = (ctx->reg_limit_addr >> 10) & 0x3; - intlv_addr_bit = intlv_addr_sel + 8; + ctx->intlv_addr_bit = intlv_addr_sel + 8; /* Re-use intlv_num_chan by setting it equal to log2(#channels) */ switch (intlv_num_chan) { @@ -876,7 +848,7 @@ int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) default: pr_err("%s: Invalid number of interleaved channels %d.\n", __func__, intlv_num_chan); - goto out_err; + return -EINVAL; } num_intlv_bits = intlv_num_chan; @@ -884,7 +856,7 @@ int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) if (intlv_num_dies > 2) { pr_err("%s: Invalid number of interleaved nodes/dies %d.\n", __func__, intlv_num_dies); - goto out_err; + return -EINVAL; } num_intlv_bits += intlv_num_dies; @@ -896,7 +868,7 @@ int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) if (num_intlv_bits > 4) { pr_err("%s: Invalid interleave bits %d.\n", __func__, num_intlv_bits); - goto out_err; + return -EINVAL; } if (num_intlv_bits > 0) { @@ -909,8 +881,8 @@ int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) * umc/channel# as instance id of the coherent slave * for FICAA. */ - if (amd_df_indirect_read(nid, df_regs[FAB_BLK_INST_INFO_3], umc, &tmp)) - goto out_err; + if (amd_df_indirect_read(ctx->nid, df_regs[FAB_BLK_INST_INFO_3], ctx->umc, &tmp)) + return -EINVAL; cs_fabric_id = (tmp >> 8) & 0xFF; die_id_bit = 0; @@ -919,14 +891,15 @@ int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) if (intlv_num_chan) { die_id_bit = intlv_num_chan; cs_mask = (1 << die_id_bit) - 1; - cs_id = cs_fabric_id & cs_mask; + ctx->cs_id = cs_fabric_id & cs_mask; } sock_id_bit = die_id_bit; if (intlv_num_dies || intlv_num_sockets) - if (amd_df_indirect_read(nid, df_regs[SYS_FAB_ID_MASK], umc, &tmp)) - goto out_err; + if (amd_df_indirect_read(ctx->nid, df_regs[SYS_FAB_ID_MASK], + ctx->umc, &tmp)) + return -EINVAL; /* If interleaved over more than 1 die. */ if (intlv_num_dies) { @@ -934,7 +907,8 @@ int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) die_id_shift = (tmp >> 24) & 0xF; die_id_mask = (tmp >> 8) & 0xFF; - cs_id |= ((cs_fabric_id & die_id_mask) >> die_id_shift) << die_id_bit; + ctx->cs_id |= ((cs_fabric_id & die_id_mask) + >> die_id_shift) << die_id_bit; } /* If interleaved over more than 1 socket. */ @@ -942,7 +916,8 @@ int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) socket_id_shift = (tmp >> 28) & 0xF; socket_id_mask = (tmp >> 16) & 0xFF; - cs_id |= ((cs_fabric_id & socket_id_mask) >> socket_id_shift) << sock_id_bit; + ctx->cs_id |= ((cs_fabric_id & socket_id_mask) + >> socket_id_shift) << sock_id_bit; } /* @@ -953,12 +928,54 @@ int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) * bits there are. "intlv_addr_bit" tells us how many "Y" bits * there are (where "I" starts). */ - temp_addr_y = ctx.ret_addr & GENMASK_ULL(intlv_addr_bit - 1, 0); - temp_addr_i = (cs_id << intlv_addr_bit); - temp_addr_x = (ctx.ret_addr & GENMASK_ULL(63, intlv_addr_bit)) << num_intlv_bits; - ctx.ret_addr = temp_addr_x | temp_addr_i | temp_addr_y; + temp_addr_y = ctx->ret_addr & GENMASK_ULL(ctx->intlv_addr_bit - 1, 0); + temp_addr_i = (ctx->cs_id << ctx->intlv_addr_bit); + temp_addr_x = (ctx->ret_addr & GENMASK_ULL(63, ctx->intlv_addr_bit)) + << num_intlv_bits; + ctx->ret_addr = temp_addr_x | temp_addr_i | temp_addr_y; } + return 0; +} + +int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) +{ + u64 dram_base_addr, dram_limit_addr, dram_hole_base; + + u32 tmp; + + u8 hashed_bit; + u8 lgcy_mmio_hole_en; + + struct addr_ctx ctx; + + memset(&ctx, 0, sizeof(ctx)); + + /* We start from the normalized address */ + ctx.ret_addr = norm_addr; + + ctx.nid = nid; + ctx.umc = umc; + + ctx.df_type = get_df_type(&ctx); + + if (remove_dram_offset(&ctx)) + return -EINVAL; + + if (get_dram_addr_map(&ctx)) + goto out_err; + + if (get_intlv_mode(&ctx)) + goto out_err; + + if (denormalize_addr(&ctx)) + goto out_err; + + lgcy_mmio_hole_en = ctx.reg_base_addr & BIT(1); + dram_base_addr = (ctx.reg_base_addr & GENMASK_ULL(31, 12)) << 16; + + dram_limit_addr = ((ctx.reg_limit_addr & GENMASK_ULL(31, 12)) << 16) | GENMASK_ULL(27, 0); + /* Add dram base address */ ctx.ret_addr += dram_base_addr; @@ -978,12 +995,12 @@ int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) (ctx.ret_addr >> 18) ^ (ctx.ret_addr >> 21) ^ (ctx.ret_addr >> 30) ^ - cs_id; + ctx.cs_id; hashed_bit &= BIT(0); - if (hashed_bit != ((ctx.ret_addr >> intlv_addr_bit) & BIT(0))) - ctx.ret_addr ^= BIT(intlv_addr_bit); + if (hashed_bit != ((ctx.ret_addr >> ctx.intlv_addr_bit) & BIT(0))) + ctx.ret_addr ^= BIT(ctx.intlv_addr_bit); } /* Is calculated system address is above DRAM limit address? */ From patchwork Fri May 7 19:01:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 12245089 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F50EC433ED for ; Fri, 7 May 2021 19:02:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 73715614A7 for ; Fri, 7 May 2021 19:02:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229821AbhEGTDH (ORCPT ); Fri, 7 May 2021 15:03:07 -0400 Received: from mail-co1nam11on2077.outbound.protection.outlook.com ([40.107.220.77]:61345 "EHLO NAM11-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229742AbhEGTDC (ORCPT ); Fri, 7 May 2021 15:03:02 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GgSoOM7ABtB5rgbkM5tCy9/XmjMuw12llHQq321ow8sBzx0oAG9UrKnTt5nN4FJkaZPLL/0V4JCWA8EkhTsmI/VYGu32pMXcdiV9pO8SnkI7IMruh0JBxnrgBQGYGH7ic1/ovF/42zl+rwssxubiRpMA3TK8b78l+SULnaEC8F4H58r8zztdL93VM5yXnfCU1Gx1lh2OhEwY1z6s2Tr5fgGpzTsWpBPWvdm3Tn8z+6MC33LudHmXRnf0WIIZrSCszzcrSZMi5iMStRgJFlGBIR9xgEGHg9DTYS7f65yCKs0Pt+KDgdtx/u+b9CuKsVo8Lb0aB+lPCJzkGlpM4UD54A== 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=E5KhUkeCccC0j7C4W+XKW7M9XcYfyFmDnxzAUKtobsM=; b=lgsqtSkg4rDtbGW5M1TxSaSEY6qfYtcFCjFvYpMdhfP4/0LhZAOMBIUyIm30zhNFbo6LMClynEOTtFr9L4c1dGC0coHDxUSjzSECp2XX+rcmmMJzM9MLLIpmlmPxLLd2ZGQjjt75KDNsuaG/Z7RFFleFlbLODLyuV2UdHrTTfKHMZDIiMYWGozvZP2OSa3OavEKWtx5SHniNTceC4vAeqnNolc7InJUxsV+UtBrbrYjDEcotBZXRtBIrtps1nO0GpEUe0Kzl5YF/8P0EIac6LPxMFWNfDtc6zetDiRsFznGk55YUSODCDee+B4k+9tuKokQA0UDvmLRwWU4WNtDVfw== 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=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=E5KhUkeCccC0j7C4W+XKW7M9XcYfyFmDnxzAUKtobsM=; b=ci/UflQQmJxuyhsfuTcC7ngKA8nFZckQ0eFRcxptyQ38++Y+Yl1RNMFZzH1D5ni4OrVEMoxRU/m1AR92NeWZGOa9ppM2gBuOdP6e2eVyHVzth0S0TTK2dhqhBZSWPM9sJQbTAoqMbHKHQ5ksdR4kyLk4OqGTEKagXHY9dk0xk7A= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) by BN8PR12MB3073.namprd12.prod.outlook.com (2603:10b6:408:66::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25; Fri, 7 May 2021 19:01:59 +0000 Received: from BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211]) by BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211%6]) with mapi id 15.20.4108.029; Fri, 7 May 2021 19:01:59 +0000 From: Yazen Ghannam To: linux-edac@vger.kernel.org Cc: Yazen Ghannam , linux-kernel@vger.kernel.org, tony.luck@intel.com, x86@kernel.org, Smita.KoralahalliChannabasappa@amd.com Subject: [PATCH 07/25] x86/MCE/AMD: Define function to add DRAM base and hole Date: Fri, 7 May 2021 15:01:22 -0400 Message-Id: <20210507190140.18854-8-Yazen.Ghannam@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210507190140.18854-1-Yazen.Ghannam@amd.com> References: <20210507190140.18854-1-Yazen.Ghannam@amd.com> X-Originating-IP: [165.204.25.250] X-ClientProxiedBy: BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) To BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from aus-x-yghannam.amd.com (165.204.25.250) by BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.3 via Frontend Transport; Fri, 7 May 2021 19:01:58 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a97e4186-b146-478b-18ff-08d9118a978d X-MS-TrafficTypeDiagnostic: BN8PR12MB3073: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2582; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vElC/nWTVe0fBQqW9pDIjAjgXZuwa1/YSt7ftjQbXRvDItnZR5hReJr1YWQR3hIs6C7XXMKlYXUbhIaEY6EcB/cGuRiRLWPiCtYpLZ09i+R4vszcRG988QpEAb0pP78a4lA8fgx/8PYDFPxDRZblraqw+2mFl2N/N5aBG0cVaYsi+yYJHU32MaOMw9ugJDH2AMiZs3t3fsCWBd4ZeCg8Q7pj6Bt4KV8+07CKeei18DgJGPRrKWE3mqmLBk0fsYFDZHsFF6XQs+oFXC2oNp8MaUjQKsPXykkFTjO9ISO2TvoQOgjbuDI4Oprys5/Y9oZ8HyMSqDZZvyjrRUkmVRf+b/FsDgtYPmWoI3i7XnkrVgjvV8G4JBPrwyYs9x4/6rdHHszyWBGLnhDKoYdBK5xWdujFT4Dh2uJAsd3QE3OEIf7EG1za3QZSsc57Y/uaZLRazs42BQQ0dTQRyIFzW0gcyJtrmT0QcvJ39hYno4JzriuiqkemxuIAeJ+HbLKcwzQMAmo6jioaXNc/78co6fZSWt89dmSIjeL6CWPf7mwRXI9dGf3Ub+r+7cNbsNEp9qE5lP6V5ovi8ZPplfbjMECJ21TApvgzPchJkNpmDuGSUfDcxCnU9tp8z1P/y2G89PguWAx/nHMHr9iExbF6fWuGj5n+T/B2Jm8NlPXXtcLF3Rk= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR12MB3108.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(136003)(376002)(366004)(39860400002)(396003)(346002)(316002)(6486002)(8936002)(8676002)(16526019)(2906002)(6666004)(186003)(83380400001)(26005)(6916009)(36756003)(52116002)(86362001)(66556008)(38100700002)(38350700002)(66476007)(66946007)(4326008)(5660300002)(1076003)(7696005)(2616005)(956004)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: c0j38krPUScyG/MDq0c2tNu5YcgZeqxMU/nCpFs5HhusM9xPkkE6Ky3ABieASF5/dKlIlDpFHLCFlPZMj5Bk4IcpqqUyZZ/GRKEu0fHwHhpEwCmiX98nyZ+XqqK8CDIQZbvZwDfwvx19HQZc9RM4jksMy/6P/lvYSj/oiHcUHeqtp8Qj4ww1V0q8GG73JRj0KFelFV+aJVq4L+zcMmoRE2Dm3fWsCNIZVE+/LrYF+uOSDDxoSDrxjekRrupnVK1Vufd9Fe7gEsvS/msShHsZgsIjufOqgGU3gQsIZmGiORNn3SnR/uwDYS2+s4/JUZVW9xfwZgNZAZbkMnUHoCYgWvJOfpH2P+5d5tZku6KyE0qH2E8MIsPOd5A0eK0VDnzMJTez4mgHi21/5ky/AR8XLFvyy488zRjG+Q+R7oB/lPErMEaqiPBXyrw8SCEqfsq/jAHvkLNUuZ0gqq2ftouuRFcpq3qSqaC5AERXCaHO43mV3+qmat1wT7XAHu0Bf8uKyJOfNPGyxuD3AavOfFDsA0csyuL4GjFfeGsXA3dQMX4U1p/buSWWPTi7dgvPpH345pWqVwl21jx5X1Qn7vnvxFjS9kBN93mi7VU7N9JiJyClRgcDH5+BbccLCwLN9gBevZHEY7d4sA1c57ifRLVvGWQYgNqZ/NSC/PPhEYYEPkJBfHNh7U4klZrx/NzAN9niWmRj34rgRqX0CLGPBKMjaqlxRt8HDOzQUH4u1Kmu8e+5aLAxUlwK7uukcctw4joH+tjxK3r9v7LjWtYoko9RJqpPu6AgSYWNQckAUqk5Ug9uYqVIfaahnQbNcSagEMrKNQcmQVmovJbqjFMv1UXSdffWmtCzmc9gU0tfkFfHO0pP/K3ND3OrwApvwGDtM+BmS7OW60MXxVs3c+bjhIVS2gzU+8C4bf+WpcnDVeATObrzBjx6pUBpfmZ6VQpc/ZeP677J/dqZv8gQZthUOahulJxhACuGhx4/mNPfbxFB3fb49WYvwSfjD6OW0xP3YJ9/HO2VIBDHfyyZyu3972ysNCabCmDfGEEd9qYdTOg1g6Sr5SxJkN/Ac6SGm3g01RxG7zr/0j8+y1j/Xuy1qbn2khk/ZviSl1YDXLsF7ACOHdOqwrIbuPpuvxNdRH00XODSWxyrjUQ3MaZK2jOLKXcr+vdgJLjymaf2hwokSvEMXCk0DWqrvVlhiZGcsdalPiRJqFJYIrWDiIySitaQDxR/gPO7RfMgL7RqDH6Fq81iY40HSo/XgaXlQg2eGjrD9sqk/JOGOtTK1KF0RV4/JpxwSfr0H50LvFRxcCzTp1vGIEYBFX9iImqDtvwx7joyLXNJ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: a97e4186-b146-478b-18ff-08d9118a978d X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3108.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2021 19:01:59.8019 (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: nIrMBBNR674Sw6TDRQY7p0wuti2QWix8eahhYWqrPA37ERwdKUx1HcFMb7OLQJfJqe320pMu2QvLfTg/M4NP0w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB3073 Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org From: Yazen Ghannam Move adding of DRAM base and hole into a separate helper function. Signed-off-by: Yazen Ghannam --- arch/x86/kernel/cpu/mce/amd.c | 45 ++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index 263d419d4175..d1a6405bb990 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -938,14 +938,34 @@ static int denormalize_addr(struct addr_ctx *ctx) return 0; } -int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) +static int add_base_and_hole(struct addr_ctx *ctx) { - u64 dram_base_addr, dram_limit_addr, dram_hole_base; + u64 dram_base_addr = (ctx->reg_base_addr & GENMASK_ULL(31, 12)) << 16; - u32 tmp; + /* Add dram base address */ + ctx->ret_addr += dram_base_addr; + + /* If legacy MMIO hole enabled */ + if (ctx->reg_base_addr & BIT(1)) { + u32 dram_hole_base; + + if (amd_df_indirect_read(ctx->nid, df_regs[DRAM_HOLE_CTL], + ctx->umc, &dram_hole_base)) + return -EINVAL; + + dram_hole_base &= GENMASK(31, 24); + if (ctx->ret_addr >= dram_hole_base) + ctx->ret_addr += (BIT_ULL(32) - dram_hole_base); + } + + return 0; +} + +int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) +{ + u64 dram_limit_addr; u8 hashed_bit; - u8 lgcy_mmio_hole_en; struct addr_ctx ctx; @@ -971,23 +991,10 @@ int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) if (denormalize_addr(&ctx)) goto out_err; - lgcy_mmio_hole_en = ctx.reg_base_addr & BIT(1); - dram_base_addr = (ctx.reg_base_addr & GENMASK_ULL(31, 12)) << 16; - dram_limit_addr = ((ctx.reg_limit_addr & GENMASK_ULL(31, 12)) << 16) | GENMASK_ULL(27, 0); - /* Add dram base address */ - ctx.ret_addr += dram_base_addr; - - /* If legacy MMIO hole enabled */ - if (lgcy_mmio_hole_en) { - if (amd_df_indirect_read(nid, df_regs[DRAM_HOLE_CTL], umc, &tmp)) - goto out_err; - - dram_hole_base = tmp & GENMASK(31, 24); - if (ctx.ret_addr >= dram_hole_base) - ctx.ret_addr += (BIT_ULL(32) - dram_hole_base); - } + if (add_base_and_hole(&ctx)) + goto out_err; if (ctx.hash_enabled) { /* Save some parentheses and grab ls-bit at the end. */ From patchwork Fri May 7 19:01:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 12245091 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37577C433B4 for ; Fri, 7 May 2021 19:02:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 11DCF6148E for ; Fri, 7 May 2021 19:02:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229765AbhEGTDI (ORCPT ); Fri, 7 May 2021 15:03:08 -0400 Received: from mail-co1nam11on2081.outbound.protection.outlook.com ([40.107.220.81]:18843 "EHLO NAM11-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229675AbhEGTDC (ORCPT ); Fri, 7 May 2021 15:03:02 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Zbd5yYS6KRnV1MLwT6YQtICij0mo1v5fdWC03RZnOJrb2tclOilOfrBdKs/74zrQzAyjh8igX5GoVJRKxhvYqa2E8TfOuPlR7kYPTRkmhEh5VX1fStZXV4uriARRewTRVeTUlbyuPcFO+DvAuPE8Ln41qEcSYLQM3Rs28/DgDGdmkpeYSf8GXZi7ga1oWqFkbblbxgBF0CGE9A8GyuM45gCNYsVKduak+LHU6sDcD7phi4wtyN6dyUaklfRJL75GbQNYAuLaQ4Ah5RJXj+tT5c/VVWUcf8vTUUSr9UFQzACK03aJkPRXyIIaDD+LR05zRHzTPgk2niVTc0+YfSoecw== 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=Uf61jbWmeTQVqQwAWSIJdaXrcZFgsbuuo5AQXXcrVUo=; b=nNzuDqi/OoCzpYYWh9EJbD3E8TtryB9LDzmpXsJfnSbseMgtidWU3gjlOSVA989qwhA6inmZAYsrfM665epn6wiq+TXgyphWQMOPXOlu/bWt72yTAIcRwAzjKEhPHq0KA5a3jkyx9WMC0adjl3IB2j9419odb4cGqP/wsjhEab/Pnz82qfHxueufeZH4snQThp9A2Ddpk3xmKbpNFgxZp8cZ+CImUDdEd+DhYFdZghhfpMTfiT6H3e2EN5G9VYckbViZkc8UoFMyiPE3lgCwRMtgrRXPF7l9ZQJb33OjxJc4lJWxkYRvzQRpcca79HHtF0wuXB1iPoE7ZiwRvJaG4g== 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=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Uf61jbWmeTQVqQwAWSIJdaXrcZFgsbuuo5AQXXcrVUo=; b=l6n5mNbVAxmpsbiQdgkg+Kpp/b76ZMOQCsfu+O/IFo+sws7+NOuD/CNmsG/TWbLq/DEqDIEbbAPcSiPvILPzhOyMAp2dNe2WZCiQF7GtrIo62BxiMQJdiGApG+gfhnkOkHpd8XGW8v8lxfKllRpucfJeXugTQ/+HDcHeYem1b98= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) by BN6PR12MB1748.namprd12.prod.outlook.com (2603:10b6:404:105::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.24; Fri, 7 May 2021 19:02:00 +0000 Received: from BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211]) by BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211%6]) with mapi id 15.20.4108.029; Fri, 7 May 2021 19:02:00 +0000 From: Yazen Ghannam To: linux-edac@vger.kernel.org Cc: Yazen Ghannam , linux-kernel@vger.kernel.org, tony.luck@intel.com, x86@kernel.org, Smita.KoralahalliChannabasappa@amd.com Subject: [PATCH 08/25] x86/MCE/AMD: Define function to dehash address Date: Fri, 7 May 2021 15:01:23 -0400 Message-Id: <20210507190140.18854-9-Yazen.Ghannam@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210507190140.18854-1-Yazen.Ghannam@amd.com> References: <20210507190140.18854-1-Yazen.Ghannam@amd.com> X-Originating-IP: [165.204.25.250] X-ClientProxiedBy: BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) To BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from aus-x-yghannam.amd.com (165.204.25.250) by BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.3 via Frontend Transport; Fri, 7 May 2021 19:02:00 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f18d3a2b-7ff4-49f1-c3d1-08d9118a982c X-MS-TrafficTypeDiagnostic: BN6PR12MB1748: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gZOp80gNslJmIDAnKNdVfxTyUujW+aoEBE6GrfgbrGK/g5sQqw0A5g1iMNASt1bPbq/hRTgpjTlrS5FoUa4KhXc/EY/QEj+dBQeMZmkX/GmKu8pWaPw8s4yDcedKFH+bPNrFVMy8Lscveq2hozGgasF8RfuL0I+ev1t0OUbv7V9k73bxfQlKk8fTacU1zUW4u5Cqh2S+MAgX8rUZu6MZS2jLbGWELGNwiPj8BqQG0oEde4GrN9Dchkudf9wXJxNOF4PvZm660M5RN5ZTNj/sjVjUjw+kaN3iS1S901ozUrUM7vL+Gr063NU3NSWNoiGm60sFrooeezpMD+TQa/0K/jX87YV1djm4l0PDsvrZzy+zCadz832gu1Id0sp7OKJo3c6Kqdfju3+5IgBqGfLrspqE/0ffgivCGKRHsVDtVHnAvwiwxR3CVWjwstZHn7Ec0iaXvhj9J3eAf3iSh0m9OdJY8VRmkZLrYA1SSpnvICeZQHaVmiV51/lM6CskmLWuQOBIQ92i5WFyxDASdWyv/sO+w6x6wkF9Cbw5GmPrcvpie7PN2BYBhlso68Lg/tlActQixxkfAvF/7iA9ldfRs6nY9h7rpaMDuOSwXc7Hz9eA2hUGkrFzALwWSrpuN/bO707cpN+1S7wq/bU135lvzsg7egRiBDKatSmaJZD/utQ= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR12MB3108.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(136003)(39860400002)(396003)(366004)(376002)(346002)(1076003)(6486002)(186003)(38350700002)(38100700002)(2616005)(86362001)(36756003)(956004)(66476007)(66946007)(66556008)(8676002)(16526019)(8936002)(6916009)(83380400001)(26005)(4326008)(5660300002)(7696005)(6666004)(52116002)(478600001)(2906002)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: UBQYXQPhDTuf5+m09pgujdFnYmUZb6w54Lqdy2lIwLnRXzK4xm3zG326+hNCOzCEhvmIJhDwZNhrtKBnBlQxAs/Ww+954TRPcovTa+PUImOEMhRKMAAan2O6SGHl9iMQ/Et4YR9l7jgfJE8FvUMWhMdNwyGOIhClGWonnpt61+57ESVngcw2gk4//0QPMRFQi0kVuy44S2mgUVY/NWez/vtbmkHWP7SKfVAnPnmiPgI3gHeBgByaGe0seMbNovxCxU3pbZx9/WlTyjHZdycTqfxP4fAZcRuWN7LBhvI3p+PYsapX89eUIApZMLuEGluYROIw/QT6vgds05Tr9SZWjCfUcWf6AY7UN3wlhhUOqoLMZ1FG+ZPGruVGLMGN16cPyJ8SsJqPpQVesT1G6yYjnVXdgiJGs5cwVh4fKAQ6mBOWR3mnLEsJ/haPETyR3bNiZ/hrK4yf1ZT3IZboLVACbU9SoM2SiAfAUDBIstlomL97TN3CbceK32a3RXLWtSuC57kKej2BV9VTUfIpmrltC1y+zLaOgjRO2Jb6saVFFyJKkeSu5CHroFvMQfYEqzHPgUIgte3FgnO8TE+x6seRIwJSnFm3bZ2psAgzFwVeXr7DrjirXeNA7610oFVuft6Wr1dSFaVN61iADH/cdKatTssZF4g9msOFwyaBAxfoWMM/hiHk6dxOkCaoVOYSjO9hEiNlf94a8ZERqvzNNQmF4Pb/Cm0HS7btuqnDcYRHHFh/ObWgp+8cHMa5OXIyokTriqpv+i54uMyTSv0/2Z6vwL5WHnOplwz1cllRZEsvHrDELydN1V3A/iZfHTwXtll2HiKm2rO+ox6w95b27691KC/SsfBr7N9rX7BdAtG5qy0rQu1DuJrHgx08AvbAFR/Rp8TGEYsrccQce695GghRJLslV3dkIhYa/2mSpY1R/mZqZHG6mzf/vCtn4YISJitIiHsabxAcuv+Ce8UznyLIjqSYDR9Vcjn8tlYaJAlxgvKvHbgMmL6An2zVsLwM774G3L1TkXE3V3do/vidDw3D3UFBj5ocaoCBrndytW72ydq8elwTauy4d8TY5DywskZefFhl92h0GcxLMCDxeorXZAGzC5DuqSu6zdk5I9KHbscdd/BGQqKWl/cOW+Bpokk+VYygIIS9EbXpThM+qzOKyRblEoMC8DR6dSAMIDbvKUHuBEGkxsUrznY6Dz5R/WJ4S0hT40eQPNH3EMdEbTRPp2ThW4I1TJ5OQedtoJmgzoPDtXmKgN02dWv8eU/IjloeF32LiqlqYmcUorOeENZkq4d+FC5zaisyYY7HKo5YVb4KzVCCwlfGY/gkkoBC3qhY X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: f18d3a2b-7ff4-49f1-c3d1-08d9118a982c X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3108.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2021 19:02:00.8124 (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: 8J88ZFG4YO9/aK71r6CWQ0CZGsThIt7q58I2aZQXUga6r5WZX14uBqmUSDe2QkMAsGXl6HP2d6kz7KWjsZZtBg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1748 Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org From: Yazen Ghannam Move the dehashing code into a separate helper function. Define a DF2-specific function for the current code. Specific helper functions will be added for future DF versions. Signed-off-by: Yazen Ghannam --- arch/x86/kernel/cpu/mce/amd.c | 41 ++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index d1a6405bb990..e341737e03d4 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -961,12 +961,34 @@ static int add_base_and_hole(struct addr_ctx *ctx) return 0; } +static int dehash_addr_df2(struct addr_ctx *ctx) +{ + u8 hashed_bit = (ctx->ret_addr >> 12) ^ + (ctx->ret_addr >> 18) ^ + (ctx->ret_addr >> 21) ^ + (ctx->ret_addr >> 30) ^ + ctx->cs_id; + + hashed_bit &= BIT(0); + + if (hashed_bit != ((ctx->ret_addr >> ctx->intlv_addr_bit) & BIT(0))) + ctx->ret_addr ^= BIT(ctx->intlv_addr_bit); + + return 0; +} + +static int dehash_addr(struct addr_ctx *ctx) +{ + if (!ctx->hash_enabled) + return 0; + + return dehash_addr_df2(ctx); +} + int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) { u64 dram_limit_addr; - u8 hashed_bit; - struct addr_ctx ctx; memset(&ctx, 0, sizeof(ctx)); @@ -996,19 +1018,8 @@ int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) if (add_base_and_hole(&ctx)) goto out_err; - if (ctx.hash_enabled) { - /* Save some parentheses and grab ls-bit at the end. */ - hashed_bit = (ctx.ret_addr >> 12) ^ - (ctx.ret_addr >> 18) ^ - (ctx.ret_addr >> 21) ^ - (ctx.ret_addr >> 30) ^ - ctx.cs_id; - - hashed_bit &= BIT(0); - - if (hashed_bit != ((ctx.ret_addr >> ctx.intlv_addr_bit) & BIT(0))) - ctx.ret_addr ^= BIT(ctx.intlv_addr_bit); - } + if (dehash_addr(&ctx)) + goto out_err; /* Is calculated system address is above DRAM limit address? */ if (ctx.ret_addr > dram_limit_addr) From patchwork Fri May 7 19:01:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 12245095 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5B30C43462 for ; Fri, 7 May 2021 19:02:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A24416157E for ; Fri, 7 May 2021 19:02:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229786AbhEGTDL (ORCPT ); Fri, 7 May 2021 15:03:11 -0400 Received: from mail-co1nam11on2055.outbound.protection.outlook.com ([40.107.220.55]:34138 "EHLO NAM11-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229791AbhEGTDG (ORCPT ); Fri, 7 May 2021 15:03:06 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MxbslUB9KclIyTTPcBF2n5Oh3ceiSp9cRCuihAHs25oUTw8+uxrS7k5mdbXEbPTi6gBiDp/08eR48VwfjtlS/2wn6Oa6K1GlHWRDE5p1rzeO971gfOvBd4eN8Wrgq1Ef1kOigAPbckA+L8sYdk2HMsAVNLM7qF/WAcK0/U640fQ+p1kmRIDqmgOryLRmOj45rN+3JVS0wu5UoLnKb3ruwQTqKDmusac/NmMQx1PK5RJ2Cky9VArthFbjm17M0lhd9Yc+WdBrz4aK+q8LudMmNl50Wg5Z5c3673AKVp09AHRvqQ0IGCrq+z2c7N6HdLOhfR9o53zVvjx0AFYmKZ1KiA== 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=xrGj2YD4nr3KhfLaUoK7DhhOD8puGiPmXxMIfH3BKMM=; b=SxV0zz1skVTH7VeMU25cjVP+NbvnRqabBL4QFqE6McdJ2Xwc/lG60+gzqt4MeUrFENrb05NjvgMKZ8Qs4dWLbWgcRfgrUAcQCTDpkiImQh5THNAF+tB8QYkE0FuRoefxcOrJbLmnxS9HSJxX4DcSa64SN8OvkBkCQDh/r/ilBof1WiuupWhlm/uu77c1U3ZVoNZKkSI66vohIdQf5XPsjGpCoT49rp6DATYV+dqtPwkgz0vU1L++oBnp7BgS7aXTLkRQdz3mkKRcuVU6LpOo+J3cOoMrrNOzUOM1TrK0WDDvzq5PNHhYkn4vZNUr+pYqQafX1TYRqFD7H5tXTCYSqQ== 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=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xrGj2YD4nr3KhfLaUoK7DhhOD8puGiPmXxMIfH3BKMM=; b=qQMLJAUoFmpWhYSiMLyKnfSNxVg9G0AGJ0rvI7uS4c0wniFSDCRnoWjYH8eqSc84bsyeJotAEoHH7L+nfB4VdzkLpbdylx3v2dpWogbtulEy4B7IZ/35sAHxKW41pIs6ZsGj+J9uh9sGf9El2bl5RHsfYqiNcZX7trsAwJHEnrw= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) by BN8PR12MB3073.namprd12.prod.outlook.com (2603:10b6:408:66::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25; Fri, 7 May 2021 19:02:02 +0000 Received: from BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211]) by BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211%6]) with mapi id 15.20.4108.029; Fri, 7 May 2021 19:02:02 +0000 From: Yazen Ghannam To: linux-edac@vger.kernel.org Cc: Yazen Ghannam , linux-kernel@vger.kernel.org, tony.luck@intel.com, x86@kernel.org, Smita.KoralahalliChannabasappa@amd.com Subject: [PATCH 09/25] x86/MCE/AMD: Define function to check DRAM limit address Date: Fri, 7 May 2021 15:01:24 -0400 Message-Id: <20210507190140.18854-10-Yazen.Ghannam@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210507190140.18854-1-Yazen.Ghannam@amd.com> References: <20210507190140.18854-1-Yazen.Ghannam@amd.com> X-Originating-IP: [165.204.25.250] X-ClientProxiedBy: BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) To BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from aus-x-yghannam.amd.com (165.204.25.250) by BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.3 via Frontend Transport; Fri, 7 May 2021 19:02:01 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cc47f9a9-43d2-4b9e-0f4d-08d9118a98cb X-MS-TrafficTypeDiagnostic: BN8PR12MB3073: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1247; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pslJWjdsD2Pfr4TKPdp2KaJ9TabVW8ma1/xmPj4h2UnAnhkDdT2J/r/ciFq+sMLUEx+EmH+WkGJnXBilStRyan7MdEZcBrZiBbHl4ZIELeVSFwpvQvdPJIcfXfRwKJhyrn5NlyI+CMzEt6CddTyPeCTuTMz4Mb1rqgq1cSh0LErEEk/97pft8frAp0tFGFiyl7vP3jfFCN9NGwqb6hmPe11yDqjIB400pd0ClD9JLSoPDsTQrEOTfmq1yDGPpOhz8hgHV16AzPozumQvik1Ax8p4bnJwV74oKQWPDYXjjgPOxt2JFM8JiHKB5irc/ZaNCJtrNfTnOBNRh6M2aIeRH6Z7od6la2Chi2Rt7dToudsRMxQB0MoeJ7GNWxDjrGirkTNf0hqDJsg166gvHOIY6jom6y3LKH6n29y7GSN5RgnHEFhlnlfjFlwvL4ZfScrzgokqL6Co3512sTbtpDj0RLA3u+DT4efui0Q6bfoKZD49Ge+7gVag+RcIQFVE+WzYsuD209LLO1Nue6N3FzR5rdeGKC2YLgxe45G/iv3qFYTHtQTnWIkPrqoA71jvT2J1CDxaimGaL87Mh0i5fpBxQb//iiDy6d1S6ql2qsLfYEBW8vuKG6JGAc4OUMawWw3N1jzMaZk/5qWMsxPfwPoiN4mXC+fT7qFPkP8ECYnYHs8= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR12MB3108.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(136003)(376002)(366004)(39860400002)(396003)(346002)(316002)(6486002)(8936002)(8676002)(16526019)(2906002)(6666004)(186003)(83380400001)(26005)(6916009)(36756003)(52116002)(86362001)(66556008)(38100700002)(38350700002)(66476007)(66946007)(4326008)(5660300002)(1076003)(7696005)(2616005)(956004)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: J0cUcVa2rvcf5lFa/tNtcWgDZ+BhoDmSiDU7K4YDlSJNDaJfSwv2rpmsDKCDKVJLuxMSGrSe2rjqeZAlHDlTwRj2K7N/S1fClldMVcbh2SaVNWc7KNGCqMu0GseChoWPAv5qlxqnJdGNntzLTQG1eP0qVXhYG1uov6nGh4WGQnwYD0fephRr1yGAdVtiEGlpgFc7yD/MzIUmqI6lbHkWdNcPyKMuzLPi5xS+E5JYHfFQVl0urcLR1L6LNarIaic0CrIqGpQoyFx8HoVZJi77sgaw3jjGeSZfu8cPqNN9u5dcJwdavofTS7bsemc5B7HyQ9VCr0eeGXPYJYvQP4nS6qNueevS99ddI5yXUXa31XavzMxogF1prSV9hVoSac/zrKgNyx/mQPuQffS5AXSTZzkem/UVWs5A1BN6mDLluhyWihV56LYUq3Aoq9BwEHqb+Ir8XqN+jV1qgn3B1YhvBCKh/dtTRxkkDoxGo2aq8MsciecmCLg8Duq6nH/DFJ1JsNi3w79IAgy4Vqm2SfAzbpw8i5Xr9+pBR8jBOkqwISxmNPvcdnAHZ2OHz/97yC5dsAYfJrZxW/fGEwqn0z/YQFT6TmgRsgE7IWpm5eQmRwRkXM2cM5p+v8cKuJPg+tmGy9T6oA1doBcTDtgTIg1cPYjLdTXQ4sSCprc4Y+D737Li8ts5E2/UdEjeYSTLaF9huQ+1Vmo34n4nOKumjIAe4bjEfVGv9DocrjFa3ThzyixIJaYXhTTPaHVQpazlM2PcJd4LVcnZcaaO5ZliQdZ664eEfZ1emS1NYjY7htryTpuBnN0xnxo1gpaX+yGdM6qcshm9Vcp4IrPMMzG43AUc+k/tYqNn2M6EA+PJcv5vB6+ufYxkooAwLw5Ev/cD8JAjYCYsU1EI22kUBcqvsUG7iuXa2DMHdX5TdZAthd+20FTdm1NArMDTDHILma2bDHF/CII3wwVaQnnUluJKsQuFHlIy5jT/83E1ATOxhug854JG0yivVr+LEFIbKgbuP7cfBF/Ov20Yga5Nso2xbYq3CAH/ie3uEz5SHIZL7ebE8gmlMtaedW/0meqr8HN2mSzq5KuXIS9KAFsid10+bZHUsfM7oAeaLCmRNczlUpSxbLkLmsBBv4OdzEphA2LttL/jv4RuwkXbKQjq6RUEG1jZPb6uea9xH6T90pQjX4RNEuGOajHuvBZgntYpUxPN3TTI7LWqxsIK26flEmfJgXaylUxERiMMMWT/H+eTtcu0NgqXeyf0o+CPTCtwLD+WC5uMZUw+bdD79kuAT6G9IXCzbmMGE4wfKgndXAeauhy7rF+7rGsje7evu0HZqbpNt/Pr X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: cc47f9a9-43d2-4b9e-0f4d-08d9118a98cb X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3108.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2021 19:02:01.9767 (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: HVq+1n2YbeoOqR1u6zdsFBEYSk1lxZ/9l819J1hDjvE7c9DK/1M/9Gm417AKrMUt9IwgQp/OqUDKGBxRdKG9kQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB3073 Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org From: Yazen Ghannam Move the DRAM limit check into a separate helper function. Signed-off-by: Yazen Ghannam --- arch/x86/kernel/cpu/mce/amd.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index e341737e03d4..7aaf8a1dce2b 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -985,10 +985,20 @@ static int dehash_addr(struct addr_ctx *ctx) return dehash_addr_df2(ctx); } -int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) +static int addr_over_limit(struct addr_ctx *ctx) { - u64 dram_limit_addr; + u64 dram_limit_addr = ((ctx->reg_limit_addr & GENMASK_ULL(31, 12)) << 16) + | GENMASK_ULL(27, 0); + + /* Is calculated system address above DRAM limit address? */ + if (ctx->ret_addr > dram_limit_addr) + return -EINVAL; + return 0; +} + +int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) +{ struct addr_ctx ctx; memset(&ctx, 0, sizeof(ctx)); @@ -1013,16 +1023,13 @@ int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) if (denormalize_addr(&ctx)) goto out_err; - dram_limit_addr = ((ctx.reg_limit_addr & GENMASK_ULL(31, 12)) << 16) | GENMASK_ULL(27, 0); - if (add_base_and_hole(&ctx)) goto out_err; if (dehash_addr(&ctx)) goto out_err; - /* Is calculated system address is above DRAM limit address? */ - if (ctx.ret_addr > dram_limit_addr) + if (addr_over_limit(&ctx)) goto out_err; *sys_addr = ctx.ret_addr; From patchwork Fri May 7 19:01:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 12245093 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74D8BC43461 for ; Fri, 7 May 2021 19:02:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5971A60232 for ; Fri, 7 May 2021 19:02:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229827AbhEGTDJ (ORCPT ); Fri, 7 May 2021 15:03:09 -0400 Received: from mail-co1nam11on2081.outbound.protection.outlook.com ([40.107.220.81]:18843 "EHLO NAM11-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229775AbhEGTDF (ORCPT ); Fri, 7 May 2021 15:03:05 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Sc3ymPczDQ0B2I++hUm85ER4sj1bZLgSiH/MCV0+gSwpTHEIul1CmXwzQuWboukQhstrvaq+z/i1IuJfyQWsx81GFa0EBfoMWRVYNpr6nZE3pA8aok3oIjcZzmmhTklmgk3LtbPcstMA5NJzpb+ixdEupHJjzDeMSrIUN1GA2tWhWYr57Hub2niW4LRgV6GOYTOc/WUcd1F8XJJ/gTSMwBfrQ2ZT8gJhHZfSF7SbXco0LqY95Lueu2J3fNCAaPF2vVAhMtesCzbvFDinMPVkry+vwNEwnUvn99+Bcs2HiNVCbPKPlBb4IE70nzLjcoRBZZAbeMK/iUkKxNn0cR9PPA== 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=pjwIbB8SP02VFUo6iTLBOw5zmh+x11IV1ifhJVwns5c=; b=OAGC+5f5WYL0/e7Q5IkyqbQ4Eqwvurw1w7pyhzVPFNLZkproQnHOXO6MsxFyPLpGp3fOlgwXdhjLQQSS5+uXQfHo1wvjTwF8xCBpDJ/DY1BSyR28jr5OiHtwTh2CV6TywqhDbU/1YFAgxpB5Wreth/bJMccY1wR9MZ/zetfDsaFL6yo8i7HPIs6yTLIdHjD1TM6KP3SoKVY5NMxnBGxez/okBPu0q5dnlq+m6L+sNaTv5h8ubPXA3Xl8RzxqSqLf+8cBZ6mo8Kc3GlRDl7MrVEcOvCOFQXqfdS+y25EysUzoRsKYjeGepWQce+FBoWMY3o3YDLzp9gu5JmsojyXK/w== 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=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pjwIbB8SP02VFUo6iTLBOw5zmh+x11IV1ifhJVwns5c=; b=hy/vuMT6ocYREP/5l+ije9GT+ORjPlMFIZZFtl5D76I1P3s7t4oCHvthXTtuJqJAnOIaGA17kDLq/dBHDlqIMqVUnxZ+CT3oYIcTidLfKIpudOhZDY2MVrAbZTnPPhvd/zn3xEagQHC+uRXJ3zxNdQx2zk8N28X4EsWCKRceq8A= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) by BN6PR12MB1748.namprd12.prod.outlook.com (2603:10b6:404:105::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.24; Fri, 7 May 2021 19:02:03 +0000 Received: from BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211]) by BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211%6]) with mapi id 15.20.4108.029; Fri, 7 May 2021 19:02:03 +0000 From: Yazen Ghannam To: linux-edac@vger.kernel.org Cc: Yazen Ghannam , linux-kernel@vger.kernel.org, tony.luck@intel.com, x86@kernel.org, Smita.KoralahalliChannabasappa@amd.com Subject: [PATCH 10/25] x86/MCE/AMD: Remove goto statements Date: Fri, 7 May 2021 15:01:25 -0400 Message-Id: <20210507190140.18854-11-Yazen.Ghannam@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210507190140.18854-1-Yazen.Ghannam@amd.com> References: <20210507190140.18854-1-Yazen.Ghannam@amd.com> X-Originating-IP: [165.204.25.250] X-ClientProxiedBy: BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) To BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from aus-x-yghannam.amd.com (165.204.25.250) by BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.3 via Frontend Transport; Fri, 7 May 2021 19:02:02 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 178802c0-7c8b-448b-2466-08d9118a998a X-MS-TrafficTypeDiagnostic: BN6PR12MB1748: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:510; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PG9kgxW9PhHcHORq7QgvgpqMGkbr0lDYqoX5zZIfym4k/Wxp119099BPO5/udO7RSxBSS+LlFo+2NKm+hpidQaQUStGfFHSXYO61w1pJpnK5Z4BsWSdogg3+V8KNYsS34NGBUmK2AVQWJERpN4CDAWw6yb/SjuLgdgBebDD5YfpwAKnePOE7AuGq+agHURxDz5o1eSaDis4gW/hD+UuAjNwjA3nx8KmtRIr2TH3IqDSZpSHZgSya/0pcugZazElG30ggSNMjzqwguceroBgAgczbgvok0MXppxu6uzGzQEMKMKBhBGjgZ1VLnTMYFuALTFFku+NmJn+dkoG6Kzt030oOs9l/Mw6KG+4sMVtQ/zP3s2wrTm7CQoICYSsa7HCCU4Wkcky6DCB0bNDDVmD+CVeG6iUwu7mwQKy29wRsktqBxO8V6sU4q2/LmvnnnjQKcFtAthAV/GSGT+HskaXljvFHjp0BwmIlMimLZkcFeRt7mKCEyiUtuXbKh/WSJRR8nfISwqQzYWyoJn4nPu94UDmVpaEcRUaHZGCJNTaNAhEUA56l26+6QJlJH3wSVaYSunckAASlE2ay0liP6Njk4ON1y13kNkrFAcYRBzLqF20U7+S3nMgAbitpwraKQLyNXOM7wzDG67V5dqs5sW6qZA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR12MB3108.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(136003)(39860400002)(396003)(366004)(376002)(346002)(1076003)(6486002)(186003)(38350700002)(38100700002)(2616005)(86362001)(36756003)(956004)(66476007)(66946007)(66556008)(8676002)(16526019)(8936002)(6916009)(83380400001)(26005)(4326008)(5660300002)(7696005)(6666004)(52116002)(478600001)(2906002)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: hopvjDdqmmgT2m4Azmftx9y09SrM4m8++4q3YmC7ZWQlFWn+r584qoz4+aAKRi/ZX2OTyez1mV8WkkaeOQQGvx7DV5HGcZKCn378wpvSXVdKtlOrPWwXLa/K39wADsOpv0sJkCbE5V6cGzU/FYOudCWtJrtWLGs4nIvUgJ07+g8LjsbSSH8p6L6w4jgyKCpCy31zQPxl/w/iUD7XLaYNyECxnPTeCBuAAvu1GkU6dt8wW+olY0YjJal/jr8FTDErOfNfD8bU4Nq8k4Hvzp+N1oLKnj6nkVbma5/Dlp48ERQ087AcfRVG8imFc+aH2kPIb04AGuC0Y87aMMQnwJkCabPsclHlAtNnaPLiIIK/o8AbVfGFNhPVh9oZevDhLg6HL+K/NuvFG/Wku5nDJmuzcAcEZ4WVZDgFJjnjIHad3zHaImlkLD9vQ8QAsA3wLw5JbLQe46gIj8jLsa3kLwZe+eK4lo6cJsH0laIf7MCtTk6J1LBrpW4IUnZbTbVH5JInQVQlN4NtXdProU3mIoavL5FEPcpBfo9Z6wXIbG6rnG67QbxO3zGzPbjsB7DtV3AS6SsCjavgSqntUQ9pc7g7lonf8GW+7KPDuk2iNp8H8y4Mm7xEpDnNHU0ZaNZSVMsGNaxHpqX5SpcfIIChu8uDU2TIVhR0gSvgYlmny1OuKH1XDxSn/Pt5YOFyjjLICaP5x8DFnQJh/3UHkwCKeWg5YxEjLUchyFUakW+Kndg4GISmfl/2BPXUeml9HO6mvtB9m6aTFy5IRTThSG50OVPy7PJEnkEtcl2plvWogpk6P6oHPl3DF+9YGikK+v0359gwoM8oL6PzckSJF3LpNIq1IY0In/DnqNP1bAzM1/JTyQjdO/Nie49YTJb3imRsxdAPGe4AblDnPLEp5gTmKga2es2IUrLC6qHl84Z0qMdtvt7uy2gtq22g35JnQN573qstxxgbf3H6OInre9cF7UaC/ASlyXFfUk5Lr3VgwdvmyZ6HnA0BeZbtAJxqHg+iGsfBDXGFiMrNvmOoxteoWY/rX33rPQHKOoklz/1PrmYkMF/t3chfPrZhHvxxgmzYE2fHX7//xY3LP/Kmc+t+NTJlAPUgrQkOD6vBp61/HubGJpB7Bkq1vkeQrt1di5ZINsMmsIL5xuzROcpXdFDSMfakCwYpkUdADLdMMA/4M1p4eem0MMi+nVoOJnt2c4X6DXit4JSnFSpgWCJscHEaRsrLDuzWxk7Q1S7FjmjAbmUNjxm+oaJ0xaGJ0DIqOtSkJHIwwXlayuIX1/E1pU6LbF+pL+Zno78rQoahxhiL6KVr5x552gUmmXFWLwfMcCS0SOfh X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 178802c0-7c8b-448b-2466-08d9118a998a X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3108.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2021 19:02:03.1180 (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: kC1W36k3EG/W8AZUcbwg6zUbNI+3/rGlVKFtOD3QknD27764hxMs/dwjgBXhW6j1PNP9CSZLwOnt/zJamUf8pQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1748 Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org From: Yazen Ghannam ...and just return error codes directly. Signed-off-by: Yazen Ghannam --- arch/x86/kernel/cpu/mce/amd.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index 7aaf8a1dce2b..d51ec5c2f319 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -1015,28 +1015,25 @@ int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) return -EINVAL; if (get_dram_addr_map(&ctx)) - goto out_err; + return -EINVAL; if (get_intlv_mode(&ctx)) - goto out_err; + return -EINVAL; if (denormalize_addr(&ctx)) - goto out_err; + return -EINVAL; if (add_base_and_hole(&ctx)) - goto out_err; + return -EINVAL; if (dehash_addr(&ctx)) - goto out_err; + return -EINVAL; if (addr_over_limit(&ctx)) - goto out_err; + return -EINVAL; *sys_addr = ctx.ret_addr; return 0; - -out_err: - return -EINVAL; } EXPORT_SYMBOL_GPL(umc_normaddr_to_sysaddr); From patchwork Fri May 7 19:01:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 12245099 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 093D7C433B4 for ; Fri, 7 May 2021 19:02:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E104361404 for ; Fri, 7 May 2021 19:02:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229876AbhEGTDS (ORCPT ); Fri, 7 May 2021 15:03:18 -0400 Received: from mail-co1nam11on2081.outbound.protection.outlook.com ([40.107.220.81]:18843 "EHLO NAM11-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229779AbhEGTDJ (ORCPT ); Fri, 7 May 2021 15:03:09 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b+x8wI5hOz5qJU8Z2wPdham0kkO4tBDYQit4trZoFPXj9pzFqIlYO3UgwbGwreDJpZwLgpMDqJLOCwxna5SvGi+F1ilk+LmTpsw/7mR6jj9oUBKVAFT+yZ6UWLfhj/c6OO2VbldBfVkZUfNAWh1rxm65mdFEiACleC08M5vdoOT7Q+jz+zDwIEwCzqcYCUFw1Jb3je0fg2LAlxG+AJYX5xU2fDuvBUjOLC6PJWFToQ1kgKcKo50rr5pB37Scm8A+IkeCVyrpc6uYhzvO/5yhZSXRwBP7oFjJwgiEtUtk29icPw+BewpkVsM3Hsj9WOn+/xesYeXTMHCw8S6pwtHAaA== 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=xMIEb9P33Qa98oHboZBN6EHjicb+oPhLb24xX6gKxNU=; b=Tx7WWJzyCNbjfZIFtPgitH3+SZZv1F9qLN50nykhV6bB8RNziL8LlTqlRPEdOR0tgTo0WZOSmBc5wvPJmsXEdnG/Q7j0kgeEj1ZqtdVI0VG9mlO5oiH/qhDh7ip6J7R4wRl6yzl4To2R+kMxX8MZ594jygNyueNE/3a6q9cJGSV2Syp681kAMZ2w0NaofPOifFnra8cA47C1hHY4ia1W/yK2LmAUDiATYEHrW8G4hVCczAKbfa/WOSRIygRnHbUpGDoDp7sfrwFhN07HENGxjw9bmGwXUUs8BlB9Tn+xL4IdK9dels7K5JHpIwWoItzabb8zZd1jOMWxhNgR0khlOA== 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=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xMIEb9P33Qa98oHboZBN6EHjicb+oPhLb24xX6gKxNU=; b=ZcaP0Otnmb7bmHrlZ1Fm/F9MipFXQgIUIwBKqog92GaRtyprZtDhb3hUi5kbKD4lpP0TGOcXtS4vnUuxuR72aq3cRRbPSlMlNhdg9/YVG87n61d8rW7YtFFfuL3w3pbCBVFhn7roPCQxt/vKpwdk0YlI9HJ0+i3DFxHEQ6aPFj4= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) by BN6PR12MB1748.namprd12.prod.outlook.com (2603:10b6:404:105::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.24; Fri, 7 May 2021 19:02:04 +0000 Received: from BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211]) by BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211%6]) with mapi id 15.20.4108.029; Fri, 7 May 2021 19:02:04 +0000 From: Yazen Ghannam To: linux-edac@vger.kernel.org Cc: Yazen Ghannam , linux-kernel@vger.kernel.org, tony.luck@intel.com, x86@kernel.org, Smita.KoralahalliChannabasappa@amd.com Subject: [PATCH 11/25] x86/MCE/AMD: Simplify function parameters Date: Fri, 7 May 2021 15:01:26 -0400 Message-Id: <20210507190140.18854-12-Yazen.Ghannam@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210507190140.18854-1-Yazen.Ghannam@amd.com> References: <20210507190140.18854-1-Yazen.Ghannam@amd.com> X-Originating-IP: [165.204.25.250] X-ClientProxiedBy: BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) To BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from aus-x-yghannam.amd.com (165.204.25.250) by BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.3 via Frontend Transport; Fri, 7 May 2021 19:02:03 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f1d98231-4d69-44b9-1cab-08d9118a9a33 X-MS-TrafficTypeDiagnostic: BN6PR12MB1748: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oPENQoOmcm8yGEAjscnWKk5a1xfEYGUwOyTwvvNtcJxZ6wKw37woBNun6sMelqqQj5JakOOE5sNWoolgU7/pl35kmDhqVzrCvkONn7XVLkOWmP9EW11fIakC+sLDwucZQ5JrVDupAsHw8sMSktAS60XnjWSp/nEs+RTkPKzzhpwBY/qn4eL/xepBhVP2YdjleLKci1g5MKk0lVKszyAu8IELIpfp8MyCtuTNJVX4jsc7321xmLdn2iOUwhwNs4st6Nz9OBbQ+9rRXTY4BEskTCW+8GijqG8g4wZd+Sap381LtMVB8+Ix5fQiPdlO5zZj5O0YqZUa3CuH5e9+b5zk9Q5RlJJT/lZ3VI61gTGDDey30VYiGSD78py3yhl4UXXHJnUgSmPMP8a3qdkWXH6Ww5NaDcdjhtBWjMNcgXnvHE2yP/TNHdRNGDLmH1i1UBV/Zb9JWtJ3hZjSXgj8lnnHGFN6mPplHcA3CjLgy3SlMxo94wBmPjFRMjK910WZoX97g7kiYeHp5HNLmxqucrL/pEnf38MVE6buapHLL0DCbgWuYQs8MnK0JQm6Bbii3wzYn/7AQWiZrPX12AvlAoWT431W5xqhXg72v/hrE0Bs+o+I2GX7a9J42+x7YWILbP325IdKXDRgxP1NnH0e2yVtl1g0EhirQMyCjOpEK2N0jUA= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR12MB3108.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(136003)(39860400002)(396003)(366004)(376002)(346002)(1076003)(6486002)(186003)(38350700002)(38100700002)(2616005)(86362001)(36756003)(956004)(66476007)(66946007)(66556008)(8676002)(16526019)(8936002)(6916009)(83380400001)(26005)(4326008)(5660300002)(7696005)(6666004)(52116002)(478600001)(2906002)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: cNSFHDuruGGtNWMv0vy6kjoMDhFYozbeA2d7ziYiDnAKxSPlqYO2cuTcLvGKKmNAkHB9m09krWy5iNDlns/PEUTqpWUGJREaq5B4FJN/SCkPL2Mnan1KXBbl5vEUKi7UfnBNfIb7ir5XevkLl1NxWyCEYy7gSLBgU0JlFxUTYxsuwC/atzu2kwPK/5VjOSpVfEYF7yQtDLp2kXGU1x5HmGFYOHDtCesdysYdUvtPlw814CbqOPO6SBhAvpgzDQ6jwSfMpAmd0PrurishTdmU78+1yLGhkcZsrklvZs6ZDJSoXdywprfVDAuSGg8gjKBNGlXBMqqfyqbSWzqlQrc+/8hFf/PmLwGLaVNxtiMtdfaHTtGZcazhma3zp+0Or4eQpJwBXspRjH+nafEtYyE0gz8Lj0aXnpHWQJYZii3+qsUNqWxQbimOVdBJ0nkTc2HDhciFH5JyARrWqSFvwtJfQ5Sh5UT6NHNJZ11hYSreHeqDdSH/K5QsjtNpe5JjImtmcvacwLkkQqzSNZtuSj3uo6Mc++Xl99/HjpWfyFYEsKC8GlBzzBDh+tjG0iqwcz5kKzSefRzi+XrtrFmKUEi0RqWUrZ0sSQDOLFMuFjuy81HMVtsQXey7lNhpulYDdACmVM3QVA8TRCc0o4mCE8vZ/VR96HVtQZ3n757n8iJMTbOfTf0aK2iiqWomsjvZVYRfTsk+J1Dw9VyU78sZDBBpv8oCzcXeO/UpcV+Xi6fpNv75qvtmZCk7/8GQdWW7q2L/fi18hQ1nuWduKrN+JxDAD3fpmHm/O+fUqwmiFHDQQ0ZXYm/BEANEjjK+GeCZb2L5fjn+LSr1eOoovwI4P52+GIfRIZF7NFgwKX1EP42PDaLDL5CtYF0kwYS4F0gnb9cHk0XNmGU4zHab/sXTpebUDV/UWM5woTWEsft/gfXxlK6AGEATG2VUaDTwMN6c+ZsTZfxVlAUZxE7R4YSBBFlcu3Nq1TiEsN1STb2ZLqjk++2SgQMYhxeWiUEEGM3VpwsNq/LbeRcibi1K+EYOrdfc1RkSmQ1Eb0d37CrnF9xBMSAyJOy9TMda7tniHBiqNweRmhsCmdKjJiZRbyb8kJvCqSG4FBhvLTM54vBdqEKLDthOl4H66w2NOxJoKRwTo7TSXzd1kFEpH8SRYN8R/41gTDC/zRmOewF4bGDDRGazLaDHfDaRBqIkXQkyB12G0/v+QCCNj5yJyE+XUHTgyfnGawQfkT2gUCtLi4McIzl/P5PrFa0O2ZCVhv/kLe8F21aae3iSQhLdgtuNNbxDw+XcfCEvNtrEbiXtZUoJxo0CLbfEx0FWSQWkrkqxZYm9qd+l X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: f1d98231-4d69-44b9-1cab-08d9118a9a33 X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3108.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2021 19:02:04.2484 (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: G69b19HwoSIZPxKSSnNfxYP6AHsX2nE4YhNM2QplipDZAoT9I6UzsLY2qeeQtxWssbwMucTYhUjwmCni/j0zug== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1748 Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org From: Yazen Ghannam Use a single address parameter for input and result to reduce the number of parameters. Signed-off-by: Yazen Ghannam --- arch/x86/include/asm/mce.h | 5 ++--- arch/x86/kernel/cpu/mce/amd.c | 6 +++--- drivers/edac/amd64_edac.c | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h index ddfb3cad8dff..991ba48a4c0c 100644 --- a/arch/x86/include/asm/mce.h +++ b/arch/x86/include/asm/mce.h @@ -351,7 +351,7 @@ extern int mce_threshold_create_device(unsigned int cpu); extern int mce_threshold_remove_device(unsigned int cpu); void mce_amd_feature_init(struct cpuinfo_x86 *c); -int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr); +int umc_normaddr_to_sysaddr(u64 *addr, u16 nid, u8 umc); #else @@ -359,8 +359,7 @@ static inline int mce_threshold_create_device(unsigned int cpu) { return 0; }; static inline int mce_threshold_remove_device(unsigned int cpu) { return 0; }; static inline bool amd_mce_is_memory_error(struct mce *m) { return false; }; static inline void mce_amd_feature_init(struct cpuinfo_x86 *c) { } -static inline int -umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) { return -EINVAL; }; +static inline int umc_normaddr_to_sysaddr(u64 *addr, u16 nid, u8 umc) { return -EINVAL; }; #endif static inline void mce_hygon_feature_init(struct cpuinfo_x86 *c) { return mce_amd_feature_init(c); } diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index d51ec5c2f319..58899c57eb76 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -997,14 +997,14 @@ static int addr_over_limit(struct addr_ctx *ctx) return 0; } -int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) +int umc_normaddr_to_sysaddr(u64 *addr, u16 nid, u8 umc) { struct addr_ctx ctx; memset(&ctx, 0, sizeof(ctx)); /* We start from the normalized address */ - ctx.ret_addr = norm_addr; + ctx.ret_addr = *addr; ctx.nid = nid; ctx.umc = umc; @@ -1032,7 +1032,7 @@ int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) if (addr_over_limit(&ctx)) return -EINVAL; - *sys_addr = ctx.ret_addr; + *addr = ctx.ret_addr; return 0; } EXPORT_SYMBOL_GPL(umc_normaddr_to_sysaddr); diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c index 9fa4dfc6ebee..dc4a642d5d7c 100644 --- a/drivers/edac/amd64_edac.c +++ b/drivers/edac/amd64_edac.c @@ -2896,7 +2896,7 @@ static void decode_umc_error(int node_id, struct mce *m) struct mem_ctl_info *mci; struct amd64_pvt *pvt; struct err_info err; - u64 sys_addr; + u64 sys_addr = m->addr; mci = edac_mc_find(node_id); if (!mci) @@ -2927,7 +2927,7 @@ static void decode_umc_error(int node_id, struct mce *m) err.csrow = m->synd & 0x7; - if (umc_normaddr_to_sysaddr(m->addr, pvt->mc_node_id, err.channel, &sys_addr)) { + if (umc_normaddr_to_sysaddr(&sys_addr, pvt->mc_node_id, err.channel)) { err.err_code = ERR_NORM_ADDR; goto log_error; } From patchwork Fri May 7 19:01:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 12245097 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C49F4C433ED for ; Fri, 7 May 2021 19:02:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A59C46141F for ; Fri, 7 May 2021 19:02:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229846AbhEGTDN (ORCPT ); Fri, 7 May 2021 15:03:13 -0400 Received: from mail-dm6nam12on2089.outbound.protection.outlook.com ([40.107.243.89]:47105 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229818AbhEGTDH (ORCPT ); Fri, 7 May 2021 15:03:07 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U9Sbf6jAaiUiOE82a/82d91s3XIWfNp5q1ge7Kro7D0k5YTan4rEvqFi+roQNhF4ABCqw4YWB3AzuPNJuzDGvpf87B8zIK+/gpP2pcZ6cNQfSkIJOZ/EZ+NM+S1SUw785S38OgwIDis89KFC6en2l92yC/c/Ho9WfOedOq8SET09PKJYGRZW+UFOk6TBOTTJhJrI9IXI3jrOA9Vg6uV1iFofKuZuXjFukedFqRrR3mfa4WXhGmoUtLbaUuQiJi2q9GsfkdwFs1Kj7s0M2TMpPMZ/XXvILx/eTVKnhKAmsTTowyzlXs8kyArGmErcFvXRYHi0EKslm6BSf1QVGWmWGA== 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=ZB2s80KBFN02J8BCyRiDOh/O0Q/NCu1dcUe8gre+ztQ=; b=em0L6yq9TbHiB0oVVu3Tg142we9stiWDnFXExs4LgsC5voJwK57+o7ml0wDpO925I+Y9JEuvSnJVYEDN1dKXXxnIw1NeKSUw23DeOh+pcSL9Qfe9J9gUu6RisZd5HrcR7oQL2EIhhwKwNwt92AlXEy+hOq4q1qIUDTGSNuT+nZFg1o+QMIb84igsTttsffpHo8P7jfmke+yebNsWuhv97BDRFuTO3CAd8vPE7dfB8oZeW48ksJJ+YWePep2C7Zg7122Xrr237WC0OjzkWlm6jC32vA4vZuBJir+S8AeQgpliXa6VnY4UbBapQ3015x39ESbM1hADguW+zmQJV8DhfQ== 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=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZB2s80KBFN02J8BCyRiDOh/O0Q/NCu1dcUe8gre+ztQ=; b=cWIVjoUgC1ihaM+SyAEVceyPeGThXrne8Eg6AHFlVkd1DRDXBVsD+zFB/+Ey1K7t2ax1ClwTWbQpDJqvsLGiItWYynIoHfMqc3up9Ch89KTtjiIZmWma9Ec3WMtdbfr07fgmgv+PxBy0bGdBajhV4BObDo7/2LtXD5IdIiyugiA= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) by BN6PR12MB1620.namprd12.prod.outlook.com (2603:10b6:405:10::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.26; Fri, 7 May 2021 19:02:05 +0000 Received: from BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211]) by BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211%6]) with mapi id 15.20.4108.029; Fri, 7 May 2021 19:02:05 +0000 From: Yazen Ghannam To: linux-edac@vger.kernel.org Cc: Yazen Ghannam , linux-kernel@vger.kernel.org, tony.luck@intel.com, x86@kernel.org, Smita.KoralahalliChannabasappa@amd.com Subject: [PATCH 12/25] x86/MCE/AMD: Define function to get Interleave Address Bit Date: Fri, 7 May 2021 15:01:27 -0400 Message-Id: <20210507190140.18854-13-Yazen.Ghannam@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210507190140.18854-1-Yazen.Ghannam@amd.com> References: <20210507190140.18854-1-Yazen.Ghannam@amd.com> X-Originating-IP: [165.204.25.250] X-ClientProxiedBy: BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) To BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from aus-x-yghannam.amd.com (165.204.25.250) by BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.3 via Frontend Transport; Fri, 7 May 2021 19:02:04 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ad108510-b783-48a5-b636-08d9118a9ad1 X-MS-TrafficTypeDiagnostic: BN6PR12MB1620: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1247; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: i2i1BZ7qgJIwMwVE93x+MOhdhwIom1S3MEjW6NbmvxVPFmZLS5ypOYs/5iom1Mlf2IkwwauXnJChjJCyFZ8TXlFrWyLxQwgMZc82zuHM+g9T/o7Z09CwAwOEWJ6FWFq1zxN5vxRYMgxBNEgyEEYwLjL23+t+ah5C/c+KE2zwowtnySjOuLjfNTiOQHRSQb5uphaM0jvzcdnRGCSO+ovuM8AA748RIdfPZhhwdMxt5/t7L5Kr68xLSG1A8DIQ8IsUmsXqJEdgXdlYG8RBPuWGDCOUsRnzv/mIaIfht8GhUCgGDRgmiYD7aCOPfMoOaQeyVUxvu2/kGAqWoWzInAi10QbfvMhAN+ftyrNNmQsefRVo4MyeGqkqeVwAEOzDFnxs8Bfh7RYEZflqIpuJFzoxkC5Kwn3gW62KtQECiNebFRmInr/3tpjy5wuuoGHOEQYeGUn4RBFTzR8Qel7qLY34PeLbs9WjAXY8B+oZyLXnsqWnfpedwR+NXyAXhs5++8rkWVkYuwJ71abnkNhoMTfqkz3vJ2LmPWT+FbqkAyw8cEZTaq6bZj3RLEPQgFKo00czZbsWdg0KMkvth1s0Au7nsscR7k2ba4ktOsLCcfWq3SKW81v+L9E+xfLiAvmKsmWrePfvGt0yQDr+le4MqAh82g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR12MB3108.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(376002)(136003)(366004)(39860400002)(346002)(4326008)(6666004)(38350700002)(38100700002)(66556008)(2906002)(26005)(6486002)(66476007)(1076003)(16526019)(86362001)(6916009)(66946007)(2616005)(956004)(186003)(5660300002)(36756003)(478600001)(316002)(52116002)(7696005)(8676002)(83380400001)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: a+9RGA2vWF6T0WPnn05p6xxS6MRQa7ch1wjN6o0v1Cllyhk/X/fIRw7FgG4kHiYqqfdwuNfQlmH6k3Wyf4/XkwS5YSfbk38+ae6EMXMGyQI1/RVfsgsYLROnhCOw1f8rZLdXnFoDcer4HnlxuFh4bkouM1F6Beh2U1wULjkA2vTKgiTzEKzvSN999qg/f9ohbJfziSOKVB2Wo3pJ+snZ3Hax8YJ1Vuez+gylQ4DlQK83CqnCcJTOZtrg90AGR6pufuMZ8zrquTTkQwMP+xssQgKT7yZrro9tGAJjbR5YwwGlRC23vDDCakBJnLIyJf5KPMBB9fKcfz2o5b7Hu/VnkNP5D8fQ38Z8HLVJmcij2jVQ1LLxsP4M977RpqQM6RBUP+O4iiQemI8mfvMUpdLZirRJGE0yGnvBhg3fVHtGFUapuGY1na0KZABeKLbmSyKztuQOeGAU750kv9zi4oia2cCTChv5zvsK3GacMUyxpkR6VifP7i3gpXBp51LqL/IxO0o0nq4lWa58UCVfeFwBi38Kl67o6R8HeO3hjuF5RJYpThfU2T1K0Bgv/maVzXXbZYIMYNeWHJB/S1ie/sxsOKAizYm7zbymFBahpBIGLZttZG0St+di9MKYoukeysKRd7kUhvAAKp2/AJn45qw+XgPX/QbVKQkJ7e6EYTVGHCgPY1F2A8F8q6ac0x3tV03hGGKMesE7VQFjEPCKbYaBjUq6q8UbN+OUE0EJZdnw2wYOVnkuME9VRP1etydJV1SWyD/688ezSSkJfW/aX8VrWmEd1TgdpD8emmrEcNeYmJ/pdfY0kFKbUpq0h/fTDimzBHmTrxQ70b54D37HmfjYJT/NEOQ4GjxR6Z5x4yGbErCug9I6XtJzKwBcxMs1YVNPuG5s3TBdNN6Pw+vh6GzbmEZ7zIu0I7KZ6OiYQBC0xKg4t2OReiw4D9S5LaHDnhKsy81yb73LHAEgoilyRT9/IDx1Keyo4CaAd1LS+LSQN4PbJeKp1LmJ1koTF9GUeWaLpOm9e4Rjpp5RkEaFivHiXTrFaUhUs5kZMsEC4G3YDPcJnq9iOpJRZ/dw7H/htLwscY2HOJNfcaGBUX6pxhFOs+gB/VYyZGvcHmyd9WPKZNCW+USFdDyS6B2GWR8T9z4hn3cnRIdUCRT+OwB3tveTXC1oAyS+6pLRRsgcJfb/O+wCpfq4g3Esr8OTSDs3Pk/hpGN/q8AMksjxC2SaW+RZHly09yPG++Vu5eWJNGkLps0tyz/sSHCJwo8sYItOiOcnGsBr83QtrgshUA0DyICKglBwQLMAaa4zbNFS5ZRRpQSAOFb/Zh8Zt+v88hApTw+H X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: ad108510-b783-48a5-b636-08d9118a9ad1 X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3108.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2021 19:02:05.2558 (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: tA5xJZApiM/Usd0S5deofKbvDO7YrIxT6pPtk0DksYgv0ZL20nyx5vRul5N7GdhpvyeUjlxBuGACJ/J24vsvJQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1620 Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org From: Yazen Ghannam Move code to find the interleave address bit into a separate helper function. Signed-off-by: Yazen Ghannam --- arch/x86/kernel/cpu/mce/amd.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index 58899c57eb76..a60d9d275d14 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -814,14 +814,9 @@ static int get_dram_addr_map(struct addr_ctx *ctx) return 0; } -static int denormalize_addr(struct addr_ctx *ctx) +static int get_intlv_addr_bit(struct addr_ctx *ctx) { - u32 tmp; - - u8 die_id_shift, die_id_mask, socket_id_shift, socket_id_mask; - u8 intlv_num_dies, intlv_num_chan, intlv_num_sockets; u8 intlv_addr_sel = (ctx->reg_base_addr >> 8) & 0x7; - u8 num_intlv_bits, cs_mask = 0; /* {0, 1, 2, 3} map to address bits {8, 9, 10, 11} respectively */ if (intlv_addr_sel > 3) { @@ -830,11 +825,25 @@ static int denormalize_addr(struct addr_ctx *ctx) return -EINVAL; } + ctx->intlv_addr_bit = intlv_addr_sel + 8; + + return 0; +} + +static int denormalize_addr(struct addr_ctx *ctx) +{ + u32 tmp; + + u8 die_id_shift, die_id_mask, socket_id_shift, socket_id_mask; + u8 intlv_num_dies, intlv_num_chan, intlv_num_sockets; + u8 num_intlv_bits, cs_mask = 0; + + if (get_intlv_addr_bit(ctx)) + return -EINVAL; + intlv_num_sockets = (ctx->reg_limit_addr >> 8) & 0x1; intlv_num_dies = (ctx->reg_limit_addr >> 10) & 0x3; - ctx->intlv_addr_bit = intlv_addr_sel + 8; - /* Re-use intlv_num_chan by setting it equal to log2(#channels) */ switch (intlv_num_chan) { case 0: intlv_num_chan = 0; break; From patchwork Fri May 7 19:01:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 12245101 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 601AFC433ED for ; Fri, 7 May 2021 19:02:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4428061404 for ; Fri, 7 May 2021 19:02:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229893AbhEGTDU (ORCPT ); Fri, 7 May 2021 15:03:20 -0400 Received: from mail-eopbgr770081.outbound.protection.outlook.com ([40.107.77.81]:44439 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229813AbhEGTDN (ORCPT ); Fri, 7 May 2021 15:03:13 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XXDCAMzkamYdNcxaikuPynpLOMdXenR6tSXEn+qYJfNuRuEvL3ih2/DmUcljU3ns3vPNZsy5ffG4laJX8TSS6aDW93ffcmeNrnDtYNyNaxyapE235VppKzk0AyLb8w2GAV4bea0KdYY6BixwZRtVfvO/3vJ3cAn3bbNsJjcJEs/4cqfoB7OL3EPeJgoMA9L6HkMZt5zuqIb15W3T7Kv6HSXR0eaqFWCOXwxdtkE5org8HbnMsSFMb5BydY5s0aUiEZjLRs7lECBV84pMPXcjA3GTpVGLeBpcWlZfPDICwnY5kAn2ILhe8PWpFaU645rRTo6VZPw1vNOkaFRxFI0SQg== 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=K9ZX0wqyJQAH3hsg7EtYQflBXgwr+eJoDbv9+8PS6DA=; b=DE606kkrSf0IhEF6hGwVskLtH16opHqUN3uWJwXdkVjcy1Lft/f3/3mPSPwEZOhG6oWGJSVjCO22m8g81kbOkTY4WwSaM9hd7Doys6xcWcrQ033rbJXYy7yTvKE/CkipuXT84r7SohB5Ypfv1b5/KVZyWZWxZA26HN32Z3ufC5XSPJeEppXJtwrAxBMfxPwZwUaoFWElKlKa/o8lDGuL8aME62xCbT8iqtTqw56OP1/w/eSrgkQc2ch3uIZaoEdpWLYKme9AA5ZyuFJKy+gHlwiTQfJtk7vHZx4MAxNwQ9u1osNpr8sJzEw0I9A9cfKkxN+aAi9JyCRxld9woXUaTw== 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=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=K9ZX0wqyJQAH3hsg7EtYQflBXgwr+eJoDbv9+8PS6DA=; b=zWjEz6KSkwh0eqslcBhsqSWytX20PHfVgJTOjTa/LanRrFB14CPQDmhjIODKhWIvwf5BIv9SNYUn34Ut9FZm3l+Zs1j/U1NYc3pPp+6CSOIiADOwF0LkG1etHkGES1BiZxGpEStpRxsc1lNbVIYElXXo+pUJM6wGx17QgA8yLLA= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) by BN6PR12MB1620.namprd12.prod.outlook.com (2603:10b6:405:10::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.26; Fri, 7 May 2021 19:02:06 +0000 Received: from BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211]) by BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211%6]) with mapi id 15.20.4108.029; Fri, 7 May 2021 19:02:06 +0000 From: Yazen Ghannam To: linux-edac@vger.kernel.org Cc: Yazen Ghannam , linux-kernel@vger.kernel.org, tony.luck@intel.com, x86@kernel.org, Smita.KoralahalliChannabasappa@amd.com Subject: [PATCH 13/25] x86/MCE/AMD: Skip denormalization if no interleaving Date: Fri, 7 May 2021 15:01:28 -0400 Message-Id: <20210507190140.18854-14-Yazen.Ghannam@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210507190140.18854-1-Yazen.Ghannam@amd.com> References: <20210507190140.18854-1-Yazen.Ghannam@amd.com> X-Originating-IP: [165.204.25.250] X-ClientProxiedBy: BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) To BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from aus-x-yghannam.amd.com (165.204.25.250) by BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.3 via Frontend Transport; Fri, 7 May 2021 19:02:05 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 344fefac-a690-4291-2816-08d9118a9b79 X-MS-TrafficTypeDiagnostic: BN6PR12MB1620: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3968; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FDxucoFDv312/VbR1HmAWiTNqXqhVxRci/q9VojUGFzppNzLwq+GVmFUztQH3sFL4wGupAn8Keuilfwr1bJaSfwDLDdmjtiY2QGBwwxdqiE3SQ4QboFYK8UOtCIy1dm36/u7caDqbOaBiVE69dbloBMWAHs77vUD7fzHWCtmlRXH7EVkX5Ku0XhQYml6lafHxgr284tONmrCS4gYYRjQ6+KmpeTWXv7S2h0wqz1OKZcFwweLsrHe6aNLd+uGwCFBKiqTsUTy6GBgrTyJ19YjHnQGBwUFuvTaYg+Kh3gTkKyHbJdcOqbRGpejFIM1EhAhVkLSzY0HM9uI57MzEYE/muaaVnN+UVTXY3luzAB4tNNQH9ion21VRN8hkC5FoT97746BqmsHOT+WTNe47YaTFANW/wmSH0r634t9ZsOPJjBxRs/+9liPQizxxY4U3yj6DeZ/NAJx20RQ6xCPYJSliV1zq3lhhumjFTWsWlOcU53Ud2ka1MoGaWOLf9FtQPQS6/gmV3eBrhFXPnhWl+UuTWuVb99B78J2WKfpUX2/zfJtx/kOUIo0/+GEV8QVimVX5krTNDypjL1HCBqiZ2eOGX0sGaK+6nBixouqqf5HcEwW9uupb4fIq7+v/BvxqhANp+oX8NqC8WtMvpB231lzCP1DHPobgiofUinB7AwF8Ic= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR12MB3108.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(376002)(136003)(366004)(39860400002)(346002)(4326008)(6666004)(38350700002)(38100700002)(66556008)(2906002)(26005)(6486002)(66476007)(1076003)(16526019)(86362001)(6916009)(66946007)(2616005)(956004)(186003)(5660300002)(36756003)(478600001)(316002)(52116002)(7696005)(8676002)(4744005)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: KjRMfZ6hickrN0xikyH9xs6Kfh8PWatQ63nxez22icC0j5/Mqh62CvF/aD6nwIkydTHkFHtRd3wlm5YeFBvhMruC1GH3N0mW+Fxz+hToaN55f8bk4rp11gWhhXyVvxk1O5Ci0lepaONZVpS1wkZ2M2+Ms5VgIK/AgXXGQAsAFAhtvWMvQ0uqj5inQVcFBQQlQDiD4+Iz/Uq4x5amhh0Tt2//iXgzNGY9rDCb8B1kHFdKosb+wWtH+IEveOAYodL/jLCldefXfJWydz+auD2szCDsmjaDokSdaT+vAoCnifznQoFjxDtpfAFFM8Q1hhh3qpdfHGXqc8ieZa07HJe7vr5hB6VYq/lZEqu2MYifSlFm1zoPKLYJ9TUnGZ4aUNfIkqIWNVJLA9xZltN2jxC+IpKfzMxoTcY5yhY+nh/zoe4seG+mwct0xKJ106h7rNzUmr9K/5ozsY7LvSmGAwj+/mhTX8D892MWvBilZNDmxh5jvmfBzterFgRIge8gDJn0xV11gSqGGd4Np8iH1ZZyGj5unnXQH+z2vLib3P64HG7eBEzcGKcweKsfeP1A018/SHtbyLiuKJ7Uom5Ev3I0mwUzK9W7o3XHQ/GnC2NxmfWgSPiTJL/XJZRmoIvvOMwQbyHWHuuill4o9PYIJdGXibmbgYe3zASCtcqNUKTTsjRbnKruEFtOyjzVJF/0M3DR8p8TkGLVj9idHTgWRJaOFAH231yB5lb8aiXZ5N3ONKJOBJ6g5XVjaszQIRM+GboOBrq3c1+zoj36D/WsScsIXqVPL4nNJVcx5Fz1Meojqxz0HICno+yYc5Mi51d5/IJ9alTJ4tXTcsA8rA+BFMqp3rvuKhsRANJ+cOIZ9uN9EPsIzP2VpZi3WBbDCZL33SS3leEOph73hHNP9XcDHerwcRPlDPAmSD0P5QPxB07LOq8DWdNYO0z7onhUYpfrwHg4a7hmuUYFYLGN7gflTYtbBpASW5pSqqEP9N9CO363pO8/sRfma0ReNEAiZhVQ3esalcaR1yVlHoUvG4ujCXfbxgcdYZ4n1EcJ34YFE4RIgVayBsNP/+CDyDkbDv3u2SAtXYqoRu4pG8Oi8RtgJyyQN31Wl4zCE4284J6TDE5bmPaoUfIgCVE8z4jJgVUNk7/6VaAKtzyYjUKW4QK7WvceT++g9hWpMbgP7qdzkKFmcLWAI0YL2AM0dEMJWdrucEPqt+xhkCiJvJNLb7MUCLsskp6eONTgOtl8R4LWEWbSIqCjfNsHcUDRIBUSj7laeoFS1u1bjeQn8BUmK+G0QUAZ2oOzrNRfph1K/H68yiuTEMcmYfc1p6cCOH1GF5xOhojG X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 344fefac-a690-4291-2816-08d9118a9b79 X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3108.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2021 19:02:06.3002 (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: xshLVz/V2A18Uc6aHLjVIGNClvamQ6SYz10vQoJfRVSSd7uqYCCuT3he0nQDjEb/+03UYGWWGNpxFfoUfAR9lg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1620 Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org From: Yazen Ghannam Denormalization doesn't apply to the "no interleaving" mode, so return early without error in this case. Signed-off-by: Yazen Ghannam --- arch/x86/kernel/cpu/mce/amd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index a60d9d275d14..605376351cc8 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -838,6 +838,10 @@ static int denormalize_addr(struct addr_ctx *ctx) u8 intlv_num_dies, intlv_num_chan, intlv_num_sockets; u8 num_intlv_bits, cs_mask = 0; + /* Return early if no interleaving. */ + if (ctx->intlv_mode == NONE) + return 0; + if (get_intlv_addr_bit(ctx)) return -EINVAL; From patchwork Fri May 7 19:01:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 12245103 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EDE3EC433ED for ; Fri, 7 May 2021 19:02:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D001B61432 for ; Fri, 7 May 2021 19:02:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229902AbhEGTDV (ORCPT ); Fri, 7 May 2021 15:03:21 -0400 Received: from mail-dm6nam12on2089.outbound.protection.outlook.com ([40.107.243.89]:47105 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229843AbhEGTDN (ORCPT ); Fri, 7 May 2021 15:03:13 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DDVmwrlifxbL8kB/IJqZm15qTrhn+QjHJTXJAgBT6s1KLqZLH/K2vD/lGqemWffGSfxUrZMeyYx7h0FBqctpLi4bQ6c8kP6LK6bZ/ompjtX3gnfyhx3mfzpMMZr1cPp6s4bGKrK4jdnZBj1n+FGf0/cePcDFVs5x7SP96KdIfbS5acT9K6+pdU7vPB2qRlQvPT7qhFO//SY7W8T0tHQhoIDLCXLfMI/VF5Rb28glb6Lb6B+RPbsJVDRHW1WUuSSR5MynZ86bnIabjptOwYe+CYpPXpO21hteVoFj37eZ4Ly+5ggRy0EuoRE5Vgq9udbpxbh3pl9CXDL6wI34DiifuQ== 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=9KEKdv57zFGfIk9M1ffeE3YZcEe4VQolLqlqAtrAUE0=; b=JbUcoKpienmZ2pF6RzMfcmUJWnzDzUzdC2MmxUXHIMkV6MIgs6veMS2nzVURNPHTp080lRMi/LY3kY/AHRU+jXOUL7uF7QVVgScgGLl6t74HNm1SItz5daHeNP/zhTX2qH8h3U5ViqbkE6s4Hjx1aHpy4F6Cqz3AWhLsh65ZRL3dnHezzpgZRd6Q1jjHLoLEDjUT+f1a2uwVG5NYOLGnKvXvtU21cOBposLkpY8/VVbcl+IvDUKxBHTc5ljjMhnarhcI9frVWfeG0DijcrpsRjTH/agyfrTAjtdp/a1OtEHyQ/LVjV51Chtj8rxHSf4c3akE1NhZIZN4gZNxR6+wrw== 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=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9KEKdv57zFGfIk9M1ffeE3YZcEe4VQolLqlqAtrAUE0=; b=H6RyezecO9FwiH4ChbRJ6dmsm1frOiDVuIvHkDZX4teXHXkjj6UMr2q09bd7bJUzGIViRfw3ZMZLavglvmpsREzGZT4H0hV0CKDksB7x/hclcUCCSo+CDWjiEyUJHL4SmXP0UxLbxBgVcyJFF7Hbz3eUA6jA98oraLzq4gw1Isk= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) by BN6PR12MB1620.namprd12.prod.outlook.com (2603:10b6:405:10::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.26; Fri, 7 May 2021 19:02:07 +0000 Received: from BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211]) by BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211%6]) with mapi id 15.20.4108.029; Fri, 7 May 2021 19:02:07 +0000 From: Yazen Ghannam To: linux-edac@vger.kernel.org Cc: Yazen Ghannam , linux-kernel@vger.kernel.org, tony.luck@intel.com, x86@kernel.org, Smita.KoralahalliChannabasappa@amd.com Subject: [PATCH 14/25] x86/MCE/AMD: Define function to get number of interleaved channels Date: Fri, 7 May 2021 15:01:29 -0400 Message-Id: <20210507190140.18854-15-Yazen.Ghannam@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210507190140.18854-1-Yazen.Ghannam@amd.com> References: <20210507190140.18854-1-Yazen.Ghannam@amd.com> X-Originating-IP: [165.204.25.250] X-ClientProxiedBy: BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) To BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from aus-x-yghannam.amd.com (165.204.25.250) by BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.3 via Frontend Transport; Fri, 7 May 2021 19:02:06 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ec818363-e01d-4f93-48b6-08d9118a9c10 X-MS-TrafficTypeDiagnostic: BN6PR12MB1620: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:186; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DHBOgA6O2NB+YcqMoW1afzytoSiQA9VeavK+b+oJBtr4MZIYD3/zq3EtAz3AamyhLqYldnfG7yiWHCIbmcr1z42iduIP/haDd+bB1Pl4W1dzIGFYHh1Se5Xlt92ZKZi9W0fxRomIrXWaIDZpC0sOP83s88Ijl/kCB8EyT/5o2G6ETFxiU3f5KB0gIiEv/Fg1VQdcqizKRsHh8Q2ELOiN2+1yBUg9fOspNlXS1vLJ1ld1VZukGKIng7DApjr0A/Zlsk2V+Bv92+hfD4uMs5r39SLyKuabK4Xjjr9nz+uu/I2xFdwxPa9iE92SYG0P/o+sJ2Z3a03k9yA9LSrToqJMO2yake0Su21JSwUzq7C1Vc29GsMZ/XuDelOO2Vh8mqvx1CjRJjEF9iqF+OK7dMrTqSkE0P5YwEUaEqgAVmUZDscz3OT7mx9jCR2icVkGSEDYrWv6ehlc1zqJXqQQtfEClkkbjZFp+rDvSDnp8/X0k7R627WyIBRsohzkLDgqA6T6MzLKbv/ImlBCRno3qXDK9T47lRR59bGJxD1zhCAn1/v8IqM0afTb1aIjoXlBKPUYPuj4o61ols2gw5DEemfZudt8KdQS0Tj038RXCx479Xmb8vv/4qOdSrFHdKsthd4bRfLa/+TzW4sVL7OJmuQlbQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR12MB3108.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(376002)(136003)(366004)(39860400002)(346002)(4326008)(6666004)(38350700002)(38100700002)(66556008)(2906002)(26005)(6486002)(66476007)(1076003)(16526019)(86362001)(6916009)(66946007)(2616005)(956004)(186003)(5660300002)(36756003)(478600001)(316002)(52116002)(7696005)(8676002)(83380400001)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: u1pG4nOxkOQhznvpcsObdPt2PTPPOyMd+c89hvqpGIqSlsHqtyNdk2aBTNy8meM8eHeh3yhZm/9HfTYP7FEYu+cIG6wtRpvhr18EzNnj9Op2n1jWmA6r4T7sK9kEN2J2uYhtOtAm2GnWpTWNgKNYzs6RWTkDSloaoHaTkg9J+FvfCTBHcU9PTtMDBl8olUjCBiEkShU1zRWJIiXpGZPtG+H2xela9DnwX35S9+b6EtuDaGHDIbPTy0svLSNP0pCV49//TNcTMOQOmnGcYC0u/EeT96YqtIsh4T8tKGGcOAQQG7LGfy0FMcHX3rJqoELlivpi2mQhSuTCStymnm46cIORLcRDzxWwAFS/wtBPh2Oaw7mQSd3oiuGkWI0qqc0ib6WMfH36WzE2ju+SB+WsW1mofaLiig4dCvIM/xz0qw3vqko961UPlak1J7bKutgO7K5UbicSDzfqU4FKTh5r+oTHRwkUQGdXB+STR+td01fhWEl9MHMLsnf4YbuwqeLqQzkTyq2s3Y5PRy30/D8/299PXcN2xgv5AtEA9GH4UQFfGWIOlb7IYju3iXP6Y/EW2VcTgORy/3Ob79sQuXnjshEkTDGVx8YmyFQQ1R0tvC5kHCYDiDyxC56IIBvOxjzaFOHldGFopawxOwhLcZhqcDyfjYJUb3lH5lpqkAsPosiB2afTQKyArD657IvICv2YQJfWU9uh000elsPTJUpNtG8qDaTDoPQ7CeJaRP3fIAN5SvTyqLMxgkyvYBcyNyLqagEeDKraMdCZr7DPqF+ytXMbMWFlLgL/nHYpHX0V91gYGubPLJ9BnPUeIHbwX/6IbSfTEEakATN9PnFgUsdTpEWY1pRKM6YTMQ0LhKwE9mO9T6qnDCqttdQhIzRcknSEZQP1ERr8DZBzpJf8myu4lrlc82g6z0jcLoBFsbJV6AoXRrtlcP+JfzBraiaNlQy69U8KJecpAPLQyJDNqVBnff11rCSfaWAYVT7Z6y5PKOiRTc66lJeSlLGTJkcxJRiT7B/2qG03YFcsK9Ll3HSiMPYFO0wARlTCu3T58MvyjLyM4GWzzPt2Z6VrYyvEu1jux5XQm1rzH1oNkheU1KS+zbTDCVasIcY7tkjDRTGhGHrTz3brx03oR020kXnUn3OPDIdAG8HmFFRHk+eFsP0ODAZrbUF2T4Wj0uCiXy4G2Rtc0j6O5qF3P49EamZks7BsRg7oTwOvftQnT8LhfVsJQ5wxsv06DDs7rJhBdCdCg/wCbf4DoYHSHJlaI0Fkh68qGJYn9VWp4rPzndzZ7lUHvFsZgA6MbAL8Ee2pTmWTVvw70zA/FfxGGC1Du5hTUWXe X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: ec818363-e01d-4f93-48b6-08d9118a9c10 X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3108.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2021 19:02:07.3176 (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: 4jnUKSg8Plv8fJDdS7/HYjw7gw9I22JKSfOxDZAYzPxzsBk5rw1cT/xLuBGuPE1O+/2QJrE1l9FLs5b+Ps/koA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1620 Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org From: Yazen Ghannam Move number of interleaved channel calculation to a separate helper function. Drop unused cases. Signed-off-by: Yazen Ghannam --- arch/x86/kernel/cpu/mce/amd.c | 42 +++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index 605376351cc8..0c24bdc346a3 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -729,6 +729,7 @@ struct addr_ctx { u8 umc; u8 map_num; u8 intlv_addr_bit; + u8 intlv_num_chan; u8 cs_id; bool hash_enabled; }; @@ -830,12 +831,29 @@ static int get_intlv_addr_bit(struct addr_ctx *ctx) return 0; } +static void get_intlv_num_chan(struct addr_ctx *ctx) +{ + /* Save the log2(# of channels). */ + switch (ctx->intlv_mode) { + case NONE: + ctx->intlv_num_chan = 0; + break; + case NOHASH_2CH: + case DF2_HASH_2CH: + ctx->intlv_num_chan = 1; + break; + default: + /* Valid interleaving modes where checked earlier. */ + break; + } +} + static int denormalize_addr(struct addr_ctx *ctx) { u32 tmp; u8 die_id_shift, die_id_mask, socket_id_shift, socket_id_mask; - u8 intlv_num_dies, intlv_num_chan, intlv_num_sockets; + u8 intlv_num_dies, intlv_num_sockets; u8 num_intlv_bits, cs_mask = 0; /* Return early if no interleaving. */ @@ -848,23 +866,9 @@ static int denormalize_addr(struct addr_ctx *ctx) intlv_num_sockets = (ctx->reg_limit_addr >> 8) & 0x1; intlv_num_dies = (ctx->reg_limit_addr >> 10) & 0x3; - /* Re-use intlv_num_chan by setting it equal to log2(#channels) */ - switch (intlv_num_chan) { - case 0: intlv_num_chan = 0; break; - case 1: intlv_num_chan = 1; break; - case 3: intlv_num_chan = 2; break; - case 5: intlv_num_chan = 3; break; - case 7: intlv_num_chan = 4; break; - - case 8: intlv_num_chan = 1; - break; - default: - pr_err("%s: Invalid number of interleaved channels %d.\n", - __func__, intlv_num_chan); - return -EINVAL; - } + get_intlv_num_chan(ctx); - num_intlv_bits = intlv_num_chan; + num_intlv_bits = ctx->intlv_num_chan; if (intlv_num_dies > 2) { pr_err("%s: Invalid number of interleaved nodes/dies %d.\n", @@ -901,8 +905,8 @@ static int denormalize_addr(struct addr_ctx *ctx) die_id_bit = 0; /* If interleaved over more than 1 channel: */ - if (intlv_num_chan) { - die_id_bit = intlv_num_chan; + if (ctx->intlv_num_chan) { + die_id_bit = ctx->intlv_num_chan; cs_mask = (1 << die_id_bit) - 1; ctx->cs_id = cs_fabric_id & cs_mask; } From patchwork Fri May 7 19:01:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 12245107 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0632BC433B4 for ; Fri, 7 May 2021 19:02:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DC69060232 for ; Fri, 7 May 2021 19:02:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229978AbhEGTDc (ORCPT ); Fri, 7 May 2021 15:03:32 -0400 Received: from mail-eopbgr770081.outbound.protection.outlook.com ([40.107.77.81]:44439 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229889AbhEGTDU (ORCPT ); Fri, 7 May 2021 15:03:20 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CFna1FKul93FE+vNtlBtifrIyoRDAwujIMNw6FVElNx3KcTg0jEGSyKlqqyt63JxI7nw9eR4sDPulP6qg02/mZiGu9SZxqEUQBRhlxBJruCZ3w7lESLgsIsmgiq3QwmdEgTyqtV/EnEOIstdZMX2UWGDyIAD8oM7lRfnlksYm0hrDuCHDe+o6taj5EH57Xcrx9mV8vd0oPTy/S3j8CPox9+hHcLWjkjFm4EJPHVLd77/jVzhJKPt+0Pkh2bmNs7SbOlPSG8p9p32wEOxFztX3r3BKoe92vM7a1tcT6EzgIOBkxLvrIJxnmmqw85B02qCYsKFm3XjfR8RNiulPCy3eg== 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=tvYXxY2mPfpY0fjm+vdKhYMf0GXw/6mRrRa+m6NjwEo=; b=CEsEgzJ3I79tgmShHYHu241GLqHfRr2toPWjynzfFewWphC4lS/H15qDSxKgXf4BR4boxVOdgYboc1g2xIZHrQq+qfFDLzf0mPNMQ4eIKgZB7SZnb7PNnCTqyadMkGTMRbXCgb01ZZ06EB4ckYhekFv2J7T8FniIoL8aI4TETtVbuzNCkTnBGNkh8igQUCtRfEm6KJtDOkDqPzQwUDuS2qH50zZNvP1kasfisGJrOznR6MK0vn8VRkP15uXqJNIQpK+x9dpuB9HWcV+Ld0g4Z/KFGMlCDePDI2gzYE7RKwj6xcYvQpucfy+d6Thg7+9rxz7HnBwGuw6Xmq3dtgniOg== 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=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tvYXxY2mPfpY0fjm+vdKhYMf0GXw/6mRrRa+m6NjwEo=; b=OBy3HWnYRhmAjKj3yyH3DS4zR7BG8XoFoFYDybR3ckftY0jFPrM9BYZ6r7I/el0TEJBnkAGlTZvLbxABRmMEPXk6LE/6uhFuuTflADOti1xQSwnzFt+u9WhmnADNATJ5DCwTdbwD8dvOcnuzsA/Dn6+Y+dDqJo/Z4j8mTvNxMC4= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) by BN6PR12MB1620.namprd12.prod.outlook.com (2603:10b6:405:10::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.26; Fri, 7 May 2021 19:02:08 +0000 Received: from BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211]) by BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211%6]) with mapi id 15.20.4108.029; Fri, 7 May 2021 19:02:08 +0000 From: Yazen Ghannam To: linux-edac@vger.kernel.org Cc: Yazen Ghannam , linux-kernel@vger.kernel.org, tony.luck@intel.com, x86@kernel.org, Smita.KoralahalliChannabasappa@amd.com Subject: [PATCH 15/25] x86/MCE/AMD: Define function to get number of interleaved dies Date: Fri, 7 May 2021 15:01:30 -0400 Message-Id: <20210507190140.18854-16-Yazen.Ghannam@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210507190140.18854-1-Yazen.Ghannam@amd.com> References: <20210507190140.18854-1-Yazen.Ghannam@amd.com> X-Originating-IP: [165.204.25.250] X-ClientProxiedBy: BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) To BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from aus-x-yghannam.amd.com (165.204.25.250) by BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.3 via Frontend Transport; Fri, 7 May 2021 19:02:07 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7d87ed3a-b9fe-446a-a9f2-08d9118a9cad X-MS-TrafficTypeDiagnostic: BN6PR12MB1620: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: d7akEjogrtvv5YWLAoDTuvUaF7MkbbeC8mMdmkQwQXwYTQGRyEilHbmgBUTCrPguZGNvw7Aizl+DO7mRw+XEqFun2jK9ZVd6ChWOlkQYZU6bQXC97STTuE8kj4qgoMjp1Tsumil3ktAiSohaHisKFdoCiy0hpT/Y91ts1TCi7UxHqBbWQg73/Q2vW4nxaM5MqPtQyaPZ/E/xPMxHIvOS3wouBi6cvAB/aW3mDzAYRrUXYuA7V8CAvnwnwAa+TrV54YsxsxADgFxnXt3Md9YOIazr1sdixlLD6zHcPxFT66t2jSoOuew9WF19vNgnebp4+//CNjZOfTRaf2cxen4C9HF5zerl4MQvkRxzxnV+v/PRM+VbM27O7VbwpC02iJuugugkyecJNLxubIpB/bLp9W37MSnkpRmoWjgRcPwr9O3hnREiOPB+/rfateZony+oSOLKfCNMXcV/Zgqz2NjuSUmO59HY8JMXEEyk/oGeWBDCKMP4MLTJfKj/aT+AYGD9CibeDflKHDRbM2KxINFcL888j8OQbD61GQGKEx/o7wwr3Hd2k+fwkTZk8rn5uNnuGeXoZTwJpjJcz9BvLxEuuDuNL5IxbXafXNNhg61nOHDIcMf4brguZji3EPWjjw+m4DHfue0QEO3RqN+MyZgSOA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR12MB3108.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(376002)(136003)(366004)(39860400002)(346002)(4326008)(6666004)(38350700002)(38100700002)(66556008)(2906002)(26005)(6486002)(66476007)(1076003)(16526019)(86362001)(6916009)(66946007)(2616005)(956004)(186003)(5660300002)(36756003)(478600001)(316002)(52116002)(7696005)(8676002)(83380400001)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: WvgyQw0mMsinaCbt27IErTuDfvk2gBoPCS8Do5JQKet9nFNv6HsSfZnl8ziJ3o91c9fOPY7TXHJXoLmmKUMYPvqIbKlQTF4vnhRaqL2Tfoh8smC7oCsEQlMwEGJUsLqd37g1LW/q+0Ir325NQxfoEc0IZprxUEStjJw+lARM+h0Be4ODQJOkANGxUT/T5O3ZQGxmCdlsLpJpYZwSWwSyL9Yl4k2l0KJdh7IXtSuxqC4vJlOKZy3rhaeFLgPD4Coctpin3YUHbgnZWvR8IUUj6BX3qLWjbkljRORtSME3xxjKpYc15BsY9fz/yv89od/8AQQ0AIJ+oSS8G4W8XJUA2qOB5Mdnglam7AhyHQiGpCBTYaUVvOVonoZ1ryE4BMWsP98hsBM8UBBmk+1kenGdyTNX8TAVCl2FO99AHBDXfCWigEoWJDzLPBP4rAAnklu8PagdKuMI/y/ZrY/XA71Xxit1PvOJ5hFCu36AUUltUdNugm5Hw2LDE6/uakHKPBFgBKZB/PEXR9TFv1KsngKhMzVkMCcluz9XMCCA2iY+QqoRc+OoR0Eud/4DlhMZ1Lkj8sBbWdzU+LXvp6ih6QULinBTyved56+P0QJoKyw9hyYjdlgaEN5W9u8Hx7F+hP3aHgR3a83FsZGvra5Mghz69+LhkSAe/9+AooKv8UdTdEZZFxcJQKIIbwSWsy0SrHcu1GRB4gn/v9aDKQ1g9mIJDFOtVoneQTVffvNOTseUL7Q8ClQbfFRYDpPMhRff6fhkz2KtRMZEEnFpeW4PYfdqkV5hyRg5f2fec3IYGiBbLlMkiOZLKC+CsCa40HXRow6w2uGLtJHUjURxS9SKQvvXvqC1ZYtKFzJQk25x4LSA19wnHMaBWgqHcfKrhH1192VAh296GZGuXI1V9SuLNx5er89/E1SyPpg1rhxeGx0A3OsJr5CuLhEQEWq8i/wlducWXdIkmdopdcPmu9NeKIqzAZNukqO/CgxEhxyLD+k4qBrXqxJzLvnCPV+7YGktwtH2L4btz8GojqSj+7HcpnfSdoB40Lo98xIeqrNyxhOY+Y0ZwPzJK1Xy/+NOwshmGQS66KrZCOqaPq4NPHLEU6crBx8QfR2uj//OzQBUBRmllWWuIFwQ8OjtSHbVkw0vUs6e1EOSnfpgQrdfkICMdTLBt+h6rCjjspmYHgLVwlP8hEHqpsRPT2F5A6CiF/4XZdjG9dho1UnYWL4Dx5FMtN7HolwuogSPhfWMw8s8YLOxrlIQMVauppVmbRM/1VC0Js2CQIsw0yY+KT9kTOxdsN5awuXb3B1yc9lvon3UTtBxBVTLCR1i3sUes/D1xKrUpB4f X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7d87ed3a-b9fe-446a-a9f2-08d9118a9cad X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3108.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2021 19:02:08.3850 (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: nstXOyePszPpd/RG04yECtpTrx0o+N4Xr1mxSyfDjs52ujy6zGCE2UyJocTzvxYtUapGAlBlG+PWgSv7m+nspQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1620 Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org From: Yazen Ghannam Move parsing of the number of interleaved dies to a separate helper function. This will be expanded for future DF versions. Also, drop an unneeded assert to match the reference code. Signed-off-by: Yazen Ghannam --- arch/x86/kernel/cpu/mce/amd.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index 0c24bdc346a3..de59fa6cf540 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -730,6 +730,7 @@ struct addr_ctx { u8 map_num; u8 intlv_addr_bit; u8 intlv_num_chan; + u8 intlv_num_dies; u8 cs_id; bool hash_enabled; }; @@ -848,12 +849,17 @@ static void get_intlv_num_chan(struct addr_ctx *ctx) } } +static void get_intlv_num_dies(struct addr_ctx *ctx) +{ + ctx->intlv_num_dies = (ctx->reg_limit_addr >> 10) & 0x3; +} + static int denormalize_addr(struct addr_ctx *ctx) { u32 tmp; u8 die_id_shift, die_id_mask, socket_id_shift, socket_id_mask; - u8 intlv_num_dies, intlv_num_sockets; + u8 intlv_num_sockets; u8 num_intlv_bits, cs_mask = 0; /* Return early if no interleaving. */ @@ -864,19 +870,12 @@ static int denormalize_addr(struct addr_ctx *ctx) return -EINVAL; intlv_num_sockets = (ctx->reg_limit_addr >> 8) & 0x1; - intlv_num_dies = (ctx->reg_limit_addr >> 10) & 0x3; get_intlv_num_chan(ctx); + get_intlv_num_dies(ctx); num_intlv_bits = ctx->intlv_num_chan; - - if (intlv_num_dies > 2) { - pr_err("%s: Invalid number of interleaved nodes/dies %d.\n", - __func__, intlv_num_dies); - return -EINVAL; - } - - num_intlv_bits += intlv_num_dies; + num_intlv_bits += ctx->intlv_num_dies; /* Add a bit if sockets are interleaved. */ num_intlv_bits += intlv_num_sockets; @@ -913,14 +912,14 @@ static int denormalize_addr(struct addr_ctx *ctx) sock_id_bit = die_id_bit; - if (intlv_num_dies || intlv_num_sockets) + if (ctx->intlv_num_dies || intlv_num_sockets) if (amd_df_indirect_read(ctx->nid, df_regs[SYS_FAB_ID_MASK], ctx->umc, &tmp)) return -EINVAL; /* If interleaved over more than 1 die. */ - if (intlv_num_dies) { - sock_id_bit = die_id_bit + intlv_num_dies; + if (ctx->intlv_num_dies) { + sock_id_bit = die_id_bit + ctx->intlv_num_dies; die_id_shift = (tmp >> 24) & 0xF; die_id_mask = (tmp >> 8) & 0xFF; From patchwork Fri May 7 19:01:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 12245109 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B2B9C433ED for ; Fri, 7 May 2021 19:02:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0E0636128B for ; Fri, 7 May 2021 19:02:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230004AbhEGTDi (ORCPT ); Fri, 7 May 2021 15:03:38 -0400 Received: from mail-dm6nam12on2089.outbound.protection.outlook.com ([40.107.243.89]:47105 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229898AbhEGTDV (ORCPT ); Fri, 7 May 2021 15:03:21 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j4ooXmRL5r5FLQiXVLwb8p6Ez6Fo+sw3IQyqekK5TmawawX4AWByQx1efR8NXVWijr2VP5sf2gTqWuNQQi+NL3dzKKwocLOz00KqFWXEfwDzgiOllF7wY73uCeVGVUaUVTEZe/ZUiOX6ZSLS8KkH1JZ/4YFHJSx0DuNZTlgNNKGYdScBpis2W8UXT9C8TQ2Vn0XOjy/hPEjGlQhGGALWJEJ513PkBXNhJHzZhM0pPed5aqzp1YiUsyUfdIUZ3CoF+fPqJUlV5DXkXaQmeCaawPo7H1tMRNGA3w59NWUsHwLQkWJNped2KVbaBduP5z35Ec4RgQke3PYTesDZyzlI/w== 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=VWVQKlSe/q6Wb6QB0xoyEvXuUEOzXi9je5kChWODsQo=; b=ASPIobuz3uk+it2/eYKhRAUBmbuk4hUAE2fxows3O6+u+PCHh3sRorjKzU0fndlgv3N8BmTAIQXyPad1ThSFAxpCiB2l5NpUMAbEz8Gz2ZFluxv5zvrJO5H7G6Y5BWjuOTTNZRwZU3CWRIVZr+P6wGJLZVKOewIAo9ySSsC3ud/+dOGsQi90qZuIvQSXWMI8uDped9dVESBW9lWOxxQ7lP+7H81GdOIyFRvYiZoyIxcrL1ks7SD8N8wGJlG1dTL5ddWFWY9CY4+HyDyRZhUul3YjBW2RoTdQPTgDUUTkFolUwTsgL3QuwZbY7fTQbPQ+zdIq2B1dp8SzzzjPBq/iaw== 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=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VWVQKlSe/q6Wb6QB0xoyEvXuUEOzXi9je5kChWODsQo=; b=A4YW6VuUk9D7RM+Eh+LZ5GgVSJZ3BSfigBOivS6wpSK8EifEhvWfxVaRzv3gYr9ReHwo3oaiuWsZfkofEyLq9zI7inPyd18S3PItKErKXTqWKMwQ6CTwnX3WiRYiPFScq+RWSuQjlv5dkJrvRj4Yphs2jp7FGtj+PS3f9KAYLF0= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) by BN6PR12MB1620.namprd12.prod.outlook.com (2603:10b6:405:10::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.26; Fri, 7 May 2021 19:02:09 +0000 Received: from BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211]) by BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211%6]) with mapi id 15.20.4108.029; Fri, 7 May 2021 19:02:09 +0000 From: Yazen Ghannam To: linux-edac@vger.kernel.org Cc: Yazen Ghannam , linux-kernel@vger.kernel.org, tony.luck@intel.com, x86@kernel.org, Smita.KoralahalliChannabasappa@amd.com Subject: [PATCH 16/25] x86/MCE/AMD: Define function to get number of interleaved sockets Date: Fri, 7 May 2021 15:01:31 -0400 Message-Id: <20210507190140.18854-17-Yazen.Ghannam@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210507190140.18854-1-Yazen.Ghannam@amd.com> References: <20210507190140.18854-1-Yazen.Ghannam@amd.com> X-Originating-IP: [165.204.25.250] X-ClientProxiedBy: BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) To BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from aus-x-yghannam.amd.com (165.204.25.250) by BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.3 via Frontend Transport; Fri, 7 May 2021 19:02:08 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7040fb26-5e07-49dc-39e6-08d9118a9d59 X-MS-TrafficTypeDiagnostic: BN6PR12MB1620: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3383; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hae7Fmb1qhOBA6lXixiaB1tqggddl2ekov6SQ20DgxDSihkim7JXU4KT30z9bxPPrBTKIMsPNYN3VA/Lm36frnkDnNW5FQGQdkDJdy3QJzt6OwYtYKifygMFHEreetFlF1QrahLpsuUTLbrjLEYvwo8lklyQvL2Ou55+XHkxBpyuQh8VVh/rYXAsN1m1dS3LJbnVBebi+AOm0S8IszdevfOkzaFd9OoCVe9prrepNgq+hx85L0RtXdWRFS5rrn9NFnie+tpNA8evKtJLoobAnLnzddgK7dc0gMEyQuwUxb52b7i9+mhTgP/fEQaxj5RztCjyWbHBYOW8Oiwi6W7WsDSwUxkOiTpccInQylEfc74oKWYX4aQmBCUfGNiPxktaeHv8gWRWAEsSa/oMcYP8yz0gJz1ar27zZQmkPEibCaZRvwf3x9Lriy5ErFiTtvASTYe1F/UPbDrhlmMy3VILf1WRwihxPwD4leBi51uDpTpTiCoMFPR3gDFvc2Umo7nmHFI0mBTEy4pjWGLd3fZrw69p4FjZ/Vrb3DwokYgMi/Judki3iUkuFLwJC8ie79g061U49Ie3B5CCn+FlhEDCgeL2jYy+IP/9GaNevMAk4QraO8sH8JwtOlajDgao6CtouC21AoCMiMtB6czg564WQ3i4lwq+lAew06nv/S3i5Ns= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR12MB3108.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(376002)(136003)(366004)(39860400002)(346002)(4326008)(6666004)(38350700002)(38100700002)(66556008)(2906002)(26005)(6486002)(66476007)(1076003)(16526019)(86362001)(6916009)(66946007)(2616005)(956004)(186003)(5660300002)(36756003)(478600001)(316002)(52116002)(7696005)(8676002)(83380400001)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: yywtHfMj3ctn+7SFgUeLtgab5HI8sh4TrV5NRYZhkge5hdbAFrfkcuGVXalffjoFjDLf9X2fJQRGVdhL/u8Nuk2qkztMQi7vdlaJ3Kpyz/JPsIRNqXqMnDbUEMqAQjlJdRzBBZkZlLPzo1yxg0ORn3c8MZuBF+faXRkurRUB0lJ1mrUjgm7tjm7N31oZMnIvq5jT4knJKLuvtxGP/rhycNiftlew4lvOMKtNC4fSIaFVqFZ/Wkp7qSSu5W149ts80BWCarVNgOWdw410r6tR4gUCMzoz+OkR/kc23PU3IuahxD054dYQpZ1ZnA+KeNIKYGtNAO26ODv+uqiwXaL9kJjtxGO9vLIdPvLFblaney41glKvgOuq5U9nVxwWfu6YMN9qMqTlvIcuaFheR5t8e5BZZKsVer8epilPmLWg2qNOROmBWaPyjw7eRzk61LJoRLiSMSiXT344wF/pS8oJpT1hB5pciu+ggpk5qYNSuQbHQH+lNSoBLKKH1Pt9H9IV6sYRWtRPCp0/KG4F2yTzE2zwnHVWm+cEDiMm6y3q95u9hxQJQ6qFTL+x36iTvhUiYvivEJ0oG22yLX4qA9e2x07GdA4LKqepcPAxbgHgWeTgOY7DN9dXntZS8478R64D8H2FsIjN2Gg0nK/HXn6pmaVF1JbRWOCpUYVSRHJpbfmX5xDsIlu4Dv+anYzR08K6tLFO59RbbCh5z6tDCyJMuXJ9V86SCPd2aXliLtqUx7Lw0jJNUOjAHRrnVwse9e4dMwQeK7mpXb5Iffo2vnjFHO41xm1CftDg8Ri6wXm2Wp2pVJkytoRAuMIgSGn6W1xAsSgkHPJTkoyDx/dYuzhVShL/LNTmPhJOc0utdOfneQqduPKWkTE0MOZHyfxAuccj6QBTwMsAlD530opTC2Rqwg0IdROK/H43but/fk9iQAxVbwyXe8gqsNRCJw6QRtgUwayMlXRtxHEfDneWx1QBDFR0NUvGiHubJ4bNXKCK0mI+1Vv/exINwH/SdPIFC+adA859I8PASri/NsC3/GBBdcS9VmCUkvoogyiHYrifxYV8bCYcRj8KNUnSkZt20Yjstj6IZZv8OLtcODjtyp7NDVIkKKQ4Yw1XeXnWggnWyee/8Vqe/IXwAdFPrQ6kuDisC+0SSyj9ldTFgFSLiqQP0MtyUzuNOwNwu7Xnkmp3d4lT1UNadovqXNIUFi2FBtzUT2jS9FCpHVo8OaeyUh1dZZaJEicN0g03/MplgLDpQiL3JOCnjaw6vOFCJCBNvBuuxuQQkHGu3fgEAff7kM0x0R6lHsJhxoQ1q9u5kZmxDomCTJNWvShX5fqtm+vp0oKj X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7040fb26-5e07-49dc-39e6-08d9118a9d59 X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3108.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2021 19:02:09.4524 (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: 81/OATBQ0rAfA4VlKEsrORVXMRmfZsWhwpXHOyHyt8RTVe1skUs7JRCYfNfKI2egfANIS5OJWJOk1gXLhbjvcw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1620 Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org From: Yazen Ghannam Move parsing of the number of interleaved sockets to a separate helper function. This will be expanded for future DF versions. Signed-off-by: Yazen Ghannam --- arch/x86/kernel/cpu/mce/amd.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index de59fa6cf540..670787be705d 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -731,6 +731,7 @@ struct addr_ctx { u8 intlv_addr_bit; u8 intlv_num_chan; u8 intlv_num_dies; + u8 intlv_num_sockets; u8 cs_id; bool hash_enabled; }; @@ -854,12 +855,16 @@ static void get_intlv_num_dies(struct addr_ctx *ctx) ctx->intlv_num_dies = (ctx->reg_limit_addr >> 10) & 0x3; } +static void get_intlv_num_sockets(struct addr_ctx *ctx) +{ + ctx->intlv_num_sockets = (ctx->reg_limit_addr >> 8) & 0x1; +} + static int denormalize_addr(struct addr_ctx *ctx) { u32 tmp; u8 die_id_shift, die_id_mask, socket_id_shift, socket_id_mask; - u8 intlv_num_sockets; u8 num_intlv_bits, cs_mask = 0; /* Return early if no interleaving. */ @@ -869,16 +874,13 @@ static int denormalize_addr(struct addr_ctx *ctx) if (get_intlv_addr_bit(ctx)) return -EINVAL; - intlv_num_sockets = (ctx->reg_limit_addr >> 8) & 0x1; - get_intlv_num_chan(ctx); get_intlv_num_dies(ctx); + get_intlv_num_sockets(ctx); num_intlv_bits = ctx->intlv_num_chan; num_intlv_bits += ctx->intlv_num_dies; - - /* Add a bit if sockets are interleaved. */ - num_intlv_bits += intlv_num_sockets; + num_intlv_bits += ctx->intlv_num_sockets; /* Assert num_intlv_bits <= 4 */ if (num_intlv_bits > 4) { @@ -912,7 +914,7 @@ static int denormalize_addr(struct addr_ctx *ctx) sock_id_bit = die_id_bit; - if (ctx->intlv_num_dies || intlv_num_sockets) + if (ctx->intlv_num_dies || ctx->intlv_num_sockets) if (amd_df_indirect_read(ctx->nid, df_regs[SYS_FAB_ID_MASK], ctx->umc, &tmp)) return -EINVAL; @@ -928,7 +930,7 @@ static int denormalize_addr(struct addr_ctx *ctx) } /* If interleaved over more than 1 socket. */ - if (intlv_num_sockets) { + if (ctx->intlv_num_sockets) { socket_id_shift = (tmp >> 28) & 0xF; socket_id_mask = (tmp >> 16) & 0xFF; From patchwork Fri May 7 19:01:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 12245113 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB186C433B4 for ; Fri, 7 May 2021 19:03:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6EE5A60E0C for ; Fri, 7 May 2021 19:03:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229806AbhEGTEE (ORCPT ); Fri, 7 May 2021 15:04:04 -0400 Received: from mail-eopbgr770081.outbound.protection.outlook.com ([40.107.77.81]:44439 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229974AbhEGTDb (ORCPT ); Fri, 7 May 2021 15:03:31 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ICl2tq03yObQYetyfVHxE/XFh8tnB55Fo9ulP55Gf4HA9spXmfXFc7QLVHW9VE9CPmKvGhLLrZqXP8uBdNq7vGeJVj8M9+Ql8Xuh6uCM/+F833Y5Sr2hcUhs+ktpT69gDRvwSYmkknQ5DSG7FE9BqROQUtnnvr0vAWRlBnGWLWn4SSlVeUnHZsNfzMSW0w4znn5Co4w3f9VhgZgPpxOswSY7Czl48BO575htKJwYsO7tC80jo4VwAfBzvN/7Kz11hu0Za4SKnYkp/5JF6Dc6esVnXYqJuVe4uohN0LuI/tXJRDPStCtMr8KGUKNz0buHLno0iLCemzE3B4FR5Q1PMQ== 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=zhWgsakzAAifgRQdxQB6LOOamCQS/oQxL6bJynDabPU=; b=cmMWL+zgzNuGUeAG/UlpNdzhbi9Oqwhx62WxSK0Zf1e1rgCL8uqE7MRlIRBnaY3ZdfJVD7vpgVSoMJt08ImbRZ9Qn4kqyi3cpwZehe3kVF5cy+06SikJco+Q4o27goyuvYd31YCo21QZ4mB1kZ7ryXHPgDzqzJxgMKjrjSIjpCoLIbDQEoFHtMqIoU1CFAVswNY5AMKVX98fCSEEHyXDvP9LyxyQwD399zUfPfO75Zd6CB3d3mtkvVFEiGbQbraHAtLDa/AzAVe+6al8H5FExvNQqCQJHMYu4ogMoHo3qNBQHsS7ZsBNeb7gbuJHeYCVXkXP5+9+XGErbNLGxxrjBQ== 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=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zhWgsakzAAifgRQdxQB6LOOamCQS/oQxL6bJynDabPU=; b=gggmot2tYdysAphv0+GBR0N+0bT1VlfZ9jwtd40F6xMffXo1WcUE2AFDRUFkoJhS7sgTimw5Yr+T9CHDsm/S6Bd51oSC5j8HHHg01JcpgNvSGW34bfojo7bMGogWHTK4x/h0ZraRwTSSOTuUS5KzCGJY3vHYs2dgku2kpwz0lSI= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) by BN6PR12MB1620.namprd12.prod.outlook.com (2603:10b6:405:10::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.26; Fri, 7 May 2021 19:02:10 +0000 Received: from BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211]) by BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211%6]) with mapi id 15.20.4108.029; Fri, 7 May 2021 19:02:10 +0000 From: Yazen Ghannam To: linux-edac@vger.kernel.org Cc: Yazen Ghannam , linux-kernel@vger.kernel.org, tony.luck@intel.com, x86@kernel.org, Smita.KoralahalliChannabasappa@amd.com Subject: [PATCH 17/25] x86/MCE/AMD: Remove unnecessary assert Date: Fri, 7 May 2021 15:01:32 -0400 Message-Id: <20210507190140.18854-18-Yazen.Ghannam@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210507190140.18854-1-Yazen.Ghannam@amd.com> References: <20210507190140.18854-1-Yazen.Ghannam@amd.com> X-Originating-IP: [165.204.25.250] X-ClientProxiedBy: BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) To BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from aus-x-yghannam.amd.com (165.204.25.250) by BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.3 via Frontend Transport; Fri, 7 May 2021 19:02:09 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d7012ec5-966a-4689-e4bd-08d9118a9df8 X-MS-TrafficTypeDiagnostic: BN6PR12MB1620: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2657; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BFcBeveru+vdsJnOog9wvLmotHp94cbdEAIvLaeRWwB1M53lSiOqepknMFLaJiNJuk1wETRuvBGEPVuO5ncpjQR9h8BZvM9K6eyDifDGG3E1exZncDqDEzleWvbN4DUgiWtVg3JwjcYzgYas9TJLChAQ2sfV2a4Mnx+NfhW/Zv66ytCgPvow1MIKct4/gZn04jUSCA0V2RD7OzXkFyiYuH6OzNh1vfFEs0pLGJmGZ1aNQ1tGoR/7b+mmXgBtVj2c51qdESom96/Cl1266iUwARR26jBQ6k2iIHznDEk+FPyj38ce+DER5UXp9i0crKo43if7BH7amXB2fIV8r0TQ/DSss9z2syj1QUNp7JeEO/v8dufJbbieXyaKQVM01yuE3XMoCy0RgAnDM8ndtEZIeeFsr3p8QnCiNNC7W7unlqrZA0ZKgGiQBPhhg+Hd5c7a402lInsqxpq5GoQobBwHeSDlUldDNarT5hCNRk2RadLr5qcu0Ju4mZNQNWa9slitMIgJS36Kc7ji0H8mjZg2L/7aaUcd3+pSiv0cbJDZrD0Nl5WTOO0QjiCRsPF+oETnxIFzD2ENWHAeusV7euVShVjBtLKf57EAKDDqRHP2WZf0VBkZWHsw0xC6bQJotqSMjIDv6Eg8MNGlZsCdrfbgNOmdw9u8FsslUK44ZMz68do= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR12MB3108.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(376002)(136003)(366004)(39860400002)(346002)(4326008)(6666004)(38350700002)(38100700002)(66556008)(2906002)(26005)(6486002)(66476007)(1076003)(16526019)(86362001)(6916009)(66946007)(2616005)(956004)(186003)(5660300002)(36756003)(478600001)(316002)(52116002)(7696005)(8676002)(83380400001)(4744005)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: X/UhYVDVueSOniNdM3E1eH/LwvS2u/Y354eBlEuRB0ViNKdSd+du5uxRnqlfh5ybTnoJtdnkRYCCrNiXUOn35jAt/fpbIyshf6geDFf7nLOEg9wgIQkpyS0RJDjuGC16YPOnPb7+TY82Ij7h7uS6WO3Adv6TTu0DnvD6zBQRWE5nkClR4X1VAp2uEND5GM2NgjRR8wrnkNkmrtoD8W9ww0kWZhqWsLjWCFCtWWsArlkuGzCVZjJAw0W9NIfnAsIGGvndZyPiKgSN5KqhdiJugHvesH0EOQoKJdbyWEdNDkaQTnUxRQc8aY7p7afByS5w+5Zw/KjUimGwwMOE26uNPBhx16iUxFjqBcQD/aaZKwnwEsldNzeEuy8d/5WB+B74XY9nTi6FL5VB/hngjVgqa3CzuZIBZbf7Hj7UMqIV9oAZRozN6S8vNUWe/rfj5s4gGMYwYHqO52TVweHpbTIx8yHoA5CLdm3n+E0J0fvkGdp8Zi9XpzqAeRTC//R3wTG13JLuIRMkcLAFsvVYfOLf6tB2oRVEIhtgTmyqMsUTjErsmQ3bpwmu3+Z2GLRMiOMi+/m1nRmmhFk+/KABEguz2KtQ72k8lAYPT1EtVb1zs8XqSCmwKkFJhsL9EXPTdG8mo/Lfoz40RWhDFakMqpCTbeZ/IuqvcRuC6iGj9Id+5+RWPSoaWO8TM0P67YlXqjl5u8QOsDh4Iu+Bht+NjGsqSqk8Twz7YPo8KnzZSrQpslS+24qPf8/JbgJkmbDvrua0v2dYZbUt3NcYnoF6J8ji2M4RAzGd4eCAMc5burf0ZluOpoehaIwcLeKQcStkkfLz/I0fmY9/WLsRSsGo9nN/FrwdRD+DMktUU3JyB3zj7HOVySNNuTVybihdsTFFznJJ+rlZf6lD99zgp0P2rKFbJmmVZxvcINSW9p4azE0pdyBs7yYTOV09tPD1ExWBr3vRJcibbVN1suWC1+VopxTUk3e5oklmhXy+zWX94ql1Q/6vQ/TCP9gd51BWiFyO2uzWn979qCcKXRG4CC612rFba/AuTnPGExwsGOSkwu66ukT3mlyYg13nvE3xpMtS2dLVem+forhD+p6bSlrdSE084joetGzfRY3eOwMB04mVLUYyCCgucqYH0vP3z5bR3vVbDmrhkHKU5TXMbyoR1OD6yVXny+m0d6e00gDNJPwuFFZa9yx7OMA/Sh7SelU6SIyrt7BKiYtpPyTw7O6I8H7OB4UpnAIWAP2S2xrSaWylC2U2WzmfskEUlzPdgyCqrBhWHLBrGOmuwkdS5B8kT1/fs91iZxpA8XeB8qoIpHur459yUrSb/7rN7X/rdV/E1PDC X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: d7012ec5-966a-4689-e4bd-08d9118a9df8 X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3108.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2021 19:02:10.5198 (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: nUjDAfFawaUznucp5iwrbVRzxZM8hxOU6Waiff7kVKKYuERiNT4RWNlO4b7uF982y0XWdQPmOWgHCAO/R3mtFw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1620 Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org From: Yazen Ghannam It was removed in the reference code, so remove it here. Signed-off-by: Yazen Ghannam --- arch/x86/kernel/cpu/mce/amd.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index 670787be705d..8f4838a3d509 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -882,13 +882,6 @@ static int denormalize_addr(struct addr_ctx *ctx) num_intlv_bits += ctx->intlv_num_dies; num_intlv_bits += ctx->intlv_num_sockets; - /* Assert num_intlv_bits <= 4 */ - if (num_intlv_bits > 4) { - pr_err("%s: Invalid interleave bits %d.\n", - __func__, num_intlv_bits); - return -EINVAL; - } - if (num_intlv_bits > 0) { u64 temp_addr_x, temp_addr_i, temp_addr_y; u8 die_id_bit, sock_id_bit, cs_fabric_id; From patchwork Fri May 7 19:01:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 12245115 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C5E9C433B4 for ; Fri, 7 May 2021 19:03:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 049E160232 for ; Fri, 7 May 2021 19:03:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229698AbhEGTEG (ORCPT ); Fri, 7 May 2021 15:04:06 -0400 Received: from mail-dm6nam12on2089.outbound.protection.outlook.com ([40.107.243.89]:47105 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229662AbhEGTDi (ORCPT ); Fri, 7 May 2021 15:03:38 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EzmE8TdAIqiERliVacfiTZvVjs3ben5N+eGwnUbR+rqEC1H4rGtKWpLEzhDm9sfTNwRvOOsMBV+tQWKumMXt0q46mRw0FY3g1iAd5fJyIf5eJyCwJS6KWbWs4l4gW1NlcR1B04A+/FFjmnTygEqg80U6OXUpFH6ZI8SyR66LGGwA2O1NrSfs012izTZMX7j3+l+okL6Cha9pikODTwa1nX/8LggMIKoZe8vBuusOc5ZR5/jdbTF/UDLaOoHFNIuzaPcspWyJjYdTxIcJn1oVOqF1pkDsmv4qTEhH4nhIi7Rlfh1bpbm+cW+cx4Ke1rxG2DmYihe/eP1q55sy/1XZyQ== 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=/Cn9Z3Vyw86bxfRiIQCRTvA+MPQ0NT1D9R2JYglSwL0=; b=V7hitFVJr0kExOPfIMU2ulocz4RMGvLKCYROtWgTboWou1fCkU/OsXnjeKMHT48fCxuteDWd8O+TRVpEZ1/w8F/5+3ErXrOp650fCgu1c9DKEN1PVAofFMIxofQHMZsTM1dNfNIN00wthDMwjzFWzQb8UTVow7IeMmzuRk0lDFOW1oXsR2/yUa6qd+0geFhcwyyGIRnVKlLIItY9In9lDLfXcq4Cbv1yxAytjGxCxU/gESo/Uw/napt283RUxACYqcxtS4euVo6Pwf1DsVP4q6h1f8rVTIY5ebjmF7Yz8MgURKKb168KXHS3aXefBsUl/qWt6uFqqFzatQoAs32OcA== 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=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/Cn9Z3Vyw86bxfRiIQCRTvA+MPQ0NT1D9R2JYglSwL0=; b=TY1xWofEyaBSSELNjOaGeN/hzL1HAVnAXRbtzIdyOai4Wz9P7poCzLMiQCsK5DHzHVxJ3G/Dy+HAHy9BeSAPQKTXpgkDSPjGcY/IOkRzXgCaJuO1LL6oInvrYKKaOB6HFsybwkalHrtJIG7rRkWaWWB3dHZeJewqIHuus4+UB3c= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) by BN6PR12MB1620.namprd12.prod.outlook.com (2603:10b6:405:10::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.26; Fri, 7 May 2021 19:02:11 +0000 Received: from BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211]) by BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211%6]) with mapi id 15.20.4108.029; Fri, 7 May 2021 19:02:11 +0000 From: Yazen Ghannam To: linux-edac@vger.kernel.org Cc: Yazen Ghannam , linux-kernel@vger.kernel.org, tony.luck@intel.com, x86@kernel.org, Smita.KoralahalliChannabasappa@amd.com Subject: [PATCH 18/25] x86/MCE/AMD: Define function to make space for CS ID Date: Fri, 7 May 2021 15:01:33 -0400 Message-Id: <20210507190140.18854-19-Yazen.Ghannam@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210507190140.18854-1-Yazen.Ghannam@amd.com> References: <20210507190140.18854-1-Yazen.Ghannam@amd.com> X-Originating-IP: [165.204.25.250] X-ClientProxiedBy: BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) To BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from aus-x-yghannam.amd.com (165.204.25.250) by BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.3 via Frontend Transport; Fri, 7 May 2021 19:02:10 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 84670962-b579-4e95-692f-08d9118a9e8f X-MS-TrafficTypeDiagnostic: BN6PR12MB1620: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: O489hqD+VmP/xO21weMvRiGYt640Mk6rvTOtBwlOvYSQYjP7aqlMMpmiklTmi56VgHdDaKyZtHXW+aYNjS5/60F21NDQa7QS9fPSQGUsdWSkahVZT7GwC+AVJcJfMgudhLwq2KPruH2mkhZkTDGS2VXfQsQMIfua2j07OR9XJslt4yOzVlFjuygdt8OHp3l032+wqj1BQZjPJzT4yMiflQ6yPfzobVxHPvO4dYEtvh2tH2Y95FgsZzhZchgXq9sSw9Hf63pCrc0uAaBvjfc8yEG+zVAUNYHR9IuG+Hv97SMwiGjCo/G7WT3CMNbBNFNQMXC+LYHbZe+XeEEovLTYop0tSICb4ELyA4P8G8kgTm5y83hObSk/f410mRUJV3eV0oc8VBOIYXHNSQozau9PWgJZw5fcNP3paWgUVLpTHbwruFFNsJfYrbAWS1L+H6kuFu0Kgy08+HACrEgNPk3RQKrhqVpM4Ka7lmpkYuCztx/9B+SxnqOWO/398upJ3g06Skr5uw6sd0VDPa55MBoQLF2udXCurC7upR0bgdR4BOMQk1MLVUXmljq01pX8wFoMhWmDzVi/CavaSjRS+OItwG3H1RcB+TMpLysQuu0dejeQGb96dh0bQcAyMsjVnH0G/aEouCdOh1ME81mbeqyfqRpCLO2SiJlMS4Hm84OL5aU= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR12MB3108.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(376002)(136003)(366004)(39860400002)(346002)(4326008)(6666004)(38350700002)(38100700002)(66556008)(2906002)(26005)(6486002)(66476007)(1076003)(16526019)(86362001)(6916009)(66946007)(2616005)(956004)(186003)(5660300002)(36756003)(478600001)(316002)(52116002)(7696005)(8676002)(83380400001)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: OjKBuoz6mw9V7xXNbIyAAq6kliP3HklEhLJihtp2XTxCXHBbDepBt1k9HME51vOcfkwXYeq9upO1SDY9cKdoRjR3VLwl+whPVSS33xVTawCmrKwbo0w0XHbpAgQepM6H9OR98aK7GJh0ajLSmNwcI/Emcb/uCierkgF0HZjrCOE7EAIxUJfjxYgh3j8xB7nerimyqgazHLv5x4wKK9iEsje+s5jvNOmFEdRkg8WP1xQuiBQQ3jWzgoglqwCmmHpkdDnT/guV4Q3ehxWfOHyQLYAZGl/39+RRjsQNtStk5aLoHJ1BUrq6XB1CiZHqyQpnqAGwPWxHAv/vYp3F5RLCZt6BtCTY8cPSbwTI0CrkSO3/3BCdT9ac3B7Qe1ldHuh7WTp9j5woElm1HKJZEryzG9tSMwfdNUgjITFlEaaZM5mMgUWkstEaby0DsnTjZItMqc6tnFpOVAVx4ZJxdUBnBhsvfMKIn2xKko0TIREnv7ph8gIIedRSnu1xEhbLafB5eLR60HWMdHZZy1b36FiIj2jSA6tJY/wRzj/Yb8blUwrBevpLccIojrayjt8C9776GOfUqpFN8vcXAFRNy+7UtycbWkCs32YDTyn1pbE6FvdXwnBVi6ruPLt/KuON3xerrb1MceDOaVej0/MAKeo4dCrLgvN4nZ4se1qeqD/Sng42mKzOF2zbs887AZzJ4OOqS5lBzalE541J3s2Vj8XdPrnmaU0+goWMdU5WaLs50P8U36zwiODfb3VSq38p7P9W1W5sI6XfauKIjzaURm1cscUZTjfnEoy64h56g/Uov9PNFKCwfmV8GUmYjgdug5jle+rnbO3Mu3AMgTwfzPXIpJhP5TFwRk/bN/GeNA9RaJeX4aEQb4EMDRmXTtEQb3ThWS1wtJzYJ6eVirYnnXkq0UVThiDgxI0yw21r2bBtVYS5IMGmv8NJfpD09A7CnHzbTqJ5xvBTTfvWdVK6hiz+1bLc3gn8sYWTxbUk9kMbBua93+4e2hl9hX3k4HCVk53v/2AZIu5aBByWJEzvhwuEbrYe8AHtGr5th8AaYbpdg8cqA083Rw0ZOUiMr/Pw3nixPtgYW2phNCIOdL5McvYC/UFUnwxp043ZLb3htC2zyhIF4e1SmxqkkML3O4cpQz1AUrtz7kLprJ0n4UJCifgRXIWIcDDNgD16n9tOHfSFbnY8UslKIbdfPY6z/cVhxDxREEaE2Jk1D/Exe5wvYKhTPpOoPPIHqfVRYj4MYDJkY2ipQVeu/oL2eWPMGE0a6iJk6G8tQktyQl3ggDb5e35Y22UYAdHg2CQ9knNclJszEByg0dkx6lV3K6uIgA24RaMa X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 84670962-b579-4e95-692f-08d9118a9e8f X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3108.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2021 19:02:11.5072 (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: CZQWoUmA9L64rbb5P5wSJKe/z2W2Cf/rzzZC8ydQIJnZjF+83V139gDLYxuwbF8CRfmhMt4r7Iyijw1N1NcK9w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1620 Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org From: Yazen Ghannam Move code to makes a gap for the CS ID into a separate helper function. The exact bits to use vary based on interleaving mode. New interleaving modes in future DF versions will be added as new cases. Also, introduce a helper function that does the bit manipulation to make the gap. Signed-off-by: Yazen Ghannam --- arch/x86/kernel/cpu/mce/amd.c | 43 ++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index 8f4838a3d509..ba365901e39d 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -860,6 +860,38 @@ static void get_intlv_num_sockets(struct addr_ctx *ctx) ctx->intlv_num_sockets = (ctx->reg_limit_addr >> 8) & 0x1; } +static void expand_bits(u8 start_bit, u8 num_bits, u64 *value) +{ + u64 temp1, temp2; + + if (start_bit == 0) { + *value <<= num_bits; + return; + } + + temp1 = *value & GENMASK_ULL(start_bit - 1, 0); + temp2 = (*value & GENMASK_ULL(63, start_bit)) << num_bits; + *value = temp1 | temp2; +} + +static void make_space_for_cs_id(struct addr_ctx *ctx) +{ + u8 num_intlv_bits; + + switch (ctx->intlv_mode) { + case NOHASH_2CH: + case DF2_HASH_2CH: + num_intlv_bits = ctx->intlv_num_chan; + num_intlv_bits += ctx->intlv_num_dies; + num_intlv_bits += ctx->intlv_num_sockets; + expand_bits(ctx->intlv_addr_bit, num_intlv_bits, &ctx->ret_addr); + break; + default: + /* Valid interleaving modes where checked earlier. */ + break; + } +} + static int denormalize_addr(struct addr_ctx *ctx) { u32 tmp; @@ -878,13 +910,11 @@ static int denormalize_addr(struct addr_ctx *ctx) get_intlv_num_dies(ctx); get_intlv_num_sockets(ctx); - num_intlv_bits = ctx->intlv_num_chan; - num_intlv_bits += ctx->intlv_num_dies; - num_intlv_bits += ctx->intlv_num_sockets; + make_space_for_cs_id(ctx); if (num_intlv_bits > 0) { - u64 temp_addr_x, temp_addr_i, temp_addr_y; u8 die_id_bit, sock_id_bit, cs_fabric_id; + u64 temp_addr_i; /* * Read FabricBlockInstanceInformation3_CS[BlockFabricID]. @@ -939,11 +969,8 @@ static int denormalize_addr(struct addr_ctx *ctx) * bits there are. "intlv_addr_bit" tells us how many "Y" bits * there are (where "I" starts). */ - temp_addr_y = ctx->ret_addr & GENMASK_ULL(ctx->intlv_addr_bit - 1, 0); temp_addr_i = (ctx->cs_id << ctx->intlv_addr_bit); - temp_addr_x = (ctx->ret_addr & GENMASK_ULL(63, ctx->intlv_addr_bit)) - << num_intlv_bits; - ctx->ret_addr = temp_addr_x | temp_addr_i | temp_addr_y; + ctx->ret_addr |= temp_addr_i; } return 0; From patchwork Fri May 7 19:01:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 12245117 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 792EAC433B4 for ; Fri, 7 May 2021 19:03:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 46A6A6054E for ; Fri, 7 May 2021 19:03:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229713AbhEGTEZ (ORCPT ); Fri, 7 May 2021 15:04:25 -0400 Received: from mail-eopbgr770081.outbound.protection.outlook.com ([40.107.77.81]:44439 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229959AbhEGTEE (ORCPT ); Fri, 7 May 2021 15:04:04 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YpS7lik5PCYrPcwpHQLSm0cIz8gWghpJq4D5Y/WwMrx/AthurJUVioKG2yY+QGzeIrO+8BIUMWgRyqNndij225hEVK8qjtrEfLhn/KpEzrJVQct3LYkzrUY69oLpnQ4XzkKf38G8YlYPfGEO1yHR3z16cr9AXNAweIQ+9KMcTyDV9q6uXXZngYi9npDmHPPYqfnrEEPmY4BhiIfwGlw40urPb3SIyAw+z0wtdX/UYH/ePwPrzZ4kEMvqhrhVyUPFcbyHA6KqZ27SN33XFB94tirHNOrq/23/JytG6wuVMNMKFaM05U8cye2lRqG9kVxHGg1Ojn64VT1nyHgJ1BBoCQ== 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=iVJuVnaUO0EaYvsywS/DLGdSddCKhRrydBtnIfckj9A=; b=oWngVyIJ/2iFViQ5MO83QEmqZPMNHxOJYzpYDbNaYoJSqzU57sdaoig52yfyBJaRWYk2HVq4s0sAI+0YSwqV0hCsOP2NYIdii0j76Q4/oKKfFUkho8+nZQwXzrx9Fsgu8hUqBOT+u2ELkuLApB0YI4WtRC7LDwgP6zUthtOdWMr/ZtUKpKrC5zetqRqChlqXYslRSKXYtuauUKeBPF6uuMpOzAAZC9qY47D9XrwYWrGlTC5RXt33iok1uoR3LfJXMejiE1+jyE9N/L69pp+yOn1SBFY6NV507znAvLLQdFhtpVNvE7HUNsC5nJiWOR4AYOZNrRRIQUghyDu0VlhEIQ== 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=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iVJuVnaUO0EaYvsywS/DLGdSddCKhRrydBtnIfckj9A=; b=SwCR0BlZ/uRXivL0037RHoCt7bmrh/ghbe8mP+aU5RBw3U4X/2wfiHl9qVscN2OIA29R0o1nmZXWB11FNRZbMcAGdGgWJtqRF2K/PXD8/ddDwUXARLXMt8yoaXa9div5Fh+vS9ElCtA/OYQXsbxevBMpDNPoAcGoTIM1mvUzMBk= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) by BN6PR12MB1620.namprd12.prod.outlook.com (2603:10b6:405:10::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.26; Fri, 7 May 2021 19:02:12 +0000 Received: from BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211]) by BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211%6]) with mapi id 15.20.4108.029; Fri, 7 May 2021 19:02:12 +0000 From: Yazen Ghannam To: linux-edac@vger.kernel.org Cc: Yazen Ghannam , linux-kernel@vger.kernel.org, tony.luck@intel.com, x86@kernel.org, Smita.KoralahalliChannabasappa@amd.com Subject: [PATCH 19/25] x86/MCE/AMD: Define function to calculate CS ID Date: Fri, 7 May 2021 15:01:34 -0400 Message-Id: <20210507190140.18854-20-Yazen.Ghannam@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210507190140.18854-1-Yazen.Ghannam@amd.com> References: <20210507190140.18854-1-Yazen.Ghannam@amd.com> X-Originating-IP: [165.204.25.250] X-ClientProxiedBy: BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) To BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from aus-x-yghannam.amd.com (165.204.25.250) by BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.3 via Frontend Transport; Fri, 7 May 2021 19:02:11 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 70692758-4437-4031-50cf-08d9118a9f2e X-MS-TrafficTypeDiagnostic: BN6PR12MB1620: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZkOIxHcpv4+7leYN24E9R0d+WnQHdcVd3fYAnoZLZwwNSeT5SzS4otGyjWKITEG1I+384ydwYxuQ4QW82fQoOv9FLbqkpCTe62qcEnej4s6vXrlFS5GlHMRwk0PB48QYs5N8bE2urB4Lp7iOcTCuM23lN1z9UHUu09xxzdAX7JtzytTuw8BaAQJM/tctN2oxafRmSxH1Ikc9RkG65KAuBvpn4G7PEuVFIIthLJ11UDSWUESpFzqADumG+AE917CL9N17Rv6fpBHSqJNno987beIxZ00iFBxDw2HmLIY2u7KaHYiUqJ2rY5EMAsDBviAiaLKXEsp3fwZZtFDughOyLTBRzzehOkmeOj8+6uDdtw+B57+L1HXoDzUq2fKE9gnLSR79ZhmRNaNDZEMQbqELg+AN3IQPbd7zgzDJJh5rgxPCwipGw/4o2e4GG65M/Jo0Pj6zuoaTtLJdU+nkg4HY1weEtLbc1ofHP1ju2g5s5hO/c7YOQ6lrALtqq8XhfKKJixqcStjmrcAYLMxclJ6kTmaIFIBsQfSkkSe9sra/Yv3yb3Hq86AY7ybpRBeOAsjbgw0U5PHL+gaeUkpDGQ47TxkwYgUjz0fEmHsbKmX54GCHRle0KJMZyamvljjUqzKV6ZFiY+Knh6S+FipVARrqEA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR12MB3108.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(376002)(136003)(366004)(39860400002)(346002)(4326008)(6666004)(38350700002)(38100700002)(66556008)(2906002)(26005)(6486002)(66476007)(1076003)(16526019)(86362001)(6916009)(66946007)(2616005)(956004)(186003)(5660300002)(36756003)(478600001)(316002)(52116002)(7696005)(8676002)(83380400001)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: HCRpPMSpe6mzYTSvK1VIbp6TsXHhE0zaBZPihX2tcd568hXVRlEy7dYJ8Oq4wFiofbg8TtTyq4h1bPg0Z/qEJ5lf9/dslMPIpc0ft0OcKj/hEXKzQOGnXRsv4oQUthBPNJclZyF+6qG1SE3c/zEjpEk4sy1bg/A21a7UPo1FKWnfL/9i80ymaY3F8aGuCzMnH1ksxM8SN6XaKH3CjFuxKETqxJ7rI28OvNgxXqkO5gxC3/T9YMqDqH01O673CfTln8WVHc7E2PMsyKqpu8GMWQ78XlYvnUO1e9CUs9HPzjYPcjY1KC1k+bwc8GEJ7gJAh4k5lhnp56ZZB2yKSoM74FvJNNpSatYYBtoX3SrWFWxG+icAlnWb7hlMyLRuQe7funRWALHWbl11kRvj+25aa/w1XKdAv1pKnPYKX57mOylNeIqSEYdekdvyYUxrBkcvB9Z0bWVoOBH3eVJrcEkA24Mqya49o98MYOMlat185P8hXcDWeai5WpHXfMf8fcEgibrDt7iO99t4jeE7s1TphI+ElvTou6KSp4x6GRyw86GlnO46uGKMWa9jJ5XBgVLVGDB+PXX4zfZV8fc598+O5m4ZDXyhUWD9IPVaV5jWONwvriRNhAuHuLOSIooyzN+7zuPfSIACBP502PRstV+cHn9Iv1WmQjUSJ9YkQaoXqdFuCDU3sonyUUS5ud8kJdr10AXFAusHl9830DFKXBthzhVmQJUnEDQJXiqBpCuPyeSews0Kzgajlj4E3nwb1/Inj40e8zM34Nx5Ch3tG+t5kNESlvCJFQl0/rsv4qn3KyIuzBBbQRMDJF/m3h7omoyOUhPnK9eQVLZxBXDZI8QfLMA4wfJFb1WT5CRCGDRKorfLaSmlzZOzcq/r4EDIwspbG5lpv54A4UEMxwGyYCR3tIRwZfZfjAwGEMs8ulmXDDhTT94uut00pbgAJ+2Otz+tym6erySHYSCbDttJmljE/BNDAmw2OUUCRSXenI46oD0CziViOp7ZSdb009UaYgfxPFr9s5cVB6nGNRAumGQG/Xb1Y2VAVeoz+v+jfO1dIA2iivphmR5zgh9qbul/tEI1c22wWKUu0j2MgmfOvtnqY4zASf0CLORlE4yDaBqpZQMYq53Zm8Hh7A2bD89BPWVBkeSwWKP7iQRax+Y7BfTnoUw57WC4oBrB9Tc1pLFIA2a7JbY15W5YT7vKx5nU7+B3H/6f16Key7MLWRBiSpx1Kn4FbztjeNTXmEh1vATBd0cYiQMbU2ujBKToBZrYV2T3di3x6dLduxwOjpD6miOdLy0an0QFvhDDCJTE1NwI0r+yGNJU7DfQOop1xb3Ykkw4 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 70692758-4437-4031-50cf-08d9118a9f2e X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3108.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2021 19:02:12.5706 (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: sUY6IcCax/D7/calPsMMGl53mDfUUpmpNFeV+Y9tyhwJGujuBR37flAbuJk2t1O+jKW4ikIf0URuaG7oOjOnyg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1620 Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org From: Yazen Ghannam Move code used to calculate the CS ID into a separate helper function. Drop redundant code comment about reading DF register. The "num_intlv_bits" variable is left uninitialized as it will be removed in a later patch. Signed-off-by: Yazen Ghannam --- arch/x86/kernel/cpu/mce/amd.c | 97 +++++++++++++++++------------------ 1 file changed, 48 insertions(+), 49 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index ba365901e39d..ae49cef4792f 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -892,12 +892,54 @@ static void make_space_for_cs_id(struct addr_ctx *ctx) } } -static int denormalize_addr(struct addr_ctx *ctx) +static int calculate_cs_id(struct addr_ctx *ctx) { + u8 die_id_shift, die_id_mask, socket_id_shift, socket_id_mask; + u8 die_id_bit, sock_id_bit, cs_fabric_id, cs_mask = 0; u32 tmp; - u8 die_id_shift, die_id_mask, socket_id_shift, socket_id_mask; - u8 num_intlv_bits, cs_mask = 0; + if (amd_df_indirect_read(ctx->nid, df_regs[FAB_BLK_INST_INFO_3], ctx->umc, &tmp)) + return -EINVAL; + + cs_fabric_id = (tmp >> 8) & 0xFF; + die_id_bit = 0; + + /* If interleaved over more than 1 channel: */ + if (ctx->intlv_num_chan) { + die_id_bit = ctx->intlv_num_chan; + cs_mask = (1 << die_id_bit) - 1; + ctx->cs_id = cs_fabric_id & cs_mask; + } + + sock_id_bit = die_id_bit; + + if (ctx->intlv_num_dies || ctx->intlv_num_sockets) + if (amd_df_indirect_read(ctx->nid, df_regs[SYS_FAB_ID_MASK], ctx->umc, &tmp)) + return -EINVAL; + + /* If interleaved over more than 1 die: */ + if (ctx->intlv_num_dies) { + sock_id_bit = die_id_bit + ctx->intlv_num_dies; + die_id_shift = (tmp >> 24) & 0xF; + die_id_mask = (tmp >> 8) & 0xFF; + + ctx->cs_id |= ((cs_fabric_id & die_id_mask) >> die_id_shift) << die_id_bit; + } + + /* If interleaved over more than 1 socket: */ + if (ctx->intlv_num_sockets) { + socket_id_shift = (tmp >> 28) & 0xF; + socket_id_mask = (tmp >> 16) & 0xFF; + + ctx->cs_id |= ((cs_fabric_id & socket_id_mask) >> socket_id_shift) << sock_id_bit; + } + + return 0; +} + +static int denormalize_addr(struct addr_ctx *ctx) +{ + u8 num_intlv_bits; /* Return early if no interleaving. */ if (ctx->intlv_mode == NONE) @@ -912,55 +954,12 @@ static int denormalize_addr(struct addr_ctx *ctx) make_space_for_cs_id(ctx); + if (calculate_cs_id(ctx)) + return -EINVAL; + if (num_intlv_bits > 0) { - u8 die_id_bit, sock_id_bit, cs_fabric_id; u64 temp_addr_i; - /* - * Read FabricBlockInstanceInformation3_CS[BlockFabricID]. - * This is the fabric id for this coherent slave. Use - * umc/channel# as instance id of the coherent slave - * for FICAA. - */ - if (amd_df_indirect_read(ctx->nid, df_regs[FAB_BLK_INST_INFO_3], ctx->umc, &tmp)) - return -EINVAL; - - cs_fabric_id = (tmp >> 8) & 0xFF; - die_id_bit = 0; - - /* If interleaved over more than 1 channel: */ - if (ctx->intlv_num_chan) { - die_id_bit = ctx->intlv_num_chan; - cs_mask = (1 << die_id_bit) - 1; - ctx->cs_id = cs_fabric_id & cs_mask; - } - - sock_id_bit = die_id_bit; - - if (ctx->intlv_num_dies || ctx->intlv_num_sockets) - if (amd_df_indirect_read(ctx->nid, df_regs[SYS_FAB_ID_MASK], - ctx->umc, &tmp)) - return -EINVAL; - - /* If interleaved over more than 1 die. */ - if (ctx->intlv_num_dies) { - sock_id_bit = die_id_bit + ctx->intlv_num_dies; - die_id_shift = (tmp >> 24) & 0xF; - die_id_mask = (tmp >> 8) & 0xFF; - - ctx->cs_id |= ((cs_fabric_id & die_id_mask) - >> die_id_shift) << die_id_bit; - } - - /* If interleaved over more than 1 socket. */ - if (ctx->intlv_num_sockets) { - socket_id_shift = (tmp >> 28) & 0xF; - socket_id_mask = (tmp >> 16) & 0xFF; - - ctx->cs_id |= ((cs_fabric_id & socket_id_mask) - >> socket_id_shift) << sock_id_bit; - } - /* * The pre-interleaved address consists of XXXXXXIIIYYYYY * where III is the ID for this CS, and XXXXXXYYYYY are the From patchwork Fri May 7 19:01:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 12245105 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD025C433ED for ; Fri, 7 May 2021 19:02:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A2C6A60725 for ; Fri, 7 May 2021 19:02:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229949AbhEGTD0 (ORCPT ); Fri, 7 May 2021 15:03:26 -0400 Received: from mail-co1nam11on2081.outbound.protection.outlook.com ([40.107.220.81]:18843 "EHLO NAM11-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229742AbhEGTDS (ORCPT ); Fri, 7 May 2021 15:03:18 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ndu723dX65CTFZJVMD+XG+8mJu1OGbyi++z2OPQU2tKRirIHqEB/7/YcFXNYomOeCor0STrG+0cFc2t9+h0O9M7Q0VfnaSMo7arN/3Oxf8CmacoKLUytZOXnCGXQUdU3DL0Ynxdq25E1tN+CQE85ELC997OvAn9O8jwhrY/JglWXqTmJ3LBX08JFOdJrBry8MPoj92dQEBCWOaUIyr+jnBqpTlDt1ylvziK9Elegb+cm4V76Y+pTtOWKwFMMbhfGrhT0+XZ/89xPPnccz+3PnCMPkLOd3qdlSscx1i9PRNzvB/Ui65fWBYVtBakaXX9ddNlczLEH03lE3tgEZhpajw== 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=03vlxunkdisypuKFtALxrxhOjQEl9+XwM6Xs4RGEE3M=; b=AiWrMUm2U8EpmzgR0rXILrBpr669NUoj7MEXLbxNMuQ4CQLqWWHWx0hQga16Yx/VMvMNrOP8hqIbeTWqbGCMZJmJ1kZ9B4r0lpaciEYbf7H8I3zdsaDeytAADq3hchbpsaChiVAaz+yFRxGw8VpPMSDkH1X7oD8IHplUeOP84q2ADapQOdnf/KbaadKgKK4ojjyt7yiUVM+dq2pieJGAktDnLe7JR5JYPfRl1iwn+h4hUB/2DcXHOV9tKIVd44KIa8a7uFfSx5+P7Kr7ZrsIdQ2nSMBANO6E/iupXBQN0URQBdJ7UBcuSEIWenDX8LiNrxv88OuaLYvFbw0c//JiVg== 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=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=03vlxunkdisypuKFtALxrxhOjQEl9+XwM6Xs4RGEE3M=; b=QDe0bY4OFF2NObrst55jA/r9+4wFFT0KERqbY8s+Il/1ir8PamzK9mfnITFQlfFwrbG+TarjF7vBuX/kj52m3swCEPy8SYgyz0DpGcO1p1YeioEUMHyG40BWOrL5ThiPvsz8SC7qq9hsHJq/49uVSBelozF8JEU5ouhvgptFHAc= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) by BN6PR12MB1748.namprd12.prod.outlook.com (2603:10b6:404:105::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.24; Fri, 7 May 2021 19:02:13 +0000 Received: from BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211]) by BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211%6]) with mapi id 15.20.4108.029; Fri, 7 May 2021 19:02:13 +0000 From: Yazen Ghannam To: linux-edac@vger.kernel.org Cc: Yazen Ghannam , linux-kernel@vger.kernel.org, tony.luck@intel.com, x86@kernel.org, Smita.KoralahalliChannabasappa@amd.com Subject: [PATCH 20/25] x86/MCE/AMD: Define function to insert CS ID into address Date: Fri, 7 May 2021 15:01:35 -0400 Message-Id: <20210507190140.18854-21-Yazen.Ghannam@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210507190140.18854-1-Yazen.Ghannam@amd.com> References: <20210507190140.18854-1-Yazen.Ghannam@amd.com> X-Originating-IP: [165.204.25.250] X-ClientProxiedBy: BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) To BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from aus-x-yghannam.amd.com (165.204.25.250) by BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.3 via Frontend Transport; Fri, 7 May 2021 19:02:12 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bc6b33fd-1ad9-419c-1937-08d9118a9fdb X-MS-TrafficTypeDiagnostic: BN6PR12MB1748: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yF8mN5Ph1yp8hYVl81t9T413O+7S8UngSNcBy87G+xwHsVLhbuQERQQR/Th3c8yFDZrt6q/p0wfd4BPs7r4G2Z4PVXu8wBAga25d6bS3sOHc8RhqICT7wBVS/ALheJdJBdiO7comZuGkqG1SMsL8bFwT2eEyUVeLv+OuGpK+ML8Ob19e2FTQadW509GK1JI8ARdJlF6JrNxJ0tJ8hy+xPBIt7ec+K/Qhba68QhOgoklkmE6a2b76yKNyAz2ph45dB5Toio3wM27XDAXzPcfxhDBs6rywGzazkBW4SPC9lBFTdd8Hun7N19Kh3/yIjoXtbjOstU19HDCENSpjjy0M7UrcAemGuNCKdgjpEKWno7iDogJltYI9IpwIbuyUferF7bm+jBo4t2VF5r4pUBk4fpY9gQMyg3Yzsd/ESzbjo32gpe5lmoo7tvl/gZn38w6muEO4PwQn1T0K5bcyqNaaQ/SJH+wjuJuv2nhKCg1giaZOMRnv42Exk7JQgHlr/lmX6zvtOoWXEYl1zx74aI6TtZQ8VMvsvrI3o2ZoV9fKcSLJyudkW0gZm0jIQk+AZq8J1IvEXzEzo37x3ln/Eleps7dIstNdXALP01/gfPM0u790uTGWIaKhFqCdF16o2Sv2xgEKsvPFlcDYsaAfWNLnOw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR12MB3108.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(136003)(39860400002)(396003)(366004)(376002)(346002)(1076003)(6486002)(186003)(38350700002)(38100700002)(2616005)(86362001)(36756003)(956004)(66476007)(66946007)(66556008)(8676002)(16526019)(8936002)(6916009)(83380400001)(26005)(4326008)(5660300002)(7696005)(6666004)(52116002)(478600001)(2906002)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 2cTK0n+8gv2DJXWp//2x2clpvBdP6Sgo+/mnvLnHFu0EgyR5nmqQ+OC/dh9GGamuN4ZAawTKiqMpXj5RPW7M+n/8EvxpjgXXdxCDgiQFSOBXtEj9Sc2Zhl/aVRJohvbzznOvxwRv4ooJ3nOZWgULTpG9gtwiIvGh1iG1VMikl9ye5mCXRi+/CLw9lzJETVeDuq49d0qLhD+lq9CSPJ8RenDD3IddtgIDV99l59b+VEM+Hewih+DIwvdWhIAd6ZLWaGGuWK6cv+Qb4SmEZZP0gBZPuaeY+kUs1YxcOxDVQGKFmKQTR4ixtVVvULT1UOE3hSQLZRHRZy/OJY7D7cFyrWW7Q+IkCPRGAVUvMUFHEqYzqkZPqg8SuPQLr23oCh12E3hvuRYrOcT8SM4x+icNy1wvLLTZ6ASOjevj0T76aBeZCCG0Dl718xtJKKAOcxWtVwqbNlrI6fsg5XZBvcSatuGuvD5Cx65wGURACnJwAwiPiEy2hqpn2EG0I/30aNc7zPkeohojlV0i4s1o/84LoGlDsKgRBy7kqCmzz/1ZJ3XTYMXyiHrYqeuTyXBP5n4jbX2pMnGhyflquM+eXO7htkVNkCqiDDRsRbm781ccKaqUKelXlcKTDrzrXj6JXRDfYNSodzS15J5KhcNCctbuyBPhLZegc981cAJ0c4Icmf615tkdBkH4dPIVou5dAHcUTCv07oI/YLS/qftWvVGg3icXblCDwmR7uEEwsetCGxoJfUBQ9AKLwKSeq8U7T4OEXO5vN881m+itips/v6Z0gv2L82z79KBi5HlFmkN8wYm/roz3oyQYVh9cqGiMhw45egnMSfcS6WfErc0SAOYNZeb4aEqcFVK5Eq564/yaeGKoFQ2Rn6IIJ5t4FUriPwTzD/z4sy53NPJ8WOOwbNNEYx7RKBeOEnqribvTonfp6ojlMIRu9JK+u5bzND0qUqkztgR9wMBFZxdjhhLk9RdffnNr8TVENgNIkkN0ltzRonRQmtK1FilIJVhTwks74hQpiG87kxKQasNYUOzxdkDBHscwLRRQYFNAe844BE2rG7IhxvgVpdyIzueHua1wzyzED5zX3bPntoXsyBUTZGRRS3HizcMrXGL0T/HGYgnQ0LgK3WAihLwzShyL2Vnbo4NeT4aEriS8ek2DUdX5S6uhOOPKQEd1rHl9AKNtzBLb0fG0LWsNhadWdmJLev8rx8InwfAZ+H8dBJHtxvWzN9BXTZzS3/I1AAg4KbADinnBGlEorR0VqX+DrhLT2Pybt/KCDhM0rB22a1sDmVBIPfuP1XeOx1mT4aGlRmzv0v9XSn5g0W5+Dc37MhWnbTRXQ5jY X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: bc6b33fd-1ad9-419c-1937-08d9118a9fdb X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3108.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2021 19:02:13.7559 (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: fHl7TQlELmUAqJRIQkNO/lY/SNlOiKeV0jHBQXZ1qRWknhgiHttV+Wp4PpHKc/T5EaUo/UqSXrqbNtcsFzY8ug== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1748 Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org From: Yazen Ghannam Move the code that inserts the CS ID into the address into a separate helper function. This will be expanded for future DF versions. Signed-off-by: Yazen Ghannam --- arch/x86/kernel/cpu/mce/amd.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index ae49cef4792f..b017e4613d8f 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -937,10 +937,13 @@ static int calculate_cs_id(struct addr_ctx *ctx) return 0; } -static int denormalize_addr(struct addr_ctx *ctx) +static void insert_cs_id(struct addr_ctx *ctx) { - u8 num_intlv_bits; + ctx->ret_addr |= (ctx->cs_id << ctx->intlv_addr_bit); +} +static int denormalize_addr(struct addr_ctx *ctx) +{ /* Return early if no interleaving. */ if (ctx->intlv_mode == NONE) return 0; @@ -957,20 +960,7 @@ static int denormalize_addr(struct addr_ctx *ctx) if (calculate_cs_id(ctx)) return -EINVAL; - if (num_intlv_bits > 0) { - u64 temp_addr_i; - - /* - * The pre-interleaved address consists of XXXXXXIIIYYYYY - * where III is the ID for this CS, and XXXXXXYYYYY are the - * address bits from the post-interleaved address. - * "num_intlv_bits" has been calculated to tell us how many "I" - * bits there are. "intlv_addr_bit" tells us how many "Y" bits - * there are (where "I" starts). - */ - temp_addr_i = (ctx->cs_id << ctx->intlv_addr_bit); - ctx->ret_addr |= temp_addr_i; - } + insert_cs_id(ctx); return 0; } From patchwork Fri May 7 19:01:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 12245119 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BBD6DC433ED for ; Fri, 7 May 2021 19:03:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9DA946128B for ; Fri, 7 May 2021 19:03:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229870AbhEGTE0 (ORCPT ); Fri, 7 May 2021 15:04:26 -0400 Received: from mail-dm6nam12on2089.outbound.protection.outlook.com ([40.107.243.89]:47105 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229974AbhEGTEG (ORCPT ); Fri, 7 May 2021 15:04:06 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OcfDV6awkmkMe3riGabMbD0rVRRCJUoPFJZSiORL13AydkTPxDTWUgRHP/LGFKjmNucqfDzmHsu+QSwrIbF3AWd81p1ueW2poAWgbc//GTsmZ8nswsgAaYEjbg0MGpjoMzHO5AY+1KOw0cUHSQImDm8+XSQU5be9+bpuFeIBela0afFjEsg5iSwHjA8uhGRp7Ut1HLfTRUoud6WlZcPunL/3eIwO4bxs2Ap4sP/P1fRJP22BKkWVseyhQ/acn/IwyMgtT19TgeiupymFApVJhf+/oDnyQCXqrnbdSv6/s7gZO0CihfxgngARXFTJBisbbWifDxOTnm+i3PLijiXjFg== 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=MTr+MFu4VJMH4jAq6oc8vtkeBcqpi41NHAu5uHEtAXc=; b=XREXP1MZRHEcG3igM/PkeGzI0Mkp5a3aOS0Y1ysVYqvemmRrWcM8fDwAVHIoLZRXWOzyXehNePgzxT6uw1E52uQH2Iob3bTpo7OJzHd35DCmLiLxf/VHSE8gwB8s3XvHmT5Q41W5wtzD0DmRFhZBs9TVPvfVSPx0yhsayyS/Ex4t9UiSEbGpckx9m3Wyi1MUrfC2cZNNq+FuwfFZhb0h72M8UCRaL0L4GdK0fqn4QzkfhVGwnGOt1f+Z1VM3A7+6GqsaTI0EyZpBcJGcfLg6FmIEo5eNonXCyqu9GMWaCfXriczzBy9PeZoGO+EosjlYqvfhfB1nJAQnqjTJC0wRqw== 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=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MTr+MFu4VJMH4jAq6oc8vtkeBcqpi41NHAu5uHEtAXc=; b=bXoySGhV0ZrEQms4VRvrZQ/v39TXU+eKSLfiRswdS2i+cDnFSi23gewxhsiLYI1dh4/F8yd2nsSs6lh3hH/yXEhOLjskU4hFQXLGgctOMTacPGaql0Zuz8OCpys0WtWrZ+ljGEinfXwjtftuKgTq4XFyQ+55oO/QC7c3cu6M2Wk= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) by BN6PR12MB1620.namprd12.prod.outlook.com (2603:10b6:405:10::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.26; Fri, 7 May 2021 19:02:14 +0000 Received: from BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211]) by BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211%6]) with mapi id 15.20.4108.029; Fri, 7 May 2021 19:02:14 +0000 From: Yazen Ghannam To: linux-edac@vger.kernel.org Cc: Yazen Ghannam , linux-kernel@vger.kernel.org, tony.luck@intel.com, x86@kernel.org, Smita.KoralahalliChannabasappa@amd.com Subject: [PATCH 21/25] x86/MCE/AMD: Define function to get CS Fabric ID Date: Fri, 7 May 2021 15:01:36 -0400 Message-Id: <20210507190140.18854-22-Yazen.Ghannam@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210507190140.18854-1-Yazen.Ghannam@amd.com> References: <20210507190140.18854-1-Yazen.Ghannam@amd.com> X-Originating-IP: [165.204.25.250] X-ClientProxiedBy: BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) To BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from aus-x-yghannam.amd.com (165.204.25.250) by BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.3 via Frontend Transport; Fri, 7 May 2021 19:02:14 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1a6bff6b-52f8-46e8-c680-08d9118aa093 X-MS-TrafficTypeDiagnostic: BN6PR12MB1620: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dqNp8UhEj3ASkU6nvYxWOc6LBfVvxZA+9lepGi/JqUFRd7n7Y/eQOHjEDIRCUER04+Lv7x6GovdIjM7qZDaeB7nPRhFH8awMDTZGJCmcB09GkUVJhBkz7UO6Pnx2TbbkFIlwCD0/rDNd2onnQnB5COYQ376AyhMGWyJc98cyaBg9uHOnYufJjnQrRBBeWgd1Y0ctqyuwucbi/btkfDkrRyIJc3dmpkgnW0+vG6zF9RbwFmz2yKBFuRusiF7pcgqtPHJpYavcMvIupT0NTzqa4lNT0QqcSshaO4AkNWuxD+pDXoCarQfjeDR5qQNGWCKafnQLZC8S2dODNH+HwP6xTyzRAJ67oL7ePpxnzaxg5g86ahn6h7dTmxM4OV0/6X3S4Y7fcAG8MIN6L2N3UYGzbLyhlzCnLS8MBc7681K01txM8OE5abKlKNfgQKEfGWLoxo8k4wCA5Gv+apqRsBhQ2eVoJGvnuxoyY3IwL5GeOUB2KHaj3fk1WygiTZSHJsiVBxcT3fKEZgXch/IrFsOTOPHKEY9wnzdYaLGcoKXODXhYbl/rvy0sAytcfuLisQA6OUy2tfag0fTZZrOVo6E+rqfyjBQR4tbdgaF+bErpKFdeOQ+8TKjBHn9GmzjqEbg8NxNhr+mc8ndR0o/OXuvcKg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR12MB3108.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(376002)(136003)(366004)(39860400002)(346002)(4326008)(6666004)(38350700002)(38100700002)(66556008)(2906002)(26005)(6486002)(66476007)(1076003)(16526019)(86362001)(6916009)(66946007)(2616005)(956004)(186003)(5660300002)(36756003)(478600001)(316002)(52116002)(7696005)(8676002)(83380400001)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 1OjUBzZPuAObOMW48ImYqk9tvHF4je+ur7ID0C1CJuIUCzr8D44E7SWnd3HU3MfBy6BIaYT+W46MjlEI3id3QbLXANtBnKbxu6Nzd5ACHKcYrDuUuZU5bfDxKJqjT0QqZB1EGxGdWEkPWFzYr5R+OJt7mBsbHydgNdFS/3V4QK/UAArLW4np1CrY7p2XgPYfkoREWJOudnWo/7NZztYhO/a9IqnBiUeLnyoKkG95cZQBJuCSxHueOit3PSh7VYv81oCUlmlCxSYW0VR69DxADxTmCjNMWMYDZWGcb1eCrrE6Z0HnKzjXgnFKHElS5B+29bss4+feMVf9mBYp7gA5SPk5bpkttS/ntTsfkoXQ/AIoT7p8DGyzSayz53/iVxxXHLWkDVJfnvmvFZLYCbOkb9Di7y1lwp6SK1qUd7l7FM8YNQCi6ql9xaNP7DC/taglKytHFNGPTS92b3IPVVDkgnGZm+157xt5n+hMegnvMIHRFqO5ABhBuT5y+CEoOW40XFZmEXKAEDOpzRCa1hrYqdNaiSl4s0bj7yDCk0NAFJ9uTONdBngcMT4Ju+kdefqxDTL9hEAmqU/iocHA+ieFFJPKhigQ0r4iZI06PmZ1zUHYEGI8o4gUJU2xI2g6EKgV0cT6VDrCy8O/HaGFmZeFW86we2ny5oc1zaLVcs281YKhvfV5FxgF0+y2rVHkyUbbbDBBU7KHjEJF6lhJ5vFcyQ95MKZf/6djNLlnXieKtK31GGSKELnF6RoZ7M3DVzPjf5kaRrgMA7a79pp49g/1sg1Jhtq7DGSNT5pTEbENmdVCMPhuaVnG66trb1b8OVP8DXfj1TCmTQtzHiBfqSD3biiw0y7A1VxsvxrXjRiOjiz3x0RmzwY6luKiRwoUZZmW7+T3lYFsM2fbJ4gDdxYL2Ifo4OR9iWFP2MObiM29Oqeeb3QQ+TSPufKm+nWUznOe2Kv+pPKTTn3bvs8Tl4bJgIX7Sz5XZ/lO7+3qIH4hEnfF0VqMS7le7JhfDQb/yXkSRw7mDp37xsfNQQX0EnuQecLJ4h+6puh6tz8C+4UdNJPRt6eM+cWLSeR+x0dqitKRzOuc/Dba6MiGcEicxm0c3oPMjLuVUfSLhhOFWcT9aLgRQQlKsJwIslNy+IZIVkVAB8ZdDVknPhWzHl7EKEv7jXd4FnyN1J9anWOCgaPrd1G6Z9TNEZC9eWAVwtBPq+zX+MdAgtO5FObwJl5YoHO6bzK5d3HLASrlyggiyFQwXHWXpJOjnmJ1J6YD4zLCIjzsLjBc7x/ElpKSTykhHHCsb9YkK8IgxXgi5j5xUzCmlMNVWyER8eTTScp+UlabdEUz X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1a6bff6b-52f8-46e8-c680-08d9118aa093 X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3108.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2021 19:02:14.9292 (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: JdPCpOlR8RPKOvSV5WrHAVGbKiJ5lfew+Gbj42lcbVwHgHzXa5ou7YcHSzM8DJmI+jFJdhwGNJQ/eY5jl0aqww== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1620 Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org From: Yazen Ghannam Move code that gets the CS Fabric ID into a separate helper function. This will be expanded for future DF versions. Signed-off-by: Yazen Ghannam --- arch/x86/kernel/cpu/mce/amd.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index b017e4613d8f..6980c5c62f49 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -733,6 +733,7 @@ struct addr_ctx { u8 intlv_num_dies; u8 intlv_num_sockets; u8 cs_id; + u8 cs_fabric_id; bool hash_enabled; }; @@ -892,23 +893,34 @@ static void make_space_for_cs_id(struct addr_ctx *ctx) } } +static int get_cs_fabric_id(struct addr_ctx *ctx) +{ + u32 tmp; + + if (amd_df_indirect_read(ctx->nid, df_regs[FAB_BLK_INST_INFO_3], ctx->umc, &tmp)) + return -EINVAL; + + ctx->cs_fabric_id = (tmp >> 8) & 0xFF; + + return 0; +} + static int calculate_cs_id(struct addr_ctx *ctx) { u8 die_id_shift, die_id_mask, socket_id_shift, socket_id_mask; - u8 die_id_bit, sock_id_bit, cs_fabric_id, cs_mask = 0; + u8 die_id_bit, sock_id_bit, cs_mask = 0; u32 tmp; - if (amd_df_indirect_read(ctx->nid, df_regs[FAB_BLK_INST_INFO_3], ctx->umc, &tmp)) + if (get_cs_fabric_id(ctx)) return -EINVAL; - cs_fabric_id = (tmp >> 8) & 0xFF; die_id_bit = 0; /* If interleaved over more than 1 channel: */ if (ctx->intlv_num_chan) { die_id_bit = ctx->intlv_num_chan; cs_mask = (1 << die_id_bit) - 1; - ctx->cs_id = cs_fabric_id & cs_mask; + ctx->cs_id = ctx->cs_fabric_id & cs_mask; } sock_id_bit = die_id_bit; @@ -923,7 +935,7 @@ static int calculate_cs_id(struct addr_ctx *ctx) die_id_shift = (tmp >> 24) & 0xF; die_id_mask = (tmp >> 8) & 0xFF; - ctx->cs_id |= ((cs_fabric_id & die_id_mask) >> die_id_shift) << die_id_bit; + ctx->cs_id |= ((ctx->cs_fabric_id & die_id_mask) >> die_id_shift) << die_id_bit; } /* If interleaved over more than 1 socket: */ @@ -931,7 +943,8 @@ static int calculate_cs_id(struct addr_ctx *ctx) socket_id_shift = (tmp >> 28) & 0xF; socket_id_mask = (tmp >> 16) & 0xFF; - ctx->cs_id |= ((cs_fabric_id & socket_id_mask) >> socket_id_shift) << sock_id_bit; + ctx->cs_id |= ((ctx->cs_fabric_id & socket_id_mask) + >> socket_id_shift) << sock_id_bit; } return 0; From patchwork Fri May 7 19:01:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 12245121 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8578DC433B4 for ; Fri, 7 May 2021 19:03:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4B98860232 for ; Fri, 7 May 2021 19:03:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229780AbhEGTEn (ORCPT ); Fri, 7 May 2021 15:04:43 -0400 Received: from mail-eopbgr770081.outbound.protection.outlook.com ([40.107.77.81]:44439 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229670AbhEGTEZ (ORCPT ); Fri, 7 May 2021 15:04:25 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Mc+/jHYP/zRUJXX20YTI8xzauaTwAjaJq0jS347PZGzmTszU03rqIPGy1Mv+UEsTRcF+HGqpDdZnPpYbaelsRe/eiknQYBXncx6IU2vn1JhKb1jF5hWGDYSdiFMIjfcs/C3YY7yIZV9zN2rAz4rdF9YadiHljOeegx+Unfqeo+kPLXc4xPy1V7GD5Ig9M1FT87PY8rDPE9wXZqhtPmVh71Q9a7xFUg8b+nJ1yJ3nEcsl80QqeopWAzsMgJvYmKjgQgogX/RUc/n+C3KD7islrf0kkUCgLtT0pnRznHJtxhek4a6qGFVwKuT0Rw9SwKYxJEguow5Qt8ZykiSJTcFLkQ== 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=tV3PNOoTlKkA+rjwbCXyznFMWc4esXOeA69SQUo1Ht4=; b=GGVkIEIQe8OLr1+oy/5uYWNk6KaGcNFuwn69nhhQBYdX1nn8cvKyOsGY0LT/ZloM7wLA9/lr2vb38/GxqUbfHvkLOJkiqZfN6kqMiVMktlnz3jBPTvvKK5od9WUHMwHJLiMkjvhOsGyKP5VrnNuhzkeXxAIc9K6tCN9sN0bG3/QAGYWFqCw0DntZu8huFIro/E61vGFA7eJoHXMkjKdFg3EuW8AXoL1LiW0CWKpSVhv4c+FyuPUXUbQlbYNXJ9Iw4jqXtbzKi/mKiqlAGYzsDKXFgu0LKO7eis+7yk+dyKpDs4ghcrtIE709dyLAZNryg0JMtDP9Op6NWbv/iyVAgA== 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=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tV3PNOoTlKkA+rjwbCXyznFMWc4esXOeA69SQUo1Ht4=; b=2eTSBZvXsoXXgkg0c+4BZEOBX4sG/dF9nEDQHmYMUKvZ981LOMLfJ/UucQj8vTAJL2QWAA2IF/LL+pVWSs1e8s3chdQ+TR7sfeVIvJBaie6lSXLdTTrSth9QnvPVSH46a8oBLc9tCvZ3oyvqMJtcOfZ5keThVqjvY7nb61+Y8sk= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) by BN6PR12MB1620.namprd12.prod.outlook.com (2603:10b6:405:10::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.26; Fri, 7 May 2021 19:02:16 +0000 Received: from BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211]) by BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211%6]) with mapi id 15.20.4108.029; Fri, 7 May 2021 19:02:16 +0000 From: Yazen Ghannam To: linux-edac@vger.kernel.org Cc: Yazen Ghannam , linux-kernel@vger.kernel.org, tony.luck@intel.com, x86@kernel.org, Smita.KoralahalliChannabasappa@amd.com Subject: [PATCH 22/25] x86/MCE/AMD: Define function to find shift and mask values Date: Fri, 7 May 2021 15:01:37 -0400 Message-Id: <20210507190140.18854-23-Yazen.Ghannam@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210507190140.18854-1-Yazen.Ghannam@amd.com> References: <20210507190140.18854-1-Yazen.Ghannam@amd.com> X-Originating-IP: [165.204.25.250] X-ClientProxiedBy: BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) To BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from aus-x-yghannam.amd.com (165.204.25.250) by BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.3 via Frontend Transport; Fri, 7 May 2021 19:02:15 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 616b161e-84d5-43ab-cd82-08d9118aa161 X-MS-TrafficTypeDiagnostic: BN6PR12MB1620: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4941; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PRBI+7fnrJhBlMHRIcDUUy6HE2mAxOrQ5gWVvQoczxpimpV+jh13ak3tyDfJQbQBpOupoyVnCl0DBIswXwaV0xdUpCnvoxxVi28QITJ/ceo0hllGBzZKnWakQwh80y5yEMBqVNj+nbsxsV1s0grhHfjvNOgQogVJ4qam2DcYDOZQjE5/ceQDv4D5v8fPXY4WGAzYJIePggLfHMbz1sKC0HMz0bsypaggUbEditll5r4TXRQM8WoOab6R+EtxQDbyjzXdCeOheT7FHLDx5eDZVKUx3j1ToJ5NSerAn9JPsBzbHE1C4509VheWIT84+FOg5Ppum6jES7/dDQMEaQd2pYZGDGpnaVZpTAgA1MjcnGSt53F/TqWeRwoj+MFzsB2P15P43K7iIZUeMkyFq7WwsiTWFsRpDeWHcnIaLpBfm1sVHlx2ApsSXB8fQRDw1CW2EFFSnVdfefHTLsC0mzsH7ta3/r1mgkvE/C3chqQ/HG+1n1FIQTiNLUMNIwyOIXg1FK8siGi6V04UQbYusPGtmpMPUXD1CBe506T3NYaLsOUCQjFwqpVJyVwUGItPrn1XLl1ajMqfZV4Z2eA3Cd/U4QXAp53OhoeyjCL4byA3GhEF4f4Q2nEGqrw7GQkr8dr4Z65Vq4UZcWAnVmDbHETdCANs4Ujg568fKdAzxqKmC0VFzMSgJt2mxsFtEefWg6ww X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR12MB3108.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(376002)(136003)(366004)(39860400002)(346002)(4326008)(6666004)(38350700002)(38100700002)(66556008)(2906002)(26005)(6486002)(66476007)(1076003)(16526019)(86362001)(6916009)(66946007)(2616005)(956004)(186003)(5660300002)(36756003)(478600001)(316002)(52116002)(7696005)(8676002)(83380400001)(8936002)(37363001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: R3Ozrm4lNYUAM/Q+g/3uuUmHA66Lh/4umQbfsyiDN7YhgzZgrwEuvn91ZjBKjBfdJqkgmA4rEMWgtn6Ef2JzHQQ0V7LbN/Z3xFYiLZXjRPwZSVUuJiUb35/8+dZvi23AR9xVgvxyWPP7lyzuo1Z+NloIntb96Gh48w6ajBov7ogRiFsxR/CXk3y54xfyfVTtS2nJmCWHi2xFmRVBpKQ5jKxE3dZ4RyX/WUZGh5w/DJSEFmv5mJvXVV+1h6g9cU5KfwLxaMT4BmjwQOb+VoPgHGen6EgSR9Znc/3/ytnY4fwqtZlkhx+4pTDlW0Y4NIeUrMyBcR5wTfGlJ3wtws6xu7QXMSASE4Xt+RR8lF7iK/I5A1EuE1/2v52tO3cpismRh9ZCL6EEe1dclnv8oXDXm/iuwBu6f38ceGEnLcpaRfqjxBhH86P/4ixRQbqUilsCOXZRiRukSUpqMBTaOIOnfu0uGRn0nSM1rai8YDE5jZ0m6MBSdB/6zzFh6w39vveROhKH1apjYAne1c9OMIRPZPgYfInrGiSXznK9wDno3QJctridhxDv4gShHe8+xV8bU55WGcAc8EojwgwMhk6Bq28f5uCSH1iQphSPL6nKiKn7HHZxPZ6QragZRzctA2LIEOqwtw+urjDWYjomafeyrEBPW7jPuIxTwQNP4vBREPhsv9ZLdRA5Q2DOa7CsA46Zr1d44QfgDsKOywO4vyX6ktGIdCfX3PKAjRku394CdX57j66WfEZ74ohJswzEDBqv40YbwTJikJzPN+WjCDJ37CLbbrB+tR5gsVct7kTjswZ69mzOI1/1KuHKnC2kFCjZ2iUohzMxKA1vWbWEvRxkN6GPe9x/zOkz4yxWN4pAET7ZDpHhlhr0TeGFBB/KJAc0pMX19knWZNOLDgWsPk1XBAOrJ8MjHsaGQ6l2S2GrljmkDJsc1NQJrx+0zlPGEDIsExdMH0rZkN37N2ujkXLpVP5ievjqfzrG5C4IZ9OT8hBjlq9hPNDybXYI7ORiawxMF7BeBOis346OpIO0WAXxJtoJdQQQhc/2c/8PdfCYlfNvtzOJiJWQcBz6o9zNYCxw3VBkU8DbDr69TMolarIg4jHjXpd8BbnKgrQJSiiYTxKdm3GeimTBmlLhq8dWkhElUhmEtOLcpc83rGmleclKZxLfoVy6jrCzO8WGUSloH6sLay7/Mt0Ey1/F0n6ufZ4DwL/HM2HuTniG5Gxc11bVMs/HlqF82XxV8LgS2sPmmQyux9FiUtssuQeH/v4D2p6d+Rb3GI880qqoBAbHy8pxuw2Lhs/vCd1iauRnEI3I63IltUdOvWFMdF/57be7nk8D X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 616b161e-84d5-43ab-cd82-08d9118aa161 X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3108.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2021 19:02:16.2564 (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: tXyBJQGAsDRwzIdZ4ttdVxxqy3XDub3BBmiPAJ5lWnZOkyakJOHGBuB2s/6wbwubFnFWP298zdbOWO7AzzqOjw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1620 Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org From: Yazen Ghannam Move code to find the shift and mask values used in die and socket interleaving into separate helper functions. These will be expanded for future DF versions. Also, move reading of the System Fabric ID Mask register into a helper function and call this early. This will be expanded for future DF versions and will be used to determine DF version levels. Signed-off-by: Yazen Ghannam --- arch/x86/kernel/cpu/mce/amd.c | 56 +++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 13 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index 6980c5c62f49..01931f98c6d9 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -725,6 +725,7 @@ struct addr_ctx { u32 reg_dram_offset; u32 reg_base_addr; u32 reg_limit_addr; + u32 reg_fab_id_mask0; u16 nid; u8 umc; u8 map_num; @@ -734,6 +735,8 @@ struct addr_ctx { u8 intlv_num_sockets; u8 cs_id; u8 cs_fabric_id; + u8 die_id_mask; + u8 socket_id_mask; bool hash_enabled; }; @@ -905,15 +908,31 @@ static int get_cs_fabric_id(struct addr_ctx *ctx) return 0; } +static void get_masks(struct addr_ctx *ctx) +{ + ctx->die_id_mask = (ctx->reg_fab_id_mask0 >> 8) & 0xFF; + ctx->socket_id_mask = (ctx->reg_fab_id_mask0 >> 16) & 0xFF; +} + +static u8 get_die_id_shift(struct addr_ctx *ctx) +{ + return (ctx->reg_fab_id_mask0 >> 24) & 0xF; +} + +static u8 get_socket_id_shift(struct addr_ctx *ctx) +{ + return (ctx->reg_fab_id_mask0 >> 28) & 0xF; +} + static int calculate_cs_id(struct addr_ctx *ctx) { - u8 die_id_shift, die_id_mask, socket_id_shift, socket_id_mask; u8 die_id_bit, sock_id_bit, cs_mask = 0; - u32 tmp; if (get_cs_fabric_id(ctx)) return -EINVAL; + get_masks(ctx); + die_id_bit = 0; /* If interleaved over more than 1 channel: */ @@ -923,27 +942,26 @@ static int calculate_cs_id(struct addr_ctx *ctx) ctx->cs_id = ctx->cs_fabric_id & cs_mask; } - sock_id_bit = die_id_bit; + /* Return early if no die interleaving and no socket interleaving. */ + if (!(ctx->intlv_num_dies || ctx->intlv_num_sockets)) + return 0; - if (ctx->intlv_num_dies || ctx->intlv_num_sockets) - if (amd_df_indirect_read(ctx->nid, df_regs[SYS_FAB_ID_MASK], ctx->umc, &tmp)) - return -EINVAL; + sock_id_bit = die_id_bit; /* If interleaved over more than 1 die: */ if (ctx->intlv_num_dies) { - sock_id_bit = die_id_bit + ctx->intlv_num_dies; - die_id_shift = (tmp >> 24) & 0xF; - die_id_mask = (tmp >> 8) & 0xFF; + u8 die_id_shift = get_die_id_shift(ctx); - ctx->cs_id |= ((ctx->cs_fabric_id & die_id_mask) >> die_id_shift) << die_id_bit; + sock_id_bit = die_id_bit + ctx->intlv_num_dies; + ctx->cs_id |= ((ctx->cs_fabric_id & ctx->die_id_mask) + >> die_id_shift) << die_id_bit; } /* If interleaved over more than 1 socket: */ if (ctx->intlv_num_sockets) { - socket_id_shift = (tmp >> 28) & 0xF; - socket_id_mask = (tmp >> 16) & 0xFF; + u8 socket_id_shift = get_socket_id_shift(ctx); - ctx->cs_id |= ((ctx->cs_fabric_id & socket_id_mask) + ctx->cs_id |= ((ctx->cs_fabric_id & ctx->socket_id_mask) >> socket_id_shift) << sock_id_bit; } @@ -1037,6 +1055,15 @@ static int addr_over_limit(struct addr_ctx *ctx) return 0; } +static int get_fabric_id_mask_reg(struct addr_ctx *ctx) +{ + if (amd_df_indirect_read(ctx->nid, df_regs[SYS_FAB_ID_MASK], + ctx->umc, &ctx->reg_fab_id_mask0)) + return -EINVAL; + + return 0; +} + int umc_normaddr_to_sysaddr(u64 *addr, u16 nid, u8 umc) { struct addr_ctx ctx; @@ -1049,6 +1076,9 @@ int umc_normaddr_to_sysaddr(u64 *addr, u16 nid, u8 umc) ctx.nid = nid; ctx.umc = umc; + if (get_fabric_id_mask_reg(&ctx)) + return -EINVAL; + ctx.df_type = get_df_type(&ctx); if (remove_dram_offset(&ctx)) From patchwork Fri May 7 19:01:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 12245123 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1754BC43460 for ; Fri, 7 May 2021 19:03:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DC7696054E for ; Fri, 7 May 2021 19:03:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229756AbhEGTEn (ORCPT ); Fri, 7 May 2021 15:04:43 -0400 Received: from mail-dm6nam12on2089.outbound.protection.outlook.com ([40.107.243.89]:47105 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229849AbhEGTE0 (ORCPT ); Fri, 7 May 2021 15:04:26 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XJnpN1FFjSqhU1ngl/4Fp2TYoRhHKsEW11PqyBmDGLfEIK0OHz/mR8vuWry7IzUqV4JUFrNpm7vKrqqPn2BfE6YdsTaBtJ6iLYRZWIsLJhe2So9rgzmqWAHSh8jtq3JM4cnE9lmOIQNu1NBzja+v7kMksGdW+Mw3n31YdMt+dYl2qsbLBP0xutU26kLBENg4vpNiMIl88kk2P88v4Pi70kmur+cZDhx/XZ2C8pxCkdG9+YKdRMv1oCHeJyDjpH9I60x/YJVonHxhSR0k9Z/Arr+sBMjdBBtW58JI70YdMGoR0BRIKssOLvKph2R5js9ARiX1OI5alhdpj7Bf4aJcsw== 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=1SUbsP7o2wseT1VUxSla838EqAdslD/W+UlDB1HZ3tw=; b=YH6AMGOTvp4Kc6riXnKUEU8K6IYlLOyftBotEeGL50tcx79W/ab/9/yA8HEcXGImuNuwaPN0E0X3mnHU4GXXOgT2gb/suPr8qq1TNs0WmEj4HglKBHCI6Yci2yIxCwV9iuXq1Jrst6vn4P9TiYJTEmaTW7Ae1fdomh2D7mHSi87e5tpSyaRv7lg5iXyEnhreKFJ6gIv8tQglU2rrFMZlHXcOMdScUjnSdK8A0Z3G7+IMZ/bz1HZCslG7tLbPMvYMtrzL6V//g+VT6b6tjnAxX1hC3X1vMMiEJOQpJJIM356wa9JuJJVI//MAlZ7zwXeur871fuMl8nj+zay7QknpBw== 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=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1SUbsP7o2wseT1VUxSla838EqAdslD/W+UlDB1HZ3tw=; b=OmQDEtxzh8BZlnJAJ57TeaVGaxxqwVJ0D0sY0Rtg49NRfYMwfoJ0G8/i1dq/s4StMQfDfrCcHC7bJV796UfA3aWS/GSNuUCUI0qtuitvR9tG+IHdjU60BX/7lrilgdFkd/SAATTTF8Mmb45zvVC5MWlDxGNbdMfOVP4lbfofRnM= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) by BN6PR12MB1620.namprd12.prod.outlook.com (2603:10b6:405:10::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.26; Fri, 7 May 2021 19:02:17 +0000 Received: from BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211]) by BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211%6]) with mapi id 15.20.4108.029; Fri, 7 May 2021 19:02:17 +0000 From: Yazen Ghannam To: linux-edac@vger.kernel.org Cc: Yazen Ghannam , linux-kernel@vger.kernel.org, tony.luck@intel.com, x86@kernel.org, Smita.KoralahalliChannabasappa@amd.com Subject: [PATCH 23/25] x86/MCE/AMD: Update CS ID calculation to match reference code Date: Fri, 7 May 2021 15:01:38 -0400 Message-Id: <20210507190140.18854-24-Yazen.Ghannam@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210507190140.18854-1-Yazen.Ghannam@amd.com> References: <20210507190140.18854-1-Yazen.Ghannam@amd.com> X-Originating-IP: [165.204.25.250] X-ClientProxiedBy: BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) To BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from aus-x-yghannam.amd.com (165.204.25.250) by BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.3 via Frontend Transport; Fri, 7 May 2021 19:02:16 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 50b3d0f7-1bab-4d51-73e0-08d9118aa203 X-MS-TrafficTypeDiagnostic: BN6PR12MB1620: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6qorhvsTH+buX0JLuFI9AzWGiOrrPh1yeXPuCObST9jEO1KQPShHleH+nF6MstnqwFiWIl6p93kMr2qb4OAIMFDlo40n1r6Sd5ycsNPWKmYFnT2mL11a4YpcGUzeSqHvVFfs1odHar7ngXeGZp1WLbU6zbJBv17XmsUYpkgNJx/wiWGb+aPu5u6e6VjpBrm1kUaoCStMe5JrlyG89XeU62xdOLyUDxn99W3Da6Jswkf0B8p1LU9i/C1x3R1sMxSXj7irkdJnV5nWL2s1VJ1Eu9TAwncMX003iELXFIBzTmSVUnGlzCe+xnwp1ZgH0mTVKHEWMQoI6tcNiOTW2d7eSKvNg9bhV0eni9WZPb7vSMuDaVJhyrAo3bRBbEclo6JqXe0tNA2K23lbxvrQPG36VHiY3vZVemQWnObpqr3tU20e/EnG4lzNtt/A8d1eTEIyY5kmlvR4naA8XoAxE6r+FAWqMocBgBwq16K1GrovPl/iQf8YTFJufBIjL9EqC+Ke/5AliY2334IbOKYd5EiUPEdVq6cE9WF56xEMnQqod+d+VWmgXUZ7UTHxYoJwp2fuIMv4q8SGwhsjJMsMIDqt8vXQCw6nCZ+Rdqgpap2FIr47f4eWCwCQ68f6aBPHTZO4nENjabo+BvFKDwi0BcDjINTqK71e/2NGBxhonPUkXJg= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR12MB3108.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(376002)(136003)(366004)(39860400002)(346002)(4326008)(6666004)(38350700002)(38100700002)(66556008)(2906002)(26005)(6486002)(66476007)(1076003)(16526019)(86362001)(6916009)(66946007)(2616005)(956004)(186003)(5660300002)(36756003)(478600001)(316002)(52116002)(7696005)(8676002)(83380400001)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: VhMojpdyTxIP8hJ1gX8l0wnfy0rtHDs/KhFkOjNBYcrhMpDVpSJplXiwImW17TfGNuhQjSpq3oEIXkl0WlzcTkqOMDzMpadXoPlpgjeoscoFy/s22wf311xeDfsBiZYRUFsQMNGeL3XV47VdPKssIAjQfGTR74yAB87ES97HurWXPoc6cgyuAG/9y7yeFJUn8pyweb3EcJyl8i2O5LItr+VIMBzCHdtHOpMv7U4ShgWnm/mK0OmV7K5D6qeV7NkuaMRkIpKJ98tgwXQC5RPhzPe6fGsC4zZdkqtBAEcP5v325Hv4d5ked8Z1MPzvO4Sj47c0ZYwsTdHOlH4QtFreHi22p9qaIPpDdoUKWyjBnXgO+sgxXILG1RajcEj4em5nqDVIvHlQQiJdsTcDJCGObOgtUCVq8v93l8znP+35q+fi3n1Cj7sQ/e6pawpLrOnt8CAP927Xd4Z1JqzXtfgscr92HcgDiA5zr78GKMAJh39mfdt2HXWNCNkLdXD4Aeh6wzcGhoqAU21nVlvbDOQVkj7PbPxT8y4IlpOLu/mHnUV66oMAdiE56rQG1N7406clqU0sMr3tlq1e6n38i9x8/0phVBOrOeWo5LnScsF3FYuEjesnaqdb6uVAppSyZBWCyQ0nUZD9+PdjAYRO1u8SnTfXhjA9mThoXjr8wM6gHW3rpfV6cb+PsEQDi2FrjC1TA/mUEtBfSV9j3z9D6baz32PrM7hSy22pgXylSXkMw7DbyRLixK9MmUFcd85L0/w5IrWbLwiMvcls15hWLp641DdyaVkEe2kTlqJy/jd6nKn5VxI8cjPKBhbv63hMWibvz+PGz/rYWGL0hn4g3zs/fyJhQ0ZvK7+boGFYO0l5tCaGujAA1qTKHlJHVH+qrH9guA5H5xRAYXCh8PDV93GyqycS07hTkSA0Q+Y112pEt6E/sYE5ynWFjstqzSIIiwCh/DjEnwFOvHfPJhAQYwXbw/+2khsr1DYtXCqMUaHfzshgEqg4f3zdVU0rVH5n1OcE6dJsCiQxOr0Pzt9TT8ydtIowfUC8ghuWxi/TyTyoVnNBCkp6HO8DRaWnpFZkb3nZnFEfzksr7zEQidgUtx6NbustYy83c8CCCt83lk/HTYzUcICxmHraINGY1lInwlLTP7TMYZgoZV1CRC2XhOBpwgmpoD0JLNZLwzr0KIQVCUIB456vww41p7GuD7/VIaXA40nkqdtuU7O2Y0Rhj2gY3EuacwG+epToMGsRPJKtiS+uA1TNCq29veKk3pZEJMOWQgtxo5cVEKB72he08Z+mujI/Fql+SUiBMBqkiC/6u4ePrL0FRKfpnAdvvsGN1ahU X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 50b3d0f7-1bab-4d51-73e0-08d9118aa203 X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3108.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2021 19:02:17.2869 (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: FhEV5wLKLOaqxyLc5Ove0GWiNo3M/cpQOC8f9K4E6c++Zi7pQyX57xY0X/vkC9xYsAJsNN6g6kNAnlE2eK4UdQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1620 Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org From: Yazen Ghannam Redo the current CS ID calculations to match the reference code. Helper functions are introduced that will be expanded for future DF versions. Signed-off-by: Yazen Ghannam --- arch/x86/kernel/cpu/mce/amd.c | 50 ++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index 01931f98c6d9..3340f8326681 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -924,45 +924,57 @@ static u8 get_socket_id_shift(struct addr_ctx *ctx) return (ctx->reg_fab_id_mask0 >> 28) & 0xF; } +static u8 get_dst_fabric_id(struct addr_ctx *ctx) +{ + return ctx->reg_limit_addr & 0xFF; +} + +static u8 get_component_id_mask(struct addr_ctx *ctx) +{ + return (~(ctx->socket_id_mask | ctx->die_id_mask)) & 0xFF; +} + +static u8 calc_level_bits(u8 id, u8 level_mask, u8 shift, u8 mask, u8 num_bits) +{ + return (((id & level_mask) >> shift) & mask) << num_bits; +} + static int calculate_cs_id(struct addr_ctx *ctx) { - u8 die_id_bit, sock_id_bit, cs_mask = 0; + u8 mask, num_intlv_bits = ctx->intlv_num_chan; + u8 dst_fabric_id = get_dst_fabric_id(ctx); if (get_cs_fabric_id(ctx)) return -EINVAL; get_masks(ctx); - die_id_bit = 0; + mask = get_component_id_mask(ctx); + ctx->cs_id = (ctx->cs_fabric_id & mask) - (dst_fabric_id & mask); - /* If interleaved over more than 1 channel: */ - if (ctx->intlv_num_chan) { - die_id_bit = ctx->intlv_num_chan; - cs_mask = (1 << die_id_bit) - 1; - ctx->cs_id = ctx->cs_fabric_id & cs_mask; - } - - /* Return early if no die interleaving and no socket interleaving. */ - if (!(ctx->intlv_num_dies || ctx->intlv_num_sockets)) - return 0; - - sock_id_bit = die_id_bit; + mask = (1 << num_intlv_bits) - 1; + ctx->cs_id &= mask; /* If interleaved over more than 1 die: */ if (ctx->intlv_num_dies) { u8 die_id_shift = get_die_id_shift(ctx); - sock_id_bit = die_id_bit + ctx->intlv_num_dies; - ctx->cs_id |= ((ctx->cs_fabric_id & ctx->die_id_mask) - >> die_id_shift) << die_id_bit; + mask = (1 << ctx->intlv_num_dies) - 1; + + ctx->cs_id |= calc_level_bits(ctx->cs_fabric_id, ctx->die_id_mask, + die_id_shift, mask, num_intlv_bits); + + num_intlv_bits += ctx->intlv_num_dies; } /* If interleaved over more than 1 socket: */ if (ctx->intlv_num_sockets) { u8 socket_id_shift = get_socket_id_shift(ctx); - ctx->cs_id |= ((ctx->cs_fabric_id & ctx->socket_id_mask) - >> socket_id_shift) << sock_id_bit; + mask = (1 << ctx->intlv_num_sockets) - 1; + + ctx->cs_id |= calc_level_bits(ctx->cs_fabric_id, ctx->socket_id_mask, + socket_id_shift, mask, num_intlv_bits); } return 0; From patchwork Fri May 7 19:01:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 12245125 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA4AFC433B4 for ; Fri, 7 May 2021 19:03:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AB04E60E0C for ; Fri, 7 May 2021 19:03:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229711AbhEGTE4 (ORCPT ); Fri, 7 May 2021 15:04:56 -0400 Received: from mail-eopbgr770081.outbound.protection.outlook.com ([40.107.77.81]:44439 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229727AbhEGTEm (ORCPT ); Fri, 7 May 2021 15:04:42 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KTwhho/lWwac3LNK8/M+bl44xGiRXW3J6WUoK6dhJBxBvqnCXgoAeT7W8Tt33rwPQzR95fLTev6Fa5cvEW140XisGmIcVk/pHNZLC5dFUZSAe0sifDnCleEcB3vWAA4j54RHh6O49j6puE4KN+LaEz8NP3vs13FPjimgL9++HwTf0GfYQp6R7mjzWdcUx4wMq6cMkDVvwJ8/2pcXyMWuvuaAaYKsBDIZVZ7ZPp2CYFH289XGuDAaHk8yhY2E7kG2b4CJJvqWLvf8SFkNtQ2bQ9URuE8FecyTCRqY6uIabO8weqNgCTCj6HXpSq4Ax0xPjhPIhanI8uXqfXeBbyJA1w== 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=bpNrWwNk470htSu/eF7fYwRRLHNbVIaJfvMJFIkEZcA=; b=HF5mL7EqqAs5UVGJhojUR6QW9bLqXOgjyJXHg/kdH9U9vZAvfX4qpu8GpFwLJi2teaJAXeYYilVgw7cxbKV10ljXL8XRbiQxD7x+gv/ljgOi06EAaH0COYkPg9tJ++v7QoPh7uKHQr3jBeGMj/aobp4Z+CDqB8nhFjHbPs6VlWnBOFO2gkWzxB9mLjfXbXQSPBeMCDlFLHWNzyfogEc+gTMv03CktdChycadO5CyToyPe2A4KrJsPIJhlB95E/s71sr6u0dtzN5kFjwArQnUyCvzl3vBa1arjpCowW9r+cCtiHJ0qmLfse0mWi76SP5CYznYJojKgOQgbz+awIFZYA== 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=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bpNrWwNk470htSu/eF7fYwRRLHNbVIaJfvMJFIkEZcA=; b=3bPk5PbGhETwJx1pkqcrjzQT4sEfcjGjMTp/ySHzB3LolxAPtynGqIhH/70H3aO/Vt4EZy3dMlFFcpxVLMKW8X5OszTZ3Etg9MY+hxBAFss8bb+Lj6xUfWS1S443MvRWSdrKNFUnaU+h3OOi2QT/RvAiPR2sIxr3VGaj9yvghCc= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) by BN6PR12MB1620.namprd12.prod.outlook.com (2603:10b6:405:10::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.26; Fri, 7 May 2021 19:02:18 +0000 Received: from BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211]) by BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211%6]) with mapi id 15.20.4108.029; Fri, 7 May 2021 19:02:18 +0000 From: Yazen Ghannam To: linux-edac@vger.kernel.org Cc: Yazen Ghannam , linux-kernel@vger.kernel.org, tony.luck@intel.com, x86@kernel.org, Smita.KoralahalliChannabasappa@amd.com Subject: [PATCH 24/25] x86/MCE/AMD: Match hash function to reference code Date: Fri, 7 May 2021 15:01:39 -0400 Message-Id: <20210507190140.18854-25-Yazen.Ghannam@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210507190140.18854-1-Yazen.Ghannam@amd.com> References: <20210507190140.18854-1-Yazen.Ghannam@amd.com> X-Originating-IP: [165.204.25.250] X-ClientProxiedBy: BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) To BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from aus-x-yghannam.amd.com (165.204.25.250) by BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.3 via Frontend Transport; Fri, 7 May 2021 19:02:17 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e0aa19fb-7eba-4add-1f59-08d9118aa29a X-MS-TrafficTypeDiagnostic: BN6PR12MB1620: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4714; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ugDA3sqoENKJRmIs3XIGOfK6NfyxHmKvrRk2cBL0viVhEibZOUM02+QGJKsEItUS2F2k/SFBRpVldrwpvfmrps7zcxWzND/I54Tf0zvooSls6ppOqpYCGbbyYtColt/J/Za9reg9m/aqsMOeiWvyQyXKS2/O1eeXdR/XSDZqi3yvJZfqm+owX77TMIpkpvUEn8PEp5DEv09Q6LpS+S2EJU7o9gTMZOzE2Id17R7Q/lOCqDcRq+luZVCaOGeJArc7fn5vOLighL25hN3uBFTO2J3BIRjGUnDr5sZSOVEigLpEpM+aAfjXmwY+85eyq7UiXls/7Ejq15FVuPnKpqlkcd+GIH/QhpzHGKqshLnIh8PziidXp6mV2IyG/7febNZOnD731Iz3OfwWBlZga9C2aH3iYAaxEJpxej6A5fmRnMZ7MARirFAb5A+bRKxd0GL9wWNsZ8FU4mE/KSrYhVQkWYnb3gnycf0+nW612p31iaYkf29pAmxxu2L41N4pAj/hKqqe07dif48WRkgRoIIAz1UBPlRTn7hj/rNUmns9PPL7GADisIStOtiQyeP4rjvf3x+86ztNPBELPugMK13gREMKdPEPYKD0/BZg9FauJ8uuvI3p6c84J0j2IuB9eqIFn6vtx4WuNQNSfnMB6y/dg+r50FBX52yaGSrX/bAYm/s= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR12MB3108.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(376002)(136003)(366004)(39860400002)(346002)(4326008)(6666004)(38350700002)(38100700002)(66556008)(2906002)(26005)(6486002)(66476007)(1076003)(16526019)(86362001)(6916009)(66946007)(2616005)(956004)(186003)(5660300002)(36756003)(478600001)(316002)(52116002)(7696005)(8676002)(83380400001)(4744005)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: y/ZZpnyG1GL6uJx1pFj0EhFmJES27sVUrQKsjipb14yZZto0cXTH8NP4VeesoBW8OMJzCDNc/W1GDsWTFBGMMjZY2YvdJ38+9UwlGLYwxjJkbmWRPEfGiWT4pq3W01CTM1yRRdL7l9s7n9K2SNbQC1m5/ssmFiRNO1Pj2hiGWq8KxrT4HflTCHJmwABuAE2rmGAIKu6qvGiD+aKbqf5sMBd75ogAnGgVm6bMrWCvP9PcaWhaArDkYO1hJOIQRRTprAa8NZXAYrAJzKaSYVJ2VovKDvfMYYcRDBa7mc7oYtiN0/kF9njEsHx0bbSUHXhEq2atK3nvjha3iFLuICkRqjhh3rSvDkvtYwuWjEUf8AC7xQn2yg2liyOMvtrgbf1f4XRYyhu1HesrtB/8ns6asgcMu41xur+lIthwwOb3KFo7LRTTZJcFw6hAsuGo2O9z1U+UYhzd2pdjW0IyYGAPrp6Qgu0OEQW3h4asPtkQWWxkI5URyg18v7cPSXV6c1O5FPp6aHJDiwz5rE4emBt7836VN9YOEDbFEeRUE6jWawlQ1v83EvbvPjms0Sdp/oCBhn7MFUFC0uCsH6veCKu2XLnBDzqbdulsn3/abzy7/3xYXlnVgG5OsNlxmuIIqXPtGbYhpD5T8klRpRM8cUyyh4CXZkdAQRJyWYHAwMz/k5viC3SATgw+1KoxqXgqnEfiGcbH9kqNcjroGGQ5MM592EAj4h3e0h0w07Srxym2lYDlDBVKNaWPd8d1aRe9bpUbH6Sn7pIiMfqcN/8nZu/h49rPIAs74lvchh9+ArpEKIkhfsCzA3wp1vpdlSbrAhn385DK/7+0R4Tq3/eplDQR5JzgagPP7R0MNlwvwTyuPl9tOu1Md2gqk4IqwY6skQJ1N8PY1NjIBq1LIHRa+pJG2Vhgrqjl4vPlYoEnRBNiO8TJLY9KGRxbCtLmLdueP3onafm4rpOHJ6cJL80uOALbc6yGhEigeIkhLGfC6XI+kDYAa6TOgWeqqIrBnY//ieWKpuEDcYdScR8ZE8gz98NJXSec4EE3pjchaI5LnTLyoNhFq4ynZTaxGh04OGwmtts1+iYj/1Z+z7qoPphToJP/kJUtTmDHEQecmO2LpiC5PU8N6g+D1prKTP6c/DmHJCo6R7T5ut23wJgqGybaOPfO8rLqP8/dbpHh5uuPNxzWZLThIDm+Egeh+uTnTEs6MvFzVQYWQWqWg4VvGUv7tv1xg5/I4pp0LiJfKLq7GozwKX2jx+2upJy35j16tQj6LbHGQPMuRLov4fd0/bVHYnNmlYWe7NH8JBZvyYOuTW8Q2TQ3lXR1HwX3n7D/X4aJq4UU X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: e0aa19fb-7eba-4add-1f59-08d9118aa29a X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3108.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2021 19:02:18.2843 (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: wuSOt4eMBQBY+X3JWiEDygVJLRzhzbg3+/Kwk5PHAJbOBVensN+tU5KPA7Re/70SqaniqzePg1rUkxUdlVJOhw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1620 Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org From: Yazen Ghannam The reference code for DF2 hashing was changed to XOR the interleave address bit rather than the CS ID. Match that here. Signed-off-by: Yazen Ghannam --- arch/x86/kernel/cpu/mce/amd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index 3340f8326681..b3bfdc42dcaa 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -1037,7 +1037,7 @@ static int dehash_addr_df2(struct addr_ctx *ctx) (ctx->ret_addr >> 18) ^ (ctx->ret_addr >> 21) ^ (ctx->ret_addr >> 30) ^ - ctx->cs_id; + (ctx->ret_addr >> ctx->intlv_addr_bit); hashed_bit &= BIT(0); From patchwork Fri May 7 19:01:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 12245127 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00759C433ED for ; Fri, 7 May 2021 19:04:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D556A60E0C for ; Fri, 7 May 2021 19:03:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229849AbhEGTE5 (ORCPT ); Fri, 7 May 2021 15:04:57 -0400 Received: from mail-dm6nam12on2089.outbound.protection.outlook.com ([40.107.243.89]:47105 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229524AbhEGTEn (ORCPT ); Fri, 7 May 2021 15:04:43 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RFByIwK4y1skAlYPFr4vlsGUniAK1CvgR16rSe1ZX4weA+FtSrBuXqQRK2czM7CqzNeZrLgVLYUsRNNdUbXH+LhODMDEPvqpCBF7R0nDy7VGmcPdIXvq/RNgHoAGN+vW/MWAzBQbBA/qRcbBup+uB2Bq9C8ncrWV6bm9562+NDU2gG/cgdpFKnuZ1uzss6oJtFR86DKrJ9V4Czy75rOzsdLr5HikEhwwTz/q9M3+4laXGrcmgSEINBgdXqPQ5qEQwHQ8q63rpLbecqFCku0xhXfqIdLk5kcPqipT1arrg7Khle1IR38hvrgvIVMCpNWbcRT8IXVonrQhIVKqtQ1uwg== 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=MowLG4pc3Cv7Iu2+U9IBlBT6WV1b8EXd6OTID5R7VZo=; b=nQKtYbyVqDwd0gY7Fhrs7vWFaOg3M/184rN9cGAdvYz3AHcc/ZK5ZVfRGsbRvdfdR9ac5wtfPLCdLGe19w9juBPPdFON2wXRrkCAKYi6Sh+IWAGTKVqXQ42dR19Fg1gfr/zD8NHjFxIT7vS7HDDCDwkuprUa1P22tySiDtg1JExukS1F7/GZpFk9sqKoVM+9OuwoLYxAwAI1tegQumThKVon+cJxL4ir9rDWzjHx03Q8EqZUSfMLfmrenGkctgbpqrtV4t/eR7VWODNj/gDu7XpBu+p3TajR1e2L8pTEoyWeU6hcXqUCQCISO2D9dgvXe8xpj72KOFxoOV41nER96A== 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=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MowLG4pc3Cv7Iu2+U9IBlBT6WV1b8EXd6OTID5R7VZo=; b=kgOwegKypxnJeYVcFPjVYfWHFBN3hyqZntNbHL8PvdLNvN+HPR6YwGHHLjgSN45lQ1Z2/toZi/EhkbN96ZbqY/MTm4wyR237c2V0qNHKeo38gS256lwZaHYx0hNfISmdvmz2iNjc9vZodDZPPkwkLtxQNf78hDyISSL1ttW/z9A= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) by BN6PR12MB1620.namprd12.prod.outlook.com (2603:10b6:405:10::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.26; Fri, 7 May 2021 19:02:20 +0000 Received: from BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211]) by BN8PR12MB3108.namprd12.prod.outlook.com ([fe80::418b:8ea0:dc4b:d211%6]) with mapi id 15.20.4108.029; Fri, 7 May 2021 19:02:20 +0000 From: Yazen Ghannam To: linux-edac@vger.kernel.org Cc: Yazen Ghannam , linux-kernel@vger.kernel.org, tony.luck@intel.com, x86@kernel.org, Smita.KoralahalliChannabasappa@amd.com Subject: [PATCH 25/25] x86/MCE/AMD: Add support for address translation on DF3 systems Date: Fri, 7 May 2021 15:01:40 -0400 Message-Id: <20210507190140.18854-26-Yazen.Ghannam@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210507190140.18854-1-Yazen.Ghannam@amd.com> References: <20210507190140.18854-1-Yazen.Ghannam@amd.com> X-Originating-IP: [165.204.25.250] X-ClientProxiedBy: BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) To BN8PR12MB3108.namprd12.prod.outlook.com (2603:10b6:408:40::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from aus-x-yghannam.amd.com (165.204.25.250) by BN6PR21CA0010.namprd21.prod.outlook.com (2603:10b6:404:8e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.3 via Frontend Transport; Fri, 7 May 2021 19:02:18 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 164fe0a8-6178-4464-1ead-08d9118aa35a X-MS-TrafficTypeDiagnostic: BN6PR12MB1620: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tAvyeFuWD6ixOE4vwK+JWM95QW1GHGZT0XKr9lK8mMtFbBMrZoCOXyCNsGWVxr/UPWkunme3R6mefrLMc1ZsGShvUhfewLQuT7vpoWMFUevT4fGCIqTcDNJymmdDO/bpmhoOqr2WRiYwRsg/8Az/L2mU4hkvhGiXADtHt0QH3pOdsaSp5YU/yLPi3m5Xyjv0sByLrjVunGol0z4EdN/BoS6DSxcMxu8c8hU1VW7pESGV0nA+SLNL/0AXTpXSf7ad0vSnemWSxKXnGpGe4UFphg0RitMlSIdXl0oechgx6/534W/33XKml9pqOdS5OTSiW0EL2sS6LXmS1o5O1tdInOxsYQ7hphtQsW2w/2grfUzsWxbm2pXAE7rutLP3ocQovyCJM7zieps0RhbVoOZ4PNrkPgMMgR8XWSBwAJTRpJNPJhM554W97+5pNr1/PxC601IjH6jjeAVAmbSu+WY2uiShW8e9TvnJuHGFzEc4cqI5ILUYJky6b8APR+1CAO8LSot4lFSgFtz/tI8LIoDMhkzmMN1aMngVgg2xsdmI9atO239OL7R+i4ZyPbqHqtBrv5w1fMI6fE98F9yUR58oVmxs3KXTfG5wPPR96WutaOcrEw0vDHlFE+1AO+owNQnClUB3tzKnjg292bgS76ds5ltriTzx37/KPnefyw/GukA= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR12MB3108.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(376002)(136003)(366004)(39860400002)(346002)(4326008)(6666004)(38350700002)(38100700002)(66556008)(2906002)(26005)(6486002)(66476007)(1076003)(16526019)(86362001)(6916009)(66946007)(2616005)(956004)(186003)(5660300002)(36756003)(478600001)(316002)(52116002)(7696005)(8676002)(83380400001)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: IxxqRRu3ugvPizndNNZLIhlZ6xa3WliulFMq25dKOqD151UUEpm1LXK/nZWH8fTmW5ze8Gahrad1A4XQYiZB/Fhea6R/63cXQnUkzSM0OaKA4z5iTV58wZpu+ADEqfzfdUAiliRNv7URkD/DKAAwzNbas7KmPN2p5K4PoVHECGf+GYuS+1KEfvQrdYTkeKM1ky7LZRHu/VoCH1WnpXLix12unwFRm0ipvpXjrhkxWhD0MdFN4mJ5tvW/XJAPzc1QKLUZhCzg80HnLq0Ht/zF/kO677xSWVcex3k6GXc+7HNyYTpWbuvxtoX5fijZ4aP39m+2GpMsB8wwEuj5ebZpaRl+fFwTSv1wS98k1iXHzZcgSCBoRxZwOk3HdSd2SXNsbORPrjeOwbHR7MESJx9jLv6QzQaT0KS32Gje3/cxFRVqyktAje28DAfQcvk6NFRHSYgj4HcKsDqEiIOuMtI7EqcaLvw72n32Y0rAd40Z+K5kYzCDkL9f7+7M/s1ItIEXLMtwfOUunhUF9qa8EmqusvFQl4yh8YM4Wq/nhsowDcetw/45UgXHgUMiKifswMPRA9bdd7vhI+mpILW875Lu9QKvonS5G0+MycC+lKDfw60TwYzXKczvKtX6kRo8pzZQEavq5nJqrZaWwiT4SKILinQvhsV8aBbCjtzy/AIlKin8Xn/DlIsAReFFN9mA0unAaWZettsxeatqAQpvMxp71Rp8tlWOsPUXz8dvuMZ0nwwscs7Mi83Xg+OMtCXliQeGobTEVWT5uHv/MJt2VcyppcRNGuGUpiSeCMIn+0HeJLuDn1Si8c1IAYFG10RSJFUY29S3ghYevkqlb8k/5mWS7L6KRRe9XOqhvo5s3Xl1teAyNS6LaPTXYws1IZy99vM7i+6ALoWbYrIU7AVWAWz2ptWU6S8Ryj+GfnlvUVldEgL55dgtxIPHikXVHNtbJi8JZPYwvz+TDDm/SzcqlBPAWUEeD4TBTTxQFiUXtT21jipzfhcKbqFp5RF+eSXj8TU6gmM0U/qhV4xcRNfwqjRdl0JEZoJURb7czsS/fC14djB/oBrO4k+9GkUb9uxL0/LSKKZ/QnVfNx9KIW2Pum3vygGUN/xrOTGPVAN2fzeEc2LmRr/gbSW0vtlxeLnQa48htnKhFHQ0BF7P3Cn7gbqz0/NjoXlyfELvuLg0Ms00Z+OorVbI5VBTDqExZYRh507l5xwY2Mqntdzjng1TSfZXyFchyAPSILIN8GkN9UuZO3YFm/WaSbTAV/+o9mgzCKAcc+HLpZRq798aMT0i9lpBwf0t/qNqQ0IwG3f7bzRrnNId51VmI2+5OEW/pzP/m09v X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 164fe0a8-6178-4464-1ead-08d9118aa35a X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3108.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2021 19:02:20.0363 (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: 0JeD+w7dHzRayCi+wR5GGIP1QVBu2dygB3MVmPztPtiyhxOGYvsufxXVfz8p9q6ksr0X+lovRw3R0XNJaUofhQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1620 Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org From: Yazen Ghannam DF3-based systems (Rome and later) support new interleaving modes and a number of bit fields have changed or moved entirely. Add support for these new modes and fields. Refactoring should be minimal due to earlier changes, and most updates will be additions. Signed-off-by: Yazen Ghannam --- arch/x86/kernel/cpu/mce/amd.c | 183 +++++++++++++++++++++++++++++++--- 1 file changed, 171 insertions(+), 12 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index b3bfdc42dcaa..a165706c04f1 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -684,9 +684,11 @@ enum df_reg_names { DRAM_BASE_ADDR_1, DRAM_LIMIT_ADDR_1, DRAM_OFFSET, + DF_GLOBAL_CTL, /* Function 1 */ SYS_FAB_ID_MASK, + SYS_FAB_ID_MASK_1, }; static struct df_reg df_regs[] = { @@ -702,18 +704,28 @@ static struct df_reg df_regs[] = { [DRAM_LIMIT_ADDR_1] = {0, 0x11C}, /* D18F0x1B4 (DramOffset) */ [DRAM_OFFSET] = {0, 0x1B4}, + /* D18F0x3F8 (DfGlobalCtrl) */ + [DF_GLOBAL_CTL] = {0, 0x3F8}, /* D18F1x208 (SystemFabricIdMask) */ [SYS_FAB_ID_MASK] = {1, 0x208}, + /* D18F1x20C (SystemFabricIdMask1) */ + [SYS_FAB_ID_MASK_1] = {1, 0x20C}, }; enum df_types { DF2, + DF3, }; /* These are mapped 1:1 to the hardware values. Special cases are set at > 0x20. */ enum intlv_modes { NONE = 0x00, NOHASH_2CH = 0x01, + NOHASH_4CH = 0x03, + NOHASH_8CH = 0x05, + HASH_COD4_2CH = 0x0C, + HASH_COD2_4CH = 0x0D, + HASH_COD1_8CH = 0x0E, DF2_HASH_2CH = 0x21, }; @@ -726,6 +738,7 @@ struct addr_ctx { u32 reg_base_addr; u32 reg_limit_addr; u32 reg_fab_id_mask0; + u32 reg_fab_id_mask1; u16 nid; u8 umc; u8 map_num; @@ -737,11 +750,15 @@ struct addr_ctx { u8 cs_fabric_id; u8 die_id_mask; u8 socket_id_mask; + u8 node_id_shift; bool hash_enabled; }; static enum df_types get_df_type(struct addr_ctx *ctx) { + if ((ctx->reg_fab_id_mask0 & 0xFF) != 0) + return DF3; + return DF2; } @@ -762,8 +779,23 @@ static int get_intlv_mode_df2(struct addr_ctx *ctx) return 0; } +static int get_intlv_mode_df3(struct addr_ctx *ctx) +{ + ctx->intlv_mode = (ctx->reg_base_addr >> 2) & 0xF; + + if (ctx->intlv_mode == HASH_COD4_2CH || + ctx->intlv_mode == HASH_COD2_4CH || + ctx->intlv_mode == HASH_COD1_8CH) + ctx->hash_enabled = true; + + return 0; +} + static int get_intlv_mode(struct addr_ctx *ctx) { + if (ctx->df_type == DF3) + return get_intlv_mode_df3(ctx); + return get_intlv_mode_df2(ctx); } @@ -777,6 +809,9 @@ static int get_dram_offset_reg(struct addr_ctx *ctx) static u64 get_hi_addr_offset(struct addr_ctx *ctx) { + if (ctx->df_type == DF3) + return (ctx->reg_dram_offset & GENMASK_ULL(31, 12)) << 16; + return (ctx->reg_dram_offset & GENMASK_ULL(31, 20)) << 8; } @@ -823,10 +858,15 @@ static int get_dram_addr_map(struct addr_ctx *ctx) static int get_intlv_addr_bit(struct addr_ctx *ctx) { - u8 intlv_addr_sel = (ctx->reg_base_addr >> 8) & 0x7; + u8 intlv_addr_sel; + + if (ctx->df_type == DF3) + intlv_addr_sel = (ctx->reg_base_addr >> 9) & 0x7; + else + intlv_addr_sel = (ctx->reg_base_addr >> 8) & 0x7; - /* {0, 1, 2, 3} map to address bits {8, 9, 10, 11} respectively */ - if (intlv_addr_sel > 3) { + /* {0, 1, 2, 3, 4} map to address bits {8, 9, 10, 11, 12} respectively */ + if (intlv_addr_sel > 4) { pr_err("%s: Invalid interleave address select %d.\n", __func__, intlv_addr_sel); return -EINVAL; @@ -845,9 +885,18 @@ static void get_intlv_num_chan(struct addr_ctx *ctx) ctx->intlv_num_chan = 0; break; case NOHASH_2CH: + case HASH_COD4_2CH: case DF2_HASH_2CH: ctx->intlv_num_chan = 1; break; + case NOHASH_4CH: + case HASH_COD2_4CH: + ctx->intlv_num_chan = 2; + break; + case NOHASH_8CH: + case HASH_COD1_8CH: + ctx->intlv_num_chan = 3; + break; default: /* Valid interleaving modes where checked earlier. */ break; @@ -856,12 +905,18 @@ static void get_intlv_num_chan(struct addr_ctx *ctx) static void get_intlv_num_dies(struct addr_ctx *ctx) { - ctx->intlv_num_dies = (ctx->reg_limit_addr >> 10) & 0x3; + if (ctx->df_type == DF3) + ctx->intlv_num_dies = (ctx->reg_base_addr >> 6) & 0x3; + else + ctx->intlv_num_dies = (ctx->reg_limit_addr >> 10) & 0x3; } static void get_intlv_num_sockets(struct addr_ctx *ctx) { - ctx->intlv_num_sockets = (ctx->reg_limit_addr >> 8) & 0x1; + if (ctx->df_type == DF3) + ctx->intlv_num_sockets = (ctx->reg_base_addr >> 8) & 0x1; + else + ctx->intlv_num_sockets = (ctx->reg_limit_addr >> 8) & 0x1; } static void expand_bits(u8 start_bit, u8 num_bits, u64 *value) @@ -884,12 +939,22 @@ static void make_space_for_cs_id(struct addr_ctx *ctx) switch (ctx->intlv_mode) { case NOHASH_2CH: + case NOHASH_4CH: + case NOHASH_8CH: case DF2_HASH_2CH: num_intlv_bits = ctx->intlv_num_chan; num_intlv_bits += ctx->intlv_num_dies; num_intlv_bits += ctx->intlv_num_sockets; expand_bits(ctx->intlv_addr_bit, num_intlv_bits, &ctx->ret_addr); break; + case HASH_COD4_2CH: + case HASH_COD2_4CH: + case HASH_COD1_8CH: + num_intlv_bits = ctx->intlv_num_chan; + num_intlv_bits += ctx->intlv_num_sockets; + expand_bits(ctx->intlv_addr_bit, 1, &ctx->ret_addr); + if (num_intlv_bits > 1) + expand_bits(12, num_intlv_bits - 1, &ctx->ret_addr); default: /* Valid interleaving modes where checked earlier. */ break; @@ -908,29 +973,56 @@ static int get_cs_fabric_id(struct addr_ctx *ctx) return 0; } -static void get_masks(struct addr_ctx *ctx) -{ - ctx->die_id_mask = (ctx->reg_fab_id_mask0 >> 8) & 0xFF; - ctx->socket_id_mask = (ctx->reg_fab_id_mask0 >> 16) & 0xFF; -} - static u8 get_die_id_shift(struct addr_ctx *ctx) { + if (ctx->df_type == DF3) + return ctx->node_id_shift; + return (ctx->reg_fab_id_mask0 >> 24) & 0xF; } static u8 get_socket_id_shift(struct addr_ctx *ctx) { + if (ctx->df_type == DF3) + return ((ctx->reg_fab_id_mask1 >> 8) & 0x3) + ctx->node_id_shift; + return (ctx->reg_fab_id_mask0 >> 28) & 0xF; } +static void get_node_id_shift(struct addr_ctx *ctx) +{ + ctx->node_id_shift = ctx->reg_fab_id_mask1 & 0xF; +} + +static void get_masks(struct addr_ctx *ctx) +{ + if (ctx->df_type == DF3) { + get_node_id_shift(ctx); + + ctx->die_id_mask = (ctx->reg_fab_id_mask1 >> 16) & 0x7; + ctx->die_id_mask <<= ctx->node_id_shift; + + ctx->socket_id_mask = (ctx->reg_fab_id_mask1 >> 24) & 0x7; + ctx->socket_id_mask <<= ctx->node_id_shift; + } else { + ctx->die_id_mask = (ctx->reg_fab_id_mask0 >> 8) & 0xFF; + ctx->socket_id_mask = (ctx->reg_fab_id_mask0 >> 16) & 0xFF; + } +} + static u8 get_dst_fabric_id(struct addr_ctx *ctx) { + if (ctx->df_type == DF3) + return ctx->reg_limit_addr & 0x1FF; + return ctx->reg_limit_addr & 0xFF; } static u8 get_component_id_mask(struct addr_ctx *ctx) { + if (ctx->df_type == DF3) + return ctx->reg_fab_id_mask0 & 0x1FF; + return (~(ctx->socket_id_mask | ctx->die_id_mask)) & 0xFF; } @@ -982,7 +1074,14 @@ static int calculate_cs_id(struct addr_ctx *ctx) static void insert_cs_id(struct addr_ctx *ctx) { - ctx->ret_addr |= (ctx->cs_id << ctx->intlv_addr_bit); + if (ctx->intlv_mode == HASH_COD4_2CH || + ctx->intlv_mode == HASH_COD2_4CH || + ctx->intlv_mode == HASH_COD1_8CH) { + ctx->ret_addr |= ((ctx->cs_id & 0x1) << ctx->intlv_addr_bit); + ctx->ret_addr |= ((ctx->cs_id & 0xE) << 11); + } else { + ctx->ret_addr |= (ctx->cs_id << ctx->intlv_addr_bit); + } } static int denormalize_addr(struct addr_ctx *ctx) @@ -1047,11 +1146,67 @@ static int dehash_addr_df2(struct addr_ctx *ctx) return 0; } +static int dehash_addr_df3(struct addr_ctx *ctx) +{ + u8 hashed_bit, intlv_ctl_64k, intlv_ctl_2M, intlv_ctl_1G; + u32 tmp; + + if (amd_df_indirect_read(ctx->nid, df_regs[DF_GLOBAL_CTL], ctx->umc, &tmp)) + return -EINVAL; + + intlv_ctl_64k = !!((tmp >> 20) & 0x1); + intlv_ctl_2M = !!((tmp >> 21) & 0x1); + intlv_ctl_1G = !!((tmp >> 22) & 0x1); + + hashed_bit = (ctx->ret_addr >> 14) ^ + ((ctx->ret_addr >> 18) & intlv_ctl_64k) ^ + ((ctx->ret_addr >> 23) & intlv_ctl_2M) ^ + ((ctx->ret_addr >> 32) & intlv_ctl_1G) ^ + (ctx->ret_addr >> ctx->intlv_addr_bit); + + hashed_bit &= BIT(0); + + if (hashed_bit != ((ctx->ret_addr >> ctx->intlv_addr_bit) & BIT(0))) + ctx->ret_addr ^= BIT(ctx->intlv_addr_bit); + + if (ctx->intlv_mode != HASH_COD2_4CH && + ctx->intlv_mode != HASH_COD1_8CH) + return 0; + + hashed_bit = (ctx->ret_addr >> 12) ^ + ((ctx->ret_addr >> 16) & intlv_ctl_64k) ^ + ((ctx->ret_addr >> 21) & intlv_ctl_2M) ^ + ((ctx->ret_addr >> 30) & intlv_ctl_1G); + + hashed_bit &= BIT(0); + + if (hashed_bit != ((ctx->ret_addr >> 12) & BIT(0))) + ctx->ret_addr ^= BIT(12); + + if (ctx->intlv_mode != HASH_COD1_8CH) + return 0; + + hashed_bit = (ctx->ret_addr >> 13) ^ + ((ctx->ret_addr >> 17) & intlv_ctl_64k) ^ + ((ctx->ret_addr >> 22) & intlv_ctl_2M) ^ + ((ctx->ret_addr >> 31) & intlv_ctl_1G); + + hashed_bit &= BIT(0); + + if (hashed_bit != ((ctx->ret_addr >> 13) & BIT(0))) + ctx->ret_addr ^= BIT(13); + + return 0; +} + static int dehash_addr(struct addr_ctx *ctx) { if (!ctx->hash_enabled) return 0; + if (ctx->df_type == DF3) + return dehash_addr_df3(ctx); + return dehash_addr_df2(ctx); } @@ -1073,6 +1228,10 @@ static int get_fabric_id_mask_reg(struct addr_ctx *ctx) ctx->umc, &ctx->reg_fab_id_mask0)) return -EINVAL; + if (amd_df_indirect_read(ctx->nid, df_regs[SYS_FAB_ID_MASK_1], + ctx->umc, &ctx->reg_fab_id_mask1)) + return -EINVAL; + return 0; }