Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp343613lqh; Fri, 31 May 2024 03:07:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXu/wzBigODBOMVnov2wsJk9Ua97tGFWdlg9/hvxnYiVxPiJHrINrbeV33vSg+VRvtJSwPtlqbJwJOjO3ZB7SpiXVtj7WH6KFyPCPmZqw== X-Google-Smtp-Source: AGHT+IH9I+vQiqeihpncqK8nWSqcUt+tnWJBCE8bKZYnasevksSJh/WoNThB7B46cNC4Ljt23ykp X-Received: by 2002:a50:f609:0:b0:57a:2a46:701 with SMTP id 4fb4d7f45d1cf-57a3638f2f7mr1173951a12.19.1717150055811; Fri, 31 May 2024 03:07:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717150055; cv=pass; d=google.com; s=arc-20160816; b=MeyKMqXVErRher9zk26vvcLWhRcmwQjmUjGo+WLtAGibtxz8mwNxljq0TI5DyYUsR+ dl3LEJc7yuvTo9AsXnTlnxbsNCR44torFNOFEAdBlBwohB3w6DyaaFqVM8r9mGPmT/4B CH8Jx2XqEVhy6ZrfrQjT4ofpYV7EJ4d2uhBfTJx7KHUzq9yqSlVfz4Fun3+5CEqFei/n GpY7EeIs0MuDD+Q+9JpVcq71rL9STLLf+u+JlXOpULIEkC6icpmviFpS08yq31CrsKOj Md64jziCP+CRuG1Au4LpIsdj0Vq+FRC4h1hZD/QtpuGicTMhdzHbD7A4148bbFklKl1o oyLA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=48SsP/w/9v8ej3aJxC5dWxIFPtDvciW11tBslkHS5mA=; fh=lBrqDP4W84ltGMxgRgMplLGeJ6OYKyUqFLdXI6maIpA=; b=cKzy/wOzZFik6GAfk+lLcrTAtcUu7Okv+pw3j9AryooA4S7OclYSjfhaOYFaBzY0PA 0ywV0bN8YDXeL/4V6BtrzcqdpenZPChY3npXBpCSLMrjTSqrlfv7zSSUbR8twj004sMp 0VF9Uapu1QuF7r40GlEz/YbHGpLSS7BnUgpzlamKmfE/KOn7BfthaWrrF7Uj9Ax95ZDL 6PwzO4/8Jcv4SjDdE5rHFuVm0hiqQyKfGxvhZFFyWYK3UFF13UIqXkrQAjz1TO28PmUq a5u/szNZyGbH/7iYMu3wK7VM2u5BcFh749VWroUrnFuPqLypR9PnqJw1h6/mBB2zvJOD PxlA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-196645-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196645-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57a31b815c1si790957a12.23.2024.05.31.03.07.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 03:07:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-196645-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-196645-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196645-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.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 7BEE51F23BF1 for ; Fri, 31 May 2024 10:07:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 23E03150987; Fri, 31 May 2024 10:07:26 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0BC0E1422DA; Fri, 31 May 2024 10:07:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717150045; cv=none; b=M5wlTzFQqqzPU0tZ0YGPvWVjkx0sULHthrg2VTwC1qrhotlN3Zml0DqjsdX8eLU/LCL7mRMW8/Rc+gDF/53XqeJogYd28DN1UyUQSmSnF7oqxNN4uC9/Eh6ZCq8xFSZqBvMhmkP0Rev8/UNpOVoveHKW/PW8t0zNDCEFbM7XRVg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717150045; c=relaxed/simple; bh=j+/aZa6nejfS6aMNK75dfxOCC5uXpPdg4qUPfc2V9MQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=GgQc1sqLTxxTaRIb/ln/1DvEQpDySXqIEkYB+fLfFGyDoRnevBUM2h4aeaI5EcDT3a8iOvRQyE8S0XJWrcRyGlFBY1i1VDnp8nd+GQv/a1W5S7V3DdKbFFfm5IRlCTNgeUkZhQ5F/dJAxDu3nG24YlZam6XWZR+u7lc3H7kmlJs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D94F51424; Fri, 31 May 2024 03:07:47 -0700 (PDT) Received: from [192.168.1.100] (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 17E403F641; Fri, 31 May 2024 03:07:21 -0700 (PDT) Message-ID: <069b904f-d14d-44ab-b847-f3cf4a957cd8@arm.com> Date: Fri, 31 May 2024 11:07:21 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v8 3/7] coresight: core: Add provision for panic callbacks To: Linu Cherian Cc: linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, linux-kernel@vger.kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, devicetree@vger.kernel.org, sgoutham@marvell.com, gcherian@marvell.com, suzuki.poulose@arm.com, mike.leach@linaro.org References: <20240531042745.494222-1-lcherian@marvell.com> <20240531042745.494222-4-lcherian@marvell.com> Content-Language: en-US From: James Clark In-Reply-To: <20240531042745.494222-4-lcherian@marvell.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 31/05/2024 05:27, Linu Cherian wrote: > 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 > 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 b83613e34289..61d75aad476b 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 5f288d475490..b156467c9baa 100644 > --- a/include/linux/coresight.h > +++ b/include/linux/coresight.h > @@ -315,6 +315,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 > @@ -384,11 +385,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,