From patchwork Wed Sep 18 20:51:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Reed X-Patchwork-Id: 1986983 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X89n21TJ5z1y2j for ; Thu, 19 Sep 2024 06:51:50 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1sr1e4-00049W-9Q; Wed, 18 Sep 2024 20:51:28 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1sr1e1-00048m-Ub for kernel-team@lists.ubuntu.com; Wed, 18 Sep 2024 20:51:25 +0000 Received: from mail-ot1-f72.google.com (mail-ot1-f72.google.com [209.85.210.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id C201C3F2B9 for ; Wed, 18 Sep 2024 20:51:25 +0000 (UTC) Received: by mail-ot1-f72.google.com with SMTP id 46e09a7af769-710f14b4d5cso138059a34.0 for ; Wed, 18 Sep 2024 13:51:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726692684; x=1727297484; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8J/KqBM6R24zVH0D3pB/giQ5aLy1x1YmqDj93oFUurQ=; b=HMARoXuEMvNgQ/ZQufnAyf7P8C1taztGX1uWKiP2pfMU6/fJa/p/YUpa9/LOUdI/Zd Ho5hwZxrtsqkkDbnZBBlhi7ROPsgd9z3R/L61K3NfjG1/PGMI5X+wVtGfUjcqztrMA0H gNKYB1K2UTgXIj4eROHoe8ZGCIXYYzJUjcMm2s6gICr+Azh5COVW1aQvIfSUtRQubrOd vgqTHl9C63w2+uy/MZLEb12Xx0uMkn4RVM6Yd6hEaCJA0kTOczONRpnqy30G5yc/+x4v K9qMJeH8AqP+rJpxVk2ubYvWIvcl4DXNur/GhnnUYccM1wzgOMU88LJR8rds1Slsl9O9 YPjg== X-Gm-Message-State: AOJu0YyrQu3PcBw8MOI/86r3f2hmtAYCPvXp5YTWKIIGIacZLSCpmrRm SjQYS5LBpHvu6npdDM40E9B7afCLYLo4a+PpzHjg3ZKWgLyrCxnN5lr6IVh8h6j71lx1FzF1yBs cuYY7hX4vDu6W9u+LbFIbzLvEdyQGeKnZuY33gHT4wLruEw/JqEdfhzPNwvH1Ud15g1dnOkRX3a pdKAFu/0sV8vKf X-Received: by 2002:a05:6830:7009:b0:710:ea11:3d40 with SMTP id 46e09a7af769-71388751b07mr414316a34.16.1726692684491; Wed, 18 Sep 2024 13:51:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGppITVwtiimuQ8rclA73XagSORYDA2i3cVT4pBKbHI3N7xsUcxOfnc7QB+UW3fNpS0YHoNow== X-Received: by 2002:a05:6830:7009:b0:710:ea11:3d40 with SMTP id 46e09a7af769-71388751b07mr414306a34.16.1726692684101; Wed, 18 Sep 2024 13:51:24 -0700 (PDT) Received: from localhost ([2600:1700:1d0:5e50:4536:727e:1556:7bf1]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-5e3b0e44405sm1765165eaf.46.2024.09.18.13.51.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Sep 2024 13:51:23 -0700 (PDT) From: Michael Reed To: kernel-team@lists.ubuntu.com Subject: [SRU][N][PATCH 4/8] perf/x86/uncore: Apply the unit control RB tree to MMIO uncore units Date: Wed, 18 Sep 2024 15:51:10 -0500 Message-Id: <20240918205114.31083-5-michael.reed@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240918205114.31083-1-michael.reed@canonical.com> References: <20240918205114.31083-1-michael.reed@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Kan Liang BugLink: https://bugs.launchpad.net/bugs/2081079 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. Signed-off-by: Kan Liang Signed-off-by: Peter Zijlstra (Intel) Tested-by: Yunying Sun Link: https://lore.kernel.org/r/20240614134631.1092359-5-kan.liang@linux.intel.com (cherry picked from commit 80580dae65b941eb681bd79f31f64f91b58232b4) Signed-off-by: Michael Reed --- 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;