From nobody Mon Feb 9 23:00:54 2026 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 A75C51C54A2; Mon, 16 Dec 2024 05:30:54 +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=1734327056; cv=none; b=gj8lNXcqRaFbbNqZSg8zGUr3M3HvqR7oXj7PdXn+V3fzspL0u5cyKUsGyfdaWeQBIwrmlVZORETxniKVo38P4+pnc5sIMMpotHYd+U7cHI2cEIMt/35z0xGgTBhjbGhNlSK6MRJkYg+50qvO1w/fTQGedo2nqAs+v+yfw9xwLxw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734327056; c=relaxed/simple; bh=juXK5vai24zSIBEaHNX2WMmcVb2OziVoMAP6fFDGGSo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dNVwJiaO8uli89YWYYO755ugwQopAjkfiloRqv6NUqUX1/MUy68COlWcG4UM4fgn1MDJD4nPOngzjjqvGqILaYfcioW0yybF4+h54dju1MTJZ2vawoJ4sAoMFkQ1SIQbS6EVBnz4CqBa9EM4Lem6PaD3WuDpVEN07wb1XbTS6Fc= 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=IK3G7bJO; 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="IK3G7bJO" 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 4BG4A1gC017561; Sun, 15 Dec 2024 21:30:46 -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=J HORdFDuRMeCQKKFJr8Y884jmWCbnas5W8XrKLeew6w=; b=IK3G7bJOoEa/Ztc4j FJWjVemHcwvF1CSb6Fz0GuydZUPbLmhj4lv+bo1oDiXw0AX1rip6eG3wzvQpawrN OuHvXJFttQoBG+GJA6dyAnwYC/kMzxg1i2CU+Iu26NeXLm+RkHQx4cgPhOUaMvk2 ZdFbhZOilqyFKnVOH7oSViXhwS5tLdb3ZJJbR9Bc89lubT/vjgTSFHAuud1YEJk8 oNYQh75Sz2KkGPLAx7CDJ8awxTm8C+nQ1C61JiFCU1JREzLgA0xN6UfrdUEaYrkR jf8mE7ZG/NSwFPiu5/Aou+FVXLi/COYWQ2MGFjaKJaG0FYGvUG2CDJX2mPec72Zk EDvHw== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 43jcxgr7bv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 15 Dec 2024 21:30:46 -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; Sun, 15 Dec 2024 21:30:45 -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; Sun, 15 Dec 2024 21:30:45 -0800 Received: from virtx40.. (unknown [10.28.34.196]) by maili.marvell.com (Postfix) with ESMTP id E767F3F7041; Sun, 15 Dec 2024 21:30:38 -0800 (PST) From: Linu Cherian To: , , CC: , , , , , , , , , , , Linu Cherian Subject: [PATCH v13 3/8] coresight: core: Add provision for panic callbacks Date: Mon, 16 Dec 2024 11:00:09 +0530 Message-ID: <20241216053014.3427909-4-lcherian@marvell.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241216053014.3427909-1-lcherian@marvell.com> References: <20241216053014.3427909-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-GUID: F4YXWJ9lLeBt-D0MIV-86gC1JSB78XT9 X-Proofpoint-ORIG-GUID: F4YXWJ9lLeBt-D0MIV-86gC1JSB78XT9 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" Panic callback handlers allows coresight device drivers to sync relevant trace data and trace metadata to reserved memory regions so that they can be retrieved later in the subsequent boot or in the crashdump kernel. Signed-off-by: Linu Cherian Reviewed-by: James Clark --- Changelog from v12: No changes. drivers/hwtracing/coresight/coresight-core.c | 42 ++++++++++++++++++++ include/linux/coresight.h | 12 ++++++ 2 files changed, 54 insertions(+) diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtraci= ng/coresight/coresight-core.c index ea38ecf26fcb..8c5fb66911a5 100644 --- a/drivers/hwtracing/coresight/coresight-core.c +++ b/drivers/hwtracing/coresight/coresight-core.c @@ -19,6 +19,7 @@ #include #include #include +#include =20 #include "coresight-etm-perf.h" #include "coresight-priv.h" @@ -1378,6 +1379,36 @@ const struct bus_type coresight_bustype =3D { .name =3D "coresight", }; =20 +static int coresight_panic_sync(struct device *dev, void *data) +{ + int mode; + struct coresight_device *csdev; + + /* Run through panic sync handlers for all enabled devices */ + csdev =3D container_of(dev, struct coresight_device, dev); + mode =3D coresight_get_mode(csdev); + + if ((mode =3D=3D CS_MODE_SYSFS) || (mode =3D=3D CS_MODE_PERF)) { + if (panic_ops(csdev)) + panic_ops(csdev)->sync(csdev); + } + + return 0; +} + +static int coresight_panic_cb(struct notifier_block *self, + unsigned long v, void *p) +{ + bus_for_each_dev(&coresight_bustype, NULL, NULL, + coresight_panic_sync); + + return 0; +} + +static struct notifier_block coresight_notifier =3D { + .notifier_call =3D coresight_panic_cb, +}; + static int __init coresight_init(void) { int ret; @@ -1390,11 +1421,20 @@ static int __init coresight_init(void) if (ret) goto exit_bus_unregister; =20 + /* Register function to be called for panic */ + ret =3D atomic_notifier_chain_register(&panic_notifier_list, + &coresight_notifier); + if (ret) + goto exit_perf; + /* initialise the coresight syscfg API */ ret =3D cscfg_init(); if (!ret) return 0; =20 + atomic_notifier_chain_unregister(&panic_notifier_list, + &coresight_notifier); +exit_perf: etm_perf_exit(); exit_bus_unregister: bus_unregister(&coresight_bustype); @@ -1404,6 +1444,8 @@ static int __init coresight_init(void) static void __exit coresight_exit(void) { cscfg_exit(); + atomic_notifier_chain_unregister(&panic_notifier_list, + &coresight_notifier); etm_perf_exit(); bus_unregister(&coresight_bustype); } diff --git a/include/linux/coresight.h b/include/linux/coresight.h index c13342594278..2e63f7614551 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -335,6 +335,7 @@ enum cs_mode { #define link_ops(csdev) csdev->ops->link_ops #define helper_ops(csdev) csdev->ops->helper_ops #define ect_ops(csdev) csdev->ops->ect_ops +#define panic_ops(csdev) csdev->ops->panic_ops =20 /** * struct coresight_ops_sink - basic operations for a sink @@ -404,11 +405,22 @@ struct coresight_ops_helper { int (*disable)(struct coresight_device *csdev, void *data); }; =20 + +/** + * struct coresight_ops_panic - Generic device ops for panic handing + * + * @sync : Sync the device register state/trace data + */ +struct coresight_ops_panic { + int (*sync)(struct coresight_device *csdev); +}; + struct coresight_ops { const struct coresight_ops_sink *sink_ops; const struct coresight_ops_link *link_ops; const struct coresight_ops_source *source_ops; const struct coresight_ops_helper *helper_ops; + const struct coresight_ops_panic *panic_ops; }; =20 static inline u32 csdev_access_relaxed_read32(struct csdev_access *csa, --=20 2.34.1