From patchwork Mon Sep 4 05:05:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linu Cherian X-Patchwork-Id: 13373475 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A2CC9C83F33 for ; Mon, 4 Sep 2023 05:07:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=I3pllH2APuK69hH465n3FBgVFXgGtKjLjMqTMlFJFgU=; b=yJKn1R0jYotEWH ffeBpA9Z77KwE30W8uxyC89rfsn70ytqd14n9BJI/I9W+dcxCx2i2FyhgmGzGRqjI5LCRYR5w+b2/ R+MCcWdYeL/dmf+JZ0z7ePpnjU3y2X9lfS1Tm4nGKbVg4AbhJqvoEWPCn4Jbc9U6U51tHGWSVEjvV 2N9o/zN2J2vP3cLR7HokWSFuab0HZ/I8oqtSghjWFfMIeVXmVp1pIbrfafKecQHiX4qiUCtDagNnv hvGA8ISBkmmNEvrtTsTYgdmu1fGCFOHOLOfSH9GMQEk4HhWK0K41INXl/ODFD3QgOS18txmrv3iH1 HK6YFbw1ii3HW8E32waQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qd1nQ-003Knx-1W; Mon, 04 Sep 2023 05:06:44 +0000 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qd1nO-003KmM-11 for linux-arm-kernel@lists.infradead.org; Mon, 04 Sep 2023 05:06:43 +0000 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 383M0leU008921; Sun, 3 Sep 2023 22:06:26 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=hc+Gf+zauvASElrSmlJ7hOR2X08qqMLQw81+hFpvqpM=; b=by1eDe1oLy3VyXNuSzwWgmFpSUUc9eyRVNOWp1q+ngcxgPlP76piTT9IhZUrjGDYXJjj LvB80gGUNtGCqMg72msm3Uzctzhxx0DMamLm0jC4B8jykTknXJzedNcZwF2AeIPbV2u3 jfyR1huEfx4mCo6piMrz0bWKXPP+Q4s5O2HeKnrbKeGiJZJudsGaE95zud9Cfz+A1m4x lYhwagSZwT8jfM8Y3WLeSOJ2ggVkNzCSGa4Wu/puEFKQBzfQDAcGesMeAoeeoaOHRLWl dZ/mBv//91G9n9P3MqxvrWHTE6BFX2q0JT5nql7bq56NXBDusdP9WbMI8u/AnDVvsTE+ yg== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3sv4jk4b86-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Sun, 03 Sep 2023 22:06:26 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Sun, 3 Sep 2023 22:06:24 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Sun, 3 Sep 2023 22:06:24 -0700 Received: from localhost.localdomain (unknown [10.28.34.196]) by maili.marvell.com (Postfix) with ESMTP id 13E203F7062; Sun, 3 Sep 2023 22:06:19 -0700 (PDT) From: Linu Cherian To: , , , CC: , , , , , , , , , Linu Cherian Subject: [RFC PATCH v3 3/7] coresight: core: Add provision for panic callbacks Date: Mon, 4 Sep 2023 10:35:43 +0530 Message-ID: <20230904050548.28047-4-lcherian@marvell.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230904050548.28047-1-lcherian@marvell.com> References: <20230904050548.28047-1-lcherian@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: KjlDWI-iRg6_PHu3z-O9R_bu0MWUlHMa X-Proofpoint-ORIG-GUID: KjlDWI-iRg6_PHu3z-O9R_bu0MWUlHMa X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-04_02,2023-08-31_01,2023-05-22_02 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230903_220642_467354_2EFF8A0E X-CRM114-Status: GOOD ( 21.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 --- drivers/hwtracing/coresight/coresight-core.c | 32 ++++++++++++++++++++ include/linux/coresight.h | 12 ++++++++ 2 files changed, 44 insertions(+) diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c index 118fcf27854d..de4e3947c8e5 100644 --- a/drivers/hwtracing/coresight/coresight-core.c +++ b/drivers/hwtracing/coresight/coresight-core.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "coresight-etm-perf.h" #include "coresight-priv.h" @@ -1800,6 +1801,31 @@ struct bus_type coresight_bustype = { .name = "coresight", }; +static int coresight_panic_sync(struct device *dev, void *data) +{ + + struct coresight_device *csdev = container_of(dev, struct coresight_device, dev); + + /* Run through panic sync handlers for all enabled devices */ + if (csdev->enable && 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 = { + .notifier_call = coresight_panic_cb, +}; + static int __init coresight_init(void) { int ret; @@ -1812,6 +1838,10 @@ static int __init coresight_init(void) if (ret) goto exit_bus_unregister; + /* Register function to be called for panic */ + ret = atomic_notifier_chain_register(&panic_notifier_list, + &coresight_notifier); + /* initialise the coresight syscfg API */ ret = cscfg_init(); if (!ret) @@ -1826,6 +1856,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 bf70987240e4..09978ea6abe1 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -299,6 +299,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 /** * struct coresight_ops_sink - basic operations for a sink @@ -368,11 +369,22 @@ struct coresight_ops_helper { int (*disable)(struct coresight_device *csdev, void *data); }; + +/** + * 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; }; #if IS_ENABLED(CONFIG_CORESIGHT)