diff mbox series

[RFC,1/2] virtio/s390: add parameter for minimum revision

Message ID 20210304132715.1587211-2-cohuck@redhat.com (mailing list archive)
State New, archived
Headers show
Series virtio-ccw: allow to disable legacy virtio | expand

Commit Message

Cornelia Huck March 4, 2021, 1:27 p.m. UTC
We use transport revisions in virtio-ccw for introducing new commands
etc.; revision 1 denotes operating according to the standard. Legacy
devices do not understand the command to set a revision; for those, we
presume to operate at revision 0.

Add a parameter min_revision to be able to actively restrict use of
old transport revisions. In particular, setting a minimum revision
of 1 makes our driver act as a non-transitional driver.

With the default min_revision of 0, we continue to act as a
transitional driver.

Signed-off-by: Cornelia Huck <cohuck@redhat.com>
---
 drivers/s390/virtio/virtio_ccw.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/s390/virtio/virtio_ccw.c b/drivers/s390/virtio/virtio_ccw.c
index 54e686dca6de..0d3971dbc109 100644
--- a/drivers/s390/virtio/virtio_ccw.c
+++ b/drivers/s390/virtio/virtio_ccw.c
@@ -34,6 +34,16 @@ 
 #include <asm/isc.h>
 #include <asm/airq.h>
 
+/*
+ * Provide a knob to turn off support for older revisions. This is useful
+ * if we want to act as a non-transitional virtio device driver: requiring
+ * a minimum revision of 1 turns off support for legacy devices.
+ */
+static int min_revision;
+
+module_param(min_revision, int, 0444);
+MODULE_PARM_DESC(min_revision, "minimum transport revision to accept");
+
 /*
  * virtio related functions
  */
@@ -1271,7 +1281,10 @@  static int virtio_ccw_set_transport_rev(struct virtio_ccw_device *vcdev)
 			else
 				vcdev->revision--;
 		}
-	} while (ret == -EOPNOTSUPP);
+	} while (vcdev->revision >= min_revision && ret == -EOPNOTSUPP);
+
+	if (ret == -EOPNOTSUPP && vcdev->revision < min_revision)
+		ret = -EINVAL;
 
 	ccw_device_dma_free(vcdev->cdev, ccw, sizeof(*ccw));
 	ccw_device_dma_free(vcdev->cdev, rev, sizeof(*rev));
@@ -1315,8 +1328,12 @@  static int virtio_ccw_online(struct ccw_device *cdev)
 	vcdev->vdev.id.device = cdev->id.cu_model;
 
 	ret = virtio_ccw_set_transport_rev(vcdev);
-	if (ret)
+	if (ret) {
+		dev_warn(&cdev->dev,
+			 "Could not set a supported transport revision: %d\n",
+			 ret);
 		goto out_free;
+	}
 
 	ret = register_virtio_device(&vcdev->vdev);
 	if (ret) {