From nobody Fri Nov 29 20:58:15 2024 Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) (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 71C1A18A6C2; Fri, 29 Nov 2024 08:48:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.148.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732870107; cv=none; b=CtZIKBgUQLNZzSZIunZxxzKre2PtvPsJBvnZA6b2lalomr/pVaslWOGan1IuErBdEim0I80kP1WJ9BOn/LQdOJA/ozhcCtj+fwtleyYWYUPV+kLH7pHEDYZ0AA13lroRoGiTGdiCoF8Cz+m8/WU7vVTHvsjB1ZJaEhMLayD7mOE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732870107; c=relaxed/simple; bh=aZKqiRIVuttXuLQY4DiJ/91S8pCMqYkAT52W0s6yRbo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HVgmcbNaUaubljm8qmfmJtz9eT99PvNedILFdWMI9ZefmIf/Wu18hgTxpGcE8B/GrG58XEPtvdZWNopIYTt2wbJyKn7fRA4Z4+N3/LliLyEOW9QbCisIn6z2goAkpQywBcbV4/jCVZZqhwld7aFt0rEAyS4z4T5oVc/XMWVmsZM= 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=hEQh3H8L; arc=none smtp.client-ip=67.231.148.174 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="hEQh3H8L" Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AT5L4uH018091; Fri, 29 Nov 2024 00:48:12 -0800 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=r txDteUQANuXWDuPp+gVVeXvVFPALeCpP0k9WCF8cZg=; b=hEQh3H8LCeCEKIMZb abAHQiywzYYVD8YxRDhwDbg+4bP5ad/EOiOO02Kben9BNBx6NJ150UzpmgtZCuG7 F1nY1+oFpkXr07B0veXl3v7zOqCWpWDJaBwKWlMKRu8Shqg7B+coCWuQb2QoQB9p D5GfiIs3G9/XF2Z5lhcVdN8mvv3MNnXuUm8QhrcuRj8Lk0L6K50UMkZ59acYbaXX UZtfdzfWeTRx+7xmLB5XBbSwwIVybaqIuKBWIQWfLjS0vhNjUGASGigApIUFiHzM lO1bxfB4yja4DCxIy89f2Q3H1C8C2bBWXdHEwwPpv64e7c8I5vqQgDw6eSWxoDEZ 3yyfA== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 43771jgbnj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 29 Nov 2024 00:48:11 -0800 (PST) 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; Fri, 29 Nov 2024 00:48:10 -0800 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; Fri, 29 Nov 2024 00:48:10 -0800 Received: from virtx40.. (unknown [10.28.34.196]) by maili.marvell.com (Postfix) with ESMTP id CDD135C68F3; Fri, 29 Nov 2024 00:48:06 -0800 (PST) From: Linu Cherian To: , , CC: , , , , , , , , , , , Linu Cherian Subject: [PATCH v12 7/8] coresight: config: Add preloaded configuration Date: Fri, 29 Nov 2024 14:17:13 +0530 Message-ID: <20241129084714.3057080-8-lcherian@marvell.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241129084714.3057080-1-lcherian@marvell.com> References: <20241129084714.3057080-1-lcherian@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-ORIG-GUID: hJyUGlFAWlqzt-4PuWXq3t6Bjwj8m6ow X-Proofpoint-GUID: hJyUGlFAWlqzt-4PuWXq3t6Bjwj8m6ow 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" Add a preloaded configuration for generating external trigger on address match. This can be used by CTI and ETR blocks to stop trace capture on kernel panic. Kernel address for "panic" function is used as the default trigger address. This new configuration is available as, /sys/kernel/config/cs-syscfg/configurations/panicstop Signed-off-by: Linu Cherian Reviewed-by: James Clark --- drivers/hwtracing/coresight/Makefile | 2 +- .../coresight/coresight-cfg-preload.c | 2 + .../coresight/coresight-cfg-preload.h | 2 + .../hwtracing/coresight/coresight-cfg-pstop.c | 83 +++++++++++++++++++ 4 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 drivers/hwtracing/coresight/coresight-cfg-pstop.c diff --git a/drivers/hwtracing/coresight/Makefile b/drivers/hwtracing/cores= ight/Makefile index 4ba478211b31..46ce7f39d05f 100644 --- a/drivers/hwtracing/coresight/Makefile +++ b/drivers/hwtracing/coresight/Makefile @@ -25,7 +25,7 @@ subdir-ccflags-y +=3D $(condflags) obj-$(CONFIG_CORESIGHT) +=3D coresight.o coresight-y :=3D coresight-core.o coresight-etm-perf.o coresight-platform= .o \ coresight-sysfs.o coresight-syscfg.o coresight-config.o \ - coresight-cfg-preload.o coresight-cfg-afdo.o \ + coresight-cfg-preload.o coresight-cfg-afdo.o coresight-cfg-pstop.o \ coresight-syscfg-configfs.o coresight-trace-id.o obj-$(CONFIG_CORESIGHT_LINK_AND_SINK_TMC) +=3D coresight-tmc.o coresight-tmc-y :=3D coresight-tmc-core.o coresight-tmc-etf.o \ diff --git a/drivers/hwtracing/coresight/coresight-cfg-preload.c b/drivers/= hwtracing/coresight/coresight-cfg-preload.c index e237a4edfa09..4980e68483c5 100644 --- a/drivers/hwtracing/coresight/coresight-cfg-preload.c +++ b/drivers/hwtracing/coresight/coresight-cfg-preload.c @@ -13,6 +13,7 @@ static struct cscfg_feature_desc *preload_feats[] =3D { #if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X) &strobe_etm4x, + &gen_etrig_etm4x, #endif NULL }; @@ -20,6 +21,7 @@ static struct cscfg_feature_desc *preload_feats[] =3D { static struct cscfg_config_desc *preload_cfgs[] =3D { #if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X) &afdo_etm4x, + &pstop_etm4x, #endif NULL }; diff --git a/drivers/hwtracing/coresight/coresight-cfg-preload.h b/drivers/= hwtracing/coresight/coresight-cfg-preload.h index 21299e175477..291ba530a6a5 100644 --- a/drivers/hwtracing/coresight/coresight-cfg-preload.h +++ b/drivers/hwtracing/coresight/coresight-cfg-preload.h @@ -10,4 +10,6 @@ #if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X) extern struct cscfg_feature_desc strobe_etm4x; extern struct cscfg_config_desc afdo_etm4x; +extern struct cscfg_feature_desc gen_etrig_etm4x; +extern struct cscfg_config_desc pstop_etm4x; #endif diff --git a/drivers/hwtracing/coresight/coresight-cfg-pstop.c b/drivers/hw= tracing/coresight/coresight-cfg-pstop.c new file mode 100644 index 000000000000..c2bfbd07bfaf --- /dev/null +++ b/drivers/hwtracing/coresight/coresight-cfg-pstop.c @@ -0,0 +1,83 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright(C) 2023 Marvell. + * Based on coresight-cfg-afdo.c + */ + +#include "coresight-config.h" + +/* ETMv4 includes and features */ +#if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X) +#include "coresight-etm4x-cfg.h" + +/* preload configurations and features */ + +/* preload in features for ETMv4 */ + +/* panic_stop feature */ +static struct cscfg_parameter_desc gen_etrig_params[] =3D { + { + .name =3D "address", + .value =3D (u64)panic, + }, +}; + +static struct cscfg_regval_desc gen_etrig_regs[] =3D { + /* resource selector */ + { + .type =3D CS_CFG_REG_TYPE_RESOURCE, + .offset =3D TRCRSCTLRn(2), + .hw_info =3D ETM4_CFG_RES_SEL, + .val32 =3D 0x40001, + }, + /* single address comparator */ + { + .type =3D CS_CFG_REG_TYPE_RESOURCE | CS_CFG_REG_TYPE_VAL_64BIT | + CS_CFG_REG_TYPE_VAL_PARAM, + .offset =3D TRCACVRn(0), + .val32 =3D 0x0, + }, + { + .type =3D CS_CFG_REG_TYPE_RESOURCE, + .offset =3D TRCACATRn(0), + .val64 =3D 0xf00, + }, + /* Driver external output[0] with comparator out */ + { + .type =3D CS_CFG_REG_TYPE_RESOURCE, + .offset =3D TRCEVENTCTL0R, + .val32 =3D 0x2, + }, + /* end of regs */ +}; + +struct cscfg_feature_desc gen_etrig_etm4x =3D { + .name =3D "gen_etrig", + .description =3D "Generate external trigger on address match\n" + "parameter \'address\': address of kernel address\n", + .match_flags =3D CS_CFG_MATCH_CLASS_SRC_ETM4, + .nr_params =3D ARRAY_SIZE(gen_etrig_params), + .params_desc =3D gen_etrig_params, + .nr_regs =3D ARRAY_SIZE(gen_etrig_regs), + .regs_desc =3D gen_etrig_regs, +}; + +/* create a panic stop configuration */ + +/* the total number of parameters in used features */ +#define PSTOP_NR_PARAMS ARRAY_SIZE(gen_etrig_params) + +static const char *pstop_ref_names[] =3D { + "gen_etrig", +}; + +struct cscfg_config_desc pstop_etm4x =3D { + .name =3D "panicstop", + .description =3D "Stop ETM on kernel panic\n", + .nr_feat_refs =3D ARRAY_SIZE(pstop_ref_names), + .feat_ref_names =3D pstop_ref_names, + .nr_total_params =3D PSTOP_NR_PARAMS, +}; + +/* end of ETM4x configurations */ +#endif /* IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X) */ --=20 2.34.1