Received: by 2002:ab2:715a:0:b0:1fd:c064:50c with SMTP id l26csp79482lqm; Mon, 10 Jun 2024 13:18:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXMUCPy4ijreelSQxUlW2UZGa6kEACU0Ear3gcPZd5zthH9Q5ly0P9PbBUMkzUtmVZtH9EjaI6Dv1xmy8zBk1RwF3JBlTA0CF2FL/mVzA== X-Google-Smtp-Source: AGHT+IESTw+5a/1TOztGw8UKd4F0KyfMkO0Ws+lqxqRAc4xFIT2iVIEtqfLuBZW3F9C7zJz1CmQm X-Received: by 2002:a2e:9009:0:b0:2eb:dfe9:19db with SMTP id 38308e7fff4ca-2ebdfe91cfemr30747011fa.36.1718050721603; Mon, 10 Jun 2024 13:18:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718050721; cv=pass; d=google.com; s=arc-20160816; b=Dh3iS/wb5oZ9fRU5KhcKj77w5+ESTA0SLipupr/vf6WA56YtNeQT+/ephzGQjpzbaC YyhHvi3/cPAJErQxWwBoSj21pP7J3vMibYfyOfkn2NMbv17oIWq0YFkKaNiSVPibLKLS ZZ2K+9IB7rsK4fC913cWswxsdWKQz1HHeIXgG371wlBTwaujgOxnLIXs7UYlMCcCNP4t dtoaxle/hj/f8Das7nc175n5hoJFoR5u5SsV6iOaMHFAaQVLFDQBjPZK/RvfiRCwYe8q TzfRsyp0DJoPCKurdkBvqO42pl5dq2gxffIdmKfYAQgCZDGPwLEscp9RVM87Y3kU3IzW qyQQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=0JwfYFqk7dm50HCjvRKFK0J8wSNaIGck6T0UJxuCc2s=; fh=t8PCxyR+qT0Nfk8VGk3BF8Qwoax2ycHp2O6dm1yrDi8=; b=qMoNQwnLzM7pRmSL0FoKs7gJG6wQysLYRVKEW54KupVnl2WTlD+AOVQd3XXWXzgx9R hizFuEr1SO9uKqT1NaVOFv4OCZst0JtoevlqqMhqSTd0dA+XbHZ526MJAAKzqkJ0Z41v RaESDZxDVvpS6byjk1jZdvIrp+pmiMj1ypJe8aSi+uJYysi3MGuCetIrKfxlpzwQzkw0 e5wqHiPoGp4M9WnVSZOaxkzOBa0RvXNxtj2cTC10RfzzyIZ8ddl/B83stBBHklB1zlwK FyJ2BBlDsp3fvnAWSCgV+sJQZ8lFySmT2HqONAWFy6ycUnS/I+LF9aX6cxV6tjn6MPkM 4pnQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GZ9u9jjO; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-208848-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208848-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57c626c2f75si3289420a12.656.2024.06.10.13.18.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 13:18:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208848-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GZ9u9jjO; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-208848-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208848-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 4A47D1F21140 for ; Mon, 10 Jun 2024 20:18:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 25DB814D70E; Mon, 10 Jun 2024 20:17:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="GZ9u9jjO" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE35D47A60 for ; Mon, 10 Jun 2024 20:17:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718050675; cv=none; b=tNwQsCOHxAf9fWMifC5mUZwiSOPkR3w+IgMzaBh46bk338KHrGi0/SeoASApCudFVdt1FNGZmbNE2O57U/cCLdswbNxk0P0VdubLejzqSnfYMGo+dGmbaBUVpugUn1xEOIUqKD5fncrEGYtVF8RHAeYX4f4JqcGNyGoO56QsaE0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718050675; c=relaxed/simple; bh=BIopyuEiippERL55Q+YUB/F51kO/pgwegBOMEDJyk+c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EE1RyI5dyQbgwvSJJv9EXSzIN7Do2gHgK/vIIiuNCAcvR9OpFoMhULkuLz1eOuQ8lTM8n77tgNZy/LJRHpeu6lo7Ajfbj9m/KMDnFqHlNaDSwKPQ1kyvjWLN9GFYuUsXwLALwdfmDQutAhVKeVZNp1ChCghZRLuQm02bV8Xn7GY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=GZ9u9jjO; arc=none smtp.client-ip=198.175.65.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718050674; x=1749586674; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BIopyuEiippERL55Q+YUB/F51kO/pgwegBOMEDJyk+c=; b=GZ9u9jjOzVe9XgLzFDXubD/bP6vCea26YM8DMffKMhfDFN05p0oXEafP 0GRjLhdoDK91AJndUCN4Lpngi0DVSSuOnns5wH/B62ctYY0kw9K1FEtt0 yjICeR3dnNl7wQJo0ccgLLtA+4Ee4QCUQzEYj9I10IBpm2/Esm48U/+Q1 KFdh5dFI/iINanO0S0mJG+HnraudD/w0CQ296AEk4Z5Tuum8Iavm5WiOL 70hPPMo/GcbgZY7qQ1h+0KfFvU/ss6K0oT3ifq3Toe81CSFEjJVW1F2D5 i7x/iWGgSc9n3TvFMwNPAQKI6+R66hop0NmDzzCSRaHn2ofquph1kH8ja w==; X-CSE-ConnectionGUID: kK3a4F5uRwCw0I9GUe20QQ== X-CSE-MsgGUID: 7HIEHBmNTkagmHcGumpB8Q== X-IronPort-AV: E=McAfee;i="6600,9927,11099"; a="18561523" X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="18561523" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2024 13:17:51 -0700 X-CSE-ConnectionGUID: TqqqL0ceQMyY8ogtSS/V0A== X-CSE-MsgGUID: O7AfG8x/QO69ZUyklXx/ww== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="39169090" Received: from kanliang-dev.jf.intel.com ([10.165.154.102]) by fmviesa008.fm.intel.com with ESMTP; 10 Jun 2024 13:17:50 -0700 From: kan.liang@linux.intel.com To: peterz@infradead.org, mingo@kernel.org, linux-kernel@vger.kernel.org Cc: acme@kernel.org, namhyung@kernel.org, irogers@google.com, eranian@google.com, ak@linux.intel.com, yunying.sun@intel.com, Kan Liang Subject: [PATCH 4/8] perf/x86/uncore: Apply the unit control RB tree to MMIO uncore units Date: Mon, 10 Jun 2024 13:16:15 -0700 Message-Id: <20240610201619.884021-5-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20240610201619.884021-1-kan.liang@linux.intel.com> References: <20240610201619.884021-1-kan.liang@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Kan Liang The unit control RB tree has the unit control and unit ID information for all the units. Use it to replace the box_ctls/mmio_offsets to get an accurate unit control address for MMIO uncore units. Tested-by: Yunying Sun Signed-off-by: Kan Liang --- arch/x86/events/intel/uncore_discovery.c | 30 +++++++++++------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/arch/x86/events/intel/uncore_discovery.c b/arch/x86/events/intel/uncore_discovery.c index e61e460520a8..ece761c9f17a 100644 --- a/arch/x86/events/intel/uncore_discovery.c +++ b/arch/x86/events/intel/uncore_discovery.c @@ -606,34 +606,30 @@ static struct intel_uncore_ops generic_uncore_pci_ops = { #define UNCORE_GENERIC_MMIO_SIZE 0x4000 -static u64 generic_uncore_mmio_box_ctl(struct intel_uncore_box *box) -{ - struct intel_uncore_type *type = box->pmu->type; - - if (!type->box_ctls || !type->box_ctls[box->dieid] || !type->mmio_offsets) - return 0; - - return type->box_ctls[box->dieid] + type->mmio_offsets[box->pmu->pmu_idx]; -} - void intel_generic_uncore_mmio_init_box(struct intel_uncore_box *box) { - u64 box_ctl = generic_uncore_mmio_box_ctl(box); + static struct intel_uncore_discovery_unit *unit; struct intel_uncore_type *type = box->pmu->type; resource_size_t addr; - if (!box_ctl) { + unit = intel_uncore_find_discovery_unit(type->boxes, box->dieid, box->pmu->pmu_idx); + if (!unit) { + pr_warn("Uncore type %d id %d: Cannot find box control address.\n", + type->type_id, box->pmu->pmu_idx); + return; + } + + if (!unit->addr) { pr_warn("Uncore type %d box %d: Invalid box control address.\n", - type->type_id, type->box_ids[box->pmu->pmu_idx]); + type->type_id, unit->id); return; } - addr = box_ctl; + addr = unit->addr; box->io_addr = ioremap(addr, UNCORE_GENERIC_MMIO_SIZE); if (!box->io_addr) { pr_warn("Uncore type %d box %d: ioremap error for 0x%llx.\n", - type->type_id, type->box_ids[box->pmu->pmu_idx], - (unsigned long long)addr); + type->type_id, unit->id, (unsigned long long)addr); return; } @@ -722,6 +718,8 @@ static bool uncore_update_uncore_type(enum uncore_access_type type_id, uncore->box_ctls = type->box_ctrl_die; uncore->mmio_offsets = type->box_offset; uncore->mmio_map_size = UNCORE_GENERIC_MMIO_SIZE; + uncore->boxes = &type->units; + uncore->num_boxes = type->num_units; break; default: return false; -- 2.35.1