Received: by 2002:ab2:715a:0:b0:1fd:c064:50c with SMTP id l26csp79937lqm; Mon, 10 Jun 2024 13:19:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWka2iNLSKLH0LzHBNgxb2YJykET4ntVU+MXz2nDQptayYyFsWT2/PIi1HGsGwtsI2HGLrL+8F0r3vPAG02xsgIDCaby6kZ4paszL0kew== X-Google-Smtp-Source: AGHT+IHvDt3uQBOVTRHQ2z2ANEoLzEK+7fb0FqYEYsJIBDTU7ka7ZlqZQlC+Jp5nY3mqKFH9AcZ5 X-Received: by 2002:a05:6870:93cb:b0:250:73f1:77be with SMTP id 586e51a60fabf-25464800748mr11657303fac.38.1718050786652; Mon, 10 Jun 2024 13:19:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718050786; cv=pass; d=google.com; s=arc-20160816; b=fbJSvARn2MBWy6KXA/Q2BR48tHXA0HZaO4YQNEdOxNJHLUqH42WnQwzyxj8NZaiqw5 qwUwY5nuMOxEZvTailCUagbFB89sgtZPnOyh5bqVTrKVu303rPEffRt+4Y2EeGkRNDqi cBpnvEoq2NWJesx8IM/d1Jbc6EmibYNJDwXR7G29RkMVdm3h/aYshH7wt0uzCakWexEI Sm0H0QZNfTJS0RqazcE9Vx+RiAJH21smp6C/ta1s/IqeUzSkKqvyvgK84irxcqmjWMxd C8m+eRvySWtRvsejhULNc0yhHb+6gNUKJmp2znd4M5lJ06j6JCxUDexrMJugnJNz1cHR 2PdQ== 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=vV2EFN2QZeJUNXPtMkkDh+GCTuQhxCHelMwTi86ZfvI=; fh=t8PCxyR+qT0Nfk8VGk3BF8Qwoax2ycHp2O6dm1yrDi8=; b=AimuUt1sX0ARnxx7O9mBSUXsRSVBttJEsijX2FilU3s2Bh7KHu48+aiImfUOZv6vnG bLw6miX53439ZJ6ThLpi1rtjV5eGM/QNS1t1jucD9pxbzbkjZQQxb0a1jjWugl173EL+ dCS8Ev5Nfx6hZRm/MjsjIFW/llywzQXALQyudpUIk7nXBniKU6mTMXKqFbsSWWvUCJu8 5Nb1Zmo9J1S+Aqb3G2d+sNpOWxHMYOUWrV6BZOCywxpSqklwCUBXPePa0PwFnRlfEDAh 8bass6BgAo2g5XWeVD/2UNc10EQnGSGARAjy2NHnOsb8QVfMzV0zLAXTgWFVVdtD38tN NpJg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DjO6+gUh; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-208852-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208852-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-79533396494si1205246985a.726.2024.06.10.13.19.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 13:19:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208852-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DjO6+gUh; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-208852-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208852-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 075271C238B5 for ; Mon, 10 Jun 2024 20:19:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4304E152160; Mon, 10 Jun 2024 20:17:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="DjO6+gUh" 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 0F46114C5BE for ; Mon, 10 Jun 2024 20:17:56 +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=1718050677; cv=none; b=YnU10+JU+HTy7vX6GKtKPxNebliV7V92YRE92C+gutuXeyyGAr03B94+z+oc9BBnIR1dYNfBhGPEkfJtvBw8jHNc4syKEKPPjpzs5T72ViNhrPOlQf44jnAXjoTTINl+3nP8S+gI61bwpWX4SafsWey2/ikRFkmSzH7Nncbmr4A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718050677; c=relaxed/simple; bh=wimvY5isq1Qjd2cAKH3TiSNl3khLuKHiYStMxXzBNrY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EpLs8mLjJgjaoYJij5pFGTEZ4i/bGou5kB3UfuDz1gxuJdL+9ezAd58dIYktvbfhf3nyvEjKQURrVcZEHGViOq1RPqX4LBkYbbknvmq78nU7kGKOb2/skWdJU9gEenmYHlcwotb+abo6QeAxtIbFUPNfwpH0CMDP1h0m/nuYVbs= 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=DjO6+gUh; 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=1718050676; x=1749586676; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wimvY5isq1Qjd2cAKH3TiSNl3khLuKHiYStMxXzBNrY=; b=DjO6+gUhCLUaCAtQYjZxCVoXQ0lGLR4YYEweApIjGGOpb/Tj5hYbKU94 mcztjkm95gMR2PYr82Ow+ezYYLN1QYN+W1rIdwaJEhrT3vE2YfkUNnG+8 2KqstjPxMejUdQYKU8xHIcMk+p1PriOL59jLkfrkgS74Xe+ltY2N8Dvix EkeZHUX3W2O6Sb0wOSlpnbc3/i3ec9u76Ztch6IxOEdvEoqzcLLCbI2go 2TI0fQNjB1Yoziw6aWmzkvZTcSBiPoVwhuqbRJBBloQxug9v3BM4MxTdn n7ojg2+pC4RiIyzb7NNr7t//hl7Kd4FI+VGqbt9sLyxYzNmgVDn/+BBtY A==; X-CSE-ConnectionGUID: mBMhNhc9SSyz1rPZeEhs9Q== X-CSE-MsgGUID: 0M8lTslSQeaKbW0BHz3Low== X-IronPort-AV: E=McAfee;i="6600,9927,11099"; a="18561541" X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="18561541" 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:52 -0700 X-CSE-ConnectionGUID: CQbSNOqcSpmI0knvizJOLw== X-CSE-MsgGUID: IzcRmTPiRTS1AHHFJDeYmQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="39169109" Received: from kanliang-dev.jf.intel.com ([10.165.154.102]) by fmviesa008.fm.intel.com with ESMTP; 10 Jun 2024 13:17:52 -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 8/8] perf/x86/intel/uncore: Support HBM and CXL PMON counters Date: Mon, 10 Jun 2024 13:16:19 -0700 Message-Id: <20240610201619.884021-9-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 Unknown uncore PMON types can be found in both SPR and EMR with HBM or CXL. $ls /sys/devices/ | grep type uncore_type_12_16 uncore_type_12_18 uncore_type_12_2 uncore_type_12_4 uncore_type_12_6 uncore_type_12_8 uncore_type_13_17 uncore_type_13_19 uncore_type_13_3 uncore_type_13_5 uncore_type_13_7 uncore_type_13_9 The unknown PMON types are HBM and CXL PMON. Except for the name, the other information regarding the HBM and CXL PMON counters can be retrieved via the discovery table. Add them into the uncores tables for SPR and EMR. The event config registers for all CXL related units are 8-byte apart. Add SPR_UNCORE_MMIO_OFFS8_COMMON_FORMAT to specially handle it. Tested-by: Yunying Sun Signed-off-by: Kan Liang --- arch/x86/events/intel/uncore_snbep.c | 55 +++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c index fde123af9e3a..a7ea221f2f11 100644 --- a/arch/x86/events/intel/uncore_snbep.c +++ b/arch/x86/events/intel/uncore_snbep.c @@ -6163,7 +6163,55 @@ static struct intel_uncore_type spr_uncore_mdf = { .name = "mdf", }; -#define UNCORE_SPR_NUM_UNCORE_TYPES 12 +static void spr_uncore_mmio_offs8_init_box(struct intel_uncore_box *box) +{ + __set_bit(UNCORE_BOX_FLAG_CTL_OFFS8, &box->flags); + intel_generic_uncore_mmio_init_box(box); +} + +static struct intel_uncore_ops spr_uncore_mmio_offs8_ops = { + .init_box = spr_uncore_mmio_offs8_init_box, + .exit_box = uncore_mmio_exit_box, + .disable_box = intel_generic_uncore_mmio_disable_box, + .enable_box = intel_generic_uncore_mmio_enable_box, + .disable_event = intel_generic_uncore_mmio_disable_event, + .enable_event = spr_uncore_mmio_enable_event, + .read_counter = uncore_mmio_read_counter, +}; + +#define SPR_UNCORE_MMIO_OFFS8_COMMON_FORMAT() \ + SPR_UNCORE_COMMON_FORMAT(), \ + .ops = &spr_uncore_mmio_offs8_ops + +static struct event_constraint spr_uncore_cxlcm_constraints[] = { + UNCORE_EVENT_CONSTRAINT(0x02, 0x0f), + UNCORE_EVENT_CONSTRAINT(0x05, 0x0f), + UNCORE_EVENT_CONSTRAINT(0x40, 0xf0), + UNCORE_EVENT_CONSTRAINT(0x41, 0xf0), + UNCORE_EVENT_CONSTRAINT(0x42, 0xf0), + UNCORE_EVENT_CONSTRAINT(0x43, 0xf0), + UNCORE_EVENT_CONSTRAINT(0x4b, 0xf0), + UNCORE_EVENT_CONSTRAINT(0x52, 0xf0), + EVENT_CONSTRAINT_END +}; + +static struct intel_uncore_type spr_uncore_cxlcm = { + SPR_UNCORE_MMIO_OFFS8_COMMON_FORMAT(), + .name = "cxlcm", + .constraints = spr_uncore_cxlcm_constraints, +}; + +static struct intel_uncore_type spr_uncore_cxldp = { + SPR_UNCORE_MMIO_OFFS8_COMMON_FORMAT(), + .name = "cxldp", +}; + +static struct intel_uncore_type spr_uncore_hbm = { + SPR_UNCORE_COMMON_FORMAT(), + .name = "hbm", +}; + +#define UNCORE_SPR_NUM_UNCORE_TYPES 15 #define UNCORE_SPR_CHA 0 #define UNCORE_SPR_IIO 1 #define UNCORE_SPR_IMC 6 @@ -6187,6 +6235,9 @@ static struct intel_uncore_type *spr_uncores[UNCORE_SPR_NUM_UNCORE_TYPES] = { NULL, NULL, &spr_uncore_mdf, + &spr_uncore_cxlcm, + &spr_uncore_cxldp, + &spr_uncore_hbm, }; /* @@ -6656,7 +6707,7 @@ static struct intel_uncore_type gnr_uncore_b2cmi = { }; static struct intel_uncore_type gnr_uncore_b2cxl = { - SPR_UNCORE_MMIO_COMMON_FORMAT(), + SPR_UNCORE_MMIO_OFFS8_COMMON_FORMAT(), .name = "b2cxl", }; -- 2.35.1