From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4959010E15B for ; Sat, 6 May 2023 00:55:39 +0000 (UTC) From: Umesh Nerlige Ramappa To: igt-dev@lists.freedesktop.org, Tvrtko Ursulin , Ashutosh Dixit Date: Fri, 5 May 2023 17:55:20 -0700 Message-Id: <20230506005528.1890922-8-umesh.nerlige.ramappa@intel.com> In-Reply-To: <20230506005528.1890922-1-umesh.nerlige.ramappa@intel.com> References: <20230506005528.1890922-1-umesh.nerlige.ramappa@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [igt-dev] [PATCH i-g-t 07/15] intel_gpu_top: Determine number of tiles List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" List-ID: Find out how many tiles are present in the platforms for multi-tile support. Signed-off-by: Umesh Nerlige Ramappa --- tools/intel_gpu_top.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c index 3d21f25bd..695f57526 100644 --- a/tools/intel_gpu_top.c +++ b/tools/intel_gpu_top.c @@ -117,6 +117,8 @@ struct engines { bool discrete; char *device; + int num_gts; + /* Do not edit below this line. * This structure is reallocated every time a new engine is * found and size is increased by sizeof (engine). @@ -533,6 +535,25 @@ static void imc_reads_open(struct pmu_counter *pmu, struct engines *engines) imc_open(pmu, "data_reads", engines); } +static int get_num_gts(uint64_t type) +{ + int fd, cnt; + + errno = 0; + for (cnt = 0; cnt < MAX_GTS; cnt++) { + fd = igt_perf_open(type, __I915_PMU_REQUESTED_FREQUENCY(cnt)); + if (fd < 0) + break; + + close(fd); + } + assert(!errno || errno == ENOENT); + assert(cnt > 0); + errno = 0; + + return cnt; +} + static int pmu_init(struct engines *engines) { unsigned int i; @@ -541,6 +562,7 @@ static int pmu_init(struct engines *engines) engines->fd = -1; engines->num_counters = 0; + engines->num_gts = get_num_gts(type); engines->irq.config = I915_PMU_INTERRUPTS; fd = _open_pmu(type, engines->num_counters, &engines->irq, engines->fd); -- 2.34.1