From patchwork Thu Nov 24 12:02:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 25477 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3355389wrr; Thu, 24 Nov 2022 04:07:04 -0800 (PST) X-Google-Smtp-Source: AA0mqf7i1tK4mxYoS37rOv7LbGWTWdYxDkE8f4lVzdqF/tcHO8AdJ7nxjsAyl5sU5+mPsJaK6Y18 X-Received: by 2002:a05:6402:40c:b0:461:c894:f6b5 with SMTP id q12-20020a056402040c00b00461c894f6b5mr14159725edv.52.1669291623837; Thu, 24 Nov 2022 04:07:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669291623; cv=none; d=google.com; s=arc-20160816; b=bwH8Y/zYSfZNOcRbXqQoJ5CWBlbF0giQNjWAQD0fpeyftk8hHGANrPr5rxVojwhWsP Gx2z0i6fViei71Rmzwjz4wV7KR7ik8VfKObEBkgNkQZTvGXakHZ6fSOKEZf0OTwvDaWK S+GX1sLfV2mDm8MIGPKfnSgkINTERQqUsfhLQMUI3MxP4Pcxu54zp7z6q+bsyOh9hQcc zPKXOXVp+1DuW/N0DyEm4AJiEBh452lKY40C/OZWV+ms3SfMHx/HNwJOOo2Rm0uHK3R9 mqkc5qHaKkziPJgh+omErWZrW1oR5u0He5vNneWKhtutUr7B2QcEM20X6JgKN4JSvBbQ ri2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=gXwitGVnHQi9ZmUqlVj77DSD4Gtci8EfV/LggeUQzU0=; b=B/agoFkcZakOyOnCxr5Hii7ku/WBV+qhkY24XyoaRlnl4VjaeEXt6HV8KanHWiTmW0 5KHurxJXq22vTEsOqGG+lLlLaiI6qO9CGBmyjy54i/RTo420Oj1gba5KhWcUAeSXZBYr Zngphyk2ZGDuukmzwbx1rD0l4G3iUIWlwfhyUEKYtX3M52kAH7WXIbBeqKmzq6/TY+Hf mxiNuOSfd0T+r0bjzznxf7VAUHFRfrJB+aqVSHnsrpk74k3sEj0fbeOGQWyQGl5X1Wch VcPtU/ZAGvlBcAFJUhIO1TpDGS5oJV5vK2RHSibwD3JGWiuXjSc1xbIkolo+yQi0f7U3 eozQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=jj4vhR3w; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=MNiHTjY3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j11-20020aa7c40b000000b0046453c39abdsi783820edq.104.2022.11.24.04.06.39; Thu, 24 Nov 2022 04:07:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=jj4vhR3w; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=MNiHTjY3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229973AbiKXMDS (ORCPT + 99 others); Thu, 24 Nov 2022 07:03:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230224AbiKXMC7 (ORCPT ); Thu, 24 Nov 2022 07:02:59 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C6D4429BA; Thu, 24 Nov 2022 04:02:57 -0800 (PST) Date: Thu, 24 Nov 2022 12:02:54 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669291376; h=from:from:sender:sender:reply-to: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gXwitGVnHQi9ZmUqlVj77DSD4Gtci8EfV/LggeUQzU0=; b=jj4vhR3wO8W10nK0vToffjcizb/dOuDU3ZiSaEv4+dvwIuZ4fxWKCxywjn6KBRn/dQEwf3 FvBQYCLTJXCW8OyDArTz9x36KC5qDm4cdzqTOxkpWSp/fWWZ15PUy4hhv6/AX2ORlfptF6 6RJcG8XJ/JaBjIHTWG/+60DRK0cKx1a4Fwr/83Q5hrc0m0MNSCEIO8oXxOfx4a9TTecAkC Bi8hofqkQ0nFgA6OPRHZ+7H4n+0uSwFjBMBbgnDsTUywgwHKjl1tEIU8z+VnqJYcd920rZ GE/+GqiCHsHkDCltQ9xzAHrvEPUbHuhKVB1I7egFzMns8l9cQQmv/HBgAm01Fg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669291376; h=from:from:sender:sender:reply-to: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gXwitGVnHQi9ZmUqlVj77DSD4Gtci8EfV/LggeUQzU0=; b=MNiHTjY3xLbVmKLchGODcSt4sAzwPJ7eauASKkoNSEm+WUkXxbJUmPOEg7xqVAJjOm4DNQ QZIVRJFnvuVxvOAw== From: "tip-bot2 for Alexander Antonov" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/core] perf/x86/intel/uncore: Get UPI NodeID and GroupID Cc: Alexander Antonov , "Peter Zijlstra (Intel)" , Kan Liang , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20221117122833.3103580-8-alexander.antonov@linux.intel.com> References: <20221117122833.3103580-8-alexander.antonov@linux.intel.com> MIME-Version: 1.0 Message-ID: <166929137480.4906.2483450142908065340.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749746668109362619?= X-GMAIL-MSGID: =?utf-8?q?1750379133558748088?= The following commit has been merged into the perf/core branch of tip: Commit-ID: c4aebdb3b5f50fd0d83bf0fc2d49ac299f8b61df Gitweb: https://git.kernel.org/tip/c4aebdb3b5f50fd0d83bf0fc2d49ac299f8b61df Author: Alexander Antonov AuthorDate: Thu, 17 Nov 2022 12:28:29 Committer: Peter Zijlstra CommitterDate: Thu, 24 Nov 2022 11:09:22 +01:00 perf/x86/intel/uncore: Get UPI NodeID and GroupID The GIDNIDMAP register of UBOX device is used to get the topology information in the snbep_pci2phy_map_init(). The same approach will be used to discover UPI topology for ICX and SPR platforms. Move common code that will be reused in next patches. Signed-off-by: Alexander Antonov Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Kan Liang Link: https://lore.kernel.org/r/20221117122833.3103580-8-alexander.antonov@linux.intel.com --- arch/x86/events/intel/uncore_snbep.c | 33 ++++++++++++++++++++------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c index f682a9a..6da5f69 100644 --- a/arch/x86/events/intel/uncore_snbep.c +++ b/arch/x86/events/intel/uncore_snbep.c @@ -1372,6 +1372,28 @@ static struct pci_driver snbep_uncore_pci_driver = { #define NODE_ID_MASK 0x7 +/* Each three bits from 0 to 23 of GIDNIDMAP register correspond Node ID. */ +#define GIDNIDMAP(config, id) (((config) >> (3 * (id))) & 0x7) + +static int upi_nodeid_groupid(struct pci_dev *ubox_dev, int nodeid_loc, int idmap_loc, + int *nodeid, int *groupid) +{ + int ret; + + /* get the Node ID of the local register */ + ret = pci_read_config_dword(ubox_dev, nodeid_loc, nodeid); + if (ret) + goto err; + + *nodeid = *nodeid & NODE_ID_MASK; + /* get the Node ID mapping */ + ret = pci_read_config_dword(ubox_dev, idmap_loc, groupid); + if (ret) + goto err; +err: + return ret; +} + /* * build pci bus to socket mapping */ @@ -1397,13 +1419,8 @@ static int snbep_pci2phy_map_init(int devid, int nodeid_loc, int idmap_loc, bool * the topology. */ if (nr_node_ids <= 8) { - /* get the Node ID of the local register */ - err = pci_read_config_dword(ubox_dev, nodeid_loc, &config); - if (err) - break; - nodeid = config & NODE_ID_MASK; - /* get the Node ID mapping */ - err = pci_read_config_dword(ubox_dev, idmap_loc, &config); + err = upi_nodeid_groupid(ubox_dev, nodeid_loc, idmap_loc, + &nodeid, &config); if (err) break; @@ -1421,7 +1438,7 @@ static int snbep_pci2phy_map_init(int devid, int nodeid_loc, int idmap_loc, bool * to a particular node. */ for (i = 0; i < 8; i++) { - if (nodeid == ((config >> (3 * i)) & 0x7)) { + if (nodeid == GIDNIDMAP(config, i)) { if (topology_max_die_per_package() > 1) die_id = i; else