Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp570208img; Fri, 22 Mar 2019 04:14:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqzMVz9lCJ775hHeM68MpfnmI8DeT7gnnHeLFc8OAq4Shr9YI5kpxxL1SFS/03tEqgubuuDj X-Received: by 2002:a63:6949:: with SMTP id e70mr8276171pgc.89.1553253273625; Fri, 22 Mar 2019 04:14:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553253273; cv=none; d=google.com; s=arc-20160816; b=W/A8VC6cfeJe0sg1YXZXDOgOLrlYnKUp5qSb4PfM0pthppfovTgs8AK1Bti/gUtkWg UHdj/kdf3/tZAxmhPuWIuhjmSrY8MQ2rt9FcRKeNFfQ3+Oh+BUoHMFBjDxlbjlPhxKNu tit//l61xYTtRw2DsjADw/kVa9Kqaqg/oK+vA5IqkAfzkuChA0Twztp9/vau3cir8ozE tE3IkkEnPrW1hXtZauM6PzOggtDNbF/AN2QNoi/TpeO+zdkx0Nc6vjnXwppTLZAca7i7 33I1rmiLPVSUczbdk0KXhh6JnA7aT3F1J4BINAKBR+4kVzhUmGU9mz15JYxenccDDeq6 1iMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=EMJLgwNELhFS/4YvRFgo0uGcM5Pj2QGqJ92g1krUzMo=; b=mzwwd6p3My7fsDQ72kaUDZLLTC4kPtNxd8jnXRibNLRY8lOqLSFdqX44l6rpMn5moD L76PY9vr/pBmyequWOUYsqT12p/OioaEylKESI8JE4+mf/0UjgvOXvMbp/un0slha3nq WAMaFJq3FEzeX0f9rbY6dFORjFB6XbzSGIRz/TIFx2LwsQMuAISHYGbG+OWnYNMZCCv9 ZNgUmPrHEz8VHETHHsbsMP8vh5rAe6L/0FBo/MvCMYNyZRpUyexlOWWEazjMiM4uZ3Bp mIngG8c5HbE/lmT7NBVtTUxRH9w5Vn4GgwsRwLOCtPn3iqxjCqc2AqTlF36Tzsv188w1 JrMQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=hygon.cn Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d4si6320292pgk.501.2019.03.22.04.14.15; Fri, 22 Mar 2019 04:14:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=hygon.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728092AbfCVLN1 (ORCPT + 99 others); Fri, 22 Mar 2019 07:13:27 -0400 Received: from [110.188.70.11] ([110.188.70.11]:28972 "EHLO spam1.hygon.cn" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726667AbfCVLN0 (ORCPT ); Fri, 22 Mar 2019 07:13:26 -0400 X-Greylist: delayed 1639 seconds by postgrey-1.27 at vger.kernel.org; Fri, 22 Mar 2019 07:13:26 EDT Received: from spam1.hygon.cn (localhost [127.0.0.2] (may be forged)) by spam1.hygon.cn with ESMTP id x2MAk7Lo043175 for ; Fri, 22 Mar 2019 18:46:07 +0800 (GMT-8) (envelope-from puwen@hygon.cn) Received: from MK-FE.hygon.cn ([172.23.18.61]) by spam1.hygon.cn with ESMTP id x2MAhUlc042757; Fri, 22 Mar 2019 18:43:30 +0800 (GMT-8) (envelope-from puwen@hygon.cn) Received: from cncheex01.Hygon.cn ([172.23.18.10]) by MK-FE.hygon.cn with ESMTP id x2MAhQGF046559; Fri, 22 Mar 2019 18:43:26 +0800 (GMT-8) (envelope-from puwen@hygon.cn) Received: from pw-vbox.hygon.cn (172.23.18.44) by cncheex01.Hygon.cn (172.23.18.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1466.3; Fri, 22 Mar 2019 18:43:26 +0800 From: Pu Wen To: , , , , CC: , Pu Wen Subject: [RFC PATCH] x86/cpu/hygon: Fix phys_proc_id calculation logic for multi-die processor Date: Fri, 22 Mar 2019 18:43:00 +0800 Message-ID: <1553251380-7015-1-git-send-email-puwen@hygon.cn> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.23.18.44] X-ClientProxiedBy: cncheex01.Hygon.cn (172.23.18.10) To cncheex01.Hygon.cn (172.23.18.10) X-MAIL: spam1.hygon.cn x2MAhUlc042757 X-DNSRBL: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For Hygon family 18h multi-die processor platform, which support 1-Die/ 2-Die/4-Die per socket, the system view is shown in the following system topology. System View (with 1-Die 2-Socket): |------------| ------ ----- SOCKET0 | D0 | | D1 | SOCKET1 ------ ----- System View (with 2-Die 2-socket): -------------------- | -------------|------ | | | | ------------ ------------ SOCKET0 | D1 -- D0 | | D3 -- D2 | SOCKET1 ------------ ------------ System View (with 4-Die 2-Socket) : -------------------- | -------------|------ | | | | ------------ ------------ | D1 -- D0 | | D7 -- D6 | | | \/ | | | | \/ | | SOCKET0 | | /\ | | | | /\ | | SOCKET1 | D2 -- D3 | | D4 -- D5 | ------------ ------------ | | | | ------|------------| | -------------------- Current codes direct use "phys_proc_id = initial_apicid >> bits", which calc phys_proc_id from initial_apicid by shifting *bits*, will get wrong phys_proc_id for Hygon family 18h 1-Die/2-Die 2-socket system. According to document [1] section 2.1.11.1, the *bits* is the value of CPUID_Fn80000008_ECX[12:15]. The value may be 4, 5 or 6. The definitions are: 4 - 1 die, 5 - 2 die, 6 - 3/4 die. ApicId definition is as below (see section 2.1.10.2.1.3 of [1]): ------------------------------------------------- Bit | 6 | 5 4 | 3 | 2 1 0 | |-----------|---------|--------|----------------| IDs | Socket ID | Node ID | CCX ID | Core/Thread ID | ------------------------------------------------- So for 3/4-Die CPU the *bits* is 6, which is same to ApicID definition field, which still can get correct socket ID for 2-socket system. But for 1-Die or 2-Die CPU the *bits* is 4 or 5, which will cause the right shifted result is not exactly the value of socket ID. For Hygon family 18h CPU the socket ID should be obtained from ApicId[6]. To fix the problem and match ApicID field definition, adjust the shift bits to 6 for all Hygon family 18h multi-die CPUs. Reference: [1] https://www.amd.com/system/files/TechDocs/54945_PPR_Family_17h_Models_00h-0Fh.pdf Signed-off-by: Pu Wen --- arch/x86/kernel/cpu/hygon.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/x86/kernel/cpu/hygon.c b/arch/x86/kernel/cpu/hygon.c index cf25405..2df6dd9 100644 --- a/arch/x86/kernel/cpu/hygon.c +++ b/arch/x86/kernel/cpu/hygon.c @@ -87,6 +87,9 @@ static void hygon_get_topology(struct cpuinfo_x86 *c) if (!err) c->x86_coreid_bits = get_count_order(c->x86_max_cores); + /* Socket ID is ApicId[6] for these processors. */ + c->phys_proc_id = c->apicid >> 6; + cacheinfo_hygon_init_llc_id(c, cpu, node_id); } else if (cpu_has(c, X86_FEATURE_NODEID_MSR)) { u64 value; -- 2.7.4