From patchwork Thu Nov 24 12:02:53 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: 25478 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3355390wrr; Thu, 24 Nov 2022 04:07:04 -0800 (PST) X-Google-Smtp-Source: AA0mqf76lnzN6WH4EMELWIqWxLjV3a36QZhwYZt3zH1WRVF5a++PSGfL4wISegZ2MysUV/Z2nywE X-Received: by 2002:a05:6402:114f:b0:462:1e07:1dd7 with SMTP id g15-20020a056402114f00b004621e071dd7mr30188060edw.293.1669291622735; Thu, 24 Nov 2022 04:07:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669291622; cv=none; d=google.com; s=arc-20160816; b=Iap2dvxMjFmMZeuxfU2Yl1NFadEHZfHuf52OTGjRJVQKuEklrQcFIIfR0yFqPrp4H4 FIAhmKGSigBt0fg1+g5DmvMOBwzgurLLDRGGYP7PlEu3YnapCjkh7vxboTO8/q6gMie4 G5Cm7/QxVj4lKuvyxvsnDR93+qhAJ3gDIolqr5U371x0MAgCVmuqr9RX7Xi0LNL9Xsjm ook0tZjLPQzx2ESAQ2YF1Hsatyju4PW/tECCV5hgmVVIaTb3fESxU3E1DV98iwc2ho4o u5U8dltiTd0yATW9tfRckxhltuPChxMdcBeWq0YFvz41uEM3688jLNukkEGJAmE+oiTW LxtQ== 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=kahsRHtayEqdmhARsEXDF6RBu6DXaA/SwKuAQAa7cl8=; b=f8FItPwFuW/i1IiRbNRXARfpi1pqHdlRiOyeIbJ5AYFAL3tGBZB9bgG9KjyyHXXyNZ NOeWdCzLq0QWjhZAtNMPTeVfBGNd9w7iLIWw1EPUIoDk1HAC6O8NbOoWJQFPVMyuuYud R+mFKvCvwEDkSfbENCHc4PeAL9r+4gE3FzDLh/uJJZRgY5OlMEfc842mrvD/zlCNYkUg CslkR2se1xWVpEaIj3UWIzgNN7RKyV4v0WH1h8c/hf6aJ85oaHzZDm3lFBRpFbnPnK+P yzzW3gQOO7ZHKH1HYOcI/waZODmAd+MwMsk9xRyYOi0jQO25YE5+BzDi4WQUpJ+yPvRF SlHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=lO72XljR; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 v19-20020a056402349300b004573107a5basi992541edc.352.2022.11.24.04.06.38; Thu, 24 Nov 2022 04:07:02 -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=lO72XljR; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S230293AbiKXMDP (ORCPT + 99 others); Thu, 24 Nov 2022 07:03:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230232AbiKXMC6 (ORCPT ); Thu, 24 Nov 2022 07:02:58 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65C315132E; Thu, 24 Nov 2022 04:02:56 -0800 (PST) Date: Thu, 24 Nov 2022 12:02:53 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669291375; 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=kahsRHtayEqdmhARsEXDF6RBu6DXaA/SwKuAQAa7cl8=; b=lO72XljRwDZ1xu7Jcz3rHZaROcSHqCZOm0RuZZPdgAPJKxOV8bRaWOEkauIUpBNyDJ1cJR ldzF04dlW0KQd7cXURXXYtyyWatA0bM+0pVEEh5nKoBQ1hw7nmRSwnKY+MbXWGFz1T9WYG aefcZ8JTaw7hZ4YZkqHWi/m98npNM2TxSq/C8mwD0ZIVjiXxrmaWD70GtasI/W5nNSu5xt EBbTU0WzkHphQm2ZDxtLqnd14og6sWtT0xCGaw2ib2JvL+rrAEEoal0e9XN7Toelbh+Jk1 jp4UenxDGYSU2vdPOqnLAHvpnWXITAK2a15t6fCG8AlQMGi+rr6q1L9YfOrN/Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669291375; 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=kahsRHtayEqdmhARsEXDF6RBu6DXaA/SwKuAQAa7cl8=; b=bDamBATxax6Zn6TvTth9Ydqk9QFpue/hTxTpgiaAqrUISW8hPWn/fJwC5XuiKrgjj23oFJ HNg3ZWI5jaYaP2Cw== 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: Enable UPI topology discovery for Icelake Server Cc: Alexander Antonov , "Peter Zijlstra (Intel)" , Kan Liang , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20221117122833.3103580-9-alexander.antonov@linux.intel.com> References: <20221117122833.3103580-9-alexander.antonov@linux.intel.com> MIME-Version: 1.0 Message-ID: <166929137372.4906.12604606874999833404.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?1749746644370900794?= X-GMAIL-MSGID: =?utf-8?q?1750379132361753814?= The following commit has been merged into the perf/core branch of tip: Commit-ID: f680b6e6062ef3c944ffc966d685f067958fca33 Gitweb: https://git.kernel.org/tip/f680b6e6062ef3c944ffc966d685f067958fca33 Author: Alexander Antonov AuthorDate: Thu, 17 Nov 2022 12:28:30 Committer: Peter Zijlstra CommitterDate: Thu, 24 Nov 2022 11:09:23 +01:00 perf/x86/intel/uncore: Enable UPI topology discovery for Icelake Server UPI topology discovery relies on data from KTILP0 (offset 0x94) and KTIPCSTS (offset 0x120) as well as on SKX but on Icelake Server these registers reside under UBOX (Device ID 0x3450) bus. This patch enables /sys/devices/uncore_upi_*/die* attributes on Icelake Server. Signed-off-by: Alexander Antonov Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Kan Liang Link: https://lore.kernel.org/r/20221117122833.3103580-9-alexander.antonov@linux.intel.com --- arch/x86/events/intel/uncore_snbep.c | 75 +++++++++++++++++++++++++++- 1 file changed, 75 insertions(+) diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c index 6da5f69..d45f584 100644 --- a/arch/x86/events/intel/uncore_snbep.c +++ b/arch/x86/events/intel/uncore_snbep.c @@ -445,6 +445,7 @@ #define ICX_UPI_PCI_PMON_CTR0 0x320 #define ICX_UPI_PCI_PMON_BOX_CTL 0x318 #define ICX_UPI_CTL_UMASK_EXT 0xffffff +#define ICX_UBOX_DID 0x3450 /* ICX M3UPI*/ #define ICX_M3UPI_PCI_PMON_CTL0 0xd8 @@ -5594,6 +5595,76 @@ static const struct attribute_group icx_upi_uncore_format_group = { .attrs = icx_upi_uncore_formats_attr, }; +#define ICX_UPI_REGS_ADDR_DEVICE_LINK0 0x02 +#define ICX_UPI_REGS_ADDR_FUNCTION 0x01 + +static int discover_upi_topology(struct intel_uncore_type *type, int ubox_did, int dev_link0) +{ + struct pci_dev *ubox = NULL; + struct pci_dev *dev = NULL; + u32 nid, gid; + int i, idx, ret = -EPERM; + struct intel_uncore_topology *upi; + unsigned int devfn; + + /* GIDNIDMAP method supports machines which have less than 8 sockets. */ + if (uncore_max_dies() > 8) + goto err; + + while ((ubox = pci_get_device(PCI_VENDOR_ID_INTEL, ubox_did, ubox))) { + ret = upi_nodeid_groupid(ubox, SKX_CPUNODEID, SKX_GIDNIDMAP, &nid, &gid); + if (ret) { + ret = pcibios_err_to_errno(ret); + break; + } + + for (i = 0; i < 8; i++) { + if (nid != GIDNIDMAP(gid, i)) + continue; + for (idx = 0; idx < type->num_boxes; idx++) { + upi = &type->topology[nid][idx]; + devfn = PCI_DEVFN(dev_link0 + idx, ICX_UPI_REGS_ADDR_FUNCTION); + dev = pci_get_domain_bus_and_slot(pci_domain_nr(ubox->bus), + ubox->bus->number, + devfn); + if (dev) { + ret = upi_fill_topology(dev, upi, idx); + if (ret) + goto err; + } + } + } + } +err: + pci_dev_put(ubox); + pci_dev_put(dev); + return ret; +} + +static int icx_upi_get_topology(struct intel_uncore_type *type) +{ + return discover_upi_topology(type, ICX_UBOX_DID, ICX_UPI_REGS_ADDR_DEVICE_LINK0); +} + +static struct attribute_group icx_upi_mapping_group = { + .is_visible = skx_upi_mapping_visible, +}; + +static const struct attribute_group *icx_upi_attr_update[] = { + &icx_upi_mapping_group, + NULL +}; + +static int icx_upi_set_mapping(struct intel_uncore_type *type) +{ + return pmu_upi_set_mapping(type, &icx_upi_mapping_group); +} + +static void icx_upi_cleanup_mapping(struct intel_uncore_type *type) +{ + pmu_cleanup_mapping(type, &icx_upi_mapping_group); +} + static struct intel_uncore_type icx_uncore_upi = { .name = "upi", .num_counters = 4, @@ -5606,6 +5677,10 @@ static struct intel_uncore_type icx_uncore_upi = { .box_ctl = ICX_UPI_PCI_PMON_BOX_CTL, .ops = &skx_upi_uncore_pci_ops, .format_group = &icx_upi_uncore_format_group, + .attr_update = icx_upi_attr_update, + .get_topology = icx_upi_get_topology, + .set_mapping = icx_upi_set_mapping, + .cleanup_mapping = icx_upi_cleanup_mapping, }; static struct event_constraint icx_uncore_m3upi_constraints[] = {