Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1556829rdb; Mon, 2 Oct 2023 13:25:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGZu9CEBjkMYjl/0rUHLhZyBmei+mnHQy3FcGPAreZRoeMAhKbZ78xPb0NNYA0Bo0yRWII7 X-Received: by 2002:a05:6a20:2446:b0:15a:290:d83d with SMTP id t6-20020a056a20244600b0015a0290d83dmr12258985pzc.41.1696278302749; Mon, 02 Oct 2023 13:25:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696278302; cv=none; d=google.com; s=arc-20160816; b=h5fKUoWnbSDX+wfN2PT5d6OiM4HhTlNaHUQwKoz99a1niMfFTwcr+PDcCPZtCZdZ74 705ZaB3ZLvxUTx//qPWFNs6uxKllATr2xMTb3Y28dmYQExyNIA9RKQ0iZNMcHcH1TCYm CWWYbHjfQxUulz2RKuIZANEt3M9iYBGm/sFvV6wVUsOSQki0SYSKZu1Y9kRBX3bLx8yy PuKHU8bTwQ+vxerQdJpUk8ekFu59dMDkDOo2VxTGEW41ew4W5zf9eOsOx8eYnV/uaXwI LpuQAJQJQMaxgUSPg6B2F26W6+/vrkF/xcrTYlfJiZvQV/dfh6o2baERnkxWwJeHSBh1 SImg== 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 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id l10-20020a170902f68a00b001c76b4c349esi3665117plg.218.2023.10.02.13.25.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 13:25:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; 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 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id BAD1A807F4BD; Mon, 2 Oct 2023 08:03:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237939AbjJBPD0 (ORCPT + 99 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 Content-Transfer-Encoding: 8bit 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 agentk.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 (agentk.vger.email [0.0.0.0]); Mon, 02 Oct 2023 08:03:52 -0700 (PDT) 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; } -- 2.35.1