From patchwork Mon Oct 2 15:03:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liang, Kan" X-Patchwork-Id: 147354 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1526006vqb; Mon, 2 Oct 2023 09:04:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEu4VDE++3uF5tB709SXa0TTvhcKKdxaYjhmbyhFWcIQ7y34cFiq66/mVGdnI1I1q2uHMh5 X-Received: by 2002:a17:902:cec3:b0:1bd:a22a:d409 with SMTP id d3-20020a170902cec300b001bda22ad409mr11955779plg.40.1696262651546; Mon, 02 Oct 2023 09:04:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696262651; cv=none; d=google.com; s=arc-20160816; b=ON+eVTY1P/3RlR9nSu74friEKch7t7jHhal3VEegpNxruJDfsivuisaYjsGQ+u2doa YkDNxKHLVe+x53Q3ndSWDtwnfV682nAyvkCsebo19+0LYzfA7kq0DUCCZYDCyfOf47FD LZU/1mMQ+gTpmEFcwjyhNhpVY6Jn2ZVq4GWTOeIwEKTNoaJkhGWRtnL+cgX4M5nEiWxZ v/EDIFwtVDCzZmxK08Q+vTArFIxDu3cQtuU5QLP24G7L6GM+Jvt3uIqB+bYmI2Q6j17m 5zEJ0dBYLnMdnzvSoXMZJZlo9XFWbgQAz7tbZB54ZGYMQBAsAF01KsW0Zxl3hUbSs3kd soWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=NH7NZvN3O4rnrqn74nsWeRQ+rcvRo8iHzuNHCqoaoMo=; fh=XOkOKN9ZbC1Zh3rfeAvxUpgU00NM1ZcWi06LZ96oE2g=; b=qvyWS1uZB8NFEcv5Kzggz4iULooj+uVCxO+3o/JgI/Lyl0c02cxt92HBZZAr+OjX+j TONtPzS/k3jMClkowfMgCYGRwlDEAtGBG2OnZQ7YocbqchXeDZHTxXEJC8qGrwX0ooU5 N5YsEkwUGpTz4WyYcKccs5cok5/0rokf7nAITbN+AXlKddo+OTSMTqCFFAxT3xE07T06 1w8hSxAzCQHEuZY93Fj99x/i1C7iSmX0+uiBNY95fBpPFzu69HUw6jfg9ZajlJJvk3Be O0yoprk9o+AHBs6Qco5ggjLOOrclMAgaJWwI1OG2kTY9RqlTB8GBCXjHA1SncYdrjoLd K3nQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IkYBynFM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id b14-20020a170902650e00b001c61bd7cee0si18511828plk.211.2023.10.02.09.04.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 09:04:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IkYBynFM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 5A35F8025442; Mon, 2 Oct 2023 08:03:42 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237940AbjJBPD0 (ORCPT + 18 others); Mon, 2 Oct 2023 11:03:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237934AbjJBPDZ (ORCPT ); Mon, 2 Oct 2023 11:03:25 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8213FAC for ; Mon, 2 Oct 2023 08:03:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696259002; x=1727795002; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=b81D1JINHi5ibUTtiEbFI9DrxQMJ+q3uFxu+iVHcAlI=; b=IkYBynFMHZPtgFbRc3Im95Oy6RPvwMzrn67pfNzlY5S/7mYkjRkqIYKQ k8mCV/6nVJgk0l9ZMCupJFjRz09B1dMtL7CTKm81+sXcxSiE0p3rjTy/7 K4SXTfYFy+jXnhA80jVD3YQzgljHLZI/cQ18ZfhVjXI6SKPwaJtnUFu4e KOVNV3CHZGmqOE1nZfqK5F/xmSrw00xFB79FwPZMdCJQ44WRnSIDh6oqx 4YJ9LMq+2AOkhWFZ46HDNpFzojEvzS/ty514NCBUkBTLdis2qWkSSPzYI aF8Kk1NQOGrpuxj5k1uX3yze7usTpYtKiVW/TLrosFIZhB0fJMFPT+Pgm w==; X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="362033035" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="362033035" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Oct 2023 08:03:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="820904658" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="820904658" Received: from kanliang-dev.jf.intel.com ([10.165.154.102]) by fmsmga004.fm.intel.com with ESMTP; 02 Oct 2023 08:03:19 -0700 From: kan.liang@linux.intel.com To: peterz@infradead.org, mingo@redhat.com, linux-kernel@vger.kernel.org Cc: eranian@google.com, ak@linux.intel.com, Kan Liang Subject: [PATCH 1/5] perf/x86/intel/uncore: Generic uncore_get_uncores and MMIO format of SPR Date: Mon, 2 Oct 2023 08:03:21 -0700 Message-Id: <20231002150325.2025749-1-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 02 Oct 2023 08:03:42 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778660305993012665 X-GMAIL-MSGID: 1778660305993012665 From: Kan Liang Factor out SPR_UNCORE_MMIO_COMMON_FORMAT which can be reused by Granite Rapids in the following patch. Granite Rapids have more uncore units than Sapphire Rapids. Add new parameters to support adjustable uncore units. No functional change. Signed-off-by: Kan Liang --- arch/x86/events/intel/uncore_snbep.c | 34 +++++++++++++++++++--------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c index d49e90dc04a4..cef51b83410a 100644 --- a/arch/x86/events/intel/uncore_snbep.c +++ b/arch/x86/events/intel/uncore_snbep.c @@ -6079,13 +6079,16 @@ static struct uncore_event_desc spr_uncore_imc_events[] = { { /* end: all zeroes */ }, }; +#define SPR_UNCORE_MMIO_COMMON_FORMAT() \ + SPR_UNCORE_COMMON_FORMAT(), \ + .ops = &spr_uncore_mmio_ops + static struct intel_uncore_type spr_uncore_imc = { - SPR_UNCORE_COMMON_FORMAT(), + SPR_UNCORE_MMIO_COMMON_FORMAT(), .name = "imc", .fixed_ctr_bits = 48, .fixed_ctr = SNR_IMC_MMIO_PMON_FIXED_CTR, .fixed_ctl = SNR_IMC_MMIO_PMON_FIXED_CTL, - .ops = &spr_uncore_mmio_ops, .event_descs = spr_uncore_imc_events, }; @@ -6412,7 +6415,8 @@ static void uncore_type_customized_copy(struct intel_uncore_type *to_type, static struct intel_uncore_type ** uncore_get_uncores(enum uncore_access_type type_id, int num_extra, - struct intel_uncore_type **extra) + struct intel_uncore_type **extra, int max_num_types, + struct intel_uncore_type **uncores) { struct intel_uncore_type **types, **start_types; int i; @@ -6421,9 +6425,9 @@ uncore_get_uncores(enum uncore_access_type type_id, int num_extra, /* Only copy the customized features */ for (; *types; types++) { - if ((*types)->type_id >= UNCORE_SPR_NUM_UNCORE_TYPES) + if ((*types)->type_id >= max_num_types) continue; - uncore_type_customized_copy(*types, spr_uncores[(*types)->type_id]); + uncore_type_customized_copy(*types, uncores[(*types)->type_id]); } for (i = 0; i < num_extra; i++, types++) @@ -6470,7 +6474,9 @@ void spr_uncore_cpu_init(void) uncore_msr_uncores = uncore_get_uncores(UNCORE_ACCESS_MSR, UNCORE_SPR_MSR_EXTRA_UNCORES, - spr_msr_uncores); + spr_msr_uncores, + UNCORE_SPR_NUM_UNCORE_TYPES, + spr_uncores); type = uncore_find_type_by_id(uncore_msr_uncores, UNCORE_SPR_CHA); if (type) { @@ -6542,7 +6548,9 @@ int spr_uncore_pci_init(void) spr_update_device_location(UNCORE_SPR_M3UPI); uncore_pci_uncores = uncore_get_uncores(UNCORE_ACCESS_PCI, UNCORE_SPR_PCI_EXTRA_UNCORES, - spr_pci_uncores); + spr_pci_uncores, + UNCORE_SPR_NUM_UNCORE_TYPES, + spr_uncores); return 0; } @@ -6550,12 +6558,16 @@ void spr_uncore_mmio_init(void) { int ret = snbep_pci2phy_map_init(0x3250, SKX_CPUNODEID, SKX_GIDNIDMAP, true); - if (ret) - uncore_mmio_uncores = uncore_get_uncores(UNCORE_ACCESS_MMIO, 0, NULL); - else { + if (ret) { + uncore_mmio_uncores = uncore_get_uncores(UNCORE_ACCESS_MMIO, 0, NULL, + UNCORE_SPR_NUM_UNCORE_TYPES, + spr_uncores); + } else { uncore_mmio_uncores = uncore_get_uncores(UNCORE_ACCESS_MMIO, UNCORE_SPR_MMIO_EXTRA_UNCORES, - spr_mmio_uncores); + spr_mmio_uncores, + UNCORE_SPR_NUM_UNCORE_TYPES, + spr_uncores); spr_uncore_imc_free_running.num_boxes = uncore_type_max_boxes(uncore_mmio_uncores, UNCORE_SPR_IMC) / 2; } From patchwork Mon Oct 2 15:03:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liang, Kan" X-Patchwork-Id: 147407 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1596365vqb; Mon, 2 Oct 2023 11:00:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE01/6WycnxlpVKRYgY19wgxu8eAnTjR7bpMFK2Q16GlezJe3vEJTUtcieVp9zbXW9BQOqu X-Received: by 2002:a05:6a20:5607:b0:157:eb32:e739 with SMTP id ir7-20020a056a20560700b00157eb32e739mr11815857pzc.32.1696269623545; Mon, 02 Oct 2023 11:00:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696269623; cv=none; d=google.com; s=arc-20160816; b=BSNRUCLz07OxcfcRrA2Fhj+WRiOcZRPpJZInnx7cGeryqYTozYePd0OR26v+pogewe bkQOT0yZdd6SnR5NTbo8Q5oFp2tVjb4l+XCXkoPt8Cid98F1YQ6LNo+cy5xycYyJk1V7 YfZk93YqIX6MbNxZRB8RLll5sYG2MINGMKQ2spYipw3ru7u0huhRrmfHsqoVPo/OBGNv qk8oB95PeYLM7gfdvgIOgjEQr9afZOllvdf7kvT102okqy+n21KMBacViw46fdarMbyV t36hCdcEMSHHqKTLIe7PyJTmp1dgFuqcQpAaTbL8S5RnrnMkakk6k2OOHZxo11pst1VI upJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=v1aca+xhntOLxXdhcoXHLSLClMDHVlBoKnkZKcEkykc=; fh=XOkOKN9ZbC1Zh3rfeAvxUpgU00NM1ZcWi06LZ96oE2g=; b=FUyq+XusgtCiSY6OSPr0pUUlHZHRuSFAfk0L0jBvpMfIEPBNjaZup6yKMVmvUaw1UT /dcsQeacPcX9uzKOXfesygzLoRzSslZazJa7pQM75GCO+c2my5Nnz2GGIIIoBqqAVZCe i7ghswhYTf+IYGHk7sAxkG1RZea0vUwCboIUTT+J5kKiPfyEWJJJP0P9AkQyTrLxjdFG n7PWo34awrT27CAlxJrPi0FZ/qwSmGrhtP8IKFh/g2R7cheKKPvuQDBWXxSmBzoovzyo 9i8V3Dg+U0PUznRZLbAPdlZFqyGSXmoy3zvD1XMz5NgIa7y06B7eHWQOaDQ5Xln49re+ w7gQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MHrDoyt5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id h9-20020a056a00230900b0068fba70d25dsi29889210pfh.33.2023.10.02.11.00.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 11:00:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MHrDoyt5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 9786F802581D; Mon, 2 Oct 2023 08:03:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237946AbjJBPD2 (ORCPT + 18 others); Mon, 2 Oct 2023 11:03:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237933AbjJBPDY (ORCPT ); Mon, 2 Oct 2023 11:03:24 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 213749D for ; Mon, 2 Oct 2023 08:03:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696259001; x=1727795001; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=N++j3DS1/2axXzEV8F4CEyXci3t830vsxt/HcEcmtvc=; b=MHrDoyt5Oi+WKiizvJJeddDfmJEKe1hJHJXDBNPXJDv8xs30Zm1xifKs FxzzlO38n4JBw8UAOylqrt2Dpz8ptz7O8X1nZEUM4VepxUSk1k06gUvIE 15+25NkD2KInQx3y96FSVgqgEVdOx30bFfB/sCaim4ZoXxeq7WDtYQJLV 9Y48h/SsXzNnkIqcRP4f0xiszGWos3a8wHyjwLGZ2lQhqUT6GSPRmrzOb ormiGczqBx4KSswB0i+acWOTuU9On89rF8n0rlddDT/jQPbiLtoMqDZgN QE+RakfMwEFvqXFIndlEiaKoeH7qGs124Bspsaxoz+DtALOX26h6JRUap Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="362033039" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="362033039" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Oct 2023 08:03:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="820904659" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="820904659" Received: from kanliang-dev.jf.intel.com ([10.165.154.102]) by fmsmga004.fm.intel.com with ESMTP; 02 Oct 2023 08:03:19 -0700 From: kan.liang@linux.intel.com To: peterz@infradead.org, mingo@redhat.com, linux-kernel@vger.kernel.org Cc: eranian@google.com, ak@linux.intel.com, Kan Liang Subject: [PATCH 2/5] perf/x86/uncore: Use u64 to replace unsigned for the uncore offsets array Date: Mon, 2 Oct 2023 08:03:22 -0700 Message-Id: <20231002150325.2025749-2-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20231002150325.2025749-1-kan.liang@linux.intel.com> References: <20231002150325.2025749-1-kan.liang@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 02 Oct 2023 08:03:35 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778667616832256403 X-GMAIL-MSGID: 1778667616832256403 From: Kan Liang The current perf doesn't save the complete address of an uncore unit. The complete address of each unit is calculated by the base address + offset. The type of the base address is u64, while the type of offset is unsigned. In the old platforms (without the discovery table method), the base address and offset are hard coded in the driver. Perf can always use the lowest address as the base address. Everything works well. In the new platforms (starting from SPR), the discovery table provides a complete address for all uncore units. To follow the current framework/codes, when parsing the discovery table, the complete address of the first box is stored as a base address. The offset of the following units is calculated by the complete address of the unit minus the base address (the address of the first unit). On GNR, the latter units may have a lower address compared to the first unit. So the offset is a negative value. The upper 32 bits are lost when casting a negative u64 to an unsigned type. Use u64 to replace unsigned for the uncore offsets array to correct the above case. There is no functional change. Signed-off-by: Kan Liang --- arch/x86/events/intel/uncore.h | 6 +++--- arch/x86/events/intel/uncore_discovery.c | 5 +++-- arch/x86/events/intel/uncore_discovery.h | 2 +- arch/x86/events/intel/uncore_nhmex.c | 2 +- arch/x86/events/intel/uncore_snbep.c | 6 +++--- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/arch/x86/events/intel/uncore.h b/arch/x86/events/intel/uncore.h index c30fb5bb1222..7428ecaddf72 100644 --- a/arch/x86/events/intel/uncore.h +++ b/arch/x86/events/intel/uncore.h @@ -72,9 +72,9 @@ struct intel_uncore_type { unsigned single_fixed:1; unsigned pair_ctr_ctl:1; union { - unsigned *msr_offsets; - unsigned *pci_offsets; - unsigned *mmio_offsets; + u64 *msr_offsets; + u64 *pci_offsets; + u64 *mmio_offsets; }; unsigned *box_ids; struct event_constraint unconstrainted; diff --git a/arch/x86/events/intel/uncore_discovery.c b/arch/x86/events/intel/uncore_discovery.c index cb488e41807c..9a698a92962a 100644 --- a/arch/x86/events/intel/uncore_discovery.c +++ b/arch/x86/events/intel/uncore_discovery.c @@ -125,7 +125,8 @@ uncore_insert_box_info(struct uncore_unit_discovery *unit, int die, bool parsed) { struct intel_uncore_discovery_type *type; - unsigned int *box_offset, *ids; + unsigned int *ids; + u64 *box_offset; int i; if (!unit->ctl || !unit->ctl_offset || !unit->ctr_offset) { @@ -153,7 +154,7 @@ uncore_insert_box_info(struct uncore_unit_discovery *unit, if (!type) return; - box_offset = kcalloc(type->num_boxes + 1, sizeof(unsigned int), GFP_KERNEL); + box_offset = kcalloc(type->num_boxes + 1, sizeof(u64), GFP_KERNEL); if (!box_offset) return; diff --git a/arch/x86/events/intel/uncore_discovery.h b/arch/x86/events/intel/uncore_discovery.h index 6ee80ad3423e..22e769a81103 100644 --- a/arch/x86/events/intel/uncore_discovery.h +++ b/arch/x86/events/intel/uncore_discovery.h @@ -125,7 +125,7 @@ struct intel_uncore_discovery_type { u8 ctr_offset; /* Counter 0 offset */ u16 num_boxes; /* number of boxes for the uncore block */ unsigned int *ids; /* Box IDs */ - unsigned int *box_offset; /* Box offset */ + u64 *box_offset; /* Box offset */ }; bool intel_uncore_has_discovery_tables(int *ignore); diff --git a/arch/x86/events/intel/uncore_nhmex.c b/arch/x86/events/intel/uncore_nhmex.c index 173e2674be6e..56eea2c66cfb 100644 --- a/arch/x86/events/intel/uncore_nhmex.c +++ b/arch/x86/events/intel/uncore_nhmex.c @@ -306,7 +306,7 @@ static const struct attribute_group nhmex_uncore_cbox_format_group = { }; /* msr offset for each instance of cbox */ -static unsigned nhmex_cbox_msr_offsets[] = { +static u64 nhmex_cbox_msr_offsets[] = { 0x0, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x240, 0x2c0, }; diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c index cef51b83410a..dfe4a84f25c6 100644 --- a/arch/x86/events/intel/uncore_snbep.c +++ b/arch/x86/events/intel/uncore_snbep.c @@ -5278,7 +5278,7 @@ void snr_uncore_mmio_init(void) /* ICX uncore support */ -static unsigned icx_cha_msr_offsets[] = { +static u64 icx_cha_msr_offsets[] = { 0x2a0, 0x2ae, 0x2bc, 0x2ca, 0x2d8, 0x2e6, 0x2f4, 0x302, 0x310, 0x31e, 0x32c, 0x33a, 0x348, 0x356, 0x364, 0x372, 0x380, 0x38e, 0x3aa, 0x3b8, 0x3c6, 0x3d4, 0x3e2, 0x3f0, 0x3fe, 0x40c, 0x41a, @@ -5326,7 +5326,7 @@ static struct intel_uncore_type icx_uncore_chabox = { .format_group = &snr_uncore_chabox_format_group, }; -static unsigned icx_msr_offsets[] = { +static u64 icx_msr_offsets[] = { 0x0, 0x20, 0x40, 0x90, 0xb0, 0xd0, }; @@ -6184,7 +6184,7 @@ static struct intel_uncore_type *spr_uncores[UNCORE_SPR_NUM_UNCORE_TYPES] = { */ #define SPR_UNCORE_UPI_NUM_BOXES 4 -static unsigned int spr_upi_pci_offsets[SPR_UNCORE_UPI_NUM_BOXES] = { +static u64 spr_upi_pci_offsets[SPR_UNCORE_UPI_NUM_BOXES] = { 0, 0x8000, 0x10000, 0x18000 }; From patchwork Mon Oct 2 15:03:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liang, Kan" X-Patchwork-Id: 147531 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1725614vqb; Mon, 2 Oct 2023 15:25:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEhOXVOxK2/3jz1FfJ1d3m8UDfCr9/JsQ9bgYriB00HYW97Q7VzaN/QOdKU7G0XT9bcRpsH X-Received: by 2002:a05:6a00:24c5:b0:690:ca4e:662f with SMTP id d5-20020a056a0024c500b00690ca4e662fmr13062022pfv.5.1696285556042; Mon, 02 Oct 2023 15:25:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696285556; cv=none; d=google.com; s=arc-20160816; b=RN5rHWMigj+9SbcPXRBHOGlfKIg9SohyOaDWQiflkV9FfASlm6YgUClDRU5IjXnD7E 0qMDhuwRAkx3ywOeMz97uiDe/Zxi7W/pTXv62JXZAGpx1jxA67eT18xhTaUo5R2H9CVU pd6OEOJQBrQVf1XhAc3LWaR3oBMVi0gyaCkJV9Hnbk1s2pGCMqVGWXIKptULXSYk/evE 1sPZ9+y19I20Cxd6EpmWB+5w2r5j1OJG1Y5bhH+VBp0AWKJTxABNkyj1PvsZWJeLCeUK udPTCBzaPrV2zpyw9u7G9mgzH0wWQZNoQMzyCn/+LeY8kW8vlsyrSfj3ZisIz7GUy+mq Fl5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6GX7AdDlmKXov+baUVmclUx0GGTeNWQiMkBImOnGSKs=; fh=XOkOKN9ZbC1Zh3rfeAvxUpgU00NM1ZcWi06LZ96oE2g=; b=wz8JXb+lbQwSpPU/9hJLBYZYnRYXfkwn/gjljoNNUa9gbg4vlN4gr1E8n8McqeV6jE JdsEM7paY3EWt/jlYMhZGaYsNQrX0YezJWFuLiqMGMp506KEGSIVnOyyOMXIYPVE3N6y fpzGCHnpSxoLSEtN4vPXrZbchwoR1c9Xc29cqqKnISaMZ3P4N68vvJHpnm2OG/XDpzCe HIgUpvm0Q48spcfQjm3uW/AmYNxDPeE6usoKjy3ZQgUpVES3D659mvwxK/dP0qhMsurZ LlBE9AurNLkGWTfZrpeNknBYHX06b+IhlyaSpidNR0fF7qMlT9wuEl4N4iadHOkuhLj6 803Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="e0iY/kpx"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id bv64-20020a632e43000000b0057745d87b50si27495977pgb.139.2023.10.02.15.25.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 15:25:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="e0iY/kpx"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 5C3DE8092DB9; Mon, 2 Oct 2023 08:03:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237953AbjJBPDa (ORCPT + 18 others); Mon, 2 Oct 2023 11:03:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237937AbjJBPDZ (ORCPT ); Mon, 2 Oct 2023 11:03:25 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91DA2B3 for ; Mon, 2 Oct 2023 08:03:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696259002; x=1727795002; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TfyWhxyy1mDgZc/yF4XXTFgx0fC2YWrU9qvajoWde6s=; b=e0iY/kpxqZVB2xC5kt50rCVMlfUy0jRVwq9XOSeBw/J/Mbn0InOvytoT z4mvhwYJrEkDCwiIEu5idesk9cDHZZAluGFhcw/Nv/0IPprTerttWDCXs fs46RHgII+ux2PB+K2u1xn1VcPAL7qygsvBOYpWxkDIT7t32rt+uoYkyA KBmH3Hhseg4ddltCmU1FYL3paN7jvRWmJWhLFog6JqYQelTiLliAmM3PV 8PGmqGjKO8AYEdtmAMppi8twIzFGFKp0qv8aw/emSjd0uIB/NNYQU6Eaq Typ+T0PO/jTPDaEQX+Y9m75NB8jiih1e5+c8SQ8afsVkctjnj4JkUvcPy w==; X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="362033043" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="362033043" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Oct 2023 08:03:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="820904661" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="820904661" Received: from kanliang-dev.jf.intel.com ([10.165.154.102]) by fmsmga004.fm.intel.com with ESMTP; 02 Oct 2023 08:03:19 -0700 From: kan.liang@linux.intel.com To: peterz@infradead.org, mingo@redhat.com, linux-kernel@vger.kernel.org Cc: eranian@google.com, ak@linux.intel.com, Kan Liang Subject: [PATCH 3/5] perf/x86/intel/uncore: Support Granite Rapids Date: Mon, 2 Oct 2023 08:03:23 -0700 Message-Id: <20231002150325.2025749-3-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20231002150325.2025749-1-kan.liang@linux.intel.com> References: <20231002150325.2025749-1-kan.liang@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 02 Oct 2023 08:03:39 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778684323288776929 X-GMAIL-MSGID: 1778684323288776929 From: Kan Liang The same as Sapphire Rapids, Granite Rapids also supports the discovery table feature. All the basic uncore PMON information can be retrieved from the discovery table which resides in the BIOS. There are 4 new units are added on Granite Rapids, b2cmi, b2cxl, ubox, and mdf_sbo. The layout of the counters is exactly the same as the generic uncore counters. Only add a name for the new units. All the details can be retrieved from the discovery table. The description of the new units can be found at https://www.intel.com/content/www/us/en/secure/content-details/772943/content-details.html The other units, e.g., cha, iio, irp, pcu, and imc, are the same as Sapphire Rapids. Ignore the upi and b2upi units in the discovery table, which are broken for now. Signed-off-by: Kan Liang --- arch/x86/events/intel/uncore.c | 10 ++++ arch/x86/events/intel/uncore.h | 4 ++ arch/x86/events/intel/uncore_snbep.c | 81 ++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+) diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c index 69043e02e8a7..01c01cae82ef 100644 --- a/arch/x86/events/intel/uncore.c +++ b/arch/x86/events/intel/uncore.c @@ -1814,6 +1814,14 @@ static const struct intel_uncore_init_fun spr_uncore_init __initconst = { .uncore_units_ignore = spr_uncore_units_ignore, }; +static const struct intel_uncore_init_fun gnr_uncore_init __initconst = { + .cpu_init = gnr_uncore_cpu_init, + .pci_init = gnr_uncore_pci_init, + .mmio_init = gnr_uncore_mmio_init, + .use_discovery = true, + .uncore_units_ignore = gnr_uncore_units_ignore, +}; + static const struct intel_uncore_init_fun generic_uncore_init __initconst = { .cpu_init = intel_uncore_generic_uncore_cpu_init, .pci_init = intel_uncore_generic_uncore_pci_init, @@ -1865,6 +1873,8 @@ static const struct x86_cpu_id intel_uncore_match[] __initconst = { X86_MATCH_INTEL_FAM6_MODEL(METEORLAKE_L, &mtl_uncore_init), X86_MATCH_INTEL_FAM6_MODEL(SAPPHIRERAPIDS_X, &spr_uncore_init), X86_MATCH_INTEL_FAM6_MODEL(EMERALDRAPIDS_X, &spr_uncore_init), + X86_MATCH_INTEL_FAM6_MODEL(GRANITERAPIDS_X, &gnr_uncore_init), + X86_MATCH_INTEL_FAM6_MODEL(GRANITERAPIDS_D, &gnr_uncore_init), X86_MATCH_INTEL_FAM6_MODEL(ATOM_TREMONT_D, &snr_uncore_init), X86_MATCH_INTEL_FAM6_MODEL(ATOM_GRACEMONT, &adl_uncore_init), {}, diff --git a/arch/x86/events/intel/uncore.h b/arch/x86/events/intel/uncore.h index 7428ecaddf72..4838502d89ae 100644 --- a/arch/x86/events/intel/uncore.h +++ b/arch/x86/events/intel/uncore.h @@ -593,6 +593,7 @@ extern struct list_head pci2phy_map_head; extern struct pci_extra_dev *uncore_extra_pci_dev; extern struct event_constraint uncore_constraint_empty; extern int spr_uncore_units_ignore[]; +extern int gnr_uncore_units_ignore[]; /* uncore_snb.c */ int snb_uncore_pci_init(void); @@ -634,6 +635,9 @@ void icx_uncore_mmio_init(void); int spr_uncore_pci_init(void); void spr_uncore_cpu_init(void); void spr_uncore_mmio_init(void); +int gnr_uncore_pci_init(void); +void gnr_uncore_cpu_init(void); +void gnr_uncore_mmio_init(void); /* uncore_nhmex.c */ void nhmex_uncore_cpu_init(void); diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c index dfe4a84f25c6..e2ce97d73a31 100644 --- a/arch/x86/events/intel/uncore_snbep.c +++ b/arch/x86/events/intel/uncore_snbep.c @@ -6574,3 +6574,84 @@ void spr_uncore_mmio_init(void) } /* end of SPR uncore support */ + +/* GNR uncore support */ + +#define UNCORE_GNR_NUM_UNCORE_TYPES 21 +#define UNCORE_GNR_TYPE_15 15 +#define UNCORE_GNR_B2UPI 18 + +int gnr_uncore_units_ignore[] = { + UNCORE_SPR_UPI, + UNCORE_GNR_TYPE_15, + UNCORE_GNR_B2UPI, + UNCORE_IGNORE_END +}; + +static struct intel_uncore_type gnr_uncore_ubox = { + .name = "ubox", + .attr_update = uncore_alias_groups, +}; + +static struct intel_uncore_type gnr_uncore_b2cmi = { + SPR_UNCORE_PCI_COMMON_FORMAT(), + .name = "b2cmi", +}; + +static struct intel_uncore_type gnr_uncore_b2cxl = { + SPR_UNCORE_MMIO_COMMON_FORMAT(), + .name = "b2cxl", +}; + +static struct intel_uncore_type gnr_uncore_mdf_sbo = { + .name = "mdf_sbo", + .attr_update = uncore_alias_groups, +}; + +static struct intel_uncore_type *gnr_uncores[UNCORE_GNR_NUM_UNCORE_TYPES] = { + &spr_uncore_chabox, + &spr_uncore_iio, + &spr_uncore_irp, + NULL, + &spr_uncore_pcu, + &gnr_uncore_ubox, + &spr_uncore_imc, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + &gnr_uncore_b2cmi, + &gnr_uncore_b2cxl, + NULL, + NULL, + &gnr_uncore_mdf_sbo, +}; + +void gnr_uncore_cpu_init(void) +{ + uncore_msr_uncores = uncore_get_uncores(UNCORE_ACCESS_MSR, 0, NULL, + UNCORE_GNR_NUM_UNCORE_TYPES, + gnr_uncores); +} + +int gnr_uncore_pci_init(void) +{ + uncore_pci_uncores = uncore_get_uncores(UNCORE_ACCESS_PCI, 0, NULL, + UNCORE_GNR_NUM_UNCORE_TYPES, + gnr_uncores); + return 0; +} + +void gnr_uncore_mmio_init(void) +{ + uncore_mmio_uncores = uncore_get_uncores(UNCORE_ACCESS_MMIO, 0, NULL, + UNCORE_GNR_NUM_UNCORE_TYPES, + gnr_uncores); +} + +/* end of GNR uncore support */ From patchwork Mon Oct 2 15:03:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liang, Kan" X-Patchwork-Id: 147445 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1656184vqb; Mon, 2 Oct 2023 12:53:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGprhlAE5+ryRj5JacbMyPGuh1lwhlxxCm4frLUjRaF9/2lE/58BunmSf2OMo5Wt/+OOxga X-Received: by 2002:a05:6a20:3d90:b0:15e:10e:12f3 with SMTP id s16-20020a056a203d9000b0015e010e12f3mr13529820pzi.0.1696276383349; Mon, 02 Oct 2023 12:53:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696276383; cv=none; d=google.com; s=arc-20160816; b=K93kwFoaXqIRRvCnq3s4Fg+uahP78N9mnevqCi0QTAm23jnIcIdd/Fk+ej1gdJAN9u QA5fGdIpxwg6IKoc3UsUmd0iaeHCg1fmoxdkwNSH+tVKmZnJ9e41Ro6k93HEVQOdghzS IKaLxuKlUe/14IaVzJQOpyEXUgkZTjIiEElJdReA9wkqKDMDdvHlik3NDBBhl5VZ2gMb nyXuhrEEho022ki2zVEk7cEmbpRiQ/Fwx+QXemq1tmu9v1MkJDisvVoheUZfTTLkkec+ 8dd/rvRDvv9RJFGka5cqtyUl4G/fl5FJrMog+/iMDG3BXnQBkEHT8OnPhnaj3logUBd4 YLgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mzRxMHkJTqwNrNEoMlTWDd2kYlj/JEd0XgYf1pDYXgA=; fh=XOkOKN9ZbC1Zh3rfeAvxUpgU00NM1ZcWi06LZ96oE2g=; b=fsxWj2brnRw6PzF5ICeQTFo5TpZJPbCX9m8Dxla/4VhvlI1oa8mL6ui20iucY2MHdF Xg4NXTHB4rXY9qKKd6mVMm7PeW25qd0rRcwLF+WFCFsPOK4DHr+14cBvkT6m9E5+JwkF RtfnFRsZBKI0/am2eB6GMfI9DtaLSEpn1cgP7cAKHKdIHgs4ARfeLNI6IyRhQ42vG81i Sg2gDH3Jo3bWVuXXG0xlN0f9LjHRO/fG7TlwNtPGUVgyiVietQDJKum2peDF46lusaDU MBv6xektmpZ3ZeH1bRyAE0XrzvDsiWgBbUT0V/UsRclMzIR1g0giv7dJPY2qN0z4rCc5 yeYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QBIQCiwQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id j13-20020a63cf0d000000b0057821ea0674si17519130pgg.812.2023.10.02.12.53.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 12:53:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QBIQCiwQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id BCEE88025824; Mon, 2 Oct 2023 08:03:42 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237961AbjJBPDc (ORCPT + 18 others); Mon, 2 Oct 2023 11:03:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237862AbjJBPDZ (ORCPT ); Mon, 2 Oct 2023 11:03:25 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92376B7 for ; Mon, 2 Oct 2023 08:03:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696259003; x=1727795003; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Nx7GNempp8UMyeQf3iZp0vdzB5eXlrq5zLmg/MI/cX8=; b=QBIQCiwQCo4cEd7CA6oybkbzbzBY0eBZRB8s2Br2WCIgGos/c5O8vqa1 pRj8exudUBDyUt6oPp0AP3lxqydDw9yg+g3mW3YUjKYBfC5cuJI7GowQy Ls0OYcClXnNlT8s3zo8WParQbKylVs3x2TtryIZhHim2IIRi6H93yXfad OlupFd66z60boK5STce6pKxznILAjvaLXy53UTYpi7O5e/4BKIONZiku2 IKabC6dyyEIXN1dRuD2bGPG/nk/3q0QhxMmQhmJB5/6miNFDsOudrQzK5 +Wux3dWB9879L3ZWM1eCUYbd2xbzGPNpzCbO++GCNu2w9/v8QV6jiz8AJ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="362033052" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="362033052" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Oct 2023 08:03:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="820904664" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="820904664" Received: from kanliang-dev.jf.intel.com ([10.165.154.102]) by fmsmga004.fm.intel.com with ESMTP; 02 Oct 2023 08:03:19 -0700 From: kan.liang@linux.intel.com To: peterz@infradead.org, mingo@redhat.com, linux-kernel@vger.kernel.org Cc: eranian@google.com, ak@linux.intel.com, Kan Liang Subject: [PATCH 4/5] perf/x86/intel/uncore: Support IIO free-running counters on GNR Date: Mon, 2 Oct 2023 08:03:24 -0700 Message-Id: <20231002150325.2025749-4-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20231002150325.2025749-1-kan.liang@linux.intel.com> References: <20231002150325.2025749-1-kan.liang@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 02 Oct 2023 08:03:42 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778674705224464502 X-GMAIL-MSGID: 1778674705224464502 From: Kan Liang The free-running counters for IIO uncore blocks on Granite Rapids are similar to Sapphire Rapids. The key difference is the offset of the registers. The number of the IIO uncore blocks can also be retrieved from the discovery table. Signed-off-by: Kan Liang --- arch/x86/events/intel/uncore_snbep.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c index e2ce97d73a31..60334026141a 100644 --- a/arch/x86/events/intel/uncore_snbep.c +++ b/arch/x86/events/intel/uncore_snbep.c @@ -6632,11 +6632,21 @@ static struct intel_uncore_type *gnr_uncores[UNCORE_GNR_NUM_UNCORE_TYPES] = { &gnr_uncore_mdf_sbo, }; +static struct freerunning_counters gnr_iio_freerunning[] = { + [SPR_IIO_MSR_IOCLK] = { 0x290e, 0x01, 0x10, 1, 48 }, + [SPR_IIO_MSR_BW_IN] = { 0x360e, 0x10, 0x80, 8, 48 }, + [SPR_IIO_MSR_BW_OUT] = { 0x2e0e, 0x10, 0x80, 8, 48 }, +}; + void gnr_uncore_cpu_init(void) { - uncore_msr_uncores = uncore_get_uncores(UNCORE_ACCESS_MSR, 0, NULL, + uncore_msr_uncores = uncore_get_uncores(UNCORE_ACCESS_MSR, + UNCORE_SPR_MSR_EXTRA_UNCORES, + spr_msr_uncores, UNCORE_GNR_NUM_UNCORE_TYPES, gnr_uncores); + spr_uncore_iio_free_running.num_boxes = uncore_type_max_boxes(uncore_msr_uncores, UNCORE_SPR_IIO); + spr_uncore_iio_free_running.freerunning = gnr_iio_freerunning; } int gnr_uncore_pci_init(void) From patchwork Mon Oct 2 15:03:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liang, Kan" X-Patchwork-Id: 147335 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1496476vqb; Mon, 2 Oct 2023 08:17:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHFbe9wiypxCW9vu/JTOX6eMMeEoQeYzwRLuTnI/ncumdGqSFvQg6rfie0GygtsH/RPaC6K X-Received: by 2002:a05:6a21:60f:b0:160:c1b9:a754 with SMTP id ll15-20020a056a21060f00b00160c1b9a754mr9144669pzb.45.1696259838061; Mon, 02 Oct 2023 08:17:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696259838; cv=none; d=google.com; s=arc-20160816; b=JBNTvY4fR+XlpoGqIwXzx1a2WApNfMlUMm8wqphP0dwf/aKG/KtqcV8S77DJNHCOY0 N+2FCFqYNCQ1iQrvMHSSv3Nt5j+cPazQzZ/4PuP9PA6GXYVQ5tAKBoAPeUZ8/bycr1Ij GUHqfXYNP2wb6kof0MjjM819ZYZ+UmG0R/kUOnnCEOed/T3NWcgVWAdXlgK7zAJV3cIc 78CgRl64zhh+saK7aDys5rUqKFXLFRWfRcKSUzpVnmbbD13ItxZ1Q6vUNFh44dtUGajt iqWr1uveuhtldj/ulB7PjdG2hAs7523ufsdQC7Xh1RMeg0s4a6g3ptq+rFl23Suj3fPl FZYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=V4yI9S8HulQVZe4Oeo4utVuBB+EAWj6ZdTPzEnW1Wp8=; fh=XOkOKN9ZbC1Zh3rfeAvxUpgU00NM1ZcWi06LZ96oE2g=; b=PnCTgfc1ZTA2f62umJA11eJL5gXsgWCipsXAA43/Q3nIdQjwPwDxbtmFOu3ugIpjI2 SfeNE3nfyfmisy4mgVOxL7RpBpqNjc9oEqf4tATRAVbEDEAFdoKjwotiORwRbn0aQvRG pTyvf2zGxEo/0IWIMJuynxJ6M6NqD/cBy6SuCJxJZJZym9AAnWp8GnhJmxlZtfI1OYqK opUF850COEeBGHdu0nFl58YNt1Yaxbru9DIDv2zXIfNl2DgWiS6pnlrmLOA81H0JDh7Q gB1CQ9yonhK74oN3edVOBjVRIO/d+qUj2zi8fR6KLZsyKFgPA4KbyfSbiDHToVf6uYNi 5HoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BkEnaIXe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id f20-20020a63f114000000b0056566687e59si26722223pgi.343.2023.10.02.08.17.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 08:17:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BkEnaIXe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id C7D5780D44C6; Mon, 2 Oct 2023 08:03:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237952AbjJBPDf (ORCPT + 18 others); Mon, 2 Oct 2023 11:03:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237948AbjJBPD2 (ORCPT ); Mon, 2 Oct 2023 11:03:28 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A66FDA7 for ; Mon, 2 Oct 2023 08:03:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696259003; x=1727795003; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UNfst+AaesJthDfkA5tDAoLeA2ZVgQ7d938xHxoBOl0=; b=BkEnaIXedm4+2Qyy5PWiZtd00QQaq8GxaLfcVjhDJUqFhSuwSW2+0nMX O/JdRAzB5q2OpR7KTUh5VvLGwgZU80yT+Tons8I4gWyOrxhUpLx73cBwv kz1yXunqWyV0QbpnC6CYMod3NrsxOEMr+4dWUc3sit46lxXAtoS4qpsXS r2AEw2zDH8i3EUJ9sF+/1LFCosyJxX0Oc/YoLX7tPYwP3j9lwvQBWAtgo QhuZmNu1wrPJtsurwhuQwdA9wED6RHbrlc0qKyGMBoT1U9vnFbizHzL0Z ye9DvVbftuYL7xundrLKVcg4OO/XBe13yhaZz6oBTRH9vbwmc0OAKyVX/ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="362033057" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="362033057" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Oct 2023 08:03:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="820904670" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="820904670" Received: from kanliang-dev.jf.intel.com ([10.165.154.102]) by fmsmga004.fm.intel.com with ESMTP; 02 Oct 2023 08:03:20 -0700 From: kan.liang@linux.intel.com To: peterz@infradead.org, mingo@redhat.com, linux-kernel@vger.kernel.org Cc: eranian@google.com, ak@linux.intel.com, Kan Liang Subject: [PATCH 5/5] perf/x86/intel/uncore: Support Sierra Forest and Grand Ridge Date: Mon, 2 Oct 2023 08:03:25 -0700 Message-Id: <20231002150325.2025749-5-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20231002150325.2025749-1-kan.liang@linux.intel.com> References: <20231002150325.2025749-1-kan.liang@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 02 Oct 2023 08:03:46 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778657356018787503 X-GMAIL-MSGID: 1778657356018787503 From: Kan Liang The same as Granite Rapids, the Sierra Forest and Grand Ridge also supports the discovery table feature and the same type of the uncore units. The difference of the available units and counters can be retrieved from the discovery table automatically. Just add the CPU model ID. Signed-off-by: Kan Liang --- arch/x86/events/intel/uncore.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c index 01c01cae82ef..4e26a28536de 100644 --- a/arch/x86/events/intel/uncore.c +++ b/arch/x86/events/intel/uncore.c @@ -1877,6 +1877,8 @@ static const struct x86_cpu_id intel_uncore_match[] __initconst = { X86_MATCH_INTEL_FAM6_MODEL(GRANITERAPIDS_D, &gnr_uncore_init), X86_MATCH_INTEL_FAM6_MODEL(ATOM_TREMONT_D, &snr_uncore_init), X86_MATCH_INTEL_FAM6_MODEL(ATOM_GRACEMONT, &adl_uncore_init), + X86_MATCH_INTEL_FAM6_MODEL(ATOM_CRESTMONT_X, &gnr_uncore_init), + X86_MATCH_INTEL_FAM6_MODEL(ATOM_CRESTMONT, &gnr_uncore_init), {}, }; MODULE_DEVICE_TABLE(x86cpu, intel_uncore_match);