Skip to content

Commit 46abe13

Browse files
Igor Skalkinsudeep-holla
authored andcommitted
firmware: arm_scmi: Add virtio transport
This transport enables communications with an SCMI platform through virtio; the SCMI platform will be represented by a virtio device. Implement an SCMI virtio driver according to the virtio SCMI device spec [1]. Virtio device id 32 has been reserved for the SCMI device [2]. The virtio transport has one Tx channel (virtio cmdq, A2P channel) and at most one Rx channel (virtio eventq, P2A channel). The following feature bit defined in [1] is not implemented: VIRTIO_SCMI_F_SHARED_MEMORY. The number of messages which can be pending simultaneously is restricted according to the virtqueue capacity negotiated at probing time. As soon as Rx channel message buffers are allocated or have been read out by the arm-scmi driver, feed them back to the virtio device. Since some virtio devices may not have the short response time exhibited by SCMI platforms using other transports, set a generous response timeout. SCMI polling mode is not supported by this virtio transport since deemed meaningless: polling mode operation is offered by the SCMI core to those transports that could not provide a completion interrupt on the TX path, which is never the case for virtio whose core callbacks can easily call into core scmi_rx_callback upon messages reception. [1] https://github.com/oasis-tcs/virtio-spec/blob/master/virtio-scmi.tex [2] https://www.oasis-open.org/committees/ballot.php?id=3496 Link: https://lore.kernel.org/r/[email protected] Cc: "Michael S. Tsirkin" <[email protected]> Cc: Jason Wang <[email protected]> Co-developed-by: Peter Hilber <[email protected]> Co-developed-by: Cristian Marussi <[email protected]> Signed-off-by: Igor Skalkin <[email protected]> [ Peter: Adapted patch for submission to upstream. ] Signed-off-by: Peter Hilber <[email protected]> [ Cristian: simplified driver logic, changed link_supplier and channel available/setup logic, removed dummy callbacks ] Signed-off-by: Cristian Marussi <[email protected]> Signed-off-by: Sudeep Holla <[email protected]>
1 parent 13fba87 commit 46abe13

File tree

8 files changed

+535
-0
lines changed

8 files changed

+535
-0
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17940,6 +17940,7 @@ F: drivers/regulator/scmi-regulator.c
1794017940
F: drivers/reset/reset-scmi.c
1794117941
F: include/linux/sc[mp]i_protocol.h
1794217942
F: include/trace/events/scmi.h
17943+
F: include/uapi/linux/virtio_scmi.h
1794317944

1794417945
SYSTEM RESET/SHUTDOWN DRIVERS
1794517946
M: Sebastian Reichel <[email protected]>

drivers/firmware/arm_scmi/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,17 @@ config ARM_SCMI_TRANSPORT_SMC
6666
If you want the ARM SCMI PROTOCOL stack to include support for a
6767
transport based on SMC, answer Y.
6868

69+
config ARM_SCMI_TRANSPORT_VIRTIO
70+
bool "SCMI transport based on VirtIO"
71+
depends on VIRTIO
72+
select ARM_SCMI_HAVE_TRANSPORT
73+
select ARM_SCMI_HAVE_MSG
74+
help
75+
This enables the virtio based transport for SCMI.
76+
77+
If you want the ARM SCMI PROTOCOL stack to include support for a
78+
transport based on VirtIO, answer Y.
79+
6980
endif #ARM_SCMI_PROTOCOL
7081

7182
config ARM_SCMI_POWER_DOMAIN

drivers/firmware/arm_scmi/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ scmi-transport-$(CONFIG_ARM_SCMI_HAVE_SHMEM) = shmem.o
55
scmi-transport-$(CONFIG_ARM_SCMI_TRANSPORT_MAILBOX) += mailbox.o
66
scmi-transport-$(CONFIG_ARM_SCMI_TRANSPORT_SMC) += smc.o
77
scmi-transport-$(CONFIG_ARM_SCMI_HAVE_MSG) += msg.o
8+
scmi-transport-$(CONFIG_ARM_SCMI_TRANSPORT_VIRTIO) += virtio.o
89
scmi-protocols-y = base.o clock.o perf.o power.o reset.o sensors.o system.o voltage.o
910
scmi-module-objs := $(scmi-bus-y) $(scmi-driver-y) $(scmi-protocols-y) \
1011
$(scmi-transport-y)

drivers/firmware/arm_scmi/common.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,9 @@ extern const struct scmi_desc scmi_mailbox_desc;
418418
#ifdef CONFIG_ARM_SCMI_TRANSPORT_SMC
419419
extern const struct scmi_desc scmi_smc_desc;
420420
#endif
421+
#ifdef CONFIG_ARM_SCMI_TRANSPORT_VIRTIO
422+
extern const struct scmi_desc scmi_virtio_desc;
423+
#endif
421424

422425
void scmi_rx_callback(struct scmi_chan_info *cinfo, u32 msg_hdr, void *priv);
423426
void scmi_free_channel(struct scmi_chan_info *cinfo, struct idr *idr, int id);

drivers/firmware/arm_scmi/driver.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1983,6 +1983,9 @@ static const struct of_device_id scmi_of_match[] = {
19831983
#endif
19841984
#ifdef CONFIG_ARM_SCMI_TRANSPORT_SMC
19851985
{ .compatible = "arm,scmi-smc", .data = &scmi_smc_desc},
1986+
#endif
1987+
#ifdef CONFIG_ARM_SCMI_TRANSPORT_VIRTIO
1988+
{ .compatible = "arm,scmi-virtio", .data = &scmi_virtio_desc},
19861989
#endif
19871990
{ /* Sentinel */ },
19881991
};

0 commit comments

Comments
 (0)