From nobody Tue Nov 26 19:37:10 2024 Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) (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 092611D26F6 for ; Wed, 16 Oct 2024 08:02:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.156.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729065769; cv=none; b=Zb37OeLXKrpnAgigLgyiVg8JCYbQD8UfGf/F+nhWaGcrWBci6JRxO7p3D2iuUrZcKIGS+cGU19Jy0c24JlsgYCNrXnYDorowMvWN5fqgKClBhcuFKbrwdfWIP09BpRUVj9n9+FLUkG9thMEUNru/hrG3/KpWahBP8JQ9AaS8oNM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729065769; c=relaxed/simple; bh=DZav2LWxnb8kglrqPo5rKEzw6khc3lvfFFymXmT6KnQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YEgsvj1MSahX4m5rgIX3CYKjc+ohHDSrPnA3w1u0WH9P5YKNS+s6BWp6ks4Zai9Nm+Epp+p9aPge9327UvHgWWMVCxbbBTNn9yXYFcWXL/K4T2tIAHqc0ZgD2dAX0LtJpcVXfstda9798xhhEWHdkF9cv2SVjv+EVBiiqNC69RE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=pass smtp.mailfrom=marvell.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=U3URSjmq; arc=none smtp.client-ip=67.231.156.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="U3URSjmq" Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49G2fiNR021631; Wed, 16 Oct 2024 01:02:30 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=Y TKLNixyrhOT4WYP0AfkbqATmvDCZWFk/qiVWvbZl1A=; b=U3URSjmqvGOdTxuJj mpN8V2EI9wznHA/GotLXRfVzpZiCrns8oGBqHZIwK4hhaqWBs6/ytqdc4fSM0aU7 3XsZEQuLUkLMRB1uehlEjFGOihMfQaHHLDYQG7m9DqAdAZSFlybfqw8yCWLyMIVl vkF/ocghOrhsMbK+raZxGT/qMsp1B6IHAwhR8Jz2ROh1iG4DgdbTkliNnXj6F02x MVV0BJmmi88rbPpVJ131oHiDXwnhChswuV/jgiAC0vYXNh+3B1kH5JGlGFVQL1fE RxRvlwr4ZyeEgmzM1Ks2bFnaI8sZRxjahcKk1deXLHoN8scJIi4HRl/n+wYocGZ6 mLAdQ== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 42a4x4gfut-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 16 Oct 2024 01:02:30 -0700 (PDT) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 16 Oct 2024 01:02:14 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 16 Oct 2024 01:02:14 -0700 Received: from IPBU-BLR-SERVER1.marvell.com (IPBU-BLR-SERVER1.marvell.com [10.28.8.41]) by maili.marvell.com (Postfix) with ESMTP id 9CFB53F706F; Wed, 16 Oct 2024 01:02:11 -0700 (PDT) From: Gowthami Thiagarajan To: , , , CC: , , , , Gowthami Thiagarajan Subject: [PATCH v9 1/5] perf/marvell: Refactor to extract platform data - no functional change Date: Wed, 16 Oct 2024 13:31:49 +0530 Message-ID: <20241016080153.3546353-2-gthiagarajan@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241016080153.3546353-1-gthiagarajan@marvell.com> References: <20241016080153.3546353-1-gthiagarajan@marvell.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: a9xJBJOKwHGGf7qQckGenqIh1F6G1Hnk X-Proofpoint-ORIG-GUID: a9xJBJOKwHGGf7qQckGenqIh1F6G1Hnk X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 Content-Type: text/plain; charset="utf-8" This commit introduces a refactor to the Marvell DDR pmu driver, specifically targeting the extraction of platform data (referred to as "pdata") from the existing driver. The purpose of this refactor is to prepare for the upcoming support of the next version of the Performance Monitoring Unit (PMU) in this driver. No functional changes are introduced in this refactor. Its sole purpose is to improve code organization and pave the way for future enhancements to the driver. Signed-off-by: Gowthami Thiagarajan --- drivers/perf/marvell_cn10k_ddr_pmu.c | 160 +++++++++++++++++++-------- 1 file changed, 112 insertions(+), 48 deletions(-) diff --git a/drivers/perf/marvell_cn10k_ddr_pmu.c b/drivers/perf/marvell_cn= 10k_ddr_pmu.c index 94f1ebcd2a27..ed929102b53d 100644 --- a/drivers/perf/marvell_cn10k_ddr_pmu.c +++ b/drivers/perf/marvell_cn10k_ddr_pmu.c @@ -1,7 +1,8 @@ // SPDX-License-Identifier: GPL-2.0 -/* Marvell CN10K DRAM Subsystem (DSS) Performance Monitor Driver +/* + * Marvell CN10K DRAM Subsystem (DSS) Performance Monitor Driver * - * Copyright (C) 2021 Marvell. + * Copyright (C) 2021-2024 Marvell. */ =20 #include @@ -14,24 +15,24 @@ #include =20 /* Performance Counters Operating Mode Control Registers */ -#define DDRC_PERF_CNT_OP_MODE_CTRL 0x8020 +#define CN10K_DDRC_PERF_CNT_OP_MODE_CTRL 0x8020 #define OP_MODE_CTRL_VAL_MANNUAL 0x1 =20 /* Performance Counters Start Operation Control Registers */ -#define DDRC_PERF_CNT_START_OP_CTRL 0x8028 +#define CN10K_DDRC_PERF_CNT_START_OP_CTRL 0x8028 #define START_OP_CTRL_VAL_START 0x1ULL #define START_OP_CTRL_VAL_ACTIVE 0x2 =20 /* Performance Counters End Operation Control Registers */ -#define DDRC_PERF_CNT_END_OP_CTRL 0x8030 +#define CN10K_DDRC_PERF_CNT_END_OP_CTRL 0x8030 #define END_OP_CTRL_VAL_END 0x1ULL =20 /* Performance Counters End Status Registers */ -#define DDRC_PERF_CNT_END_STATUS 0x8038 +#define CN10K_DDRC_PERF_CNT_END_STATUS 0x8038 #define END_STATUS_VAL_END_TIMER_MODE_END 0x1 =20 /* Performance Counters Configuration Registers */ -#define DDRC_PERF_CFG_BASE 0x8040 +#define CN10K_DDRC_PERF_CFG_BASE 0x8040 =20 /* 8 Generic event counter + 2 fixed event counters */ #define DDRC_PERF_NUM_GEN_COUNTERS 8 @@ -42,13 +43,14 @@ DDRC_PERF_NUM_FIX_COUNTERS) =20 /* Generic event counter registers */ -#define DDRC_PERF_CFG(n) (DDRC_PERF_CFG_BASE + 8 * (n)) +#define DDRC_PERF_CFG(base, n) ((base) + 8 * (n)) #define EVENT_ENABLE BIT_ULL(63) =20 /* Two dedicated event counters for DDR reads and writes */ #define EVENT_DDR_READS 101 #define EVENT_DDR_WRITES 100 =20 +#define DDRC_PERF_REG(base, n) ((base) + 8 * (n)) /* * programmable events IDs in programmable event counters. * DO NOT change these event-id numbers, they are used to @@ -102,28 +104,29 @@ #define EVENT_HIF_RD_OR_WR 1 =20 /* Event counter value registers */ -#define DDRC_PERF_CNT_VALUE_BASE 0x8080 -#define DDRC_PERF_CNT_VALUE(n) (DDRC_PERF_CNT_VALUE_BASE + 8 * (n)) +#define CN10K_DDRC_PERF_CNT_VALUE_BASE 0x8080 =20 /* Fixed event counter enable/disable register */ -#define DDRC_PERF_CNT_FREERUN_EN 0x80C0 +#define CN10K_DDRC_PERF_CNT_FREERUN_EN 0x80C0 #define DDRC_PERF_FREERUN_WRITE_EN 0x1 #define DDRC_PERF_FREERUN_READ_EN 0x2 =20 /* Fixed event counter control register */ -#define DDRC_PERF_CNT_FREERUN_CTRL 0x80C8 +#define CN10K_DDRC_PERF_CNT_FREERUN_CTRL 0x80C8 #define DDRC_FREERUN_WRITE_CNT_CLR 0x1 #define DDRC_FREERUN_READ_CNT_CLR 0x2 =20 -/* Fixed event counter value register */ -#define DDRC_PERF_CNT_VALUE_WR_OP 0x80D0 -#define DDRC_PERF_CNT_VALUE_RD_OP 0x80D8 #define DDRC_PERF_CNT_VALUE_OVERFLOW BIT_ULL(48) #define DDRC_PERF_CNT_MAX_VALUE GENMASK_ULL(48, 0) =20 +/* Fixed event counter value register */ +#define CN10K_DDRC_PERF_CNT_VALUE_WR_OP 0x80D0 +#define CN10K_DDRC_PERF_CNT_VALUE_RD_OP 0x80D8 + struct cn10k_ddr_pmu { struct pmu pmu; void __iomem *base; + const struct ddr_pmu_platform_data *p_data; unsigned int cpu; struct device *dev; int active_events; @@ -134,6 +137,23 @@ struct cn10k_ddr_pmu { =20 #define to_cn10k_ddr_pmu(p) container_of(p, struct cn10k_ddr_pmu, pmu) =20 +struct ddr_pmu_platform_data { + u64 counter_overflow_val; + u64 counter_max_val; + u64 cnt_base; + u64 cfg_base; + u64 cnt_op_mode_ctrl; + u64 cnt_start_op_ctrl; + u64 cnt_end_op_ctrl; + u64 cnt_end_status; + u64 cnt_freerun_en; + u64 cnt_freerun_ctrl; + u64 cnt_freerun_clr; + u64 cnt_value_wr_op; + u64 cnt_value_rd_op; + bool is_cn10k; +}; + static ssize_t cn10k_ddr_pmu_event_show(struct device *dev, struct device_attribute *attr, char *page) @@ -354,6 +374,7 @@ static int cn10k_ddr_perf_event_init(struct perf_event = *event) static void cn10k_ddr_perf_counter_enable(struct cn10k_ddr_pmu *pmu, int counter, bool enable) { + const struct ddr_pmu_platform_data *p_data =3D pmu->p_data; u32 reg; u64 val; =20 @@ -363,7 +384,7 @@ static void cn10k_ddr_perf_counter_enable(struct cn10k_= ddr_pmu *pmu, } =20 if (counter < DDRC_PERF_NUM_GEN_COUNTERS) { - reg =3D DDRC_PERF_CFG(counter); + reg =3D DDRC_PERF_CFG(p_data->cfg_base, counter); val =3D readq_relaxed(pmu->base + reg); =20 if (enable) @@ -373,7 +394,8 @@ static void cn10k_ddr_perf_counter_enable(struct cn10k_= ddr_pmu *pmu, =20 writeq_relaxed(val, pmu->base + reg); } else { - val =3D readq_relaxed(pmu->base + DDRC_PERF_CNT_FREERUN_EN); + val =3D readq_relaxed(pmu->base + + p_data->cnt_freerun_en); if (enable) { if (counter =3D=3D DDRC_PERF_READ_COUNTER_IDX) val |=3D DDRC_PERF_FREERUN_READ_EN; @@ -385,27 +407,33 @@ static void cn10k_ddr_perf_counter_enable(struct cn10= k_ddr_pmu *pmu, else val &=3D ~DDRC_PERF_FREERUN_WRITE_EN; } - writeq_relaxed(val, pmu->base + DDRC_PERF_CNT_FREERUN_EN); + writeq_relaxed(val, pmu->base + + p_data->cnt_freerun_en); } } =20 static u64 cn10k_ddr_perf_read_counter(struct cn10k_ddr_pmu *pmu, int coun= ter) { + const struct ddr_pmu_platform_data *p_data =3D pmu->p_data; u64 val; =20 if (counter =3D=3D DDRC_PERF_READ_COUNTER_IDX) - return readq_relaxed(pmu->base + DDRC_PERF_CNT_VALUE_RD_OP); + return readq_relaxed(pmu->base + + p_data->cnt_value_rd_op); =20 if (counter =3D=3D DDRC_PERF_WRITE_COUNTER_IDX) - return readq_relaxed(pmu->base + DDRC_PERF_CNT_VALUE_WR_OP); + return readq_relaxed(pmu->base + + p_data->cnt_value_wr_op); =20 - val =3D readq_relaxed(pmu->base + DDRC_PERF_CNT_VALUE(counter)); + val =3D readq_relaxed(pmu->base + + DDRC_PERF_REG(p_data->cnt_base, counter)); return val; } =20 static void cn10k_ddr_perf_event_update(struct perf_event *event) { struct cn10k_ddr_pmu *pmu =3D to_cn10k_ddr_pmu(event->pmu); + const struct ddr_pmu_platform_data *p_data =3D pmu->p_data; struct hw_perf_event *hwc =3D &event->hw; u64 prev_count, new_count, mask; =20 @@ -414,7 +442,7 @@ static void cn10k_ddr_perf_event_update(struct perf_eve= nt *event) new_count =3D cn10k_ddr_perf_read_counter(pmu, hwc->idx); } while (local64_xchg(&hwc->prev_count, new_count) !=3D prev_count); =20 - mask =3D DDRC_PERF_CNT_MAX_VALUE; + mask =3D p_data->counter_max_val; =20 local64_add((new_count - prev_count) & mask, &event->count); } @@ -435,6 +463,7 @@ static void cn10k_ddr_perf_event_start(struct perf_even= t *event, int flags) static int cn10k_ddr_perf_event_add(struct perf_event *event, int flags) { struct cn10k_ddr_pmu *pmu =3D to_cn10k_ddr_pmu(event->pmu); + const struct ddr_pmu_platform_data *p_data =3D pmu->p_data; struct hw_perf_event *hwc =3D &event->hw; u8 config =3D event->attr.config; int counter, ret; @@ -454,7 +483,7 @@ static int cn10k_ddr_perf_event_add(struct perf_event *= event, int flags) =20 if (counter < DDRC_PERF_NUM_GEN_COUNTERS) { /* Generic counters, configure event id */ - reg_offset =3D DDRC_PERF_CFG(counter); + reg_offset =3D DDRC_PERF_CFG(p_data->cfg_base, counter); ret =3D ddr_perf_get_event_bitmap(config, &val); if (ret) return ret; @@ -467,7 +496,7 @@ static int cn10k_ddr_perf_event_add(struct perf_event *= event, int flags) else val =3D DDRC_FREERUN_WRITE_CNT_CLR; =20 - writeq_relaxed(val, pmu->base + DDRC_PERF_CNT_FREERUN_CTRL); + writeq_relaxed(val, pmu->base + p_data->cnt_freerun_ctrl); } =20 hwc->state |=3D PERF_HES_STOPPED; @@ -512,17 +541,19 @@ static void cn10k_ddr_perf_event_del(struct perf_even= t *event, int flags) static void cn10k_ddr_perf_pmu_enable(struct pmu *pmu) { struct cn10k_ddr_pmu *ddr_pmu =3D to_cn10k_ddr_pmu(pmu); + const struct ddr_pmu_platform_data *p_data =3D ddr_pmu->p_data; =20 writeq_relaxed(START_OP_CTRL_VAL_START, ddr_pmu->base + - DDRC_PERF_CNT_START_OP_CTRL); + p_data->cnt_start_op_ctrl); } =20 static void cn10k_ddr_perf_pmu_disable(struct pmu *pmu) { struct cn10k_ddr_pmu *ddr_pmu =3D to_cn10k_ddr_pmu(pmu); + const struct ddr_pmu_platform_data *p_data =3D ddr_pmu->p_data; =20 writeq_relaxed(END_OP_CTRL_VAL_END, ddr_pmu->base + - DDRC_PERF_CNT_END_OP_CTRL); + p_data->cnt_end_op_ctrl); } =20 static void cn10k_ddr_perf_event_update_all(struct cn10k_ddr_pmu *pmu) @@ -549,6 +580,7 @@ static void cn10k_ddr_perf_event_update_all(struct cn10= k_ddr_pmu *pmu) =20 static irqreturn_t cn10k_ddr_pmu_overflow_handler(struct cn10k_ddr_pmu *pm= u) { + const struct ddr_pmu_platform_data *p_data =3D pmu->p_data; struct perf_event *event; struct hw_perf_event *hwc; u64 prev_count, new_count; @@ -586,7 +618,7 @@ static irqreturn_t cn10k_ddr_pmu_overflow_handler(struc= t cn10k_ddr_pmu *pmu) continue; =20 value =3D cn10k_ddr_perf_read_counter(pmu, i); - if (value =3D=3D DDRC_PERF_CNT_MAX_VALUE) { + if (value =3D=3D p_data->counter_max_val) { pr_info("Counter-(%d) reached max value\n", i); cn10k_ddr_perf_event_update_all(pmu); cn10k_ddr_perf_pmu_disable(&pmu->pmu); @@ -629,11 +661,32 @@ static int cn10k_ddr_pmu_offline_cpu(unsigned int cpu= , struct hlist_node *node) return 0; } =20 +#if defined(CONFIG_ACPI) || defined(CONFIG_OF) +static const struct ddr_pmu_platform_data cn10k_ddr_pmu_pdata =3D { + .counter_overflow_val =3D BIT_ULL(48), + .counter_max_val =3D GENMASK_ULL(48, 0), + .cnt_base =3D CN10K_DDRC_PERF_CNT_VALUE_BASE, + .cfg_base =3D CN10K_DDRC_PERF_CFG_BASE, + .cnt_op_mode_ctrl =3D CN10K_DDRC_PERF_CNT_OP_MODE_CTRL, + .cnt_start_op_ctrl =3D CN10K_DDRC_PERF_CNT_START_OP_CTRL, + .cnt_end_op_ctrl =3D CN10K_DDRC_PERF_CNT_END_OP_CTRL, + .cnt_end_status =3D CN10K_DDRC_PERF_CNT_END_STATUS, + .cnt_freerun_en =3D CN10K_DDRC_PERF_CNT_FREERUN_EN, + .cnt_freerun_ctrl =3D CN10K_DDRC_PERF_CNT_FREERUN_CTRL, + .cnt_freerun_clr =3D 0, + .cnt_value_wr_op =3D CN10K_DDRC_PERF_CNT_VALUE_WR_OP, + .cnt_value_rd_op =3D CN10K_DDRC_PERF_CNT_VALUE_RD_OP, + .is_cn10k =3D TRUE, +}; +#endif + static int cn10k_ddr_perf_probe(struct platform_device *pdev) { + const struct ddr_pmu_platform_data *dev_data; struct cn10k_ddr_pmu *ddr_pmu; struct resource *res; void __iomem *base; + bool is_cn10k; char *name; int ret; =20 @@ -644,30 +697,41 @@ static int cn10k_ddr_perf_probe(struct platform_devic= e *pdev) ddr_pmu->dev =3D &pdev->dev; platform_set_drvdata(pdev, ddr_pmu); =20 + dev_data =3D device_get_match_data(&pdev->dev); + if (!dev_data) { + dev_err(&pdev->dev, "Error: No device match data found\n"); + return -ENODEV; + } + base =3D devm_platform_get_and_ioremap_resource(pdev, 0, &res); if (IS_ERR(base)) return PTR_ERR(base); =20 ddr_pmu->base =3D base; =20 - /* Setup the PMU counter to work in manual mode */ - writeq_relaxed(OP_MODE_CTRL_VAL_MANNUAL, ddr_pmu->base + - DDRC_PERF_CNT_OP_MODE_CTRL); - - ddr_pmu->pmu =3D (struct pmu) { - .module =3D THIS_MODULE, - .capabilities =3D PERF_PMU_CAP_NO_EXCLUDE, - .task_ctx_nr =3D perf_invalid_context, - .attr_groups =3D cn10k_attr_groups, - .event_init =3D cn10k_ddr_perf_event_init, - .add =3D cn10k_ddr_perf_event_add, - .del =3D cn10k_ddr_perf_event_del, - .start =3D cn10k_ddr_perf_event_start, - .stop =3D cn10k_ddr_perf_event_stop, - .read =3D cn10k_ddr_perf_event_update, - .pmu_enable =3D cn10k_ddr_perf_pmu_enable, - .pmu_disable =3D cn10k_ddr_perf_pmu_disable, - }; + ddr_pmu->p_data =3D dev_data; + is_cn10k =3D ddr_pmu->p_data->is_cn10k; + + if (is_cn10k) { + /* Setup the PMU counter to work in manual mode */ + writeq_relaxed(OP_MODE_CTRL_VAL_MANNUAL, ddr_pmu->base + + ddr_pmu->p_data->cnt_op_mode_ctrl); + + ddr_pmu->pmu =3D (struct pmu) { + .module =3D THIS_MODULE, + .capabilities =3D PERF_PMU_CAP_NO_EXCLUDE, + .task_ctx_nr =3D perf_invalid_context, + .attr_groups =3D cn10k_attr_groups, + .event_init =3D cn10k_ddr_perf_event_init, + .add =3D cn10k_ddr_perf_event_add, + .del =3D cn10k_ddr_perf_event_del, + .start =3D cn10k_ddr_perf_event_start, + .stop =3D cn10k_ddr_perf_event_stop, + .read =3D cn10k_ddr_perf_event_update, + .pmu_enable =3D cn10k_ddr_perf_pmu_enable, + .pmu_disable =3D cn10k_ddr_perf_pmu_disable, + }; + } =20 /* Choose this cpu to collect perf data */ ddr_pmu->cpu =3D raw_smp_processor_id(); @@ -688,7 +752,7 @@ static int cn10k_ddr_perf_probe(struct platform_device = *pdev) if (ret) goto error; =20 - pr_info("CN10K DDR PMU Driver for ddrc@%llx\n", res->start); + pr_info("DDR PMU Driver for ddrc@%llx\n", res->start); return 0; error: cpuhp_state_remove_instance_nocalls( @@ -710,7 +774,7 @@ static void cn10k_ddr_perf_remove(struct platform_devic= e *pdev) =20 #ifdef CONFIG_OF static const struct of_device_id cn10k_ddr_pmu_of_match[] =3D { - { .compatible =3D "marvell,cn10k-ddr-pmu", }, + { .compatible =3D "marvell,cn10k-ddr-pmu", .data =3D &cn10k_ddr_pmu_pdata= }, { }, }; MODULE_DEVICE_TABLE(of, cn10k_ddr_pmu_of_match); @@ -718,7 +782,7 @@ MODULE_DEVICE_TABLE(of, cn10k_ddr_pmu_of_match); =20 #ifdef CONFIG_ACPI static const struct acpi_device_id cn10k_ddr_pmu_acpi_match[] =3D { - {"MRVL000A", 0}, + {"MRVL000A", (kernel_ulong_t)&cn10k_ddr_pmu_pdata }, {}, }; MODULE_DEVICE_TABLE(acpi, cn10k_ddr_pmu_acpi_match); --=20 2.25.1 From nobody Tue Nov 26 19:37:10 2024 Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) (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 8177C1D1724 for ; Wed, 16 Oct 2024 08:02:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.156.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729065767; cv=none; b=lgL2dlOhjMbDiGEm6Z8+YeexfriVmaFOOIxnhdTtFjxFErO4m2/YSaxRF9IFR+4ZIvous7txg5PyxJxN2Y3/6ErFtekFfUWOHB0PRkWxlSeUB/Q4niTSNYJDZHOBfNqLmEgaEPWXJwR8P0a9ZRhcNPt5HTLC3CMwYmdcKLJuH2o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729065767; c=relaxed/simple; bh=f73UcqI1xsrlchW3YDLrpd6COuVe4LITVXYvhFaylEc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jDYX8OI63+n1jvqFqSzcViV8Swk5OfMp6so1sRBPTQmP4CGTogSu2KN+FOKQ75gbHS23sfAqYvU+xFOVlVTgFEJpVStBZz0DU1CObHMLk2qZ0qyxa0jfJvhj4raR5wr63x666laz/BbX45lx5yBcbLdUCRGIY40CXndeam8VBQQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=pass smtp.mailfrom=marvell.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=ZC3ClbR/; arc=none smtp.client-ip=67.231.156.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="ZC3ClbR/" Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49G2fiNS021631; Wed, 16 Oct 2024 01:02:34 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=H 1xhiLDxda/rr99yyZNzRLZh8vxDZpgamSPq1Ju3iIQ=; b=ZC3ClbR/8fsJe4TyJ 6BCflVOfCCZnZCfj/b7PZc/h6HMSm2sa0Jjrom5Yeh4zwmpgmlCYANiEDyl6mFWH zhERf0zEzNTnboCpxZA12/8jmo8ZUPZBKCJdYaNEUpSlhXDqcoSMixlql6bMCUP0 kSFg6RmXPUlKOJV4rk/dwGWoz2a2RXNdfsf3lYee026hZn+O2yO5PRtSxVCHhpOt e+to9OsoPXXBA7by3lEL3nM7U6ruviYTnW0AhbHXhuPp1d7saA/70KxIeGoBq/e7 8URtdfTq2aYkUr24Ueidzw0WSxCwTPdpWNq1sBnF/Waie6chdmeZ4VZf/2vTQjSC j6RnA== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 42a4x4gfut-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 16 Oct 2024 01:02:31 -0700 (PDT) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 16 Oct 2024 01:02:18 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 16 Oct 2024 01:02:18 -0700 Received: from IPBU-BLR-SERVER1.marvell.com (IPBU-BLR-SERVER1.marvell.com [10.28.8.41]) by maili.marvell.com (Postfix) with ESMTP id CC09D3F7074; Wed, 16 Oct 2024 01:02:15 -0700 (PDT) From: Gowthami Thiagarajan To: , , , CC: , , , , Gowthami Thiagarajan Subject: [PATCH v9 2/5] perf/marvell: Refactor to extract platform specific ops - no functional change Date: Wed, 16 Oct 2024 13:31:50 +0530 Message-ID: <20241016080153.3546353-3-gthiagarajan@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241016080153.3546353-1-gthiagarajan@marvell.com> References: <20241016080153.3546353-1-gthiagarajan@marvell.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: pk-r2ySu9QoIMJ6PXiKZsMy-7FviW9Ux X-Proofpoint-ORIG-GUID: pk-r2ySu9QoIMJ6PXiKZsMy-7FviW9Ux X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 Content-Type: text/plain; charset="utf-8" This commit introduces a refactor to the Marvell DDR pmu driver, specifically targeting the extraction of ops (referred to as "pmu ops") from the existing driver. Signed-off-by: Gowthami Thiagarajan --- drivers/perf/marvell_cn10k_ddr_pmu.c | 105 +++++++++++++++++++++------ 1 file changed, 83 insertions(+), 22 deletions(-) diff --git a/drivers/perf/marvell_cn10k_ddr_pmu.c b/drivers/perf/marvell_cn= 10k_ddr_pmu.c index ed929102b53d..0b340540e175 100644 --- a/drivers/perf/marvell_cn10k_ddr_pmu.c +++ b/drivers/perf/marvell_cn10k_ddr_pmu.c @@ -127,6 +127,7 @@ struct cn10k_ddr_pmu { struct pmu pmu; void __iomem *base; const struct ddr_pmu_platform_data *p_data; + const struct ddr_pmu_ops *ops; unsigned int cpu; struct device *dev; int active_events; @@ -135,6 +136,16 @@ struct cn10k_ddr_pmu { struct hlist_node node; }; =20 +struct ddr_pmu_ops { + void (*enable_read_freerun_counter)(struct cn10k_ddr_pmu *pmu, + bool enable); + void (*enable_write_freerun_counter)(struct cn10k_ddr_pmu *pmu, + bool enable); + void (*clear_read_freerun_counter)(struct cn10k_ddr_pmu *pmu); + void (*clear_write_freerun_counter)(struct cn10k_ddr_pmu *pmu); + void (*pmu_overflow_handler)(struct cn10k_ddr_pmu *pmu, int evt_idx); +}; + #define to_cn10k_ddr_pmu(p) container_of(p, struct cn10k_ddr_pmu, pmu) =20 struct ddr_pmu_platform_data { @@ -375,6 +386,7 @@ static void cn10k_ddr_perf_counter_enable(struct cn10k_= ddr_pmu *pmu, int counter, bool enable) { const struct ddr_pmu_platform_data *p_data =3D pmu->p_data; + const struct ddr_pmu_ops *ops =3D pmu->ops; u32 reg; u64 val; =20 @@ -394,21 +406,10 @@ static void cn10k_ddr_perf_counter_enable(struct cn10= k_ddr_pmu *pmu, =20 writeq_relaxed(val, pmu->base + reg); } else { - val =3D readq_relaxed(pmu->base + - p_data->cnt_freerun_en); - if (enable) { - if (counter =3D=3D DDRC_PERF_READ_COUNTER_IDX) - val |=3D DDRC_PERF_FREERUN_READ_EN; - else - val |=3D DDRC_PERF_FREERUN_WRITE_EN; - } else { - if (counter =3D=3D DDRC_PERF_READ_COUNTER_IDX) - val &=3D ~DDRC_PERF_FREERUN_READ_EN; - else - val &=3D ~DDRC_PERF_FREERUN_WRITE_EN; - } - writeq_relaxed(val, pmu->base + - p_data->cnt_freerun_en); + if (counter =3D=3D DDRC_PERF_READ_COUNTER_IDX) + ops->enable_read_freerun_counter(pmu, enable); + else + ops->enable_write_freerun_counter(pmu, enable); } } =20 @@ -464,6 +465,7 @@ static int cn10k_ddr_perf_event_add(struct perf_event *= event, int flags) { struct cn10k_ddr_pmu *pmu =3D to_cn10k_ddr_pmu(event->pmu); const struct ddr_pmu_platform_data *p_data =3D pmu->p_data; + const struct ddr_pmu_ops *ops =3D pmu->ops; struct hw_perf_event *hwc =3D &event->hw; u8 config =3D event->attr.config; int counter, ret; @@ -492,11 +494,9 @@ static int cn10k_ddr_perf_event_add(struct perf_event = *event, int flags) } else { /* fixed event counter, clear counter value */ if (counter =3D=3D DDRC_PERF_READ_COUNTER_IDX) - val =3D DDRC_FREERUN_READ_CNT_CLR; + ops->clear_read_freerun_counter(pmu); else - val =3D DDRC_FREERUN_WRITE_CNT_CLR; - - writeq_relaxed(val, pmu->base + p_data->cnt_freerun_ctrl); + ops->clear_write_freerun_counter(pmu); } =20 hwc->state |=3D PERF_HES_STOPPED; @@ -578,9 +578,63 @@ static void cn10k_ddr_perf_event_update_all(struct cn1= 0k_ddr_pmu *pmu) } } =20 +static void ddr_pmu_enable_read_freerun(struct cn10k_ddr_pmu *pmu, bool en= able) +{ + const struct ddr_pmu_platform_data *p_data =3D pmu->p_data; + u64 val; + + val =3D readq_relaxed(pmu->base + p_data->cnt_freerun_en); + if (enable) + val |=3D DDRC_PERF_FREERUN_READ_EN; + else + val &=3D ~DDRC_PERF_FREERUN_READ_EN; + + writeq_relaxed(val, pmu->base + p_data->cnt_freerun_en); +} + +static void ddr_pmu_enable_write_freerun(struct cn10k_ddr_pmu *pmu, bool e= nable) +{ + const struct ddr_pmu_platform_data *p_data =3D pmu->p_data; + u64 val; + + val =3D readq_relaxed(pmu->base + p_data->cnt_freerun_en); + if (enable) + val |=3D DDRC_PERF_FREERUN_WRITE_EN; + else + val &=3D ~DDRC_PERF_FREERUN_WRITE_EN; + + writeq_relaxed(val, pmu->base + p_data->cnt_freerun_en); +} + +static void ddr_pmu_read_clear_freerun(struct cn10k_ddr_pmu *pmu) +{ + const struct ddr_pmu_platform_data *p_data =3D pmu->p_data; + u64 val; + + val =3D DDRC_FREERUN_READ_CNT_CLR; + writeq_relaxed(val, pmu->base + p_data->cnt_freerun_ctrl); +} + +static void ddr_pmu_write_clear_freerun(struct cn10k_ddr_pmu *pmu) +{ + const struct ddr_pmu_platform_data *p_data =3D pmu->p_data; + u64 val; + + val =3D DDRC_FREERUN_WRITE_CNT_CLR; + writeq_relaxed(val, pmu->base + p_data->cnt_freerun_ctrl); +} + +static void ddr_pmu_overflow_hander(struct cn10k_ddr_pmu *pmu, int evt_idx) +{ + cn10k_ddr_perf_event_update_all(pmu); + cn10k_ddr_perf_pmu_disable(&pmu->pmu); + cn10k_ddr_perf_pmu_enable(&pmu->pmu); +} + static irqreturn_t cn10k_ddr_pmu_overflow_handler(struct cn10k_ddr_pmu *pm= u) { const struct ddr_pmu_platform_data *p_data =3D pmu->p_data; + const struct ddr_pmu_ops *ops =3D pmu->ops; struct perf_event *event; struct hw_perf_event *hwc; u64 prev_count, new_count; @@ -620,9 +674,7 @@ static irqreturn_t cn10k_ddr_pmu_overflow_handler(struc= t cn10k_ddr_pmu *pmu) value =3D cn10k_ddr_perf_read_counter(pmu, i); if (value =3D=3D p_data->counter_max_val) { pr_info("Counter-(%d) reached max value\n", i); - cn10k_ddr_perf_event_update_all(pmu); - cn10k_ddr_perf_pmu_disable(&pmu->pmu); - cn10k_ddr_perf_pmu_enable(&pmu->pmu); + ops->pmu_overflow_handler(pmu, i); } } =20 @@ -661,6 +713,14 @@ static int cn10k_ddr_pmu_offline_cpu(unsigned int cpu,= struct hlist_node *node) return 0; } =20 +static const struct ddr_pmu_ops ddr_pmu_ops =3D { + .enable_read_freerun_counter =3D ddr_pmu_enable_read_freerun, + .enable_write_freerun_counter =3D ddr_pmu_enable_write_freerun, + .clear_read_freerun_counter =3D ddr_pmu_read_clear_freerun, + .clear_write_freerun_counter =3D ddr_pmu_write_clear_freerun, + .pmu_overflow_handler =3D ddr_pmu_overflow_hander, +}; + #if defined(CONFIG_ACPI) || defined(CONFIG_OF) static const struct ddr_pmu_platform_data cn10k_ddr_pmu_pdata =3D { .counter_overflow_val =3D BIT_ULL(48), @@ -713,6 +773,7 @@ static int cn10k_ddr_perf_probe(struct platform_device = *pdev) is_cn10k =3D ddr_pmu->p_data->is_cn10k; =20 if (is_cn10k) { + ddr_pmu->ops =3D &ddr_pmu_ops; /* Setup the PMU counter to work in manual mode */ writeq_relaxed(OP_MODE_CTRL_VAL_MANNUAL, ddr_pmu->base + ddr_pmu->p_data->cnt_op_mode_ctrl); --=20 2.25.1 From nobody Tue Nov 26 19:37:10 2024 Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) (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 8C7231B07D4 for ; Wed, 16 Oct 2024 08:02:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.156.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729065762; cv=none; b=uisSZJ9Wg7Y9gbPElUZrLvOeIiCH+/l8WzrVsDh7CuyQJDg5K15TXQLPYXeQkJ2jg8goCobXPGHMaqLK1hp+hZJc4NF4byjAN3HqIJvn8liafENZz8cIVHWQ5UxG4KXWB/HX/UZP6m97qG5HIYoz63a2qh3hViV3WvWXZMWDQms= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729065762; c=relaxed/simple; bh=9v0udjtGvpD8QKNy+q6MlqLB6l8YJfnZbaqIEHIaQc0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Qx4NqvK4HC9KLwFOU6RJQYtXDZLRB/sCo9PdyTd05g7JjzJWE+tLhELW6U3bW8yxoLtig3xc9BPxLa/bofkLTEIy9aW6jRUUkA6JpuTIDDoAJAYtA3vKyVYPjbZx3qtF4SNi4DFhzYaWigSj2XLByc4rwPXz06a9UmVlHpNtZ80= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=pass smtp.mailfrom=marvell.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=L8D0onFP; arc=none smtp.client-ip=67.231.156.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="L8D0onFP" Received: from pps.filterd (m0431383.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49G38QPa009190; Wed, 16 Oct 2024 01:02:23 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=p TJy/+mL5o/HUQzwqTZaFcFE66lHitToqrmmvCw2wzI=; b=L8D0onFP9dFmOO1UZ kyGPTKDY1kv8QR9TbPZBGdcwCfuXXCgjRVRa1Wmy4AzyXdZTaOCS0Whcn9YXqns7 VCB/uOKOZSxlblF99/NpRwrM4jOBw/CdIj+UK4yNNc/angyW6t4KeOV6vXrUVfzS WT3i1LWLSIQR38bYkrCdMMHXEnDv5SmTJO68+0ta8PN53h0STRtXlrDwm3WuxqRQ XEAYnZw7S3hZ2gwkwqd9AlR++iTif6skz9WTywhf8ndESLi8EgZLPB5O/Gz5MinI Ym/X6+BPZCQ4r94Z89mgm8GTFHkejoaLTit7SHHA+JzUd0v1gG6aUu2HDAdgQd7z 1bxhA== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 42a5ahre3m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 16 Oct 2024 01:02:23 -0700 (PDT) Received: from DC6WP-EXCH02.marvell.com (10.76.176.209) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 16 Oct 2024 01:02:22 -0700 Received: from maili.marvell.com (10.69.176.80) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 16 Oct 2024 01:02:22 -0700 Received: from IPBU-BLR-SERVER1.marvell.com (IPBU-BLR-SERVER1.marvell.com [10.28.8.41]) by maili.marvell.com (Postfix) with ESMTP id E4C623F706F; Wed, 16 Oct 2024 01:02:19 -0700 (PDT) From: Gowthami Thiagarajan To: , , , CC: , , , , Gowthami Thiagarajan Subject: [PATCH v9 3/5] perf/marvell: Odyssey DDR Performance monitor support Date: Wed, 16 Oct 2024 13:31:51 +0530 Message-ID: <20241016080153.3546353-4-gthiagarajan@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241016080153.3546353-1-gthiagarajan@marvell.com> References: <20241016080153.3546353-1-gthiagarajan@marvell.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: R9_ikPGHOsyLKa2cz-LolCZ9L3_kTGu_ X-Proofpoint-ORIG-GUID: R9_ikPGHOsyLKa2cz-LolCZ9L3_kTGu_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.687,Hydra:6.0.235,FMLib:17.0.607.475 definitions=2020-10-13_15,2020-10-13_02,2020-04-07_01 Content-Type: text/plain; charset="utf-8" Odyssey DRAM Subsystem supports eight counters for monitoring performance and software can program those counters to monitor any of the defined performance events. Supported performance events include those counted at the interface between the DDR controller and the PHY, interface between the DDR Controller and the CHI interconnect, or within the DDR Controller. Additionally DSS also supports two fixed performance event counters, one for ddr reads and the other for ddr writes. Signed-off-by: Gowthami Thiagarajan --- Documentation/admin-guide/perf/index.rst | 1 + .../admin-guide/perf/mrvl-odyssey-ddr-pmu.rst | 80 ++++++ drivers/perf/marvell_cn10k_ddr_pmu.c | 261 +++++++++++++++++- 3 files changed, 339 insertions(+), 3 deletions(-) create mode 100644 Documentation/admin-guide/perf/mrvl-odyssey-ddr-pmu.rst diff --git a/Documentation/admin-guide/perf/index.rst b/Documentation/admin= -guide/perf/index.rst index 8502bc174640..f9be610b2e6d 100644 --- a/Documentation/admin-guide/perf/index.rst +++ b/Documentation/admin-guide/perf/index.rst @@ -14,6 +14,7 @@ Performance monitor support qcom_l2_pmu qcom_l3_pmu starfive_starlink_pmu + mrvl-odyssey-ddr-pmu arm-ccn arm-cmn arm-ni diff --git a/Documentation/admin-guide/perf/mrvl-odyssey-ddr-pmu.rst b/Docu= mentation/admin-guide/perf/mrvl-odyssey-ddr-pmu.rst new file mode 100644 index 000000000000..2e817593a4d9 --- /dev/null +++ b/Documentation/admin-guide/perf/mrvl-odyssey-ddr-pmu.rst @@ -0,0 +1,80 @@ +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Marvell Odyssey DDR PMU Performance Monitoring Unit (PMU UNCORE) +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Odyssey DRAM Subsystem supports eight counters for monitoring performance +and software can program those counters to monitor any of the defined +performance events. Supported performance events include those counted +at the interface between the DDR controller and the PHY, interface between +the DDR Controller and the CHI interconnect, or within the DDR Controller. + +Additionally DSS also supports two fixed performance event counters, one +for ddr reads and the other for ddr writes. + +The counter will be operating in either manual or auto mode. + +The PMU driver exposes the available events and format options under sysfs= :: + + /sys/bus/event_source/devices/mrvl_ddr_pmu_<>/events/ + /sys/bus/event_source/devices/mrvl_ddr_pmu_<>/format/ + +Examples:: + + $ perf list | grep ddr + mrvl_ddr_pmu_<>/ddr_act_bypass_access/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_bsm_alloc/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_bsm_starvation/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_cam_active_access/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_cam_mwr/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_cam_rd_active_access/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_cam_rd_or_wr_access/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_cam_read/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_cam_wr_access/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_cam_write/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_capar_error/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_crit_ref/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_ddr_reads/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_ddr_writes/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_dfi_cmd_is_retry/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_dfi_cycles/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_dfi_parity_poison/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_dfi_rd_data_access/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_dfi_wr_data_access/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_dqsosc_mpc/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_dqsosc_mrr/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_enter_mpsm/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_enter_powerdown/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_enter_selfref/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_hif_pri_rdaccess/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_hif_rd_access/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_hif_rd_or_wr_access/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_hif_rmw_access/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_hif_wr_access/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_hpri_sched_rd_crit_access/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_load_mode/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_lpri_sched_rd_crit_access/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_precharge/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_precharge_for_other/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_precharge_for_rdwr/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_raw_hazard/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_rd_bypass_access/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_rd_crc_error/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_rd_uc_ecc_error/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_rdwr_transitions/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_refresh/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_retry_fifo_full/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_spec_ref/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_tcr_mrr/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_war_hazard/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_waw_hazard/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_win_limit_reached_rd/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_win_limit_reached_wr/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_wr_crc_error/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_wr_trxn_crit_access/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_write_combine/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_zqcl/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_zqlatch/ [Kernel PMU event] + mrvl_ddr_pmu_<>/ddr_zqstart/ [Kernel PMU event] + + $ perf stat -e ddr_cam_read,ddr_cam_write,ddr_cam_active_access,dd= r_cam + rd_or_wr_access,ddr_cam_rd_active_access,ddr_cam_mwr diff --git a/drivers/perf/marvell_cn10k_ddr_pmu.c b/drivers/perf/marvell_cn= 10k_ddr_pmu.c index 0b340540e175..80574dcd2554 100644 --- a/drivers/perf/marvell_cn10k_ddr_pmu.c +++ b/drivers/perf/marvell_cn10k_ddr_pmu.c @@ -16,23 +16,28 @@ =20 /* Performance Counters Operating Mode Control Registers */ #define CN10K_DDRC_PERF_CNT_OP_MODE_CTRL 0x8020 +#define ODY_DDRC_PERF_CNT_OP_MODE_CTRL 0x20020 #define OP_MODE_CTRL_VAL_MANNUAL 0x1 =20 /* Performance Counters Start Operation Control Registers */ #define CN10K_DDRC_PERF_CNT_START_OP_CTRL 0x8028 +#define ODY_DDRC_PERF_CNT_START_OP_CTRL 0x200A0 #define START_OP_CTRL_VAL_START 0x1ULL #define START_OP_CTRL_VAL_ACTIVE 0x2 =20 /* Performance Counters End Operation Control Registers */ #define CN10K_DDRC_PERF_CNT_END_OP_CTRL 0x8030 +#define ODY_DDRC_PERF_CNT_END_OP_CTRL 0x200E0 #define END_OP_CTRL_VAL_END 0x1ULL =20 /* Performance Counters End Status Registers */ #define CN10K_DDRC_PERF_CNT_END_STATUS 0x8038 +#define ODY_DDRC_PERF_CNT_END_STATUS 0x20120 #define END_STATUS_VAL_END_TIMER_MODE_END 0x1 =20 /* Performance Counters Configuration Registers */ #define CN10K_DDRC_PERF_CFG_BASE 0x8040 +#define ODY_DDRC_PERF_CFG_BASE 0x20160 =20 /* 8 Generic event counter + 2 fixed event counters */ #define DDRC_PERF_NUM_GEN_COUNTERS 8 @@ -56,6 +61,15 @@ * DO NOT change these event-id numbers, they are used to * program event bitmap in h/w. */ +#define EVENT_DFI_CMD_IS_RETRY 61 +#define EVENT_RD_UC_ECC_ERROR 60 +#define EVENT_RD_CRC_ERROR 59 +#define EVENT_CAPAR_ERROR 58 +#define EVENT_WR_CRC_ERROR 57 +#define EVENT_DFI_PARITY_POISON 56 +#define EVENT_RETRY_FIFO_FULL 46 +#define EVENT_DFI_CYCLES 45 + #define EVENT_OP_IS_ZQLATCH 55 #define EVENT_OP_IS_ZQSTART 54 #define EVENT_OP_IS_TCR_MRR 53 @@ -105,6 +119,7 @@ =20 /* Event counter value registers */ #define CN10K_DDRC_PERF_CNT_VALUE_BASE 0x8080 +#define ODY_DDRC_PERF_CNT_VALUE_BASE 0x201C0 =20 /* Fixed event counter enable/disable register */ #define CN10K_DDRC_PERF_CNT_FREERUN_EN 0x80C0 @@ -113,15 +128,21 @@ =20 /* Fixed event counter control register */ #define CN10K_DDRC_PERF_CNT_FREERUN_CTRL 0x80C8 +#define ODY_DDRC_PERF_CNT_FREERUN_CTRL 0x20240 #define DDRC_FREERUN_WRITE_CNT_CLR 0x1 #define DDRC_FREERUN_READ_CNT_CLR 0x2 =20 +/* Fixed event counter clear register, defined only for Odyssey */ +#define ODY_DDRC_PERF_CNT_FREERUN_CLR 0x20248 + #define DDRC_PERF_CNT_VALUE_OVERFLOW BIT_ULL(48) #define DDRC_PERF_CNT_MAX_VALUE GENMASK_ULL(48, 0) =20 /* Fixed event counter value register */ #define CN10K_DDRC_PERF_CNT_VALUE_WR_OP 0x80D0 #define CN10K_DDRC_PERF_CNT_VALUE_RD_OP 0x80D8 +#define ODY_DDRC_PERF_CNT_VALUE_WR_OP 0x20250 +#define ODY_DDRC_PERF_CNT_VALUE_RD_OP 0x20258 =20 struct cn10k_ddr_pmu { struct pmu pmu; @@ -163,6 +184,7 @@ struct ddr_pmu_platform_data { u64 cnt_value_wr_op; u64 cnt_value_rd_op; bool is_cn10k; + bool is_ody; }; =20 static ssize_t cn10k_ddr_pmu_event_show(struct device *dev, @@ -240,6 +262,85 @@ static struct attribute *cn10k_ddr_perf_events_attrs[]= =3D { NULL }; =20 +static struct attribute *odyssey_ddr_perf_events_attrs[] =3D { + /* Programmable */ + CN10K_DDR_PMU_EVENT_ATTR(ddr_hif_rd_or_wr_access, EVENT_HIF_RD_OR_WR), + CN10K_DDR_PMU_EVENT_ATTR(ddr_hif_wr_access, EVENT_HIF_WR), + CN10K_DDR_PMU_EVENT_ATTR(ddr_hif_rd_access, EVENT_HIF_RD), + CN10K_DDR_PMU_EVENT_ATTR(ddr_hif_rmw_access, EVENT_HIF_RMW), + CN10K_DDR_PMU_EVENT_ATTR(ddr_hif_pri_rdaccess, EVENT_HIF_HI_PRI_RD), + CN10K_DDR_PMU_EVENT_ATTR(ddr_rd_bypass_access, EVENT_READ_BYPASS), + CN10K_DDR_PMU_EVENT_ATTR(ddr_act_bypass_access, EVENT_ACT_BYPASS), + CN10K_DDR_PMU_EVENT_ATTR(ddr_dfi_wr_data_access, + EVENT_DFI_WR_DATA_CYCLES), + CN10K_DDR_PMU_EVENT_ATTR(ddr_dfi_rd_data_access, + EVENT_DFI_RD_DATA_CYCLES), + CN10K_DDR_PMU_EVENT_ATTR(ddr_hpri_sched_rd_crit_access, + EVENT_HPR_XACT_WHEN_CRITICAL), + CN10K_DDR_PMU_EVENT_ATTR(ddr_lpri_sched_rd_crit_access, + EVENT_LPR_XACT_WHEN_CRITICAL), + CN10K_DDR_PMU_EVENT_ATTR(ddr_wr_trxn_crit_access, + EVENT_WR_XACT_WHEN_CRITICAL), + CN10K_DDR_PMU_EVENT_ATTR(ddr_cam_active_access, EVENT_OP_IS_ACTIVATE), + CN10K_DDR_PMU_EVENT_ATTR(ddr_cam_rd_or_wr_access, + EVENT_OP_IS_RD_OR_WR), + CN10K_DDR_PMU_EVENT_ATTR(ddr_cam_rd_active_access, + EVENT_OP_IS_RD_ACTIVATE), + CN10K_DDR_PMU_EVENT_ATTR(ddr_cam_read, EVENT_OP_IS_RD), + CN10K_DDR_PMU_EVENT_ATTR(ddr_cam_write, EVENT_OP_IS_WR), + CN10K_DDR_PMU_EVENT_ATTR(ddr_cam_mwr, EVENT_OP_IS_MWR), + CN10K_DDR_PMU_EVENT_ATTR(ddr_precharge, EVENT_OP_IS_PRECHARGE), + CN10K_DDR_PMU_EVENT_ATTR(ddr_precharge_for_rdwr, + EVENT_PRECHARGE_FOR_RDWR), + CN10K_DDR_PMU_EVENT_ATTR(ddr_precharge_for_other, + EVENT_PRECHARGE_FOR_OTHER), + CN10K_DDR_PMU_EVENT_ATTR(ddr_rdwr_transitions, EVENT_RDWR_TRANSITIONS), + CN10K_DDR_PMU_EVENT_ATTR(ddr_write_combine, EVENT_WRITE_COMBINE), + CN10K_DDR_PMU_EVENT_ATTR(ddr_war_hazard, EVENT_WAR_HAZARD), + CN10K_DDR_PMU_EVENT_ATTR(ddr_raw_hazard, EVENT_RAW_HAZARD), + CN10K_DDR_PMU_EVENT_ATTR(ddr_waw_hazard, EVENT_WAW_HAZARD), + CN10K_DDR_PMU_EVENT_ATTR(ddr_enter_selfref, EVENT_OP_IS_ENTER_SELFREF), + CN10K_DDR_PMU_EVENT_ATTR(ddr_enter_powerdown, + EVENT_OP_IS_ENTER_POWERDOWN), + CN10K_DDR_PMU_EVENT_ATTR(ddr_enter_mpsm, EVENT_OP_IS_ENTER_MPSM), + CN10K_DDR_PMU_EVENT_ATTR(ddr_refresh, EVENT_OP_IS_REFRESH), + CN10K_DDR_PMU_EVENT_ATTR(ddr_crit_ref, EVENT_OP_IS_CRIT_REF), + CN10K_DDR_PMU_EVENT_ATTR(ddr_spec_ref, EVENT_OP_IS_SPEC_REF), + CN10K_DDR_PMU_EVENT_ATTR(ddr_load_mode, EVENT_OP_IS_LOAD_MODE), + CN10K_DDR_PMU_EVENT_ATTR(ddr_zqcl, EVENT_OP_IS_ZQCL), + CN10K_DDR_PMU_EVENT_ATTR(ddr_cam_wr_access, EVENT_OP_IS_ZQCS), + CN10K_DDR_PMU_EVENT_ATTR(ddr_dfi_cycles, EVENT_DFI_CYCLES), + CN10K_DDR_PMU_EVENT_ATTR(ddr_retry_fifo_full, + EVENT_RETRY_FIFO_FULL), + CN10K_DDR_PMU_EVENT_ATTR(ddr_bsm_alloc, EVENT_BSM_ALLOC), + CN10K_DDR_PMU_EVENT_ATTR(ddr_bsm_starvation, EVENT_BSM_STARVATION), + CN10K_DDR_PMU_EVENT_ATTR(ddr_win_limit_reached_rd, + EVENT_VISIBLE_WIN_LIMIT_REACHED_RD), + CN10K_DDR_PMU_EVENT_ATTR(ddr_win_limit_reached_wr, + EVENT_VISIBLE_WIN_LIMIT_REACHED_WR), + CN10K_DDR_PMU_EVENT_ATTR(ddr_dqsosc_mpc, EVENT_OP_IS_DQSOSC_MPC), + CN10K_DDR_PMU_EVENT_ATTR(ddr_dqsosc_mrr, EVENT_OP_IS_DQSOSC_MRR), + CN10K_DDR_PMU_EVENT_ATTR(ddr_tcr_mrr, EVENT_OP_IS_TCR_MRR), + CN10K_DDR_PMU_EVENT_ATTR(ddr_zqstart, EVENT_OP_IS_ZQSTART), + CN10K_DDR_PMU_EVENT_ATTR(ddr_zqlatch, EVENT_OP_IS_ZQLATCH), + CN10K_DDR_PMU_EVENT_ATTR(ddr_dfi_parity_poison, + EVENT_DFI_PARITY_POISON), + CN10K_DDR_PMU_EVENT_ATTR(ddr_wr_crc_error, EVENT_WR_CRC_ERROR), + CN10K_DDR_PMU_EVENT_ATTR(ddr_capar_error, EVENT_CAPAR_ERROR), + CN10K_DDR_PMU_EVENT_ATTR(ddr_rd_crc_error, EVENT_RD_CRC_ERROR), + CN10K_DDR_PMU_EVENT_ATTR(ddr_rd_uc_ecc_error, EVENT_RD_UC_ECC_ERROR), + CN10K_DDR_PMU_EVENT_ATTR(ddr_dfi_cmd_is_retry, EVENT_DFI_CMD_IS_RETRY), + /* Free run event counters */ + CN10K_DDR_PMU_EVENT_ATTR(ddr_ddr_reads, EVENT_DDR_READS), + CN10K_DDR_PMU_EVENT_ATTR(ddr_ddr_writes, EVENT_DDR_WRITES), + NULL +}; + +static struct attribute_group odyssey_ddr_perf_events_attr_group =3D { + .name =3D "events", + .attrs =3D odyssey_ddr_perf_events_attrs, +}; + static struct attribute_group cn10k_ddr_perf_events_attr_group =3D { .name =3D "events", .attrs =3D cn10k_ddr_perf_events_attrs, @@ -285,6 +386,13 @@ static const struct attribute_group *cn10k_attr_groups= [] =3D { NULL, }; =20 +static const struct attribute_group *odyssey_attr_groups[] =3D { + &odyssey_ddr_perf_events_attr_group, + &cn10k_ddr_perf_format_attr_group, + &cn10k_ddr_perf_cpumask_attr_group, + NULL +}; + /* Default poll timeout is 100 sec, which is very sufficient for * 48 bit counter incremented max at 5.6 GT/s, which may take many * hours to overflow. @@ -297,20 +405,27 @@ static ktime_t cn10k_ddr_pmu_timer_period(void) return ms_to_ktime((u64)cn10k_ddr_pmu_poll_period_sec * USEC_PER_SEC); } =20 -static int ddr_perf_get_event_bitmap(int eventid, u64 *event_bitmap) +static int ddr_perf_get_event_bitmap(int eventid, u64 *event_bitmap, + struct cn10k_ddr_pmu *ddr_pmu) { switch (eventid) { case EVENT_HIF_RD_OR_WR ... EVENT_WAW_HAZARD: case EVENT_OP_IS_REFRESH ... EVENT_OP_IS_ZQLATCH: *event_bitmap =3D (1ULL << (eventid - 1)); break; + case EVENT_DFI_PARITY_POISON ...EVENT_DFI_CMD_IS_RETRY: + if (ddr_pmu->p_data->is_ody) + *event_bitmap =3D (1ULL << (eventid - 1)); + else + goto err; + break; case EVENT_OP_IS_ENTER_SELFREF: case EVENT_OP_IS_ENTER_POWERDOWN: case EVENT_OP_IS_ENTER_MPSM: *event_bitmap =3D (0xFULL << (eventid - 1)); break; default: - pr_err("%s Invalid eventid %d\n", __func__, eventid); +err: pr_err("%s Invalid eventid %d\n", __func__, eventid); return -EINVAL; } =20 @@ -448,15 +563,44 @@ static void cn10k_ddr_perf_event_update(struct perf_e= vent *event) local64_add((new_count - prev_count) & mask, &event->count); } =20 +static void cn10k_ddr_perf_counter_start(struct cn10k_ddr_pmu *ddr_pmu, + int counter) +{ + const struct ddr_pmu_platform_data *p_data =3D ddr_pmu->p_data; + u64 ctrl_reg =3D p_data->cnt_start_op_ctrl; + + writeq_relaxed(START_OP_CTRL_VAL_START, ddr_pmu->base + + DDRC_PERF_REG(ctrl_reg, counter)); +} + +static void cn10k_ddr_perf_counter_stop(struct cn10k_ddr_pmu *ddr_pmu, + int counter) +{ + const struct ddr_pmu_platform_data *p_data =3D ddr_pmu->p_data; + u64 ctrl_reg =3D p_data->cnt_end_op_ctrl; + + writeq_relaxed(END_OP_CTRL_VAL_END, ddr_pmu->base + + DDRC_PERF_REG(ctrl_reg, counter)); +} + static void cn10k_ddr_perf_event_start(struct perf_event *event, int flags) { struct cn10k_ddr_pmu *pmu =3D to_cn10k_ddr_pmu(event->pmu); + u64 ctrl_reg =3D pmu->p_data->cnt_op_mode_ctrl; struct hw_perf_event *hwc =3D &event->hw; + bool is_ody =3D pmu->p_data->is_ody; int counter =3D hwc->idx; =20 local64_set(&hwc->prev_count, 0); =20 cn10k_ddr_perf_counter_enable(pmu, counter, true); + if (is_ody) { + /* Setup the PMU counter to work in manual mode */ + writeq_relaxed(OP_MODE_CTRL_VAL_MANNUAL, pmu->base + + DDRC_PERF_REG(ctrl_reg, counter)); + + cn10k_ddr_perf_counter_start(pmu, counter); + } =20 hwc->state =3D 0; } @@ -486,7 +630,7 @@ static int cn10k_ddr_perf_event_add(struct perf_event *= event, int flags) if (counter < DDRC_PERF_NUM_GEN_COUNTERS) { /* Generic counters, configure event id */ reg_offset =3D DDRC_PERF_CFG(p_data->cfg_base, counter); - ret =3D ddr_perf_get_event_bitmap(config, &val); + ret =3D ddr_perf_get_event_bitmap(config, &val, pmu); if (ret) return ret; =20 @@ -511,10 +655,14 @@ static void cn10k_ddr_perf_event_stop(struct perf_eve= nt *event, int flags) { struct cn10k_ddr_pmu *pmu =3D to_cn10k_ddr_pmu(event->pmu); struct hw_perf_event *hwc =3D &event->hw; + bool is_ody =3D pmu->p_data->is_ody; int counter =3D hwc->idx; =20 cn10k_ddr_perf_counter_enable(pmu, counter, false); =20 + if (is_ody) + cn10k_ddr_perf_counter_stop(pmu, counter); + if (flags & PERF_EF_UPDATE) cn10k_ddr_perf_event_update(event); =20 @@ -631,6 +779,66 @@ static void ddr_pmu_overflow_hander(struct cn10k_ddr_p= mu *pmu, int evt_idx) cn10k_ddr_perf_pmu_enable(&pmu->pmu); } =20 +static void ddr_pmu_ody_enable_read_freerun(struct cn10k_ddr_pmu *pmu, + bool enable) +{ + const struct ddr_pmu_platform_data *p_data =3D pmu->p_data; + u64 val; + + val =3D readq_relaxed(pmu->base + p_data->cnt_freerun_ctrl); + if (enable) + val |=3D DDRC_PERF_FREERUN_READ_EN; + else + val &=3D ~DDRC_PERF_FREERUN_READ_EN; + + writeq_relaxed(val, pmu->base + p_data->cnt_freerun_ctrl); +} + +static void ddr_pmu_ody_enable_write_freerun(struct cn10k_ddr_pmu *pmu, + bool enable) +{ + const struct ddr_pmu_platform_data *p_data =3D pmu->p_data; + u64 val; + + val =3D readq_relaxed(pmu->base + p_data->cnt_freerun_ctrl); + if (enable) + val |=3D DDRC_PERF_FREERUN_WRITE_EN; + else + val &=3D ~DDRC_PERF_FREERUN_WRITE_EN; + + writeq_relaxed(val, pmu->base + p_data->cnt_freerun_ctrl); +} + +static void ddr_pmu_ody_read_clear_freerun(struct cn10k_ddr_pmu *pmu) +{ + const struct ddr_pmu_platform_data *p_data =3D pmu->p_data; + u64 val; + + val =3D DDRC_FREERUN_READ_CNT_CLR; + writeq_relaxed(val, pmu->base + p_data->cnt_freerun_clr); +} + +static void ddr_pmu_ody_write_clear_freerun(struct cn10k_ddr_pmu *pmu) +{ + const struct ddr_pmu_platform_data *p_data =3D pmu->p_data; + u64 val; + + val =3D DDRC_FREERUN_WRITE_CNT_CLR; + writeq_relaxed(val, pmu->base + p_data->cnt_freerun_clr); +} + +static void ddr_pmu_ody_overflow_hander(struct cn10k_ddr_pmu *pmu, int evt= _idx) +{ + /* + * On reaching the maximum value of the counter, the counter freezes + * there. The particular event is updated and the respective counter + * is stopped and started again so that it starts counting from zero + */ + cn10k_ddr_perf_event_update(pmu->events[evt_idx]); + cn10k_ddr_perf_counter_stop(pmu, evt_idx); + cn10k_ddr_perf_counter_start(pmu, evt_idx); +} + static irqreturn_t cn10k_ddr_pmu_overflow_handler(struct cn10k_ddr_pmu *pm= u) { const struct ddr_pmu_platform_data *p_data =3D pmu->p_data; @@ -740,6 +948,33 @@ static const struct ddr_pmu_platform_data cn10k_ddr_pm= u_pdata =3D { }; #endif =20 +static const struct ddr_pmu_ops ddr_pmu_ody_ops =3D { + .enable_read_freerun_counter =3D ddr_pmu_ody_enable_read_freerun, + .enable_write_freerun_counter =3D ddr_pmu_ody_enable_write_freerun, + .clear_read_freerun_counter =3D ddr_pmu_ody_read_clear_freerun, + .clear_write_freerun_counter =3D ddr_pmu_ody_write_clear_freerun, + .pmu_overflow_handler =3D ddr_pmu_ody_overflow_hander, +}; + +#ifdef CONFIG_ACPI +static const struct ddr_pmu_platform_data odyssey_ddr_pmu_pdata =3D { + .counter_overflow_val =3D 0, + .counter_max_val =3D GENMASK_ULL(63, 0), + .cnt_base =3D ODY_DDRC_PERF_CNT_VALUE_BASE, + .cfg_base =3D ODY_DDRC_PERF_CFG_BASE, + .cnt_op_mode_ctrl =3D ODY_DDRC_PERF_CNT_OP_MODE_CTRL, + .cnt_start_op_ctrl =3D ODY_DDRC_PERF_CNT_START_OP_CTRL, + .cnt_end_op_ctrl =3D ODY_DDRC_PERF_CNT_END_OP_CTRL, + .cnt_end_status =3D ODY_DDRC_PERF_CNT_END_STATUS, + .cnt_freerun_en =3D 0, + .cnt_freerun_ctrl =3D ODY_DDRC_PERF_CNT_FREERUN_CTRL, + .cnt_freerun_clr =3D ODY_DDRC_PERF_CNT_FREERUN_CLR, + .cnt_value_wr_op =3D ODY_DDRC_PERF_CNT_VALUE_WR_OP, + .cnt_value_rd_op =3D ODY_DDRC_PERF_CNT_VALUE_RD_OP, + .is_ody =3D TRUE, +}; +#endif + static int cn10k_ddr_perf_probe(struct platform_device *pdev) { const struct ddr_pmu_platform_data *dev_data; @@ -747,6 +982,7 @@ static int cn10k_ddr_perf_probe(struct platform_device = *pdev) struct resource *res; void __iomem *base; bool is_cn10k; + bool is_ody; char *name; int ret; =20 @@ -771,6 +1007,7 @@ static int cn10k_ddr_perf_probe(struct platform_device= *pdev) =20 ddr_pmu->p_data =3D dev_data; is_cn10k =3D ddr_pmu->p_data->is_cn10k; + is_ody =3D ddr_pmu->p_data->is_ody; =20 if (is_cn10k) { ddr_pmu->ops =3D &ddr_pmu_ops; @@ -794,6 +1031,23 @@ static int cn10k_ddr_perf_probe(struct platform_devic= e *pdev) }; } =20 + if (is_ody) { + ddr_pmu->ops =3D &ddr_pmu_ody_ops; + + ddr_pmu->pmu =3D (struct pmu) { + .module =3D THIS_MODULE, + .capabilities =3D PERF_PMU_CAP_NO_EXCLUDE, + .task_ctx_nr =3D perf_invalid_context, + .attr_groups =3D odyssey_attr_groups, + .event_init =3D cn10k_ddr_perf_event_init, + .add =3D cn10k_ddr_perf_event_add, + .del =3D cn10k_ddr_perf_event_del, + .start =3D cn10k_ddr_perf_event_start, + .stop =3D cn10k_ddr_perf_event_stop, + .read =3D cn10k_ddr_perf_event_update, + }; + } + /* Choose this cpu to collect perf data */ ddr_pmu->cpu =3D raw_smp_processor_id(); =20 @@ -844,6 +1098,7 @@ MODULE_DEVICE_TABLE(of, cn10k_ddr_pmu_of_match); #ifdef CONFIG_ACPI static const struct acpi_device_id cn10k_ddr_pmu_acpi_match[] =3D { {"MRVL000A", (kernel_ulong_t)&cn10k_ddr_pmu_pdata }, + {"MRVL000C", (kernel_ulong_t)&odyssey_ddr_pmu_pdata}, {}, }; MODULE_DEVICE_TABLE(acpi, cn10k_ddr_pmu_acpi_match); --=20 2.25.1 From nobody Tue Nov 26 19:37:10 2024 Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) (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 423621D14E3 for ; Wed, 16 Oct 2024 08:02:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.156.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729065766; cv=none; b=B8/hJXfxnGjiu+X7pR1wvkLwUv3IGzyrv1icJdrQA/uuf/7mKuiUqABXdrXRrA918SwhbPrChetkI5qrEK5qr1ERtlIrs9FPT44H2TT7uEa1NZhLlVOh+FRQ9r7eZRjgyhJbH/aZIop0jBztStiQcM0e5B4AOCIcEMmW1fcEDdQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729065766; c=relaxed/simple; bh=MJyHgPPd/wjGZ3tiKzDqqqplfT19M+mdXcR2gOceW2w=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XRrQEWQn9Yl8429CWJ+nGAgDFL5zIu06zYFFIQDbz3T7ympIvDc57H58VQkEmb62w14ZYZ5y3I5TQKJ1yL/1hRro+5d889gq2DL2jNJduA09ZDdfesWvao5taT7lAMz19R3YarzxlzKDCPICJdbcGuDE5RHbsEqdMcsI979FLvo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=pass smtp.mailfrom=marvell.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=D4lTEiIC; arc=none smtp.client-ip=67.231.156.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="D4lTEiIC" Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49G2fiJY021630; Wed, 16 Oct 2024 01:02:28 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=s p78n+b6k2d5MDNfJaWsTjrFl1pMA438IW72EystjvU=; b=D4lTEiICi4uU3/yQY peqbQIkv6zZUCc+1dA2inx5EDwkXvmQJyX93Syy5HWjxofdbrKpmvWG54880/pGu gx8O4gtUv1zfh6LIG3Ka2nl188Rod2be9L6YS2b556m06ZXxC9D4jSYI9VuesaI9 1md4skwbmfWJLyFMHtoMuwUAoIcW4Ptxe3CR2mdYHdfMhEnoZD6EZxhJWDdIq5QW 0OzOu/pKhLn1D6wnfn9qPC0NXhiU5o3pP0TrzCtm3V4tR/qjYwgj3jlZGMZ30AEa MQOts8tsCrzahmzlAQfBGQv6RIEM63Se3taLJqcbBN/ucDhBGP/kGaGAHLCc9kOO 6//yg== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 42a4x4gfv8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 16 Oct 2024 01:02:27 -0700 (PDT) Received: from DC6WP-EXCH02.marvell.com (10.76.176.209) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 16 Oct 2024 01:02:27 -0700 Received: from maili.marvell.com (10.69.176.80) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 16 Oct 2024 01:02:26 -0700 Received: from IPBU-BLR-SERVER1.marvell.com (IPBU-BLR-SERVER1.marvell.com [10.28.8.41]) by maili.marvell.com (Postfix) with ESMTP id 120273F706F; Wed, 16 Oct 2024 01:02:23 -0700 (PDT) From: Gowthami Thiagarajan To: , , , CC: , , , , Gowthami Thiagarajan Subject: [PATCH v9 4/5] perf/marvell : Refactor to extract platform data - no functional change Date: Wed, 16 Oct 2024 13:31:52 +0530 Message-ID: <20241016080153.3546353-5-gthiagarajan@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241016080153.3546353-1-gthiagarajan@marvell.com> References: <20241016080153.3546353-1-gthiagarajan@marvell.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: -bBleqVoOzJZXOBuazuJmj7OiF9uGG0q X-Proofpoint-ORIG-GUID: -bBleqVoOzJZXOBuazuJmj7OiF9uGG0q X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 Content-Type: text/plain; charset="utf-8" This commit introduces a refactor to the Marvell TAD PMU driver specifically to add versioning to the existing driver. No functional changes are introduced; the behavior and performance of the driver remain unchanged. Signed-off-by: Gowthami Thiagarajan --- drivers/perf/marvell_cn10k_tad_pmu.c | 31 +++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/drivers/perf/marvell_cn10k_tad_pmu.c b/drivers/perf/marvell_cn= 10k_tad_pmu.c index 9e635f355470..15f9f67cb3bd 100644 --- a/drivers/perf/marvell_cn10k_tad_pmu.c +++ b/drivers/perf/marvell_cn10k_tad_pmu.c @@ -37,6 +37,14 @@ struct tad_pmu { DECLARE_BITMAP(counters_map, TAD_MAX_COUNTERS); }; =20 +enum mrvl_tad_pmu_version { + TAD_PMU_V1 =3D 1, +}; + +struct tad_pmu_data { + int id; +}; + static int tad_pmu_cpuhp_state; =20 static void tad_pmu_event_counter_read(struct perf_event *event) @@ -254,6 +262,7 @@ static const struct attribute_group *tad_pmu_attr_group= s[] =3D { =20 static int tad_pmu_probe(struct platform_device *pdev) { + const struct tad_pmu_data *dev_data; struct device *dev =3D &pdev->dev; struct tad_region *regions; struct tad_pmu *tad_pmu; @@ -261,6 +270,7 @@ static int tad_pmu_probe(struct platform_device *pdev) u32 tad_pmu_page_size; u32 tad_page_size; u32 tad_cnt; + int version; int i, ret; char *name; =20 @@ -270,6 +280,13 @@ static int tad_pmu_probe(struct platform_device *pdev) =20 platform_set_drvdata(pdev, tad_pmu); =20 + dev_data =3D device_get_match_data(&pdev->dev); + if (!dev_data) { + dev_err(&pdev->dev, "Error: No device match data found\n"); + return -ENODEV; + } + version =3D dev_data->id; + res =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&pdev->dev, "Mem resource not found\n"); @@ -319,7 +336,6 @@ static int tad_pmu_probe(struct platform_device *pdev) tad_pmu->pmu =3D (struct pmu) { =20 .module =3D THIS_MODULE, - .attr_groups =3D tad_pmu_attr_groups, .capabilities =3D PERF_PMU_CAP_NO_EXCLUDE | PERF_PMU_CAP_NO_INTERRUPT, .task_ctx_nr =3D perf_invalid_context, @@ -332,6 +348,9 @@ static int tad_pmu_probe(struct platform_device *pdev) .read =3D tad_pmu_event_counter_read, }; =20 + if (version =3D=3D TAD_PMU_V1) + tad_pmu->pmu.attr_groups =3D tad_pmu_attr_groups; + tad_pmu->cpu =3D raw_smp_processor_id(); =20 /* Register pmu instance for cpu hotplug */ @@ -360,16 +379,22 @@ static void tad_pmu_remove(struct platform_device *pd= ev) perf_pmu_unregister(&pmu->pmu); } =20 +#if defined(CONFIG_OF) || defined(CONFIG_ACPI) +static const struct tad_pmu_data tad_pmu_data =3D { + .id =3D TAD_PMU_V1, +}; +#endif + #ifdef CONFIG_OF static const struct of_device_id tad_pmu_of_match[] =3D { - { .compatible =3D "marvell,cn10k-tad-pmu", }, + { .compatible =3D "marvell,cn10k-tad-pmu", .data =3D &tad_pmu_data }, {}, }; #endif =20 #ifdef CONFIG_ACPI static const struct acpi_device_id tad_pmu_acpi_match[] =3D { - {"MRVL000B", 0}, + {"MRVL000B", (kernel_ulong_t)&tad_pmu_data}, {}, }; MODULE_DEVICE_TABLE(acpi, tad_pmu_acpi_match); --=20 2.25.1 From nobody Tue Nov 26 19:37:10 2024 Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) (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 8A7571CB9F0 for ; Wed, 16 Oct 2024 08:02:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.156.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729065765; cv=none; b=SgpqjxKlIEMS3fYWjwmpzaicxoXkQpwOVKfoZ8BqaHXNAlsg8/l1aIpAi8CXU2tF9i7bzDkMgUCcxs+IDfyAzjlSOQwqRM2ReztQU6eDhzl+WBgrXEkBWNcaRnRlxdaeUQRsglcLMrOi+poHELejxS2Mxg3d/HPQaeZZLiC3tGE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729065765; c=relaxed/simple; bh=obyV78oUjWVeKRdPHEazO9TW3s8naiInq747cCOT01Q=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RaG+p2wMTvEA2sgJlSU20RQ1pgWUZ+LQ5j18kyWKAlIxqbfXkQRhq/9VR8+vgZnEPsv9+1jf16+UVxXDdD4CavrPgWQkUoTI5H4ntcY9HXc1zJ+wAaYjznQZ/Qi13SowDw08TeI+Hj8GgRies3S/rgUVcRI0m+E2lA/Vvnedz/o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=pass smtp.mailfrom=marvell.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=LygDk3C4; arc=none smtp.client-ip=67.231.156.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="LygDk3C4" Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49G2fw8i022296; Wed, 16 Oct 2024 01:02:31 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=2 vBA9/YIjtC9NXvu1JNHv6kTYHCKQnYXVoCmc4mw7mw=; b=LygDk3C4BSVopTzgi fCCpAPM0jq2PpAu0YIl37509r9+50+aA967C0v9MuUhdVJU1AcVhmXHnGc9Um23T XW2e2zQRUWELiCZcN0zecvwZKziRxTud0bxc0ONN3hBJRYUMKRb1xydk33gEz6+r 0GCLLIP7fdrE3NcjtXEsD4m+iloIMz5nDAfiMGc5z30JbzhccB5AVCDrw0z7JrgO OFiwftQF6PHX0nKbJIYWZ2dgn4H/BySO9Bnm/fRPQ6vMIQxiLnT3P4Vv4Y72o46x ZfKwq+k7boyV3PWZr9UW9X//TYHUsz3FfqxSvEfBdpJPlH8gJLhqd63w6yZQ+8BU qjyLQ== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 42a4x4gfvc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 16 Oct 2024 01:02:31 -0700 (PDT) Received: from DC6WP-EXCH02.marvell.com (10.76.176.209) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 16 Oct 2024 01:02:31 -0700 Received: from maili.marvell.com (10.69.176.80) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 16 Oct 2024 01:02:30 -0700 Received: from IPBU-BLR-SERVER1.marvell.com (IPBU-BLR-SERVER1.marvell.com [10.28.8.41]) by maili.marvell.com (Postfix) with ESMTP id 1BAC23F706D; Wed, 16 Oct 2024 01:02:27 -0700 (PDT) From: Gowthami Thiagarajan To: , , , CC: , , , , Gowthami Thiagarajan Subject: [PATCH v9 5/5] perf/marvell : Odyssey LLC-TAD performance monitor support Date: Wed, 16 Oct 2024 13:31:53 +0530 Message-ID: <20241016080153.3546353-6-gthiagarajan@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241016080153.3546353-1-gthiagarajan@marvell.com> References: <20241016080153.3546353-1-gthiagarajan@marvell.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: T5c0wA9tYPVyx9cM7yJ6qixeaGTQmNQM X-Proofpoint-ORIG-GUID: T5c0wA9tYPVyx9cM7yJ6qixeaGTQmNQM X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 Content-Type: text/plain; charset="utf-8" Each TAD provides eight 64-bit counters for monitoring cache behavior.The driver always configures the same counter for all the TADs. The user would end up effectively reserving one of eight counters in every TAD to look across all TADs. The occurrences of events are aggregated and presented to the user at the end of running the workload. The driver does not provide a way for the user to partition TADs so that different TADs are used for different applications. The performance events reflect various internal or interface activities. By combining the values from multiple performance counters, cache performance can be measured in terms such as: cache miss rate, cache allocations, interface retry rate, internal resource occupancy, etc. Each supported counter's event and formatting information is exposed to sysfs at /sys/devices/tad/. Use perf tool stat command to measure the pmu events. For instance: perf stat -e tad_hit_ltg,tad_hit_dtg Signed-off-by: Gowthami Thiagarajan --- Documentation/admin-guide/perf/index.rst | 1 + .../admin-guide/perf/mrvl-odyssey-tad-pmu.rst | 37 +++++++++++++++++++ drivers/perf/marvell_cn10k_tad_pmu.c | 35 ++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 Documentation/admin-guide/perf/mrvl-odyssey-tad-pmu.rst diff --git a/Documentation/admin-guide/perf/index.rst b/Documentation/admin= -guide/perf/index.rst index f9be610b2e6d..0aecdc3e4efa 100644 --- a/Documentation/admin-guide/perf/index.rst +++ b/Documentation/admin-guide/perf/index.rst @@ -15,6 +15,7 @@ Performance monitor support qcom_l3_pmu starfive_starlink_pmu mrvl-odyssey-ddr-pmu + mrvl-odyssey-tad-pmu arm-ccn arm-cmn arm-ni diff --git a/Documentation/admin-guide/perf/mrvl-odyssey-tad-pmu.rst b/Docu= mentation/admin-guide/perf/mrvl-odyssey-tad-pmu.rst new file mode 100644 index 000000000000..ad1975b14087 --- /dev/null +++ b/Documentation/admin-guide/perf/mrvl-odyssey-tad-pmu.rst @@ -0,0 +1,37 @@ +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Marvell Odyssey LLC-TAD Performance Monitoring Unit (PMU UNCORE) +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Each TAD provides eight 64-bit counters for monitoring +cache behavior.The driver always configures the same counter for +all the TADs. The user would end up effectively reserving one of +eight counters in every TAD to look across all TADs. +The occurrences of events are aggregated and presented to the user +at the end of running the workload. The driver does not provide a +way for the user to partition TADs so that different TADs are used for +different applications. + +The performance events reflect various internal or interface activities. +By combining the values from multiple performance counters, cache +performance can be measured in terms such as: cache miss rate, cache +allocations, interface retry rate, internal resource occupancy, etc. + +The PMU driver exposes the available events and format options under sysfs= :: + + /sys/bus/event_source/devices/tad/events/ + /sys/bus/event_source/devices/tad/format/ + +Examples:: + + $ perf list | grep tad + tad/tad_alloc_any/ [Kernel PMU eve= nt] + tad/tad_alloc_dtg/ [Kernel PMU eve= nt] + tad/tad_alloc_ltg/ [Kernel PMU eve= nt] + tad/tad_hit_any/ [Kernel PMU eve= nt] + tad/tad_hit_dtg/ [Kernel PMU eve= nt] + tad/tad_hit_ltg/ [Kernel PMU eve= nt] + tad/tad_req_msh_in_exlmn/ [Kernel PMU eve= nt] + tad/tad_tag_rd/ [Kernel PMU eve= nt] + tad/tad_tot_cycle/ [Kernel PMU eve= nt] + + $ perf stat -e tad_alloc_dtg,tad_alloc_ltg,tad_alloc_any,tad_hit_dtg,ta= d_hit_ltg,tad_hit_any,tad_tag_rd diff --git a/drivers/perf/marvell_cn10k_tad_pmu.c b/drivers/perf/marvell_cn= 10k_tad_pmu.c index 15f9f67cb3bd..29976b435417 100644 --- a/drivers/perf/marvell_cn10k_tad_pmu.c +++ b/drivers/perf/marvell_cn10k_tad_pmu.c @@ -39,6 +39,7 @@ struct tad_pmu { =20 enum mrvl_tad_pmu_version { TAD_PMU_V1 =3D 1, + TAD_PMU_V2, }; =20 struct tad_pmu_data { @@ -222,6 +223,24 @@ static const struct attribute_group tad_pmu_events_att= r_group =3D { .attrs =3D tad_pmu_event_attrs, }; =20 +static struct attribute *ody_tad_pmu_event_attrs[] =3D { + TAD_PMU_EVENT_ATTR(tad_req_msh_in_exlmn, 0x3), + TAD_PMU_EVENT_ATTR(tad_alloc_dtg, 0x1a), + TAD_PMU_EVENT_ATTR(tad_alloc_ltg, 0x1b), + TAD_PMU_EVENT_ATTR(tad_alloc_any, 0x1c), + TAD_PMU_EVENT_ATTR(tad_hit_dtg, 0x1d), + TAD_PMU_EVENT_ATTR(tad_hit_ltg, 0x1e), + TAD_PMU_EVENT_ATTR(tad_hit_any, 0x1f), + TAD_PMU_EVENT_ATTR(tad_tag_rd, 0x20), + TAD_PMU_EVENT_ATTR(tad_tot_cycle, 0xFF), + NULL +}; + +static const struct attribute_group ody_tad_pmu_events_attr_group =3D { + .name =3D "events", + .attrs =3D ody_tad_pmu_event_attrs, +}; + PMU_FORMAT_ATTR(event, "config:0-7"); =20 static struct attribute *tad_pmu_format_attrs[] =3D { @@ -260,6 +279,13 @@ static const struct attribute_group *tad_pmu_attr_grou= ps[] =3D { NULL }; =20 +static const struct attribute_group *ody_tad_pmu_attr_groups[] =3D { + &ody_tad_pmu_events_attr_group, + &tad_pmu_format_attr_group, + &tad_pmu_cpumask_attr_group, + NULL +}; + static int tad_pmu_probe(struct platform_device *pdev) { const struct tad_pmu_data *dev_data; @@ -350,6 +376,8 @@ static int tad_pmu_probe(struct platform_device *pdev) =20 if (version =3D=3D TAD_PMU_V1) tad_pmu->pmu.attr_groups =3D tad_pmu_attr_groups; + else + tad_pmu->pmu.attr_groups =3D ody_tad_pmu_attr_groups; =20 tad_pmu->cpu =3D raw_smp_processor_id(); =20 @@ -385,6 +413,12 @@ static const struct tad_pmu_data tad_pmu_data =3D { }; #endif =20 +#ifdef CONFIG_ACPI +static const struct tad_pmu_data tad_pmu_v2_data =3D { + .id =3D TAD_PMU_V2, +}; +#endif + #ifdef CONFIG_OF static const struct of_device_id tad_pmu_of_match[] =3D { { .compatible =3D "marvell,cn10k-tad-pmu", .data =3D &tad_pmu_data }, @@ -395,6 +429,7 @@ static const struct of_device_id tad_pmu_of_match[] =3D= { #ifdef CONFIG_ACPI static const struct acpi_device_id tad_pmu_acpi_match[] =3D { {"MRVL000B", (kernel_ulong_t)&tad_pmu_data}, + {"MRVL000D", (kernel_ulong_t)&tad_pmu_v2_data}, {}, }; MODULE_DEVICE_TABLE(acpi, tad_pmu_acpi_match); --=20 2.25.1