Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp8125895rdb; Thu, 4 Jan 2024 22:00:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IEAs4vy5oC73ELz79u3dxJAlBwDSdlL7SLIr/vnGsoE45qrquQKcLkCIgzjU70t5tU6LVIF X-Received: by 2002:a17:906:fcc3:b0:a28:d4eb:4286 with SMTP id qx3-20020a170906fcc300b00a28d4eb4286mr829819ejb.109.1704434403987; Thu, 04 Jan 2024 22:00:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704434403; cv=none; d=google.com; s=arc-20160816; b=L/K3ctVLCFBFWagUs9Vn4X+cwiH+RGxJWKMwh5hi4pBkX8mEeCFj24r5elplDw559D KtOnk+sERIURaNyoz4+CzblS1NeQPurgAqIDZFyFVihoYS8RCdTVmOvXd/vX0pP2o5+9 jBRFXCv3P9renP/EA4JYFnsOsJPrqF4//b9H52jY3AQd3cj6cGNbuSVWoBd8FMVM31og ApQ1aeb7gQIfE7oIDZeHqctVn8lYr3GT8yoefZeboy2mA8Ew/+UHfsSJ5XR+XhTLIZ0R YZgFYoDrBrp6vebl6g9c+MHhB0bvYGDi/MW/xMyiF0UxTFsJhdJ8hA5zjlG5Z1suVGLO Fp/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=3DXLv79UiE5bciMOIiohAYhZ37ofResi1U27M/l3zzo=; fh=j6jQ2O1hOk2hlRhcXI+dCLNuHpc8cpEOuv6Msh4aoKg=; b=MS3SGuvxOMl6nDDgf3aLi+TOMku8og/zZlTrOHK4aOMtcOSyYjyap88ycrO/5CG+mw mYjbli+lxbyhD6UtCiKwc3l1cz4NL+4V67obxzjwluNed5tW1b9d4rcJicRmCFvN8OED 9Nt5BSE+stxGsdqSZl8dZE6d8kYByWg3znpSFkc1XB7I286oQ0igpVtSRTIz05wpWs9B qwppphqCL76I0PXGZWhi2AqeOxL1k9yYNy7/zKOS53yvPJZ9ZviW/iM25G5VeNvjzaJH NJXMUJo5gWTdxXathfI1St598AR0ORJx6GDvzNHCKee6dsUlsx/NMZwcX0Pc4c6espWl xleQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=a4ICQXE7; spf=pass (google.com: domain of linux-kernel+bounces-17493-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17493-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id gr5-20020a170906e2c500b00a26dcbc6ff9si311392ejb.842.2024.01.04.22.00.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 22:00:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17493-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=a4ICQXE7; spf=pass (google.com: domain of linux-kernel+bounces-17493-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17493-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id BB3A61F23510 for ; Fri, 5 Jan 2024 06:00:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 19B27610E; Fri, 5 Jan 2024 05:59:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="a4ICQXE7" X-Original-To: linux-kernel@vger.kernel.org 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 007481D54A; Fri, 5 Jan 2024 05:59:21 +0000 (UTC) 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 Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 4052r5t8027822; Thu, 4 Jan 2024 21:59:13 -0800 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=3DXLv79UiE5bciMOIiohAYhZ37ofResi1U27M/l3zzo=; b=a4I CQXE7oviSu7OpE7Y7hzrdWVYQp+ohkW/0kM7DanFA/XxXiE7n1MyBsz5mm1UqtPJ QnYMNdIDWfW5LJW7yOeaZIBCWN4qj4ujtzq//ZPHrnGwlHk1ifHNhF/iGOdlGmay c0fP3uzrFuBqCXFRXzJ8HweAmrCfyZ9JCoi11rcOaAwjwKkvHYvEvux6cM+/T+3O TvHyehaa7VbgdQt+Fn+TW13aLVaSY6zz0adzuVb20vk9U59ev5hstWtUw9La2ZOH TJGLVK+7tEB/G00081AODFgsusBC1AL14y7quM1OcDmTvr6T82Dp3OLSAG/oJ7fm DcTkmELyn8CICgB7Uhw== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3ve9c7gdqj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 04 Jan 2024 21:59:13 -0800 (PST) Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Thu, 4 Jan 2024 21:59:11 -0800 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; Thu, 4 Jan 2024 21:59:11 -0800 Received: from virtx40.. (unknown [10.28.34.196]) by maili.marvell.com (Postfix) with ESMTP id B1AA63F704F; Thu, 4 Jan 2024 21:59:07 -0800 (PST) From: Linu Cherian To: , , , CC: , , , , , , , , , Linu Cherian Subject: [PATCH v6 3/7] coresight: core: Add provision for panic callbacks Date: Fri, 5 Jan 2024 11:28:36 +0530 Message-ID: <20240105055840.1977897-4-lcherian@marvell.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240105055840.1977897-1-lcherian@marvell.com> References: <20240105055840.1977897-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: 8bit Content-Type: text/plain X-Proofpoint-GUID: sqIiL60kBXlH_mWZ4TacmLW87QulH99g X-Proofpoint-ORIG-GUID: sqIiL60kBXlH_mWZ4TacmLW87QulH99g X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-09_02,2023-12-07_01,2023-05-22_02 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 --- Changelog from v5: * No changes 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 9fabe00a40d6..dfa695c103de 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 a269fffaf991..4fd518738958 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -301,6 +301,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 @@ -370,11 +371,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) -- 2.34.1