Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp804120img; Fri, 22 Mar 2019 08:55:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqyrXFFeZvifwOH81DFBZqcPiD9WiVAPnt3v0CqLYcsujbLsbPOffoMHlv0Ymkc3zWmLB4zA X-Received: by 2002:a65:5c4b:: with SMTP id v11mr9387212pgr.411.1553270144369; Fri, 22 Mar 2019 08:55:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553270144; cv=none; d=google.com; s=arc-20160816; b=0BWeA4QvYJaT0Hx0PCrRfPPGWG3IWNwQcmODogPQGUqMZ7012I4VxNLeYIDB+hS4JQ jsRbyRhK3aVdpiKkULXV8MRm/E9CiejtOv7bb4rqCps/NcAjiMwyf43CpVsL0KjG7ir/ saswP74dYDF92kNRxqLhm7g/jxA89Hjf19DLPfesEk0BM+1O4Ku8tFtvgOj6bPKcrYd/ lOMaIQZHLZ7JbaIpwsQ4uqWMFvjYTx+ite+vnt2+eOltFL9QPZqGo093v77zLfHe/wjR tv7l1Mq5iplGLO70msd+fawF7eLDqS6vB6J8smLZNOCXjArwwIOng9vGAMD2ZsFQ5lHr 9vuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Jc4qPRnlCCGWrGsd4y+Fy2J+F4FBc7sfwpQFtcwEG6o=; b=ZgAVrK8GsdnkNpKXVsCjyg+nH0puhgCH+pf6BhSd+M0XtzfY8OQRzgKjtE8vbd9yA3 Nz6UPwP7BOfxIIIO4sFF0IfGu+wOq3oMnx6c19SOLk15yhh39pOVE8u/PxOusFYET5RL s/dhAk8QePjU3iweoWErsQ0VvDa/mZsXkJpHYi8VY0KMuCu1P4qyg4G/nqgDrXMkudfs mE4XtKR14MTr22rblnX4ynGHjGBGn8Rls6oZDjj+N1o3P2Yc5gttV84cV7+4uG9p+ISy W8wmKq6FRTxY0PtCZcP2MjOlKAWBUUExoH1NrBxltHVNENAU5PRofEYobqBn8jPNKWlC y7Ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=lZcoodbq; 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=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y18si7018650plp.357.2019.03.22.08.55.29; Fri, 22 Mar 2019 08:55:44 -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; dkim=pass header.i=@alien8.de header.s=dkim header.b=lZcoodbq; 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=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727637AbfCVPyu (ORCPT + 99 others); Fri, 22 Mar 2019 11:54:50 -0400 Received: from mail.skyhub.de ([5.9.137.197]:51046 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727169AbfCVPyu (ORCPT ); Fri, 22 Mar 2019 11:54:50 -0400 Received: from zn.tnic (p200300EC2F098000329C23FFFEA6A903.dip0.t-ipconnect.de [IPv6:2003:ec:2f09:8000:329c:23ff:fea6:a903]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 49BDE1EC09F1; Fri, 22 Mar 2019 16:54:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1553270088; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=Jc4qPRnlCCGWrGsd4y+Fy2J+F4FBc7sfwpQFtcwEG6o=; b=lZcoodbqoQwnFlJsuZR8gzk9t4X90tpI2cBR+G1dpJvVlnzrH0opozUX6TpS0f7tMTvlRl b1QC19Ki0f7Sg93ObGz2ScJp30MpL/DefDVoiQMUSQgZ8SleATjLZRmSVYH8nBKY9zHqh2 vgCFDvN5FhFKodbhEFku0yos+EJAYY8= Date: Fri, 22 Mar 2019 16:54:50 +0100 From: Borislav Petkov To: Pu Wen Cc: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH] x86/cpu/hygon: Fix phys_proc_id calculation logic for multi-die processor Message-ID: <20190322155449.GE12472@zn.tnic> References: <1553251380-7015-1-git-send-email-puwen@hygon.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1553251380-7015-1-git-send-email-puwen@hygon.cn> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 22, 2019 at 06:43:00PM +0800, Pu Wen wrote: > 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 Use proper english please - there's no "codes" > calc phys_proc_id from initial_apicid by shifting *bits*, will get ... or "calc" > 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. Sounds to me like you're programming the initial APIC ID not the same way as AMD do... > 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; That 6 is a magic number, I assume? -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.