diff mbox series

[v3,08/12] gunyah: sysfs: Add node to describe supported features

Message ID 20220811214107.1074343-9-quic_eberman@quicinc.com
State New
Headers show
Series Drivers for gunyah hypervisor | expand

Commit Message

Elliot Berman Aug. 11, 2022, 9:41 p.m. UTC
Add a sysfs node to list the features that the Gunyah hypervisor and
Linux supports. For now, Linux support cspace (capability IDs) and
message queues, so only report those..

Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
---
 Documentation/ABI/testing/sysfs-hypervisor-gunyah | 15 +++++++++++++++
 drivers/virt/gunyah/sysfs.c                       | 15 +++++++++++++++
 2 files changed, 30 insertions(+)
diff mbox series

Patch

diff --git a/Documentation/ABI/testing/sysfs-hypervisor-gunyah b/Documentation/ABI/testing/sysfs-hypervisor-gunyah
index 219465783a9e..7c14027b3daa 100644
--- a/Documentation/ABI/testing/sysfs-hypervisor-gunyah
+++ b/Documentation/ABI/testing/sysfs-hypervisor-gunyah
@@ -6,6 +6,21 @@  Description:	If running under Gunyah:
 		Type of hypervisor:
 		"gunyah": Gunyah hypervisor
 
+What:		/sys/hypervisor/gunyah/features
+Date:		August 2022
+KernelVersion:	6.0
+Contact:	linux-arm-msm@vger.kernel.org
+Description:	If running under Gunyah:
+		Space separated list of features supported by Linux and Gunyah:
+		"cspace": Gunyah devices
+		"doorbell": Sending/receiving virtual interrupts via Gunyah doorbells
+		"message-queue": Sending/receiving messages via Gunyah message queues
+		"vic": Interrupt lending
+		"vpm": Virtual platform management
+		"vcpu": Virtual CPU management
+		"memextent": Memory lending/management
+		"trace": Gunyah hypervisor tracing
+
 What:		/sys/hypervisor/gunyah/api
 Date:		August 2022
 KernelVersion:	6.0
diff --git a/drivers/virt/gunyah/sysfs.c b/drivers/virt/gunyah/sysfs.c
index 9de700fdbfcb..8c6ea141ec66 100644
--- a/drivers/virt/gunyah/sysfs.c
+++ b/drivers/virt/gunyah/sysfs.c
@@ -31,9 +31,24 @@  static ssize_t variant_show(struct kobject *kobj, struct kobj_attribute *attr, c
 }
 static struct kobj_attribute variant_attr = __ATTR_RO(variant);
 
+static ssize_t features_show(struct kobject *kobj, struct kobj_attribute *attr, char *buffer)
+{
+	int len = 0;
+
+	if (GH_IDENTIFY_PARTITION_CSPACE(gunyah_api.flags))
+		len += sysfs_emit_at(buffer, len, "cspace ");
+	if (GH_IDENTIFY_MSGQUEUE(gunyah_api.flags))
+		len += sysfs_emit_at(buffer, len, "message-queue ");
+
+	len += sysfs_emit_at(buffer, len, "\n");
+	return len;
+}
+static struct kobj_attribute features_attr = __ATTR_RO(features);
+
 static struct attribute *gunyah_attrs[] = {
 	&api_attr.attr,
 	&variant_attr.attr,
+	&features_attr.attr,
 	NULL
 };