lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210611165937.701-17-cristian.marussi@arm.com>
Date:   Fri, 11 Jun 2021 17:59:37 +0100
From:   Cristian Marussi <cristian.marussi@....com>
To:     linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
        virtualization@...ts.linux-foundation.org,
        virtio-dev@...ts.oasis-open.org
Cc:     sudeep.holla@....com, james.quinlan@...adcom.com,
        Jonathan.Cameron@...wei.com, f.fainelli@...il.com,
        etienne.carriere@...aro.org, vincent.guittot@...aro.org,
        souvik.chakravarty@....com, cristian.marussi@....com,
        igor.skalkin@...nsynergy.com, peter.hilber@...nsynergy.com,
        alex.bennee@...aro.org, jean-philippe@...aro.org,
        mikhail.golubev@...nsynergy.com, anton.yakovlev@...nsynergy.com,
        Vasyl.Vavrychuk@...nsynergy.com,
        Andriy.Tryshnivskyy@...nsynergy.com
Subject: [PATCH v4 16/16] firmware: arm_scmi: Add polling mode to virtio transport

Enable polling mode support to virtio transport.

Upon reception of a synchronous command response for a transfer that has
the hdr.poll_completion flag set, virtio transport now simply completes the
same completion which .poll_done() is spinning on.

Signed-off-by: Cristian Marussi <cristian.marussi@....com>
---
Note that as of now in order to test this you have to forcibly
enable hdr.poll_completion in the core and increase SCMI_MAX_POLL_TO_NS.

These workarounds won't be needed anymore once addressed by a distinct
series currently under review.
---
 drivers/firmware/arm_scmi/virtio.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/firmware/arm_scmi/virtio.c b/drivers/firmware/arm_scmi/virtio.c
index 4412bc590ca7..f77c7f288d4c 100644
--- a/drivers/firmware/arm_scmi/virtio.c
+++ b/drivers/firmware/arm_scmi/virtio.c
@@ -158,12 +158,12 @@ static void scmi_process_vqueue_input(struct scmi_vio_channel *vioch,
 	/* Drop processed virtio message anyway */
 	scmi_finalize_message(vioch, msg);
 
+	/* Deliver DRESP, NOTIF and non-polled RESP */
 	if (vioch->is_rx || !xfer->hdr.poll_completion)
 		scmi_rx_callback(vioch->cinfo, msg_hdr);
 	else
-		dev_warn(vioch->cinfo->dev,
-			 "Polling mode NOT supported. Dropped hdr:0X%X\n",
-			 msg_hdr);
+		/* poll_done() is busy-waiting on this */
+		complete(&xfer->done);
 
 	scmi_transfer_release(vioch->cinfo, xfer);
 }
@@ -414,10 +414,16 @@ static void dummy_clear_channel(struct scmi_chan_info *cinfo)
 {
 }
 
-static bool dummy_poll_done(struct scmi_chan_info *cinfo,
-			    struct scmi_xfer *xfer)
+static bool virtio_poll_done(struct scmi_chan_info *cinfo,
+			     struct scmi_xfer *xfer)
 {
-	return false;
+	/*
+	 * In polling mode SCMI core does not use xfer->done completion,
+	 * so we can busy-wait on this same completion without adding
+	 * a new flag: this is completed properly upon msg reception in
+	 * scmi_process_vqueue_input().
+	 */
+	return try_wait_for_completion(&xfer->done);
 }
 
 static const struct scmi_transport_ops scmi_virtio_ops = {
@@ -430,7 +436,7 @@ static const struct scmi_transport_ops scmi_virtio_ops = {
 	.fetch_response = virtio_fetch_response,
 	.fetch_notification = virtio_fetch_notification,
 	.clear_channel = dummy_clear_channel,
-	.poll_done = dummy_poll_done,
+	.poll_done = virtio_poll_done,
 };
 
 static int scmi_vio_probe(struct virtio_device *vdev)
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ