From patchwork Fri Dec 6 16:11: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: 13897339 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2056.outbound.protection.outlook.com [40.107.94.56]) (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 7E12217A58F; Fri, 6 Dec 2024 16:12:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.56 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733501553; cv=fail; b=c+QLf0AIFVBq0Dosns0mtwWDcVqs8PBrLm1sXaff2RSLmuh17nxQyXXdfIirh+/AYnJ+h/QTw+hPjypCcvFeXbs3DjWPVbZ+ciwN7litFj4tVKNJdRxQZNyxLi6pw+K0rVoD12MikjSu7PjraegptV7Pe73eRDEWzW85UEkSNkc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733501553; c=relaxed/simple; bh=I56KNJnRmsNXnGb0I8vbQfvcemSTdNmJ/Rrxa/niPOo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=B65D9HLIJh54ysYZkfG2YMDVZgluCTM2cwUtK5PsPxLPHr+1vzQooqdjax8T752E46VVUDGs9/r43C8Lununz22Cdq+d/k2791w4tEhTpcvK7PE9ut9FVpRQyvEz2FLZUvO1lfBPZSPRzFAnJLn25IkVGEtbb2B3lYNhicjY1Ow= 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=2+bMcH9G; arc=fail smtp.client-ip=40.107.94.56 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="2+bMcH9G" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=f9/GJU47gAbhj7z5pjCukBQiJRX9mbxY3Lt5yNBmVETts0wWsCgYZsAxjr6ZgK0qrWlvT5rBgH5RwKBX2CU7XNJ1EM95tQyezkSWEltPjt6G2bnXXw3IJF321b5/d85Vu8sOQaucYByV0j0reogDtVSbwyV+SxWKM5piH833lLWbAFwwDRXz8zx3TCbrrDWfWFevIaTDdfcuOUbfqL6NaLhzSUDKm6hilUmGuRwMSlKmA+qrW89Wu2d301q1+xP3JoGK2GfigBuZ21RTMnil5ImMERs3TU0lHtihemdS/TdepSh15+JvF+OMlNj+bvR/fQkTLgtrrzIprJ2lC+F8YA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=FRvGkcmtAsT0q0xkGgY6nJIAlFTl7ZaIcAX6OGqxuYo=; b=VY88L/v9BUALhc7C6BJc6T2INEsAbnnOZ3mvVRVYVcK6+HiGAwyk6tO3NtPaohvQ+Zrn5B+Y7S/5BuRGMPTAJDpLPm84LLHBJuUeF2Em1Ilest7aOzx7ygh8q7+XlzlmLOd0FYzNWX023Q1W1cvEj/FWKtJlPr1FTKr9u8AqAhtVy4+1j5bS5Dh90kvW1mMK98aVOxeCK0oDczFHncKhqARqerDV6k/L9kGLG6FpPF9BTPf5bCme+WsknZBvNPtf1KHuXXjXXx7yF++Q9z8Xars0FBTyMHQTVBZHdePwuKyO1QSpwKLMeghbiLp5FhTyv08E2LCEIZZA7taL7rWKuQ== 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=FRvGkcmtAsT0q0xkGgY6nJIAlFTl7ZaIcAX6OGqxuYo=; b=2+bMcH9GYe22D/3R7y771mD3VAwwt++0Dm14fVBbGPDk79jFteAi/3y5+iBfJGCyW/pO2mOktU6i+b5ZHiSgqOLcZ56uq5jf8rkIV+KO97icIly6utKzInyBwpBb42xE8SK9YXEu3DwWSUSBnNF1eh5+kisp751zuDAIIdwkut4= Received: from DS0PR17CA0023.namprd17.prod.outlook.com (2603:10b6:8:191::24) by SA1PR12MB8597.namprd12.prod.outlook.com (2603:10b6:806:251::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.19; Fri, 6 Dec 2024 16:12:26 +0000 Received: from DS1PEPF0001708E.namprd03.prod.outlook.com (2603:10b6:8:191:cafe::c0) by DS0PR17CA0023.outlook.office365.com (2603:10b6:8:191::24) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.10 via Frontend Transport; Fri, 6 Dec 2024 16:12: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 DS1PEPF0001708E.mail.protection.outlook.com (10.167.17.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Fri, 6 Dec 2024 16:12:25 +0000 Received: from purico-9eb2host.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.39; Fri, 6 Dec 2024 10:12:24 -0600 From: Yazen Ghannam To: , , Tony Luck , Mario Limonciello , "Bjorn Helgaas" , Jean Delvare , "Guenter Roeck" , Clemens Ladisch , "Shyam Sundar S K" , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Naveen Krishna Chatradhi" , Suma Hegde CC: , , , , , Borislav Petkov Subject: [PATCH v2 01/16] x86/mce/amd: Remove shared threshold bank plumbing Date: Fri, 6 Dec 2024 16:11:54 +0000 Message-ID: <20241206161210.163701-2-yazen.ghannam@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241206161210.163701-1-yazen.ghannam@amd.com> References: <20241206161210.163701-1-yazen.ghannam@amd.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.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: DS1PEPF0001708E:EE_|SA1PR12MB8597:EE_ X-MS-Office365-Filtering-Correlation-Id: a5f56297-d347-4645-5c10-08dd1610c670 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|7416014|36860700013|376014|921020; X-Microsoft-Antispam-Message-Info: mXBSBjfNZWS/4tKegDfBy6QQAVFDzpexdwIMnMGbugUp4eCcyxsVoQ/UjMi2c2ctH8HXzbvm/wFc+IhU+7fzvfU33DoKDllapG4SEwSmcXttZSuKvptKDd/lY0BkQo+yn0eAchBvxIZf5yDNF1xgDb34E+oozQojquJfwMgi5Ps7qBc5GwX70BCCH0Ct4NEXkgnjrtjz7nA4CXCa2xUt563PxKJLG55E3NSLuhflKUC9xGdu3xvax3XpHbOeASMX4NF2EbBSSj9fb2CWXt8VGLFJSFgLuRl1VolRRgzVUEJ6yVmaPP7ctudTncZ9HCrMqnvB/qiEliFqOm6s0pmUZHI6KKE+swHjNtNu32ZjCrSh/j3mKjuJZvE4/jk1WA0tQQutQT8OTr8jVkr5jnY992uA1iiQznQoTQw6mekaRPM+6Z0gKgVCBG3Q9geCeRs1hQN+BNTF5FoUVz8dQ6I7qgvVG/ca8H6X8Qma+WV6j7TZWJ+2pG3psNAAgiGVgPURNxaGEVSIZujmpDvVmNUQBpIEI36MbCcw0TW2VNpZ3LPSMDgBuN5vOWJB1PaelLED4EHTnClGQJzHu2qrh4XdAo122rZuYEb4fFILnJNSEYYe7/AsStf0bF7LfNSk+PkqUXxdK34PLqJ+qrURaWNgiUNAwBaAY8/m8AnBKJ07hCgNwW2GgNwIMqwI+aw1A2pM4GPQPqRjNN+ZMs+K3+d+YppKuwg1p9l/NzylGdVq9HP8Rbqd4aCB6azNJbgLxPYSaUibtEIHBlKoYMUzqyCmy5g1Y9zv6YoJP54qAMZq0QzpHipp31S3NgMObatKat85JlmLvEaKtqDYiZo4FT+7dIdumrBvrfVDAYEALEQXPzGS9HE5zc1nHYLYVKBU674XVft7DxPc/9d2tO+W5GqyEL69x11Ja+pKph3xpocVDnUCKdE7AHeFi/8etfoLDd4z12Nn7XD5rhypsL+2kLhlfaU4mEx1LQEEn5ljA/mQFdgXlauMPY014C8CUjc/FsBlTPKgRhMEjcYrjixbeZz9Lb6gq43cqdAaIAeEgdAwpT6bBsiyewyxxJjSFLvpJrdLOHs6hq7cDxHZxd4YTfVfsciJI/OhKKRApMVSaiCL+6dUS/j1j0zosbMpo36LeFZzLnm5A9TZBKGGZXS19kWSitx4/wruhpD0wJ0xIe9RKPp07BwY527GhTwgyiNOyeigUzFhCyJaOXk/hyijEdAbyOGVcP1wRUnPbVf5iHzc5mNIZpbZ4jbmY1CuUq5tjq05dhqHST+Zb96eLnZo4fnJwLomcukscEfNVwepb+hZNlDo7KYbuuVBq1F1jkLPbdEaQThOM+v97Yj0A5aa4BW88GfOcfvVh3X6wZDUZ9BKNKlWzhliv/jafAKXK5ZqtXlzy40CX9tZumryo+yTg8smn5NyKPA0ayyLu4jbMcsQoryNHpWNS3XFepbZscO9A3/vCRoGxyfU+Wnk79hPfHXkSw== 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:(13230040)(1800799024)(82310400026)(7416014)(36860700013)(376014)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 16:12:25.9924 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a5f56297-d347-4645-5c10-08dd1610c670 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: DS1PEPF0001708E.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8597 Legacy AMD systems include an integrated Northbridge that is represented by MCA bank 4. This is the only non-core MCA bank in legacy systems. The Northbridge is physically shared by all the CPUs within an AMD "Node". However, in practice the "shared" MCA bank can only by managed by a single CPU within that AMD Node. This is known as the "Node Base Core" (NBC). For example, only the NBC will be able to read the MCA bank 4 registers; they will be Read-as-Zero for other CPUs. Also, the MCA Thresholding interrupt will only signal the NBC; the other CPUs will not receive it. This is enforced by hardware, and it should not be managed by software. The current AMD Thresholding code attempts to deal with the "shared" MCA bank by micromanaging the bank's sysfs kobjects. However, this does not follow the intended kobject use cases. It is also fragile, and it has caused bugs in the past. Modern AMD systems do not need this shared MCA bank support, and it should not be needed on legacy systems either. Remove the shared threshold bank code. Also, move the threshold struct definitions to mce/amd.c, since they are no longer needed in amd_nb.c. Signed-off-by: Yazen Ghannam Reviewed-by: Borislav Petkov (AMD) --- Notes: Link: https://lore.kernel.org/20241023172150.659002-2-yazen.ghannam@amd.com v1->v2: * No change. arch/x86/Kconfig | 2 +- arch/x86/include/asm/amd_nb.h | 31 --------- arch/x86/kernel/cpu/mce/amd.c | 127 +++++++--------------------------- 3 files changed, 27 insertions(+), 133 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 9d7bd0ae48c4..e4e27d44dc2b 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1189,7 +1189,7 @@ config X86_MCE_INTEL config X86_MCE_AMD def_bool y prompt "AMD MCE features" - depends on X86_MCE && X86_LOCAL_APIC && AMD_NB + depends on X86_MCE && X86_LOCAL_APIC help Additional support for AMD specific MCE features such as the DRAM Error Threshold. diff --git a/arch/x86/include/asm/amd_nb.h b/arch/x86/include/asm/amd_nb.h index d0caac26533f..4f586fc699fd 100644 --- a/arch/x86/include/asm/amd_nb.h +++ b/arch/x86/include/asm/amd_nb.h @@ -4,7 +4,6 @@ #include #include -#include struct amd_nb_bus_dev_range { u8 bus; @@ -29,41 +28,11 @@ struct amd_l3_cache { u8 subcaches[4]; }; -struct threshold_block { - unsigned int block; /* Number within bank */ - unsigned int bank; /* MCA bank the block belongs to */ - unsigned int cpu; /* CPU which controls MCA bank */ - u32 address; /* MSR address for the block */ - u16 interrupt_enable; /* Enable/Disable APIC interrupt */ - bool interrupt_capable; /* Bank can generate an interrupt. */ - - u16 threshold_limit; /* - * Value upon which threshold - * interrupt is generated. - */ - - struct kobject kobj; /* sysfs object */ - struct list_head miscj; /* - * List of threshold blocks - * within a bank. - */ -}; - -struct threshold_bank { - struct kobject *kobj; - struct threshold_block *blocks; - - /* initialized to the number of CPUs on the node sharing this bank */ - refcount_t cpus; - unsigned int shared; -}; - struct amd_northbridge { struct pci_dev *root; struct pci_dev *misc; struct pci_dev *link; struct amd_l3_cache l3_cache; - struct threshold_bank *bank4; }; struct amd_northbridge_info { diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index 6ca80fff1fea..0cbc56c68c8a 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -4,8 +4,6 @@ * * Written by Jacob Shin - AMD, Inc. * Maintained by: Borislav Petkov - * - * All MC4_MISCi registers are shared between cores on a node. */ #include #include @@ -20,7 +18,6 @@ #include #include -#include #include #include #include @@ -221,6 +218,32 @@ static const struct smca_hwid smca_hwid_mcatypes[] = { #define MAX_MCATYPE_NAME_LEN 30 static char buf_mcatype[MAX_MCATYPE_NAME_LEN]; +struct threshold_block { + /* This block's number within its bank. */ + unsigned int block; + /* MCA bank number that contains this block. */ + unsigned int bank; + /* CPU which controls this block's MCA bank. */ + unsigned int cpu; + /* MCA_MISC MSR address for this block. */ + u32 address; + /* Enable/Disable APIC interrupt. */ + bool interrupt_enable; + /* Bank can generate an interrupt. */ + bool interrupt_capable; + /* Value upon which threshold interrupt is generated. */ + u16 threshold_limit; + /* sysfs object */ + struct kobject kobj; + /* List of threshold blocks within this block's MCA bank. */ + struct list_head miscj; +}; + +struct threshold_bank { + struct kobject *kobj; + struct threshold_block *blocks; +}; + static DEFINE_PER_CPU(struct threshold_bank **, threshold_banks); /* @@ -333,19 +356,6 @@ struct thresh_restart { u16 old_limit; }; -static inline bool is_shared_bank(int bank) -{ - /* - * Scalable MCA provides for only one core to have access to the MSRs of - * a shared bank. - */ - if (mce_flags.smca) - return false; - - /* Bank 4 is for northbridge reporting and is thus shared */ - return (bank == 4); -} - static const char *bank4_names(const struct threshold_block *b) { switch (b->address) { @@ -1198,35 +1208,10 @@ static int allocate_threshold_blocks(unsigned int cpu, struct threshold_bank *tb return err; } -static int __threshold_add_blocks(struct threshold_bank *b) -{ - struct list_head *head = &b->blocks->miscj; - struct threshold_block *pos = NULL; - struct threshold_block *tmp = NULL; - int err = 0; - - err = kobject_add(&b->blocks->kobj, b->kobj, b->blocks->kobj.name); - if (err) - return err; - - list_for_each_entry_safe(pos, tmp, head, miscj) { - - err = kobject_add(&pos->kobj, b->kobj, pos->kobj.name); - if (err) { - list_for_each_entry_safe_reverse(pos, tmp, head, miscj) - kobject_del(&pos->kobj); - - return err; - } - } - return err; -} - static int threshold_create_bank(struct threshold_bank **bp, unsigned int cpu, unsigned int bank) { struct device *dev = this_cpu_read(mce_device); - struct amd_northbridge *nb = NULL; struct threshold_bank *b = NULL; const char *name = get_name(cpu, bank, NULL); int err = 0; @@ -1234,26 +1219,6 @@ static int threshold_create_bank(struct threshold_bank **bp, unsigned int cpu, if (!dev) return -ENODEV; - if (is_shared_bank(bank)) { - nb = node_to_amd_nb(topology_amd_node_id(cpu)); - - /* threshold descriptor already initialized on this node? */ - if (nb && nb->bank4) { - /* yes, use it */ - b = nb->bank4; - err = kobject_add(b->kobj, &dev->kobj, name); - if (err) - goto out; - - bp[bank] = b; - refcount_inc(&b->cpus); - - err = __threshold_add_blocks(b); - - goto out; - } - } - b = kzalloc(sizeof(struct threshold_bank), GFP_KERNEL); if (!b) { err = -ENOMEM; @@ -1267,17 +1232,6 @@ static int threshold_create_bank(struct threshold_bank **bp, unsigned int cpu, goto out_free; } - if (is_shared_bank(bank)) { - b->shared = 1; - refcount_set(&b->cpus, 1); - - /* nb is already initialized, see above */ - if (nb) { - WARN_ON(nb->bank4); - nb->bank4 = b; - } - } - err = allocate_threshold_blocks(cpu, b, bank, 0, mca_msr_reg(bank, MCA_MISC)); if (err) goto out_kobj; @@ -1310,40 +1264,11 @@ static void deallocate_threshold_blocks(struct threshold_bank *bank) kobject_put(&bank->blocks->kobj); } -static void __threshold_remove_blocks(struct threshold_bank *b) -{ - struct threshold_block *pos = NULL; - struct threshold_block *tmp = NULL; - - kobject_put(b->kobj); - - list_for_each_entry_safe(pos, tmp, &b->blocks->miscj, miscj) - kobject_put(b->kobj); -} - static void threshold_remove_bank(struct threshold_bank *bank) { - struct amd_northbridge *nb; - if (!bank->blocks) goto out_free; - if (!bank->shared) - goto out_dealloc; - - if (!refcount_dec_and_test(&bank->cpus)) { - __threshold_remove_blocks(bank); - return; - } else { - /* - * The last CPU on this node using the shared bank is going - * away, remove that bank now. - */ - nb = node_to_amd_nb(topology_amd_node_id(smp_processor_id())); - nb->bank4 = NULL; - } - -out_dealloc: deallocate_threshold_blocks(bank); out_free: From patchwork Fri Dec 6 16:11: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: 13897340 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2082.outbound.protection.outlook.com [40.107.96.82]) (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 0167420C499; Fri, 6 Dec 2024 16:12:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.82 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733501553; cv=fail; b=pgdKXRwxYejjWqpSAg1KP3HWqQgloT0zDbEi5tFicxYk/K6SAF1Rw996m59rob6o69gwsB3PML3kfjV8aO41rjBQ4yfAvw3aYw9wvLlQqBNoLQFbXEGf/Rnhhh1LcZ7M9umWOxjdtdRvlg5iFWZH75On6zyEFYtMRZc/t9S/6wU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733501553; c=relaxed/simple; bh=5Yd4gh+tqsCLFJaziDb7PnDCE1qiYJUXMonvOwQEoqo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Xn+xb2Jc0hzXK6sYHSzIVVht9Jn2n08V7Pt8ay1tgunquDFjgYZfWoo0+oh+SuYIPFW3DxLzO7z9tqQorNriL9QRxlEHb7mE9jomz2NkApuMxhch04bg1OgN4tqjpNp9AHSm34XqsqsQb38j8gEWw9DXeajjJKKsW75v5bylyMc= 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=nqVNUxtg; arc=fail smtp.client-ip=40.107.96.82 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="nqVNUxtg" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VFmuI7w0kxMlHXZbImJtHv71G+nCj0SNudigv69pFpvkF+T1hIMu/4cmIukxcpQcniku1nIJ90LoV/2hnW5nyDjKxmSdNNhob1mGW+HMgHogvkjjVpEO+tO1ICav+sq8xnXh/pBvA7aHUshHLx/bW6l3o4ocnBgmUclC93KDR42er/gR7kXYRhh1Ya2mHGO5yNepSeWOyOK6hHXC95m+yFyL7yRDQRko886BcO05lhy4GAd6Rqy5yIt7ueMDYKTXBepiJuYB+Wl3dRLxbzYCciOCwNPSBM71wEYA/OkwGgpY9/+LvwSK8fTxWwlrkmmOHtEWOVBLChsnkal6BFZFLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=Rxy0scJa0jmvC+OPAtX0lMo6y/mirVOnOMz4Fb6Ai58=; b=xFMiykP2iGlJHsnsoq5EBQcuvlr2kGrQ3EarQORxDiVx8u5+HjlTL+6/5u5nD2j6MiDKVtrND8oqvvzffqZPdhPklUg6O59S7z7fJXs3DCPZ7SR0iBLvgIjyFukVDgTbAnzWb7YzXwW+44fOVa4EkEOmGDt0EA6isH0849s3gu24ry4WjfMlq0zDQqYRPPikXJIcCAF9szTZpj1xF12fAVnLzgYpS0bFBSkl1IDPLkOVDUtpBKXieBWtM8/e5dQXfEV6QqtWjGYJBacG+6jd2RTGiQ7O5O0imdyINZdDQV1FAa8ppql+8sGn2SkXzmylncMEY8dDQKgh2CODbiBalw== 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=Rxy0scJa0jmvC+OPAtX0lMo6y/mirVOnOMz4Fb6Ai58=; b=nqVNUxtgImzQWeWCwEbVY2xmOfTDgQtHb1OYy19fu4vfl4SZ7ztp2sBJ5vU+xHj2dhjy4P064YaWLYZWyh9ao04oKGUsGFQ9i0pPXK5K8RcGNMvH2S9SP8hrNCpHQDA1GqzvTso5KQmUJzcVpdMz7rUJ6ydod5IIG52wr8z6VGo= Received: from DS0PR17CA0008.namprd17.prod.outlook.com (2603:10b6:8:191::15) by CY5PR12MB6323.namprd12.prod.outlook.com (2603:10b6:930:20::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.11; Fri, 6 Dec 2024 16:12:26 +0000 Received: from DS1PEPF0001708E.namprd03.prod.outlook.com (2603:10b6:8:191:cafe::47) by DS0PR17CA0008.outlook.office365.com (2603:10b6:8:191::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.19 via Frontend Transport; Fri, 6 Dec 2024 16:12: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 DS1PEPF0001708E.mail.protection.outlook.com (10.167.17.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Fri, 6 Dec 2024 16:12:26 +0000 Received: from purico-9eb2host.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.39; Fri, 6 Dec 2024 10:12:25 -0600 From: Yazen Ghannam To: , , Tony Luck , Mario Limonciello , "Bjorn Helgaas" , Jean Delvare , "Guenter Roeck" , Clemens Ladisch , "Shyam Sundar S K" , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Naveen Krishna Chatradhi" , Suma Hegde CC: , , , , Subject: [PATCH v2 02/16] x86/amd_nb: Restrict init function to AMD-based systems Date: Fri, 6 Dec 2024 16:11:55 +0000 Message-ID: <20241206161210.163701-3-yazen.ghannam@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241206161210.163701-1-yazen.ghannam@amd.com> References: <20241206161210.163701-1-yazen.ghannam@amd.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.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: DS1PEPF0001708E:EE_|CY5PR12MB6323:EE_ X-MS-Office365-Filtering-Correlation-Id: 0d1e842a-8d28-49ee-57eb-08dd1610c6cd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|82310400026|36860700013|921020; X-Microsoft-Antispam-Message-Info: fL9P1mo7p5/ITuPWvEjgp+6eMNwb8zG2kCH+awI9b47lDD1aplsblIC9kAnO8S/NI/59pO5bqx8sIylx0y3RaVqSM7IjO6TXHFmByNEuggr1ZeJ/1NPuLYXkPx9xY4nghAHFV2Dlu7tahqMWtv3z+bPiIhVPBp8MBp2suUeMgeb6ccWXXPIjhWTy/w99+5Fmij+v4QiyZWEwiVzXM1uJGjJRoq9iyhVT++6NAUEq1puf9UZBBK7kinrvF5KMX0FXGHRwmKUQYBYvHji2//hsqMbe4Qa/HKoZRB0ZoUCTbNtdupP6btw/qiNjbCnU2LfvxZYQCXxYWIWZYCLKGGN3eAC3mbCrujjkSpFJWu6EBzbvF67VCzxjhB15mQW6zHWTiAVlbDlwlFJd1NMqZv9gvdtq80hqIiESyYdXIL1AkX0y3+R9yK/98us4C4nb6C/7mx9g0FOqu0pi8uG25mvLUnJ4AgLSrpLSGg/QjNvTemebteTheaLauL0LLLgFiSR1i5YdA4KUi1aiGzAtrGIAC7wYO7/CF5oKYzOZzLg4o6RnMUNtbCn9j00RpGzbzU3zikChU8clHIetNBbi6nhEnByTY/M5XE6I79/1rwcEv1/pBkW1gvAzssLNCTt/9PL8G0IOipph0tz6IprTJXRLhpSUX5Imr7r41fMXfMQ6Q9zIoWNy7hiP86e9SFZTBwTAOcnooF8RwDewchHttkTJJlweKNvdb5HYrtqkV1y7CI+MNNp1p8Z8tOEDAqirNw4tXOURyVPk/AWbffS92q9frB/Tdrq/2fGVKFitzU21yZasiGW+vmCWRgQM4BTfONI5D88mzyYAOhdPprzaRPaIqLHgv5EBzR4Q7Jnn2139pcRO1C2iVw0K3j6nbQtQO5D+9oBonFtvuD42rD2tWmskPZxbEOGV2hQkI9fH8ZHehqDBXEW3r5RTaWh4QSUAKCNKP592LHYdDJbaX6F/LkCHqJWK60+i7LnhazqYh4nN1zc+ZQqkg9Oyl7XLX3xj64c89wDN7YbiFPM/1Q2DjPfmAl4QVxZ+4zIxaH7/lfUHXh2+jdFb0yWvWkGmZ5DGoYCzUmYJqGottAVQ4em+wSR7/6F97E7550SoNqKXHWX1BbGmnyDbmAdPE3C3QM+qbiL74rNNWBjCe3CwtwZaYCWyq7hzAw1V8jxKnw3VueAUjg2bGRWkVepNCmjT9UgbFtsiG7qKWsm6yiN/B0gDpFCK4BdD0JIxmG64tE4i9G3/QRgtp2Ef9fcQYazclWOZgYkBT852KBmMOiRoNrR5vO1+cfC6t3XALcUKl4Wcv4TKjlMSf3R2FRf7wJ2o+p3nxi/KWGBnXcD/j3d9ufCfj5UTZCuqCdBIz2bXUf6A/Q0Jmt02dphU80dpuFfGRSYz3py30YPaNbtdVG4V2I8HLv+MYwYDXbdbreaVs64GXOaCMczhTdN5gVTlvohd60ufzwrvFh5o2w3fIgxJCT1uPGx/LnSrUyF5TVrrmf+3wSgy+X4= 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:(13230040)(376014)(7416014)(1800799024)(82310400026)(36860700013)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 16:12:26.6018 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0d1e842a-8d28-49ee-57eb-08dd1610c6cd 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: DS1PEPF0001708E.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6323 The code implicitly operates on AMD-based systems by matching on PCI IDs. However, the use of these IDs is going away. Add an explicit CPU vendor check instead of relying on PCI IDs. Signed-off-by: Yazen Ghannam --- Notes: Link: https://lore.kernel.org/20241023172150.659002-3-yazen.ghannam@amd.com v1->v2: * No change. arch/x86/kernel/amd_nb.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/kernel/amd_nb.c b/arch/x86/kernel/amd_nb.c index 9fe9972d2071..37b8244899d8 100644 --- a/arch/x86/kernel/amd_nb.c +++ b/arch/x86/kernel/amd_nb.c @@ -582,6 +582,10 @@ static __init void fix_erratum_688(void) static __init int init_amd_nbs(void) { + if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD && + boot_cpu_data.x86_vendor != X86_VENDOR_HYGON) + return 0; + amd_cache_northbridges(); amd_cache_gart(); From patchwork Fri Dec 6 16:11: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: 13897341 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2079.outbound.protection.outlook.com [40.107.92.79]) (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 9E08320CCE4; Fri, 6 Dec 2024 16:12:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.79 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733501554; cv=fail; b=Z9a+jWjGf8W+rVw1AN2NarR7XjdE/21oVKT97hIXYKFYn4eDyWGHVgu6f84ZyeLxobVjI8kJn8liBcKRn9kRFxhQ9URAU5ECGr1Wb1E3ji8YxqQnTthxltPuDBEwZgtsXADhKcjchmyAaHkoYNZyD7vJZIfqczfWZpQ3rqti5io= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733501554; c=relaxed/simple; bh=TZRC3eAR9VV9wfoJblx/waz3/VovV6C4YBcQko5iwIw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TKL2hz8O0whnxnnx/FQtAFmPARZNdgtqUnrqnYLEcBew+6mCblufTykEfo2S7NzYsCyHOGF1v6gbGhf5deUaFwSA+9I7by9lFJuMLsstlLzn084r4GJemeoeMBG/x0G52qFRf4SZBODXBP4uA9uoYNpODhx66gnq/L8gd7NfVms= 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=HoXp1lzU; arc=fail smtp.client-ip=40.107.92.79 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="HoXp1lzU" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ye7m08/Ah3MFCGa9aH7yHUVSs8f524aYMr1d2MmNcqUocyEikJMrPU9jSjthwKGIKooaDWcteCBmjIl3pJ81UHGsnGX07d7Rz9L1QnHKDpKKU0dhpuQaK79DTJWDiQMghkGcu9B49gP2+UAQI3u0uf8cmZ6QeFOpCGg4v9Wiy3z2UoeeOGBfFdcCbFQjjIjUcNzoaudqUl655cRXdu4edAYYbCWn8hlckPrM7IGqnctKYKwhzl7+eLxd64Rsn3HPMRw1AkexSffpEu4Xx2NHOGqJYoNwmGojGnWOj6NkqbtWc/bEvdUCuWWkfgwotssXv6To9dy7C59n4HaIY8Zx6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=w5U3p4tm0z43Z47aWlormyNfSIuoP1PZRUwGhXonLW0=; b=Pw6jQfNGRskyIx9TzLYyjO8+6bCVuo5920KxbZYCOHVUTB9y+4Kyutsv5b4mq4ZDGMwF8F2ogdtBkBcwZK+opA05qsekaQIOe2bBZfec/E+onoKSsxMHmhga+Ci3RbiglMfrc8EDOYIj1fEpAT4CQqTac1/jYaYsOiUeu0YFnSJOfo+J5cJPuFYg3sg7/rdmURls99hiketny/2tQ6xpXcRlMx9wt/2UKaVS0wd0Mws9oA5ik0emBIjoX9GEPZwjuolDsP/N8H7TrJIpfzf9CFw5ezKWwODh7sx4lVuWxdKswrJ7sEtZDReM5mcbSqZ+M0lXYxjijcW6Xppv1aPcVw== 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=w5U3p4tm0z43Z47aWlormyNfSIuoP1PZRUwGhXonLW0=; b=HoXp1lzU82W0aNv82GZXFpOAPYyGo1yAWpyhN9naZ4qD8wSRQQ/MMqWWGgDhAWs2Qt96kiO35L3NC7ztSyBhncpb4mYRJWlW1Jui1IpOuSw7GNEzc5Wznoekt+ltm+bXZj7NIV08HOFnhonXEvBh8l0DBZgruCUDFchK73qaMZE= Received: from DM6PR02CA0167.namprd02.prod.outlook.com (2603:10b6:5:332::34) by SA1PR12MB7344.namprd12.prod.outlook.com (2603:10b6:806:2b7::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.19; Fri, 6 Dec 2024 16:12:28 +0000 Received: from DS1PEPF00017091.namprd03.prod.outlook.com (2603:10b6:5:332:cafe::c) by DM6PR02CA0167.outlook.office365.com (2603:10b6:5:332::34) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.11 via Frontend Transport; Fri, 6 Dec 2024 16:12:27 +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 DS1PEPF00017091.mail.protection.outlook.com (10.167.17.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Fri, 6 Dec 2024 16:12:27 +0000 Received: from purico-9eb2host.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.39; Fri, 6 Dec 2024 10:12:26 -0600 From: Yazen Ghannam To: , , Tony Luck , Mario Limonciello , "Bjorn Helgaas" , Jean Delvare , "Guenter Roeck" , Clemens Ladisch , "Shyam Sundar S K" , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Naveen Krishna Chatradhi" , Suma Hegde CC: , , , , Subject: [PATCH v2 03/16] x86/amd_nb: Clean up early_is_amd_nb() Date: Fri, 6 Dec 2024 16:11:56 +0000 Message-ID: <20241206161210.163701-4-yazen.ghannam@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241206161210.163701-1-yazen.ghannam@amd.com> References: <20241206161210.163701-1-yazen.ghannam@amd.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.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: DS1PEPF00017091:EE_|SA1PR12MB7344:EE_ X-MS-Office365-Filtering-Correlation-Id: f88ffaba-5f94-4b9c-9a4b-08dd1610c771 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|36860700013|376014|82310400026|921020; X-Microsoft-Antispam-Message-Info: ukLpvX0qukDnlfhx24EzStWk6MdhJl7Sz4GYkhoQWYfkvI5j4luTU5CG4Vny/wl5aSprw/7z+RXngTbeiKVf5BHPKu1svMskBCM/AMj97e+z7e5suD2Elp7VwHYRCjJbNhMAEmiE3CfVbqwFTREIz1XXNUHllrbw0aI7oLgYF5xsksLSvbA1KOl8Z7TLiWnp6BLC4THkWoCaTnUgjnVWHLtQBQ23oFFVHq6S5Ub1TxBm1La+sV+xPQ7Vw2nv6E2FljrfMF35lICgPmCROrKbJ/zgTwtRZP3wXm98SfuYZrjodC9x+FLMCIS54W6WdzMXKTCGevFb9i0slvyACyQ9tqZ2VMlMGct2zkW8E7L/uWXlewH3yU89RHaX3nPDW2RMPjKGE6f/meYuRoaVlGuUVZaEk9FdKsM1tP5sQowLWl1M00avXk45EoXwHZHnDAS2HCoWGQXylY1kiDBhfPd0kn6guldwM75GuypxEhEP8Q/n96l2dJwWo0LkJ/Ds8/ajlHhysxld8c6wBlTpB8y9RXJD03mtFHfYULVtRohhtX2Jiz3h1SW7+5bZbZp9g+Xr7SpWWp1MfvAtENiiPSrGrH0xgZtmpJuYdo7BGM4xqyRIp9pi8+P7Cfdr7oOVACSWgrGEWaMTvlgugMCoL5BdOR2hrQP3FLVv04+/mrpuGyDbJ0f6KeojMXD8aQ8ImvXafBaUFu5JCyFYUrKxyDoMO84C4O8W5q6MhoNTvPCfqfBruq1shJSdg9PDWmd0Sn4HF9S9PCa/Q5VqXcKRdJBrRs7YmUcRTsIz6ZUErf0kr6iukrs7nbZnNxwuf7A/S+i0t+OWt8fLrbi/r9equ8GmNOEqN+oDlIT5+Jzv1jiKY0mWKKwkKxbGZdDGhPKtgSOGpEzIuYw3UyMRi9arsvE0gWJWZIblyOR969eNzNpRgZ+s06iRwREl4ZeMvdoyEgUlDGobczdL3aqe2eofyd2EFXF/cPqZUhMlYX4gx2ShKmpF830MS8iz1X9/cFApb/13kOcnhCYzZiG1A+g9SB5tWEAZools7YMCTYKNiAhZJy7md/eoGkFhmsEfE61fYtCM+JQi53sh8Bu0/tdp2lNvprAgS0uXhGmr8KCyaLYzCdTk64uZkwXfJCFUfxnpgCQTNKdKyf+1eBYsgpRtXXUspTYLs9+JcHsu0obHAAmoiQUwzq8myPGo5Bc+F728wP5YxzS7ckMlY/1WkJqO21SLAXYTuSxmQ5k4ofZHmHrovmjIbjIy1MRsKuIgngRvX9chOxFLmMa9lCfAX3V+da5VRHlgO4qQfEnWdHzHbiY4H2wxTNcJD8+lLYvf9LGJxwt/v3aMIGsQ2wKQbYmT0ZNoVZ0Lv+LukLpGVt9tbCz1AAIeMXlDHNTueCa3ipu1xQwg/1L8wCvUkTRJBTGhaTLfh4H3K8wVUWTouPhfkA/KqDkdL/PsWVt/GlRkyy5ty0PxKqiC5kPqqlefGjOFiMB/hQ== 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:(13230040)(1800799024)(7416014)(36860700013)(376014)(82310400026)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 16:12:27.6783 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f88ffaba-5f94-4b9c-9a4b-08dd1610c771 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: DS1PEPF00017091.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7344 The check for early_is_amd_nb() is only useful for systems with GART or the NB_CFG register. Zen-based systems (both AMD and Hygon) have neither, so return early for them. Signed-off-by: Yazen Ghannam --- Notes: Link: https://lore.kernel.org/r/20241023172150.659002-4-yazen.ghannam@amd.com v1->v2: * Change boot_cpu_has() to cpu_feature_enabled(). arch/x86/kernel/amd_nb.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/amd_nb.c b/arch/x86/kernel/amd_nb.c index 37b8244899d8..ee20071ced99 100644 --- a/arch/x86/kernel/amd_nb.c +++ b/arch/x86/kernel/amd_nb.c @@ -385,7 +385,6 @@ static int amd_cache_northbridges(void) */ bool __init early_is_amd_nb(u32 device) { - const struct pci_device_id *misc_ids = amd_nb_misc_ids; const struct pci_device_id *id; u32 vendor = device & 0xffff; @@ -393,11 +392,11 @@ bool __init early_is_amd_nb(u32 device) boot_cpu_data.x86_vendor != X86_VENDOR_HYGON) return false; - if (boot_cpu_data.x86_vendor == X86_VENDOR_HYGON) - misc_ids = hygon_nb_misc_ids; + if (cpu_feature_enabled(X86_FEATURE_ZEN)) + return false; device >>= 16; - for (id = misc_ids; id->vendor; id++) + for (id = amd_nb_misc_ids; id->vendor; id++) if (vendor == id->vendor && device == id->device) return true; return false; From patchwork Fri Dec 6 16:11: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: 13897345 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2089.outbound.protection.outlook.com [40.107.96.89]) (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 E3B3420E6E4; Fri, 6 Dec 2024 16:12:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.89 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733501558; cv=fail; b=Jq6FKtI7wL3vqM6q7uQHTnQuvvfmUAskU/7mEc9+SKx6bFwrKGCbAmasZlOcUb8ROzY9YE5Gyi3RrvHjRE4KhEtAQtFnQY1AWW+Knpt2F1eYLET4plNHzPJJ789DR4DQLw36bAufQRDOnBh1ujqM4OdzHM0/kdyh4hdoSU46xRw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733501558; c=relaxed/simple; bh=P3sPgDshuhYTm6D/3VKVhomI4EzX24szkfR7ufyZH28=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VYO+KFyfvbaiTyxaLahW/KLAHXka4bPdvu3KIPqT0xD7eF226wATCur0YbSrZENuB4p0MjOtxiah77k1puBlEEmzyUQvkPdTpXh/s0atujl939SgYE/tDrQjZXRXA2b8yGnmARjDgGIEH6ndRIxxeApbeaCfsT52Veje7ooeguk= 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=hFFhxphB; arc=fail smtp.client-ip=40.107.96.89 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="hFFhxphB" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Yx2jUqFx/eCU/jrAYjZdAU40+1jqzCS7rGvJLpkwNO7ptvIE+Fixh5bdrX1MAzyaJPHnZapveERviEHwEVVo5Un3QuPPLXgExtZsDXjDpBxEgFPscVlRGBYscot3kfoeKTs1bNjdwkoDIbht6VXcRb/fgNhb4qMVdoVUXGPQq4Y8Hf8ssq6KIxsk8t2PS+GOhTICg4ruN1Df0AO/LTRjqZzGkTBKFj7Cv3XMQM9OMOyw+IvpP/a9DVbpMNfYEiTw+9NCgifstP3q87iGW9r6RM41qDSjPY5nsZYrhJFeZLI4s/Q4JpXDmUWokFU4y0mOcAcs4KKrDg3cRjdIXy+Viw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=NyTSCnBoWM69YaGUkVY3eEfQ8JWKZ32hNTsfvrEu4e0=; b=iRpXzgnaxIbSuAA4n9yHH5bkkvDIYrMwCqk5Yett8g3oV+A7Y3qjgMjC1CEnf7zVrBJy4yUsOKW9/G37aofQzh3XTQYBpUBoEE38iJszqSPiuc7xEipBxW1OQW+ATBAKsDmtMXJlLPbvEv8FugShxfFDniIgEuOhpbc196x5qNEFWlwQTL8hLExsemkItshiawfrRiqqlf2tksArEtuApwltnf/2yh2GH7iO/CWeM6bKhWZz/oJP/LFmN7C+371RZv/ParBi7n4zXBhUyQ4WCn+5e49U4R0lIIK4Vy2W2glY86lYCoDUJpaPstbENyP6qQPr5VDhgWugMN8zBarnEg== 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=NyTSCnBoWM69YaGUkVY3eEfQ8JWKZ32hNTsfvrEu4e0=; b=hFFhxphBpoUm0Q2gOu++xIBrmgBeFbSNZrAiuJlvIgtM40p71CG/blX5gMN9EFsY9rjtJktt5wrxWu5d6VFTDaJfQO5HcjPCz0cMzcUEAAll4kWRoRrBYzC2tCYUlo/RZ3hnq7YqlnnlRC61+paxYn7+W9JbMN+nAcwPuKjm2lc= Received: from DM6PR02CA0161.namprd02.prod.outlook.com (2603:10b6:5:332::28) by PH7PR12MB7114.namprd12.prod.outlook.com (2603:10b6:510:1ed::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.18; Fri, 6 Dec 2024 16:12:29 +0000 Received: from DS1PEPF00017091.namprd03.prod.outlook.com (2603:10b6:5:332:cafe::12) by DM6PR02CA0161.outlook.office365.com (2603:10b6:5:332::28) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.12 via Frontend Transport; Fri, 6 Dec 2024 16:12: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 DS1PEPF00017091.mail.protection.outlook.com (10.167.17.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Fri, 6 Dec 2024 16:12:28 +0000 Received: from purico-9eb2host.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.39; Fri, 6 Dec 2024 10:12:27 -0600 From: Yazen Ghannam To: , , Tony Luck , Mario Limonciello , "Bjorn Helgaas" , Jean Delvare , "Guenter Roeck" , Clemens Ladisch , "Shyam Sundar S K" , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Naveen Krishna Chatradhi" , Suma Hegde CC: , , , , Subject: [PATCH v2 04/16] x86: Start moving AMD Node functionality out of AMD_NB Date: Fri, 6 Dec 2024 16:11:57 +0000 Message-ID: <20241206161210.163701-5-yazen.ghannam@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241206161210.163701-1-yazen.ghannam@amd.com> References: <20241206161210.163701-1-yazen.ghannam@amd.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.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: DS1PEPF00017091:EE_|PH7PR12MB7114:EE_ X-MS-Office365-Filtering-Correlation-Id: b85070b9-c59e-491a-1db6-08dd1610c7f7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|1800799024|7416014|376014|921020; X-Microsoft-Antispam-Message-Info: BQl27I9U4Yg4g/j2azW51idaudXhaMV4QxfYm8BWd0NVp50jh/kA3g35QtgeVuKBt2MCRLgq5Td2Pa2DJkMWEhpM13CTexXBnp5mM6Fsj03BxiPbTmELa179RmBwsf/2B9mLU0A7BWNcb6i0UO8EVP0bbNPeeuJzZcaAFBGPhCwsbLUKnfuK6Kx0F9YL0PaAg7V/uzJfaDWBPjxBIhqPirgrmxx5ffcy4v6adE1ogTWehGxLde/SHYpEdkUddjPX3NDbW7VkkLfyvfY+sY3P/RmqdwrK8k3OiO3QRfwxN2o0oIVwdFOrCNOc8TYvUYrfRBC+hbKWM5Q5GXSuyfH9L1EjFkEvZv7DwHfRJap/I+LQx7RGWj0uRrW20HFcgVqqLu2h1a4zV3Aja+wkGs3WYcHtS5QlVokcSekqm8THyTXt6oEU6SnL2bIUNETQrsS+ZcNWU4Pd/+ADQdkS9DA52xoEP59haHoPsZJM4rMvk+9lDq+PO7if86LMGQ8m0OoFkX36f8vZX3a+xAKtydEzJ2axhB8hwUdZZ8gnxJ0m29KW5623fgd0on3BMg8cjSoVEHx0BsT6th1a+X8LeffwRL2kI9YN5R01Od1A+XSiYcPsxthEp8B0lgsYrBmZCya/02Os+1Q6wxKNMm9ZkLH6AkR95v4i05HmhmQlTkWv2CpqP/rkayEKKnDf33aA6P2WdtHergJgNHTh+cInS7nmL0Hu/HE5zRmD7PRZEgnuxv5p+lcA8lxo+C6d+8zPpVZdsERpN6Mk6P0RvT1CoZB83l0p+lip+NCtoyex3ZadH1CzHQj2c5E7g5hLWi5xafGqgYERLsQlQbUO5a4KZd+dbBL+j9Xse95bRHsmdaOw0v8liktQLTkA4I0f7hsBC4cxNEnmoNnXP9Ok+kQJxW5DSpRrBZ1/apIkBQYmVdB7DsSuHzxMM232R1sjHhSCl7WvqJkiF7fSAtnm0zNYF2/O6LZ5zL5m0sHezuhYlBlVmQpuDjwKPsQqmJLDGR3C57GahvP+dv659P4cpjCzosevEQiOxZphjIzADYr7Zy9JFzOlu+qT43x+mX1FsOITbceetJ1SXOVfnIaJTN9JOjn5Xi5VhwR2u+S0I9RgzNV4/fjA3mnNiQZr7hTnAUQZoL1MuPcwlzoWlPysYpH4I14/sHOjSLFropKHirqyAsWi4Kibi/6MKZOZRLpANhR+rqH+N7VcdEkJDnDL368gQ+1W9FCTMXjZpz7nAo5vcknvumR8TJGrO9CXx6f3TvBke4dsgb7b1MsO5K7axq1rZ+H1IloRpbNtiyCqEi9DVwmm8V3ZCmB/C1iNHWyDCQ36uAFL69Cs43v30xKueJ3nlKhTBnI/Jbw6wWlMgV+5Xg1JFg1hCDXoC0pjMGCA8vIUCvSMpl8BkQQp8zUaB4hmaZ9jdXqF8QwlYLHegPaYZ9+9QQKx4furSsILZmD46ssDoMSzw8PUfF+u++D2aqtKujJ+0A== 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:(13230040)(36860700013)(82310400026)(1800799024)(7416014)(376014)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 16:12:28.5533 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b85070b9-c59e-491a-1db6-08dd1610c7f7 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: DS1PEPF00017091.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7114 The "AMD Node" concept spans many families of systems and applies to a number of subsystems and drivers. Currently, the AMD Northbridge code is overloaded with AMD node functionality. However, the node concept is broader than just northbridges. Start files to host common AMD node functions and definitions. Include a helper to find an AMD node device function based on the convention described in AMD documentation. Anything that needs node functionality should include this rather than amd_nb.h. The AMD_NB code will be reduced to only northbridge-specific code needed for legacy systems. Signed-off-by: Yazen Ghannam --- Notes: Link: https://lore.kernel.org/20241023172150.659002-5-yazen.ghannam@amd.com v1->v2: * No change. MAINTAINERS | 7 +++++++ arch/x86/Kconfig | 4 ++++ arch/x86/include/asm/amd_node.h | 27 ++++++++++++++++++++++++++ arch/x86/kernel/Makefile | 1 + arch/x86/kernel/amd_node.c | 34 +++++++++++++++++++++++++++++++++ 5 files changed, 73 insertions(+) create mode 100644 arch/x86/include/asm/amd_node.h create mode 100644 arch/x86/kernel/amd_node.c diff --git a/MAINTAINERS b/MAINTAINERS index 686109008d8e..d7617f196bda 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1121,6 +1121,13 @@ L: linux-i2c@vger.kernel.org S: Supported F: drivers/i2c/busses/i2c-amd-asf-plat.c +AMD NODE DRIVER +M: Yazen Ghannam +L: linux-kernel@vger.kernel.org +S: Supported +F: arch/x86/include/asm/amd_node.h +F: arch/x86/kernel/amd_node.c + AMD PDS CORE DRIVER M: Shannon Nelson M: Brett Creeley diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index e4e27d44dc2b..12915f620b12 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -3128,6 +3128,10 @@ config TS5500 endif # X86_32 config AMD_NB + def_bool y + depends on AMD_NODE + +config AMD_NODE def_bool y depends on CPU_SUP_AMD && PCI diff --git a/arch/x86/include/asm/amd_node.h b/arch/x86/include/asm/amd_node.h new file mode 100644 index 000000000000..622bd3038eeb --- /dev/null +++ b/arch/x86/include/asm/amd_node.h @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * AMD Node helper functions and common defines + * + * Copyright (c) 2024, Advanced Micro Devices, Inc. + * All Rights Reserved. + * + * Author: Yazen Ghannam + * + * Note: + * Items in this file may only be used in a single place. + * However, it's prudent to keep all AMD Node functionality + * in a unified place rather than spreading throughout the + * kernel. + */ + +#ifndef _ASM_X86_AMD_NODE_H_ +#define _ASM_X86_AMD_NODE_H_ + +#include + +#define MAX_AMD_NUM_NODES 8 +#define AMD_NODE0_PCI_SLOT 0x18 + +struct pci_dev *amd_node_get_func(u16 node, u8 func); + +#endif /*_ASM_X86_AMD_NODE_H_*/ diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile index f7918980667a..b43eb7e384eb 100644 --- a/arch/x86/kernel/Makefile +++ b/arch/x86/kernel/Makefile @@ -119,6 +119,7 @@ obj-$(CONFIG_EARLY_PRINTK) += early_printk.o obj-$(CONFIG_HPET_TIMER) += hpet.o obj-$(CONFIG_AMD_NB) += amd_nb.o +obj-$(CONFIG_AMD_NODE) += amd_node.o obj-$(CONFIG_DEBUG_NMI_SELFTEST) += nmi_selftest.o obj-$(CONFIG_KVM_GUEST) += kvm.o kvmclock.o diff --git a/arch/x86/kernel/amd_node.c b/arch/x86/kernel/amd_node.c new file mode 100644 index 000000000000..e825cd4426b9 --- /dev/null +++ b/arch/x86/kernel/amd_node.c @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * AMD Node helper functions and common defines + * + * Copyright (c) 2024, Advanced Micro Devices, Inc. + * All Rights Reserved. + * + * Author: Yazen Ghannam + */ + +#include + +/* + * AMD Nodes are a physical collection of I/O devices within an SoC. There can be one + * or more nodes per package. + * + * The nodes are software-visible through PCI config space. All nodes are enumerated + * on segment 0 bus 0. The device (slot) numbers range from 0x18 to 0x1F (maximum 8 + * nodes) with 0x18 corresponding to node 0, 0x19 to node 1, etc. Each node can be a + * multi-function device. + * + * On legacy systems, these node devices represent integrated Northbridge functionality. + * On Zen-based systems, these node devices represent Data Fabric functionality. + * + * See "Configuration Space Accesses" section in BKDGs or + * "Processor x86 Core" -> "Configuration Space" section in PPRs. + */ +struct pci_dev *amd_node_get_func(u16 node, u8 func) +{ + if (node >= MAX_AMD_NUM_NODES) + return NULL; + + return pci_get_domain_bus_and_slot(0, 0, PCI_DEVFN(AMD_NODE0_PCI_SLOT + node, func)); +} From patchwork Fri Dec 6 16:11: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: 13897344 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2061.outbound.protection.outlook.com [40.107.237.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 BF94520E6E1; Fri, 6 Dec 2024 16:12:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.61 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733501558; cv=fail; b=hInsC6xcwoZMgvsnsZmvAbZQGXN3rtUrevFuJ6NVCdNA3cVW/HWdy8j7O5cJi3IFmGU4S7nIC2PjJ19rBSS1MAV9Hsvafl1AL9KKKdOJAVxBO6JBfWr7KNoJgStUQMEsYiGQt4PB81r1T2kS5iqd3zrco5c5/Rm0N5HlDHCDMYY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733501558; c=relaxed/simple; bh=10H33gWO2syuo+yhGQ+pwePLCcGH/oR7AHPbUjCC/Nw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=f5I3HXXeJrenYPsSDWkbfWAQquKD/k85Ij/vDcrrPdmE29JEUb4lR+SS3dX6X0jonJLua6ar5DzOWu3lt4V1jjfmNpxr0CPxRSuH9SNGyZxKiYM6mXZKEjx7rG6boKNR9PGtdoOSzlo9e0R4G8akJuhsTdlvXeuQiRjXLM9o5BM= 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=shpIq0CC; arc=fail smtp.client-ip=40.107.237.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="shpIq0CC" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FkQG3euG2zzOSAEnqLFIQDPiFD8lqXBHTEMIYHghH50mZe4GVsu/yt9Xntsuqefd5U+RuD0zaq3h+KwiWhzMfyvOg7MXPcYOISRU4rAshk5VNUfM7xPhOXwF93SLaY0coXh+LNI6b7O6FQ6tcl9ajVgL8Vp453k6g5mEnkhYUtJrW+fPqwZDIcktuPbM7cEUN1Ft5NoIrM8eYS9HeYWMDAIaWOnl1OmOmwepZsGK5rVshA3RDXYaop+5tjj+3swwRsCWUZJ/UpOuX3v1MupP3vq1I69JTPbZnqJVm44pC6wadddQcb+s7e0dMd2gQCaQ9fGZyedQ5mVX9EFzrG2xpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=rrnxYYazJBRdHXhleU3iLaaWal2T1Gpzc8rEorY2Ygk=; b=jgHZ3QJDJGUaLSXs+48RI1ILBphz4b/sIPlR1EVvv/frXZ0Gu3jyTj/kQ2OkbyGZVzjW8HPiUfbI7fyRPJ1IpVNxPMkuC5FGELSODbWnkvxezXzZbQtHNgxkcPDK1nGlYEwgxyQmPWEA8nA00bp9GWAQNF1nkxPveW2a2090TVgmyegA276eBR7lrY0frkUe9sERrJdtalGyYTn3q6GmlXoNDAFQosLnPOLEXatiJPqbAMqY4A+gcI8ld5pt4s2tB40lIFspzjkwmlBGpktGM9TOScKd+JYGYb08VFvJmF5g3V8DHtkIpZl9bSnPBlnPheTfzfQQHHfEaapwJX7xEg== 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=rrnxYYazJBRdHXhleU3iLaaWal2T1Gpzc8rEorY2Ygk=; b=shpIq0CChN/LmwdXdHeJUupiEjZ2AfXxXlpBVbv2Y+fG6sYFsUJhfrqjd7aexCM3rv2czfVZmYCflrhBCwNH7pHD5h2dtH1FRI36Q9b4x3DCYBIpJsQSnr62wQCs1tzLf8SFapqy5FcTQMhaGGuC+vqtGLAjO8P9z3RxpHko5WM= Received: from DM6PR02CA0143.namprd02.prod.outlook.com (2603:10b6:5:332::10) by CH3PR12MB9249.namprd12.prod.outlook.com (2603:10b6:610:1bc::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.19; Fri, 6 Dec 2024 16:12:29 +0000 Received: from DS1PEPF00017091.namprd03.prod.outlook.com (2603:10b6:5:332:cafe::fc) by DM6PR02CA0143.outlook.office365.com (2603:10b6:5:332::10) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.12 via Frontend Transport; Fri, 6 Dec 2024 16:12: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 DS1PEPF00017091.mail.protection.outlook.com (10.167.17.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Fri, 6 Dec 2024 16:12:29 +0000 Received: from purico-9eb2host.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.39; Fri, 6 Dec 2024 10:12:27 -0600 From: Yazen Ghannam To: , , Tony Luck , Mario Limonciello , "Bjorn Helgaas" , Jean Delvare , "Guenter Roeck" , Clemens Ladisch , "Shyam Sundar S K" , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Naveen Krishna Chatradhi" , Suma Hegde CC: , , , , Subject: [PATCH v2 05/16] x86/amd_nb: Simplify function 4 search Date: Fri, 6 Dec 2024 16:11:58 +0000 Message-ID: <20241206161210.163701-6-yazen.ghannam@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241206161210.163701-1-yazen.ghannam@amd.com> References: <20241206161210.163701-1-yazen.ghannam@amd.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.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: DS1PEPF00017091:EE_|CH3PR12MB9249:EE_ X-MS-Office365-Filtering-Correlation-Id: 7053fc8c-dfe3-46cf-dd03-08dd1610c877 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|376014|36860700013|82310400026|921020; X-Microsoft-Antispam-Message-Info: c/mj/NId6U1sifFwSRWhNgkum8sSDrn/S7tNeiPTLxnRntIZlDPVSum8nOlzioVJlGBznUfUmtfhUxSU8OEp9NsOAChRjnJaSfNeyImmFN5nKN03Vur6EfZG0tHMqLCCijS/tVfeeW80PlYXHfT7jLyIPWlrmrUgBkRmvZMYIdFw848RZHDck5ajGnlyGelkvzvVXWSKLsIVckHmb76JFZZ+M8MnEwf756kmJlcyZz4chot5nhZt7iQ1fXfCCYIxpwoL45bReV6Bmgm/ngpWKM0WshLCAFGg53rLSaolsze6KE6h8UhbFTa1rTCF2os167fg3J6L0fg21JdhnBeQy4q0QY7fJdypGX+Ps7xrXL1FUT00tnMb3TnFDCz04SF17FwTBINIsCR5vLrZWV4XzAe2tiRVovzZEi7jAXX69El8Xeb3f+ul+FczcryHdJfVZ78ckWLx8ULJqvFnWFXoBY2s+tnMtXlA27o2XPXDrNvIYgUYtug7+EdoYo56iYSo4jN06Hk2v7nBMnOtUDPPa1DfreiCi+gRvdCwcWoE7g3/YkCJvx51wTQ0pX2dFimy1fwWO5hlGuAXAXkOpsXpDOCrYj+fHAMXePGkZP0f/CqDe0LW8GXw5+qjMtocly1pbr9UqP8ij9QnhPrwDJqFNkl+EcJVcKmur8ItJtwdhDvAcSJN+B/qSuGNzQXHWeWcpwJmoSvbTeqZMv9RlCzs0yjsUAuFVNrut5y72Jqzetqclvhrn+9wEIlmDoRvzueWe0ZKXQyQbhKhyFJgkEOT4e2+v6mTDMV4sAYT79zJAmd+pgLWLP5qYHfKDgc3ya1RGRDQjhP3qpQlIwOcJMevEBqq0f3Z3xh3MBF1wOLIMToVr3SErlUc2mJdWcXrRuLJk7+HgwVvxztBzq+J9Oul4lp9crhq6o353IailsD7Y4qvuQPu74YWcs1kPa443agQdhz+nb9geMAmknrHmXdWDYgYtIP/0juGqAbyBW6Ski4B+wIwgvxF56kVXkIJRZ0hK8/iOgU+pYLFTArO+k09xWuqvIUmO8JzpoqN0KKWViDcFSLOT0ImucXnDUidShl8LH9Mt8XMG+jUkcSaQcYBr2Sn2Q8EeLfQehr3QupxxgJfGW61Bjk6pq5ia55+xad+V4Y+3+BIv51rHO/tVnp2UNWznG6PKrBAnQjvoBwRFFVfyPIaAOHcfoCQht7veQwtrDIboWUW7oYXJl82nm+K5OXnbZEhSYKHBOWFKxsvknBMp9qR3SU6+tnYDCo2GvxzgXGudlcqn85nyrwMbTKH3Jog2eeP5mx2iJxSGxZCFKmiX4M+cHyDb60n4XQ2BCCftWbSGAUcU9e1vqcaUS5i6xBHXMU7UqvH1gx6Z3QJTS8EpsRqJMx4/i/NmtnOH6SsdkoVLhbQsHjEAXKAh9Sd1BMgMZAd9Oq9Bk39qGwQeJvyD2wnHO0CyxaQR2fnJog9VGB+5oPQ7vYkVCW5/xiKcg== 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:(13230040)(1800799024)(7416014)(376014)(36860700013)(82310400026)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 16:12:29.4127 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7053fc8c-dfe3-46cf-dd03-08dd1610c877 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: DS1PEPF00017091.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9249 Use the newly added helper function to look up a CPU/Node function to find "function 4" devices. This avoids the need to regularly add new PCI IDs for basic discovery. The unique PCI IDs are still useful in case of quirks or functional changes. And they should be used only in such a manner. Signed-off-by: Yazen Ghannam --- Notes: Link: https://lore.kernel.org/20241023172150.659002-6-yazen.ghannam@amd.com v1->v2: * No change. arch/x86/include/asm/amd_nb.h | 1 + arch/x86/kernel/amd_nb.c | 66 ++--------------------------------- 2 files changed, 4 insertions(+), 63 deletions(-) diff --git a/arch/x86/include/asm/amd_nb.h b/arch/x86/include/asm/amd_nb.h index 4f586fc699fd..31547108de1a 100644 --- a/arch/x86/include/asm/amd_nb.h +++ b/arch/x86/include/asm/amd_nb.h @@ -4,6 +4,7 @@ #include #include +#include struct amd_nb_bus_dev_range { u8 bus; diff --git a/arch/x86/kernel/amd_nb.c b/arch/x86/kernel/amd_nb.c index ee20071ced99..7a62c5af2531 100644 --- a/arch/x86/kernel/amd_nb.c +++ b/arch/x86/kernel/amd_nb.c @@ -30,26 +30,6 @@ #define PCI_DEVICE_ID_AMD_MI200_ROOT 0x14bb #define PCI_DEVICE_ID_AMD_MI300_ROOT 0x14f8 -#define PCI_DEVICE_ID_AMD_17H_DF_F4 0x1464 -#define PCI_DEVICE_ID_AMD_17H_M10H_DF_F4 0x15ec -#define PCI_DEVICE_ID_AMD_17H_M30H_DF_F4 0x1494 -#define PCI_DEVICE_ID_AMD_17H_M60H_DF_F4 0x144c -#define PCI_DEVICE_ID_AMD_17H_M70H_DF_F4 0x1444 -#define PCI_DEVICE_ID_AMD_17H_MA0H_DF_F4 0x1728 -#define PCI_DEVICE_ID_AMD_19H_DF_F4 0x1654 -#define PCI_DEVICE_ID_AMD_19H_M10H_DF_F4 0x14b1 -#define PCI_DEVICE_ID_AMD_19H_M40H_DF_F4 0x167d -#define PCI_DEVICE_ID_AMD_19H_M50H_DF_F4 0x166e -#define PCI_DEVICE_ID_AMD_19H_M60H_DF_F4 0x14e4 -#define PCI_DEVICE_ID_AMD_19H_M70H_DF_F4 0x14f4 -#define PCI_DEVICE_ID_AMD_19H_M78H_DF_F4 0x12fc -#define PCI_DEVICE_ID_AMD_1AH_M00H_DF_F4 0x12c4 -#define PCI_DEVICE_ID_AMD_1AH_M20H_DF_F4 0x16fc -#define PCI_DEVICE_ID_AMD_1AH_M60H_DF_F4 0x124c -#define PCI_DEVICE_ID_AMD_1AH_M70H_DF_F4 0x12bc -#define PCI_DEVICE_ID_AMD_MI200_DF_F4 0x14d4 -#define PCI_DEVICE_ID_AMD_MI300_DF_F4 0x152c - /* Protect the PCI config register pairs used for SMN. */ static DEFINE_MUTEX(smn_mutex); @@ -73,8 +53,6 @@ static const struct pci_device_id amd_root_ids[] = { {} }; -#define PCI_DEVICE_ID_AMD_CNB17H_F4 0x1704 - static const struct pci_device_id amd_nb_misc_ids[] = { { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_K8_NB_MISC) }, { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_10H_NB_MISC) }, @@ -107,35 +85,6 @@ static const struct pci_device_id amd_nb_misc_ids[] = { {} }; -static const struct pci_device_id amd_nb_link_ids[] = { - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_15H_NB_F4) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_15H_M30H_NB_F4) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_15H_M60H_NB_F4) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_NB_F4) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_M30H_NB_F4) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_DF_F4) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_M10H_DF_F4) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_M30H_DF_F4) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_M60H_DF_F4) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_M70H_DF_F4) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_MA0H_DF_F4) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_19H_DF_F4) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_19H_M10H_DF_F4) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_19H_M40H_DF_F4) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_19H_M50H_DF_F4) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_19H_M60H_DF_F4) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_19H_M70H_DF_F4) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_19H_M78H_DF_F4) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CNB17H_F4) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_1AH_M00H_DF_F4) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_1AH_M20H_DF_F4) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_1AH_M60H_DF_F4) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_1AH_M70H_DF_F4) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_MI200_DF_F4) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_MI300_DF_F4) }, - {} -}; - static const struct pci_device_id hygon_root_ids[] = { { PCI_DEVICE(PCI_VENDOR_ID_HYGON, PCI_DEVICE_ID_AMD_17H_ROOT) }, {} @@ -146,11 +95,6 @@ static const struct pci_device_id hygon_nb_misc_ids[] = { {} }; -static const struct pci_device_id hygon_nb_link_ids[] = { - { PCI_DEVICE(PCI_VENDOR_ID_HYGON, PCI_DEVICE_ID_AMD_17H_DF_F4) }, - {} -}; - const struct amd_nb_bus_dev_range amd_nb_bus_dev_ranges[] __initconst = { { 0x00, 0x18, 0x20 }, { 0xff, 0x00, 0x20 }, @@ -275,13 +219,11 @@ int __must_check amd_smn_write(u16 node, u32 address, u32 value) } EXPORT_SYMBOL_GPL(amd_smn_write); - static int amd_cache_northbridges(void) { const struct pci_device_id *misc_ids = amd_nb_misc_ids; - const struct pci_device_id *link_ids = amd_nb_link_ids; const struct pci_device_id *root_ids = amd_root_ids; - struct pci_dev *root, *misc, *link; + struct pci_dev *root, *misc; struct amd_northbridge *nb; u16 roots_per_misc = 0; u16 misc_count = 0; @@ -294,7 +236,6 @@ static int amd_cache_northbridges(void) if (boot_cpu_data.x86_vendor == X86_VENDOR_HYGON) { root_ids = hygon_root_ids; misc_ids = hygon_nb_misc_ids; - link_ids = hygon_nb_link_ids; } misc = NULL; @@ -328,14 +269,13 @@ static int amd_cache_northbridges(void) amd_northbridges.nb = nb; amd_northbridges.num = misc_count; - link = misc = root = NULL; + misc = root = NULL; for (i = 0; i < amd_northbridges.num; i++) { node_to_amd_nb(i)->root = root = next_northbridge(root, root_ids); node_to_amd_nb(i)->misc = misc = next_northbridge(misc, misc_ids); - node_to_amd_nb(i)->link = link = - next_northbridge(link, link_ids); + node_to_amd_nb(i)->link = amd_node_get_func(i, 4); /* * If there are more PCI root devices than data fabric/ From patchwork Fri Dec 6 16:11: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: 13897343 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2073.outbound.protection.outlook.com [40.107.220.73]) (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 82C2020E31C; Fri, 6 Dec 2024 16:12:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.73 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733501557; cv=fail; b=uusuZakci/9b8WtnWaeTCyVjLKARmgSpsATUI+niK1T1K9oddy5ov62AlvOw4K83P5KWwkaqJJ9mhCHHKDicZctPFsE3xqxFKT+FM54XZxWh3w4nTWc47ie0bS2g9d7zYTtCul/ChgKNBcjbGlNlEuHCe196z1bsRBQqT5bhmfQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733501557; c=relaxed/simple; bh=OL3+fkQfzmbFM4bre43jilJwGpwVSBhIrlxdJJ1s5w0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RTxFSmBsxbPTd7ITCKNtHkN3pi7mKggJPbxnwWZ9TM8jGmUCygWfEcMUrUfLs5pNrjkQuSGfrQffykptyf26rl1qq5psEHiHdVZHfJuUbHX3FZTSe72/4LReZZnrchm4Mqt9OxKdl5X29uwP2vo4//88T0UheoLDCPumD9foiTI= 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=WE0+2IrU; arc=fail smtp.client-ip=40.107.220.73 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="WE0+2IrU" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=gp6R0rQZyR9S5EZIL4LsEMaHpIOSTHBF7y3I7sU+cxADmtGv/3iCvCpaxaTvwustYGQyBFxjwF8ty6MSkPYGhHq3J7ooRw1EiwGhkaP9/xcUEMFsmJYwSgmNTaO5FlBBfBU5C6XYOvNA1J/vSgaFiAtzuutJ9dgIjPtq1dv4evFQMAEZGcmM4Tsr/Xg7ZMwZHnGv7bBd41CCHhXU6kAv3ACQn+rMO0eNCVrDK18t8XyQpHcJB+meCLF46A2jFGeilxLfYfVQDtv1FxBc73/H214kQyinniXsgoydREiIp0YYtobuqu+FBgzPAxqAJtGbL/Eq11MAn/j0Bnbbs0CPhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=UpwtKN4gM0LDrWcZURA5GCufwXUnWLxQwBwDsZErTfU=; b=PoqoNkt8ZA27098sXiszvgbbfwtkPNRb2DwWg1EwTDh85+trVAE4aVZoQkYAGnYGI4ROL3siJq6mQeOZONsHY7BJ7yn6W6o6hF0HPTpDcojKHbz444cZAmVRM2TIcytUTDM0rjZp8QS9t1OK/HkDVVZLo3oMc9G3dRD1MELCIdWFnh604/t6iQQnbT6Kls0HjZqjDqUfr5cMh0ZS9+CgoZk3Wk1N3aCOYcS2nQhlBsqSr/fi7MxTYIDgSvmeiS0nx4TFerw7zylfzMq/cy+1S5G5lZQxfP97biLETmfpmWVMS+rLrLeBHKALvgq1vKYT9EikzwfCxAjfGj4S13XQUw== 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=UpwtKN4gM0LDrWcZURA5GCufwXUnWLxQwBwDsZErTfU=; b=WE0+2IrULFFIS6XIOpEGjt4njilvuONqlkgyFRGSyujkNsmZkWnB5ZGr2IQuOaLZETWueROFwGOiklFd2Rf+6Ae3NXX8VRhub0hqCbVfcxXJhV9OSMOEqzxBKd9iBAlKwLurFYmwRnOR3aZN/bl0M8Ci+VANghJB8wnTrs+kmgU= Received: from DM6PR02CA0167.namprd02.prod.outlook.com (2603:10b6:5:332::34) by IA1PR12MB6628.namprd12.prod.outlook.com (2603:10b6:208:3a0::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.11; Fri, 6 Dec 2024 16:12:30 +0000 Received: from DS1PEPF00017091.namprd03.prod.outlook.com (2603:10b6:5:332::4) by DM6PR02CA0167.outlook.office365.com (2603:10b6:5:332::34) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.11 via Frontend Transport; Fri, 6 Dec 2024 16:12: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 DS1PEPF00017091.mail.protection.outlook.com (10.167.17.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Fri, 6 Dec 2024 16:12:29 +0000 Received: from purico-9eb2host.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.39; Fri, 6 Dec 2024 10:12:28 -0600 From: Yazen Ghannam To: , , Tony Luck , Mario Limonciello , "Bjorn Helgaas" , Jean Delvare , "Guenter Roeck" , Clemens Ladisch , "Shyam Sundar S K" , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Naveen Krishna Chatradhi" , Suma Hegde CC: , , , , Subject: [PATCH v2 06/16] x86/amd_nb: Simplify root device search Date: Fri, 6 Dec 2024 16:11:59 +0000 Message-ID: <20241206161210.163701-7-yazen.ghannam@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241206161210.163701-1-yazen.ghannam@amd.com> References: <20241206161210.163701-1-yazen.ghannam@amd.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.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: DS1PEPF00017091:EE_|IA1PR12MB6628:EE_ X-MS-Office365-Filtering-Correlation-Id: 4298b8c3-fdcc-4f96-3bea-08dd1610c8b8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|7416014|1800799024|82310400026|921020; X-Microsoft-Antispam-Message-Info: JHDhywJgwfeJwYype9XuWVyF4KTQQmFYuaz05wgP1Z6kQrbfL04HERo7/EgnrFY48uiS3aMaaCfeVFrClcmhUvfVhB9/WaFgNc0JnALub7I1UCTXPKl/90iN14ObBa7M4mLLnXcLyv+UElTWaNURPQBGEguLKFQrVLu8I64yr029M7nCnd8THkVBrqkm20OW1T4vihK7UIjX63kxNN7IaddDsH0fYkOhwZX5faytaeDIGzOUP5LhozS0zHmZ5AVyQh30XqFOh8/kKz0cnsyJdoI2NwnJDooNgpALYQlkX2Z9KnL+dfCjWLpCcV0lbFeKLpBtC25nHBGoqN2PjwAxv+zQxEMyeiWR32ay7Zs1KqKDUxwP0bzSa3+Vy8np6EFIxb7wBJKwtRci17wSNFOkXx1RPg2lFg5rkarlnTzLsTM3dQgjqXRLOeW94TTCnLwaeyNYeG1hR2Y3SwL0jCytyj0ef8cf7TuX5bYRL2db8/fH8EJwy1y+KaSX82voAoP52C81qVWdSVdD8w3pjR5M8pvWLREXwKqxd8QGPUEA+WUFR8OPYLfacOjDNI1qmnrsCsXKGiokTVTxxFC1WYc0T2ZoF/U5fafx6KOTJ7eb4UguZtCrPG/ZnCZDkOxFvKX2/XxwE2U45tA7WWVbk0rCK/cG0KXioN61NuD2WyMl5eXBi0KQPxKlJHOWNrgsIBjfo9VTPYjuwIC7cPoZ5obu523q4U2CIOjphBCCe327WM50/gLNZ6D9yqFQ2cVWxrt2nnIIXu2pgsqIsYD9jpJ3cUlJCchgjQpvxk2vlyRaHLDlW/zbR3IRollvutAebG3FNeYkKuqTIoc8KJQ2q5+Fn4CZhgKAu9+rIVlIPxeDb+uuYQgRYSG19V+zvd0zBtPM4bB8fN37R9iTFG4CufRlSkOC1yz3YoM+/GPKnbW9VH+Y3D6+PwJgpVDpgXlTvkiwh4743yAxIZQ5pR5jQIJ5ihA880rx5v6RcB+rZyZ9XRLPWpd+n2aBD9UFTSPqoNmFpaJJKQG0eCrzYqXeLilD5U+8SmLg5HuBZeq9gRYBOGTMlbVtprG59fCt0jCtI72o6i/w/9jFGhFKhydg//z+/Zo46wHzQollpmCDqBIDfN/kg/poklEA7Y6/v9eLpistG9Wciogo1w2KlFIViQyCkTTh1JDhuRPDGzkLrC9jXckOFHHRceJPTzG1vu6Fr/VuGxCEVFT3F816iuWtuCcVrOAH8p6tTrcGOs9/OnBi0ntl9YfAUDLfe2jL648G0nKcuIBLh8XcH5J6PukRJFWngvSDB8Fa2AHrImFktcIhsh6UeF+TKD4/SYz7Jn7cRGYPFtq4g5G7WXFKTEvaDCffkCx/S10TwhIk0FkVxm+PcI7F5D5wSnUa4Or0k0RGJwG6Dt3+Ru9LTFffqIRguoKFjpKF2tTNAv+m+ucsUVBIaPkU7qt2HiVNQtUadipDODSS65wiokxahcngW77wM0mFqA== 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:(13230040)(36860700013)(376014)(7416014)(1800799024)(82310400026)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 16:12:29.8189 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4298b8c3-fdcc-4f96-3bea-08dd1610c8b8 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: DS1PEPF00017091.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6628 The "root" device search was introduced to support SMN access for Zen systems. This device represents a PCIe root complex. It is not the same as the "CPU/node" devices found at slots 0x18-0x1F. There may be multiple PCIe root complexes within an AMD node. Such is the case with server or High-end Desktop (HEDT) systems, etc. Therefore it is not enough to assume "root <-> AMD node" is a 1-to-1 association. Currently, this is handled by skipping "extra" root complexes during the search. However, the hardware provides the PCI bus number of an AMD node's root device. Use the hardware info to get the root device's bus and drop the extra search code and PCI IDs. Signed-off-by: Yazen Ghannam --- Notes: Link: https://lore.kernel.org/20241023172150.659002-7-yazen.ghannam@amd.com v1->v2: * Spell out HEDT in commit message. * Change boot_cpu_has() to cpu_feature_enabled(). * Move 'df_f0' declaration to location of first use. arch/x86/include/asm/amd_node.h | 1 + arch/x86/kernel/amd_nb.c | 80 ++------------------------------- arch/x86/kernel/amd_node.c | 56 +++++++++++++++++++++++ 3 files changed, 61 insertions(+), 76 deletions(-) diff --git a/arch/x86/include/asm/amd_node.h b/arch/x86/include/asm/amd_node.h index 622bd3038eeb..3f097dd479f8 100644 --- a/arch/x86/include/asm/amd_node.h +++ b/arch/x86/include/asm/amd_node.h @@ -23,5 +23,6 @@ #define AMD_NODE0_PCI_SLOT 0x18 struct pci_dev *amd_node_get_func(u16 node, u8 func); +struct pci_dev *amd_node_get_root(u16 node); #endif /*_ASM_X86_AMD_NODE_H_*/ diff --git a/arch/x86/kernel/amd_nb.c b/arch/x86/kernel/amd_nb.c index 7a62c5af2531..6218a0428c77 100644 --- a/arch/x86/kernel/amd_nb.c +++ b/arch/x86/kernel/amd_nb.c @@ -15,44 +15,11 @@ #include #include -#define PCI_DEVICE_ID_AMD_17H_ROOT 0x1450 -#define PCI_DEVICE_ID_AMD_17H_M10H_ROOT 0x15d0 -#define PCI_DEVICE_ID_AMD_17H_M30H_ROOT 0x1480 -#define PCI_DEVICE_ID_AMD_17H_M60H_ROOT 0x1630 -#define PCI_DEVICE_ID_AMD_17H_MA0H_ROOT 0x14b5 -#define PCI_DEVICE_ID_AMD_19H_M10H_ROOT 0x14a4 -#define PCI_DEVICE_ID_AMD_19H_M40H_ROOT 0x14b5 -#define PCI_DEVICE_ID_AMD_19H_M60H_ROOT 0x14d8 -#define PCI_DEVICE_ID_AMD_19H_M70H_ROOT 0x14e8 -#define PCI_DEVICE_ID_AMD_1AH_M00H_ROOT 0x153a -#define PCI_DEVICE_ID_AMD_1AH_M20H_ROOT 0x1507 -#define PCI_DEVICE_ID_AMD_1AH_M60H_ROOT 0x1122 -#define PCI_DEVICE_ID_AMD_MI200_ROOT 0x14bb -#define PCI_DEVICE_ID_AMD_MI300_ROOT 0x14f8 - /* Protect the PCI config register pairs used for SMN. */ static DEFINE_MUTEX(smn_mutex); static u32 *flush_words; -static const struct pci_device_id amd_root_ids[] = { - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_ROOT) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_M10H_ROOT) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_M30H_ROOT) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_M60H_ROOT) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_MA0H_ROOT) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_19H_M10H_ROOT) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_19H_M40H_ROOT) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_19H_M60H_ROOT) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_19H_M70H_ROOT) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_1AH_M00H_ROOT) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_1AH_M20H_ROOT) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_1AH_M60H_ROOT) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_MI200_ROOT) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_MI300_ROOT) }, - {} -}; - static const struct pci_device_id amd_nb_misc_ids[] = { { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_K8_NB_MISC) }, { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_10H_NB_MISC) }, @@ -85,11 +52,6 @@ static const struct pci_device_id amd_nb_misc_ids[] = { {} }; -static const struct pci_device_id hygon_root_ids[] = { - { PCI_DEVICE(PCI_VENDOR_ID_HYGON, PCI_DEVICE_ID_AMD_17H_ROOT) }, - {} -}; - static const struct pci_device_id hygon_nb_misc_ids[] = { { PCI_DEVICE(PCI_VENDOR_ID_HYGON, PCI_DEVICE_ID_AMD_17H_DF_F3) }, {} @@ -222,19 +184,15 @@ EXPORT_SYMBOL_GPL(amd_smn_write); static int amd_cache_northbridges(void) { const struct pci_device_id *misc_ids = amd_nb_misc_ids; - const struct pci_device_id *root_ids = amd_root_ids; - struct pci_dev *root, *misc; + struct pci_dev *misc; struct amd_northbridge *nb; - u16 roots_per_misc = 0; u16 misc_count = 0; - u16 root_count = 0; - u16 i, j; + u16 i; if (amd_northbridges.num) return 0; if (boot_cpu_data.x86_vendor == X86_VENDOR_HYGON) { - root_ids = hygon_root_ids; misc_ids = hygon_nb_misc_ids; } @@ -245,23 +203,6 @@ static int amd_cache_northbridges(void) if (!misc_count) return -ENODEV; - root = NULL; - while ((root = next_northbridge(root, root_ids))) - root_count++; - - if (root_count) { - roots_per_misc = root_count / misc_count; - - /* - * There should be _exactly_ N roots for each DF/SMN - * interface. - */ - if (!roots_per_misc || (root_count % roots_per_misc)) { - pr_info("Unsupported AMD DF/PCI configuration found\n"); - return -ENODEV; - } - } - nb = kcalloc(misc_count, sizeof(struct amd_northbridge), GFP_KERNEL); if (!nb) return -ENOMEM; @@ -269,25 +210,12 @@ static int amd_cache_northbridges(void) amd_northbridges.nb = nb; amd_northbridges.num = misc_count; - misc = root = NULL; + misc = NULL; for (i = 0; i < amd_northbridges.num; i++) { - node_to_amd_nb(i)->root = root = - next_northbridge(root, root_ids); + node_to_amd_nb(i)->root = amd_node_get_root(i); node_to_amd_nb(i)->misc = misc = next_northbridge(misc, misc_ids); node_to_amd_nb(i)->link = amd_node_get_func(i, 4); - - /* - * If there are more PCI root devices than data fabric/ - * system management network interfaces, then the (N) - * PCI roots per DF/SMN interface are functionally the - * same (for DF/SMN access) and N-1 are redundant. N-1 - * PCI roots should be skipped per DF/SMN interface so - * the following DF/SMN interfaces get mapped to - * correct PCI roots. - */ - for (j = 1; j < roots_per_misc; j++) - root = next_northbridge(root, root_ids); } if (amd_gart_present()) diff --git a/arch/x86/kernel/amd_node.c b/arch/x86/kernel/amd_node.c index e825cd4426b9..4eea8c7d8090 100644 --- a/arch/x86/kernel/amd_node.c +++ b/arch/x86/kernel/amd_node.c @@ -32,3 +32,59 @@ struct pci_dev *amd_node_get_func(u16 node, u8 func) return pci_get_domain_bus_and_slot(0, 0, PCI_DEVFN(AMD_NODE0_PCI_SLOT + node, func)); } + +#define DF_BLK_INST_CNT 0x040 +#define DF_CFG_ADDR_CNTL_LEGACY 0x084 +#define DF_CFG_ADDR_CNTL_DF4 0xC04 + +#define DF_MAJOR_REVISION GENMASK(27, 24) + +static u16 get_cfg_addr_cntl_offset(struct pci_dev *df_f0) +{ + u32 reg; + + /* + * Revision fields added for DF4 and later. + * + * Major revision of '0' is found pre-DF4. Field is Read-as-Zero. + */ + if (pci_read_config_dword(df_f0, DF_BLK_INST_CNT, ®)) + return 0; + + if (reg & DF_MAJOR_REVISION) + return DF_CFG_ADDR_CNTL_DF4; + + return DF_CFG_ADDR_CNTL_LEGACY; +} + +struct pci_dev *amd_node_get_root(u16 node) +{ + struct pci_dev *root; + u16 cntl_off; + u8 bus; + + if (!cpu_feature_enabled(X86_FEATURE_ZEN)) + return NULL; + + /* + * D18F0xXXX [Config Address Control] (DF::CfgAddressCntl) + * Bits [7:0] (SecBusNum) holds the bus number of the root device for + * this Data Fabric instance. The segment, device, and function will be 0. + */ + struct pci_dev *df_f0 __free(pci_dev_put) = amd_node_get_func(node, 0); + if (!df_f0) + return NULL; + + cntl_off = get_cfg_addr_cntl_offset(df_f0); + if (!cntl_off) + return NULL; + + if (pci_read_config_byte(df_f0, cntl_off, &bus)) + return NULL; + + /* Grab the pointer for the actual root device instance. */ + root = pci_get_domain_bus_and_slot(0, bus, 0); + + pci_dbg(root, "is root for AMD node %u\n", node); + return root; +} From patchwork Fri Dec 6 16:12: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: 13897346 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2052.outbound.protection.outlook.com [40.107.92.52]) (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 E2A2720E70A; Fri, 6 Dec 2024 16:12:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.52 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733501559; cv=fail; b=O7+fgFnSlvlmUJ+de2yWrtEOjeC3g7Gq8x00anlZgSIBwO4nskjd2BYFqhdHG7IzMSRashihVEdG097Cdzi5s+ilaDU+415wt6iHu/s14vMk4ajdA+dGTzf6Aq/2JT1v8XtHGUUJF2anISJi8baAT3TQw9ly2nvcmCK/TZTVcck= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733501559; c=relaxed/simple; bh=O2tgyfLuD4FrR/vAWACNKO2AEuAbqENgbcOrMaQbV4g=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kzUhaRp4ydrditn8g1tlTSAKL5HLxFPHEzPmk+PFsTsx7dn4UAyI0LrZK6faUYuWqLEMJOSsX7dokAZMz8MMfcyKa7E0P0jX3mn2rjqcaJQMoXz/TxH0XeAatBCCLIE/WB2hJOQAQdP9LU2pqQEUJirhAvhfKl3WYL2Gla311tI= 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=TobWx2KY; arc=fail smtp.client-ip=40.107.92.52 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="TobWx2KY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=T60rZmTow9T2r3QT6CuRtITE1wlEArKdxfS08fI0pw3jJ6Z1ldQLrXFrYOiC1Z2LHNXYfurD1IsCu7yf7oR/wt23dw3LhVuna5T62lIIWCRHoaX7KN0vHtRIEoW2AcPqFtZUu0O5YzlWH/GAdtg0uWmYkdThl2H4xEvVbPVcYKPQ9Db8+sYQ28mHs+4UibER1cW+R0lR2elLNJ/K+2EJgl1/yLVdnPHPS7SSQ/bsthPx6D/KoEfqqqNl7eMN0gMPlvr2U5VwIS8beHhoCSIuM/G9ovu7NqmPZoHKhqmDPo0FHDWjOEsbRMwZRiwBI3Y2Jzfj68B/YWnLHN8JVWejXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=AQdL5h0LeIad4WjSklXOQXicb6CKC4V6SyF7Q0m0rcs=; b=A8Ck1ZAxYtP4ZTcMSqoR9Q9v9j208eCdAGIgXPYOmEtVjsvFblTgZ9d3Pk4aORdaL54Y8+ya90NB8avtbWdr1ZaW206+w+i+HoyKCHal9LqRdOFtdgrpKUbPELCmP0mWQK1+C0+8Chjmcm+OHJCx6S7mmtDGs03S4DOTxtUFTj/UdyxgUsnlUM9Nwuzqxa/gST+3HwYMYCy0OodOtsshcR7bfqSNtvo+JHbGfPRtyI/D+RdHOxMEVrvTjlVYnhIdBykhDAIBwxR27Toj4IzQNbfV5Wqywx7U50KRdqD9or7rsDUf3Uf9g2Q9jqYFPjLO/TkQQy3EXejpouFwc8jB4Q== 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=AQdL5h0LeIad4WjSklXOQXicb6CKC4V6SyF7Q0m0rcs=; b=TobWx2KYLF/R1HX1bvdDdwVZLmTu/zQYZnbAVEWd7DZK+z/vklOAivyoP+nSpYSVrf8mrUW3awmDHTeupK5c6lAln1dhbpLcMjy53gaZZFj/chW5/IMOF2XLmuaJ+EKwQl5NOFDgbXqj7vApxRnHUbcSkgDWQzBOBeA9gXHY8m0= Received: from DM6PR02CA0057.namprd02.prod.outlook.com (2603:10b6:5:177::34) by SJ0PR12MB6807.namprd12.prod.outlook.com (2603:10b6:a03:479::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.18; Fri, 6 Dec 2024 16:12:31 +0000 Received: from DS1PEPF00017095.namprd03.prod.outlook.com (2603:10b6:5:177:cafe::70) by DM6PR02CA0057.outlook.office365.com (2603:10b6:5:177::34) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8182.15 via Frontend Transport; Fri, 6 Dec 2024 16:12:31 +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 DS1PEPF00017095.mail.protection.outlook.com (10.167.17.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Fri, 6 Dec 2024 16:12:30 +0000 Received: from purico-9eb2host.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.39; Fri, 6 Dec 2024 10:12:29 -0600 From: Yazen Ghannam To: , , Tony Luck , Mario Limonciello , "Bjorn Helgaas" , Jean Delvare , "Guenter Roeck" , Clemens Ladisch , "Shyam Sundar S K" , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Naveen Krishna Chatradhi" , Suma Hegde CC: , , , , Subject: [PATCH v2 07/16] x86/amd_nb: Use topology info to get AMD node count Date: Fri, 6 Dec 2024 16:12:00 +0000 Message-ID: <20241206161210.163701-8-yazen.ghannam@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241206161210.163701-1-yazen.ghannam@amd.com> References: <20241206161210.163701-1-yazen.ghannam@amd.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.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: DS1PEPF00017095:EE_|SJ0PR12MB6807:EE_ X-MS-Office365-Filtering-Correlation-Id: 0e40a525-8bf7-4a33-acab-08dd1610c94d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|1800799024|7416014|376014|921020; X-Microsoft-Antispam-Message-Info: j9sKG9+/+WGW2I13TQOTzkfsRvLmZMxmsHKT6MN2aEXcLi6O9XHpZPtXaLs0M/bdzyFKqL1FEcP/MFgv2MGyLaJprWuM0WNkubEg9Mj5nW4vTS6liTAl51mRfTUvFb1Bcgcro6dGMhWqJtiyH/7x1RLfm2AveFY3hpQ3ikdIlWGOSg4f5sbueCndFRh2ADWIzilhdcUVEE38MsdaZSzzK47dZgcmtMGlnKjbNphtpRAGRyloKX2b4T3rALddh1CNEQI7Lrmz9zsyVrIOVNSkcyMEnFZrRo5en6j0VO+fVLZtRgDMDK7pbQZ6J2KvFE6Fq9lp+owQoZZ/TQ/xuRmbjOMxxQ+V2L6TcICbx43njWNTTZOHe/qmV9DS+/hrZTuEq89pmiYi8VNTf26HseSyYbFAWypF+ROg496o9tV/HW7+zt73yNCEvs6Hv4tZzImgYfRMQruIiCt/RZsJfwQpy1DpkVs+HQMOMgdxizoIyB0T7H5cL+8d0drw6MPRkDl8eQuBZxps0v9wclK0XIV792LPtNjjF07YQJUlvAOeIqFTlXH+xwxdE9M5bQtNnvBmX9PtNNGTBk8BJ9KKFfo1Bb1eQEiJeDly9Dv28jbqGX22gGqB1fNVkL0UYBvuf06TK9yrtBv6isM4ceQ57NG3QqP2olcVL6RC+WCce8Qouxai5ZBZdOLR5fm5caBWn6jIlO8DJr0EBEWwRAutu6DZRgMoat7i7HuPm1nKXfhy8M+dB8C4Ce+yFaEF/Q1Yrq1ghqoezCUYt3zU/4Q56iHNwHaa/94blTrwI54Ky8UCDHByHP/p62oEAqmAZTUeNitT1Tu6f+1qzjji5xwd22pLZzvc/DZoZ8xIimVtn8y7nOjDxFfmamRlagEYJSKG2VYGTJBZ7Z/w2fGE5Mb82nHHHxJVGoS3+/e7d/ukJZ1jwWbWpWZtlbM09v1eNOKxrWHu5nItO/R8DAJh7lvRZd//Z1F+6vka/61a6+Jh4l70e/rfx77TYJCWH5HTke4Hqpsg9QSUw5+lf0gSj3TshRygDe49xSyQOyFmaBKkKYiBNz29Uvn9IyOddd0nCr/Idsm+I+spfQSUcHf8CuC1z4RPSegyGB6pAP3Y6dM4jafPQKeTdjqX+NH06hfezA5pN0s27nKqNv/jHMeVn6IIGt4WIGN6V5lRphb6ZYBxQIT5Osvv54xmp9BK4Zjh/rsSHLOtUfHG3gT45AIqhb6d3+7DYwPFMNAXxy9wQckirI7Hgn1GebTSJaRnRXx/VHQxi1GNT985b2zizR61b8Xna7dfRfZSgpieXhSly55DTe/VVpsKeo1fbvVdu8MmN5rxkFlX5tupUPfSm6utBAm+uFZTiGhdfXQgR6BLJzq9iJTrncUUjAbydW7RCAb1bFzvDi2B1cgX/XbBenIXIDWTU8CSyPFlh4YVH/SzlKStcjLioHRENmeCHyvqEZnCkVeAeKK1hcE5WyEFrlxMYVJEokFplA== 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:(13230040)(36860700013)(82310400026)(1800799024)(7416014)(376014)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 16:12:30.7983 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0e40a525-8bf7-4a33-acab-08dd1610c94d 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: DS1PEPF00017095.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6807 Currently, the total AMD node count is determined by searching and counting CPU/node devices using PCI IDs. However, AMD node information is already available through topology CPUID/MSRs. The recent topology rework has made this info easier to access. Replace the node counting code with a simple product of topology info. Signed-off-by: Yazen Ghannam --- Notes: Link: https://lore.kernel.org/20241023172150.659002-8-yazen.ghannam@amd.com v1->v2: * No change. arch/x86/include/asm/amd_node.h | 5 +++++ arch/x86/kernel/amd_nb.c | 11 ++--------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/arch/x86/include/asm/amd_node.h b/arch/x86/include/asm/amd_node.h index 3f097dd479f8..419a0ad13ef2 100644 --- a/arch/x86/include/asm/amd_node.h +++ b/arch/x86/include/asm/amd_node.h @@ -25,4 +25,9 @@ struct pci_dev *amd_node_get_func(u16 node, u8 func); struct pci_dev *amd_node_get_root(u16 node); +static inline u16 amd_num_nodes(void) +{ + return topology_amd_nodes_per_pkg() * topology_max_packages(); +} + #endif /*_ASM_X86_AMD_NODE_H_*/ diff --git a/arch/x86/kernel/amd_nb.c b/arch/x86/kernel/amd_nb.c index 6218a0428c77..371e33abbdc1 100644 --- a/arch/x86/kernel/amd_nb.c +++ b/arch/x86/kernel/amd_nb.c @@ -186,7 +186,6 @@ static int amd_cache_northbridges(void) const struct pci_device_id *misc_ids = amd_nb_misc_ids; struct pci_dev *misc; struct amd_northbridge *nb; - u16 misc_count = 0; u16 i; if (amd_northbridges.num) @@ -196,19 +195,13 @@ static int amd_cache_northbridges(void) misc_ids = hygon_nb_misc_ids; } - misc = NULL; - while ((misc = next_northbridge(misc, misc_ids))) - misc_count++; - - if (!misc_count) - return -ENODEV; + amd_northbridges.num = amd_num_nodes(); - nb = kcalloc(misc_count, sizeof(struct amd_northbridge), GFP_KERNEL); + nb = kcalloc(amd_northbridges.num, sizeof(struct amd_northbridge), GFP_KERNEL); if (!nb) return -ENOMEM; amd_northbridges.nb = nb; - amd_northbridges.num = misc_count; misc = NULL; for (i = 0; i < amd_northbridges.num; i++) { From patchwork Fri Dec 6 16:12: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: 13897347 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2079.outbound.protection.outlook.com [40.107.95.79]) (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 3193620C499; Fri, 6 Dec 2024 16:12:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.79 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733501560; cv=fail; b=ZfGoZKk039h2geVfLnQVkQgmV2cWj+bBpc7O0NwVhlPAEip5vh8zQ4mT+TJsWlfmN+D6aliKLx35hxz6IDNhjo/Jd5KiiVwOqvSoorQG+JDTi1Egtkm+dcJ+XTV1dsd99x70ZKShaSs7fZ9SyIWt5oF690rqaRCjDFjdCTDn1OM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733501560; c=relaxed/simple; bh=d/9HDBSR0JtmK7V5Upv7zq1fRY0CHrxc/r1Sr+bBv9A=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Weng6dmY993vrWYRvaqikqTx6OkP8zVSPusW7LozLT9MNQPW1Chp4b2UbQWL4nX6h2fAdipSKjY0lQML+fiJRLB42fc5U+oKfROtQSF21B5OL5UiTLq3GKKEgLa0AsbfTdmq891tA/xC8aeaFHhslT8WgMMd1Lm5fytq35MGKVA= 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=1Sl1mJbN; arc=fail smtp.client-ip=40.107.95.79 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="1Sl1mJbN" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tHysRqGGbd4Qp8RwtGF2Bn2W9DX7A5yBr3T5yj1fNS+jtNwpmr1i8ciPtiIw5HUV6DFIPGAPwG264RI1hRmZCjfh+NeKMwhyG5eGqogX8kNwNSnqX9oudJ/gXRmit70eKXXVSwp6F8xp1d6qp/v347Vk3pNm1a86n4/OCg/SayJhhD64QjK3fIgvqWRGYcrjBSzp9VwVR3yG76Ctx4l79KIlLe6vWJQb5MnCGQGTKk1eXmkr1hSOUF+J/uDb0WxhyQPvV66E6c19E9BF+Z0ENWdtSkN9HLqRCck/UD6ZSUpuhLd8cd2KzVZ7Jv+DRhdpLKlRd3HWZDuGmxmaynfpjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=jYoNyCkN29Tmhbj42lp0Gh4DMmmSHYD9oli23mlTHtA=; b=Ujl5EZ9VA3Dp0uLgCiKexAHVq9q5sSDTgigokIzrj5WLiw0kfVo+GbAbYaaaHKIN2OuHYxqQCMIlKYzbVf6BqUeioDwly0JXKkkrkLR+pWl0hinxk0J+xupJpJ+5jFUvxJHS5gGyX4wjea6juhnUZ4SOJO7Ll6SNy7WXwhdvj0p959qckAIkc52kvv/WWTUWR0JLdQlTOQUuILSeScPfMpRFTQy/+5wrYrKY9nrOv6lDZ8UBM1p8pjYyl7dZxpMnOfRFKXnT6Ir6y3Gm/Noq4xSQPXJriIr3NwwBqtlRME09nvNQ+hUo7rg3c3ZfhUyqliGparsIb5h+i7f7BIJbOg== 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=jYoNyCkN29Tmhbj42lp0Gh4DMmmSHYD9oli23mlTHtA=; b=1Sl1mJbNhWRVVOLIcqp15dBuJGEaWso/w/Ro6z8g4hk1Jed7NVc+mr1bIy2vaVXQ8J87E1DWOEQcRDSZtLv/+U+06bNWGA3l7cVowMLYNM8uQl/WHqoEBioJovQQd9CGzRDgD15LKTvrLmjvzwl4UCAgHNYvIhzWlqFMP4TBTiE= Received: from DM6PR02CA0063.namprd02.prod.outlook.com (2603:10b6:5:177::40) by SN7PR12MB6888.namprd12.prod.outlook.com (2603:10b6:806:260::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.24; Fri, 6 Dec 2024 16:12:31 +0000 Received: from DS1PEPF00017095.namprd03.prod.outlook.com (2603:10b6:5:177:cafe::17) by DM6PR02CA0063.outlook.office365.com (2603:10b6:5:177::40) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.12 via Frontend Transport; Fri, 6 Dec 2024 16:12:31 +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 DS1PEPF00017095.mail.protection.outlook.com (10.167.17.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Fri, 6 Dec 2024 16:12:31 +0000 Received: from purico-9eb2host.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.39; Fri, 6 Dec 2024 10:12:30 -0600 From: Yazen Ghannam To: , , Tony Luck , Mario Limonciello , "Bjorn Helgaas" , Jean Delvare , "Guenter Roeck" , Clemens Ladisch , "Shyam Sundar S K" , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Naveen Krishna Chatradhi" , Suma Hegde CC: , , , , Subject: [PATCH v2 08/16] x86/amd_nb: Simplify function 3 search Date: Fri, 6 Dec 2024 16:12:01 +0000 Message-ID: <20241206161210.163701-9-yazen.ghannam@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241206161210.163701-1-yazen.ghannam@amd.com> References: <20241206161210.163701-1-yazen.ghannam@amd.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.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: DS1PEPF00017095:EE_|SN7PR12MB6888:EE_ X-MS-Office365-Filtering-Correlation-Id: ee98584b-bc78-4ad1-bb77-08dd1610c9bd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|82310400026|1800799024|36860700013|921020; X-Microsoft-Antispam-Message-Info: WmHjzeckOSz3wdmcL28fyC00+ATUBVcldsaTGB1Rwg7hEoOgvrpC2hIv9H5HSawqLGoGpcXoSSTOAa4AketHUpy+zae84buMQX/r5wnS50Gd/XSe02LDJGS2kp/6zciqRdxjpd0S64i9LPe3a51USVid3vec3FXgjTgMyFTZ2UZPUZvRsDDy71jGY+RvIQ3vsJPu/ZsF2bu3usDQTPRKfRrpu57Ookur8s9zuUjBmAccE/CbbSWw6I2QtWXZ/Hi1mGJofffHvZSR/h+r8Sn1oIOBtVRjYN+lXt/3Wd7tnCuPwB4Mt56ZpD1v69J/cOUZ+i/yKjF/U7x9XlrkLIOksyvAPcgzLrILsq5W63U4dJJDUewYXB7pOLqTTFK3itpsxx9rqB7wh3IWuH3H6Zn9a/Ey+QIUzHpAQYOxfRnYyDk73qzyc0vQOppmu5hAw7rCcjWBpNhi/MKArooMSpnV+Sm8nzOwiI9fIrzPMN/hU0/NKdQINYdOFGjrpSNj60F3rxX5gQ0ZI4aN3ui2bbCwddxVRbyvO7PzToNSPE3GNV2OJQJWk3KxCSeCe6d3vd9oLtSf1u1dA/+LUp6ahXjm6jPj6uVXMU8I2zeIQB/eNU/CM3TxlwTAZP4dgodQkvWrs8f55wD8u6PutZ33FP4GphS9epf+MFrZOSfY3j506PqtMGi3gxFsTw9LApp7dOUHA/2pY4p5LG2PMKcS6s6UfBRnrMdY3u3p4PV1J3rI99MOFB4PNN6oAqE3SUm2plHsPZwg3uR5JXKyPgiYQp7sLoE+nF7p5qvpnJ4Bure+zTSDF81YTZ/cvFRlTITYv7T34BKP77XuKITR+tGWKzkANlCIaCvpBQ3ahvkQcZgLHrZKO1LrWd/k9eyYFMo6OjQekbcIGcyc0PIkuefN5vHUC9qBSo08pEib5exkQhJJqpnibeiTfdoR2qvcjPGM1Ht5Qb4x+Xpur1CSyLkhjCMI8y3n/o77FhOP0h7AB7tOCr0//alqn0yjSAbY5KlVkruGbUK2qJxbnhH3y/JctnOCc32+msBLXhC5EKaYAe1HIwfA2OvKIDz/FO2E/bwL206IL9yrayBHWr/bP8zeFDgLErk7mtrB7d062pjcYn8htrnPVEmXvXd3at9d+nhoR7EtSIwpXspBW8BAmZhJ+OpjimNTHIKuT4irBi9StC4Oj3D0t/0Ul4bV4T7A2K2KLTuuHI7PjmFYo9QEJpLrpUYI/6Lafmrwf4KQFTA6lYnLC9nLJMpoEbICxVf8oZ7Zt+fz3u1Kq5N4e6xE3ejdOPAIkOmDmfaxeCkkRf1wtLySa+1E3HGSKSUlugH3fadgdFF0rACIlkIcl7S4oXadnR4kBWO06GE2VA4QJq5bS/0c5N4kdXTvxhWSJMkQDnb83JLnP9vHDyyP9VEZfgCPipdaVX0ZkJvVrXpHauABUSNoOdvje/5oM9Qq6LziBLxly+Y8t6vQ32c5+dLYL0EnsjmQWw== 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:(13230040)(7416014)(376014)(82310400026)(1800799024)(36860700013)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 16:12:31.5327 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ee98584b-bc78-4ad1-bb77-08dd1610c9bd 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: DS1PEPF00017095.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6888 Use the newly introduced helper function to look up "function 3". Drop unused PCI IDs and code. Signed-off-by: Yazen Ghannam --- Notes: Link: https://lore.kernel.org/20241023172150.659002-9-yazen.ghannam@amd.com v1->v2: * No change. arch/x86/kernel/amd_nb.c | 46 +--------------------------------------- 1 file changed, 1 insertion(+), 45 deletions(-) diff --git a/arch/x86/kernel/amd_nb.c b/arch/x86/kernel/amd_nb.c index 371e33abbdc1..2ad67efe9032 100644 --- a/arch/x86/kernel/amd_nb.c +++ b/arch/x86/kernel/amd_nb.c @@ -29,31 +29,6 @@ static const struct pci_device_id amd_nb_misc_ids[] = { { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_15H_M60H_NB_F3) }, { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_NB_F3) }, { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_M30H_NB_F3) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_DF_F3) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_M10H_DF_F3) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_M30H_DF_F3) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_M60H_DF_F3) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_MA0H_DF_F3) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CNB17H_F3) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_M70H_DF_F3) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_19H_DF_F3) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_19H_M10H_DF_F3) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_19H_M40H_DF_F3) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_19H_M50H_DF_F3) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_19H_M60H_DF_F3) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_19H_M70H_DF_F3) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_19H_M78H_DF_F3) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_1AH_M00H_DF_F3) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_1AH_M20H_DF_F3) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_1AH_M60H_DF_F3) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_1AH_M70H_DF_F3) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_MI200_DF_F3) }, - { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_MI300_DF_F3) }, - {} -}; - -static const struct pci_device_id hygon_nb_misc_ids[] = { - { PCI_DEVICE(PCI_VENDOR_ID_HYGON, PCI_DEVICE_ID_AMD_17H_DF_F3) }, {} }; @@ -84,17 +59,6 @@ struct amd_northbridge *node_to_amd_nb(int node) } EXPORT_SYMBOL_GPL(node_to_amd_nb); -static struct pci_dev *next_northbridge(struct pci_dev *dev, - const struct pci_device_id *ids) -{ - do { - dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev); - if (!dev) - break; - } while (!pci_match_id(ids, dev)); - return dev; -} - /* * SMN accesses may fail in ways that are difficult to detect here in the called * functions amd_smn_read() and amd_smn_write(). Therefore, callers must do @@ -183,18 +147,12 @@ EXPORT_SYMBOL_GPL(amd_smn_write); static int amd_cache_northbridges(void) { - const struct pci_device_id *misc_ids = amd_nb_misc_ids; - struct pci_dev *misc; struct amd_northbridge *nb; u16 i; if (amd_northbridges.num) return 0; - if (boot_cpu_data.x86_vendor == X86_VENDOR_HYGON) { - misc_ids = hygon_nb_misc_ids; - } - amd_northbridges.num = amd_num_nodes(); nb = kcalloc(amd_northbridges.num, sizeof(struct amd_northbridge), GFP_KERNEL); @@ -203,11 +161,9 @@ static int amd_cache_northbridges(void) amd_northbridges.nb = nb; - misc = NULL; for (i = 0; i < amd_northbridges.num; i++) { node_to_amd_nb(i)->root = amd_node_get_root(i); - node_to_amd_nb(i)->misc = misc = - next_northbridge(misc, misc_ids); + node_to_amd_nb(i)->misc = amd_node_get_func(i, 3); node_to_amd_nb(i)->link = amd_node_get_func(i, 4); } From patchwork Fri Dec 6 16:12:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 13897349 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2044.outbound.protection.outlook.com [40.107.236.44]) (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 051E720FA9A; Fri, 6 Dec 2024 16:12:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733501560; cv=fail; b=g7+C9clnG41XUpI9A6FbL5DC3n/7VG1epYeOhaj+sQKRtp92w6+ygGulUpNypR4VnBiyh05sYIy8zmQSVhLLQFbSBjxJJc1Hmis6sGa/p1ISeK0VipU912a2KH8fXIcOs2OQQ2e4kJ3qwVg07FZzEoggplPVdDo6uzKuHLxZZh0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733501560; c=relaxed/simple; bh=KYMkyD09g66g1KOmFrbgLAtyxx2po0J/C/CdY6F7zW8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=B5xfNue7gmrNviMGyO3IzOdiQEyYU4oYQRICELVH8mTTm1OSVsPxwSm7jL6/39SgxbJaRbI+m6mrkJqN8CypdsoFmU2lLGP+4ABiG+pX5Dkfj2Bo8vpQ7xAzc13bgKA4R7mr2s5fyQkrCiLkjL4Io2k2mMEND3uJ8IGWo+r0n0g= 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=zxDcMQUt; arc=fail smtp.client-ip=40.107.236.44 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="zxDcMQUt" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=P24kErQqYbVqx9AfMhZfufYyHo/PqjdJBXZAWp/YlL5VjhBhJYeYB+Et/6QMbHAQDhKzn/ViJpV8WF4X1ETzw/o+L5ghbWCpUHo9Ii51HY7LmCfDYPYTm4ZCpkgPil3t2tzj9toYCeH/c2a9pT39hqz6hah1+6P2PV/lc3kKuNA6TsX5IdHWq9DFWwDrM8ncY5LNWtV9kGglyKQ/49KypUu90yyjrCj547b2hha1h3liTnWfEgyi1CvxzJu/BzczZdaT2+X+q6Rd4HYF7avdbeqeECloc1Ua0bLjS59Vj8Go/k7DntCwVjwVf/CJwuZ9O6pRInKMSzwh4vEPQO4kkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=5fwT3ZKKS0G3C1n9Is0V1PZ7P4RBFR+IA1u6KPmwxU4=; b=vnUvrec3iJcDlXFj9qQH1J5GtZF70gb0sM5rrHsa+o0yBNZ0UJHWCyTAzRXChxBuImS2yZfTmQxnT3zpBGYh1oiv1aaGRg7yeWhEG4owEj3FSEin++6rARj1lBOk0PAQ+eN7GDxKcOEH6Y6X64upOTbopEruAWvBLQmGmsLPIrK9vZFEPPHXpoQ/+0e7Jrmuh7C0yKgoXbj8ABZBsmVxVJkWRq/9etQsfqyz9TpKlZdnMw7AvHuefHAF+akCL5alQaoUQd1LzcJrxU+04V9MMeTxdh/IMDdL+p9NBeCum2z5dMpTrHdK3uVPeNrb8zOsa/WJYn6aqxq+6NYs7XWIEA== 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=5fwT3ZKKS0G3C1n9Is0V1PZ7P4RBFR+IA1u6KPmwxU4=; b=zxDcMQUtfUXoAZVWcVzS7BCuaVnhgGFoo1864i6zcv1TbsxJV1+ft4ByU0mZJ44BbB3JOuDjAqOORJypbKc27P1lDIDgpUYdeKC1QfEkhxNDtk0Im13mKwWzhMMgMbpZVv9zsy4Q9SMw+YFKMw70/r9pL9O70ruT67vulfivS2E= Received: from DM6PR02CA0064.namprd02.prod.outlook.com (2603:10b6:5:177::41) by SA1PR12MB6845.namprd12.prod.outlook.com (2603:10b6:806:25c::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.22; Fri, 6 Dec 2024 16:12:32 +0000 Received: from DS1PEPF00017095.namprd03.prod.outlook.com (2603:10b6:5:177:cafe::ec) by DM6PR02CA0064.outlook.office365.com (2603:10b6:5:177::41) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.13 via Frontend Transport; Fri, 6 Dec 2024 16:12:32 +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 DS1PEPF00017095.mail.protection.outlook.com (10.167.17.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Fri, 6 Dec 2024 16:12:32 +0000 Received: from purico-9eb2host.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.39; Fri, 6 Dec 2024 10:12:31 -0600 From: Yazen Ghannam To: , , Tony Luck , Mario Limonciello , "Bjorn Helgaas" , Jean Delvare , "Guenter Roeck" , Clemens Ladisch , "Shyam Sundar S K" , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Naveen Krishna Chatradhi" , Suma Hegde CC: , , , , Subject: [PATCH v2 09/16] x86/amd_nb, hwmon: (k10temp): Simplify amd_pci_dev_to_node_id() Date: Fri, 6 Dec 2024 16:12:02 +0000 Message-ID: <20241206161210.163701-10-yazen.ghannam@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241206161210.163701-1-yazen.ghannam@amd.com> References: <20241206161210.163701-1-yazen.ghannam@amd.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.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: DS1PEPF00017095:EE_|SA1PR12MB6845:EE_ X-MS-Office365-Filtering-Correlation-Id: 9da51e1f-7967-454e-67c3-08dd1610ca2b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|376014|7416014|1800799024|921020; X-Microsoft-Antispam-Message-Info: y6yg8+E5JWSgb92rTagorQ06nmfPPCnbBc6NHTBEufxE78fqn/4RC8XW9PcKNYWZGsGYzALomztfecpuY5+YnHSfTAEpB4vy13/a0FafYhxJQzmBcBTquGPeFcXZsKb0ejRlYf/ihGSAYrMFcIlHfYzCFr9C0DEvrntYjQ20MkRqYc3LYE4kabrCFfpIIOCNfI+a7j/A/RdsYXWVDlvwi/LGsPRgrAXaUpVJwgY0ah0MgH2XAMjOOheRPYE69Odka3Ppm8PbnrQ7LwxKon0Gh2HdoSqzX675zcCcB7A6zeX+FP93FFhnaXd6RQFHCJo0NEANz+sTTIyr1MyHB6huODvC4krhgP5II524Om9VetRbtZW6tw5NmU2MFjk7zKCEZHufc9iUHjq6L3OixWquo/juPZPJzIQnQENRcb011L09ZnqeC2cF6de3tdyRAhuiXd1gEGV131RKCJr4bGRRtD3qV0Wtx2pSSfGdXp+S+LzTIm75s7CurqBOJ6FrZzW8P1SS5bX7vWSR/6fr8ceUEBoCNydYnsrrrINM6vwZjkho8pZPYI4NjQ6AxWPsBanBcOzSe1V6s1gxdD9BEsdABzjL+TqWsuqp7JWo3slZoGI2+gHDsfsgtKpeVni4PK7r9DD9hW2NDJv4+iBFf9l3y6O9Yj2L6boA7dSWPlzq2slOXmr9zTJYNjZhAdXm2DadiXguLYjoFr3hOtoyzHAoq51MYwSzGw4d7LnovVvLncozN5hn+It86uvl+gg96IeD2a8SwOVf3sHBpdShTZM8k+U4yux3rX/C8VogdMad32h+cdz9exDClRElWye1Squm2FtjVMud8a6fZbzKx4qC9BCsh9QN6Zllms5b9/OY9TeZrbFdxjH1YRYzU0tvtd32MWiaVBAoLwTodsQWHSxnBoCpsizF4bsPGMvKMS1xI9MgqgN8DvesnN6E+oAkyjm7vo/3ZCQikENzAiKmGcP53ASLIDZ0GpztsA5KeJljT2XfncAp1bWnSlJY+M1NadeYRxyI1XOWegOVCFRr07WsWuiMyPEUl3z1+Lmnkpc5XPSqsBqG0XxTPCE4OEH7iUcBevq8+9lmuWBhucvazwxEA6mRh4z7tFyOhE/JIU2cj5NT5+H9b5us2EBVTsPDb7BxWXKUgKKk5Dl1Wx7GlnFbgvwgQoEdwsNXoyG6kQpTcaM4UmAiLNCEF5cO6kISqtttVzMM4CIrD1pqzOL/MH+6cs7NikZvoaIQ/xsL3sw8cg6yBuCT/kBj0NXPXKZqzxvRKONel2AGzEBjNNV2kK508J5LdQ6Ja0ZZM6UzjYeYoUlMmc0B6Vwc1biBNWHK8BA1VXBf31YOslRVR/vvXEDql8TBMXlGo4NaaCzdhlSuODuXh+3KSJHQfuYrdbgTEfARgHsjtAlNWXfAF2Us098Eo6cO2Q1wVkJMD/c0oaL8OROMRS0ZNX1q+r+mycDzHykUg2MzhcKUw6xxVI+AMSCKxA== 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:(13230040)(36860700013)(82310400026)(376014)(7416014)(1800799024)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 16:12:32.2514 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9da51e1f-7967-454e-67c3-08dd1610ca2b 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: DS1PEPF00017095.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6845 From: Mario Limonciello amd_pci_dev_to_node_id() tries to find the AMD node ID of a device by searching and counting devices. The AMD node ID of an AMD node device is simply its slot number minus the AMD node 0 slot number. Simplify this function and move it to k10temp.c. [Yazen: Update commit message and simplify function] Signed-off-by: Mario Limonciello Co-developed-by: Yazen Ghannam Signed-off-by: Yazen Ghannam Acked-by: Guenter Roeck --- Notes: Link: https://lore.kernel.org/20241023172150.659002-10-yazen.ghannam@amd.com v1->v2: * Move simplified function to k10temp.c. * Based on the original idea from Mario. * This can be removed when reworking k10temp. arch/x86/include/asm/amd_nb.h | 17 ----------------- drivers/hwmon/k10temp.c | 5 +++++ 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/arch/x86/include/asm/amd_nb.h b/arch/x86/include/asm/amd_nb.h index 31547108de1a..066dc3801430 100644 --- a/arch/x86/include/asm/amd_nb.h +++ b/arch/x86/include/asm/amd_nb.h @@ -52,23 +52,6 @@ u16 amd_nb_num(void); bool amd_nb_has_feature(unsigned int feature); struct amd_northbridge *node_to_amd_nb(int node); -static inline u16 amd_pci_dev_to_node_id(struct pci_dev *pdev) -{ - struct pci_dev *misc; - int i; - - for (i = 0; i != amd_nb_num(); i++) { - misc = node_to_amd_nb(i)->misc; - - if (pci_domain_nr(misc->bus) == pci_domain_nr(pdev->bus) && - PCI_SLOT(misc->devfn) == PCI_SLOT(pdev->devfn)) - return i; - } - - WARN(1, "Unable to find AMD Northbridge id for %s\n", pci_name(pdev)); - return 0; -} - static inline bool amd_gart_present(void) { if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD) diff --git a/drivers/hwmon/k10temp.c b/drivers/hwmon/k10temp.c index 7dc19c5d62ac..cefa8cd184c8 100644 --- a/drivers/hwmon/k10temp.c +++ b/drivers/hwmon/k10temp.c @@ -150,6 +150,11 @@ static void read_tempreg_nb_f15(struct pci_dev *pdev, u32 *regval) F15H_M60H_REPORTED_TEMP_CTRL_OFFSET, regval); } +static u16 amd_pci_dev_to_node_id(struct pci_dev *pdev) +{ + return PCI_SLOT(pdev->devfn) - AMD_NODE0_PCI_SLOT; +} + static void read_tempreg_nb_zen(struct pci_dev *pdev, u32 *regval) { if (amd_smn_read(amd_pci_dev_to_node_id(pdev), From patchwork Fri Dec 6 16:12:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 13897355 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2074.outbound.protection.outlook.com [40.107.223.74]) (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 7336420E012; Fri, 6 Dec 2024 16:12:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.74 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733501573; cv=fail; b=aBxqAdZhQE38IpgV531TdBCp8itJK1727srBr9LKtcRINPAoLJoYIBQkRawU0wUgErjhmBGKaBVk8Knczlr0b7qZ7k3PCyoZTZwWRmNIFzNHsyRYapopvQrzGsRINu8X4EhLr4VZFwh+t2+V19Hlje3ohEglscTVy4Us9lqPZ/o= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733501573; c=relaxed/simple; bh=CDo+hEBWn8fDB9VZnKoPhXDI6kon5Dl/JqSB2wJ2wps=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FurxP7ehOB1o6j6TqvApdGTa3BxLy3lOc28c+tOPEE9pyPXkrWCyzwPVenC/6MefvNXzStYN5R7woh89OLJfY8Y71iYs8p5l4sftgKm6xsrFzEvHvJSlxY5HF7zxjU+dl/QehIhOK0twhe1YvzMCcA7I+9A31yDcJ5Y0kHi7WJA= 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=duN6B6km; arc=fail smtp.client-ip=40.107.223.74 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="duN6B6km" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=am1wnlmFdXv/eguMO5XhWJxdSXYevi8E63Tjgx4yzsZ9MXQ8a2//4XwReeGSw8puiixa5YPb3Tt5W+Fp0/GtnGWRpPj7Rr077ZVZyLjrJYhH8aNj0lT18LbsQbw04w09LUzwyxc4SeC7nERXR+zXYZFtYCwOTf4JD5dfjeuBFN6CfRDlWp1+1CkPCX9uPmC9jEYUU+/5V/2wR/t1UiEQnxcKK8S5BG5iUsy44NINyPwCcNlZu1d+1XAEtUs02ngPYujYKF349aN7J2udb+h+HTSi5RpoRlEnRoQ72ccPP1hcADUdH0Szr7+SJcILrxDVP/Ta4u1CkV5Dp85Qu1tAgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=byqu+VBXhyRQnZe8soU+QIm5j6cIaK98iGLCFBNB81c=; b=qtdgSDb/4qOdw1XcJpgZ4N1I25DrJxL1Xcjww9lThZ/pYj479JwTzi5s3M2q/Eww0dw8U7gt95rB52kfk755PpdJQGs0NAdZGmmtakiqC5GFp4UPYBhmAXC+eGlUxCNiYHpjVt8XKByzit8nfXlTGpDoNk4tfw9YHsQETHRmGA3YyEZVxh9yilz5pAbIbm7fNMjWsh6JhKZyZG9YaYEMs9w+GRLYqmcRWm9f8NzpoNMesXzeXlaf7REx8n/VJY3jZkJ8slHwm8Oe/7w+/1xYx+EF1ELWSZYKVf+t3ykDfZLSuFWA1/c2YWClibjXTRK/bSJL6H4cSL7xWjo4nTjy/Q== 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=byqu+VBXhyRQnZe8soU+QIm5j6cIaK98iGLCFBNB81c=; b=duN6B6km52BqTTqzoWvxAkHCN7LPAmGlSBEbI5lSmG9btMLeu+L4XFm8b60kZW8BWGnnC5iYQ7C9mIn+y6NhuNHcP6N7c+b56e3tLXMO/FC0GyK6B32z4mCBuh/WS9wbRuLDqSgBuIy8rb2thM4JLVWFn3w0TQwkdDIgWi/e6CQ= Received: from DM6PR02CA0069.namprd02.prod.outlook.com (2603:10b6:5:177::46) by LV8PR12MB9083.namprd12.prod.outlook.com (2603:10b6:408:18c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.19; Fri, 6 Dec 2024 16:12:33 +0000 Received: from DS1PEPF00017095.namprd03.prod.outlook.com (2603:10b6:5:177:cafe::7f) by DM6PR02CA0069.outlook.office365.com (2603:10b6:5:177::46) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.18 via Frontend Transport; Fri, 6 Dec 2024 16:12:33 +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 DS1PEPF00017095.mail.protection.outlook.com (10.167.17.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Fri, 6 Dec 2024 16:12:33 +0000 Received: from purico-9eb2host.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.39; Fri, 6 Dec 2024 10:12:31 -0600 From: Yazen Ghannam To: , , Tony Luck , Mario Limonciello , "Bjorn Helgaas" , Jean Delvare , "Guenter Roeck" , Clemens Ladisch , "Shyam Sundar S K" , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Naveen Krishna Chatradhi" , Suma Hegde CC: , , , , Subject: [PATCH v2 10/16] x86/amd_nb: Move SMN access code to a new amd_node driver Date: Fri, 6 Dec 2024 16:12:03 +0000 Message-ID: <20241206161210.163701-11-yazen.ghannam@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241206161210.163701-1-yazen.ghannam@amd.com> References: <20241206161210.163701-1-yazen.ghannam@amd.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.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: DS1PEPF00017095:EE_|LV8PR12MB9083:EE_ X-MS-Office365-Filtering-Correlation-Id: b5bd210b-22f7-4e7b-9d8d-08dd1610caa2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|82310400026|36860700013|921020; X-Microsoft-Antispam-Message-Info: HmaH/4CtGKtAXUB8cBTmc8nRdAS1x1FJTIx2wLzIVlqalA/knVH3GKWARclhRwDsPi2zLaJEN5LQxYHPuVeO885ThuJZhbh84UDAdp/xYrjOO1OUCr7dCKoHfZwhEeETTyhC5/iiOVDoyI3Bzwy5w+W8Mm3BuwUpRJmhRq6TQqucZB1AKH1HMoxi5mk9Ucb9yBC0puBYuttXjWALx4r0bkGn4+OnU52qaxLsxDgGp2Ax+477MiRNYFs0SxOl8hP1gua5bw5inhOytVS8C1eH6IgcKRfwBv56XrwdKLIYgUETmSqNbs1enD33kzzn07d7fOw8EDANnyUDeSnJdAaGVKFSeSzwRGngo3D+03Mjp94UFLIwEyJAs9sl+LX34jMu+4PrPB4TQsNj20fnJ/3ib6V0o5pIIkX4LkhFdrzZR0rKSc0bP+TO/EowlljMwKFCQv37GMWirVHXZRdDNc0bZtCv5mwUu3UCm1m5IVYLzD1CC/Me+QN2i6S1mQ1OMrNWYvDy9I87A1d8wKR7eQM0UaMEvn0MTb50hC+hrK2QIzx6i0FMG2pXNuzu1wuPYv4/JTUPek7OLLlOSxgH+o44DRDk5ZriL2lKG6XkI3yGaLOIQ9US64xhA4VXKMGq16fLIaOoCLsMasnK5vqJd+H63C8NscdFT4hKfkm0/y1hNbM2Ja+nJgRpSVP5g181pgYH7fQk+I0b1kLdqCXE6nmqzZgUjJOMY+EhpSTxujuRZyv4SLDFENBdZsvoH+OtIrPL72bHT43t+ekCo7xCQi4N9HkrruzyfSo4yZDVeE5WIim4mrRnCHPhPCl9yfOR5m6rIce/0QM2XBX475AXjmwQzRKRa4sYhSEgD5vhkmlyf9gEFHU2PexBqf9AdxeHfrpBavPAzsF95bUeqngo9OikbsHwwGke7vpxFDAPxjqhpmm3xKWNkpQ33M7dTpN/lqQmd21jF4WBHuAbXLL3fqBvdppS2jAFRZZZfN60kbtUV6qqts8/bCF3bY7/JoG7ovKhwDvDs6DJtL7sVZEDPasPPadLDgPqLW/GJlMAge2zyydl2i0RiO/Wn88cCR/4RrgyxRF4L/QfWf/FF0ex9Kq8ch3m9/ALx8J0/gXyt8xipniUEcadcTlB7N6TtDpIM4sKFAEVwcT00S9HwMcoP5CsdXHdgq/ZCqpMYCyTX5H1NUxZ9ljZ9IV6oPRrpCwTGdX9IxepTCaMUZQZJ8z9CDIJ1/e2cNWTgwnbTSJUwCjqK1tF4hRkCPXESDPZjy8iovVFXhNQTdtU22wxHb2SlzTnnrA7MiHmgF7cA8qsbzqed2C5M+sNjOsdQH1a0UBLq3Nh2DLiUs4smEtds/L4kcbE9o6dTQm1Un4oCYxGDS+q4OL92ODWtSMl236wQ9kwS81LugSor60LyHksimRdqcWbCe4+rsyxm5H0bkiWalTf8In49C10L7Y01u9I0gW5vso8yixRQgB6a1VkiH6CxI+3vw== 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:(13230040)(7416014)(376014)(1800799024)(82310400026)(36860700013)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 16:12:33.0327 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b5bd210b-22f7-4e7b-9d8d-08dd1610caa2 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: DS1PEPF00017095.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR12MB9083 From: Mario Limonciello SMN access was bolted into amd_nb mostly as convenience. This has limitations though that require incurring tech debt to keep it working. Move SMN access to the newly introduced AMD Node driver. Signed-off-by: Mario Limonciello Signed-off-by: Yazen Ghannam Acked-by: Ilpo Järvinen --- Notes: Link: https://lore.kernel.org/20241023172150.659002-11-yazen.ghannam@amd.com v1->v2: * Move code to AMD_NODE rather than create a new compilation unit. MAINTAINERS | 1 + arch/x86/include/asm/amd_nb.h | 3 - arch/x86/include/asm/amd_node.h | 3 + arch/x86/kernel/amd_nb.c | 89 --------------------------- arch/x86/kernel/amd_node.c | 90 ++++++++++++++++++++++++++++ arch/x86/pci/fixup.c | 4 +- drivers/edac/Kconfig | 1 + drivers/edac/amd64_edac.c | 1 + drivers/hwmon/Kconfig | 2 +- drivers/hwmon/k10temp.c | 2 +- drivers/platform/x86/amd/pmc/Kconfig | 2 +- drivers/platform/x86/amd/pmc/pmc.c | 3 +- drivers/platform/x86/amd/pmf/Kconfig | 2 +- drivers/platform/x86/amd/pmf/core.c | 2 +- drivers/ras/amd/atl/Kconfig | 1 + drivers/ras/amd/atl/internal.h | 1 + 16 files changed, 107 insertions(+), 100 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index d7617f196bda..ca383cb1539f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1122,6 +1122,7 @@ S: Supported F: drivers/i2c/busses/i2c-amd-asf-plat.c AMD NODE DRIVER +M: Mario Limonciello M: Yazen Ghannam L: linux-kernel@vger.kernel.org S: Supported diff --git a/arch/x86/include/asm/amd_nb.h b/arch/x86/include/asm/amd_nb.h index 066dc3801430..4c4efb93045e 100644 --- a/arch/x86/include/asm/amd_nb.h +++ b/arch/x86/include/asm/amd_nb.h @@ -21,9 +21,6 @@ extern int amd_numa_init(void); extern int amd_get_subcaches(int); extern int amd_set_subcaches(int, unsigned long); -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; u8 subcaches[4]; diff --git a/arch/x86/include/asm/amd_node.h b/arch/x86/include/asm/amd_node.h index 419a0ad13ef2..113ad3e8ee40 100644 --- a/arch/x86/include/asm/amd_node.h +++ b/arch/x86/include/asm/amd_node.h @@ -30,4 +30,7 @@ static inline u16 amd_num_nodes(void) return topology_amd_nodes_per_pkg() * topology_max_packages(); } +int __must_check amd_smn_read(u16 node, u32 address, u32 *value); +int __must_check amd_smn_write(u16 node, u32 address, u32 value); + #endif /*_ASM_X86_AMD_NODE_H_*/ diff --git a/arch/x86/kernel/amd_nb.c b/arch/x86/kernel/amd_nb.c index 2ad67efe9032..2729e99806ec 100644 --- a/arch/x86/kernel/amd_nb.c +++ b/arch/x86/kernel/amd_nb.c @@ -15,9 +15,6 @@ #include #include -/* Protect the PCI config register pairs used for SMN. */ -static DEFINE_MUTEX(smn_mutex); - static u32 *flush_words; static const struct pci_device_id amd_nb_misc_ids[] = { @@ -59,92 +56,6 @@ struct amd_northbridge *node_to_amd_nb(int node) } EXPORT_SYMBOL_GPL(node_to_amd_nb); -/* - * SMN accesses may fail in ways that are difficult to detect here in the called - * functions amd_smn_read() and amd_smn_write(). Therefore, callers must do - * their own checking based on what behavior they expect. - * - * For SMN reads, the returned 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" - * 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; - int err = -ENODEV; - - if (node >= amd_northbridges.num) - goto out; - - root = node_to_amd_nb(node)->root; - if (!root) - goto out; - - mutex_lock(&smn_mutex); - - err = pci_write_config_dword(root, 0x60, address); - if (err) { - pr_warn("Error programming SMN address 0x%x.\n", address); - goto out_unlock; - } - - err = (write ? pci_write_config_dword(root, 0x64, *value) - : pci_read_config_dword(root, 0x64, value)); - -out_unlock: - mutex_unlock(&smn_mutex); - -out: - return err; -} - -int __must_check amd_smn_read(u16 node, u32 address, u32 *value) -{ - int err = __amd_smn_rw(node, address, value, false); - - if (PCI_POSSIBLE_ERROR(*value)) { - err = -ENODEV; - *value = 0; - } - - return err; -} -EXPORT_SYMBOL_GPL(amd_smn_read); - -int __must_check amd_smn_write(u16 node, u32 address, u32 value) -{ - return __amd_smn_rw(node, address, &value, true); -} -EXPORT_SYMBOL_GPL(amd_smn_write); - static int amd_cache_northbridges(void) { struct amd_northbridge *nb; diff --git a/arch/x86/kernel/amd_node.c b/arch/x86/kernel/amd_node.c index 4eea8c7d8090..95e5ca0acc90 100644 --- a/arch/x86/kernel/amd_node.c +++ b/arch/x86/kernel/amd_node.c @@ -8,6 +8,7 @@ * Author: Yazen Ghannam */ +#include #include /* @@ -88,3 +89,92 @@ struct pci_dev *amd_node_get_root(u16 node) pci_dbg(root, "is root for AMD node %u\n", node); return root; } + +/* Protect the PCI config register pairs used for SMN. */ +static DEFINE_MUTEX(smn_mutex); + +/* + * SMN accesses may fail in ways that are difficult to detect here in the called + * functions amd_smn_read() and amd_smn_write(). Therefore, callers must do + * their own checking based on what behavior they expect. + * + * For SMN reads, the returned 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" + * 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; + int err = -ENODEV; + + if (node >= amd_nb_num()) + goto out; + + root = node_to_amd_nb(node)->root; + if (!root) + goto out; + + mutex_lock(&smn_mutex); + + err = pci_write_config_dword(root, 0x60, address); + if (err) { + pr_warn("Error programming SMN address 0x%x.\n", address); + goto out_unlock; + } + + err = (write ? pci_write_config_dword(root, 0x64, *value) + : pci_read_config_dword(root, 0x64, value)); + +out_unlock: + mutex_unlock(&smn_mutex); + +out: + return err; +} + +int __must_check amd_smn_read(u16 node, u32 address, u32 *value) +{ + int err = __amd_smn_rw(node, address, value, false); + + if (PCI_POSSIBLE_ERROR(*value)) { + err = -ENODEV; + *value = 0; + } + + return err; +} +EXPORT_SYMBOL_GPL(amd_smn_read); + +int __must_check amd_smn_write(u16 node, u32 address, u32 value) +{ + return __amd_smn_rw(node, address, &value, true); +} +EXPORT_SYMBOL_GPL(amd_smn_write); diff --git a/arch/x86/pci/fixup.c b/arch/x86/pci/fixup.c index 0681ecfe3430..592fb9d97e77 100644 --- a/arch/x86/pci/fixup.c +++ b/arch/x86/pci/fixup.c @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include @@ -828,7 +828,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x7910, rs690_fix_64bit_dma); #endif -#ifdef CONFIG_AMD_NB +#ifdef CONFIG_AMD_NODE #define AMD_15B8_RCC_DEV2_EPF0_STRAP2 0x10136008 #define AMD_15B8_RCC_DEV2_EPF0_STRAP2_NO_SOFT_RESET_DEV2_F0_MASK 0x00000080L diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig index 06f7b43a6f78..cb97d7bdae31 100644 --- a/drivers/edac/Kconfig +++ b/drivers/edac/Kconfig @@ -78,6 +78,7 @@ config EDAC_GHES config EDAC_AMD64 tristate "AMD64 (Opteron, Athlon64)" depends on AMD_NB && EDAC_DECODE_MCE + depends on AMD_NODE imply AMD_ATL help Support for error detection and correction of DRAM ECC errors on diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c index ddfbdb66b794..29465088639c 100644 --- a/drivers/edac/amd64_edac.c +++ b/drivers/edac/amd64_edac.c @@ -2,6 +2,7 @@ #include #include "amd64_edac.h" #include +#include static struct edac_pci_ctl_info *pci_ctl; diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index dd376602f3f1..ea13ea482a63 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -324,7 +324,7 @@ config SENSORS_K8TEMP config SENSORS_K10TEMP tristate "AMD Family 10h+ temperature sensor" - depends on X86 && PCI && AMD_NB + depends on X86 && PCI && AMD_NODE help If you say yes here you get support for the temperature sensor(s) inside your CPU. Supported are later revisions of diff --git a/drivers/hwmon/k10temp.c b/drivers/hwmon/k10temp.c index cefa8cd184c8..d0b4cc9a5011 100644 --- a/drivers/hwmon/k10temp.c +++ b/drivers/hwmon/k10temp.c @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include MODULE_DESCRIPTION("AMD Family 10h+ CPU core temperature monitor"); diff --git a/drivers/platform/x86/amd/pmc/Kconfig b/drivers/platform/x86/amd/pmc/Kconfig index 94f9563d8be7..eeffdafd686e 100644 --- a/drivers/platform/x86/amd/pmc/Kconfig +++ b/drivers/platform/x86/amd/pmc/Kconfig @@ -5,7 +5,7 @@ config AMD_PMC tristate "AMD SoC PMC driver" - depends on ACPI && PCI && RTC_CLASS && AMD_NB + depends on ACPI && PCI && RTC_CLASS && AMD_NODE depends on SUSPEND select SERIO help diff --git a/drivers/platform/x86/amd/pmc/pmc.c b/drivers/platform/x86/amd/pmc/pmc.c index 26b878ee5191..941b7753dd78 100644 --- a/drivers/platform/x86/amd/pmc/pmc.c +++ b/drivers/platform/x86/amd/pmc/pmc.c @@ -10,7 +10,6 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt -#include #include #include #include @@ -28,6 +27,8 @@ #include #include +#include + #include "pmc.h" /* SMU communication registers */ diff --git a/drivers/platform/x86/amd/pmf/Kconfig b/drivers/platform/x86/amd/pmf/Kconfig index 99d67cdbd91e..25b8f7ae3abd 100644 --- a/drivers/platform/x86/amd/pmf/Kconfig +++ b/drivers/platform/x86/amd/pmf/Kconfig @@ -7,7 +7,7 @@ config AMD_PMF tristate "AMD Platform Management Framework" depends on ACPI && PCI depends on POWER_SUPPLY - depends on AMD_NB + depends on AMD_NODE select ACPI_PLATFORM_PROFILE depends on TEE && AMDTEE depends on AMD_SFH_HID diff --git a/drivers/platform/x86/amd/pmf/core.c b/drivers/platform/x86/amd/pmf/core.c index 06a97c533cb8..7f88f3121cf5 100644 --- a/drivers/platform/x86/amd/pmf/core.c +++ b/drivers/platform/x86/amd/pmf/core.c @@ -8,13 +8,13 @@ * Author: Shyam Sundar S K */ -#include #include #include #include #include #include #include +#include #include "pmf.h" /* PMF-SMU communication registers */ diff --git a/drivers/ras/amd/atl/Kconfig b/drivers/ras/amd/atl/Kconfig index 551680073e43..6e03942cd7da 100644 --- a/drivers/ras/amd/atl/Kconfig +++ b/drivers/ras/amd/atl/Kconfig @@ -10,6 +10,7 @@ config AMD_ATL tristate "AMD Address Translation Library" depends on AMD_NB && X86_64 && RAS + depends on AMD_NODE depends on MEMORY_FAILURE default N help diff --git a/drivers/ras/amd/atl/internal.h b/drivers/ras/amd/atl/internal.h index 143d04c779a8..f9be26d25348 100644 --- a/drivers/ras/amd/atl/internal.h +++ b/drivers/ras/amd/atl/internal.h @@ -18,6 +18,7 @@ #include #include +#include #include "reg_fields.h" From patchwork Fri Dec 6 16:12:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 13897348 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2088.outbound.protection.outlook.com [40.107.220.88]) (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 760FF20E71A; Fri, 6 Dec 2024 16:12:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.88 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733501560; cv=fail; b=CyIBOeupTWeZu7+nQeSFT0mN0GnnWrtjahobKKHpaWeNd0vfO+XPCxgAF7iNGKwTOGo9voaFL/W8YMQ+oFhIcgwhKW9uyBZJFtDkfRNVCPWP6fw2bNwTnl8GX2q3mgy4q28l1W6sKybfyIWKjaIKOWzhPHamPP/sE46rz9sZ8Dc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733501560; c=relaxed/simple; bh=w+SbRx+ynE3ifmKD8Dq8CA2+wkpOjJ4i3jymNv4hiAU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WMbRPEIES3SixFv+mH+6Vg8TkYHDjJKAXLgUFjlbKy1dUWoPm5Ir5hodTOIxR5TR8o+nwP03dF3eAVGb1fQMhIqd3im9923YJQm3pecyU+6wyc4KVtiwELmY8TZRW4O582vQrIDvQVyfvoSA63GQ/1u3YkYmYHUNtD5hJC2r7Q0= 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=wM2QA7sp; arc=fail smtp.client-ip=40.107.220.88 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="wM2QA7sp" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MftBohd488iLR+RFTujfF6XNtxohUCAOiVg3jqua/FiRwhjSM7vf/kdPwkyWbD58tI+LT5tyDfOXlGKhk/73Agl7KcxWw8IFSk/JCWVUUpRnUInn5cpzw5BuCbcX/FmzqsTGgWc5SFeYNTc4cx2OxwS+XVO25lCQjMg/CuXxpX2OeOvoHeyg0VDToB2axTi0dNORQo2CHT+mkZ4dhvzIH382piXwgnsM/oF5EeJvuSDtnfYDVIw+Gw5ATOxBrZlL6JAWquYYeklJOF1KUiGXi7D7CTBfiJVSr2kMoExHHRkpIHgAJPYm7CmpCIiz2B3bRngzjM/ydWWEqv8kG5NqgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=Ha88gzqeraxEemKnKmWXaTOoc3Wu8iQXSvrfdlND8OI=; b=H1zM0RDQlB3zCMQwOJCTVonUBP7VYdRUCYZi7uNPEzkxVWXOhAW3tScKwJVc40uSRvvPSH/3u+xHMqyQltFvxaZWpnSkk4UDLvzhj0rMMQ4RP9e3C4d6SraXReCgbIDs2ccN/l0wjjSUKy0d2VNXwW2HOCAutzxOd4IfqTQgbk1iKjQCnFaPpVWTDPt9JXbyCCK7V9Tp6WVbpLXAiiJDaqF2HHnKc5aubz0v7oO5BM6Rr16OUBL57lWJtvOoHhZKq8TIoMnwA9kPsM20NHy6fOgR1L/urfOfCrhyRE8HEi94zKs8mUfKgGnAs/9ZO9/UEoZlbqlkKI9u3zm/if8h7A== 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=Ha88gzqeraxEemKnKmWXaTOoc3Wu8iQXSvrfdlND8OI=; b=wM2QA7spQUvvphpgaAcL/QS5s3uglFsIbOxISfjwCy8xao3BA9qm38SycBR4gm6J+b7jVlj2yJLXdm3kLkjxODdv3mbG6WxxNXtGNOs3WNm2ZgETlfgsoJlvLgMGwgMt7dOMQYh6qrrKXmxS6TifNL2R4mi80+OsPetsvGZJSqo= Received: from DS7PR03CA0269.namprd03.prod.outlook.com (2603:10b6:5:3b3::34) by SA1PR12MB8643.namprd12.prod.outlook.com (2603:10b6:806:387::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.12; Fri, 6 Dec 2024 16:12:34 +0000 Received: from DS1PEPF00017093.namprd03.prod.outlook.com (2603:10b6:5:3b3:cafe::c4) by DS7PR03CA0269.outlook.office365.com (2603:10b6:5:3b3::34) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.9 via Frontend Transport; Fri, 6 Dec 2024 16:12:34 +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 DS1PEPF00017093.mail.protection.outlook.com (10.167.17.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Fri, 6 Dec 2024 16:12:33 +0000 Received: from purico-9eb2host.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.39; Fri, 6 Dec 2024 10:12:32 -0600 From: Yazen Ghannam To: , , Tony Luck , Mario Limonciello , "Bjorn Helgaas" , Jean Delvare , "Guenter Roeck" , Clemens Ladisch , "Shyam Sundar S K" , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Naveen Krishna Chatradhi" , Suma Hegde CC: , , , , , Tom Lendacky Subject: [PATCH v2 11/16] x86/amd_node: Update __amd_smn_rw() error paths Date: Fri, 6 Dec 2024 16:12:04 +0000 Message-ID: <20241206161210.163701-12-yazen.ghannam@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241206161210.163701-1-yazen.ghannam@amd.com> References: <20241206161210.163701-1-yazen.ghannam@amd.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.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: DS1PEPF00017093:EE_|SA1PR12MB8643:EE_ X-MS-Office365-Filtering-Correlation-Id: dae064ad-5208-4193-51ea-08dd1610cb33 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|36860700013|7416014|1800799024|921020; X-Microsoft-Antispam-Message-Info: yf2W6mnipItx0lSjbRD0m1o/ug79INI39r655bM13Ol/U5lV3sHtWhlrvOcl2BzpoCahPH9k2CTxUe2HRVs7oGAJjchM86VOuVJ0/ZlA7nUi0sJB6XGpz/kGhDX8S0TsYjsZ3adW0Tvs5vIzDT8kqoUGXeVtSdkpCIyLpx8M1ucwJiKcED3J/tGxHm3quVtGeuWvqlb9LLUB5YtixUScA+ne1l1Mb5uLYZzLTbU5zzoqxbkChT3a+F+LhoyBGgkTjt7ARyetDHuGvjrFsIeoMEXo4RY/VvEVJTRdL0AM1OrTp5UoRMC1WPfqMJ6x7jIf7SdcNBk11FGUTUASVsTJttA8JN61vFHAHbHlpddOTzIpPN2c3O3g1yBr62sBf2G0azfk3ckRapXHDODgs/yNc9SXGawuoKYuHRCewYfSavV7RgzEKQAJXXE1ffkFKcoEMK79S6Bwo6VCF+mnviJ/eiV65q7Ct9bM1Xe1qkNrG6+/t2eZUElklfcZBga/AkGiimWry5tFKRkwZy4xEFTGtwV3xSLm/jN496UHfd8MvRX/pS6eeIxf3LrbMu/5uOWg+3mcE/AP275PV7rWhDRTSav5CUZ8D0Rn9q532nlGYCaYQL4Lg8l6FY+KtAIi7bh79pMOMY73XJjnoxAw9O9AclkNBy4Di226xA1yvCoA40RY1MQtzp2dgs4ML/YBh+MqNvNUG0b4QK2lUWmXxqyz39TkKSwt80a7dtLutEZmMROrJ3iQymegTzzHhe7Bdr/nuGD4t9XEAEo8gQ8Rpuw+3LEo2zO9/qw7UNCbT1gqkZ00wckhbcyCmq0sq7YysYMdAbl+NvWo5NDCL84g7ixdkdDr6ZB7Ld9SO6ot+D+2rhfRu22KzIYAaLwdIAsz47Pw6TL9TyoA9se7uGqlpE+qu5Hagk816KJUM44vjW6A6/aIqZvRMSTAz24elTojgS24bx5/2VVl5d86PdhCgKAhH2zkYzpRPxEUjBuraAebGIAxPkxdNTXjP4yiuWCToFYudibzZ5AgTph0iK0KfqTm/KxLhnPM01VTDUOUOWxKQRzuVl2b0/wWv9CKPMY/4PdnjROA9J7jpDJHuIRo1lHiJafjjrvPaDPkdbuGxMYae5EURJqXoWoVNkP5S2lDcdurYKR0R3vutZVW7SZCA1OQ0BRgFIuKCxTjsDl15OlCcE2Rjyl8gGQqRkCm/aa4+PQwMvt8v2AMQ5yr8eS7TjdUV86qe7M4grDi+hA0/e2xAWLSVukWH7sXUXDlyShZZevhkWrQi4i23V1/SM8WNLSG+Vj+y1+lBpa8qZ+rtSxgY6tgzPi667Uq83wBebnHv4Bvzrs0KxQ01DpAlLiJy3qHqdte33Toy2nR4a2hd8KL+hHweuPjY+9tRl2XP6fzTTv1Hicu3bWor+asZpfERfoACMNv2wnr6waaHzykHQMuQDpfix9LJVtRaWCqoy8OUwR81rHup7cELG38I0qJZsky9w== 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:(13230040)(82310400026)(376014)(36860700013)(7416014)(1800799024)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 16:12:33.9810 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dae064ad-5208-4193-51ea-08dd1610cb33 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: DS1PEPF00017093.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8643 Use guard(mutex) and convert PCI error codes to common ones. Suggested-by: Tom Lendacky Signed-off-by: Yazen Ghannam --- Notes: Link: https://lore.kernel.org/20241023172150.659002-12-yazen.ghannam@amd.com v1->v2: * Update commit subject. arch/x86/kernel/amd_node.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/arch/x86/kernel/amd_node.c b/arch/x86/kernel/amd_node.c index 95e5ca0acc90..0cca541e18d5 100644 --- a/arch/x86/kernel/amd_node.c +++ b/arch/x86/kernel/amd_node.c @@ -136,28 +136,24 @@ static int __amd_smn_rw(u16 node, u32 address, u32 *value, bool write) int err = -ENODEV; if (node >= amd_nb_num()) - goto out; + return err; root = node_to_amd_nb(node)->root; if (!root) - goto out; + return err; - mutex_lock(&smn_mutex); + guard(mutex)(&smn_mutex); err = pci_write_config_dword(root, 0x60, address); if (err) { pr_warn("Error programming SMN address 0x%x.\n", address); - goto out_unlock; + return pcibios_err_to_errno(err); } err = (write ? pci_write_config_dword(root, 0x64, *value) : pci_read_config_dword(root, 0x64, value)); -out_unlock: - mutex_unlock(&smn_mutex); - -out: - return err; + return pcibios_err_to_errno(err); } int __must_check amd_smn_read(u16 node, u32 address, u32 *value) From patchwork Fri Dec 6 16:12:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 13897351 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2073.outbound.protection.outlook.com [40.107.93.73]) (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 7688E21147C; Fri, 6 Dec 2024 16:12:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.73 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733501563; cv=fail; b=lwayCHnAcaW7t1GYXpjwnzP9zpXZhNJo45Zx3VxirOzx8QQtnu4hJll5P3aKEaXNtp5rEQfojoqqli+voe7vn56g4I6OgH6+tMxTBqu/em7IzAyIostfH/Fz2/0DfDTnANOPA4cWD8W4W1OC+JTuo3YnKGWYYrkuzdNacY0cNVw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733501563; c=relaxed/simple; bh=MfVWnrdzjh5zgDf17FZkeOPBuOsx+G2InN0vT0pYyaw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iThB9OhTy4Gkfh8jUGRX/GagBivYOsMdg1WRCvXF5N4CCIkOafGx5Q4oGHxnE3zwv0i9K00hE0EolaMtk7Jji9/lDHaBAqqsp4x6Mx6KWJ/bNBUSQy0JiOLq6ukFb7coI6n53xLIBfWKDLMVNzfe7bGnD8TXJGXQPhoVwhNBY1E= 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=4pGjnqCy; arc=fail smtp.client-ip=40.107.93.73 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="4pGjnqCy" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Zu3ZdNa7exbjdYEbwbmoVZPhF+sJ4FpdNb275/uAi+dT9kDglLykELJb0RE/hBCyTFYWKnXNFZ5kOXIKh17m4o3HpBOw+9267Ab9xx1Zs/hK7j7tuqWlci8rtVSh5A0QFYiCnId2lsca6W6MVVUWRpW0ihrqJgx6NDqQz9Mi3vXxyjzdk6s/mobEnEKinMiDK8DsXhk30p6D32msnAQVRq2ImTj50O35UYemtFEl19mMA7RHUjafY+dhOncADSny4JTz2ECgOXZirX/Y4TsS8dFh7OmFOHw7tqubRtoVXeH/p1vICUbFTfbY3+gTUuOI6MHoC77xpPg+PrSSpXcAvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=FlHlcR9VqKCinqql447V9yi/B7E0+PdXRB59KT7EBec=; b=ZPJHQaxQUMHMg0TJZbVM1Cz3oiOrfRjfDoimWP4vDsUmDPFkiCLixFwoT5bUjtpCGyhAaP8pEG8iAxq5NjgNqb4s+z2Glp4pa/IYLwKny5eFDDYV8GeiApQ8BlwYTUqThU8AHfNRLaS0f6bPvqPDFcniYJYZoZLp39baK05UwYOK/vtQ64fGTIUb3xRI9Dz4Sb9RhGDxuwzr4uwNuRDYRy7qa+iDKmn8Qswr9D8aGuR5dw4gI5wEH4h/3Vt39UiSWqJ+LyQcK3wGLquy2uceCyb2a39L94/d4mqZJiOoWAcZprJePINRnvbUevqea/jF8iUzWxDrgW18ChZMWAWaQQ== 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=FlHlcR9VqKCinqql447V9yi/B7E0+PdXRB59KT7EBec=; b=4pGjnqCyyC7Ul7hwLrR/Qy8ZVkLPW4fXv5BlkILoiwc/sQmoDiUvidTT3pFgpFLiMCBAR39LvbccTRSREGBHVRdLtao0bixW0xgyJxLEOGU2Ko779vKz7FNP/o/Jya9QyoyHPInhSDlm/uitSgl3zsUutLJ/RYddN0IGOE1DjHI= Received: from DS7PR03CA0266.namprd03.prod.outlook.com (2603:10b6:5:3b3::31) by CH3PR12MB8457.namprd12.prod.outlook.com (2603:10b6:610:154::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.12; Fri, 6 Dec 2024 16:12:35 +0000 Received: from DS1PEPF00017093.namprd03.prod.outlook.com (2603:10b6:5:3b3:cafe::b4) by DS7PR03CA0266.outlook.office365.com (2603:10b6:5:3b3::31) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.10 via Frontend Transport; Fri, 6 Dec 2024 16:12:35 +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 DS1PEPF00017093.mail.protection.outlook.com (10.167.17.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Fri, 6 Dec 2024 16:12:34 +0000 Received: from purico-9eb2host.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.39; Fri, 6 Dec 2024 10:12:33 -0600 From: Yazen Ghannam To: , , Tony Luck , Mario Limonciello , "Bjorn Helgaas" , Jean Delvare , "Guenter Roeck" , Clemens Ladisch , "Shyam Sundar S K" , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Naveen Krishna Chatradhi" , Suma Hegde CC: , , , , Subject: [PATCH v2 12/16] x86/amd_node: Remove dependency on AMD_NB Date: Fri, 6 Dec 2024 16:12:05 +0000 Message-ID: <20241206161210.163701-13-yazen.ghannam@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241206161210.163701-1-yazen.ghannam@amd.com> References: <20241206161210.163701-1-yazen.ghannam@amd.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.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: DS1PEPF00017093:EE_|CH3PR12MB8457:EE_ X-MS-Office365-Filtering-Correlation-Id: e95b8726-65e9-4e15-23d5-08dd1610cbc7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|36860700013|82310400026|921020; X-Microsoft-Antispam-Message-Info: QF7hsPjJx0r6v5UFdWjymfZbi49oPizjtwJMl2N/Eyw6oPYzilIGDKyzoXeDveu0zCik5/Gof+8U6fI2UsGJ6IO7ERE4AKHQZ7RyQjvYcYljd+bhRAL2Q5vUPpuoYuGGPSK6V74AkM9v38mJylIJSu2saMHrUz9Gcks4aQGKzQghduKUXge+l3zcOrN0xw2zFd9kBO6w4wXcITndC1IfQMYJnnki1wy3m9IiQYkB9NDJMBCDGl5wP+rCnH5Nn7UQ0Si3aH0YUdvBIRZg6fjJOHzTqeY71UyEs1yxvlbMYEJyw0vbZSZxdGwVUsnsI3noOIttKIh7tgbNrlzzzjvM6vrLmlDH0tNAkIxs87+XpK47JAkrdSfstAReKirDOlrHM6LF8PnEc2yMCrg4Lqnlu1xgRaQw5kHQ08+X01PEQGjCz4GBHTJhCvsfqbJDwi9NPH5jM0TOR9sLdaBbeD+4WQWw96zhlEVPKWQ49WWM2qXzdmkd6aOXnKMheZ9e0JWtB9FHLBo5w4BFivOr42ph3BhCTWRYjBTkEwI0BF5TiZIDkqHI4cqYDFcakOVgJHk3snP6VxyCjRApD3hQ980Cb7Wq/FvBtmYk6QDBtx/Rd3Xc0r7rZitfqJIBIp+oyvSoqkrUlHiRibfnVgcwKoVN0jI8FtSu12phWoZsZQNSLLvSQExHFZnVjk8PEQ97IEqi1btqyifGmhcU45uHYuiL8tlDhi4fC8qkYhMSMVVBFjfmnOut2GeJXQf+g3s7lI5Wqe65Aiao5GYbLjF66c8dRTaOa5FQWpdsXsUNvuuR/WxUHBnfrrK1/6rjnbbkU0Io3U2CKmMh4tAXA9oZxttVLSge7KWq99FDkgJSpp8LI921YoFR5qCpXplpdHuce82YP+TYMvLhVHlkC2zwsJJwZsZNIT9tFQZys8ifiHQc8n4cblnJkmYmALVhSrKSGavt5EYhqGFBgLk8f/0/daH4bfULRt6tru+QuE/TMngzba23rq6cEnzB/+kfPzubk+z6EHGWdHwR04aa+lUhQl1fEwuicPFhW7YPYY/AHk/rFQwOD3LRjb/PuYMM8hMf4d3KNGUMoueau2SAp5sVD7pY+pXgQnO9mJPlAhLPq6/lrmFr15deEDZGzf7PANXk643gCFM4DwE9z4aUhqCQ2xEghHrYMEmjBcZHQ+qcx6/TdMMU9KKGX92Kt44+VG6YMsCK5dOsIVReB/11IZnQAB/g0lxlkmoYTCmH9MwWOQyKX744zjjYEnE0k/BAubFuluon6HfvESDPTkj56zW5IiUmLDq/9JO2RbT0ey6EUJKgLkIz9CL8txZsejyHFNmFCTib7I2oc+eGl76AO5MwZSpJtA/TigxZrqf4fsiHfINddwPy8LGhNd2Tjlr4gkxXWhfZUeRdXyXdvy03+aKBjKFjP3EBjT9/fxm5MFFPIDdr1zIy0CRcmnasP0McWXQYNJSRLB3GkFDNe07dVNfbLOpmOg== 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:(13230040)(1800799024)(376014)(7416014)(36860700013)(82310400026)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 16:12:34.9498 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e95b8726-65e9-4e15-23d5-08dd1610cbc7 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: DS1PEPF00017093.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8457 Cache the root devices locally so that there are no more dependencies on AMD_NB. Signed-off-by: Yazen Ghannam --- Notes: Link: https://lore.kernel.org/20241023172150.659002-13-yazen.ghannam@amd.com v1->v2: * Apply to amd_node.c. * Change sizeof() parameter in kcalloc(). arch/x86/kernel/amd_node.c | 42 +++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/amd_node.c b/arch/x86/kernel/amd_node.c index 0cca541e18d5..45077e2e6f2f 100644 --- a/arch/x86/kernel/amd_node.c +++ b/arch/x86/kernel/amd_node.c @@ -8,7 +8,6 @@ * Author: Yazen Ghannam */ -#include #include /* @@ -90,6 +89,8 @@ struct pci_dev *amd_node_get_root(u16 node) return root; } +static struct pci_dev **amd_roots; + /* Protect the PCI config register pairs used for SMN. */ static DEFINE_MUTEX(smn_mutex); @@ -135,10 +136,10 @@ static int __amd_smn_rw(u16 node, u32 address, u32 *value, bool write) struct pci_dev *root; int err = -ENODEV; - if (node >= amd_nb_num()) + if (node >= amd_num_nodes()) return err; - root = node_to_amd_nb(node)->root; + root = amd_roots[node]; if (!root) return err; @@ -174,3 +175,38 @@ int __must_check amd_smn_write(u16 node, u32 address, u32 value) return __amd_smn_rw(node, address, &value, true); } EXPORT_SYMBOL_GPL(amd_smn_write); + +static int amd_cache_roots(void) +{ + u16 node, num_nodes = amd_num_nodes(); + + amd_roots = kcalloc(num_nodes, sizeof(*amd_roots), GFP_KERNEL); + if (!amd_roots) + return -ENOMEM; + + for (node = 0; node < num_nodes; node++) + amd_roots[node] = amd_node_get_root(node); + + return 0; +} + +static int __init amd_smn_init(void) +{ + int err; + + if (!cpu_feature_enabled(X86_FEATURE_ZEN)) + return 0; + + guard(mutex)(&smn_mutex); + + if (amd_roots) + return 0; + + err = amd_cache_roots(); + if (err) + return err; + + return 0; +} + +fs_initcall(amd_smn_init); From patchwork Fri Dec 6 16:12:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 13897350 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2046.outbound.protection.outlook.com [40.107.220.46]) (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 CD2DD2101B6; Fri, 6 Dec 2024 16:12:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.46 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733501562; cv=fail; b=TvHRAJBriIrOF4MBrLZ0Qk4x2C+1mKGba0rNr72n4SvSbpxszaSQR/ovxeuw8FbSEMT5s9O7WANauA5Wrd67hKH4yq9g/k6EByCQhJpGve5PLcMSsIUz1DPEfO0keoR05M3izGG7pPKg5SBz6fFnRQGW7vOdJlP68oFKypI979s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733501562; c=relaxed/simple; bh=vqzQwMJF9JP9bQWs6+5a8srrKwlPqCtuAWdd/xZesiw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CwehkBGOkV36A3qtJ3STnxWwkQEA35ZTs5uxbBz44jx18Pn+a4zRQqzi8ArKAxG2hdejbbTj1v1ndP5f/8+Nnwlg+LX/q6aXDjVUdFyS9R0PN6EA38e4ZL7Gs9S+/L7NZqGCVZxN6bVyepMIs/xiuXHXbuqTgziRqkU3PuXVzH8= 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=PtLpP+YN; arc=fail smtp.client-ip=40.107.220.46 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="PtLpP+YN" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=gQx+Y9YXkfYKUoXvNcmDfv4WafkQCjfeYU494LetbwsPzREx4gp8b2BU5Y03S3p0EkhEYMpqSDlIEx5RhdD+zQcJtqv1Q9kLtoQd9WzrAV2g6K6Mlh5Y4QmjUimOon+uS9QxAHON8D5717dvttSe5WajjZvx8VNCHpr7q26byr24uftbCBRu58wBvvGgTtniTI/UF/5t1+1vzaj4f2bfhS33eEOvbVOHPUAe4oJvgElcVaVxq3/nZmN4JDAivdIFIRDzpupdfMsZbDGe02/gk/izHtCRrbtVawPbgk7yB9PpqCO+uo1MvCEIfM1ZmnT4JfuxC439o2NkSS9RwzTyQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=C++KkPEUXWrS/jmE9Yo2OIssErmMbgM0b0geYt9Kqtg=; b=lsA5h5P1RRTLhf9pmEhCoTtF6T5hrb2RspWW0kzzpJ1RGbe4qsVCpbPK21TiJUuS1CCXub+J86LOgyRRlDFEXUvOMxBI+ORh2N9n3s9OYPSEta82QRSlV7uDWGANiey8DZkbmti2M3HLmQm6dl0AlmE21LLzNGCRGBD+M5pKvFL5hU3Li9Fhy3fxK65BYGntu3vfx7ytVbZbEZD3BAd1pj7pxLZBetXTgE1VREwU9qHCtVLUGph8OIwj8qOFs5awTNLupHqUXxyn+uh1Tx2UAQNA4CbuQznWzqA9jgbqaMK0ua8WXAwHdva8uaeiawh60BOiNZCbYjRS2G7Hni6mxA== 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=C++KkPEUXWrS/jmE9Yo2OIssErmMbgM0b0geYt9Kqtg=; b=PtLpP+YNDJ9d9L3MWW3o8cbJLFV3WbN+KnR7KMOQsD79NNFn6f3+1vkE8GVt8EBVvoFBBfxcPrpseMBCviMPETJu7WMkrS3TK3b/43LYxQYCtYfC+lyF7lQ/7n/UbnKh+VazelPMEVgJuBLg7NvYoM46K4+qJuTs5EAPPWXLfTE= Received: from DS7PR03CA0250.namprd03.prod.outlook.com (2603:10b6:5:3b3::15) by CH3PR12MB8904.namprd12.prod.outlook.com (2603:10b6:610:167::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.11; Fri, 6 Dec 2024 16:12:36 +0000 Received: from DS1PEPF00017093.namprd03.prod.outlook.com (2603:10b6:5:3b3:cafe::37) by DS7PR03CA0250.outlook.office365.com (2603:10b6:5:3b3::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.10 via Frontend Transport; Fri, 6 Dec 2024 16:12:36 +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 DS1PEPF00017093.mail.protection.outlook.com (10.167.17.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Fri, 6 Dec 2024 16:12:36 +0000 Received: from purico-9eb2host.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.39; Fri, 6 Dec 2024 10:12:34 -0600 From: Yazen Ghannam To: , , Tony Luck , Mario Limonciello , "Bjorn Helgaas" , Jean Delvare , "Guenter Roeck" , Clemens Ladisch , "Shyam Sundar S K" , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Naveen Krishna Chatradhi" , Suma Hegde CC: , , , , Subject: [PATCH v2 13/16] x86/amd_node: Use defines for SMN register offsets Date: Fri, 6 Dec 2024 16:12:06 +0000 Message-ID: <20241206161210.163701-14-yazen.ghannam@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241206161210.163701-1-yazen.ghannam@amd.com> References: <20241206161210.163701-1-yazen.ghannam@amd.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.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: DS1PEPF00017093:EE_|CH3PR12MB8904:EE_ X-MS-Office365-Filtering-Correlation-Id: aea411c9-3af6-491a-8ef8-08dd1610ccb5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|82310400026|36860700013|921020; X-Microsoft-Antispam-Message-Info: 8+RHHDic/8EpPa1F4MjyL7bT3JgNG1Ylu0YTDtwGlv0TzoEksGnf1Xn2DGAOeO+2mWCgiOD22uT6wwHp6FBxUpw8X89F5PtNWoTvLxtst+evGHEwMZ1nS+OlOZpn1EzhMXJ2zozoOzORPxWzRJt4CM9L0PRpj6SB3fJht79YACBHeKroDxR+UVI/FfYdsXUTrHRMVIGOaVTZ+qAdgI2MzAKkWZdAHM8K0wv6YJEomkBW9i3yhVFb1EBf/HtTgmCQefpqw935uaIWVQdG5UblCp7dnCg7v/F93IzJfedCtYfTbhetWMFfyBuyfeW3y/+wBqrD8jZ+jQD6sL1O02h81gfRsisbLK3YpsMlqvTnn0CfkQQb9aypIF6cdmhhp2ZtUpYCS9fijr9qhcrev0ZvnsrApuU+M3HFHrtszHZPbYkN8TvRmffQpmVx8DDzM8iXN8WNzwwWoAKHRScT3UFMs7bJ/N0FER55EkVKzl5v1Feft5KpS04dUriMFCGnn1MA6PRIFsIUqXU/f652sWdsG/fm0E6eu5Gr9AeDceAV3mPNjhsWFl9bx0x95lNZhb7J2nl4x17TK/vrq45vg7OZs315S8zSrkWQkUReNl/NgwlCkPYC7dclxWPLSjq5iYloKA7GJn+dECgEA8Hf+UyPgZD9MNzZXQEUSOkJbBqGl4KSdkrcyiLnA/ImXA3TpiZtdORVCUS4ZoujngG+g/2Id0gH4YU0Cs2TuidkPInGucY1CJOP0JA2Lcaun73nW3sGj7eD7QhAabCuLE8pxfDUs69RRlVr8Ca6qGIMzVQz9Lpqfz+5LBdyGujOKQyS04z7pJKp/uNInSIXgdQ+1TCRF4TRia/C44547yVF0LupNBzNB0V5gGN+8mhSw5nKhwb1VdvSV8opzXes8Bl8KNOLc6nTvm70wYNprMz5cwyvj3WYBVBG6hzwvVDQ6Nab2jXA6Eaug8HABT/oGbX17+pIY17OGiV5p7qb2PWWN8v6PvhFw9By+y9VABN6ysIRXT6Teu8gTwHS2tjyx7qbrsJw/5sbrOdyJ7h5zni97pD7XI+K456MccNug+PmnqZFnKHY206A54D4Qdc/5ezxQSUzmlb4WMd9adZZQ5n40pkDt5Acg3E41infOYccuyyOn/vXnqkvv6RgWTUzCiAeOJurGN7aC+58VnC0XbrJ/ukd9utXaygnX7r4fBuhYnCzpANx8AAYlXEIeRdeYTueQFq7K8R2ce5Sy2sAYehLrDFjhOEE5Ygb7AKCD/sds9/MAtgZY/4/4YcFvoyG0+lnxS/VH7VKMnN/HC2H2Lo2oK8tdrUn7LuKC0BgjcMtr6/SLvtxLJW5YGi3NGn+P5bG/jxvj/2uhS6N4f+bwQiPTYULN38ru62E1J5U/7D869y1UuYGEtjr4mkzTC+hjfINqM19RlAeD1Jn+6DUWNiFxGAMZOdPBB3K5IeAIwdb00LRR7uDyz21IfbyHFWChsQsVrludw== 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:(13230040)(1800799024)(376014)(7416014)(82310400026)(36860700013)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 16:12:36.5123 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aea411c9-3af6-491a-8ef8-08dd1610ccb5 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: DS1PEPF00017093.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8904 There are more than one SMN index/data pair available for software use. The register offsets are different, but the protocol is the same. Use defines for the SMN offset values and allow the index/data offsets to be passed to the read/write helper function. This eases code reuse with other SMN users in the kernel. Signed-off-by: Yazen Ghannam --- Notes: Link: https://lore.kernel.org/20241023172150.659002-14-yazen.ghannam@amd.com v1->v2: * No change. arch/x86/kernel/amd_node.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/amd_node.c b/arch/x86/kernel/amd_node.c index 45077e2e6f2f..d2ec7fd555c5 100644 --- a/arch/x86/kernel/amd_node.c +++ b/arch/x86/kernel/amd_node.c @@ -94,6 +94,9 @@ static struct pci_dev **amd_roots; /* Protect the PCI config register pairs used for SMN. */ static DEFINE_MUTEX(smn_mutex); +#define SMN_INDEX_OFFSET 0x60 +#define SMN_DATA_OFFSET 0x64 + /* * SMN accesses may fail in ways that are difficult to detect here in the called * functions amd_smn_read() and amd_smn_write(). Therefore, callers must do @@ -131,7 +134,7 @@ static DEFINE_MUTEX(smn_mutex); * 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) +static int __amd_smn_rw(u8 i_off, u8 d_off, u16 node, u32 address, u32 *value, bool write) { struct pci_dev *root; int err = -ENODEV; @@ -145,21 +148,21 @@ static int __amd_smn_rw(u16 node, u32 address, u32 *value, bool write) guard(mutex)(&smn_mutex); - err = pci_write_config_dword(root, 0x60, address); + err = pci_write_config_dword(root, i_off, address); if (err) { pr_warn("Error programming SMN address 0x%x.\n", address); return pcibios_err_to_errno(err); } - err = (write ? pci_write_config_dword(root, 0x64, *value) - : pci_read_config_dword(root, 0x64, value)); + err = (write ? pci_write_config_dword(root, d_off, *value) + : pci_read_config_dword(root, d_off, value)); return pcibios_err_to_errno(err); } int __must_check amd_smn_read(u16 node, u32 address, u32 *value) { - int err = __amd_smn_rw(node, address, value, false); + int err = __amd_smn_rw(SMN_INDEX_OFFSET, SMN_DATA_OFFSET, node, address, value, false); if (PCI_POSSIBLE_ERROR(*value)) { err = -ENODEV; @@ -172,7 +175,7 @@ EXPORT_SYMBOL_GPL(amd_smn_read); int __must_check amd_smn_write(u16 node, u32 address, u32 value) { - return __amd_smn_rw(node, address, &value, true); + return __amd_smn_rw(SMN_INDEX_OFFSET, SMN_DATA_OFFSET, node, address, &value, true); } EXPORT_SYMBOL_GPL(amd_smn_write); From patchwork Fri Dec 6 16:12:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 13897352 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2069.outbound.protection.outlook.com [40.107.220.69]) (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 AD2D8211481; Fri, 6 Dec 2024 16:12:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.69 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733501563; cv=fail; b=mU2tGC+AuTwsUfpbvQvze09LE6eYQ8fyINBWi+WSezzJvpmYC9VWxfqVAD65wjnJhtXx5f4xpgaAhlVesPFNZYD/rvNrBWNxqB59zYuRSe/s0nhMBcjO5jx/Xe9WUAcCPcp//Gvc1hC3skfqCz8a4ZQcejVMoN0vL5Jh6uICds4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733501563; c=relaxed/simple; bh=SkZ2W5WDeN3bTVJJBbvSdbRxZfppKq4LZDEG1/8SZT4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=eBHwFNoTJBxh0GJqLZ8WMZManwxyx8vFG3trA6YAJH+p0P7wZ2E2Wqn/WmW2csDlGNVdvttamZ3brNw26iyXwIilnczk+8+CQ9N0/lQN/OWkI8nvHLMG1US6wnatgCywVB8yZzynzk5C3omXPsvcZKId2yzaFv/xoBeCAUBYbMg= 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=x3canAxr; arc=fail smtp.client-ip=40.107.220.69 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="x3canAxr" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AD7yIZRCzpddHnf3t2L0o1eNInu8A+GkGr9XxjZvbTiu2mG4TkRXZ2cMRb2L7HKaZh1NiaFYdnZrO0qrMxa93cTHw5yM6Ii+gx538FJQKZjPwxE5MhkAzlJijMLsLvnoW8lbxy4x+Ip5jSG0OBTDMRllLzYzU477et5TdoFU9ioWiJP96Tp+eE0zhFxrBY750k/dMdeth6G5nHy+aTXHFynAlk7J9AydeYgvIAvs/lPrEMJTGMg5xuIwZS5ofqO61hFCWLi7L2NhWTLY/eLmpQtIu5wtLENRpaqgxvjYTjNvDAUssO1yNPlTKwwaLl9UMQACvS9CXFheJO21VN9g8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=qGHpQQGP+YVhKbtouiCvmg/ZjtQ7prAcbUk2Lpl+z7E=; b=zQODgA6oA81A922h/xfk4XDvV5gQPcVpydCd+IjeNKlv2AIBu+0B2RxXxkyYsI7PjZl5288NTiYCTA/xugYHkNRHd49oFa193p/FrPTY6qk4C6JFtlZtV33YEFQUtGrO3y5S2TUnfWjNQGITiID9xUVSgpnWG9WmVU7IGh+yCTWUKsFTga5jfwyWb5IAL3ZJUJLIFvNWD20PGkgyzAeIzB7yCIhf5lI3SLwASMe8i6breoYgOpRVEWvqcLPHS6+bf/DT9dT1sZjoObNL5z0K3S9HJhiGhqTOk8SsBC/IuL5JDSF/YmHi9/pyr+9B/X9COi52Btm2vRrVauVusWEj8g== 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=qGHpQQGP+YVhKbtouiCvmg/ZjtQ7prAcbUk2Lpl+z7E=; b=x3canAxrRFFASdepxxnvFT0DiaDQ3HYJEOv6PVuRGeuRn3v7ibPZhRCeHAuO2bnnaVI8fkd5aMTb4bWIr33GksVEtSEVnnfwpVE9AX+AV/U5yyrBYLd3PsDZZd6ezLY9X+CSXFa0GwiMUIynoT64bqE9QfWMuu9i5J0wQxVJRfw= Received: from DS7PR03CA0246.namprd03.prod.outlook.com (2603:10b6:5:3b3::11) by SJ0PR12MB7473.namprd12.prod.outlook.com (2603:10b6:a03:48d::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.11; Fri, 6 Dec 2024 16:12:37 +0000 Received: from DS1PEPF00017093.namprd03.prod.outlook.com (2603:10b6:5:3b3:cafe::d5) by DS7PR03CA0246.outlook.office365.com (2603:10b6:5:3b3::11) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.19 via Frontend Transport; Fri, 6 Dec 2024 16:12:37 +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 DS1PEPF00017093.mail.protection.outlook.com (10.167.17.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Fri, 6 Dec 2024 16:12:36 +0000 Received: from purico-9eb2host.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.39; Fri, 6 Dec 2024 10:12:35 -0600 From: Yazen Ghannam To: , , Tony Luck , Mario Limonciello , "Bjorn Helgaas" , Jean Delvare , "Guenter Roeck" , Clemens Ladisch , "Shyam Sundar S K" , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Naveen Krishna Chatradhi" , Suma Hegde CC: , , , , Subject: [PATCH v2 14/16] x86/amd_node, platform/x86/amd/hsmp: Have HSMP use SMN through AMD_NODE Date: Fri, 6 Dec 2024 16:12:07 +0000 Message-ID: <20241206161210.163701-15-yazen.ghannam@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241206161210.163701-1-yazen.ghannam@amd.com> References: <20241206161210.163701-1-yazen.ghannam@amd.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.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: DS1PEPF00017093:EE_|SJ0PR12MB7473:EE_ X-MS-Office365-Filtering-Correlation-Id: 2dc53ed3-3fbb-49be-ee83-08dd1610ccf5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|7416014|376014|82310400026|921020; X-Microsoft-Antispam-Message-Info: kxmBPEvqlFDwdmcp+TwGFoRyrKKN6MqCubf/TXjZF6d3UZ3WQEYHNIzHuvHcklwB4gPlOJrQCUCbVWnENwEGUvwFsGwk/HE61GCjZuzUkzgN8h+nlo93z+ve2nG1uGkl1ErgYia/to96EPvQjzSqNYpwH8VYteiGb/zjxG4QPoxes/Da8fipMQnROcfitc0C78ka8ncFYO3LRxGdCYVNlnSGOA9VCZBz/BdqLQ+dYYUKfyknZRyZWNyccJ7JjODz4QH1PNChaX6pS0uW5EwRL5qExYGkIc+MbdfBRVuzgLBOBn04wH/l325AjZdiYIBMtTEAWxC7lWuW7fIXEudYDqkoRQir4tgmbRbrBZBsyCaL8EiyTHSrngpCzOpPlO6qclyOWAVjXlYySF6V2QntJEdzmAlIvPLeKdxzKNaomoB9fLXF6EL1/RxyMQ4au9sCgJwTOvZHP/3fV7kqInaDfLPiWQGONRuthWQ0mPQrNYTPzK6Ddw9DTSzqJP34dtjPT3q5mvyYVxLuSjSOcPllQA0CU2reTZwlQOagq0H6j+FdEw6LxJSDzaCgGqkcsACQe08P6LSiWETgJrzTxBQcIwGCCqdRbWNm5PSXAyaeorsLKB2GwwuLPWd7ZvpJoHqC2paEvbjMpvtsR2TYWqplbBGh1006oGv53ZJeKV6kD6wKVPfoUvhmbJOzc4503JNzyQd9oKmeyY/CBIk3cIw5eqY7XpAM7pWLALguTG5WSstA3ZC/Y/QBtVaKXxr+mi4EKpe7GchXwJ/UsqId4seOOjAfAXo1ITg4ET/egMUROxPBRbakJRteC4mHn01ERH8MxYt5qxfbzwb+iO79bZnskMOxh7BOZObTaaRWIUKMYvYmOK/p+Apa2eXrDIUei0QIFYOXgehigXa5P1Ev47cD4kTuoQTyHoiFILwOyDsKUN2TxCcFkk6PbeircQil0gNvOlwUDi2m9TkRKGY76OX0w4Zrx/TU3rPzwKkig4VhPMHDENFpCzhsOlCc0BCI+0LyxXgopSJ8unpVawTflkheKoLGDgqmDPV2EpKcvAqrrpTUIeGVnRNnIIEg/UbDOjgnzDsHw4SD8KAe3U2TBFVzl1I4XovRhNlrqSHrfcO9aIZuh6n7PQhc4+DRr3NQ/UB2pCFFjjQ0F78tlyotu/IjVLZdiTUARqfCgu9C2Noy7D/yORJa3wMoArJIyjRQdUHCFELu7DfmKFANLFA7o6FDWuOMdQOCHQejHHBdQxrl78cGyy3OzoM5xzi3MpIk/unE3OWEV508Xph4qemVBOUvps8Tk/cIML20LnjL5dhV987e3mZD0VYjD/22Qd+erf/b3Oir3dqx1GKfFJ+0lhgn0jf4WHcHTHoJZq6OKwg5NsePejsAYTCN8EVA50LD6lcvQowIoWuRbJpMkZ79wEz7imqEtHsL8azyv193MMCyVFl6b9RlkXIl1+aE00s91Kn+qnkaASRevqCASpk+ab8wFA== 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:(13230040)(1800799024)(36860700013)(7416014)(376014)(82310400026)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 16:12:36.9341 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2dc53ed3-3fbb-49be-ee83-08dd1610ccf5 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: DS1PEPF00017093.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB7473 The HSMP interface is just an SMN interface with different offsets. Define an HSMP wrapper in the SMN code and have the HSMP platform driver use that rather than a local solution. Also, remove the "root" member from AMD_NB, since there are no more users of it. Signed-off-by: Yazen Ghannam --- Notes: Link: https://lore.kernel.org/20241023172150.659002-15-yazen.ghannam@amd.com v1->v2: * Rebase on recent HSMP rework. arch/x86/include/asm/amd_nb.h | 1 - arch/x86/include/asm/amd_node.h | 3 +++ arch/x86/kernel/amd_nb.c | 1 - arch/x86/kernel/amd_node.c | 9 ++++++++ drivers/platform/x86/amd/hsmp/Kconfig | 2 +- drivers/platform/x86/amd/hsmp/acpi.c | 7 ++++--- drivers/platform/x86/amd/hsmp/hsmp.c | 1 - drivers/platform/x86/amd/hsmp/hsmp.h | 3 --- drivers/platform/x86/amd/hsmp/plat.c | 30 ++++++--------------------- 9 files changed, 23 insertions(+), 34 deletions(-) diff --git a/arch/x86/include/asm/amd_nb.h b/arch/x86/include/asm/amd_nb.h index 4c4efb93045e..adfa0854cf2d 100644 --- a/arch/x86/include/asm/amd_nb.h +++ b/arch/x86/include/asm/amd_nb.h @@ -27,7 +27,6 @@ struct amd_l3_cache { }; struct amd_northbridge { - struct pci_dev *root; struct pci_dev *misc; struct pci_dev *link; struct amd_l3_cache l3_cache; diff --git a/arch/x86/include/asm/amd_node.h b/arch/x86/include/asm/amd_node.h index 113ad3e8ee40..5fe9c6537434 100644 --- a/arch/x86/include/asm/amd_node.h +++ b/arch/x86/include/asm/amd_node.h @@ -33,4 +33,7 @@ static inline u16 amd_num_nodes(void) int __must_check amd_smn_read(u16 node, u32 address, u32 *value); int __must_check amd_smn_write(u16 node, u32 address, u32 value); +/* Should only be used by the HSMP driver. */ +int __must_check amd_smn_hsmp_rdwr(u16 node, u32 address, u32 *value, bool write); + #endif /*_ASM_X86_AMD_NODE_H_*/ diff --git a/arch/x86/kernel/amd_nb.c b/arch/x86/kernel/amd_nb.c index 2729e99806ec..3a20312062af 100644 --- a/arch/x86/kernel/amd_nb.c +++ b/arch/x86/kernel/amd_nb.c @@ -73,7 +73,6 @@ static int amd_cache_northbridges(void) amd_northbridges.nb = nb; for (i = 0; i < amd_northbridges.num; i++) { - node_to_amd_nb(i)->root = amd_node_get_root(i); node_to_amd_nb(i)->misc = amd_node_get_func(i, 3); node_to_amd_nb(i)->link = amd_node_get_func(i, 4); } diff --git a/arch/x86/kernel/amd_node.c b/arch/x86/kernel/amd_node.c index d2ec7fd555c5..65045f223c10 100644 --- a/arch/x86/kernel/amd_node.c +++ b/arch/x86/kernel/amd_node.c @@ -97,6 +97,9 @@ static DEFINE_MUTEX(smn_mutex); #define SMN_INDEX_OFFSET 0x60 #define SMN_DATA_OFFSET 0x64 +#define HSMP_INDEX_OFFSET 0xc4 +#define HSMP_DATA_OFFSET 0xc8 + /* * SMN accesses may fail in ways that are difficult to detect here in the called * functions amd_smn_read() and amd_smn_write(). Therefore, callers must do @@ -179,6 +182,12 @@ int __must_check amd_smn_write(u16 node, u32 address, u32 value) } EXPORT_SYMBOL_GPL(amd_smn_write); +int __must_check amd_smn_hsmp_rdwr(u16 node, u32 address, u32 *value, bool write) +{ + return __amd_smn_rw(HSMP_INDEX_OFFSET, HSMP_DATA_OFFSET, node, address, value, write); +} +EXPORT_SYMBOL_GPL(amd_smn_hsmp_rdwr); + static int amd_cache_roots(void) { u16 node, num_nodes = amd_num_nodes(); diff --git a/drivers/platform/x86/amd/hsmp/Kconfig b/drivers/platform/x86/amd/hsmp/Kconfig index 7d10d4462a45..d6f7a62d55b5 100644 --- a/drivers/platform/x86/amd/hsmp/Kconfig +++ b/drivers/platform/x86/amd/hsmp/Kconfig @@ -7,7 +7,7 @@ config AMD_HSMP tristate menu "AMD HSMP Driver" - depends on AMD_NB || COMPILE_TEST + depends on AMD_NODE || COMPILE_TEST config AMD_HSMP_ACPI tristate "AMD HSMP ACPI device driver" diff --git a/drivers/platform/x86/amd/hsmp/acpi.c b/drivers/platform/x86/amd/hsmp/acpi.c index e981d45e1c12..28565ca78afd 100644 --- a/drivers/platform/x86/amd/hsmp/acpi.c +++ b/drivers/platform/x86/amd/hsmp/acpi.c @@ -10,7 +10,6 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include -#include #include #include @@ -24,6 +23,8 @@ #include +#include + #include "hsmp.h" #define DRIVER_NAME "amd_hsmp" @@ -321,8 +322,8 @@ static int hsmp_acpi_probe(struct platform_device *pdev) return -ENOMEM; if (!hsmp_pdev->is_probed) { - hsmp_pdev->num_sockets = amd_nb_num(); - if (hsmp_pdev->num_sockets == 0 || hsmp_pdev->num_sockets > MAX_AMD_SOCKETS) + hsmp_pdev->num_sockets = amd_num_nodes(); + if (hsmp_pdev->num_sockets == 0 || hsmp_pdev->num_sockets > MAX_AMD_NUM_NODES) return -ENODEV; hsmp_pdev->sock = devm_kcalloc(&pdev->dev, hsmp_pdev->num_sockets, diff --git a/drivers/platform/x86/amd/hsmp/hsmp.c b/drivers/platform/x86/amd/hsmp/hsmp.c index 227b4ad4a51a..e04c613ad5d6 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.c +++ b/drivers/platform/x86/amd/hsmp/hsmp.c @@ -8,7 +8,6 @@ */ #include -#include #include #include diff --git a/drivers/platform/x86/amd/hsmp/hsmp.h b/drivers/platform/x86/amd/hsmp/hsmp.h index e852f0a947e4..af8b21f821d6 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.h +++ b/drivers/platform/x86/amd/hsmp/hsmp.h @@ -21,8 +21,6 @@ #define HSMP_ATTR_GRP_NAME_SIZE 10 -#define MAX_AMD_SOCKETS 8 - #define HSMP_CDEV_NAME "hsmp_cdev" #define HSMP_DEVNODE_NAME "hsmp" @@ -41,7 +39,6 @@ struct hsmp_socket { void __iomem *virt_base_addr; struct semaphore hsmp_sem; char name[HSMP_ATTR_GRP_NAME_SIZE]; - struct pci_dev *root; struct device *dev; u16 sock_ind; int (*amd_hsmp_rdwr)(struct hsmp_socket *sock, u32 off, u32 *val, bool rw); diff --git a/drivers/platform/x86/amd/hsmp/plat.c b/drivers/platform/x86/amd/hsmp/plat.c index a61f815c9f80..42bd4553bffd 100644 --- a/drivers/platform/x86/amd/hsmp/plat.c +++ b/drivers/platform/x86/amd/hsmp/plat.c @@ -10,7 +10,6 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include -#include #include #include @@ -18,6 +17,8 @@ #include #include +#include + #include "hsmp.h" #define DRIVER_NAME "amd_hsmp" @@ -34,28 +35,12 @@ #define SMN_HSMP_MSG_RESP 0x0010980 #define SMN_HSMP_MSG_DATA 0x00109E0 -#define HSMP_INDEX_REG 0xc4 -#define HSMP_DATA_REG 0xc8 - static struct hsmp_plat_device *hsmp_pdev; static int amd_hsmp_pci_rdwr(struct hsmp_socket *sock, u32 offset, u32 *value, bool write) { - int ret; - - if (!sock->root) - return -ENODEV; - - ret = pci_write_config_dword(sock->root, HSMP_INDEX_REG, - sock->mbinfo.base_addr + offset); - if (ret) - return ret; - - ret = (write ? pci_write_config_dword(sock->root, HSMP_DATA_REG, *value) - : pci_read_config_dword(sock->root, HSMP_DATA_REG, value)); - - return ret; + return amd_smn_hsmp_rdwr(sock->sock_ind, sock->mbinfo.base_addr + offset, value, write); } static ssize_t hsmp_metric_tbl_plat_read(struct file *filp, struct kobject *kobj, @@ -159,10 +144,7 @@ static int init_platform_device(struct device *dev) int ret, i; for (i = 0; i < hsmp_pdev->num_sockets; i++) { - if (!node_to_amd_nb(i)) - return -ENODEV; sock = &hsmp_pdev->sock[i]; - sock->root = node_to_amd_nb(i)->root; sock->sock_ind = i; sock->dev = dev; sock->mbinfo.base_addr = SMN_HSMP_BASE; @@ -305,11 +287,11 @@ static int __init hsmp_plt_init(void) return -ENOMEM; /* - * amd_nb_num() returns number of SMN/DF interfaces present in the system + * amd_num_nodes() returns number of SMN/DF interfaces present in the system * if we have N SMN/DF interfaces that ideally means N sockets */ - hsmp_pdev->num_sockets = amd_nb_num(); - if (hsmp_pdev->num_sockets == 0 || hsmp_pdev->num_sockets > MAX_AMD_SOCKETS) + hsmp_pdev->num_sockets = amd_num_nodes(); + if (hsmp_pdev->num_sockets == 0 || hsmp_pdev->num_sockets > MAX_AMD_NUM_NODES) return ret; ret = platform_driver_register(&amd_hsmp_driver); From patchwork Fri Dec 6 16:12:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 13897354 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2069.outbound.protection.outlook.com [40.107.95.69]) (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 9952C2116E7; Fri, 6 Dec 2024 16:12:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.69 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733501566; cv=fail; b=JG54JsWIKv6SSCY7TO/llsqRZXKACwc5wy3+RNYOpc/zhOYjiiXnsTs6oJyUlvCADspzGvFF3KutKsjxuZnLVWFdxqOyMfn8Nsj7rPQrDpngCmDXiY0jhNm96VqILeL7ckoBlBc0mnD2Wc7Mj9cdcHlJK68twjsPMiYtT5IYLEQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733501566; c=relaxed/simple; bh=MwEf5gtHST7+XitqXEEhokGYiEmYO6q5w/15Zb/HHMQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bOcmsLOEVRy7mGWCwv0cTkMxZevFo+FhdeknM+KIj86l+V6TUformNgakHcDGOd/gd+FeiqCQCKQ9KrAExAWx2q99DVqjZhaOuajLRWh4j7XYX0NAYgz1vVxLD4f4mQ8uInrF3KPi38a5zxiUSDUunaImCh5rUEVUGXfNatMa2E= 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=B8tOCm2m; arc=fail smtp.client-ip=40.107.95.69 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="B8tOCm2m" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XrSz5wNRlTjC1NoVBfwZe7RnbBUry4RJ32gP8485WD1Uxkgmt667WHQdTUFh8MQfyKkrbsKDqHd7HNEynQ21itCVM+GCrLr2FFw+4U2yBGVYPT/mmaxG2VwA6bePEOQzkp5fiKDBzxGd6FTNLqBaB97NjUAXWvARRFewh0cDnMotbxORVD2l77SZjHtJN5rtrtCnioks8XGD2WCbr6pAPM1qGISiZsFcV472yqcZQakj9KimOtQaq3lOEYRXHAfhtlpHSsdGQgZSDAaX36OfYKFXu+4MjbUXKFHlBwKTkeyxckgBj0FM6V569KQ20j+6kOxB5KUlnUVoQ/Bc+1PbVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=xensgGzD9KbdIJGoXyvlN0pk+M22gE0tYGWOT+VnKcs=; b=h1I+H7n1u8cPbNiomBS8iUramPM5Jd0ba4qYxILOi/TywM+xXE2VQalzX6Z5NFsF/mjEhNiHBX1ntawqgy5Mpn3ewHqxXvSGkarVwI3QUImjoyM1TnMyBxEr0JZPFKvDVlogyWzIBBaWWE6+hembObOSGwCgzFnytQjdpYRUCYiFCy0K833obqil9FK0xz7lsEClRaFR+cpCtr38TKX7mTZRbaXf4o9JTp6ilwBLRsa85BzFu7vwCwmG0H3c2M0iCXBnqJcHF3B78aRJ6+iEse6p/wqg429hfqmXADFuxZAfj6PH5LEEukHZL4lpsOfc4Ds+Nx3Py3h3XUT7OLRFJA== 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=xensgGzD9KbdIJGoXyvlN0pk+M22gE0tYGWOT+VnKcs=; b=B8tOCm2mNl+BmJJydP2HSGkppZRv/A/rs8GcrKFy0+Dg7sJvxWQf7NiBacsx48lCfuNmkNj+q0tZ30Boecv0kymrnpGhtpjJbF5RIvMdKuOeAbtBphvjEd0oULxf6M4+PsoLSUVDOxP/h+j+SlmRuFmj6WQxvV7LxOnYHTs+3IU= Received: from DS7PR03CA0252.namprd03.prod.outlook.com (2603:10b6:5:3b3::17) by SA1PR12MB7409.namprd12.prod.outlook.com (2603:10b6:806:29c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.18; Fri, 6 Dec 2024 16:12:37 +0000 Received: from DS1PEPF00017093.namprd03.prod.outlook.com (2603:10b6:5:3b3:cafe::79) by DS7PR03CA0252.outlook.office365.com (2603:10b6:5:3b3::17) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.12 via Frontend Transport; Fri, 6 Dec 2024 16:12:37 +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 DS1PEPF00017093.mail.protection.outlook.com (10.167.17.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Fri, 6 Dec 2024 16:12:37 +0000 Received: from purico-9eb2host.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.39; Fri, 6 Dec 2024 10:12:35 -0600 From: Yazen Ghannam To: , , Tony Luck , Mario Limonciello , "Bjorn Helgaas" , Jean Delvare , "Guenter Roeck" , Clemens Ladisch , "Shyam Sundar S K" , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Naveen Krishna Chatradhi" , Suma Hegde CC: , , , , Subject: [PATCH v2 15/16] x86/amd_node: Add SMN offsets to exclusive region access Date: Fri, 6 Dec 2024 16:12:08 +0000 Message-ID: <20241206161210.163701-16-yazen.ghannam@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241206161210.163701-1-yazen.ghannam@amd.com> References: <20241206161210.163701-1-yazen.ghannam@amd.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.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: DS1PEPF00017093:EE_|SA1PR12MB7409:EE_ X-MS-Office365-Filtering-Correlation-Id: a22ebeac-19fe-45e0-87d5-08dd1610cd50 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|7416014|376014|921020; X-Microsoft-Antispam-Message-Info: TZ0Jy0WJdB3E0NSv9nmqAitDFFoAIuGc/L2gQ5p+qfPQqhXuJ3t+WbLLPyFJgMgzgtgx8Ybb4gMQ28DAwflNEPO4GWnpK11iW7IrZWSZKlYqGAlPFb+LSUpERCoPrXIOT87G/QdKBcEmkaFfd3y4HmVAbpniNXIxF6g4P0uDd5WyCXXRCVeaRHxJ8YDbH0aZwwoBeUmvUwqWz1Vw/A/DwCODmuZ+DrUzSzhcdIgJ1HfsBKQzJvaFVHqP7h+rluFhsSiHkkZuIdNmiBdB5TYsRxd4D8bx8i12fW9KOzbF4iqF7PK9MJjGA9IHdQJ4V3nAGX6paMC7bvDUCPDPkuIAtBfxWpWW3NDOBM5gV2mVYeze92Enjys/pqM3HmwpT0RB1BUb9M05xUdpKfD08AU3t4f3PrcALMt5kVkYF2ZxNre5HzO0Buaens+17SH0oHvEiKn6ZKPLfYnqeJ3FyIpm+/SpYSGzAzl7aRgvUqgj+LmIxX32ZXrwIpDRLbnl7pqng5vjKizuz+0ZqjjNpekQsbc1+WuT8UyleIgj5baUkzJT8MzFEdL2L6NPo7w3zvwyHGmJqdxfz75CvroSj5iIq8pLXOyV3XQTiYIU81RlR4X1hw7zLmw6DmgysLNC2MUdPr4HeDRlvj7c09ieNvloH9Cr+jjRj8QsAN8pJp62hH66sbC4c7VzUW+Fb6YXahZIZjvriN7pJTG8MdGLViOSABLVtwb9Rr6PSgEVyUlAV+loBNARvmiE1Tiwwqblq34QfQeZqlSgKJndmWN6M7QATci2d9OmGb+bYQwjRtVBkqXQcb1M0gWS/79Ku7VPrjcgEb/mKmorOe/uyQCNLfy+u2Yd+FsyW9ZC9nbrmueC6P3XUpgBBWuQlEfFP6TngB2bmAN8ZRF2DWxKtHHISZ7p0Ho89zOTXMe0f/yNAXb7ulQKpgNSK5Eq7QMnjM/zs7eD72p9ZYt7PhOoQWc1g/AVJCssNN5qri2vJ9qdkH8Gwt2UmorS6D+TqbvtQQkeNsY4v+FnqlKPuhm6UEdGpEWpEGUmr7eHKeU0FM2DGXnEz5VadpQRcZUIzQkbI48qN3wGCgepdXMZqs0K6EqYwAbpUe3pi/l9n4+Arz2uvlb+7InSSxgKIeUK0HWuTWCCDGOqgO9S+9jP7bjFM3o5ZjNZrxK9v4F5OwBMqNnnZ/pIoX9LQ5cI4rzZuNA3gFpxc/76eq/v+F1iW2DenTz7yIhobB6OP8PDM5n5QUGze0a7Ly5idvFRiZHdZfTJY0pK4+w7Oz2F0z/3MtGsYdc0MbB21USmuTiNb44NJbdaRkxD8K8Qr+SXhxx1xlxAHT/GtnBByeK/0z77dIl2N4Q+eu/04aUZA4FH+k/qqWsagLQjdIp04Y6Y/JT51slJ4a4yMaFapLP6vvn6vrzdNmOohic4becVrUhPdTV2DCdzVA6gmACRpXcbtFb+QcezFhsGypTl97Nfc3uWIWtW+ltqBRIfGg== 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:(13230040)(1800799024)(36860700013)(82310400026)(7416014)(376014)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 16:12:37.5279 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a22ebeac-19fe-45e0-87d5-08dd1610cd50 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: DS1PEPF00017093.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7409 From: Mario Limonciello Offsets 0x60 and 0x64 are used internally by kernel drivers that call the amd_smn_read() and amd_smn_write() functions. If userspace accesses the regions at the same time as the kernel it may cause malfunctions in drivers using the offsets. Add these offsets to the exclusions so that the kernel is tainted if a non locked down userspace tries to access them. Signed-off-by: Mario Limonciello Signed-off-by: Yazen Ghannam --- Notes: Link: https://lore.kernel.org/20241023172150.659002-16-yazen.ghannam@amd.com v1->v2: * No change. arch/x86/kernel/amd_node.c | 41 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/arch/x86/kernel/amd_node.c b/arch/x86/kernel/amd_node.c index 65045f223c10..ac571948cb35 100644 --- a/arch/x86/kernel/amd_node.c +++ b/arch/x86/kernel/amd_node.c @@ -93,6 +93,7 @@ static struct pci_dev **amd_roots; /* Protect the PCI config register pairs used for SMN. */ static DEFINE_MUTEX(smn_mutex); +static bool smn_exclusive; #define SMN_INDEX_OFFSET 0x60 #define SMN_DATA_OFFSET 0x64 @@ -149,6 +150,9 @@ static int __amd_smn_rw(u8 i_off, u8 d_off, u16 node, u32 address, u32 *value, b if (!root) return err; + if (!smn_exclusive) + return err; + guard(mutex)(&smn_mutex); err = pci_write_config_dword(root, i_off, address); @@ -202,6 +206,39 @@ static int amd_cache_roots(void) return 0; } +static int reserve_root_config_spaces(void) +{ + struct pci_dev *root = NULL; + struct pci_bus *bus = NULL; + + while ((bus = pci_find_next_bus(bus))) { + /* Root device is Device 0 Function 0 on each Primary Bus. */ + root = pci_get_slot(bus, 0); + if (!root) + continue; + + if (root->vendor != PCI_VENDOR_ID_AMD && + root->vendor != PCI_VENDOR_ID_HYGON) + continue; + + pci_dbg(root, "Reserving PCI config space\n"); + + /* + * There are a few SMN index/data pairs and other registers + * that shouldn't be accessed by user space. + * So reserve the entire PCI config space for simplicity rather + * than covering specific registers piecemeal. + */ + if (!pci_request_config_region_exclusive(root, 0, PCI_CFG_SPACE_SIZE, NULL)) { + pci_err(root, "Failed to reserve config space\n"); + return -EEXIST; + } + } + + smn_exclusive = true; + return 0; +} + static int __init amd_smn_init(void) { int err; @@ -218,6 +255,10 @@ static int __init amd_smn_init(void) if (err) return err; + err = reserve_root_config_spaces(); + if (err) + return err; + return 0; } From patchwork Fri Dec 6 16:12:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 13897353 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2040.outbound.protection.outlook.com [40.107.102.40]) (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 AD24420DD66; Fri, 6 Dec 2024 16:12:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.102.40 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733501564; cv=fail; b=cpd3XeNuYnu/+XnI+4C506YTG+tb6BVj0kIakY/UgRz3bdaBJtXREI5y8qGdDyZ+N3NSpzKzELASOB/XsWXvbTMCbAKvHR8qzo4rbTf8dAUmh/6KWW4qetcIjkzQZLYU07+YUTeJKQmasAErTZNygaU0ZGfPYbCSoZ2Rdnjkcb4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733501564; c=relaxed/simple; bh=RYm8BqMlEH6yyCKTyOl4gvad7YVqLaIy0W2NlwGbZQg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TO4yuHg8aQROz4nyhZvp/g/JqDsoETltcqlOc0OLj+XS9MbJyCbjh9wf96gMGAg5vT2q4uTz/o/a9WnL2gUnSCt/YnOyNgwXAzaKUlqE4BwOXhvXL5b5b9oNrMzen6IzJ95gnbu513jZPBbZ5rW9X8zVicgAJafgbrHm3LHxx4c= 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=dpgmnjnI; arc=fail smtp.client-ip=40.107.102.40 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="dpgmnjnI" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SL59TV18aPfTsqMqWPLxZONL/kV5/O2TJ3aU5jkdWtvXrIcZqXwV95DrOk3DoJjTjrnkMZVJITrJQjp7ROxHpAh5VUIJs/LqOzu0YRK8A5QCDU+Qc1Xxh34b+grO+9XfcY48D5X1iw1DuSdhu/hAneKfE0tRTUP71NsYqRt55iHeEjM/ftoZ1wE1M/KLj9ZPlUdf0OYpqCew/vmw+QDMjXKhAEF/cnfQaABTtIKrGO/dTOKkN3HLxqdS9m/H8KvJqx2ZpEYqyPdOR6WfE8TERrPgznQT48ldbBfweFZ5A2Wy2wIwymnWjfaJmMl0Lshj9IJSc2xo9vHY/TFtu/CUsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=Cg8BZBWXBiypPOyCwJ9J2w1f7xTy5DTk2AFBkN7kQ6Y=; b=PTbXQMRfF0qScvugni0zHwxINYkmQTH3bhjiJQHYCIzaeV0RuBKis5HxxNIZ/WsQY8TCVOI1ARCj0xcXbINq4TiRLsp+di/iK4paZQru7zYsd/kIxY99UJ38sAjyzEhDia4hcKIQPjVRE80aDjl2dz4/M9MYJ2hX8Smg1Ro2Xi/xCH77aFom3VxKaPJig9JhIaeDleLkGpAUpW76DaImjFiUNhn4GvdDJGGpBzEtchyYwIJksaNr41J3/t5NB9fD3MG+TYvoGF7h7hPOg3ssUnp6RXOHgwoTF7ERIKCTUC3iS2y80E8y7oqcQvwEAtprlSpfz5+EmEN2HhUaghKfIQ== 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=Cg8BZBWXBiypPOyCwJ9J2w1f7xTy5DTk2AFBkN7kQ6Y=; b=dpgmnjnI/+XkSZIJKqUuE8xXyvZvgpfKdSaY6oxAMfEMUnrJLTBnbkKIcO5MbwuMyLJVkkOTQbESI32LRUlFF/h4t/v36juy5F6EtdARvQeMvxgFLZD4ZrdMlXbqdhr3RmZtiQFnP8B/zKs5tgnIukG6y669Oxfd2eonnUcJ0xU= Received: from DS7PR03CA0251.namprd03.prod.outlook.com (2603:10b6:5:3b3::16) by CY8PR12MB7121.namprd12.prod.outlook.com (2603:10b6:930:62::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.12; Fri, 6 Dec 2024 16:12:38 +0000 Received: from DS1PEPF00017093.namprd03.prod.outlook.com (2603:10b6:5:3b3:cafe::da) by DS7PR03CA0251.outlook.office365.com (2603:10b6:5:3b3::16) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.10 via Frontend Transport; Fri, 6 Dec 2024 16:12:38 +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 DS1PEPF00017093.mail.protection.outlook.com (10.167.17.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Fri, 6 Dec 2024 16:12:38 +0000 Received: from purico-9eb2host.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.39; Fri, 6 Dec 2024 10:12:36 -0600 From: Yazen Ghannam To: , , Tony Luck , Mario Limonciello , "Bjorn Helgaas" , Jean Delvare , "Guenter Roeck" , Clemens Ladisch , "Shyam Sundar S K" , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Naveen Krishna Chatradhi" , Suma Hegde CC: , , , , Subject: [PATCH v2 16/16] x86/amd_node: Add support for debugfs access to SMN registers Date: Fri, 6 Dec 2024 16:12:09 +0000 Message-ID: <20241206161210.163701-17-yazen.ghannam@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241206161210.163701-1-yazen.ghannam@amd.com> References: <20241206161210.163701-1-yazen.ghannam@amd.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.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: DS1PEPF00017093:EE_|CY8PR12MB7121:EE_ X-MS-Office365-Filtering-Correlation-Id: 06f56bba-dbb6-4681-97cc-08dd1610cda1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|1800799024|36860700013|921020; X-Microsoft-Antispam-Message-Info: Rf/l9LLTh+nqQjgsyO5LA7y2Qjy1gnzPyaKoImLKm7HOt4b22ksHu8vz4kv1FOw22S496ZZQ4Q+nhlLRxsQdJRT1piiwVElp5eRgN0CjAhNvMPwrzcdJvhnUeDcMgfXV9WaLJMibNdacRuyoqBmxIq9AFYQhAU7lRmV4mMIQP0K0nJ6dpvoqHJOAHMWm9ORQVhCZviu6oAriIjRY33+xWnrXeMzWT19DmG1A/LxqJ+1xl3z9GvAWkNZMqCUsFtUs5cPDLz7Qfo7SUcdnXvwg15uINCi5ze0A2fFcOWLjqXXRUfRMfGIgMLXE11XC1sscBmWzyl+CPXqoK/xcx3o1QnSh5LFkx6eNZ43JK3UGZohKmQccVQct9ErVWqmDTO0RbqlgXVzTLKOhvt54gdzRzoBGg1RlF+Ne110dvaJRhl8GbHIyUL/kv+wAX5v+Tz6BAIBMGw1LzIBNBnggYm0fpS1NyP7zl1YMN2je4CaueXW/M8XEik/YgRH+vMXHxw9uct7esD+vNKpBt1Wlqzc3IOtKFzpWwYUjuUQlTz6t24RuT25eTgmqYW2z/e4ClxeQsPwjvfA87euCuU1MriAbqLYD4I0HLozk6pCsY3Kzq8IphiDtMf8HBLEzA1YIH/YxxbqG/gNj7c4ZQ8yBfzdUtGTb8XOyYzRwpsoIUZopWuV3xTPTIb3db9KVL6pWsQs2/N3a4cfPFfxNEbZ0Ia4ddZ52ZlBkeh91J1hJbQzwXfDvOWyOwT/MTmlM8NbqcpSj59JOvHJYtylpUz0LtV49EHPeGjjhLxumPiQ7ZKpSdX/uwixHzH2vkfLk0srZIDVdmNwuaGGHkGLnf3As7QkUmvmYDcsAn0QDCpWNlw6hvtkKFEINU0PshSJ+2Ilr4VlK+li3hqtzowsyaYvXZFRisKj5RyVmJqHdnlNBQzFDzVCaW3n7AtEOeW/gjFToT32Y96GRJoUdJGJCgmD80ZgRYGKl7ayFV2TrWUktkWud1iszLcQmYOe2NiMk6nNWSpA9rCgI8ze1FDRJ+hOZP6b1NAYyXq5pHKTvLrgY/LiM1V2xa2OUUkpTxDKNznQhHBpbGCZhRDFfl4x27mKKjmtuICYSPQBBldtrdxG/eiQuiRp88O1yCKXgjT4Qe1nRjAlf1LKcem1YhEiA5xo2vVVM6ktAAAM4pfN6g8MmkZH4LrKwAh/Zg76mqC/ar0BCnMPuRsdhLGvVRRXcX5LI6rXoi7wp7G7Je4JONtWrvQ/Aoxu+x0S6x8J2sJWiLKuDgUg6dDZx910lMTf2nSitUUjFfJYRj0q82NlAY7snINJ4qIGKWKPRGUTL6cBM/9/bgi/iML8GVWScH7B1N1D6K1Rp7XfQwFylO4tCfmbKD8cW5tAWfAW7/HfA30A8sMX4Trt51TJOrxqTg7Z4f9awz6FJluqCTel3TLWTp+I+HYbbIe/mRWWl3Wts3ux7CqNe50GKvFisGmMiyIZDUilDRFwhMBvWqhqFhWlAmDdwSYqxAmg= 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:(13230040)(376014)(7416014)(82310400026)(1800799024)(36860700013)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 16:12:38.0591 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 06f56bba-dbb6-4681-97cc-08dd1610cda1 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: DS1PEPF00017093.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7121 From: Mario Limonciello There are certain registers on AMD Zen systems that can only be accessed through SMN. Introduce a new interface that provides debugfs files for accessing SMN. As this introduces the capability for userspace to manipulate the hardware in unpredictable ways, taint the kernel when writing. Include a kernel parameter to enable the debugfs interface. This is intentionally left undocumented to discourage use of the interface. Signed-off-by: Mario Limonciello Signed-off-by: Yazen Ghannam --- Notes: Link: https://lore.kernel.org/20241023172150.659002-17-yazen.ghannam@amd.com v1->v2: * Use TAINT_CPU_OUT_OF_SPEC. * Add parameter to enable debugfs interface. * Validate node input from user. arch/x86/kernel/amd_node.c | 99 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) diff --git a/arch/x86/kernel/amd_node.c b/arch/x86/kernel/amd_node.c index ac571948cb35..b670fa85c61b 100644 --- a/arch/x86/kernel/amd_node.c +++ b/arch/x86/kernel/amd_node.c @@ -8,6 +8,7 @@ * Author: Yazen Ghannam */ +#include #include /* @@ -192,6 +193,87 @@ int __must_check amd_smn_hsmp_rdwr(u16 node, u32 address, u32 *value, bool write } EXPORT_SYMBOL_GPL(amd_smn_hsmp_rdwr); +static struct dentry *debugfs_dir; +static u16 debug_node; +static u32 debug_address; + +static ssize_t smn_node_write(struct file *file, const char __user *userbuf, + size_t count, loff_t *ppos) +{ + u16 node; + int ret; + + ret = kstrtou16_from_user(userbuf, count, 0, &node); + if (ret) + return ret; + + if (node >= amd_num_nodes()) + return -ENODEV; + + debug_node = node; + return count; +} + +static int smn_node_show(struct seq_file *m, void *v) +{ + seq_printf(m, "0x%08x\n", debug_node); + return 0; +} + +static ssize_t smn_address_write(struct file *file, const char __user *userbuf, + size_t count, loff_t *ppos) +{ + int ret; + + ret = kstrtouint_from_user(userbuf, count, 0, &debug_address); + if (ret) + return ret; + + return count; +} + +static int smn_address_show(struct seq_file *m, void *v) +{ + seq_printf(m, "0x%08x\n", debug_address); + return 0; +} + +static int smn_value_show(struct seq_file *m, void *v) +{ + u32 val; + int ret; + + ret = amd_smn_read(debug_node, debug_address, &val); + if (ret) + return ret; + + seq_printf(m, "0x%08x\n", val); + return 0; +} + +static ssize_t smn_value_write(struct file *file, const char __user *userbuf, + size_t count, loff_t *ppos) +{ + u32 val; + int ret; + + ret = kstrtouint_from_user(userbuf, count, 0, &val); + if (ret) + return ret; + + add_taint(TAINT_CPU_OUT_OF_SPEC, LOCKDEP_STILL_OK); + + ret = amd_smn_write(debug_node, debug_address, val); + if (ret) + return ret; + + return count; +} + +DEFINE_SHOW_STORE_ATTRIBUTE(smn_node); +DEFINE_SHOW_STORE_ATTRIBUTE(smn_address); +DEFINE_SHOW_STORE_ATTRIBUTE(smn_value); + static int amd_cache_roots(void) { u16 node, num_nodes = amd_num_nodes(); @@ -239,6 +321,15 @@ static int reserve_root_config_spaces(void) return 0; } +static bool enable_dfs; + +static int __init amd_smn_enable_dfs(char *str) +{ + enable_dfs = true; + return 1; +} +__setup("amd_smn_debugfs_enable", amd_smn_enable_dfs); + static int __init amd_smn_init(void) { int err; @@ -259,6 +350,14 @@ static int __init amd_smn_init(void) if (err) return err; + if (enable_dfs) { + debugfs_dir = debugfs_create_dir("amd_smn", arch_debugfs_dir); + + debugfs_create_file("node", 0600, debugfs_dir, NULL, &smn_node_fops); + debugfs_create_file("address", 0600, debugfs_dir, NULL, &smn_address_fops); + debugfs_create_file("value", 0600, debugfs_dir, NULL, &smn_value_fops); + } + return 0; }