Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964942AbbKCUef (ORCPT ); Tue, 3 Nov 2015 15:34:35 -0500 Received: from mail-bl2on0096.outbound.protection.outlook.com ([65.55.169.96]:36576 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753416AbbKCUed (ORCPT ); Tue, 3 Nov 2015 15:34:33 -0500 Authentication-Results: spf=none (sender IP is 165.204.84.221) smtp.mailfrom=amd.com; 163.com; dkim=none (message not signed) header.d=none;163.com; dmarc=permerror action=none header.from=amd.com; X-WSS-ID: 0NX9AHF-07-DUS-02 X-M-MSG: From: Aravind Gopalakrishnan To: , , , CC: , , , , , Subject: [PATCH V2] x86/AMD: Fix LLC topology for AMD Fam17h systems Date: Tue, 3 Nov 2015 14:34:59 -0600 Message-ID: <1446582899-9378-1-git-send-email-Aravind.Gopalakrishnan@amd.com> X-Mailer: git-send-email 2.6.1 MIME-Version: 1.0 Content-Type: text/plain X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:165.204.84.221;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(2980300002)(428002)(199003)(189002)(106466001)(105586002)(19580405001)(87936001)(19580395003)(2201001)(36756003)(50226001)(86362001)(101416001)(5007970100001)(47776003)(53416004)(50986999)(11100500001)(5001920100001)(92566002)(189998001)(5008740100001)(5003940100001)(77096005)(48376002)(5003600100002)(5001770100001)(97736004)(50466002)(229853001);DIR:OUT;SFP:1101;SCL:1;SRVR:CY1PR12MB0716;H:atltwp01.amd.com;FPR:;SPF:None;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;CY1PR12MB0716;2:9lDoO+W+5Xz3v8lo7yWZ/XKyv976kZJUyalUHYB+3nE7xzPR8T2aNg/vGgaTXyMf0MY+NJz2A6cf6CVoHsN095PkJV3e0jm5UHqsvB/9jzmY1Vpxh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LqBmYG9I021/CSzg3ZvznNRc2bo2SbWBYCEEBAECySZA7KS7zOs94E23Eyp13rhWU5xTAPlvypPKbhG9PY++eNtI15rmiOtDIXtcd+JYubfQiIZMd4b6IYqBn1l+YSg+ePdnS/GwM;4:bfDgG6tSYMuNgsJ9DkvmEUrg7HA1eAa4mv8rMwGGjAIJMTHQEnSb75IxR9rwug+9+CTLJM/Vmy2zz7QBBH99yO4sGKXq+XGjmCHJOYtJlVmYG2mi6fq1f70mfOHd/cW0nvyHECdXstNFBq8WeIMR3+HwdYSD3+ZywnQzmpzTEI5qBdMBvoagTEFcY+gX3zkSLWrLUoaGNvL75IOrQRcEXUN/kbo2MaLrs1PnxKeZlKJa4BAu649mC1etBbeftl6KIZPfSof+9CGNI6P3DX/Pp1bSZ6cDqeaJMT0kdkfwvYB8kIKmMPI8XSLlCd7BUZU+ZLkV9uJr4ikXg9JLnUmcUN5VCbK6OLR+i76cCPxMgW4osHrA6EzGp5oqVoOvLAQA X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(8121501046)(5005006)(520078)(3002001)(10201501046);SRVR:CY1PR12MB0716;BCL:0;PCL:0;RULEID:;SRVR:CY1PR12MB0716; X-Forefront-PRVS: 0749DC2CE6 X-Microsoft-Exchange-Diagnostics: 1;CY1PR12MB0716;23:o6D0x4K170qxCrCwy9LRGV2+pdNAftzDem+4RBl8pd9/N2HLtrzanHH0mGmZXxO9JobzWnNbnhENu+F76X/x+hEzS9+hyMGKE4+CRXVDRkFoMcreuVQAKp3j4G4fO3cNWTR9CEufIwaNBChcRLwtGvr0e06NdUNLHOv9dSRxpTLWKjDHaenNeaEC10wOYdCJTnWbX3zWC0oaWixmPWu2MFdhmEOrsUdt4VWEnM1UVCayMTcNJWfakpSpZ8jzkO1TqPA5l5FT7W6F4dnKaUpbyftdljxw/kwkcKk8EJoefZtujU2bTnbc2cw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qb5lNL+ENXrk/9pzer+XOnT+zGEpOGigk21HCJXith0mbKCbcnWSRD2W4/jlJQDJ7N47U1LjPGPcGn/xPl5gTUBgSnQBF23fQ8NSkjV9jlWq4g2c2+Ja SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2015 20:34:28.6221 (UTC) X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.221];Helo=[atltwp01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR12MB0716 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1875 Lines: 56 On AMD Fam17h systems, the last level cache is not resident in Northbridge. Therefore, we cannot assign cpu_llc_id to same value as Node ID (as we have been doing currently) We should rather look at the ApicID bits of the core to provide us the last level cache ID info. Doing that here. Signed-off-by: Aravind Gopalakrishnan --- Changes in V2: - Move LLC calculation logic to amd_detect_cmp() and change patch header as a result. (This in turn fixes the issue found by kbuild bot on the V1 patch) arch/x86/kernel/cpu/amd.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c index 4a70fc6..dab371e 100644 --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c @@ -352,6 +352,8 @@ static void amd_detect_cmp(struct cpuinfo_x86 *c) #ifdef CONFIG_SMP unsigned bits; int cpu = smp_processor_id(); + unsigned int apicid = c->apicid; + unsigned int socket_id, core_complex_id; bits = c->x86_coreid_bits; /* Low order bits define the core id (index of core in socket) */ @@ -361,6 +363,17 @@ static void amd_detect_cmp(struct cpuinfo_x86 *c) /* use socket ID also for last level cache */ per_cpu(cpu_llc_id, cpu) = c->phys_proc_id; amd_get_topology(c); + + /* + * Fix percpu cpu_llc_id here as LLC topology is different + * for Fam17h systems. + */ + if (c->x86 != 0x17 || !cpuid_edx(0x80000006)) + return; + + socket_id = (apicid >> bits) - 1; + core_complex_id = (apicid & ((1 << bits) - 1)) >> 3; + per_cpu(cpu_llc_id, cpu) = (socket_id << 3) | core_complex_id; #endif } -- 2.6.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/