Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp145186lqr; Wed, 5 Jun 2024 01:24:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUw/UDfT9IpBJ55/Q+rfn9GSWHZQr1jcLx7q3FjE+eAP9Jxr6oKYTnsI3cw9GCHx0LtxHrCUK0eOnYenDaYmffpqzFKXnrQ3LY+f4Gpig== X-Google-Smtp-Source: AGHT+IGbleuhXYDDiYV2yZhXOmCjJuJBW0QXCdDUChmasKuwCV9B+T/f20ZDH3anGnsi0Um8+EWo X-Received: by 2002:a17:906:318d:b0:a59:c0a6:25cd with SMTP id a640c23a62f3a-a699f363624mr149055366b.5.1717575856513; Wed, 05 Jun 2024 01:24:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717575856; cv=pass; d=google.com; s=arc-20160816; b=NFMxukwgxnpGirtwRJ6sdK7B6rtXQwix1u3dprSEnlO+EEzV2I76qvozPXMfGG1Cyd F6lIsZTku0Cx5+G5LoBdEp5rzE/9oh7o9ShRfYYy0YX1uji8Q4JUj6wo3jxtvrEc9wYl 4hq4m1gyMIZ7yS2suSrUg7Mf8wwFrHmk7G6XjLQ8xNtObW+I5PjrGlj5izfe4lZpkBM3 jpul1iapnw/zxksoSp/het3ESoCLV664satPrztLWbpJHJqM5glBMSHy9DP3HgIUaTJr NKHsT6i/y3dB3PA+KjV9VC2oYfwxTzu2UC2MgbuIIB4nHa5QMPG12P0r4CbO4g39xPvB zRng== ARC-Message-Signature: i=2; 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=C9VVWICHZY5iZTSdEFRzo0dPB84R3sF5ECSXEN0geOM=; fh=Lmcwnbrzc6iXxb3h/s4EQlBYs2WnsA2bZNBJIYM8/3Y=; b=gq4v8gjJ5q5H7gFPfGsr65MZLP2pb4K+1k5TfrwQDwhy1SqEjmy1A367md05EUeFLw m+z4+u6czd9lxvZsTvpLoM1FKqkqBsF1CpV5+H8QadU8R+L5NsrMTLzSe0tpjA+Z2vJd 822PU6o4gKMkwcGynU1DXKhiun2IJ+tUn/ea1X1mBAX3a0BNQyAU1xnFD4Wm6H5VFn+k 60Z5pvzMFff0C0mV2jBYgmIhwE/CGodV4THnjslT9r+6Igt4gi3bLrStrAFrpKsOBnuN XDvsSIZ3RodJ4KC76mnYgc8It1Kk3D54vXBWELRu+9pIpkED0KB04/9c6ehJg8s25B1h pq2g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=lHou2wMJ; arc=pass (i=1 spf=pass spfdomain=marvell.com dkim=pass dkdomain=marvell.com dmarc=pass fromdomain=marvell.com); spf=pass (google.com: domain of linux-kernel+bounces-201978-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201978-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 a640c23a62f3a-a68c9fa1af1si386061166b.682.2024.06.05.01.24.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 01:24:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-201978-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=lHou2wMJ; arc=pass (i=1 spf=pass spfdomain=marvell.com dkim=pass dkdomain=marvell.com dmarc=pass fromdomain=marvell.com); spf=pass (google.com: domain of linux-kernel+bounces-201978-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201978-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 13E2D1F227FF for ; Wed, 5 Jun 2024 08:24:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C896D18FC94; Wed, 5 Jun 2024 08:18:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="lHou2wMJ" 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 83CAA18FC73; Wed, 5 Jun 2024 08:18:11 +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=1717575492; cv=none; b=U26+BIR/sIof/dnR3KUXCUWRwhi3MNfA/VTNy0Ed0PZ099k7HCa8MCFUuJ6kPZlLhTKVLzDqKxfbTOkiAISupfAxmK/A2iXgHxH178PKLnmkv48B3emYQhe5yNflVTw460MeqjE97T3xy1UtnYg1c4KLkc26+DZu+edZ4VYNHis= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717575492; c=relaxed/simple; bh=T1jNIimVvsNXToVe+C7OSqugb5fDRJsa8cix4PcvxFw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=u9DOwo9DnmjW8FINTYUp1AAPcpoJ1ptb0BxMsc1YDintEzuW52QwWUIzNSLccGtumqSAUcGwTKiwTlt2WiOFT8A08Yau0p5Wp6HKw1OlpJh4DZBGCsLCDF54txZHPsPfiTOEsbaYtorhaAP551puXLx5hwGdjoViIwBURb1czWU= 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=lHou2wMJ; 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 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 4554rxtv013268; Wed, 5 Jun 2024 01:17:56 -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=C 9VVWICHZY5iZTSdEFRzo0dPB84R3sF5ECSXEN0geOM=; b=lHou2wMJfW8qYjYtL a2dcCuFSbjLMy8JHTWU605oWhNRO92yMcQXuCxGw4ihtLz4De94MvaAHfhp4tPml plGnJu+wDbbZV9bazVLH7BdiNPiKVpa9O/3bk6NCClT7bYhbHmwFX5tOZrBnSzIb 0Isl5yP95MECpy6ivLDAeo/jtBIrNR1vgngA831F6WcsPLEjqDesH3r2xVrQkKST WO0QE2odwZuiUiA6D/1yuCrfpUetBDEeLih0oYB7gU6NMnOEg7x/vgxIAQHZ94OA ovqiJHJsOV2kQBfIpwD4brJETsykEiwxmw+RSS5N/S9uf3rEldbV4+Qw5q+wMcnK NrYKA== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3yjhd1gjc8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 01:17:55 -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, 5 Jun 2024 01:17:54 -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, 5 Jun 2024 01:17:54 -0700 Received: from virtx40.. (unknown [10.28.34.196]) by maili.marvell.com (Postfix) with ESMTP id 8CA533F706A; Wed, 5 Jun 2024 01:17:50 -0700 (PDT) From: Linu Cherian To: , , CC: , , , , , , , , , Linu Cherian Subject: [PATCH v9 3/7] coresight: core: Add provision for panic callbacks Date: Wed, 5 Jun 2024 13:47:21 +0530 Message-ID: <20240605081725.622953-4-lcherian@marvell.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240605081725.622953-1-lcherian@marvell.com> References: <20240605081725.622953-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-ORIG-GUID: lI2gk7hfc3MNsIuirRIi_ui1_8HosW0l X-Proofpoint-GUID: lI2gk7hfc3MNsIuirRIi_ui1_8HosW0l X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-04_11,2024-06-05_01,2024-05-17_01 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 v8: Added Reviewed-by tag. drivers/hwtracing/coresight/coresight-core.c | 37 ++++++++++++++++++++ include/linux/coresight.h | 12 +++++++ 2 files changed, 49 insertions(+) diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c index 9fc6f6b863e0..c30b9f00d77b 100644 --- a/drivers/hwtracing/coresight/coresight-core.c +++ b/drivers/hwtracing/coresight/coresight-core.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "coresight-etm-perf.h" #include "coresight-priv.h" @@ -1365,6 +1366,36 @@ const struct bus_type coresight_bustype = { .name = "coresight", }; +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 = container_of(dev, struct coresight_device, dev); + mode = coresight_get_mode(csdev); + + if ((mode == CS_MODE_SYSFS) || (mode == 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 = { + .notifier_call = coresight_panic_cb, +}; + static int __init coresight_init(void) { int ret; @@ -1377,6 +1408,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) @@ -1391,6 +1426,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 f09ace92176e..6aa54cdb66a2 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -316,6 +316,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 @@ -385,11 +386,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; }; static inline u32 csdev_access_relaxed_read32(struct csdev_access *csa, -- 2.34.1