From mboxrd@z Thu Jan 1 00:00:00 1970 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 7956FC433F5 for ; Sun, 27 Feb 2022 21:01:49 +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:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id: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=yP0J9tHFaGuTeRY9Fwz2EE5UQk4eDQJ9RjEsee86RrQ=; b=4+cV5LT6ELa3VR KRFRcbwEsSCSEKrwqbWT4v45yww6TbcH+NZqrEHv+B/vHZvE3SUu4JWhNODC0e82U/tRqfgcz/nEs MugkXFHo9KL2MSAT1mTWC5+slc15J5uV8bmKjvZpecYTlFvdcUcS+OrCGAenBdbHrilV7JQSBif5E Joo2f22drQSb7pRvu4aMxabLzuBc75+cPEn+ELm/iV7pwxz6CZDi/9GhrC+0ISBNWoQZFeQfz1Ywh Ow1MgSDIzBrihOFCb6mFn7H1iyrWtSXvN0CwpyejSBsZrs4I2tasR0Fxx650BYfaWW75HPMgt4MUg z6PxOmCs4Jkl6toD/Deg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nOQeO-00A9Al-Eg; Sun, 27 Feb 2022 21:00:16 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nOQaw-00A7IU-N6 for linux-arm-kernel@lists.infradead.org; Sun, 27 Feb 2022 20:56:44 +0000 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 B755C1063; Sun, 27 Feb 2022 12:56:41 -0800 (PST) Received: from e120937-lin.home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5BB753F66F; Sun, 27 Feb 2022 12:56:40 -0800 (PST) From: Cristian Marussi 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 Message-Id: <20220227205608.30812-13-cristian.marussi@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220227205608.30812-1-cristian.marussi@arm.com> References: <20220227205608.30812-1-cristian.marussi@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220227_125642_944770_10CAD222 X-CRM114-Status: GOOD ( 16.16 ) 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: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 --- 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 for sensor . Users: KSelftest, Debugging + +What: /sys/kernel/debug/scmi/protocol_0x15//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 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 has + been advertised as supporting continuos updated notifications. +Users: KSelftest, Debugging + +What: /sys/kernel/debug/scmi/protocol_0x15//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