public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Cristian Marussi <cristian.marussi@arm.com>
To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Cc: sudeep.holla@arm.com, james.quinlan@broadcom.com,
	Jonathan.Cameron@Huawei.com, f.fainelli@gmail.com,
	vincent.guittot@linaro.org, souvik.chakravarty@arm.com,
	peter.hilber@opensynergy.com, cristian.marussi@arm.com
Subject: [RFC PATCH 12/16] firmware: arm_scmi: Add Sensor notifications testing support
Date: Sun, 27 Feb 2022 20:56:04 +0000	[thread overview]
Message-ID: <20220227205608.30812-13-cristian.marussi@arm.com> (raw)
In-Reply-To: <20220227205608.30812-1-cristian.marussi@arm.com>

Add a few debugfs entry to enable Sensor notifications support, namely
continuos sensor updates notifications and sensor trip point events
notifications.

Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
---
 Documentation/ABI/testing/debugfs-scmi        |  50 +++++++++
 .../arm_scmi/scmi_test_driver/test_sensors.c  | 104 +++++++++++++++++-
 2 files changed, 153 insertions(+), 1 deletion(-)

diff --git a/Documentation/ABI/testing/debugfs-scmi b/Documentation/ABI/testing/debugfs-scmi
index 72835516dee8..8b3f9a12053d 100644
--- a/Documentation/ABI/testing/debugfs-scmi
+++ b/Documentation/ABI/testing/debugfs-scmi
@@ -217,3 +217,53 @@ Description:	SCMI Sensor Protocol trip points configuration operation for
 		writing a base-10 integer value configure and enable trip point
 		<YYY> for sensor <XXX>.
 Users:		KSelftest, Debugging
+
+What:		/sys/kernel/debug/scmi/protocol_0x15/<XXX>/sensor_update_notifs
+Date:		Feb 2022
+KernelVersion:	5.19
+Contact:	cristian.marussi@arm.com
+Description:	A RW entry to support SENSOR_UPDATE notifications testing.
+		Writing a true value (Y/y/1) to this entry will trigger the
+		registration of a common notifier block for the SENSOR_UPDATE
+		notification as defined in SCMI Sensor Protocol: this common
+		notifier block starts collecting all the received notification
+		payload in a circular buffer.
+		The rate at which such notifications are emitted depends on the
+		specific update interval currently selected by the resource
+		at hand using the SENSOR_CONFIG command.
+		Note that, as per SCMI specification, the related sensor
+		resource <XXX> has also to be in an enabled state for the
+		notifications to be emitted by the platform.
+		Reading from this entry will return the latest content of the
+		above mentioned circular buffer.
+		Writing a false value (N/n/0) to this entry will cause the above
+		mentioned common notifier block to be unregistered and so
+		effectively the notification emission to be stopped.
+		When the notifier is unregistered the notification circular
+		buffer is cleared empty.
+		This entry is present only if the related resource <XXX> has
+		been advertised as supporting continuos updated notifications.
+Users:		KSelftest, Debugging
+
+What:		/sys/kernel/debug/scmi/protocol_0x15/<XXX>/sensor_trip_notifs
+Date:		Feb 2022
+KernelVersion:	5.19
+Contact:	cristian.marussi@arm.com
+Description:	A RW entry to support SENSOR_TRIP_POINT_EVENT notifications
+		testing. Writing a true value (Y/y/1) to this entry will trigger
+		the registration of a common notifier block for
+		SENSOR_TRIP_POINT_EVENT notification as defined in SCMI Sensor
+		Protocol: this common notifier block starts collecting all the
+		received notification payload in a circular buffer.
+		Such notifications will be emitted once the related sensor
+		resource crosses one of the configured trip point: such trip
+		point can be cofigured using SENSOR_TRIP_POINT_CONFIG command
+		and related entries in the SCMI debugfs filesystem.
+		Reading from this entry will return the latest content of the
+		above mentioned circular buffer.
+		Writing a false value (N/n/0) to this entry will cause the above
+		mentioned common notifier block to be unregistered and so
+		effectively the notification emission to be stopped.
+		When the notifier is unregistered the notification circular
+		buffer is cleared empty.
+Users:		KSelftest, Debugging
diff --git a/drivers/firmware/arm_scmi/scmi_test_driver/test_sensors.c b/drivers/firmware/arm_scmi/scmi_test_driver/test_sensors.c
index 23206c2bac98..2d610d84390f 100644
--- a/drivers/firmware/arm_scmi/scmi_test_driver/test_sensors.c
+++ b/drivers/firmware/arm_scmi/scmi_test_driver/test_sensors.c
@@ -284,6 +284,79 @@ static const struct file_operations test_sensor_trip_config_fops = {
 	.write = scmi_test_sensor_trip_config_write,
 };
 
+static ssize_t scmi_test_sensor_updates_write(struct file *filp,
+					      const char __user *buf,
+					      size_t count, loff_t *ppos)
+{
+	bool enabled;
+	int ret;
+	u32 src_id;
+	struct scmi_test_setup *tsp = filp->f_inode->i_private;
+	struct scmi_test_buffer *data = filp->private_data;
+
+	if (!tsp || !data)
+		return count;
+
+	ret = kstrtobool_from_user(buf, count, &enabled);
+	if (ret)
+		return ret;
+
+	src_id = data->id;
+	ret = scmi_test_notif_manage(tsp, enabled,
+				     SCMI_PROTOCOL_SENSOR,
+				     SCMI_EVENT_SENSOR_UPDATE, &src_id,
+				     sizeof(struct scmi_sensor_update_report),
+				     scmi_test_generic_notif_cb);
+	if (ret < 0)
+		return ret;
+
+	return count;
+}
+
+static const struct file_operations test_sensor_updates_fops_rw = {
+	.open = scmi_test_setup_open,
+	.release = scmi_test_release,
+	.read = scmi_test_notif_reports_read,
+	.write = scmi_test_sensor_updates_write,
+};
+
+static ssize_t scmi_test_sensor_trip_point_write(struct file *filp,
+						 const char __user *buf,
+						 size_t count, loff_t *ppos)
+{
+	bool enabled;
+	int ret;
+	u32 src_id;
+	struct scmi_test_setup *tsp = filp->f_inode->i_private;
+	struct scmi_test_buffer *data = filp->private_data;
+
+	if (!tsp || !data)
+		return count;
+
+	ret = kstrtobool_from_user(buf, count, &enabled);
+	if (ret)
+		return ret;
+
+	src_id = data->id;
+	ret = scmi_test_notif_manage(tsp, enabled,
+				     SCMI_PROTOCOL_SENSOR,
+				     SCMI_EVENT_SENSOR_TRIP_POINT_EVENT,
+				     &src_id,
+				   sizeof(struct scmi_sensor_trip_point_report),
+				     scmi_test_generic_notif_cb);
+	if (ret < 0)
+		return ret;
+
+	return count;
+}
+
+static const struct file_operations test_sensor_trips_fops_rw = {
+	.open = scmi_test_setup_open,
+	.release = scmi_test_release,
+	.read = scmi_test_notif_reports_read,
+	.write = scmi_test_sensor_trip_point_write,
+};
+
 static void scmi_test_sensor_trips_debugfs(struct dentry *pdentry,
 					   struct scmi_test_setup *tsp,
 					   unsigned int num_points)
@@ -514,10 +587,39 @@ int scmi_test_sensor_init(struct scmi_test_setup *tsp)
 					    sensor_dentry, tsp,
 					    &test_sensor_config_fops_rw);
 
-			if (sdata->sinfo[i]->num_trip_points)
+			if (sdata->sinfo[i]->update) {
+				struct scmi_test_setup *tsp_copy;
+
+				tsp_copy = scmi_test_tsp_shallow_copy(dev, tsp);
+				if (IS_ERR(tsp_copy))
+					return PTR_ERR(tsp_copy);
+
+				/* Bigger dedicated buffer for notifs */
+				tsp_copy->blen = 4096;
+				debugfs_create_file("sensor_update_notifs",
+						    0600, sensor_dentry,
+						    tsp_copy,
+						  &test_sensor_updates_fops_rw);
+			}
+
+			if (sdata->sinfo[i]->num_trip_points) {
+				struct scmi_test_setup *tsp_copy;
+
 				scmi_test_sensor_trips_debugfs(sensor_dentry,
 							       tsp,
 					      sdata->sinfo[i]->num_trip_points);
+
+				tsp_copy = scmi_test_tsp_shallow_copy(dev, tsp);
+				if (IS_ERR(tsp_copy))
+					return PTR_ERR(tsp_copy);
+
+				/* Bigger dedicated buffer for notifs */
+				tsp_copy->blen = 4096;
+				debugfs_create_file("sensor_trip_notifs",
+						    0600, sensor_dentry,
+						    tsp_copy,
+						    &test_sensor_trips_fops_rw);
+			}
 		}
 	}
 
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2022-02-27 21:01 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-27 20:55 [RFC PATCH 00/16] Introduce SCMI test driver and related Kselftest Cristian Marussi
2022-02-27 20:55 ` [RFC PATCH 01/16] firmware: arm_scmi: Simplify scmi_devm_notifier_unregister Cristian Marussi
2022-02-27 20:55 ` [RFC PATCH 02/16] firmware: arm_scmi: Make protocols init fail on basic errors Cristian Marussi
2022-02-27 20:55 ` [RFC PATCH 03/16] firmware: arm_scmi: Add multiple protocols registration support Cristian Marussi
2022-02-27 20:55 ` [RFC PATCH 04/16] firmware: arm_scmi: Add .version_get protocol operation Cristian Marussi
2022-02-27 20:55 ` [RFC PATCH 05/16] firmware: arm_scmi: Expose information on configured transport Cristian Marussi
2022-02-27 20:55 ` [RFC PATCH 06/16] firmware: arm_scmi: Define a common SCMI_MAX_PROTOCOLS value Cristian Marussi
2022-02-27 20:55 ` [RFC PATCH 07/16] debugfs: Add signed versions of debugfs_create_u32/64 helpers Cristian Marussi
2022-03-18 13:21   ` Greg Kroah-Hartman
2022-03-18 15:39     ` Cristian Marussi
2022-03-18 15:49       ` Greg Kroah-Hartman
2022-02-27 20:56 ` [RFC PATCH 08/16] firmware: arm_scmi: Add SCMI Testing driver Cristian Marussi
2022-02-27 20:56 ` [RFC PATCH 09/16] firmware: arm_scmi: testing: Add Clock protocol full support Cristian Marussi
2022-02-27 20:56 ` [RFC PATCH 10/16] firmware: arm_scmi: testing: Add Sensor protocol basic support Cristian Marussi
2022-02-27 20:56 ` [RFC PATCH 11/16] firmware: arm_scmi: Add test driver generic notification helpers Cristian Marussi
2022-02-27 20:56 ` Cristian Marussi [this message]
2022-02-27 20:56 ` [RFC PATCH 13/16] firmware: arm_scmi: Add testing Power protocol support Cristian Marussi
2022-02-27 20:56 ` [RFC PATCH 14/16] firmware: arm_scmi: Add testing Voltage " Cristian Marussi
2022-08-01  4:47   ` Arun KS
2022-08-01  6:44     ` Cristian Marussi
2022-02-27 20:56 ` [RFC PATCH 15/16] selftests: arm64: Add initial SCMI testcases Cristian Marussi
2022-08-01  4:52   ` Arun KS
2022-08-01  6:54     ` Cristian Marussi
     [not found]   ` <CAKZGPAMoBPiikbpNE2SjDxsUQQKZC-Yn5cbn60Sx0ZRqGv47jA@mail.gmail.com>
2022-08-01  7:01     ` Cristian Marussi
2022-02-27 20:56 ` [RFC PATCH 16/16] [DEBUG]: firmware: arm_scmi: Add Kconfig to allow SCMI Testing driver coexistence Cristian Marussi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220227205608.30812-13-cristian.marussi@arm.com \
    --to=cristian.marussi@arm.com \
    --cc=Jonathan.Cameron@Huawei.com \
    --cc=f.fainelli@gmail.com \
    --cc=james.quinlan@broadcom.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peter.hilber@opensynergy.com \
    --cc=souvik.chakravarty@arm.com \
    --cc=sudeep.holla@arm.com \
    --cc=vincent.guittot@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox