Commit b1a1b152 authored by Sudeep Holla's avatar Sudeep Holla

Merge tag 'scmi-updates-5.17' of...

Merge tag 'scmi-updates-5.17' of git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux into for-next/scmi

Arm SCMI firmware interface updates for v5.17

Couple of main additions:
- Support for OPTEE based SCMI transport to enable using SCMI service
  provided by OPTEE on some platforms
- Support for atomic SCMI transports which enables few SCMI transactions
  to be completed in atomic context. This involves other refactoring work
  associated with it. It also marks SMC and OPTEE as atomic transport as
  the commands are completed once the return

Other changes involves some trace and log enhancements and a miscellaneous
bug fix.

* tag 'scmi-updates-5.17' of git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux:
  firmware: arm_scmi: Add new parameter to mark_txdone
  firmware: arm_scmi: Add atomic mode support to smc transport
  firmware: arm_scmi: Add support for atomic transports
  firmware: arm_scmi: Make optee support sync_cmds_completed_on_ret
  firmware: arm_scmi: Make smc support sync_cmds_completed_on_ret
  firmware: arm_scmi: Add sync_cmds_completed_on_ret transport flag
  firmware: arm_scmi: Make smc transport use common completions
  firmware: arm_scmi: Add configurable polling mode for transports
  firmware: arm_scmi: Use new trace event scmi_xfer_response_wait
  include: trace: Add new scmi_xfer_response_wait event
  firmware: arm_scmi: Refactor message response path
  firmware: arm_scmi: Set polling timeout to max_rx_timeout_ms
  firmware: arm_scmi: Perform earlier cinfo lookup call in do_xfer
  firmware: arm_scmi: optee: Drop the support for the OPTEE shared dynamic buffer
  firmware: arm_scmi: optee: Fix missing mutex_init()
  firmware: arm_scmi: Make virtio Version_1 compliance optional
  firmware: arm_scmi: Add optee transport
  dt-bindings: arm: Add OP-TEE transport for SCMI
  firmware: arm_scmi: Review some virtio log messages
parents e783362e 94d0cd1d
...@@ -38,6 +38,9 @@ properties: ...@@ -38,6 +38,9 @@ properties:
The virtio transport only supports a single device. The virtio transport only supports a single device.
items: items:
- const: arm,scmi-virtio - const: arm,scmi-virtio
- description: SCMI compliant firmware with OP-TEE transport
items:
- const: linaro,scmi-optee
interrupts: interrupts:
description: description:
...@@ -83,6 +86,11 @@ properties: ...@@ -83,6 +86,11 @@ properties:
description: description:
SMC id required when using smc or hvc transports SMC id required when using smc or hvc transports
linaro,optee-channel-id:
$ref: /schemas/types.yaml#/definitions/uint32
description:
Channel specifier required when using OP-TEE transport.
protocol@11: protocol@11:
type: object type: object
properties: properties:
...@@ -195,6 +203,12 @@ patternProperties: ...@@ -195,6 +203,12 @@ patternProperties:
minItems: 1 minItems: 1
maxItems: 2 maxItems: 2
linaro,optee-channel-id:
$ref: /schemas/types.yaml#/definitions/uint32
description:
Channel specifier required when using OP-TEE transport and
protocol has a dedicated communication channel.
required: required:
- reg - reg
...@@ -226,6 +240,16 @@ else: ...@@ -226,6 +240,16 @@ else:
- arm,smc-id - arm,smc-id
- shmem - shmem
else:
if:
properties:
compatible:
contains:
const: linaro,scmi-optee
then:
required:
- linaro,optee-channel-id
examples: examples:
- | - |
firmware { firmware {
...@@ -340,7 +364,48 @@ examples: ...@@ -340,7 +364,48 @@ examples:
reg = <0x11>; reg = <0x11>;
#power-domain-cells = <1>; #power-domain-cells = <1>;
}; };
};
};
- |
firmware {
scmi {
compatible = "linaro,scmi-optee";
linaro,optee-channel-id = <0>;
#address-cells = <1>;
#size-cells = <0>;
scmi_dvfs1: protocol@13 {
reg = <0x13>;
linaro,optee-channel-id = <1>;
shmem = <&cpu_optee_lpri0>;
#clock-cells = <1>;
};
scmi_clk0: protocol@14 {
reg = <0x14>;
#clock-cells = <1>;
};
};
};
soc {
#address-cells = <2>;
#size-cells = <2>;
sram@51000000 {
compatible = "mmio-sram";
reg = <0x0 0x51000000 0x0 0x10000>;
#address-cells = <1>;
#size-cells = <1>;
ranges = <0 0x0 0x51000000 0x10000>;
cpu_optee_lpri0: optee-sram-section@0 {
compatible = "arm,scmi-shmem";
reg = <0x0 0x80>;
};
}; };
}; };
......
...@@ -54,6 +54,18 @@ config ARM_SCMI_TRANSPORT_MAILBOX ...@@ -54,6 +54,18 @@ config ARM_SCMI_TRANSPORT_MAILBOX
If you want the ARM SCMI PROTOCOL stack to include support for a If you want the ARM SCMI PROTOCOL stack to include support for a
transport based on mailboxes, answer Y. transport based on mailboxes, answer Y.
config ARM_SCMI_TRANSPORT_OPTEE
bool "SCMI transport based on OP-TEE service"
depends on OPTEE=y || OPTEE=ARM_SCMI_PROTOCOL
select ARM_SCMI_HAVE_TRANSPORT
select ARM_SCMI_HAVE_SHMEM
default y
help
This enables the OP-TEE service based transport for SCMI.
If you want the ARM SCMI PROTOCOL stack to include support for a
transport based on OP-TEE SCMI service, answer Y.
config ARM_SCMI_TRANSPORT_SMC config ARM_SCMI_TRANSPORT_SMC
bool "SCMI transport based on SMC" bool "SCMI transport based on SMC"
depends on HAVE_ARM_SMCCC_DISCOVERY depends on HAVE_ARM_SMCCC_DISCOVERY
...@@ -66,6 +78,20 @@ config ARM_SCMI_TRANSPORT_SMC ...@@ -66,6 +78,20 @@ config ARM_SCMI_TRANSPORT_SMC
If you want the ARM SCMI PROTOCOL stack to include support for a If you want the ARM SCMI PROTOCOL stack to include support for a
transport based on SMC, answer Y. transport based on SMC, answer Y.
config ARM_SCMI_TRANSPORT_SMC_ATOMIC_ENABLE
bool "Enable atomic mode support for SCMI SMC transport"
depends on ARM_SCMI_TRANSPORT_SMC
help
Enable support of atomic operation for SCMI SMC based transport.
If you want the SCMI SMC based transport to operate in atomic
mode, avoiding any kind of sleeping behaviour for selected
transactions on the TX path, answer Y.
Enabling atomic mode operations allows any SCMI driver using this
transport to optionally ask for atomic SCMI transactions and operate
in atomic context too, at the price of using a number of busy-waiting
primitives all over instead. If unsure say N.
config ARM_SCMI_TRANSPORT_VIRTIO config ARM_SCMI_TRANSPORT_VIRTIO
bool "SCMI transport based on VirtIO" bool "SCMI transport based on VirtIO"
depends on VIRTIO=y || VIRTIO=ARM_SCMI_PROTOCOL depends on VIRTIO=y || VIRTIO=ARM_SCMI_PROTOCOL
...@@ -77,6 +103,21 @@ config ARM_SCMI_TRANSPORT_VIRTIO ...@@ -77,6 +103,21 @@ config ARM_SCMI_TRANSPORT_VIRTIO
If you want the ARM SCMI PROTOCOL stack to include support for a If you want the ARM SCMI PROTOCOL stack to include support for a
transport based on VirtIO, answer Y. transport based on VirtIO, answer Y.
config ARM_SCMI_TRANSPORT_VIRTIO_VERSION1_COMPLIANCE
bool "SCMI VirtIO transport Version 1 compliance"
depends on ARM_SCMI_TRANSPORT_VIRTIO
default y
help
This enforces strict compliance with VirtIO Version 1 specification.
If you want the ARM SCMI VirtIO transport layer to refuse to work
with Legacy VirtIO backends and instead support only VirtIO Version 1
devices (or above), answer Y.
If you want instead to support also old Legacy VirtIO backends (like
the ones implemented by kvmtool) and let the core Kernel VirtIO layer
take care of the needed conversions, say N.
endif #ARM_SCMI_PROTOCOL endif #ARM_SCMI_PROTOCOL
config ARM_SCMI_POWER_DOMAIN config ARM_SCMI_POWER_DOMAIN
......
...@@ -6,6 +6,7 @@ scmi-transport-$(CONFIG_ARM_SCMI_TRANSPORT_MAILBOX) += mailbox.o ...@@ -6,6 +6,7 @@ scmi-transport-$(CONFIG_ARM_SCMI_TRANSPORT_MAILBOX) += mailbox.o
scmi-transport-$(CONFIG_ARM_SCMI_TRANSPORT_SMC) += smc.o scmi-transport-$(CONFIG_ARM_SCMI_TRANSPORT_SMC) += smc.o
scmi-transport-$(CONFIG_ARM_SCMI_HAVE_MSG) += msg.o scmi-transport-$(CONFIG_ARM_SCMI_HAVE_MSG) += msg.o
scmi-transport-$(CONFIG_ARM_SCMI_TRANSPORT_VIRTIO) += virtio.o scmi-transport-$(CONFIG_ARM_SCMI_TRANSPORT_VIRTIO) += virtio.o
scmi-transport-$(CONFIG_ARM_SCMI_TRANSPORT_OPTEE) += optee.o
scmi-protocols-y = base.o clock.o perf.o power.o reset.o sensors.o system.o voltage.o scmi-protocols-y = base.o clock.o perf.o power.o reset.o sensors.o system.o voltage.o
scmi-module-objs := $(scmi-bus-y) $(scmi-driver-y) $(scmi-protocols-y) \ scmi-module-objs := $(scmi-bus-y) $(scmi-driver-y) $(scmi-protocols-y) \
$(scmi-transport-y) $(scmi-transport-y)
......
...@@ -339,11 +339,16 @@ void scmi_protocol_release(const struct scmi_handle *handle, u8 protocol_id); ...@@ -339,11 +339,16 @@ void scmi_protocol_release(const struct scmi_handle *handle, u8 protocol_id);
* @dev: Reference to device in the SCMI hierarchy corresponding to this * @dev: Reference to device in the SCMI hierarchy corresponding to this
* channel * channel
* @handle: Pointer to SCMI entity handle * @handle: Pointer to SCMI entity handle
* @no_completion_irq: Flag to indicate that this channel has no completion
* interrupt mechanism for synchronous commands.
* This can be dynamically set by transports at run-time
* inside their provided .chan_setup().
* @transport_info: Transport layer related information * @transport_info: Transport layer related information
*/ */
struct scmi_chan_info { struct scmi_chan_info {
struct device *dev; struct device *dev;
struct scmi_handle *handle; struct scmi_handle *handle;
bool no_completion_irq;
void *transport_info; void *transport_info;
}; };
...@@ -373,7 +378,8 @@ struct scmi_transport_ops { ...@@ -373,7 +378,8 @@ struct scmi_transport_ops {
unsigned int (*get_max_msg)(struct scmi_chan_info *base_cinfo); unsigned int (*get_max_msg)(struct scmi_chan_info *base_cinfo);
int (*send_message)(struct scmi_chan_info *cinfo, int (*send_message)(struct scmi_chan_info *cinfo,
struct scmi_xfer *xfer); struct scmi_xfer *xfer);
void (*mark_txdone)(struct scmi_chan_info *cinfo, int ret); void (*mark_txdone)(struct scmi_chan_info *cinfo, int ret,
struct scmi_xfer *xfer);
void (*fetch_response)(struct scmi_chan_info *cinfo, void (*fetch_response)(struct scmi_chan_info *cinfo,
struct scmi_xfer *xfer); struct scmi_xfer *xfer);
void (*fetch_notification)(struct scmi_chan_info *cinfo, void (*fetch_notification)(struct scmi_chan_info *cinfo,
...@@ -402,6 +408,18 @@ struct scmi_device *scmi_child_dev_find(struct device *parent, ...@@ -402,6 +408,18 @@ struct scmi_device *scmi_child_dev_find(struct device *parent,
* be pending simultaneously in the system. May be overridden by the * be pending simultaneously in the system. May be overridden by the
* get_max_msg op. * get_max_msg op.
* @max_msg_size: Maximum size of data per message that can be handled. * @max_msg_size: Maximum size of data per message that can be handled.
* @force_polling: Flag to force this whole transport to use SCMI core polling
* mechanism instead of completion interrupts even if available.
* @sync_cmds_completed_on_ret: Flag to indicate that the transport assures
* synchronous-command messages are atomically
* completed on .send_message: no need to poll
* actively waiting for a response.
* Used by core internally only when polling is
* selected as a waiting for reply method: i.e.
* if a completion irq was found use that anyway.
* @atomic_enabled: Flag to indicate that this transport, which is assured not
* to sleep anywhere on the TX path, can be used in atomic mode
* when requested.
*/ */
struct scmi_desc { struct scmi_desc {
int (*transport_init)(void); int (*transport_init)(void);
...@@ -410,6 +428,9 @@ struct scmi_desc { ...@@ -410,6 +428,9 @@ struct scmi_desc {
int max_rx_timeout_ms; int max_rx_timeout_ms;
int max_msg; int max_msg;
int max_msg_size; int max_msg_size;
const bool force_polling;
const bool sync_cmds_completed_on_ret;
const bool atomic_enabled;
}; };
#ifdef CONFIG_ARM_SCMI_TRANSPORT_MAILBOX #ifdef CONFIG_ARM_SCMI_TRANSPORT_MAILBOX
...@@ -421,6 +442,9 @@ extern const struct scmi_desc scmi_smc_desc; ...@@ -421,6 +442,9 @@ extern const struct scmi_desc scmi_smc_desc;
#ifdef CONFIG_ARM_SCMI_TRANSPORT_VIRTIO #ifdef CONFIG_ARM_SCMI_TRANSPORT_VIRTIO
extern const struct scmi_desc scmi_virtio_desc; extern const struct scmi_desc scmi_virtio_desc;
#endif #endif
#ifdef CONFIG_ARM_SCMI_TRANSPORT_OPTEE
extern const struct scmi_desc scmi_optee_desc;
#endif
void scmi_rx_callback(struct scmi_chan_info *cinfo, u32 msg_hdr, void *priv); void scmi_rx_callback(struct scmi_chan_info *cinfo, u32 msg_hdr, void *priv);
void scmi_free_channel(struct scmi_chan_info *cinfo, struct idr *idr, int id); void scmi_free_channel(struct scmi_chan_info *cinfo, struct idr *idr, int id);
......
This diff is collapsed.
...@@ -140,7 +140,8 @@ static int mailbox_send_message(struct scmi_chan_info *cinfo, ...@@ -140,7 +140,8 @@ static int mailbox_send_message(struct scmi_chan_info *cinfo,
return ret; return ret;
} }
static void mailbox_mark_txdone(struct scmi_chan_info *cinfo, int ret) static void mailbox_mark_txdone(struct scmi_chan_info *cinfo, int ret,
struct scmi_xfer *__unused)
{ {
struct scmi_mailbox *smbox = cinfo->transport_info; struct scmi_mailbox *smbox = cinfo->transport_info;
......
This diff is collapsed.
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
*/ */
#include <linux/arm-smccc.h> #include <linux/arm-smccc.h>
#include <linux/atomic.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
...@@ -14,6 +15,7 @@ ...@@ -14,6 +15,7 @@
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_address.h> #include <linux/of_address.h>
#include <linux/of_irq.h> #include <linux/of_irq.h>
#include <linux/processor.h>
#include <linux/slab.h> #include <linux/slab.h>
#include "common.h" #include "common.h"
...@@ -23,26 +25,29 @@ ...@@ -23,26 +25,29 @@
* *
* @cinfo: SCMI channel info * @cinfo: SCMI channel info
* @shmem: Transmit/Receive shared memory area * @shmem: Transmit/Receive shared memory area
* @shmem_lock: Lock to protect access to Tx/Rx shared memory area * @shmem_lock: Lock to protect access to Tx/Rx shared memory area.
* Used when NOT operating in atomic mode.
* @inflight: Atomic flag to protect access to Tx/Rx shared memory area.
* Used when operating in atomic mode.
* @func_id: smc/hvc call function id * @func_id: smc/hvc call function id
* @irq: Optional; employed when platforms indicates msg completion by intr.
* @tx_complete: Optional, employed only when irq is valid.
*/ */
struct scmi_smc { struct scmi_smc {
struct scmi_chan_info *cinfo; struct scmi_chan_info *cinfo;
struct scmi_shared_mem __iomem *shmem; struct scmi_shared_mem __iomem *shmem;
/* Protect access to shmem area */
struct mutex shmem_lock; struct mutex shmem_lock;
#define INFLIGHT_NONE MSG_TOKEN_MAX
atomic_t inflight;
u32 func_id; u32 func_id;
int irq;
struct completion tx_complete;
}; };
static irqreturn_t smc_msg_done_isr(int irq, void *data) static irqreturn_t smc_msg_done_isr(int irq, void *data)
{ {
struct scmi_smc *scmi_info = data; struct scmi_smc *scmi_info = data;
complete(&scmi_info->tx_complete); scmi_rx_callback(scmi_info->cinfo,
shmem_read_header(scmi_info->shmem), NULL);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -57,6 +62,41 @@ static bool smc_chan_available(struct device *dev, int idx) ...@@ -57,6 +62,41 @@ static bool smc_chan_available(struct device *dev, int idx)
return true; return true;
} }
static inline void smc_channel_lock_init(struct scmi_smc *scmi_info)
{
if (IS_ENABLED(CONFIG_ARM_SCMI_TRANSPORT_SMC_ATOMIC_ENABLE))
atomic_set(&scmi_info->inflight, INFLIGHT_NONE);
else
mutex_init(&scmi_info->shmem_lock);
}
static bool smc_xfer_inflight(struct scmi_xfer *xfer, atomic_t *inflight)
{
int ret;
ret = atomic_cmpxchg(inflight, INFLIGHT_NONE, xfer->hdr.seq);
return ret == INFLIGHT_NONE;
}
static inline void
smc_channel_lock_acquire(struct scmi_smc *scmi_info,
struct scmi_xfer *xfer __maybe_unused)
{
if (IS_ENABLED(CONFIG_ARM_SCMI_TRANSPORT_SMC_ATOMIC_ENABLE))
spin_until_cond(smc_xfer_inflight(xfer, &scmi_info->inflight));
else
mutex_lock(&scmi_info->shmem_lock);
}
static inline void smc_channel_lock_release(struct scmi_smc *scmi_info)
{
if (IS_ENABLED(CONFIG_ARM_SCMI_TRANSPORT_SMC_ATOMIC_ENABLE))
atomic_set(&scmi_info->inflight, INFLIGHT_NONE);
else
mutex_unlock(&scmi_info->shmem_lock);
}
static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev, static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
bool tx) bool tx)
{ {
...@@ -111,13 +151,13 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev, ...@@ -111,13 +151,13 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
dev_err(dev, "failed to setup SCMI smc irq\n"); dev_err(dev, "failed to setup SCMI smc irq\n");
return ret; return ret;
} }
init_completion(&scmi_info->tx_complete); } else {
scmi_info->irq = irq; cinfo->no_completion_irq = true;
} }
scmi_info->func_id = func_id; scmi_info->func_id = func_id;
scmi_info->cinfo = cinfo; scmi_info->cinfo = cinfo;
mutex_init(&scmi_info->shmem_lock); smc_channel_lock_init(scmi_info);
cinfo->transport_info = scmi_info; cinfo->transport_info = scmi_info;
return 0; return 0;
...@@ -142,26 +182,22 @@ static int smc_send_message(struct scmi_chan_info *cinfo, ...@@ -142,26 +182,22 @@ static int smc_send_message(struct scmi_chan_info *cinfo,
struct scmi_smc *scmi_info = cinfo->transport_info; struct scmi_smc *scmi_info = cinfo->transport_info;
struct arm_smccc_res res; struct arm_smccc_res res;
mutex_lock(&scmi_info->shmem_lock); /*
* Channel will be released only once response has been
* surely fully retrieved, so after .mark_txdone()
*/
smc_channel_lock_acquire(scmi_info, xfer);
shmem_tx_prepare(scmi_info->shmem, xfer); shmem_tx_prepare(scmi_info->shmem, xfer);
if (scmi_info->irq)
reinit_completion(&scmi_info->tx_complete);
arm_smccc_1_1_invoke(scmi_info->func_id, 0, 0, 0, 0, 0, 0, 0, &res); arm_smccc_1_1_invoke(scmi_info->func_id, 0, 0, 0, 0, 0, 0, 0, &res);
if (scmi_info->irq)
wait_for_completion(&scmi_info->tx_complete);
scmi_rx_callback(scmi_info->cinfo,
shmem_read_header(scmi_info->shmem), NULL);
mutex_unlock(&scmi_info->shmem_lock);
/* Only SMCCC_RET_NOT_SUPPORTED is valid error code */ /* Only SMCCC_RET_NOT_SUPPORTED is valid error code */
if (res.a0) if (res.a0) {
smc_channel_lock_release(scmi_info);
return -EOPNOTSUPP; return -EOPNOTSUPP;
}
return 0; return 0;
} }
...@@ -173,12 +209,12 @@ static void smc_fetch_response(struct scmi_chan_info *cinfo, ...@@ -173,12 +209,12 @@ static void smc_fetch_response(struct scmi_chan_info *cinfo,
shmem_fetch_response(scmi_info->shmem, xfer); shmem_fetch_response(scmi_info->shmem, xfer);
} }
static bool static void smc_mark_txdone(struct scmi_chan_info *cinfo, int ret,
smc_poll_done(struct scmi_chan_info *cinfo, struct scmi_xfer *xfer) struct scmi_xfer *__unused)
{ {
struct scmi_smc *scmi_info = cinfo->transport_info; struct scmi_smc *scmi_info = cinfo->transport_info;
return shmem_poll_done(scmi_info->shmem, xfer); smc_channel_lock_release(scmi_info);
} }
static const struct scmi_transport_ops scmi_smc_ops = { static const struct scmi_transport_ops scmi_smc_ops = {
...@@ -186,8 +222,8 @@ static const struct scmi_transport_ops scmi_smc_ops = { ...@@ -186,8 +222,8 @@ static const struct scmi_transport_ops scmi_smc_ops = {
.chan_setup = smc_chan_setup, .chan_setup = smc_chan_setup,
.chan_free = smc_chan_free, .chan_free = smc_chan_free,
.send_message = smc_send_message, .send_message = smc_send_message,
.mark_txdone = smc_mark_txdone,
.fetch_response = smc_fetch_response, .fetch_response = smc_fetch_response,
.poll_done = smc_poll_done,
}; };
const struct scmi_desc scmi_smc_desc = { const struct scmi_desc scmi_smc_desc = {
...@@ -195,4 +231,14 @@ const struct scmi_desc scmi_smc_desc = { ...@@ -195,4 +231,14 @@ const struct scmi_desc scmi_smc_desc = {
.max_rx_timeout_ms = 30, .max_rx_timeout_ms = 30,
.max_msg = 20, .max_msg = 20,
.max_msg_size = 128, .max_msg_size = 128,
/*
* Setting .sync_cmds_atomic_replies to true for SMC assumes that,
* once the SMC instruction has completed successfully, the issued
* SCMI command would have been already fully processed by the SCMI
* platform firmware and so any possible response value expected
* for the issued command will be immmediately ready to be fetched
* from the shared memory area.
*/
.sync_cmds_completed_on_ret = true,
.atomic_enabled = IS_ENABLED(CONFIG_ARM_SCMI_TRANSPORT_SMC_ATOMIC_ENABLE),
}; };
...@@ -95,7 +95,7 @@ static int scmi_vio_feed_vq_rx(struct scmi_vio_channel *vioch, ...@@ -95,7 +95,7 @@ static int scmi_vio_feed_vq_rx(struct scmi_vio_channel *vioch,
rc = virtqueue_add_inbuf(vioch->vqueue, &sg_in, 1, msg, GFP_ATOMIC); rc = virtqueue_add_inbuf(vioch->vqueue, &sg_in, 1, msg, GFP_ATOMIC);
if (rc) if (rc)
dev_err_once(dev, "failed to add to virtqueue (%d)\n", rc); dev_err(dev, "failed to add to RX virtqueue (%d)\n", rc);
else else
virtqueue_kick(vioch->vqueue); virtqueue_kick(vioch->vqueue);
...@@ -193,8 +193,8 @@ static unsigned int virtio_get_max_msg(struct scmi_chan_info *base_cinfo) ...@@ -193,8 +193,8 @@ static unsigned int virtio_get_max_msg(struct scmi_chan_info *base_cinfo)
static int virtio_link_supplier(struct device *dev) static int virtio_link_supplier(struct device *dev)
{ {
if (!scmi_vdev) { if (!scmi_vdev) {
dev_notice_once(dev, dev_notice(dev,
"Deferring probe after not finding a bound scmi-virtio device\n"); "Deferring probe after not finding a bound scmi-virtio device\n");
return -EPROBE_DEFER; return -EPROBE_DEFER;
} }
...@@ -334,9 +334,8 @@ static int virtio_send_message(struct scmi_chan_info *cinfo, ...@@ -334,9 +334,8 @@ static int virtio_send_message(struct scmi_chan_info *cinfo,
rc = virtqueue_add_sgs(vioch->vqueue, sgs, 1, 1, msg, GFP_ATOMIC); rc = virtqueue_add_sgs(vioch->vqueue, sgs, 1, 1, msg, GFP_ATOMIC);
if (rc) { if (rc) {
list_add(&msg->list, &vioch->free_list); list_add(&msg->list, &vioch->free_list);
dev_err_once(vioch->cinfo->dev, dev_err(vioch->cinfo->dev,
"%s() failed to add to virtqueue (%d)\n", __func__, "failed to add to TX virtqueue (%d)\n", rc);
rc);
} else { } else {
virtqueue_kick(vioch->vqueue); virtqueue_kick(vioch->vqueue);
} }
...@@ -427,10 +426,10 @@ static int scmi_vio_probe(struct virtio_device *vdev) ...@@ -427,10 +426,10 @@ static int scmi_vio_probe(struct virtio_device *vdev)
sz /= DESCRIPTORS_PER_TX_MSG; sz /= DESCRIPTORS_PER_TX_MSG;
if (sz > MSG_TOKEN_MAX) { if (sz > MSG_TOKEN_MAX) {
dev_info_once(dev, dev_info(dev,
"%s virtqueue could hold %d messages. Only %ld allowed to be pending.\n", "%s virtqueue could hold %d messages. Only %ld allowed to be pending.\n",
channels[i].is_rx ? "rx" : "tx", channels[i].is_rx ? "rx" : "tx",
sz, MSG_TOKEN_MAX); sz, MSG_TOKEN_MAX);
sz = MSG_TOKEN_MAX; sz = MSG_TOKEN_MAX;
} }
channels[i].max_msg = sz; channels[i].max_msg = sz;
...@@ -460,12 +459,13 @@ static void scmi_vio_remove(struct virtio_device *vdev) ...@@ -460,12 +459,13 @@ static void scmi_vio_remove(struct virtio_device *vdev)
static int scmi_vio_validate(struct virtio_device *vdev) static int scmi_vio_validate(struct virtio_device *vdev)
{ {
#ifdef CONFIG_ARM_SCMI_TRANSPORT_VIRTIO_VERSION1_COMPLIANCE
if (!virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) { if (!virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) {
dev_err(&vdev->dev, dev_err(&vdev->dev,
"device does not comply with spec version 1.x\n"); "device does not comply with spec version 1.x\n");
return -EINVAL; return -EINVAL;
} }
#endif
return 0; return 0;
} }
......
...@@ -612,6 +612,13 @@ struct scmi_notify_ops { ...@@ -612,6 +612,13 @@ struct scmi_notify_ops {
* @devm_protocol_get: devres managed method to acquire a protocol and get specific * @devm_protocol_get: devres managed method to acquire a protocol and get specific
* operations and a dedicated protocol handler * operations and a dedicated protocol handler
* @devm_protocol_put: devres managed method to release a protocol * @devm_protocol_put: devres managed method to release a protocol
* @is_transport_atomic: method to check if the underlying transport for this
* instance handle is configured to support atomic
* transactions for commands.
* Some users of the SCMI stack in the upper layers could
* be interested to know if they can assume SCMI
* command transactions associated to this handle will
* never sleep and act accordingly.
* @notify_ops: pointer to set of notifications related operations * @notify_ops: pointer to set of notifications related operations
*/ */
struct scmi_handle { struct scmi_handle {
...@@ -622,6 +629,7 @@ struct scmi_handle { ...@@ -622,6 +629,7 @@ struct scmi_handle {
(*devm_protocol_get)(struct scmi_device *sdev, u8 proto, (*devm_protocol_get)(struct scmi_device *sdev, u8 proto,
struct scmi_protocol_handle **ph); struct scmi_protocol_handle **ph);
void (*devm_protocol_put)(struct scmi_device *sdev, u8 proto); void (*devm_protocol_put)(struct scmi_device *sdev, u8 proto);
bool (*is_transport_atomic)(const struct scmi_handle *handle);
const struct scmi_notify_ops *notify_ops; const struct scmi_notify_ops *notify_ops;
}; };
......
...@@ -33,6 +33,34 @@ TRACE_EVENT(scmi_xfer_begin, ...@@ -33,6 +33,34 @@ TRACE_EVENT(scmi_xfer_begin,
__entry->seq, __entry->poll) __entry->seq, __entry->poll)
); );
TRACE_EVENT(scmi_xfer_response_wait,
TP_PROTO(int transfer_id, u8 msg_id, u8 protocol_id, u16 seq,
u32 timeout, bool poll),
TP_ARGS(transfer_id, msg_id, protocol_id, seq, timeout, poll),
TP_STRUCT__entry(
__field(int, transfer_id)
__field(u8, msg_id)
__field(u8, protocol_id)
__field(u16, seq)
__field(u32, timeout)
__field(bool, poll)
),
TP_fast_assign(
__entry->transfer_id = transfer_id;
__entry->msg_id = msg_id;
__entry->protocol_id = protocol_id;
__entry->seq = seq;
__entry->timeout = timeout;
__entry->poll = poll;
),
TP_printk("transfer_id=%d msg_id=%u protocol_id=%u seq=%u tmo_ms=%u poll=%u",
__entry->transfer_id, __entry->msg_id, __entry->protocol_id,
__entry->seq, __entry->timeout, __entry->poll)
);
TRACE_EVENT(scmi_xfer_end, TRACE_EVENT(scmi_xfer_end,
TP_PROTO(int transfer_id, u8 msg_id, u8 protocol_id, u16 seq, TP_PROTO(int transfer_id, u8 msg_id, u8 protocol_id, u16 seq,
int status), int status),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment