From patchwork Thu May 23 18:26:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 13672154 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2045.outbound.protection.outlook.com [40.107.93.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E796A4F8BB; Thu, 23 May 2024 18:27:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716488834; cv=fail; b=In5bnhi/U1lIVW5iVJHxojVuRDvQZerGor6A8QQyFLIzYxJ8ytYLJerDAI2e5onV//oUSkxwieKbiJjzNOod2CQvwVM3Ucfntne0EscUjFwFPXo8As792IKAcr+j1pmaJmLt5MaTJc30NcwSyyzAudeB1Wo2CXufpkVROrZOEk0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716488834; c=relaxed/simple; bh=BIcXZX1mtI8ZTj+EiV2rx3f58KkkrSjFXf1uZpjRcIg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=tdRe//LCove3DQbUucLzK+WdtdCLt9DPfvjJ8l/BOUAZUtAgan+7bHZQlhcXRih9lxaWo/bWTHyESOzDoDQuAWNCPtNazW1VmL2qsypDMMic+4eQnf++eiE+Z9bGdc4TzrkJgH3yxL+lXDkHebVFSXM/gGdo5qiP/LzaiUmknQ4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=JAgmt1/x; arc=fail smtp.client-ip=40.107.93.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="JAgmt1/x" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GCFJJtZi4hOOizIk6uWIUiIm6ZeWd6uSrY0v5nGPomr8uAD7oNGcPTmQyliZdo43og+U3ruWUhtjCzvubsb2XKia/YKxUAj4LsyXyCMtOVXavRiIvhiZ+/oSpPuhqL0ELOmof9CSOMp/34HLRNqFLEI3jVhVIgGwhzCWFVvdwiJSOoBMO80tiaPWDmguZLgPVVOhcJ12qA+sTBeSlYrMrbfFXXHOtLK6Ncgoh47eDnr1MBg1n1+n1KrTHw8uDxY92mv1OHyRNufaw/yh2frrOwTRK/ojIo9vQ47NvMFrpp6FJFE4IrqXlxWEzDrE9qESBdlmyFWHDP6G6dHPJ6efSw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=X7SCt7F4OO7w2sQIN1qLxP+POI2Lgw2NcR+2gbWxrSU=; b=Pa+Ig7IW57d+yS/Rbtvsv/XqpcgRTaD9059uyGB/FVkDlSYSOlBLu4zMUvzZ19gGvHKLRuWqRTylNl55k/kM9C3BKDxCwWIfMuBjdG2pYYWJnaGFpdltV6o7LTuA0P9/kaTYUcqa72ps6lTq3/1vF2K6AYzK55MBLR26Ui7E8FkeV461cL4FH0VlVOUwz3H9XGUL05xOCLv4+w8V9x9kbA65nOOQVcLjPRfUtIIfSGviUYKyBZ9F3D4YqshfPWpGSpfXrhMTcLWl3qDinVqFtMDFSV0jHiZoRatfKWUcqeWEnZWMelJFUvt95hA5iFuHpYzUEYFRUV5Qp6cTWqkMKA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) 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=X7SCt7F4OO7w2sQIN1qLxP+POI2Lgw2NcR+2gbWxrSU=; b=JAgmt1/xm/u/0KdcIEpeEIulv2IY+eho93yIusOw0kV3E2OdndyvHx+9Gf520FE0wn4QPUd0ShvLT0eZju5Zb5VipGa2w4vN5aKAsO3Aq9Ya7crNGnV/dbp+7fqXWvqK5U/mjYUbx9n1GkPn6YSqTtbppyuXf8fRnQkZZAjv0pM= Received: from DS7PR03CA0258.namprd03.prod.outlook.com (2603:10b6:5:3b3::23) by CYYPR12MB8990.namprd12.prod.outlook.com (2603:10b6:930:ba::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.35; Thu, 23 May 2024 18:27:10 +0000 Received: from CH3PEPF00000011.namprd21.prod.outlook.com (2603:10b6:5:3b3:cafe::f7) by DS7PR03CA0258.outlook.office365.com (2603:10b6:5:3b3::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.34 via Frontend Transport; Thu, 23 May 2024 18:27:10 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH3PEPF00000011.mail.protection.outlook.com (10.167.244.116) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7633.0 via Frontend Transport; Thu, 23 May 2024 18:27:10 +0000 Received: from quartz-7b1chost.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 23 May 2024 13:27:08 -0500 From: Yazen Ghannam Date: Thu, 23 May 2024 13:26:52 -0500 Subject: [PATCH v3 1/8] EDAC/amd64: Remove unused register accesses Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240523-fix-smn-bad-read-v3-1-aa44c622de39@amd.com> References: <20240523-fix-smn-bad-read-v3-0-aa44c622de39@amd.com> In-Reply-To: <20240523-fix-smn-bad-read-v3-0-aa44c622de39@amd.com> To: Guenter Roeck , , Yazen Ghannam CC: Mario Limonciello , , , X-Mailer: b4 0.13.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PEPF00000011:EE_|CYYPR12MB8990:EE_ X-MS-Office365-Filtering-Correlation-Id: 7ea45ac9-e257-42b3-d4ae-08dc7b55f5ce X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|82310400017|36860700004|376005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?rgHlCIahMWXMjzv4gqSbWhR26N0EJqG?= =?utf-8?q?2mGZGdbFEXxNj34Iao2bR4JWnH67M99xXsqp41WQ4r3yo+RheAF3iKmt24vd3p6fH?= =?utf-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utf-8?q?xrTUn+Yh8qkkXHwoR0wWBz1oENHkKIexjshzxZI7dyJ4fpc2p+1+asOpfNEq4SoFG?= =?utf-8?q?m7XqWyreQ5D8toc0dOU4W1oiOA4tcsYnyme4n1ibFm33N8SA+9+CmQcEBck2S/SKv?= =?utf-8?q?Bt5aUa9FmV46YtFuD+utl061oZpkSLKgzoodYQZsJu6WtWQO4R4BFBu9YfYpm4qUy?= =?utf-8?q?ed73iWkDChFEHbEPPVSDb+UhYF3wAWBk4Of4b28pczVBsjia5qv4Mf6Gw4+svZn7F?= =?utf-8?q?Ph2FX8CTYm3PofxvIqIDJtcueqxo/aQwxUABv/Ed5OKd4+f3GSuwsjtGHHSUYrQEE?= =?utf-8?q?OC7HT5DNF5eXqkxbVrOQdLqgzeVoNiJKA/oI7yeBgC6BNSTntdTziznaf0sfWPa1D?= =?utf-8?q?IGHvYkZqSA+F?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(1800799015)(82310400017)(36860700004)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2024 18:27:10.5552 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7ea45ac9-e257-42b3-d4ae-08dc7b55f5ce X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH3PEPF00000011.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR12MB8990 A number of UMC registers are read only for the purpose of debug printing. They are not used in any calculations. Nor do they have any specific debug value. Remove these register accesses. Signed-off-by: Yazen Ghannam Reviewed-by: Mario Limonciello Cc: stable@vger.kernel.org --- drivers/edac/amd64_edac.c | 18 +----------------- drivers/edac/amd64_edac.h | 4 ---- 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c index 1f3520d76861..4cedfb3b4cb6 100644 --- a/drivers/edac/amd64_edac.c +++ b/drivers/edac/amd64_edac.c @@ -20,7 +20,6 @@ static inline u32 get_umc_reg(struct amd64_pvt *pvt, u32 reg) return reg; switch (reg) { - case UMCCH_ADDR_CFG: return UMCCH_ADDR_CFG_DDR5; case UMCCH_ADDR_MASK_SEC: return UMCCH_ADDR_MASK_SEC_DDR5; case UMCCH_DIMM_CFG: return UMCCH_DIMM_CFG_DDR5; } @@ -1339,22 +1338,15 @@ static void umc_debug_display_dimm_sizes(struct amd64_pvt *pvt, u8 ctrl) static void umc_dump_misc_regs(struct amd64_pvt *pvt) { struct amd64_umc *umc; - u32 i, tmp, umc_base; + u32 i; for_each_umc(i) { - umc_base = get_umc_base(i); umc = &pvt->umc[i]; edac_dbg(1, "UMC%d DIMM cfg: 0x%x\n", i, umc->dimm_cfg); edac_dbg(1, "UMC%d UMC cfg: 0x%x\n", i, umc->umc_cfg); edac_dbg(1, "UMC%d SDP ctrl: 0x%x\n", i, umc->sdp_ctrl); edac_dbg(1, "UMC%d ECC ctrl: 0x%x\n", i, umc->ecc_ctrl); - - amd_smn_read(pvt->mc_node_id, umc_base + UMCCH_ECC_BAD_SYMBOL, &tmp); - edac_dbg(1, "UMC%d ECC bad symbol: 0x%x\n", i, tmp); - - amd_smn_read(pvt->mc_node_id, umc_base + UMCCH_UMC_CAP, &tmp); - edac_dbg(1, "UMC%d UMC cap: 0x%x\n", i, tmp); edac_dbg(1, "UMC%d UMC cap high: 0x%x\n", i, umc->umc_cap_hi); edac_dbg(1, "UMC%d ECC capable: %s, ChipKill ECC capable: %s\n", @@ -1367,14 +1359,6 @@ static void umc_dump_misc_regs(struct amd64_pvt *pvt) edac_dbg(1, "UMC%d x16 DIMMs present: %s\n", i, (umc->dimm_cfg & BIT(7)) ? "yes" : "no"); - if (umc->dram_type == MEM_LRDDR4 || umc->dram_type == MEM_LRDDR5) { - amd_smn_read(pvt->mc_node_id, - umc_base + get_umc_reg(pvt, UMCCH_ADDR_CFG), - &tmp); - edac_dbg(1, "UMC%d LRDIMM %dx rank multiply\n", - i, 1 << ((tmp >> 4) & 0x3)); - } - umc_debug_display_dimm_sizes(pvt, i); } } diff --git a/drivers/edac/amd64_edac.h b/drivers/edac/amd64_edac.h index b879b12971e7..17228d07de4c 100644 --- a/drivers/edac/amd64_edac.h +++ b/drivers/edac/amd64_edac.h @@ -256,15 +256,11 @@ #define UMCCH_ADDR_MASK 0x20 #define UMCCH_ADDR_MASK_SEC 0x28 #define UMCCH_ADDR_MASK_SEC_DDR5 0x30 -#define UMCCH_ADDR_CFG 0x30 -#define UMCCH_ADDR_CFG_DDR5 0x40 #define UMCCH_DIMM_CFG 0x80 #define UMCCH_DIMM_CFG_DDR5 0x90 #define UMCCH_UMC_CFG 0x100 #define UMCCH_SDP_CTRL 0x104 #define UMCCH_ECC_CTRL 0x14C -#define UMCCH_ECC_BAD_SYMBOL 0xD90 -#define UMCCH_UMC_CAP 0xDF0 #define UMCCH_UMC_CAP_HI 0xDF4 /* UMC CH bitfields */ From patchwork Thu May 23 18:26:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 13672155 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2076.outbound.protection.outlook.com [40.107.101.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C36C328B6; Thu, 23 May 2024 18:27:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.101.76 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716488835; cv=fail; b=dJ/dojilbB2NnYY0hgDSAm2P1WHKGpT7XbxSf4F7NITjqyS0KjtwxMqsKprSouhnHjUhtfvSph4ZSoIaynFiR1AIiDGCFIRnSja/WGwTZIgAOtDYaMEHHIg/jV5Z5Zldd0S89I941mVmf/27pbLJcYIFFPLLVqM/NTJ2eBCA+0M= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716488835; c=relaxed/simple; bh=wwYqJWUS+KYhs9EtGAZZWv9VZgwoU0otfpLm+i1Ff6s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=MNodi8K+x6HLEmlUNN1lMA3DbNvMkwwLnx0daAvhyCz9DfleVsJfQImVBg7A9F+XZr7FwReTehfxh1EJ49v0cM8K7WvOHekXlmnL6Vh8LU0brdX8PG1Ziivq+1ybXIy4lxHl9uwqb5xyYsR4tpfXFRdAAdQMoA2Q9PUVczey9bA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=KkRo9wLk; arc=fail smtp.client-ip=40.107.101.76 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="KkRo9wLk" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wj6klcuIhzdQjRe4DOULpqByr7BhTEhl1ukwHdJzCKwaOeaGk+pJuObdsYOKFKd7bvIwPvRpzc0XQO0IJnqjUfjfMlchwO/D3u2EKM+c4jL/fwTThcTHw4Gm4FzZBy8XIzbPOS2a5i8xLBjMJHmZrPQqBF/EUALfrgSXjBJuEa5OHewqXsQi2nsvMD7Ja4p70M/p7qVulRd6TwXEOWxd760aKGunmYWjcHwwtszBuvnnp5CjYG9pD2p9v+YxW3f39JsBSKxG0/SYNcgmegng8OPJLlifIylLg74+qX7FqN3zxGrixL251wRaR8DhHNoc+d/BuqYtCzSMMhps3NpnQA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/OCt8Z94Wcov5itagpyaQtF99QufOLAe8Ee91JXuDAo=; b=XV8iExjpkVkur1819WVqN2LNrxWLe4nmqoVXGWLSzzb5CEAOzjsxUlnXcBs+gyCDO49Ei8USAR/nAChGdrvqllVkPNDY+epOqEq9Yv/4e7wApDGyRR4cpPCS7qTGfh48V1XBz0Jhy3mrBVDHG8EWqP9iHVZT+OflV4nDqDJsCsW918NU7oB3hjH3C1XKuKugXI5sYzyAk+DdgYQ/+rMDLTTRHPbSMz9KH7duuLEiUks6M9Q8dJXTN/p/XrGdmiEdyfym8sX6zCnOYROn5xr0BUYQNfDNqd91bRQ7s2kvBmLCecxxT3pJJlceocR2Sl2qr0netjulvB44ROH/2l8UXA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) 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=/OCt8Z94Wcov5itagpyaQtF99QufOLAe8Ee91JXuDAo=; b=KkRo9wLkNdLwTQvtFDRTwTvjblsWz0Tqymz1R04PQuDTa9eUiYeAmwSKTFbC2saqvI+OqNPiWbsi8JshmFxxPDP8HhitAwceXm9unJokaGt0K3HEX0wYn6g6++4oB2Xq1mKV0VETsbZH2KGXN1im9Hbt2vJZyTFtODrVb83Z67g= Received: from DS7PR03CA0264.namprd03.prod.outlook.com (2603:10b6:5:3b3::29) by DM3PR12MB9287.namprd12.prod.outlook.com (2603:10b6:8:1ac::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.18; Thu, 23 May 2024 18:27:11 +0000 Received: from CH3PEPF00000011.namprd21.prod.outlook.com (2603:10b6:5:3b3:cafe::21) by DS7PR03CA0264.outlook.office365.com (2603:10b6:5:3b3::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.35 via Frontend Transport; Thu, 23 May 2024 18:27:11 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH3PEPF00000011.mail.protection.outlook.com (10.167.244.116) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7633.0 via Frontend Transport; Thu, 23 May 2024 18:27:11 +0000 Received: from quartz-7b1chost.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 23 May 2024 13:27:09 -0500 From: Yazen Ghannam Date: Thu, 23 May 2024 13:26:53 -0500 Subject: [PATCH v3 2/8] EDAC/amd64: Check return value of amd_smn_read() Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240523-fix-smn-bad-read-v3-2-aa44c622de39@amd.com> References: <20240523-fix-smn-bad-read-v3-0-aa44c622de39@amd.com> In-Reply-To: <20240523-fix-smn-bad-read-v3-0-aa44c622de39@amd.com> To: Guenter Roeck , , Yazen Ghannam CC: Mario Limonciello , , , X-Mailer: b4 0.13.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PEPF00000011:EE_|DM3PR12MB9287:EE_ X-MS-Office365-Filtering-Correlation-Id: 3cf4c44a-b482-4943-e4d2-08dc7b55f61f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|36860700004|376005|1800799015|82310400017; X-Microsoft-Antispam-Message-Info: =?utf-8?q?93pZsXpSbXua2niJH4AvOW1WANwVT2h?= =?utf-8?q?YOM2m9gU/HrmxIJCMdx3CJvC4/V4WYFmEz7qrDVxGeCLfLHMSgO0G689rhwM2+9LF?= =?utf-8?q?e7KMML18e5+W5foJjWNskgK20/gn701v+bt76IVBVy2Lh85ymtpnvR1foZWmqOnd9?= =?utf-8?q?UFsB3R5soi5AhB3mN78cX2C3z30rJ6SvcZy0P8Tov7l8X4IC/LGS/2YymDCTm3lZt?= =?utf-8?q?VVV3yeCrRy67gTUB0XpQWv8sURCcJQQvizV7zX2q7FXwFA1L007enu3SQUat31gLO?= =?utf-8?q?sZSyLySFk0U2zlC7kuM7SeXIVCJFQ0D3SlKqiGXk8XhUxj9nrSv0ZPInI7Itl/4R3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utf-8?q?yxim0sjxhfb8sx/2FtU5cW5jEm5p1cPxPi4EMhTZ+sSM+EGq/jxsiS/DxYq4M5MIP?= =?utf-8?q?w7A9Un5wt0320OeYntWrIeBChDRvv/2PZxv94Gzzqrr0SYgsrbOhIsqw=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(36860700004)(376005)(1800799015)(82310400017);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2024 18:27:11.0864 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3cf4c44a-b482-4943-e4d2-08dc7b55f61f X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH3PEPF00000011.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR12MB9287 Check the return value of amd_smn_read() before saving a value. This ensures invalid values aren't saved. The struct umc instance is initialized to 0 during memory allocation. Therefore, a bad read will keep the value as 0 providing the expected Read-as-Zero behavior. Furthermore, the __must_check attribute will be added to amd_smn_read(). Therefore, this change is required to avoid compile-time warnings. Signed-off-by: Yazen Ghannam Reviewed-by: Mario Limonciello Cc: stable@vger.kernel.org --- drivers/edac/amd64_edac.c | 51 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 14 deletions(-) diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c index 4cedfb3b4cb6..e958ade6ff24 100644 --- a/drivers/edac/amd64_edac.c +++ b/drivers/edac/amd64_edac.c @@ -1436,6 +1436,7 @@ static void umc_read_base_mask(struct amd64_pvt *pvt) u32 *base, *base_sec; u32 *mask, *mask_sec; int cs, umc; + u32 tmp; for_each_umc(umc) { umc_base_reg = get_umc_base(umc) + UMCCH_BASE_ADDR; @@ -1448,13 +1449,17 @@ static void umc_read_base_mask(struct amd64_pvt *pvt) base_reg = umc_base_reg + (cs * 4); base_reg_sec = umc_base_reg_sec + (cs * 4); - if (!amd_smn_read(pvt->mc_node_id, base_reg, base)) + if (!amd_smn_read(pvt->mc_node_id, base_reg, &tmp)) { + *base = tmp; edac_dbg(0, " DCSB%d[%d]=0x%08x reg: 0x%x\n", umc, cs, *base, base_reg); + } - if (!amd_smn_read(pvt->mc_node_id, base_reg_sec, base_sec)) + if (!amd_smn_read(pvt->mc_node_id, base_reg_sec, &tmp)) { + *base_sec = tmp; edac_dbg(0, " DCSB_SEC%d[%d]=0x%08x reg: 0x%x\n", umc, cs, *base_sec, base_reg_sec); + } } umc_mask_reg = get_umc_base(umc) + UMCCH_ADDR_MASK; @@ -1467,13 +1472,17 @@ static void umc_read_base_mask(struct amd64_pvt *pvt) mask_reg = umc_mask_reg + (cs * 4); mask_reg_sec = umc_mask_reg_sec + (cs * 4); - if (!amd_smn_read(pvt->mc_node_id, mask_reg, mask)) + if (!amd_smn_read(pvt->mc_node_id, mask_reg, &tmp)) { + *mask = tmp; edac_dbg(0, " DCSM%d[%d]=0x%08x reg: 0x%x\n", umc, cs, *mask, mask_reg); + } - if (!amd_smn_read(pvt->mc_node_id, mask_reg_sec, mask_sec)) + if (!amd_smn_read(pvt->mc_node_id, mask_reg_sec, &tmp)) { + *mask_sec = tmp; edac_dbg(0, " DCSM_SEC%d[%d]=0x%08x reg: 0x%x\n", umc, cs, *mask_sec, mask_reg_sec); + } } } } @@ -2892,7 +2901,7 @@ static void umc_read_mc_regs(struct amd64_pvt *pvt) { u8 nid = pvt->mc_node_id; struct amd64_umc *umc; - u32 i, umc_base; + u32 i, tmp, umc_base; /* Read registers from each UMC */ for_each_umc(i) { @@ -2900,11 +2909,20 @@ static void umc_read_mc_regs(struct amd64_pvt *pvt) umc_base = get_umc_base(i); umc = &pvt->umc[i]; - amd_smn_read(nid, umc_base + get_umc_reg(pvt, UMCCH_DIMM_CFG), &umc->dimm_cfg); - amd_smn_read(nid, umc_base + UMCCH_UMC_CFG, &umc->umc_cfg); - amd_smn_read(nid, umc_base + UMCCH_SDP_CTRL, &umc->sdp_ctrl); - amd_smn_read(nid, umc_base + UMCCH_ECC_CTRL, &umc->ecc_ctrl); - amd_smn_read(nid, umc_base + UMCCH_UMC_CAP_HI, &umc->umc_cap_hi); + if (!amd_smn_read(nid, umc_base + get_umc_reg(pvt, UMCCH_DIMM_CFG), &tmp)) + umc->dimm_cfg = tmp; + + if (!amd_smn_read(nid, umc_base + UMCCH_UMC_CFG, &tmp)) + umc->umc_cfg = tmp; + + if (!amd_smn_read(nid, umc_base + UMCCH_SDP_CTRL, &tmp)) + umc->sdp_ctrl = tmp; + + if (!amd_smn_read(nid, umc_base + UMCCH_ECC_CTRL, &tmp)) + umc->ecc_ctrl = tmp; + + if (!amd_smn_read(nid, umc_base + UMCCH_UMC_CAP_HI, &tmp)) + umc->umc_cap_hi = tmp; } } @@ -3633,16 +3651,21 @@ static void gpu_read_mc_regs(struct amd64_pvt *pvt) { u8 nid = pvt->mc_node_id; struct amd64_umc *umc; - u32 i, umc_base; + u32 i, tmp, umc_base; /* Read registers from each UMC */ for_each_umc(i) { umc_base = gpu_get_umc_base(pvt, i, 0); umc = &pvt->umc[i]; - amd_smn_read(nid, umc_base + UMCCH_UMC_CFG, &umc->umc_cfg); - amd_smn_read(nid, umc_base + UMCCH_SDP_CTRL, &umc->sdp_ctrl); - amd_smn_read(nid, umc_base + UMCCH_ECC_CTRL, &umc->ecc_ctrl); + if (!amd_smn_read(nid, umc_base + UMCCH_UMC_CFG, &tmp)) + umc->umc_cfg = tmp; + + if (!amd_smn_read(nid, umc_base + UMCCH_SDP_CTRL, &tmp)) + umc->sdp_ctrl = tmp; + + if (!amd_smn_read(nid, umc_base + UMCCH_ECC_CTRL, &tmp)) + umc->ecc_ctrl = tmp; } } From patchwork Thu May 23 18:26:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 13672157 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2067.outbound.protection.outlook.com [40.107.220.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10BB6839F1; Thu, 23 May 2024 18:27:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.67 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716488839; cv=fail; b=QpEum1y1yZW2uhRBOClks/OJ/X+2jb3PiFwi+GSqc4zlsWV6a1LA0qRrISMFIRyNXjaItkCbFGhOZ2QRWmzbAOm4n4ehvS+1p6P4yM7G60fEvJRyzYnwoh883CAFE8u3oFOFgh4YBVjX4blmi8CE1IVB+a/g/11INwVRIRudDvY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716488839; c=relaxed/simple; bh=2gYvUh5PKw2233MexlsVSiWRL1PGFQPAhe56WcdKUdY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=GXuW1O0bE0c98QzQ/rNyVRRXO5/vY7TecytSjFOl84949nb/jrnPBdFiMtAFWVjUNPtwEzmNDndB/ZhfBI9uEitw3svNIlxsoR8Rve84dQu5l1cGUWuTVwXTzmJtoAg+qkTFsX3/8TM0KlbFT7E/AmCMJnT/BZqCVC6Yrfd5kU0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=uKySHWCV; arc=fail smtp.client-ip=40.107.220.67 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="uKySHWCV" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U6xR4SuHUprAhD9apMlrecQaP/P0xFnIQWLN7IqK1K/ge6zjL77PWoHfnm4nrfiM/xXhs8luIPkL7io0Ox10HpIz1g0+B67K1cGGxCrGlwrWPTsf6LFnGT+FhHXAZPrty2fWVCFKr66eNbELkWN+e+Ri3fUcFJcQ5dNabTP1dqttOjQM/BQ0cnLZwnSi9PHNvxzNR3C41PPY15M8gcFoQtvvczZDIk8a7Gh4yae4qGxd3VIVVZpcMmSE0SuIZt8SvhooPP/JMwK1QfuQDR9QrhhehmjePTqPmL0kyvBR1JjjyZBy6phFjWwmx6yuLP8/yW7dwS913ZQmfbg6QLuaqg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=PQMYUiQToI6bsPL5qK5LK7Ie+ErRZ5mhsBYqaRs6/bY=; b=M5Ym+qFZPCo0rVosB7tfNLs13W0uOAXJFNskKcdPP2uHcqtRW7QJo8cCkpP3doWbUY3cJ+VSnfVu2uomcy0WLFZcI2ubv38WgsLwXD6ezo68BYwSGgTfNHHqbDuy4uP9tJ/Xqu6C+0AAdHXoQpRU/BmrjT2gWoHAaBWOHSb5YkYm8PPXGh2ED+aU+QdxcMX6dZjJgnm3Ya2mtkptOcfurKCT4vlKXsMlgmsjmDBkdJ1uRA8VaYztjmTe7OLnlwyGT+qMRSf2CTrHv3JtD4HNMaVCMDWisdoRBa7Ur84Nx0qYo6l4CzIKTGuDsfyjuHR5KzrI1GzAKByGt94yY4sgiw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) 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=PQMYUiQToI6bsPL5qK5LK7Ie+ErRZ5mhsBYqaRs6/bY=; b=uKySHWCV569z7hhXvq//seSm7VQJjGmmLcbILkHBANk3FKWI6k833SCmW78h3/c3zstApvgFs1vJR8UtPVRvKgtas83BsNRQXTVAtl45XMlCNtizLj9Q857IFmMI/nz98KMIcVHFZcgCPpGkbFZX01YsHMxfzpxnEE9MF8fYNlo= Received: from DS7PR03CA0247.namprd03.prod.outlook.com (2603:10b6:5:3b3::12) by DS0PR12MB9040.namprd12.prod.outlook.com (2603:10b6:8:f5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.36; Thu, 23 May 2024 18:27:15 +0000 Received: from CH3PEPF00000011.namprd21.prod.outlook.com (2603:10b6:5:3b3:cafe::da) by DS7PR03CA0247.outlook.office365.com (2603:10b6:5:3b3::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.35 via Frontend Transport; Thu, 23 May 2024 18:27:11 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH3PEPF00000011.mail.protection.outlook.com (10.167.244.116) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7633.0 via Frontend Transport; Thu, 23 May 2024 18:27:11 +0000 Received: from quartz-7b1chost.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 23 May 2024 13:27:09 -0500 From: Yazen Ghannam Date: Thu, 23 May 2024 13:26:54 -0500 Subject: [PATCH v3 3/8] hwmon: (k10temp) Check return value of amd_smn_read() Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240523-fix-smn-bad-read-v3-3-aa44c622de39@amd.com> References: <20240523-fix-smn-bad-read-v3-0-aa44c622de39@amd.com> In-Reply-To: <20240523-fix-smn-bad-read-v3-0-aa44c622de39@amd.com> To: Guenter Roeck , , Yazen Ghannam CC: Mario Limonciello , , , X-Mailer: b4 0.13.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PEPF00000011:EE_|DS0PR12MB9040:EE_ X-MS-Office365-Filtering-Correlation-Id: 35ae8702-a0f9-4b6c-445b-08dc7b55f660 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|1800799015|36860700004|82310400017; X-Microsoft-Antispam-Message-Info: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aiJH3zrcsPsR/a1MVajp141gejS0ymaL+2treQdI2oV1?= =?utf-8?q?E/Fblr1f1TND4EudVNVMsc7dUFCodR8b+COrQPgHF/74c2AlEZXrXgi5DiMkiicCn?= =?utf-8?q?6l7eZXQwfe2WqPgdZlBDMfxK77dhw1vcMRF147wrnwwRwa82b6tW97V51xgQ+SsrZ?= =?utf-8?q?TbEaTSSeVXyd2a9Pp/ZcLjT0DwxJOEvEizppbhf9ZpkSt/zaQVBOVTd2lrvp1M0De?= =?utf-8?q?IC/e9ncwBX7Dd2pOqET0V/qDHE+CRgybLsFx0jYcSrx59mwH8k83EaoSeSnLnPivS?= =?utf-8?q?7nW0ZiUzC7W7WhI42ZGOi5ahGR3c5kZBkxyqoIZR0HHfMgBtjkc9u3rMP0PU7IJr5?= =?utf-8?q?ZEVUPI/GfR+9nMG5gWkTY8RQa0keCWkqqYNfvmCwBd8xVXD+G0m3zsuuTGTaABh9F?= =?utf-8?q?H40lwdwwg0QmxUCL0kwutsSmrkRGwyaf2a2bJJVQLAl1q0ndypT+6rspDBDmsGBu6?= =?utf-8?q?yTnNk0Ri0McS?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(376005)(1800799015)(36860700004)(82310400017);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2024 18:27:11.5083 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 35ae8702-a0f9-4b6c-445b-08dc7b55f660 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH3PEPF00000011.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB9040 Check the return value of amd_smn_read() before saving a value. This ensures invalid values aren't saved or used. There are three cases here with slightly different behavior. 1) read_tempreg_nb_zen(): This is a function pointer which does not include a return code. In this case, set the register value to 0 on failure. This enforces Read-as-Zero behavior. 2) k10temp_read_temp(): This function does have return codes, so return the error code from the failed register read. Continued operation is not necessary, since there is no valid data from the register. Furthermore, if the register value was set to 0, then the following operation would underflow. 3) k10temp_get_ccd_support(): This function reads the same register from multiple CCD instances in a loop. And a bitmask is formed if a specific bit is set in each register instance. The loop should continue on a failed register read, skipping the bit check. Furthermore, the __must_check attribute will be added to amd_smn_read(). Therefore, this change is required to avoid compile-time warnings. Signed-off-by: Yazen Ghannam Reviewed-by: Mario Limonciello Acked-by: Guenter Roeck Cc: stable@vger.kernel.org --- drivers/hwmon/k10temp.c | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/drivers/hwmon/k10temp.c b/drivers/hwmon/k10temp.c index 8092312c0a87..6cad35e7f182 100644 --- a/drivers/hwmon/k10temp.c +++ b/drivers/hwmon/k10temp.c @@ -153,8 +153,9 @@ static void read_tempreg_nb_f15(struct pci_dev *pdev, u32 *regval) static void read_tempreg_nb_zen(struct pci_dev *pdev, u32 *regval) { - amd_smn_read(amd_pci_dev_to_node_id(pdev), - ZEN_REPORTED_TEMP_CTRL_BASE, regval); + if (amd_smn_read(amd_pci_dev_to_node_id(pdev), + ZEN_REPORTED_TEMP_CTRL_BASE, regval)) + *regval = 0; } static long get_raw_temp(struct k10temp_data *data) @@ -205,6 +206,7 @@ static int k10temp_read_temp(struct device *dev, u32 attr, int channel, long *val) { struct k10temp_data *data = dev_get_drvdata(dev); + int ret = -EOPNOTSUPP; u32 regval; switch (attr) { @@ -221,13 +223,17 @@ static int k10temp_read_temp(struct device *dev, u32 attr, int channel, *val = 0; break; case 2 ... 13: /* Tccd{1-12} */ - amd_smn_read(amd_pci_dev_to_node_id(data->pdev), - ZEN_CCD_TEMP(data->ccd_offset, channel - 2), - ®val); + ret = amd_smn_read(amd_pci_dev_to_node_id(data->pdev), + ZEN_CCD_TEMP(data->ccd_offset, channel - 2), + ®val); + + if (ret) + return ret; + *val = (regval & ZEN_CCD_TEMP_MASK) * 125 - 49000; break; default: - return -EOPNOTSUPP; + return ret; } break; case hwmon_temp_max: @@ -243,7 +249,7 @@ static int k10temp_read_temp(struct device *dev, u32 attr, int channel, - ((regval >> 24) & 0xf)) * 500 + 52000; break; default: - return -EOPNOTSUPP; + return ret; } return 0; } @@ -381,8 +387,20 @@ static void k10temp_get_ccd_support(struct pci_dev *pdev, int i; for (i = 0; i < limit; i++) { - amd_smn_read(amd_pci_dev_to_node_id(pdev), - ZEN_CCD_TEMP(data->ccd_offset, i), ®val); + /* + * Ignore inaccessible CCDs. + * + * Some systems will return a register value of 0, and the TEMP_VALID + * bit check below will naturally fail. + * + * Other systems will return a PCI_ERROR_RESPONSE (0xFFFFFFFF) for + * the register value. And this will incorrectly pass the TEMP_VALID + * bit check. + */ + if (amd_smn_read(amd_pci_dev_to_node_id(pdev), + ZEN_CCD_TEMP(data->ccd_offset, i), ®val)) + continue; + if (regval & ZEN_CCD_TEMP_VALID) data->show_temp |= BIT(TCCD_BIT(i)); } From patchwork Thu May 23 18:26:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 13672161 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2077.outbound.protection.outlook.com [40.107.220.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 66C7584047; Thu, 23 May 2024 18:27:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716488842; cv=fail; b=ekpvUGI3cG6WHlm+tmurZglGuIm3aQobiJF7eFIZ6huUTt7AhExHZn829nvzNJ51XqVQ3NVxwD8Fj/iz9T9aUjSDj5OpQDY8GjOfo0W80SXH35zNmd8UbbL3llOJwp6lso5mG7sNhufT9RDawEJUGpRkIfloItXdpV69pf/i0SA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716488842; c=relaxed/simple; bh=dDTTCEV+d0iopyDJ4xM95DCs80v4QTmTcDGLuro42kc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=OFGbBnFzXp9z5U2ePC0AXy2bRc1quZlMVHA0mvPfSKAU1WJOFOXSCa5BNfKFE9uKhZ3+1yQFkJ3YRAj6IXzeYZ3QKgzO5mV077YRSuU54UFQ7YvdTVftMokYuwGvRfeQ4SxDfzIlyw0jLZoLEERWPliBx+SmnrMykbhkFwYNfXE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=uRKAIZzH; arc=fail smtp.client-ip=40.107.220.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="uRKAIZzH" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Bi6BK3JeNxytLRiZPKQVOQa9cp7mZPhZRg0ebxz46spIVR8YkYnPfTuK4ZgBnffwlA7flrqKeA/eFpeerb6D8vIynvvXw+m1VYOekr/g0BdDo9lqnD7sFAyeZQ1ACNY95J3wWh5xWGwohP01cwGAeP/5RQFz1jl41RYETVann2jqQGt02hyv3KBajgkaW/CanS/tnOTQRNwetlK9T9KjOJGT1bOg3c4fEDslfKJbVX5JPe4ZabFdhBH9sDx4lg1pUL12GixnCDFfe2deqlngFmoLmS08VOnTAV4goWCH0uwgSFIUg2aJY6sh1kFabhvGutrOojYh+o/EZ/YMEJmi0A== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=j/prkzvhX7aBUAyFTQ1Ogj1nExfxmcCLbWoU+rIQGK8=; b=jTfEYKvUUByjq+GXRWTV41QOwFy5GYuNgSLQEYU37XQqolipykIraVEt8DQdOvEQRomwxjaE7gFuEKSQOQWIrhCO4T3zFRoSiUxzBwF1Xr6jFJqshnX5SkRCeRCFrzh6S87isi8wiJ8LwUfIAp2GgS4tWNEutFzSe5UUFc2XCgv9JXlJxeVyWA6horetTsdnRGi4e1YTCkDqy4g7D2jyoRIcvCXgYVTwLQpp1jb3RgxyjsSyDFbfDxCFDnKMVqvOGAZrJ3ytKRkI/FA8Hp5Om/2cN/HjsD2OoWItP4VUHyAQso1AU4uyRhBHYFSdfj5gnFL5Bw1zZFd8H9tMB2CaEg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) 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=j/prkzvhX7aBUAyFTQ1Ogj1nExfxmcCLbWoU+rIQGK8=; b=uRKAIZzHo74xhQaZmTGOHQ+vedJL53GYmtuyC+14tjPGNgceokADGGfz9L1X9MLSOnUeOayEDg3u7OQ1jEJhXmv8P6iX4kIBwiJmnbjF2PrqXlvjWCPnlHVg415B7utOo46mfW1hsV4z0VTSAvots9txRUi8Ay6Zf9kMbBINImM= Received: from CH2PR19CA0002.namprd19.prod.outlook.com (2603:10b6:610:4d::12) by CY8PR12MB8214.namprd12.prod.outlook.com (2603:10b6:930:76::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.36; Thu, 23 May 2024 18:27:14 +0000 Received: from CH3PEPF00000012.namprd21.prod.outlook.com (2603:10b6:610:4d:cafe::15) by CH2PR19CA0002.outlook.office365.com (2603:10b6:610:4d::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.20 via Frontend Transport; Thu, 23 May 2024 18:27:13 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH3PEPF00000012.mail.protection.outlook.com (10.167.244.117) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7633.0 via Frontend Transport; Thu, 23 May 2024 18:27:13 +0000 Received: from quartz-7b1chost.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 23 May 2024 13:27:10 -0500 From: Yazen Ghannam Date: Thu, 23 May 2024 13:26:55 -0500 Subject: [PATCH v3 4/8] x86/amd_nb: Enhance SMN access error checking Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240523-fix-smn-bad-read-v3-4-aa44c622de39@amd.com> References: <20240523-fix-smn-bad-read-v3-0-aa44c622de39@amd.com> In-Reply-To: <20240523-fix-smn-bad-read-v3-0-aa44c622de39@amd.com> To: Guenter Roeck , , Yazen Ghannam CC: Mario Limonciello , , , X-Mailer: b4 0.13.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PEPF00000012:EE_|CY8PR12MB8214:EE_ X-MS-Office365-Filtering-Correlation-Id: 760bed3d-07e8-4154-5abd-08dc7b55f7ac X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|36860700004|1800799015|82310400017; X-Microsoft-Antispam-Message-Info: =?utf-8?q?iqNAvlgAAQVW9n1z5fdw2yWfGzQi146?= =?utf-8?q?xD7LctBKgeB0V5aFhTC7l6wj3Pl5PuK/Ls+JlPS/iqdFl3WCPKOQ5ZDlWsHDLY6qs?= =?utf-8?q?JHf/35SAs4f+LH7haa585aYbVEhe46XSZdtgU/inUMbrCt01O2w0ey6ps/ENK7Zau?= =?utf-8?q?rRtQZXYmLqw6DxGm680cfc9nFOuiyIUhnsZJrghcknBNfB1G1/KTR1YksiEaLZUV2?= =?utf-8?q?KN52U5/ovuiQml1FbiwUMGtj6WTuaUfvax66bNFvsmcXI+8FMDuNZKswOF06NKLji?= =?utf-8?q?TiHGJxq0ZH2R8Ql33RRuU1GRosbEtdMRYYn0ba0AdqB+YxlTkLhVl8J5nnquAnFsS?= =?utf-8?q?VZ7FB5R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wWmN/rr66DD4VEA7RWN9mNM4Rjvh0uE0minjIxyUzzRUmu8iL1xrjtyi?= =?utf-8?q?NeIOCoaTL4F0lW6GmqxFw0YPRdG77Sv4YcHFP8R4lkqC6x1KHQYMbTbWY1Q/0USeq?= =?utf-8?q?FwFPSF9lTuA8?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(376005)(36860700004)(1800799015)(82310400017);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2024 18:27:13.6847 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 760bed3d-07e8-4154-5abd-08dc7b55f7ac X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH3PEPF00000012.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB8214 AMD Zen-based systems use a System Management Network (SMN) that provides access to implementation-specific registers. SMN accesses are done indirectly through an index/data pair in PCI config space. The PCI config access may fail and return an error code. This would prevent the "read" value from being updated, and it would give an indication to the caller that the read or write operation failed. However for reads, the PCI config access may succeed, but the return value may be invalid. This is in similar fashion to PCI bad reads, i.e. return all bits set. Most systems will return 0 for SMN addresses that are not accessible. This is in line with AMD convention that unavailable registers are Read-as-Zero/Writes-Ignored. However, some systems will return a "PCI Error Response" instead. This value, along with an error code of 0 from the PCI config access, will confuse callers of the amd_smn_read() function. Check for this condition and set a proper error code for SMN reads. Furthermore, require error checking for callers of amd_smn_read() and amd_smn_write(). This is needed because many error conditions cannot be checked by these functions. Also, drop the extern keyword as it's not needed. And remove a warning that will not be trigger in many cases. Fixes: ddfe43cdc0da ("x86/amd_nb: Add SMN and Indirect Data Fabric access for AMD Fam17h") Signed-off-by: Yazen Ghannam Reviewed-by: Mario Limonciello Cc: stable@vger.kernel.org --- arch/x86/include/asm/amd_nb.h | 4 ++-- arch/x86/kernel/amd_nb.c | 46 +++++++++++++++++++++++++++++++++++++------ 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/arch/x86/include/asm/amd_nb.h b/arch/x86/include/asm/amd_nb.h index 5c37944c8a5e..6f3b6aef47ba 100644 --- a/arch/x86/include/asm/amd_nb.h +++ b/arch/x86/include/asm/amd_nb.h @@ -21,8 +21,8 @@ extern int amd_numa_init(void); extern int amd_get_subcaches(int); extern int amd_set_subcaches(int, unsigned long); -extern int amd_smn_read(u16 node, u32 address, u32 *value); -extern int amd_smn_write(u16 node, u32 address, u32 value); +int __must_check amd_smn_read(u16 node, u32 address, u32 *value); +int __must_check amd_smn_write(u16 node, u32 address, u32 value); struct amd_l3_cache { unsigned indices; diff --git a/arch/x86/kernel/amd_nb.c b/arch/x86/kernel/amd_nb.c index 3cf156f70859..d00c568e45b8 100644 --- a/arch/x86/kernel/amd_nb.c +++ b/arch/x86/kernel/amd_nb.c @@ -180,6 +180,38 @@ static struct pci_dev *next_northbridge(struct pci_dev *dev, return dev; } +/* + * SMN accesses may fail in ways that are difficult to detect here in the called + * functions smn_read() and smn_write(). Therefore, callers of these functions + * must do their own checking based on what behavior they expect. + * + * For SMN reads, the returned SMN value may be zero if the register is + * Read-as-Zero . Or it may be a "PCI Error Response", e.g. all 0xFFs. The "PCI + * Error Response" can be checked here, and a proper error code can be returned. + * But the Read-as-Zero response cannot be verified here. A value of 0 may be + * correct in some cases, so callers must check that this correct is for the + * register/fields they need. + * + * For SMN writes, success can be determined through a "write and read back" + * procedure. However, this is not robust when done here. + * + * Possible issues: + * 1) Bits that are "Write-1-to-Clear". In this case, the read value should + * *not* match the write value. + * 2) Bits that are "Read-as-Zero"/"Writes-Ignored". This information cannot be + * known here. + * 3) Bits that are "Reserved / Set to 1". Ditto above. + * + * Callers of amd_smn_write() should do the "write and read back" check themselves, + * if needed. + * + * For #1, they can see if their target bits got cleared. + * + * For #2 and #3, they can check if their target bits got set as intended. + * + * This matches what is done for rdmsr/wrmsr. As long as there's no #GP, then + * the operation is considered a success, and the caller does their own checking. + */ static int __amd_smn_rw(u16 node, u32 address, u32 *value, bool write) { struct pci_dev *root; @@ -202,9 +234,6 @@ static int __amd_smn_rw(u16 node, u32 address, u32 *value, bool write) err = (write ? pci_write_config_dword(root, 0x64, *value) : pci_read_config_dword(root, 0x64, value)); - if (err) - pr_warn("Error %s SMN address 0x%x.\n", - (write ? "writing to" : "reading from"), address); out_unlock: mutex_unlock(&smn_mutex); @@ -213,13 +242,18 @@ static int __amd_smn_rw(u16 node, u32 address, u32 *value, bool write) return err; } -int amd_smn_read(u16 node, u32 address, u32 *value) +int __must_check amd_smn_read(u16 node, u32 address, u32 *value) { - return __amd_smn_rw(node, address, value, false); + int err = __amd_smn_rw(node, address, value, false); + + if (PCI_POSSIBLE_ERROR(*value)) + err = -ENODEV; + + return err; } EXPORT_SYMBOL_GPL(amd_smn_read); -int amd_smn_write(u16 node, u32 address, u32 value) +int __must_check amd_smn_write(u16 node, u32 address, u32 value) { return __amd_smn_rw(node, address, &value, true); } From patchwork Thu May 23 18:26:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 13672160 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2060.outbound.protection.outlook.com [40.107.94.60]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D2ED883CC8; Thu, 23 May 2024 18:27:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716488841; cv=fail; b=VowdkMemTZg93FYOOFvid0jn8r5vm+riq5BrZ5REQN2kH1DY0Y+bp05YvPpba0qbdg61wbF1Ni7ARrUoofGIUUatqMg1Lo+nNXFGrb18m4IZvAA1scqm2pkPLXdpQ5mwhLvi9yZ9aaLRFuXVZN3/352/4cu5kjvYKvThHfRePDo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716488841; c=relaxed/simple; bh=wS3+mE2h5wAiqHNbd5F0/aPcPHQiIWNi1aQuBqT3Qf4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=i9zKitCVnat4xnpcbaJ1/ef3WVYZlfsvW5B+J0ZP7rBDrantQbG5r2pwZak0gXquzNRBHYVEbf0ze+m39a1GiXWaKrdfkx4tJozxyj2GiBtACkoo0FaWH7ZW82+bLoQWqcW6Md5+cYrsn94T18cSLzWJuRxIU3U2LtWBgL5FogM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=e9bwMbo8; arc=fail smtp.client-ip=40.107.94.60 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="e9bwMbo8" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Cfjno8kNge2FVbgJYiNZNhXiZqpDRvQJPezQ62W76NVnzZYQVDJkdTQ16S4iZjM6Jjf16GjkJvqlabXJinh1FyMVlotIHJJu/OPfwqbfsh9u5UCIDGXrLZYwqfxjbLc3Ohf5u6IiRrP/Uh/2Z2gTmkiZe5zWhcVTtLYPvabjgsf0roU/520qnjKJJduZEdsdC8WnFAaTVNN3vEOUon7qNTLbYVxI+dQa+p9fl/U2WsFyQznbD/8tFHrUgENg3EblhyxJCujhJb6o4okyjq/iXmEk9PbmuwIklb7WEmtWLnxd4DrimYmf7k+Y4dfpXUO350lQpNQaZt+hFPg3pAFpzw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QSVWdwBYxEnXSQDb11DLW1FrriGwziZwr5kWDaJdBUU=; b=jj/+7k7go6xrVhHdzhoCtB16C6b241CBx9n9cd7OnnU7FXv98wZDN9kwm6QIY0YL4ccS9FbLe3IC/KEZfF+DH3TTvDU5hE1tdCtQJaZeM2Qm59QQS/HfrC+da7kVihk4fzBeJmP4gAVqCExaQfYpJxY1tKE4jE8eFiLz8bQkwQAXGvLRnJDpf6JjRH4KULCMtT+rTtLtk432gutlZFrHVSy8agMPS0jk42vL/PsHO+nqhjIDSXuXnjbZgJAaRqwH+LNJ+4Tj8Hqo3iH7w8U66vwt9D4/gyGjbQtqddXpi8AqRiu70cF3QGNRiy1ArdOLedtxDIo5ukrZSiBFsvt/LQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) 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=QSVWdwBYxEnXSQDb11DLW1FrriGwziZwr5kWDaJdBUU=; b=e9bwMbo83G8VUAqlpM/7ZPOq4EtbvucpR9M6MWLQdn7Rj0OtMi4cgV9Q313TzTj4JJMVxEQHfPoC+QXCREvYDwrqtfWLvMFsXKGca4ODO3djua3r15fzj+igaWdhlDlPhgd09q9Yp8mDpUvnTFynXpr3msx8IvFEdnyBbcZM29c= Received: from DS7PR03CA0261.namprd03.prod.outlook.com (2603:10b6:5:3b3::26) by DM4PR12MB6037.namprd12.prod.outlook.com (2603:10b6:8:b0::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.19; Thu, 23 May 2024 18:27:15 +0000 Received: from CH3PEPF00000011.namprd21.prod.outlook.com (2603:10b6:5:3b3:cafe::bd) by DS7PR03CA0261.outlook.office365.com (2603:10b6:5:3b3::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.18 via Frontend Transport; Thu, 23 May 2024 18:27:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH3PEPF00000011.mail.protection.outlook.com (10.167.244.116) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7633.0 via Frontend Transport; Thu, 23 May 2024 18:27:15 +0000 Received: from quartz-7b1chost.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 23 May 2024 13:27:10 -0500 From: Yazen Ghannam Date: Thu, 23 May 2024 13:26:56 -0500 Subject: [PATCH v3 5/8] hwmon: (k10temp) Define helper function to read CCD temp Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240523-fix-smn-bad-read-v3-5-aa44c622de39@amd.com> References: <20240523-fix-smn-bad-read-v3-0-aa44c622de39@amd.com> In-Reply-To: <20240523-fix-smn-bad-read-v3-0-aa44c622de39@amd.com> To: Guenter Roeck , , Yazen Ghannam CC: Mario Limonciello , , , X-Mailer: b4 0.13.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PEPF00000011:EE_|DM4PR12MB6037:EE_ X-MS-Office365-Filtering-Correlation-Id: acf9d69c-106d-4c9e-8ccc-08dc7b55f8af X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|82310400017|36860700004|376005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?WFLbB1RniwGKb9Fz8AwtMJRnrCBEwK+?= =?utf-8?q?aUk7oCS5rVKr+wccd4hdqgdY7OVkzM/FlZ+/TxX9BZZ+MDVvHiofIS+7faMo/+CNd?= =?utf-8?q?uJ4EW3bFbouqxIFIHeNxp5iQrLG6YOOCu3yNYnRs4fJFnQ7q9Q/DhHMOxPDH/J0bE?= =?utf-8?q?SBxB03whxXprl7zjmdTTTpvNXB8M5tWB/2HKvyzlIcnUKQak3szGP/Ih6H6jclwTl?= =?utf-8?q?ZQR/nTR22bd2ffci9IztPThwU6XPAMcIC34hDzqBqO7SboXtcCuIXy3p9z8KLfj9f?= =?utf-8?q?hEYTziyykQgt7wdInGqqkmFdFhg6OIuhYnHM53ocN4/3tG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xjFcyWu7+sTzSNv?= =?utf-8?q?li2FF65Jh7FdcJoMnHyOLU2LDkdmkHkbLt5i/xC4feZPjDNfmePcskfLz0lmR2g6A?= =?utf-8?q?obPs/zcoz9q9Fx1HsFo7OHReZC3wxOztzTf+koXJmBZIAi3AG9Zn0vkE=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(1800799015)(82310400017)(36860700004)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2024 18:27:15.3833 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: acf9d69c-106d-4c9e-8ccc-08dc7b55f8af X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH3PEPF00000011.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6037 The CCD temperature register is read in two places. These reads are done using an AMD SMN access, and a number of parameters are needed for the operation. Move the SMN access and parameter gathering into a helper function in order to simply the code flow. This also has a benefit of centralizing the hardware register access in a single place in case fixes or special decoding is required. Signed-off-by: Yazen Ghannam Reviewed-by: Mario Limonciello Acked-by: Guenter Roeck --- drivers/hwmon/k10temp.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/hwmon/k10temp.c b/drivers/hwmon/k10temp.c index 6cad35e7f182..315c52de6e54 100644 --- a/drivers/hwmon/k10temp.c +++ b/drivers/hwmon/k10temp.c @@ -158,6 +158,13 @@ static void read_tempreg_nb_zen(struct pci_dev *pdev, u32 *regval) *regval = 0; } +static int read_ccd_temp_reg(struct k10temp_data *data, int ccd, u32 *regval) +{ + u16 node_id = amd_pci_dev_to_node_id(data->pdev); + + return amd_smn_read(node_id, ZEN_CCD_TEMP(data->ccd_offset, ccd), regval); +} + static long get_raw_temp(struct k10temp_data *data) { u32 regval; @@ -223,9 +230,7 @@ static int k10temp_read_temp(struct device *dev, u32 attr, int channel, *val = 0; break; case 2 ... 13: /* Tccd{1-12} */ - ret = amd_smn_read(amd_pci_dev_to_node_id(data->pdev), - ZEN_CCD_TEMP(data->ccd_offset, channel - 2), - ®val); + ret = read_ccd_temp_reg(data, channel - 2, ®val); if (ret) return ret; @@ -397,8 +402,7 @@ static void k10temp_get_ccd_support(struct pci_dev *pdev, * the register value. And this will incorrectly pass the TEMP_VALID * bit check. */ - if (amd_smn_read(amd_pci_dev_to_node_id(pdev), - ZEN_CCD_TEMP(data->ccd_offset, i), ®val)) + if (read_ccd_temp_reg(data, i, ®val)) continue; if (regval & ZEN_CCD_TEMP_VALID) From patchwork Thu May 23 18:26:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 13672158 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2076.outbound.protection.outlook.com [40.107.223.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2CF14839F4; Thu, 23 May 2024 18:27:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.76 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716488839; cv=fail; b=lMo4XQa0LxYJVbBA3Vd3dfY6MEKRVYVP5n6LeKXRSXMMik6uHiDRq4+o6HGJvn6qTAQJGakPL7iiXGjFIZF7qbPCWdVR8n+Msoax3a8C9+Q4GXUp1NLfZllnRNoJd0zWu9+UWIsRsump10aR9OVN0OXNuo+OofofLESg/fJfieI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716488839; c=relaxed/simple; bh=f6hqEN1VIsd63HVw54vGLB6GVd2Qpx/lRCj+1dUDUQc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=JTDQTM77KT1Llfxsxs77obtxa+egg/4FTPLpkZ5fQ0HlAlErpgFN6An1UBasCiLBfFmb80Y7KQYsWv7fEOWTh7sQmORJnxR6CC2M267oN+RhtewHv3RB1ncDj3G8y/PlgIlHaWnIsxGcIggQEmRIbLWxzqq3v3p6hc9l0ZSNLCs= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=5U2ZjGoB; arc=fail smtp.client-ip=40.107.223.76 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="5U2ZjGoB" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cwcYYdHGDnDUBfxZQGccEP+iF5bV40T96yeGzvBSYtIU6JwKJeJfZevMAeRVn7iPNs7vyH0Cv862wShDjNA8hYzqBwTMy1su8Wd+0cnooy/BRrsqLAHgAGNt43qEWty3dnXZPYz0qfUOs6OK1axmc8BV60ixcrre70i51Ge+Yobks6TnCg/zmYDdfVXuwZEya1xWP1gXgkT6EC+cp2RoagK0fBv01RV69zIJFxdEZWjiIBOHE4Rl63aP9/oZFMaK9rr6JjxCCwKoRlhAz8sjYeFtVkKwrmcyuFqc/Sz8uIpU/l4obJM12jj4TN0hH4KU+vzeLP4CvyTUv7OEbBhmBg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/bHFV0adVCqx/ezBMck7stOQmPqgwE41m48rs+rvyqc=; b=U6bybkYqTQjAVn61QTWG06VvTHkMH8diMTAL12AEs/MBYUUaxRU6Q+we5rWmKx6R0j0yJUBmSSYs2+LGnrnFuRGocv+pQgi2ZPiOTalK1Uf9YtI1wL8bDVGJRs90Uawlc87yqGEWGH0WWpN6l7WHeSCGSCHt/msNbzgRIPkYDVDSqxCX9nH4UPaYlCwbaCBeqhBM30KPwJP9NXSw0aqgp7WEZKOotH7Gxys+K6DUZZU0PLb8PhW0XJbaUoNC/GmowYdIzzyX6aB5wm92KrLigmt3gKWco9h34RhKDCM3gJeMWl2u6mEsHJOTAKqEEjzcO76dXO0lrBeEU0KlgATD+g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) 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=/bHFV0adVCqx/ezBMck7stOQmPqgwE41m48rs+rvyqc=; b=5U2ZjGoBLlmQrbded+2iiJUAisacMk9pgE+8rf3VMKH2hfEbgibwjT7Q3KHTCyidUu6UEK5aWmlPCkjJ+Yrts3jX3/Y5QnnQwBlAn4mRHsl6FDaMKVUws2Y3PMArjAQvvnpoHSw5mKZF7hIOTXkXrfmXFQODVlUgmzTKZUx7yhU= Received: from DS7PR03CA0266.namprd03.prod.outlook.com (2603:10b6:5:3b3::31) by SJ0PR12MB7475.namprd12.prod.outlook.com (2603:10b6:a03:48d::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.22; Thu, 23 May 2024 18:27:15 +0000 Received: from CH3PEPF00000011.namprd21.prod.outlook.com (2603:10b6:5:3b3:cafe::79) by DS7PR03CA0266.outlook.office365.com (2603:10b6:5:3b3::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.36 via Frontend Transport; Thu, 23 May 2024 18:27:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH3PEPF00000011.mail.protection.outlook.com (10.167.244.116) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7633.0 via Frontend Transport; Thu, 23 May 2024 18:27:15 +0000 Received: from quartz-7b1chost.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 23 May 2024 13:27:10 -0500 From: Yazen Ghannam Date: Thu, 23 May 2024 13:26:57 -0500 Subject: [PATCH v3 6/8] hwmon: (k10temp) Reduce k10temp_get_ccd_support() parameters Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240523-fix-smn-bad-read-v3-6-aa44c622de39@amd.com> References: <20240523-fix-smn-bad-read-v3-0-aa44c622de39@amd.com> In-Reply-To: <20240523-fix-smn-bad-read-v3-0-aa44c622de39@amd.com> To: Guenter Roeck , , Yazen Ghannam CC: Mario Limonciello , , , X-Mailer: b4 0.13.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PEPF00000011:EE_|SJ0PR12MB7475:EE_ X-MS-Office365-Filtering-Correlation-Id: ec0aeeae-b846-42d4-9ea7-08dc7b55f8e1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|82310400017|36860700004|376005|1800799015; X-Microsoft-Antispam-Message-Info: =?utf-8?q?mAAkUnyLTWX9nGmMTXyQYKPTxQDewrU?= =?utf-8?q?ZNC7s/d//4AJWVN3beeqJfRmj60wu7+bXg0JhaE5NblvAqp2bomyUrYnC+C0DxkWB?= =?utf-8?q?Rp8FJAiVcHQLTB6F/ihVOqfvlMcjTeb6+Dmq8J/pLQ+3UI/gIzyyCnN0LjIIQrsq0?= =?utf-8?q?rZQi6QUzleEsr4Uw3M5IEBfJzgW6+XzoHc9BA7pDBMWxM93nXaiOVb/x4vlzO1BOM?= =?utf-8?q?HIQ4iLLgvlRP2OyhsMQvHkHXiotjI0OAyNMZNMJdPQYV3AV1R2LEmTljgm44iJKRU?= =?utf-8?q?JBwl1CjnouZjxdg8PC2eWbNlFCXDXMcJPbjeK7p72UjphH2jsBWwpSke6qlLyeVWP?= =?utf-8?q?LZ/4lXEGD71dlqfkBimoGPYw+BaAwiEZ84ncgaeVZrXMRl0+dBKFTOXmXAvAGKd5o?= =?utf-8?q?tNkhtCJtbd/wa3CpEtjQGZPmVPRMvUih1gTFa+rbWl9ZEZT3rYQ3vRXHwj5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LM?= =?utf-8?q?9d5PPZWBM+vm?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(82310400017)(36860700004)(376005)(1800799015);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2024 18:27:15.7115 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ec0aeeae-b846-42d4-9ea7-08dc7b55f8e1 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH3PEPF00000011.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB7475 Currently, k10temp_get_ccd_support() takes as input "pdev" and "data". However, "pdev" is already included in "data". Furthermore, the "pdev" parameter is no longer used in k10temp_get_ccd_support(), since its use was moved into read_ccd_temp_reg(). Drop the "pdev" input parameter as it is no longer needed. No functional change is intended. Signed-off-by: Yazen Ghannam Reviewed-by: Mario Limonciello Acked-by: Guenter Roeck --- drivers/hwmon/k10temp.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/hwmon/k10temp.c b/drivers/hwmon/k10temp.c index 315c52de6e54..6deb272c7cef 100644 --- a/drivers/hwmon/k10temp.c +++ b/drivers/hwmon/k10temp.c @@ -385,8 +385,7 @@ static const struct hwmon_chip_info k10temp_chip_info = { .info = k10temp_info, }; -static void k10temp_get_ccd_support(struct pci_dev *pdev, - struct k10temp_data *data, int limit) +static void k10temp_get_ccd_support(struct k10temp_data *data, int limit) { u32 regval; int i; @@ -456,18 +455,18 @@ static int k10temp_probe(struct pci_dev *pdev, const struct pci_device_id *id) case 0x11: /* Zen APU */ case 0x18: /* Zen+ APU */ data->ccd_offset = 0x154; - k10temp_get_ccd_support(pdev, data, 4); + k10temp_get_ccd_support(data, 4); break; case 0x31: /* Zen2 Threadripper */ case 0x60: /* Renoir */ case 0x68: /* Lucienne */ case 0x71: /* Zen2 */ data->ccd_offset = 0x154; - k10temp_get_ccd_support(pdev, data, 8); + k10temp_get_ccd_support(data, 8); break; case 0xa0 ... 0xaf: data->ccd_offset = 0x300; - k10temp_get_ccd_support(pdev, data, 8); + k10temp_get_ccd_support(data, 8); break; } } else if (boot_cpu_data.x86 == 0x19) { @@ -481,21 +480,21 @@ static int k10temp_probe(struct pci_dev *pdev, const struct pci_device_id *id) case 0x21: /* Zen3 Ryzen Desktop */ case 0x50 ... 0x5f: /* Green Sardine */ data->ccd_offset = 0x154; - k10temp_get_ccd_support(pdev, data, 8); + k10temp_get_ccd_support(data, 8); break; case 0x40 ... 0x4f: /* Yellow Carp */ data->ccd_offset = 0x300; - k10temp_get_ccd_support(pdev, data, 8); + k10temp_get_ccd_support(data, 8); break; case 0x60 ... 0x6f: case 0x70 ... 0x7f: data->ccd_offset = 0x308; - k10temp_get_ccd_support(pdev, data, 8); + k10temp_get_ccd_support(data, 8); break; case 0x10 ... 0x1f: case 0xa0 ... 0xaf: data->ccd_offset = 0x300; - k10temp_get_ccd_support(pdev, data, 12); + k10temp_get_ccd_support(data, 12); break; } } else if (boot_cpu_data.x86 == 0x1a) { From patchwork Thu May 23 18:26:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 13672159 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2078.outbound.protection.outlook.com [40.107.223.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6ADB583A06; Thu, 23 May 2024 18:27:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.78 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716488839; cv=fail; b=QH+dyKyGQlvAXQxgL/PACplGwTQwugoA2MWgSyRwLaYkN9egC9Xe+e51560GvGUiho/ZGNwMTucvzMpMcu2fOJgT16gT16Pr8+Rj4fhk1E11mDOCUqVTw8r8P7Q5BgtULXu2U0GAriw+AOmwnQ+cTomJI89E4BJ4zqppf+KuNA8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716488839; c=relaxed/simple; bh=OiKP1+GNYSbg1+OE5L0dnBHK6al0w4Wqt/Oqdqnncso=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=i1haJ1Apxg43qHPn5wetTrw8xJaHl4jADVLyV8X6hwIrySnCNWlcmZX+cHCbvGVytg8of/bbzv7w1cvGBzf9CpPb3IYy0iFzy2n0x+Hgcy22nKDVZV06f3l/TrIURM7KN9DP+zzSN84564tzEPyJCfT7W5GOKP/3vKr2jPJJlRA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=Vn5EbSLO; arc=fail smtp.client-ip=40.107.223.78 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="Vn5EbSLO" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MVDpAj+NptLVDss+qy4RcPjliy6eAYWy9DLRY1KpG4yiJfyB5YyaZO1d3w3JKAW1kd5AQLmQeSkLYvrcZEgNt6oZbdlDW47elZFrsPRCYM9YhUyLvyYe5g4F5fuELKpa/KTyFbqYtCXN8cCZ0S/W/rxZ2qpBQPRLBPuS00fzoj0d4mso1NcKAhe0/VpQMjWtVkUAmbQqubt7aMCKTMvTkda30NTdSrB8mC5KPga0Q+MoVNMuulk/6hCS8oGGna2WKZbX7Z4xKnSUlS/oCAkwzJVr0Gk8gvh0f+ZgjvKyvIW9KJfpzM070rMM0GI5cWWMAGsL2bcFfgZkRMCMZA+aPQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1J9+2SDlidu/RlDKIHhb76jZjeYkl9ua0Ft+dX8dBC8=; b=aL2jXBUHUEiUwTAOCEXS5iijWYCMZF7G1vHWrWJ3MhzRvp63DQ826gc7BzwPnwIB1eksixyJmcSP7nQLOupIpa8jEon21oe5cz7qKrmMRdlSdv+89ozj281jFlj5Ml4JQc/cR2UWjyj59LOOy3Scxj3W9UFrGH7QxkWidsArowuFWqSTepvvqIXDd4yw+SM4UtFWXmXzR28xSIqIPQojt7wh5xjIwkidzcK6att7w29hqPJswYvBQS6zeD74cwUQbEwRQhPBfLVXreo3qFTpxgOuekGJdw4k7+AnXtAaV7DjOEfDB6UofSaV/SkVFAV2ZusaFSjIaky+63KAp0Ol/A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) 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=1J9+2SDlidu/RlDKIHhb76jZjeYkl9ua0Ft+dX8dBC8=; b=Vn5EbSLOBvFs1msWIWqu7HXNpIcYk7sbfKl2wEfQXEdDKP21jWvtwNMPlCGuQ7dulj2weSYERGvJYRlvBvjIbdBmYoF00e5AlQwSlkatCeRkNbVkqjSMRyt+vjdYBaqWYC2ssQ2zSf/2HQhcnEnJd2gWyjFtBQniKHFJsCGUExw= Received: from CH2PR19CA0025.namprd19.prod.outlook.com (2603:10b6:610:4d::35) by DM4PR12MB6231.namprd12.prod.outlook.com (2603:10b6:8:a6::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.18; Thu, 23 May 2024 18:27:16 +0000 Received: from CH3PEPF00000012.namprd21.prod.outlook.com (2603:10b6:610:4d:cafe::50) by CH2PR19CA0025.outlook.office365.com (2603:10b6:610:4d::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.20 via Frontend Transport; Thu, 23 May 2024 18:27:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH3PEPF00000012.mail.protection.outlook.com (10.167.244.117) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7633.0 via Frontend Transport; Thu, 23 May 2024 18:27:15 +0000 Received: from quartz-7b1chost.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 23 May 2024 13:27:11 -0500 From: Yazen Ghannam Date: Thu, 23 May 2024 13:26:58 -0500 Subject: [PATCH v3 7/8] hwmon: (k10temp) Remove unused HAVE_TDIE() macro Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240523-fix-smn-bad-read-v3-7-aa44c622de39@amd.com> References: <20240523-fix-smn-bad-read-v3-0-aa44c622de39@amd.com> In-Reply-To: <20240523-fix-smn-bad-read-v3-0-aa44c622de39@amd.com> To: Guenter Roeck , , Yazen Ghannam CC: Mario Limonciello , , , X-Mailer: b4 0.13.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PEPF00000012:EE_|DM4PR12MB6231:EE_ X-MS-Office365-Filtering-Correlation-Id: 0596a4e2-43a2-42b4-fc28-08dc7b55f8f2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|82310400017|376005|1800799015|36860700004; X-Microsoft-Antispam-Message-Info: =?utf-8?q?SllMPnhuFFQ9iIH3+eTTn3t5AGtyq5L?= =?utf-8?q?nAm8vuS4vuXAIYcOHBdsVDesd7J9NlPh2XtmRmgXaxHMG9ldehc8nJlgXDBSP7gKU?= =?utf-8?q?C+y3KU4b4aj60CK4BQyXL6CmU0O0PqIqUKo1DWw2HqRSIgNLiQqyJCE2XGMcf7WwD?= =?utf-8?q?ri4HhQRnGPnaKstoP1xV1tqSYuSNPfN+OvoMcgUnVSoSHYiVQTEdpdO7TqRGK7RuI?= =?utf-8?q?pT3LYdXZhLOt1USBf+ZKM4vnyU8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XczN7NpgWeWIs/w122rra2hPAuutfKkWycT7J7NU83J?= =?utf-8?q?lRm/dwEDYlQtc8mHpxlgK/MZqulHE7kBuCiTi7nht/bLGwGwGO3Thv1hmsGQVQ6r2?= =?utf-8?q?ItiXMyktmqbbebfp4/AOoIlRgiK71G/LEf1ZHS/5aTDhF1WVaDQk1h3prztHAFVq/?= =?utf-8?q?iCkPdFpe7gf4dVfSa1RwFL/ZJmrJXBUUOeeuZc9/4p9xSBr9HeisIZhitpJLmuypw?= =?utf-8?q?3hU0zw3ON9SU?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(82310400017)(376005)(1800799015)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2024 18:27:15.8253 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0596a4e2-43a2-42b4-fc28-08dc7b55f8f2 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH3PEPF00000012.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6231 ...to address the following warning: drivers/hwmon/k10temp.c:104:9: warning: macro is not used [-Wunused-macros] No functional change is intended. Signed-off-by: Yazen Ghannam Acked-by: Guenter Roeck --- drivers/hwmon/k10temp.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/hwmon/k10temp.c b/drivers/hwmon/k10temp.c index 6deb272c7cef..a2d203304533 100644 --- a/drivers/hwmon/k10temp.c +++ b/drivers/hwmon/k10temp.c @@ -101,7 +101,6 @@ struct k10temp_data { #define TCCD_BIT(x) ((x) + 2) #define HAVE_TEMP(d, channel) ((d)->show_temp & BIT(channel)) -#define HAVE_TDIE(d) HAVE_TEMP(d, TDIE_BIT) struct tctl_offset { u8 model; From patchwork Thu May 23 18:26:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 13672162 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2061.outbound.protection.outlook.com [40.107.102.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 48A3C84A24; Thu, 23 May 2024 18:27:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.102.61 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716488843; cv=fail; b=tRxNUiqEv+jpIReKjVL+CAIbYr8d1XLqjKCVGL/gJrSfQF50ppZV1HNoxl/woJKBrdgzAyrvBUsNC2q1oLC2oLUEpb/raxE7lCs8zl70BVFuyOsjIhzYQm+I4/V4qlBlIhPiCVqX3XHz9M9EFNlv0c8FOq2uv6Shj8nD1/pkbZc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716488843; c=relaxed/simple; bh=oB2R3j2lKRv63IrZ0oiRycPwUr7KbwNgetf4mRprZh8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=IYlwrJ7qQc+X2hckNYnwW2rxfOG/8Q88Dg9E+2B2ZTQ6IDdlpKyw+g4StQ7ByZ6A3FsDlD08mx9KX0Gdhcp8vipE5fobF2M6rs8hx/4mzzoRV9gYiJmdeYkmXtCppSNJtWoN2so1Kri42iG4FiTSt0wIgHaTrY7ZOLZf4O39umo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=z0V4//K0; arc=fail smtp.client-ip=40.107.102.61 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="z0V4//K0" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BbytXOeqYVKcatYuMdTXpNPqL0jQobD3899IWUJMuKauaknkAiNQlo0Pdusn2MRNEqClsE3MSkUadX/Ev8m3ra3R1xuAOGwuti8XFysC9Fj5f2Z7UtOJpY1DfpMN3tTwzr76Aqb/vuX8WX5zdd2nQ3qMqiNuRoi9bYgzQxtjGy1NVToM5KO/LOumXydi2St2ENOIA5Hc8sY27NoGGRxEeS3SDEHtiAvcLSRllRM4dcvo4BMz/UxgpbtJfjNkWBxzxjoXFq8TDSzxYSOVk0TcSDgODagPDSDss9BbhiT4Q76YlHxsZZO3IHJVgnWWxUfyG9RP+omR3GcD4kP9SJvE6Q== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sryX850tuSnxY6ts/Md6DOVM3hP9hrrQWRIrYnq0jvI=; b=Af/zDAkTUqwQm6QBwX7kHlQ4+Fm9fu8yJrcjFSKR8lAmE61a64H+7d9SSdRlaOJ79hZQ74BKpTTcZSDd2n23NVvUQ5T8sPpL6PDia0cRhQgYoAw9AJKtnNFKJGRo8U+wcWmyzsVEMjfCvU26ea4oPSENZwKEiFx+ZcG/Gh8tvXyIAy5FrDenl5FMyx1SFnowVBsb7c3cVZwQ34Jhz87HHlqEbK3cW8WKIl2s6lvIb36xjvPenDkokmZUXqiXRYCVKRqcDUbf2RohAkMReQPoNtzykedu/AN8jOgC03OOGh9DbYBWpY6T3xOAEhebcEBFg1sZgKxf0TYb4pIZB6ysvg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) 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=sryX850tuSnxY6ts/Md6DOVM3hP9hrrQWRIrYnq0jvI=; b=z0V4//K0pznn7DoSzOCS3e7vqyWElp7Sv6Jf5lPgwKFrgm9xDojzZUrlu+FTc67RlDjdM8nnKhTtk9sx7zbn39y0JTAf9PJU2iyUlCiz6M6oaeiKzPtueZ/3Ve3vC9W+8saKUy+QOxU3Oo5ErHZHV1jgoWzp8TES9SqdT1BC/8I= Received: from DS7PR03CA0260.namprd03.prod.outlook.com (2603:10b6:5:3b3::25) by SJ2PR12MB8181.namprd12.prod.outlook.com (2603:10b6:a03:4f6::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.20; Thu, 23 May 2024 18:27:17 +0000 Received: from CH3PEPF00000011.namprd21.prod.outlook.com (2603:10b6:5:3b3:cafe::36) by DS7PR03CA0260.outlook.office365.com (2603:10b6:5:3b3::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.34 via Frontend Transport; Thu, 23 May 2024 18:27:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH3PEPF00000011.mail.protection.outlook.com (10.167.244.116) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7633.0 via Frontend Transport; Thu, 23 May 2024 18:27:16 +0000 Received: from quartz-7b1chost.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 23 May 2024 13:27:11 -0500 From: Yazen Ghannam Date: Thu, 23 May 2024 13:26:59 -0500 Subject: [PATCH v3 8/8] hwmon: (k10temp) Rename _data variable Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240523-fix-smn-bad-read-v3-8-aa44c622de39@amd.com> References: <20240523-fix-smn-bad-read-v3-0-aa44c622de39@amd.com> In-Reply-To: <20240523-fix-smn-bad-read-v3-0-aa44c622de39@amd.com> To: Guenter Roeck , , Yazen Ghannam CC: Mario Limonciello , , , X-Mailer: b4 0.13.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PEPF00000011:EE_|SJ2PR12MB8181:EE_ X-MS-Office365-Filtering-Correlation-Id: 262bff4c-fc4a-4c9e-20f6-08dc7b55f986 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|36860700004|1800799015|82310400017|376005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?3vDXWbowERTUqaeMFo4tpvfxZeP5l+L?= =?utf-8?q?gXrGnSEqsNw5hlJUtSegfVQtZqut1HMDtwLOyAjgYKubdPz3cIXOXtNklrwyR8S8J?= =?utf-8?q?v6snmCDa+lsgpWWC+Gto3T9CUybMhYwnUWTYsXMJDe8f58O2t9HEcVSEBwZk0nUC6?= =?utf-8?q?qrXj4gBA9PqoSM2EjC4T75VHVlHFbiGjOMofmCYwTAJyEvqZ2Ewrz6ENm/nQtGk9x?= =?utf-8?q?buKkPgSUNAFZq3pLE8LvLwPfejwzuU3QSkPtSQT0kPNU4sLca/8Mo0exvXQsj2adx?= =?utf-8?q?2ut8AtMESpXO3yL1e2NvrSTdtvsh4Gu12RldxmAz8MGIkIzAoYvxtJAbFZdCnIpet?= =?utf-8?q?wanU+HCK/Cgkmc5aAzzDzMRvozEAvX7NxlL+ku7thB/ROQeSfFIsfsHn+vsFl9Y/S?= =?utf-8?q?FeoZwkdSqL8Z509hjtSNgbsKn85jxw9fhUHjcpGrD/j3kAjDJ1lK6FS9fDN72lgDH?= =?utf-8?q?3x45puHIbweDQAwza4xUQIEDz8L7ExC1ZNFxFVs2f69rmnllptR4ecSCYal2ptDL3?= =?utf-8?q?+c/WfXbgYyniaV61ZNYxhgswVubLzrWbvkkiI1NNOL4CrEuFdiRivqW2vG7VvJMVT?= =?utf-8?q?fks+fQgDCZF4bpwLRDb+1iGZeV100IthCE69NxkzDnnIqAhDygp7JDwdQoNsn8wG4?= =?utf-8?q?xN5AUafhotO2zyy0rnZBXNMUC6elBN0KTG1IlSUKlX/X5MFQ5LuUhnCe0NTlisL7f?= =?utf-8?q?/2SkFtD6wR3Epm+ZD8VVFpyptDeAmtrJtBnJO1trITJZC3BjopZU/RLnUS53gqbLp?= =?utf-8?q?hV5LG4Nhs3yIWBYmKStRLDTf5+99wkiLy9Sdzs7c9TYGEfRhEEXzRYGwOQNVGjaDB?= =?utf-8?q?o4OHipMocLtWzal8c5/9xS81kirMqMp4eIgDdCJR6N3EB+rAkHc0BK37+GaY98hrG?= =?utf-8?q?Vrbv/Ol89OXY+bjMUJ/f8L+BhpByYeHGrO7/NXiQS+F/lZIi5VZurwxINRl9ZoP8q?= =?utf-8?q?Zp5oeVKU2ok1equ35EvDI/gKgABkp9HwH8BZJvhaWapRfa9I5l+8fjiu3bx0rYxuA?= =?utf-8?q?xqzdCKAJ5YXxb9B6Vq057Mpoc24HZU0afLYOEiyloQtt+symSYvIfAEELXgiBQgEF?= =?utf-8?q?dfGjq+dOS5g95BfQzVX/hpXl5z9CB3nkWe3HpS4HPCsGIH2dX74MSfIs+8QmBi5qy?= =?utf-8?q?H684pm6jtLKCSehqZgW0hY1PC9l//iOMs2pZOyQmCQRCdNwDJhuAqDWxlK4+wp0UZ?= =?utf-8?q?9ikt4zHKW7ob2VocHPYv0XzCZ97ibcZcHd4HScYBti44cBELpr1MgwrQe+j1NwkUG?= =?utf-8?q?v0IR/VE9PD/Vcdze+Y5yDZpnFHezLiktFQ7GOGgqFyH4DeioC/hj6XJU5kC5KPQoJ?= =?utf-8?q?4dgQHV+Tt2oA?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(36860700004)(1800799015)(82310400017)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2024 18:27:16.7896 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 262bff4c-fc4a-4c9e-20f6-08dc7b55f986 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH3PEPF00000011.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8181 ...to address the following warning: drivers/hwmon/k10temp.c:273:47: warning: declaration shadows a variable in the global scope [-Wshadow] static umode_t k10temp_is_visible(const void *_data, ^ include/asm-generic/sections.h:36:13: note: previous declaration is here extern char _data[], _sdata[], _edata[]; No functional change is intended. Signed-off-by: Yazen Ghannam Acked-by: Guenter Roeck --- drivers/hwmon/k10temp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/k10temp.c b/drivers/hwmon/k10temp.c index a2d203304533..543526bac042 100644 --- a/drivers/hwmon/k10temp.c +++ b/drivers/hwmon/k10temp.c @@ -269,11 +269,11 @@ static int k10temp_read(struct device *dev, enum hwmon_sensor_types type, } } -static umode_t k10temp_is_visible(const void *_data, +static umode_t k10temp_is_visible(const void *drvdata, enum hwmon_sensor_types type, u32 attr, int channel) { - const struct k10temp_data *data = _data; + const struct k10temp_data *data = drvdata; struct pci_dev *pdev = data->pdev; u32 reg;