From patchwork Thu Jun 6 16:12: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: 13688763 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2077.outbound.protection.outlook.com [40.107.212.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 8E503197A85; Thu, 6 Jun 2024 16:13:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.212.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717690405; cv=fail; b=fjSIdsaOD2MMSIqo96UWj907iC8mLvyGMQIaIbgugIb1MQOLhZ7/V12n1vGyityZrR6KxmEsxF/oJ+U+wSkq/9NrJWryY33SGeNsCstdeMhm0tSOZhObE93k4hOyBhqhMT7RFrF0d+h1W6mp2r656VZtHgvUI1VU2JNZYtRRnFo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717690405; c=relaxed/simple; bh=w8/KCczhGQKcmIm4ZXAF+LWIY2sLX43W13QiFZ+B/iY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=fIVtbkagowizPYdo8s0Lrf9qoQQa2jsTBZxKT2uoaD1DTD+l4YUIxqT4igO5v/ysYqHNYBa6OfXG+xjiWNKKEmcB7LqOQ4feb5eoxLNFBpnMSm7apFSGUZ77G3upzokhpkj8XP9cfRrkVfhfvYqHqojZZOucYYXdJU5q+UZSFHY= 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=EnJFVw8j; arc=fail smtp.client-ip=40.107.212.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="EnJFVw8j" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g2o1CxVlXuRyy5APLNzTNFLM0kAdaHJEKT4EnsHBaJA6PdbV62uUlshFG17r6ciaD0+63y9EnZldwuJeytKs+RAEGqYWNZnrBCxJh4Pzl+dCgaVyOh7C+r9M4SMQOfNrD61V/B9egA1vFRcv+bpu5kRt8C027Sgd3b2SQAaVaPGp9yGfOB9fXU/da9oDafQzQp1zlLIG7+p/+8SMBfLiwlTGbOhZ1EYtCNWhC3gxYmROeirGgp+DP+CyAg9BhiBpmm0zmdGy2J2YydpxuguavrcnTowdnTo4ckseavMoGpD0+Bgf4i4bGYOX/Au90aOvIboHgPpShm6lE8qwcbiWEw== 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=JJbQ5aHkjvpM6IBklleTnILdolhhhWaT6GN/wxrHqNQ=; b=hKh0ZTyPCqWpbI+zoth5l+rMPYj8raTgug8/dtJcb4hkD+vy6dmulq0/2t9qBTwSaHcxGdJ7Rx8MOWF4Ox60zoywsSJgkr9NE0Ln/Li91U7IvFVh65YPuuChGp1bb+x2CRNOZqlZyrVubKsPIA77Ad2a6iQViWStcEd1YK5FJbkr2yiJuKdW2vw8W4j+e2rXIsYTa1HGCMXPbih/o0xGxh7JdXfE5cN6OQkHtFgHjjfLS4MkxvcZTHy9KmoYEeNcK36XS2qiwuk8hbq73m69BGAUUbQD/xLjWFBTA2lya2yZYtWGCUuCaZF4mIYr66ZQzI2TleNsrfLxxXCeuPxRpw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.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=JJbQ5aHkjvpM6IBklleTnILdolhhhWaT6GN/wxrHqNQ=; b=EnJFVw8jGJUYA1rMyuhr97sxLTse2lc81PZo5V90nTcQ6Uk62VXGvuj+lEjglp7kZOM5Cgy+Oa07pR6y35altcaLI82Z9qMX4j4JUHmnUx6LRuU6uvq5i3NV79TMeffxeAT/ZoeKHjPSfIye3uPEZhLJcH61SNuZeQzt/2ABK98= Received: from CH0PR04CA0101.namprd04.prod.outlook.com (2603:10b6:610:75::16) by MW6PR12MB8760.namprd12.prod.outlook.com (2603:10b6:303:23a::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.31; Thu, 6 Jun 2024 16:13:20 +0000 Received: from CH2PEPF00000146.namprd02.prod.outlook.com (2603:10b6:610:75:cafe::d) by CH0PR04CA0101.outlook.office365.com (2603:10b6:610:75::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7656.21 via Frontend Transport; Thu, 6 Jun 2024 16:13:20 +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 CH2PEPF00000146.mail.protection.outlook.com (10.167.244.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7633.15 via Frontend Transport; Thu, 6 Jun 2024 16:13:20 +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, 6 Jun 2024 11:13:19 -0500 From: Yazen Ghannam Date: Thu, 6 Jun 2024 11:12:54 -0500 Subject: [PATCH v4 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: <20240606-fix-smn-bad-read-v4-1-ffde21931c3f@amd.com> References: <20240606-fix-smn-bad-read-v4-0-ffde21931c3f@amd.com> In-Reply-To: <20240606-fix-smn-bad-read-v4-0-ffde21931c3f@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: CH2PEPF00000146:EE_|MW6PR12MB8760:EE_ X-MS-Office365-Filtering-Correlation-Id: 3758d8fa-7f4c-4d65-6574-08dc8643954d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|36860700004|1800799015|376005|82310400017; X-Microsoft-Antispam-Message-Info: =?utf-8?q?UyKhIRDKUHqKdqLtxk2Gfew3aQ/zLdi?= =?utf-8?q?tgMsuMOC3DkE1w3nMl9UJ1uIsq/ko2GZceOwEQZxK+gLKB0/GGzwBR5bCjrAGzz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=?utf-8?q?GCTmrTwW06ab9L0DsmqO3y06sWjpoTV0+lW+eZ06vu8vbAhWLPHefsBuWw4WPl0Yg?= =?utf-8?q?GLiK6c9wUNoLVroPuS4nJDzG97ZY1E5zb9kxaINoWXU8Q9f89F6tAxYDakPgqlr4I?= =?utf-8?q?eLGrvVIFMJvFai+QHVldrAllF8AX6RyjMPRxbb6UcNUFYfg43RRl7LLl3I+TEnDgx?= =?utf-8?q?f2NM/pnhNEYyntSiVIm9kl8RIOhHWuxWRtJ6K7jI/wksNl6sUvt7AwL2akxDiDaWK?= =?utf-8?q?zDfpIuo+PXR5v+p1RHrnUicP916h1btM6ZillZjF4tWInrzeLFw2ve0ycpNNV88js?= =?utf-8?q?AU864F1Jjo7rHSoI+lruTcDwUskqwwsrFFKpGMGQVsFvI075UKstG9KNqqgLMY/CZ?= =?utf-8?q?v1LJFrDGl01hc0/lBcMlvU97OwY5cXFuBg=3D=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)(1800799015)(376005)(82310400017);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2024 16:13:20.4794 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3758d8fa-7f4c-4d65-6574-08dc8643954d 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: CH2PEPF00000146.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW6PR12MB8760 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 --- 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 Jun 6 16:12: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: 13688764 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2070.outbound.protection.outlook.com [40.107.92.70]) (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 4DD0919938A; Thu, 6 Jun 2024 16:13:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717690407; cv=fail; b=Cewg/gpDlIl6fud2MkycGuydU2zB9YLlSocJMBMXVXNeJekQAcLEKU4hQM4D9e1kCAUKHdBa9soy2Xdyqdy5VZlGMCxf+SNT8ta6dcoRBxasYuLM26e3mX6cu/RCkrOBfAHHXWwpebKVjAnjx0/qmHqOvfg8NwEPA/7/Fp+cXl4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717690407; c=relaxed/simple; bh=LnxJPSgE0r64ML2RQm//3BfDZYpa0oAmS8jPoS2I3FE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=nYYh5kT94SqHI4R/DTWOSqPXfgvN+BPqMrDJo+mK1DKpxf3VnYRBFfqvH1x5xKD3tbq6pU9LKkbJlixileRDoh1+VQ/p8d8trXKgfhfdzIe5tguiQy3vQ+Z+uRUcqrq4Ne5ukeErGxfdT2ZF98WgyDeuOnfOqB6iN0O0eRaxKCs= 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=EIoSpYZf; arc=fail smtp.client-ip=40.107.92.70 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="EIoSpYZf" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iS7Xl/SohIBwRdQotJYbTMIfU6Vs3oqpBlPOr2D1mFgDOU7AsH86JjnWZZR3fBjy90VmWirkqfJMAm/CXdKhzBb0X23NZO2oeRG05y/qaj/zf84GEQ22YOEZM986emgHiQTtHaK5OvH8dPn8eDIbWG/lYSrubMBfVDB+tEHG/Vv8a3rZ9wvAsMUme/X2a7oFeg18YZDvpJYiDoShVU2phJjsuaJZ+dZYV6Sn755xt3Wqs/WJLtTN3Y5SKYKo9Qo2nFYm5E3NhiVhw4g6PcGYEn1q0vXH2y3Lc8c638g032kUAeeeBLV1EIyBUT8TThjOSa/iSLv3OSSYbFxM356AWA== 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=QsDZR3hzWO/VTYZ7wJbVcJ5VZEkIzXGeZnBSNwhqRPQ=; b=kgUdxV6kXBKQN9TsVL/KBFthXtMvFUTe9WVPFV05TifbgbWLy3HTrDRsf3GXzMB5/ZIDF3CNk/ha1QsP/4foILzUdezh6CmvARvU2vpVgYiqTmPiMnEZmnqB+E9HBP4s5W/MGI3hntD6qOC6y7616fvH40KSj2kVdqRSemYcl/WGJnPvpzDOZgA/dbb6jHlpsE1gBcp8I+zsidu+Xzb44w32k4+HhkfhKIIP5qiP0yjF5cPqS6V7HXHP4IQBlVoqMigXPXfcLbcW3BbmhzAM5gPjkNXtulI8p+Ebf9AXjq77B5JS2FAkkWifVI6FB3bOgwB+2cchfand8kqTEp+Q0A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.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=QsDZR3hzWO/VTYZ7wJbVcJ5VZEkIzXGeZnBSNwhqRPQ=; b=EIoSpYZflglEZzuPPNNowGv2UtgkZVWqMGDHJ/Xhr71wYY3f7Xw4y9BrWpRr/r614wdi3t6P3cyH8WtahVUmd2HelwQgXIo8WSgJsZML/ytIJPsT7hnl/ccD3dsO6i5p5pAX85S7fGulGOVq2o4fTae5CpzSj3hXHGFUADRVHAM= Received: from CH0PR04CA0091.namprd04.prod.outlook.com (2603:10b6:610:75::6) by PH7PR12MB6444.namprd12.prod.outlook.com (2603:10b6:510:1f8::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.31; Thu, 6 Jun 2024 16:13:21 +0000 Received: from CH2PEPF00000146.namprd02.prod.outlook.com (2603:10b6:610:75:cafe::bb) by CH0PR04CA0091.outlook.office365.com (2603:10b6:610:75::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7656.21 via Frontend Transport; Thu, 6 Jun 2024 16:13:21 +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 CH2PEPF00000146.mail.protection.outlook.com (10.167.244.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7633.15 via Frontend Transport; Thu, 6 Jun 2024 16:13:21 +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, 6 Jun 2024 11:13:20 -0500 From: Yazen Ghannam Date: Thu, 6 Jun 2024 11:12:55 -0500 Subject: [PATCH v4 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: <20240606-fix-smn-bad-read-v4-2-ffde21931c3f@amd.com> References: <20240606-fix-smn-bad-read-v4-0-ffde21931c3f@amd.com> In-Reply-To: <20240606-fix-smn-bad-read-v4-0-ffde21931c3f@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: CH2PEPF00000146:EE_|PH7PR12MB6444:EE_ X-MS-Office365-Filtering-Correlation-Id: 05ae1ec2-2bf1-49c8-d81d-08dc864395a0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|36860700004|82310400017|1800799015|376005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?RdFmwa/JFCeWmyaH7u0bAUl/LlthHtT?= =?utf-8?q?5sUnO8t/zRp45LjGmFnT26Jz80cH5v23isaBBXe3h0Y3isl8jQO5lxfMtiezBNhpE?= =?utf-8?q?UO8oTh0B2H9He7ska5O9Ip3BmHUu8ben1h02ltPUnL8OrhqvOWVOn1fF51O8sbu9q?= =?utf-8?q?CwxqFui0X+lN4P1ZPvkm4qiPqscpR025M5IJuevazx6W6bPGvper8Af3zsCZKVrO2?= =?utf-8?q?xnMs4pt+cqlOj2rVKRZyVrGXUeXrhn5BVwJDO3kB0nHJ5hbF/8wQMuVBo/wN8HMtM?= =?utf-8?q?CtXA03X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C6S8TlwPYRjr1JzHTX0LMIT+DQ02TAIv3aa7uiaxHMsnHy8X?= =?utf-8?q?z7H892tx5autKpYtj0g4NTyk+KXeCzlrjlBgHWwlW018odYhBtY21kyFkJ1Aa1dfV?= =?utf-8?q?6f/ydDSshkb83RpLTa88UBPCzgF7+XjVcjS0Ys9W1Tf1PRrcOkz5TD+QjN102g37E?= =?utf-8?q?z9lleZOcpuS9HZQ4ZYQyXqTQgDPm6EXsFQ=3D=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)(82310400017)(1800799015)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2024 16:13:21.0263 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 05ae1ec2-2bf1-49c8-d81d-08dc864395a0 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: CH2PEPF00000146.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6444 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 --- 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 Jun 6 16:12: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: 13688765 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2053.outbound.protection.outlook.com [40.107.244.53]) (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 7FE0D19938C; Thu, 6 Jun 2024 16:13:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.53 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717690407; cv=fail; b=MXZBaEJtSOcpXYRghghdTYAnfQeouINCPrfuPuM1/hxpND/lWinDAwyS6Y68BEweFDw/9oBGMHTHS0Eqf6/NWhopatjQUk6KeTBorZtj9K8XQ7AMiQDcPQp5ulxRLITcPHcrdcOiCGsd7e4VVFNclxXAHIccm1eDUq6mWfOMdp8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717690407; c=relaxed/simple; bh=PMQ6PBDRlaZoSnBPMlsnw249a40yN1TcPjfZBEYP530=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=QJSHO4PpEcSku/LdqNkxxzCwyUNBVtB62RN6gIUOXZmxTIAl3V3yr9BNqVudAas8jQWvuZyOK+GcM0ugNwe7OUEIV45e0tLkTF7UEGie2Gnd7+bjM1FilyQ6OCFFnYsgZZhrejJoLvxfT+dnCQ7bpuqiBhdPHhtefRsCUFfFr0A= 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=4IgLUVhq; arc=fail smtp.client-ip=40.107.244.53 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="4IgLUVhq" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ixswb4gDrWwJYSWLFCeo8LMzAevzMHz6qinFjytjaZaQIV0hcUuEM7+sPoD/OCTI2S5mdSTlE7KlFkuJqpv7SwMZLRYBWi2b6+Xnh9+K6kopCBVFduPQ7cZJ4Ai+IMuA5lznOgvS3EXL0qu9GF7HXUra8XF1hMWk2HX9ncJKBk/u0qNCuCEkayPkTzFZeePg8WJqpLeOX5GilQMIq8A/G+stZNqohB2K9AQ+E5gG5Z2HmY2Xw1F7G2W8Lz5x2NwxJDupjJOiJ5e/uZfZVffOG7aswbqSRGzgr1h4hzqTZrW6sxDSRkCM7Zng4iNdzPQk/7P+fCWiGwJEe2V1o9X5ng== 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=m3avHqH3H9cvY8+8JDGI6G5xgoIKzMDnfcPcP/x6ovs=; b=ir3ZeJ2LsdJw4D5968QHwyHqKxoq58HVTWEZOnZdPYB5om7dY6wuy/a4ubarTnakdTW4xtwMT5Qb7MKI5NIOmNDObcqsn0x3C2bR+LMiTfM/1nS4pX4c2Y0oRDynKcTxWVskgdxM30e3fsa7S7ACVH7pywZRFPzIGRTv6O3klBjKVLuQFMSXS+awTyXui5HbOZsRx5PoeKLw9eeYuBuLQ17sUR7p+HW++2TRZ92rUmiA1z7nNxCrfqpCSr9SlDOoYh6T8OqkIABNuIojZkLkUFaD+GBodB9FtIkcge69CqGpZ3m0LnVjcJg+nU2GIjttanLUtUARCDFA6Q+Z/Kzr3Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.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=m3avHqH3H9cvY8+8JDGI6G5xgoIKzMDnfcPcP/x6ovs=; b=4IgLUVhqDm42OBCGJTXPh8du8lhCDZm+PtP18RYSHoCMFIqeWg7Wc9kA862UeBYpPyJRge65PO8IxbR0EHjFFxxO6s0k9PeU4yPHEwsmcprQFMVN+bnplUMoj4FArhabj7N1ZkA0k1XUVhnPI/CpR6kXGvB2+SaxpvlOzCvGOCc= Received: from CH0PR04CA0096.namprd04.prod.outlook.com (2603:10b6:610:75::11) by IA1PR12MB8467.namprd12.prod.outlook.com (2603:10b6:208:448::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.32; Thu, 6 Jun 2024 16:13:21 +0000 Received: from CH2PEPF00000146.namprd02.prod.outlook.com (2603:10b6:610:75:cafe::66) by CH0PR04CA0096.outlook.office365.com (2603:10b6:610:75::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7656.21 via Frontend Transport; Thu, 6 Jun 2024 16:13:21 +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 CH2PEPF00000146.mail.protection.outlook.com (10.167.244.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7633.15 via Frontend Transport; Thu, 6 Jun 2024 16:13:21 +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, 6 Jun 2024 11:13:20 -0500 From: Yazen Ghannam Date: Thu, 6 Jun 2024 11:12:56 -0500 Subject: [PATCH v4 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: <20240606-fix-smn-bad-read-v4-3-ffde21931c3f@amd.com> References: <20240606-fix-smn-bad-read-v4-0-ffde21931c3f@amd.com> In-Reply-To: <20240606-fix-smn-bad-read-v4-0-ffde21931c3f@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: CH2PEPF00000146:EE_|IA1PR12MB8467:EE_ X-MS-Office365-Filtering-Correlation-Id: 08905f71-b40f-4d92-bfc0-08dc86439609 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|36860700004|376005|82310400017; X-Microsoft-Antispam-Message-Info: =?utf-8?q?UGVHZXIwzSTnsziS+pBoeECYMo7s6xz?= =?utf-8?q?h3Tn6juvrsnhT7ypnd3MurSGWr9PJsNJ+5mpvzxcIJR+5GqFlEqoG9uU5XMTPn+nE?= =?utf-8?q?uSxLoEqxKTmSKnqeWTa4LxHwZVF7T5BXVGHuDNFbpjPt1Vg+3tAodkKGTUQzFW42Y?= =?utf-8?q?FzHp8SIq4sFuq3+q81yOFn/A9jYzoh47HRb4/F2VyAloc4N1ECbQz8NdM78QxKchK?= =?utf-8?q?XqoC1/wvjsgY4Y1V/qvA6vjE8PArKYqKzEyis8xC2jgnsawvGO9tguyWu9Q1p+1ge?= =?utf-8?q?gUwvaJl3lzdcn/tlRa+wruZOMKccy+PZWKa1jsKL+E6U08zuAL7t25Z8zNgT1o9qX?= =?utf-8?q?5T1uF02sJ5c4CsZvhLbZlW3+Yu4OcX0aA06FEWGSB6NQNMa5RCDptowg/yE7Sp+P9?= =?utf-8?q?DJCNRExEOcTYT4X7uU2xQwkyqfqkuPgN7Dl9GnElzHxiRfuL60IJCTBVNLVDq+so/?= =?utf-8?q?V2/U+iIUSjrwqqqhmi6a7/2ZcygiShj6B9U21LqTLLDj1K00bpyui8jeXQ3zoWNR8?= =?utf-8?q?r3oWgRDPtasxpGaKutX6Pb1MuWjdhINI33RdIqKL6mz5asUz5oNHneCiXGGeszjsX?= =?utf-8?q?BHBT5pZ/7Y9GoXqdhodkwrYLekhVe9cElLWi7fKDimA3TiOhtyrtjlANRbqpC9suP?= =?utf-8?q?LzcooeGLiHe8rfflJ7+k8uHcjGPAkdID/l35Pn6Do1cUtGUElo0JQFDXjORgRhVK4?= =?utf-8?q?6kjivARz557I9DGohD2aHLo6j4moqA/CALn+HqjhqNquG4AydYvXh6TJk92qSpa8P?= =?utf-8?q?gf7+G5ysh9SBXloVF6ENTYm+sNptJN2qrfyx5kIFZPWzkZuuoJM2aelNSC5Qs999X?= =?utf-8?q?IQfyWbgN1v83MHN/knL2A/jjtkEmR+r3Y32G0ESWOZI0EUwhvt54kuGdZ3Ofl99jh?= =?utf-8?q?QFHxBESxeIFX36Bkuunepb2n6gj1wKCS8qcq8eQKZUA1uqI7Zu1419ZCjoA74Lp58?= =?utf-8?q?Jf7A+pjtg1vAjRYbT35XI7HUfJ4Nh2ecbXrLx+70T5kEHreRt9q/20ZXsAlQjifDl?= =?utf-8?q?0P998tQde+wjPxWg4oCzymD9sERTsVKIb2krx1IJY8SrYQdIfk9KS3Ho35BM3dwwF?= =?utf-8?q?ZBJC0D09AjAFmi8p9zjKFZwdSQllKBdi9OyWZANSHy+9YBSax9a9MI4d727vR0BF8?= =?utf-8?q?1Q3akRbT148VRZJFh+ccyPruP/vqnWlwsqfj09MVrGnynUseCUAE5ytqgEOzjwazx?= =?utf-8?q?teqslA/+cv3NB4jO/9evO01Byh6yacmIS41Z3D+4Bjl6iWyFKz6gaRaGqrOXZsdnt?= =?utf-8?q?8HVpSYItz7qUZg0KxZvW9nq36lKpV8b0g7cr/AYo3TPYqYPE4oZ/i4tfUgJWt5Hb1?= =?utf-8?q?/PB0l4upvUbuNCpO8hUrZIMZoVxL2mTiLg=3D=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)(36860700004)(376005)(82310400017);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2024 16:13:21.6982 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 08905f71-b40f-4d92-bfc0-08dc86439609 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: CH2PEPF00000146.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8467 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 --- 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 Jun 6 16:12: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: 13688766 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2054.outbound.protection.outlook.com [40.107.212.54]) (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 F0BC610E9; Thu, 6 Jun 2024 16:13:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.212.54 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717690408; cv=fail; b=kbGICGCqF4xNodYU+G3nDKCwp38jVUKZDQVVdk62HGAb1rNUMHCMwPjxEvh8QrYJyQk9kbSNaK+IXrd/6mox/7O4qKahziB3CSUzIa6At4wiSc2PpIKOLeEmPnOXcaZLp/LBN52ubaizP3rgDR2pnCLZVXQCFD++0I/3mhgYm9M= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717690408; c=relaxed/simple; bh=MUlGyB5iXHHTtsMSSIROW5lZNLnBx5a90QrI0AQfsS4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=WCli9qDZLkO+fl4g8/RO7TUCuxzpBys/L9vy1H0YUlIzUlIRKehIMG7CjnvWzlKaz5/wgjXNrvX176Nlb3zY1H7a1nSlSOCkHEwRXl0jUiYBBBx2nAfaqxKvr4LVXn53zeydP7z8dShfX4BtfHIMnrdDz36E8ki0aJchIeesjAc= 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=ftskJr1o; arc=fail smtp.client-ip=40.107.212.54 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="ftskJr1o" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iW6NDOr4fLEU+XxjWf2L8w8T7fA0RcQAk+KVAhW0w9ll578zbKUKeoWqI0rvWNlbzOY56ws27tvUdF6BxaeaPqUW37BG36T/60agocFLF0/xM1xEkIdVNx5ajsuFWnEBJTjvifT7NSXCdrqiKzbcsxcO2nBAujJALBbAhECZOtzN+xoPdXSDF33J2FPhcTyBVPGQLDKat+q4323ahWBVjrIeV5AlmB7oJlG1SA5kQ+1G+Rv9qeQ8EOoM/edZyaWCkfBnbl2/UOaQhcG+M2SzDQU1zPHGjrz91wOyvx8NQLu1jzAxkAzcT17pvQqHm6klowIeIcMNzE2bvpWkN+rA5w== 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=g5y6ygaRJmECniZ6MPfml9wCtAtf0WN9CsGo/8DeIIM=; b=DEuX/F8IA/IPjAbGifU5p9UQ4A7tY/dnA14VeHPtPMfBtIqPgR1b1uYcc1rCIb0UhFFFOd6vBAeouLc3fgsLv+itSqRkZ28sLdR1NMF1aamfysBdovJoBpxTb59FAkVHb5AL0aKJ0s/g9JS83+QvlhsBQyxLeZz6eRc2igJlhuRSCYbUCpDoHJYtQTLY9/PtaTDEejF0rOxpk+N+cch34A+x4WZ2qq1KvK3BG5hmBqa1con/ok4ObsfUXp+ocMDPurbFCqzNevNLpwZ1G1SDaiiYZLI8b67mX8pOw6fHcu/sfT0fc0mVtxxQV2pWp1sZeF5CAZZ4G66WdT8sibj9fw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.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=g5y6ygaRJmECniZ6MPfml9wCtAtf0WN9CsGo/8DeIIM=; b=ftskJr1obDADFuH3HSBQ0LnXtkySq3j/WYJe94uStEa5qnAi/EF3zFIZQ+QBFSTLSJ0O5RTntwB1nwkhnWpYCavDdKEYCAH+1fUPJxJI7f85sxdq7AVwJSb0d38BLWRVy1kWttxTiWDZbR2minsiYAfP+mBau03olw4OW+e7vZU= Received: from CH0PR04CA0110.namprd04.prod.outlook.com (2603:10b6:610:75::25) by SJ2PR12MB7920.namprd12.prod.outlook.com (2603:10b6:a03:4c6::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.24; Thu, 6 Jun 2024 16:13:22 +0000 Received: from CH2PEPF00000146.namprd02.prod.outlook.com (2603:10b6:610:75:cafe::3e) by CH0PR04CA0110.outlook.office365.com (2603:10b6:610:75::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7656.21 via Frontend Transport; Thu, 6 Jun 2024 16:13:22 +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 CH2PEPF00000146.mail.protection.outlook.com (10.167.244.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7633.15 via Frontend Transport; Thu, 6 Jun 2024 16:13:22 +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, 6 Jun 2024 11:13:20 -0500 From: Yazen Ghannam Date: Thu, 6 Jun 2024 11:12:57 -0500 Subject: [PATCH v4 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: <20240606-fix-smn-bad-read-v4-4-ffde21931c3f@amd.com> References: <20240606-fix-smn-bad-read-v4-0-ffde21931c3f@amd.com> In-Reply-To: <20240606-fix-smn-bad-read-v4-0-ffde21931c3f@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: CH2PEPF00000146:EE_|SJ2PR12MB7920:EE_ X-MS-Office365-Filtering-Correlation-Id: ec2cf8eb-2498-4adc-81de-08dc8643964c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|82310400017|1800799015|36860700004|376005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?xxP4EeKdJyAaSLQos4wk5OmFD9ItWIf?= =?utf-8?q?R1Ba9nj+40ApaeC3QQRG7NEu/U3w/ny+47cKrG+mfOWDp5sQz6KXzGJ2lMZGbve+j?= =?utf-8?q?AdKBivmbWJ6p9wtJbbiL+H0DoQ2Cuw+qgZ89uLX19N/VoO1ljfAblVi0Ip4g8A8MW?= =?utf-8?q?p4bEDNB/MZsarWQBylqwXvr9MW4XNew7M3hAJoTU9Vz5U7xtY4Qti1BLsRdYwCRQt?= =?utf-8?q?rUsVRaoPNajkczc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4q5RtgIqqErGUaxLIxsca7f0YoQLB+Biy6uEzzmuqPH5fxi8L1?= =?utf-8?q?WDcSJbZe7FAKNZEYY0CIbbbnWuUsSGwS1vqE3sNrgM0oekpKgqohP7zzwAoy23wVb?= =?utf-8?q?jQZuZYmNLBIo7+iUnjtGMJq/y6DdQyO80MJsnVbfoqbtpaqieH9nEGjYjVfWe1jIp?= =?utf-8?q?BmwVRj7wVLhicDkem7nUD5k3dFTjAmepO4cG/E3I80GTT3RK1F6T7fvSUwwIOdOfT?= =?utf-8?q?3Z/S3wBKILuSBupyEjBAg8H6THpSiIMN7Q=3D=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)(82310400017)(1800799015)(36860700004)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2024 16:13:22.1513 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ec2cf8eb-2498-4adc-81de-08dc8643964c 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: CH2PEPF00000146.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB7920 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 accesses can fail for a variety of reasons. Include code comments to describe some possible scenarios. 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 triggered in many cases. Signed-off-by: Yazen Ghannam Reviewed-by: Mario Limonciello --- arch/x86/include/asm/amd_nb.h | 4 ++-- arch/x86/kernel/amd_nb.c | 39 ++++++++++++++++++++++++++++++++++----- 2 files changed, 36 insertions(+), 7 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 027a8c7a2c9e..0616a7727898 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,7 +242,7 @@ 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) { int err = __amd_smn_rw(node, address, value, false); @@ -226,7 +255,7 @@ int amd_smn_read(u16 node, u32 address, u32 *value) } 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 Jun 6 16:12: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: 13688767 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2081.outbound.protection.outlook.com [40.107.92.81]) (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 589D219B3DB; Thu, 6 Jun 2024 16:13:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.81 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717690411; cv=fail; b=U5hfbOpYLcaZ6quRAjxgpUm7gS9zxe/hJpwbDQqx79AsCguqRNG+veT2qaN1Xu6mj9zbiAyoqJNfI4e+Qn7sGRbho6AmMAa5WwW9FrahulHU0l+nYPCDGD5LMO0RRAk78FRFbIe1aHQa/LYBB4JTKdPYcfe1/a4jSZlauXCXe/Q= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717690411; c=relaxed/simple; bh=wS3+mE2h5wAiqHNbd5F0/aPcPHQiIWNi1aQuBqT3Qf4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=pP6m2oVS6+vxBFeIihKZPxZLegKjUs1iIZVapJWPgdByOFrqqbQrIPn3ILoRlSwbg73qbGHjTV0EF8P58bJ8tWvFfCk/lpuXrndI9q3q09ISXeLpPFhSITiktEy7mHPnMYsHdf+cSIEZxnbnlvaKJgUqfEnQ4UhCWAVLRccv4WU= 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=dXRFRNAq; arc=fail smtp.client-ip=40.107.92.81 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="dXRFRNAq" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bB+f99TuKqWxqLYoovwCtNdmW9T4IRZIUju/DrYJ+KUubaAfYUFiEHmh8/3lgzsZviCykD8F5PxkS1nglf9zHQyzIm1bDQrL86GcEvSa1i7TCs+PywtL/AOCWjfQ5FMF+sagj3T2k1dvcP9/O6XVj0IL6/L5B2kus5oO+W3/R9ALsMNWP/wa1dbtABPlY0pXzRL/jk+KtV9HXrb16GF7QOAxZYaDS7V9SkCZoYWxPhaVtbMFevsSPQ5rH7jyivu/6LS+8zrbqk6A6JNaVq2uXnprC87k8ijF7MDDNesA8KhVCWJnjkBX1/s4aOblqKJILYDrDPl6LgMV1gH3f4GGDw== 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=DyaStnTPp4ll++mehWt0Z7tTgPoYUiKW3zeNhq2bPhe9/mRs4JEr/4Crc6cZnz35wjZrvywvOyWKAOLiSsT3VRVZyqc8TSlA5sOBliN6hVNuLVqfzEt7qocX+9jPfz28wkGPv/X0mahtJrEDV7e+xfdKKhC7C+oCg6xnvbMJsoJbaWL/RnxIy0OYoPH5XuW6CU7RV7D2ayDjwBOe3DBo6RRBsFs0Kv0aKzmYSF23xTlxmQ4ddXMBBxtFWsmJeNsdeUxKpwgq5WFiNrKNuOKf7Mv2pZUMtoTLTi0bWbt4XfykU8in+jZ32es7RdaIBVTMdOcADRub9QqB2awGCxNqqw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.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=dXRFRNAqC+VtpMgSqUun6o41B9p5+7v2VAnMVyVf8odHqbmAWqGh53Gc3qxH0rjhmTxPXPmZIIiLGW0JD9iX7vgym5ZyTOXkfN+RsoJDE57P9WzfSb8aPuzezp/g4E0dW9Si+KwHojfXctMD+B113gkJyZuOKM0/7b18g1D51/c= Received: from CH0PR04CA0112.namprd04.prod.outlook.com (2603:10b6:610:75::27) by CY5PR12MB9053.namprd12.prod.outlook.com (2603:10b6:930:37::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.17; Thu, 6 Jun 2024 16:13:23 +0000 Received: from CH2PEPF00000146.namprd02.prod.outlook.com (2603:10b6:610:75:cafe::2e) by CH0PR04CA0112.outlook.office365.com (2603:10b6:610:75::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7656.21 via Frontend Transport; Thu, 6 Jun 2024 16:13:23 +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 CH2PEPF00000146.mail.protection.outlook.com (10.167.244.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7633.15 via Frontend Transport; Thu, 6 Jun 2024 16:13:23 +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, 6 Jun 2024 11:13:21 -0500 From: Yazen Ghannam Date: Thu, 6 Jun 2024 11:12:58 -0500 Subject: [PATCH v4 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: <20240606-fix-smn-bad-read-v4-5-ffde21931c3f@amd.com> References: <20240606-fix-smn-bad-read-v4-0-ffde21931c3f@amd.com> In-Reply-To: <20240606-fix-smn-bad-read-v4-0-ffde21931c3f@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: CH2PEPF00000146:EE_|CY5PR12MB9053:EE_ X-MS-Office365-Filtering-Correlation-Id: e3c0f5d4-4619-45f6-18d8-08dc864396e5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|82310400017|376005|36860700004; X-Microsoft-Antispam-Message-Info: =?utf-8?q?MkXfVeutfY1GnqhqP24XQjachemFQz/?= =?utf-8?q?3rtH8pCxQb3Zj8UnXKM3lRNVQ7eLq7TbYe65ggvLfbO1F8OjrJnbqiPalU5jhNeIh?= =?utf-8?q?TMETlE/WNPXlX2VQgdUG9rnDhwEUl2k70b6Fku4n+EixxWZ/I80J0UJZD9Vdh0Fvz?= =?utf-8?q?DBorQLO/ITESM5wjrrU9QWHws+3QVVRnJ1svFtYhDWUcuTftHyL8P/MTYhblX4g3f?= =?utf-8?q?g62MMOp7yYQn31fnwXYdvf6Bs0kew/6+CBvoO+2xiZ2IJTbmT8OKz4kniZnjglxAR?= =?utf-8?q?HPjlfXdyc7RB4/hYyY5npT1LU8ArN91hFhiLJbF664uBe+SMsE9oPLYTTPxC64hYz?= =?utf-8?q?R1zYP1lpke1UAVYs4Fr34s+T0J1GEwcG9HXkLSZvv+9LKFjXxtJJn8s6LTJ8GiaF4?= =?utf-8?q?pecy+7icfZGIvFiReirE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px/839ny5O8UjMwIe0o33Wge4/xskwf?= =?utf-8?q?glBYGkGt12oJo5af40GmD46rB0YaKwThfQ=3D=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)(376005)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2024 16:13:23.1357 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e3c0f5d4-4619-45f6-18d8-08dc864396e5 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: CH2PEPF00000146.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB9053 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 Jun 6 16:12: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: 13688769 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2047.outbound.protection.outlook.com [40.107.93.47]) (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 38C3219B5A5; Thu, 6 Jun 2024 16:13:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717690413; cv=fail; b=YiBhY1z3YFdQpr5NhfU2TYdv3xXjpWM4GOfWsHRBWmtbNuEY5p12K5MWlg9s3HHy/ka9eyDlOtYjaCF1k/INmDqcaFDJr2ZZO8Z6u+kLq5DKHuIn8V7bxQAdJ5dkR7ulLKUvDIhsM8usRxSjAa9gclQQLm0MFUBoKotVlPvDCbY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717690413; c=relaxed/simple; bh=f6hqEN1VIsd63HVw54vGLB6GVd2Qpx/lRCj+1dUDUQc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=k0ZTDzr84N3fPMu9FJdiyzF6ukaw9qMdwQGj+Fb0virBl8Q0YOJYq7VyL0OyB4Bn0plw3kRyEwWn6cWCGWJ2ezWkiAQOAlavmYMa2ptfC81YtzhxEBE41Utf+ouBr4vN5vmbZ43v1qrXcOUUbkTIxrnhrQZ9kcLXequRCrdiHus= 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=uzA9cSOk; arc=fail smtp.client-ip=40.107.93.47 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="uzA9cSOk" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MOwrjDHXogRyv+5q9hOLdKWqQMwVHql4GieJLPvmJXngJd08rHXXVtlf3Ib8/7nP+BHf5nvpaZHqbNuMWD+RAaZWa898CgyAZ1mSI3snkPCj9z1QHovfiq9HwCJDZncKoVqg6D+dsbm9Ny6tE9vR/rJTU8pauCmqR7bLs8zSJ8SP+r0Euex4K7o4CwFFVKkMsE71ezX3JQMQWvvL7t7N0Uf3S2hrPEvUnRiaZud1EQs5a9EaEgsaMPKLASa6TYGZxc/3GPhWDmvv2Y80xsWwpJGxVkmINDDdeaUCRtWy0bxv+Sjpm9C9d7U55iJ9L/bvveVps6t4UC4RYzmmilp4KA== 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=GTHro1TGKiP6IKOjsNq8x8/OI7j2gWyEHdpH2CsrUBT2IvqnenzUmiauqn7ZC/PbuiyHS5e4OQsZ5RotTpKYmKWf5xB1wL5uD4u4fYvZGKaO//ndH4guRD1cFiydS5+JseHyqNcI5nS60pWuaDz/CfQWyOUnD0ExSmH0yYE4Vlonc2EWYFQU7Nb5Sd4fIrupJj4MfnvRVoy86Guvg4Jb5ZneKpsFZRcF47HcCEBA8/XRmlbPLgFDUP3IY1W5ZDBpACyBAtJmnqfK5MljP9CnQ1PBd7abivGjHVidx7Z+WO1jCHAlAH8CyoDlN9C/BrtkuWSVuLLKk/9VmE7680HMpQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.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=uzA9cSOkeRpPWC3EJnPCxluUT5q5LC9aTA2jXuX+HSdluiOEa49wyoo3JmDQvsH10BwuGKhsx5dBdRjryopKeaqU71YxV9YnqEpPdExjIXLYpwjlh9cuvUN+STYBI2ZntFNAg09I77oUxieNAWkNXEdN4JBQtK7/48U9GnP+hsg= Received: from CH0PR04CA0109.namprd04.prod.outlook.com (2603:10b6:610:75::24) by PH7PR12MB5999.namprd12.prod.outlook.com (2603:10b6:510:1db::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.22; Thu, 6 Jun 2024 16:13:28 +0000 Received: from CH2PEPF00000146.namprd02.prod.outlook.com (2603:10b6:610:75:cafe::ec) by CH0PR04CA0109.outlook.office365.com (2603:10b6:610:75::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7656.21 via Frontend Transport; Thu, 6 Jun 2024 16:13:26 +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 CH2PEPF00000146.mail.protection.outlook.com (10.167.244.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7633.15 via Frontend Transport; Thu, 6 Jun 2024 16:13:26 +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, 6 Jun 2024 11:13:21 -0500 From: Yazen Ghannam Date: Thu, 6 Jun 2024 11:12:59 -0500 Subject: [PATCH v4 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: <20240606-fix-smn-bad-read-v4-6-ffde21931c3f@amd.com> References: <20240606-fix-smn-bad-read-v4-0-ffde21931c3f@amd.com> In-Reply-To: <20240606-fix-smn-bad-read-v4-0-ffde21931c3f@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: CH2PEPF00000146:EE_|PH7PR12MB5999:EE_ X-MS-Office365-Filtering-Correlation-Id: 00b8b172-1007-4995-8b86-08dc864398fd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|82310400017|36860700004|1800799015|376005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?gP8L0D/6w596pMec3zn+0h7tR+T8W9G?= =?utf-8?q?fP6kGuqLK4h2dac53oQnatu4ykO0ZYNaMSjcW5qgAiYOLLe6Zh3Iwg7cuwrThXSZf?= =?utf-8?q?8fQVCpaA0Cqjk/SqUsm+KeOJhoZTJA5x0Sq52YzU7x2vZ3LknZxvR2c2SFXnxVYSm?= =?utf-8?q?bTeUa2onzyhi2sSnPfDRn3Ha+SVUBzuETsHtSJr1u4eDmJEcl8bNKqpwhn/+Urd9X?= =?utf-8?q?VNZDClzZe8x+y8fEMEm2J/mi+aG2Umt1Kff+D30Pq9k7ZD5mTNpWwkebC3k8gTVCU?= =?utf-8?q?KixLZrjGa4cAI+H40sVe3fY2HAO/t2V4v4XiktWbQVcsr2b9i70PTSio7U2hV+UJu?= =?utf-8?q?Td6Ie3y5jVpdg5CtsiFhY5QNb7YBQHnTfI7OncnGpIszufs6f/Vkeual0Vx5PsK7I?= =?utf-8?q?uaVlzPZ6MSafIdwipJ8TWDHOofn03H3iUWfBX6dVYsXU9VdhFx+7Gihdo8j4yYHQT?= =?utf-8?q?7oehO9UR6RN4anBbL8G/EdwPU+jZTZH56gZ4SSJNLGAu6dgd5v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efront-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)(1800799015)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2024 16:13:26.6670 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 00b8b172-1007-4995-8b86-08dc864398fd 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: CH2PEPF00000146.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5999 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 Jun 6 16:13:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 13688768 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2063.outbound.protection.outlook.com [40.107.101.63]) (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 D767719B5A3; Thu, 6 Jun 2024 16:13:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.101.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717690413; cv=fail; b=k4touC2JtjhzCXgV5MWsdVPR30JoFitG+2YCnZ6DjJ9s4mRQkpLs+OHiMjSnpTErbxQ0nr7iFd1gI4rxkceM5ze1epVZZLOCBxi5yFYXFeFiB3cAJ3xrptHnRJurzqWSNlfiAHWUEHcHm4BHuWC6+EC2x1Pv4D96BgOIIy5jveU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717690413; c=relaxed/simple; bh=HlMe0Gc3kR6Av85KHTRT5SCGGwJ2tnl78akSFegQH0o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=rHm6Xy3bWUTl6oKNpoTIscaAuRN+SxrjlydVtKvXZOvFQU5ivVKYS5SqKYeklkQbQbjG6WKRBiVlNPuKpToHejtSnK3/PyjCyl7hE/ScRo/SN+S3ROVlp9WkuA2wxsynhGv4WHCEL1NQxeT0Hp6tfXgj/gbEoDXmTT6g44JLbFs= 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=u63+BYx2; arc=fail smtp.client-ip=40.107.101.63 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="u63+BYx2" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AJ7l3BL6BinPPglZb2p5fSSSTFr7umC6dExBfMAj938v/i0FLZ/mZruxOL+num4SsUoDQ66R7Xjuvpb1ivWeWlx9E6ikW7ubNy5lc/psVQD30wf2JpFzjY0SfXKrurFydUo9l39c9z1xus+keWVBiTzWpPGBcqWnY1WQk1ekw2HKyS/qRDGZtF7ycSffFLQjkQbGTKr6kn6GOXjZzHASlXfO1BwBgQGfXrudV2+haQCr9bWB2F2uKhIQ3R8Ugx9bhfgo4LSQjHRlXGCneWdJ1bhzabJUvyV3SMoVm/J7sFPg90IOGxNxG3HDQ1PpeHBYigxkT9Ab07iakYGzaTUPEg== 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=OLPh46yqPqgF8WLaVPPxOOQvI0dGu5nvOUdYlRnGLgY=; b=FCf8dOI/3D3cRa7L4IxppfhXAuD7K5zWuJpy8p9r4v5MirS+D7uyT/y1WdsUQ2XJPQC0VTbB3mHHRB+IkHv8pudwmai/h6rS/5/NF7Hyy7zX+5Mo4iZ5ZAxp4kwS67V3HoUGOm2kroRtqNNS/di8Zm/u8PNW6fsNHomdhzQux/IWueoYxnvEbnlPUV0paM3V1Uvd7iohERofQvkuPO5tzeoO/4Yse2zT88UyyNDXOwvcRhGP9Sg1s7qxKRKc+Iv3KmTM6AWfMwZZvIOetmGQdwWXCcmH3n5RTOyGYZaBpIy4YP2v3LBtVNso/bk57sogmJFpvw5RYFIBk+d9KLiZyg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.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=OLPh46yqPqgF8WLaVPPxOOQvI0dGu5nvOUdYlRnGLgY=; b=u63+BYx2mPrP3XkkedX+KIdmYRDStLEMS0EEyRBptX1PU7t837cxiLE0bte741wQrXUVirdFx51tD94lAB0FwEv4TwKd/ToZ3NKfVG9ZyZJnlZmIS44Wl3IQ+muC3RRjW4FyC6uzp+n7QZVr2951g/V7iJP0C/CNqwBj+tovGd4= Received: from CH0PR04CA0114.namprd04.prod.outlook.com (2603:10b6:610:75::29) by DM4PR12MB8559.namprd12.prod.outlook.com (2603:10b6:8:17d::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.34; Thu, 6 Jun 2024 16:13:28 +0000 Received: from CH2PEPF00000146.namprd02.prod.outlook.com (2603:10b6:610:75:cafe::7f) by CH0PR04CA0114.outlook.office365.com (2603:10b6:610:75::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7656.20 via Frontend Transport; Thu, 6 Jun 2024 16:13:28 +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 CH2PEPF00000146.mail.protection.outlook.com (10.167.244.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7633.15 via Frontend Transport; Thu, 6 Jun 2024 16:13:28 +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, 6 Jun 2024 11:13:22 -0500 From: Yazen Ghannam Date: Thu, 6 Jun 2024 11:13:00 -0500 Subject: [PATCH v4 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: <20240606-fix-smn-bad-read-v4-7-ffde21931c3f@amd.com> References: <20240606-fix-smn-bad-read-v4-0-ffde21931c3f@amd.com> In-Reply-To: <20240606-fix-smn-bad-read-v4-0-ffde21931c3f@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: CH2PEPF00000146:EE_|DM4PR12MB8559:EE_ X-MS-Office365-Filtering-Correlation-Id: 02a87e0f-daa0-4ac1-e19c-08dc86439a16 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: =?utf-8?q?fdovAm7CNpz42CbfE1IdY/zghKfQmf4?= =?utf-8?q?npb2ICyIxkJ+Yqo9IG6HMHLxWccRypa7dLsfdnlUTZzzo3yepUc7Fg/ZrtvWFG5Ix?= =?utf-8?q?uXgCDIf5FptFMwAfP+u6Zo78A0HH5VxjOqOP6yDj5nVTjZsXHkE7/zk/2r/6+eF8l?= =?utf-8?q?dI6Xmw9CYRSygWjcAKHW914FefLH36aepbG+BajxDutlybmPr9ESH5bHrJxqzGHUR?= =?utf-8?q?CfruCDvbeaE/dnNyg4LuGdklIv9XxvCoF09N5G/3WELTj/AhDNSmYnS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DQsfU6L?= =?utf-8?q?RrPquxBb/1f4HYACU1wMNzV+UPaOABdIgWaQT2LvDOW9EKVe+8nEXvJBAsBsdzb4Z?= =?utf-8?q?/u0PLk5yn2WyJIHd9KfyBJkaQCg/PsCFnSqHXPuvStXWOG/YxnlXYd6CY1tPJvOpu?= =?utf-8?q?534YTOzs55xDaz4pQDo/e7eB9dzOhvxXbc6mBigHpk+QIk1AJHkbJTKMvK8WfW0Tl?= =?utf-8?q?I7b5/emQaGPlVmaIeD2ZxYtrHeQl/XF+uQ=3D=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)(376005)(1800799015)(36860700004)(82310400017);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2024 16:13:28.4951 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 02a87e0f-daa0-4ac1-e19c-08dc86439a16 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: CH2PEPF00000146.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB8559 ...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 Jun 6 16:13:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 13688770 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2042.outbound.protection.outlook.com [40.107.244.42]) (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 1002219CCF4; Thu, 6 Jun 2024 16:13:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.42 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717690415; cv=fail; b=KVMGbmBCkYQ81QfjA26sJbKhDu8o58AIdlotCfDEiH/gXx+/F/hRE4gX3vYUi0CjLU87REJ3pyLaRbYyoWfI2Pb58IdlKglJLoNWkH7WGFG8SS/x1wShWkhWAMkWK8AVVZqETetq0keq/kB6Hk0nW1mRPjrjGlhgRqGi7rdtIzs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717690415; c=relaxed/simple; bh=1skJ/7VJ1g2JtxqhkVli2UyaJ7oCXqXoF/P+u1FuNqw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=Q1jrs6XFn++T3GZ/POgWWo/Th4uDVJp0sO4XvKTzjzGt7Apz2B3YeRSo2fqt27O34AfLSB/AJSvY2Xdsre7+hqWua4CXhaLrdC6J87fZF/sR60wQZdjL3NVpXeVQ69d1NOyTMbd8S7pOJy6xI24i8pQMtiZavV3M8krdaxVlQYE= 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=XhNjxgb5; arc=fail smtp.client-ip=40.107.244.42 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="XhNjxgb5" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HgtVhK4IWNTFh7qnraElEebZSN3gUOCVTjELqF7TWqmvC9zHnSC8ogKcmsEdWgMj9ldduq8wH1xCpdy2EFBEsrFBcIJXXNd/pkesQTim8r1PWQGKfjEFvKFHT8CJY9fdi9oZy4MUnUa2mPCEXjiGjpUwvtgFrOfDVb8xncHRS8Ezy9sNgh7W5ft7HmpyXzXtOBWgRvEMaciFO+PUdO6MCKENZ1P0dSkYMcbB1za6rbi1lSE0xl3AnAQuv8XPKcTxrQKqQ2WbChOqeX0PQKELkcxjNz2YWhJgQeVH/aGB3VMV/L5QZUcnNsLWzjSkUXaxvRQrMDD3VHcEci+fiV+TAA== 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=UE47HnUxvTJjZSnzAEg9NHiMXdh7F1Vo3vF5L9ZH1NA=; b=Mh+yOSqj99Xws/jBf6Wzkht7ZTGACQ0GNlncMSXHH4UtTlQgSAPgCEDUjjEgjue8SsOQWaDq9u+W6ONGeKKg03YOSDqJulP3H2Iop91TaJ71MlS3ucc2swAmFGqRxYKZM5XWh4IlEVedbfA7S5rVuBWJE6aqAOMuPozfRrv4oNcZ2h54FXogKnxRf2G853pShkqNoXrVAEdhwOdH8OQjQUQDb9erJ92RGInOc8aOb7kawfqoY5iwtIBQ+NrWSh12s0fzRbnHmpaDBZtPtGpt/8sgEbKsqXLvB1Pb0auJksWsThEI2TyfFIwRQ9PzK8J4Dc8l7WaGGSf7EzE3IR0xgg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.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=UE47HnUxvTJjZSnzAEg9NHiMXdh7F1Vo3vF5L9ZH1NA=; b=XhNjxgb5YWQFYptXTbQUa6EIaA4W83ZI85e2Uy6NAa0SLJuc3m8haa24VQ07mLagZdvQ49O66RE8vyy8UGb1g3Ogp8LZjuJCbuRNCyNA1UvZzDRM8lEDJdzUr7t1SkppRuXh53/nFJrEcAlCod6fOCNPLbSefoZWN0dFTfLoEGE= Received: from CH0PR04CA0097.namprd04.prod.outlook.com (2603:10b6:610:75::12) by PH0PR12MB7813.namprd12.prod.outlook.com (2603:10b6:510:286::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.25; Thu, 6 Jun 2024 16:13:29 +0000 Received: from CH2PEPF00000146.namprd02.prod.outlook.com (2603:10b6:610:75:cafe::ec) by CH0PR04CA0097.outlook.office365.com (2603:10b6:610:75::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7656.20 via Frontend Transport; Thu, 6 Jun 2024 16:13:29 +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 CH2PEPF00000146.mail.protection.outlook.com (10.167.244.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7633.15 via Frontend Transport; Thu, 6 Jun 2024 16:13:28 +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, 6 Jun 2024 11:13:22 -0500 From: Yazen Ghannam Date: Thu, 6 Jun 2024 11:13:01 -0500 Subject: [PATCH v4 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: <20240606-fix-smn-bad-read-v4-8-ffde21931c3f@amd.com> References: <20240606-fix-smn-bad-read-v4-0-ffde21931c3f@amd.com> In-Reply-To: <20240606-fix-smn-bad-read-v4-0-ffde21931c3f@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: CH2PEPF00000146:EE_|PH0PR12MB7813:EE_ X-MS-Office365-Filtering-Correlation-Id: 3c365862-689b-4bf6-a3a2-08dc86439a59 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|36860700004|376005|82310400017; X-Microsoft-Antispam-Message-Info: =?utf-8?q?lcZ3mV3XosVk/hgCk2CqH12AuuzReVX?= =?utf-8?q?BT7IXjXK08ZbzddGsbGNwkah2Ojl72Hhf1XVRsktRsQyM8Yqkco+xD+Gi8UY4UtpF?= =?utf-8?q?QseC0PWvXjyRg+g46ocBwSjS06fHJQWHRExSzFsZq97+QLAfwrZRnsPI8FrUN5P2T?= =?utf-8?q?NNFsUOdaVlQTLL7FQMWvybru7cin2NyPbSjvymTQ5DfZGcvaAETvUIb3p9Kf3P1NP?= =?utf-8?q?OMQwpeA+r0t7tEU79eeuGJj5GcJBEkrdpCU9RT21/iRslvtz5bIxS/nXFduLdOJWh?= =?utf-8?q?56ypXY2IWDG1/uQJHFvnd/pkfv4qxyHYzIdhNQuNZ46lpxRDlg2cDDG/S1VxodgLr?= =?utf-8?q?kCnPVuw9o6nZOaPbzLnu+B4NL/y3AUvcU+DeD281nccdfYI3m5XgH1bAe6Rgnk7w7?= =?utf-8?q?1Pbz565tCEeEHCq5QywffSuyvBefbM6gl2/6dkdnZLlREZR4a+8jQE3gyq8zyjJ7C?= =?utf-8?q?dFUrPpKZo2HfSpER7yUm9wKrVBP7/NeaxUEOXP8vQ8ToC+KBJtQlFak08CSHl766s?= =?utf-8?q?SULJ2+Ef68jKsUsnAZVi665CheDpZUrTOZ2kJExgAGTot1vJG6mHde3EaC0iSiNUb?= =?utf-8?q?LcEE4HOoOdBsyGovD10nao1iJSy4O7NYWYE4CqA7oKRAMyfnRLkFBju/JDbcb/+uk?= =?utf-8?q?ybVzBmaQahmOLFfkUjuFxDB7DA/EFm/ymivsS4eY1UA05xeZDbiPU6GSi73xZaMgn?= =?utf-8?q?pn2qz5O7tv/oS1JzeBNg8BCIVkxbTcu9vG8/g8oCDFZrH5JgWnh9knRlgFpg99dki?= =?utf-8?q?MLSNCmf7CD+Sn1PHmlRvddb8Acuz8XhxLIgkza6KbJH3oVBz0xC+YjX11xOHqzGhT?= =?utf-8?q?T+xIs+Ro4gHsZ/i/cUJM9pK9z72J1iMKdzm/eLm0nqpFvGRjR7In1nX6xMwum2cCF?= =?utf-8?q?HVqehKJkYam59BRQsa0RR6mVMSUd6ypUI+YAIvbwrJfx79J5pZldze3veGW2Gjd6B?= =?utf-8?q?4YXaOpTsbE3BMjye1uS7T8mgOLp2UxTazLqZ8iQrYFjtPtPux3rhoznZcdX05+JUv?= =?utf-8?q?hh2Wxdi5hdIf3DIZS6COIqt2zbzhbEbb+1CFJ1KcOi1VcHwI/JpsvwB83at3+xcQW?= =?utf-8?q?cWgQVcX7xT4EHEMhAIuxOMhVGWiHtEgQvZDnwsJ16Qr8XzuhJDAlUFIOm1cCUJ2Px?= =?utf-8?q?PFMedtYAnSM1Xem/JHLZKZPpSkc7HO5VgnDC13/3FRxjnq9eoACt/rJVG4XkHHHQp?= =?utf-8?q?CDGkzxIOtIfRj7wvELLeHslRuHXU5siUIcCRzBnZasU2OIWg0Rn6fJvsr3vDyCYds?= =?utf-8?q?gKozj7Q7x2rGk/tftHCklOq9tWosh+7ROQa1h7lak6UUHLt7douy2IrG+m4401wyf?= =?utf-8?q?kTCxkxnNRw5uSY4VClSXFTZc9xW1Q79Rrg=3D=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)(36860700004)(376005)(82310400017);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2024 16:13:28.9483 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3c365862-689b-4bf6-a3a2-08dc86439a59 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: CH2PEPF00000146.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7813 ...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;