Commit 77abf472 authored by Arnd Bergmann's avatar Arnd Bergmann

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

Merge tag 'scmi-updates-5.20' of git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux into arm/drivers

Arm SCMI updates for v5.20

The main additions this time around are:

1. The capability to trace full SCMI message headers and payloads.
   The recent unearthing of chain of old firmware issues motivated
   this effort so that it is easier to trace them and debug quicker
   than it took this time around in absence of such tracing.

2. SCMI System power control driver to handle platform's requests for a
   graceful shutdown. Though the system power control protocol has been
   around since the begining of SCMI, it lacked the timeout information
   that was added in SCMI v3.1 that enables kernel to take appropriate
   action within the timeout and doesn't have to rely on any other
   user inputs(which was blocking factor for addition of this driver
   earlier)

3. Support for SCMI Power Capping protocol that was introduced in SCMI v3.1
   This protocol is intended for controlling and monitoring the power
   consumption of power capping domains. The firmware also provides the
   hierarchy of powercap domains by providing parent domain information.

It also contains a bug fix in the old SCPI driver addressing possible
user-after-free issues.

* tag 'scmi-updates-5.20' of git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux:
  firmware: arm_scmi: Use fast channel tracing
  include: trace: Add SCMI fast channel tracing
  firmware: arm_scmi: Add SCMI v3.1 powercap fast channels support
  firmware: arm_scmi: Generalize the fast channel support
  firmware: arm_scmi: Add SCMI v3.1 powercap protocol basic support
  dt-bindings: firmware: arm,scmi: Add support for powercap protocol
  firmware: arm_scmi: Add SCMI System Power Control driver
  firmware: arm_scmi: Add devm_protocol_acquire helper
  firmware: arm_scmi: Add SCMI v3.1 System Power extensions
  firmware: arm_scmi: Support only one single system power device
  firmware: arm_scmi: Use new SCMI full message tracing
  include: trace: Add SCMI full message tracing
  firmware: arm_scpi: Ensure scpi_info is not assigned if the probe fails
  firmware: arm_scmi: Remove usage of the deprecated ida_simple_xxx API
  firmware: arm_scmi: Fix response size warning for OPTEE transport
  firmware: arm_scmi: Relax CLOCK_DESCRIBE_RATES out-of-spec checks

Link: https://lore.kernel.org/r/20220706115045.2272678-1-sudeep.holla@arm.comSigned-off-by: default avatarArnd Bergmann <arnd@arndb.de>
parents 3ed9222c b27d04d5
...@@ -183,6 +183,12 @@ properties: ...@@ -183,6 +183,12 @@ properties:
required: required:
- reg - reg
protocol@18:
type: object
properties:
reg:
const: 0x18
additionalProperties: false additionalProperties: false
patternProperties: patternProperties:
...@@ -323,6 +329,10 @@ examples: ...@@ -323,6 +329,10 @@ examples:
}; };
}; };
}; };
scmi_powercap: protocol@18 {
reg = <0x18>;
};
}; };
}; };
......
...@@ -149,4 +149,16 @@ config ARM_SCMI_POWER_DOMAIN ...@@ -149,4 +149,16 @@ config ARM_SCMI_POWER_DOMAIN
will be called scmi_pm_domain. Note this may needed early in boot will be called scmi_pm_domain. Note this may needed early in boot
before rootfs may be available. before rootfs may be available.
config ARM_SCMI_POWER_CONTROL
tristate "SCMI system power control driver"
depends on ARM_SCMI_PROTOCOL || (COMPILE_TEST && OF)
help
This enables System Power control logic which binds system shutdown or
reboot actions to SCMI System Power notifications generated by SCP
firmware.
This driver can also be built as a module. If so, the module will be
called scmi_power_control. Note this may needed early in boot to catch
early shutdown/reboot SCMI requests.
endmenu endmenu
...@@ -7,11 +7,12 @@ scmi-transport-$(CONFIG_ARM_SCMI_TRANSPORT_SMC) += smc.o ...@@ -7,11 +7,12 @@ 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-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 powercap.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)
obj-$(CONFIG_ARM_SCMI_PROTOCOL) += scmi-module.o obj-$(CONFIG_ARM_SCMI_PROTOCOL) += scmi-module.o
obj-$(CONFIG_ARM_SCMI_POWER_DOMAIN) += scmi_pm_domain.o obj-$(CONFIG_ARM_SCMI_POWER_DOMAIN) += scmi_pm_domain.o
obj-$(CONFIG_ARM_SCMI_POWER_CONTROL) += scmi_power_control.o
ifeq ($(CONFIG_THUMB2_KERNEL)$(CONFIG_CC_IS_CLANG),yy) ifeq ($(CONFIG_THUMB2_KERNEL)$(CONFIG_CC_IS_CLANG),yy)
# The use of R7 in the SMCCC conflicts with the compiler's use of R7 as a frame # The use of R7 in the SMCCC conflicts with the compiler's use of R7 as a frame
......
...@@ -181,7 +181,7 @@ scmi_device_create(struct device_node *np, struct device *parent, int protocol, ...@@ -181,7 +181,7 @@ scmi_device_create(struct device_node *np, struct device *parent, int protocol,
return NULL; return NULL;
} }
id = ida_simple_get(&scmi_bus_id, 1, 0, GFP_KERNEL); id = ida_alloc_min(&scmi_bus_id, 1, GFP_KERNEL);
if (id < 0) { if (id < 0) {
kfree_const(scmi_dev->name); kfree_const(scmi_dev->name);
kfree(scmi_dev); kfree(scmi_dev);
...@@ -204,7 +204,7 @@ scmi_device_create(struct device_node *np, struct device *parent, int protocol, ...@@ -204,7 +204,7 @@ scmi_device_create(struct device_node *np, struct device *parent, int protocol,
put_dev: put_dev:
kfree_const(scmi_dev->name); kfree_const(scmi_dev->name);
put_device(&scmi_dev->dev); put_device(&scmi_dev->dev);
ida_simple_remove(&scmi_bus_id, id); ida_free(&scmi_bus_id, id);
return NULL; return NULL;
} }
...@@ -212,7 +212,7 @@ void scmi_device_destroy(struct scmi_device *scmi_dev) ...@@ -212,7 +212,7 @@ void scmi_device_destroy(struct scmi_device *scmi_dev)
{ {
kfree_const(scmi_dev->name); kfree_const(scmi_dev->name);
scmi_handle_put(scmi_dev->handle); scmi_handle_put(scmi_dev->handle);
ida_simple_remove(&scmi_bus_id, scmi_dev->id); ida_free(&scmi_bus_id, scmi_dev->id);
device_unregister(&scmi_dev->dev); device_unregister(&scmi_dev->dev);
} }
......
...@@ -194,6 +194,7 @@ static int rate_cmp_func(const void *_r1, const void *_r2) ...@@ -194,6 +194,7 @@ static int rate_cmp_func(const void *_r1, const void *_r2)
} }
struct scmi_clk_ipriv { struct scmi_clk_ipriv {
struct device *dev;
u32 clk_id; u32 clk_id;
struct scmi_clock_info *clk; struct scmi_clock_info *clk;
}; };
...@@ -223,6 +224,29 @@ iter_clk_describe_update_state(struct scmi_iterator_state *st, ...@@ -223,6 +224,29 @@ iter_clk_describe_update_state(struct scmi_iterator_state *st,
st->num_returned = NUM_RETURNED(flags); st->num_returned = NUM_RETURNED(flags);
p->clk->rate_discrete = RATE_DISCRETE(flags); p->clk->rate_discrete = RATE_DISCRETE(flags);
/* Warn about out of spec replies ... */
if (!p->clk->rate_discrete &&
(st->num_returned != 3 || st->num_remaining != 0)) {
dev_warn(p->dev,
"Out-of-spec CLOCK_DESCRIBE_RATES reply for %s - returned:%d remaining:%d rx_len:%zd\n",
p->clk->name, st->num_returned, st->num_remaining,
st->rx_len);
/*
* A known quirk: a triplet is returned but num_returned != 3
* Check for a safe payload size and fix.
*/
if (st->num_returned != 3 && st->num_remaining == 0 &&
st->rx_len == sizeof(*r) + sizeof(__le32) * 2 * 3) {
st->num_returned = 3;
st->num_remaining = 0;
} else {
dev_err(p->dev,
"Cannot fix out-of-spec reply !\n");
return -EPROTO;
}
}
return 0; return 0;
} }
...@@ -255,7 +279,6 @@ iter_clk_describe_process_response(const struct scmi_protocol_handle *ph, ...@@ -255,7 +279,6 @@ iter_clk_describe_process_response(const struct scmi_protocol_handle *ph,
*rate = RATE_TO_U64(r->rate[st->loop_idx]); *rate = RATE_TO_U64(r->rate[st->loop_idx]);
p->clk->list.num_rates++; p->clk->list.num_rates++;
//XXX dev_dbg(ph->dev, "Rate %llu Hz\n", *rate);
} }
return ret; return ret;
...@@ -275,6 +298,7 @@ scmi_clock_describe_rates_get(const struct scmi_protocol_handle *ph, u32 clk_id, ...@@ -275,6 +298,7 @@ scmi_clock_describe_rates_get(const struct scmi_protocol_handle *ph, u32 clk_id,
struct scmi_clk_ipriv cpriv = { struct scmi_clk_ipriv cpriv = {
.clk_id = clk_id, .clk_id = clk_id,
.clk = clk, .clk = clk,
.dev = ph->dev,
}; };
iter = ph->hops->iter_response_init(ph, &ops, SCMI_MAX_NUM_RATES, iter = ph->hops->iter_response_init(ph, &ops, SCMI_MAX_NUM_RATES,
......
This diff is collapsed.
...@@ -117,6 +117,7 @@ struct scmi_optee_channel { ...@@ -117,6 +117,7 @@ struct scmi_optee_channel {
u32 channel_id; u32 channel_id;
u32 tee_session; u32 tee_session;
u32 caps; u32 caps;
u32 rx_len;
struct mutex mu; struct mutex mu;
struct scmi_chan_info *cinfo; struct scmi_chan_info *cinfo;
union { union {
...@@ -302,6 +303,9 @@ static int invoke_process_msg_channel(struct scmi_optee_channel *channel, size_t ...@@ -302,6 +303,9 @@ static int invoke_process_msg_channel(struct scmi_optee_channel *channel, size_t
return -EIO; return -EIO;
} }
/* Save response size */
channel->rx_len = param[2].u.memref.size;
return 0; return 0;
} }
...@@ -353,6 +357,7 @@ static int setup_dynamic_shmem(struct device *dev, struct scmi_optee_channel *ch ...@@ -353,6 +357,7 @@ static int setup_dynamic_shmem(struct device *dev, struct scmi_optee_channel *ch
shbuf = tee_shm_get_va(channel->tee_shm, 0); shbuf = tee_shm_get_va(channel->tee_shm, 0);
memset(shbuf, 0, msg_size); memset(shbuf, 0, msg_size);
channel->req.msg = shbuf; channel->req.msg = shbuf;
channel->rx_len = msg_size;
return 0; return 0;
} }
...@@ -508,7 +513,7 @@ static void scmi_optee_fetch_response(struct scmi_chan_info *cinfo, ...@@ -508,7 +513,7 @@ static void scmi_optee_fetch_response(struct scmi_chan_info *cinfo,
struct scmi_optee_channel *channel = cinfo->transport_info; struct scmi_optee_channel *channel = cinfo->transport_info;
if (channel->tee_shm) if (channel->tee_shm)
msg_fetch_response(channel->req.msg, SCMI_OPTEE_MAX_MSG_SIZE, xfer); msg_fetch_response(channel->req.msg, channel->rx_len, xfer);
else else
shmem_fetch_response(channel->req.shmem, xfer); shmem_fetch_response(channel->req.shmem, xfer);
} }
......
...@@ -10,13 +10,14 @@ ...@@ -10,13 +10,14 @@
#include <linux/bits.h> #include <linux/bits.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/io-64-nonatomic-hi-lo.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_opp.h> #include <linux/pm_opp.h>
#include <linux/scmi_protocol.h> #include <linux/scmi_protocol.h>
#include <linux/sort.h> #include <linux/sort.h>
#include <trace/events/scmi.h>
#include "protocols.h" #include "protocols.h"
#include "notify.h" #include "notify.h"
...@@ -35,6 +36,12 @@ enum scmi_performance_protocol_cmd { ...@@ -35,6 +36,12 @@ enum scmi_performance_protocol_cmd {
PERF_DOMAIN_NAME_GET = 0xc, PERF_DOMAIN_NAME_GET = 0xc,
}; };
enum {
PERF_FC_LEVEL,
PERF_FC_LIMIT,
PERF_FC_MAX,
};
struct scmi_opp { struct scmi_opp {
u32 perf; u32 perf;
u32 power; u32 power;
...@@ -115,43 +122,6 @@ struct scmi_msg_resp_perf_describe_levels { ...@@ -115,43 +122,6 @@ struct scmi_msg_resp_perf_describe_levels {
} opp[]; } opp[];
}; };
struct scmi_perf_get_fc_info {
__le32 domain;
__le32 message_id;
};
struct scmi_msg_resp_perf_desc_fc {
__le32 attr;
#define SUPPORTS_DOORBELL(x) ((x) & BIT(0))
#define DOORBELL_REG_WIDTH(x) FIELD_GET(GENMASK(2, 1), (x))
__le32 rate_limit;
__le32 chan_addr_low;
__le32 chan_addr_high;
__le32 chan_size;
__le32 db_addr_low;
__le32 db_addr_high;
__le32 db_set_lmask;
__le32 db_set_hmask;
__le32 db_preserve_lmask;
__le32 db_preserve_hmask;
};
struct scmi_fc_db_info {
int width;
u64 set;
u64 mask;
void __iomem *addr;
};
struct scmi_fc_info {
void __iomem *level_set_addr;
void __iomem *limit_set_addr;
void __iomem *level_get_addr;
void __iomem *limit_get_addr;
struct scmi_fc_db_info *level_set_db;
struct scmi_fc_db_info *limit_set_db;
};
struct perf_dom_info { struct perf_dom_info {
bool set_limits; bool set_limits;
bool set_perf; bool set_perf;
...@@ -360,40 +330,6 @@ scmi_perf_describe_levels_get(const struct scmi_protocol_handle *ph, u32 domain, ...@@ -360,40 +330,6 @@ scmi_perf_describe_levels_get(const struct scmi_protocol_handle *ph, u32 domain,
return ret; return ret;
} }
#define SCMI_PERF_FC_RING_DB(w) \
do { \
u##w val = 0; \
\
if (db->mask) \
val = ioread##w(db->addr) & db->mask; \
iowrite##w((u##w)db->set | val, db->addr); \
} while (0)
static void scmi_perf_fc_ring_db(struct scmi_fc_db_info *db)
{
if (!db || !db->addr)
return;
if (db->width == 1)
SCMI_PERF_FC_RING_DB(8);
else if (db->width == 2)
SCMI_PERF_FC_RING_DB(16);
else if (db->width == 4)
SCMI_PERF_FC_RING_DB(32);
else /* db->width == 8 */
#ifdef CONFIG_64BIT
SCMI_PERF_FC_RING_DB(64);
#else
{
u64 val = 0;
if (db->mask)
val = ioread64_hi_lo(db->addr) & db->mask;
iowrite64_hi_lo(db->set | val, db->addr);
}
#endif
}
static int scmi_perf_mb_limits_set(const struct scmi_protocol_handle *ph, static int scmi_perf_mb_limits_set(const struct scmi_protocol_handle *ph,
u32 domain, u32 max_perf, u32 min_perf) u32 domain, u32 max_perf, u32 min_perf)
{ {
...@@ -426,10 +362,14 @@ static int scmi_perf_limits_set(const struct scmi_protocol_handle *ph, ...@@ -426,10 +362,14 @@ static int scmi_perf_limits_set(const struct scmi_protocol_handle *ph,
if (PROTOCOL_REV_MAJOR(pi->version) >= 0x3 && !max_perf && !min_perf) if (PROTOCOL_REV_MAJOR(pi->version) >= 0x3 && !max_perf && !min_perf)
return -EINVAL; return -EINVAL;
if (dom->fc_info && dom->fc_info->limit_set_addr) { if (dom->fc_info && dom->fc_info[PERF_FC_LIMIT].set_addr) {
iowrite32(max_perf, dom->fc_info->limit_set_addr); struct scmi_fc_info *fci = &dom->fc_info[PERF_FC_LIMIT];
iowrite32(min_perf, dom->fc_info->limit_set_addr + 4);
scmi_perf_fc_ring_db(dom->fc_info->limit_set_db); trace_scmi_fc_call(SCMI_PROTOCOL_PERF, PERF_LIMITS_SET,
domain, min_perf, max_perf);
iowrite32(max_perf, fci->set_addr);
iowrite32(min_perf, fci->set_addr + 4);
ph->hops->fastchannel_db_ring(fci->set_db);
return 0; return 0;
} }
...@@ -468,9 +408,13 @@ static int scmi_perf_limits_get(const struct scmi_protocol_handle *ph, ...@@ -468,9 +408,13 @@ static int scmi_perf_limits_get(const struct scmi_protocol_handle *ph,
struct scmi_perf_info *pi = ph->get_priv(ph); struct scmi_perf_info *pi = ph->get_priv(ph);
struct perf_dom_info *dom = pi->dom_info + domain; struct perf_dom_info *dom = pi->dom_info + domain;
if (dom->fc_info && dom->fc_info->limit_get_addr) { if (dom->fc_info && dom->fc_info[PERF_FC_LIMIT].get_addr) {
*max_perf = ioread32(dom->fc_info->limit_get_addr); struct scmi_fc_info *fci = &dom->fc_info[PERF_FC_LIMIT];
*min_perf = ioread32(dom->fc_info->limit_get_addr + 4);
*max_perf = ioread32(fci->get_addr);
*min_perf = ioread32(fci->get_addr + 4);
trace_scmi_fc_call(SCMI_PROTOCOL_PERF, PERF_LIMITS_GET,
domain, *min_perf, *max_perf);
return 0; return 0;
} }
...@@ -505,9 +449,13 @@ static int scmi_perf_level_set(const struct scmi_protocol_handle *ph, ...@@ -505,9 +449,13 @@ static int scmi_perf_level_set(const struct scmi_protocol_handle *ph,
struct scmi_perf_info *pi = ph->get_priv(ph); struct scmi_perf_info *pi = ph->get_priv(ph);
struct perf_dom_info *dom = pi->dom_info + domain; struct perf_dom_info *dom = pi->dom_info + domain;
if (dom->fc_info && dom->fc_info->level_set_addr) { if (dom->fc_info && dom->fc_info[PERF_FC_LEVEL].set_addr) {
iowrite32(level, dom->fc_info->level_set_addr); struct scmi_fc_info *fci = &dom->fc_info[PERF_FC_LEVEL];
scmi_perf_fc_ring_db(dom->fc_info->level_set_db);
trace_scmi_fc_call(SCMI_PROTOCOL_PERF, PERF_LEVEL_SET,
domain, level, 0);
iowrite32(level, fci->set_addr);
ph->hops->fastchannel_db_ring(fci->set_db);
return 0; return 0;
} }
...@@ -542,8 +490,10 @@ static int scmi_perf_level_get(const struct scmi_protocol_handle *ph, ...@@ -542,8 +490,10 @@ static int scmi_perf_level_get(const struct scmi_protocol_handle *ph,
struct scmi_perf_info *pi = ph->get_priv(ph); struct scmi_perf_info *pi = ph->get_priv(ph);
struct perf_dom_info *dom = pi->dom_info + domain; struct perf_dom_info *dom = pi->dom_info + domain;
if (dom->fc_info && dom->fc_info->level_get_addr) { if (dom->fc_info && dom->fc_info[PERF_FC_LEVEL].get_addr) {
*level = ioread32(dom->fc_info->level_get_addr); *level = ioread32(dom->fc_info[PERF_FC_LEVEL].get_addr);
trace_scmi_fc_call(SCMI_PROTOCOL_PERF, PERF_LEVEL_GET,
domain, *level, 0);
return 0; return 0;
} }
...@@ -572,100 +522,33 @@ static int scmi_perf_level_limits_notify(const struct scmi_protocol_handle *ph, ...@@ -572,100 +522,33 @@ static int scmi_perf_level_limits_notify(const struct scmi_protocol_handle *ph,
return ret; return ret;
} }
static bool scmi_perf_fc_size_is_valid(u32 msg, u32 size)
{
if ((msg == PERF_LEVEL_GET || msg == PERF_LEVEL_SET) && size == 4)
return true;
if ((msg == PERF_LIMITS_GET || msg == PERF_LIMITS_SET) && size == 8)
return true;
return false;
}
static void
scmi_perf_domain_desc_fc(const struct scmi_protocol_handle *ph, u32 domain,
u32 message_id, void __iomem **p_addr,
struct scmi_fc_db_info **p_db)
{
int ret;
u32 flags;
u64 phys_addr;
u8 size;
void __iomem *addr;
struct scmi_xfer *t;
struct scmi_fc_db_info *db;
struct scmi_perf_get_fc_info *info;
struct scmi_msg_resp_perf_desc_fc *resp;
if (!p_addr)
return;
ret = ph->xops->xfer_get_init(ph, PERF_DESCRIBE_FASTCHANNEL,
sizeof(*info), sizeof(*resp), &t);
if (ret)
return;
info = t->tx.buf;
info->domain = cpu_to_le32(domain);
info->message_id = cpu_to_le32(message_id);
ret = ph->xops->do_xfer(ph, t);
if (ret)
goto err_xfer;
resp = t->rx.buf;
flags = le32_to_cpu(resp->attr);
size = le32_to_cpu(resp->chan_size);
if (!scmi_perf_fc_size_is_valid(message_id, size))
goto err_xfer;
phys_addr = le32_to_cpu(resp->chan_addr_low);
phys_addr |= (u64)le32_to_cpu(resp->chan_addr_high) << 32;
addr = devm_ioremap(ph->dev, phys_addr, size);
if (!addr)
goto err_xfer;
*p_addr = addr;
if (p_db && SUPPORTS_DOORBELL(flags)) {
db = devm_kzalloc(ph->dev, sizeof(*db), GFP_KERNEL);
if (!db)
goto err_xfer;
size = 1 << DOORBELL_REG_WIDTH(flags);
phys_addr = le32_to_cpu(resp->db_addr_low);
phys_addr |= (u64)le32_to_cpu(resp->db_addr_high) << 32;
addr = devm_ioremap(ph->dev, phys_addr, size);
if (!addr)
goto err_xfer;
db->addr = addr;
db->width = size;
db->set = le32_to_cpu(resp->db_set_lmask);
db->set |= (u64)le32_to_cpu(resp->db_set_hmask) << 32;
db->mask = le32_to_cpu(resp->db_preserve_lmask);
db->mask |= (u64)le32_to_cpu(resp->db_preserve_hmask) << 32;
*p_db = db;
}
err_xfer:
ph->xops->xfer_put(ph, t);
}
static void scmi_perf_domain_init_fc(const struct scmi_protocol_handle *ph, static void scmi_perf_domain_init_fc(const struct scmi_protocol_handle *ph,
u32 domain, struct scmi_fc_info **p_fc) u32 domain, struct scmi_fc_info **p_fc)
{ {
struct scmi_fc_info *fc; struct scmi_fc_info *fc;
fc = devm_kzalloc(ph->dev, sizeof(*fc), GFP_KERNEL); fc = devm_kcalloc(ph->dev, PERF_FC_MAX, sizeof(*fc), GFP_KERNEL);
if (!fc) if (!fc)
return; return;
scmi_perf_domain_desc_fc(ph, domain, PERF_LEVEL_SET, ph->hops->fastchannel_init(ph, PERF_DESCRIBE_FASTCHANNEL,
&fc->level_set_addr, &fc->level_set_db); PERF_LEVEL_SET, 4, domain,
scmi_perf_domain_desc_fc(ph, domain, PERF_LEVEL_GET, &fc[PERF_FC_LEVEL].set_addr,
&fc->level_get_addr, NULL); &fc[PERF_FC_LEVEL].set_db);
scmi_perf_domain_desc_fc(ph, domain, PERF_LIMITS_SET,
&fc->limit_set_addr, &fc->limit_set_db); ph->hops->fastchannel_init(ph, PERF_DESCRIBE_FASTCHANNEL,
scmi_perf_domain_desc_fc(ph, domain, PERF_LIMITS_GET, PERF_LEVEL_GET, 4, domain,
&fc->limit_get_addr, NULL); &fc[PERF_FC_LEVEL].get_addr, NULL);
ph->hops->fastchannel_init(ph, PERF_DESCRIBE_FASTCHANNEL,
PERF_LIMITS_SET, 8, domain,
&fc[PERF_FC_LIMIT].set_addr,
&fc[PERF_FC_LIMIT].set_db);
ph->hops->fastchannel_init(ph, PERF_DESCRIBE_FASTCHANNEL,
PERF_LIMITS_GET, 8, domain,
&fc[PERF_FC_LIMIT].get_addr, NULL);
*p_fc = fc; *p_fc = fc;
} }
...@@ -789,7 +672,7 @@ static bool scmi_fast_switch_possible(const struct scmi_protocol_handle *ph, ...@@ -789,7 +672,7 @@ static bool scmi_fast_switch_possible(const struct scmi_protocol_handle *ph,
dom = pi->dom_info + scmi_dev_domain_id(dev); dom = pi->dom_info + scmi_dev_domain_id(dev);
return dom->fc_info && dom->fc_info->level_set_addr; return dom->fc_info && dom->fc_info[PERF_FC_LEVEL].set_addr;
} }
static bool scmi_power_scale_mw_get(const struct scmi_protocol_handle *ph) static bool scmi_power_scale_mw_get(const struct scmi_protocol_handle *ph)
......
This diff is collapsed.
...@@ -179,6 +179,8 @@ struct scmi_protocol_handle { ...@@ -179,6 +179,8 @@ struct scmi_protocol_handle {
* @max_resources: Maximum acceptable number of items, configured by the caller * @max_resources: Maximum acceptable number of items, configured by the caller
* depending on the underlying resources that it is querying. * depending on the underlying resources that it is querying.
* @loop_idx: The iterator loop index in the current multi-part reply. * @loop_idx: The iterator loop index in the current multi-part reply.
* @rx_len: Size in bytes of the currenly processed message; it can be used by
* the user of the iterator to verify a reply size.
* @priv: Optional pointer to some additional state-related private data setup * @priv: Optional pointer to some additional state-related private data setup
* by the caller during the iterations. * by the caller during the iterations.
*/ */
...@@ -188,6 +190,7 @@ struct scmi_iterator_state { ...@@ -188,6 +190,7 @@ struct scmi_iterator_state {
unsigned int num_remaining; unsigned int num_remaining;
unsigned int max_resources; unsigned int max_resources;
unsigned int loop_idx; unsigned int loop_idx;
size_t rx_len;
void *priv; void *priv;
}; };
...@@ -212,6 +215,19 @@ struct scmi_iterator_ops { ...@@ -212,6 +215,19 @@ struct scmi_iterator_ops {
struct scmi_iterator_state *st, void *priv); struct scmi_iterator_state *st, void *priv);
}; };
struct scmi_fc_db_info {
int width;
u64 set;
u64 mask;
void __iomem *addr;
};
struct scmi_fc_info {
void __iomem *set_addr;
void __iomem *get_addr;
struct scmi_fc_db_info *set_db;
};
/** /**
* struct scmi_proto_helpers_ops - References to common protocol helpers * struct scmi_proto_helpers_ops - References to common protocol helpers
* @extended_name_get: A common helper function to retrieve extended naming * @extended_name_get: A common helper function to retrieve extended naming
...@@ -227,6 +243,9 @@ struct scmi_iterator_ops { ...@@ -227,6 +243,9 @@ struct scmi_iterator_ops {
* provided in @ops. * provided in @ops.
* @iter_response_run: A common helper to trigger the run of a previously * @iter_response_run: A common helper to trigger the run of a previously
* initialized iterator. * initialized iterator.
* @fastchannel_init: A common helper used to initialize FC descriptors by
* gathering FC descriptions from the SCMI platform server.
* @fastchannel_db_ring: A common helper to ring a FC doorbell.
*/ */
struct scmi_proto_helpers_ops { struct scmi_proto_helpers_ops {
int (*extended_name_get)(const struct scmi_protocol_handle *ph, int (*extended_name_get)(const struct scmi_protocol_handle *ph,
...@@ -236,6 +255,12 @@ struct scmi_proto_helpers_ops { ...@@ -236,6 +255,12 @@ struct scmi_proto_helpers_ops {
unsigned int max_resources, u8 msg_id, unsigned int max_resources, u8 msg_id,
size_t tx_size, void *priv); size_t tx_size, void *priv);
int (*iter_response_run)(void *iter); int (*iter_response_run)(void *iter);
void (*fastchannel_init)(const struct scmi_protocol_handle *ph,
u8 describe_id, u32 message_id,
u32 valid_size, u32 domain,
void __iomem **p_addr,
struct scmi_fc_db_info **p_db);
void (*fastchannel_db_ring)(struct scmi_fc_db_info *db);
}; };
/** /**
...@@ -312,5 +337,6 @@ DECLARE_SCMI_REGISTER_UNREGISTER(reset); ...@@ -312,5 +337,6 @@ DECLARE_SCMI_REGISTER_UNREGISTER(reset);
DECLARE_SCMI_REGISTER_UNREGISTER(sensors); DECLARE_SCMI_REGISTER_UNREGISTER(sensors);
DECLARE_SCMI_REGISTER_UNREGISTER(voltage); DECLARE_SCMI_REGISTER_UNREGISTER(voltage);
DECLARE_SCMI_REGISTER_UNREGISTER(system); DECLARE_SCMI_REGISTER_UNREGISTER(system);
DECLARE_SCMI_REGISTER_UNREGISTER(powercap);
#endif /* _SCMI_PROTOCOLS_H */ #endif /* _SCMI_PROTOCOLS_H */
This diff is collapsed.
...@@ -27,10 +27,12 @@ struct scmi_system_power_state_notifier_payld { ...@@ -27,10 +27,12 @@ struct scmi_system_power_state_notifier_payld {
__le32 agent_id; __le32 agent_id;
__le32 flags; __le32 flags;
__le32 system_state; __le32 system_state;
__le32 timeout;
}; };
struct scmi_system_info { struct scmi_system_info {
u32 version; u32 version;
bool graceful_timeout_supported;
}; };
static int scmi_system_request_notify(const struct scmi_protocol_handle *ph, static int scmi_system_request_notify(const struct scmi_protocol_handle *ph,
...@@ -72,17 +74,27 @@ scmi_system_fill_custom_report(const struct scmi_protocol_handle *ph, ...@@ -72,17 +74,27 @@ scmi_system_fill_custom_report(const struct scmi_protocol_handle *ph,
const void *payld, size_t payld_sz, const void *payld, size_t payld_sz,
void *report, u32 *src_id) void *report, u32 *src_id)
{ {
size_t expected_sz;
const struct scmi_system_power_state_notifier_payld *p = payld; const struct scmi_system_power_state_notifier_payld *p = payld;
struct scmi_system_power_state_notifier_report *r = report; struct scmi_system_power_state_notifier_report *r = report;
struct scmi_system_info *pinfo = ph->get_priv(ph);
expected_sz = pinfo->graceful_timeout_supported ?
sizeof(*p) : sizeof(*p) - sizeof(__le32);
if (evt_id != SCMI_EVENT_SYSTEM_POWER_STATE_NOTIFIER || if (evt_id != SCMI_EVENT_SYSTEM_POWER_STATE_NOTIFIER ||
sizeof(*p) != payld_sz) payld_sz != expected_sz)
return NULL; return NULL;
r->timestamp = timestamp; r->timestamp = timestamp;
r->agent_id = le32_to_cpu(p->agent_id); r->agent_id = le32_to_cpu(p->agent_id);
r->flags = le32_to_cpu(p->flags); r->flags = le32_to_cpu(p->flags);
r->system_state = le32_to_cpu(p->system_state); r->system_state = le32_to_cpu(p->system_state);
if (pinfo->graceful_timeout_supported &&
r->system_state == SCMI_SYSTEM_SHUTDOWN &&
SCMI_SYSPOWER_IS_REQUEST_GRACEFUL(r->flags))
r->timeout = le32_to_cpu(p->timeout);
else
r->timeout = 0x00;
*src_id = 0; *src_id = 0;
return r; return r;
...@@ -129,6 +141,9 @@ static int scmi_system_protocol_init(const struct scmi_protocol_handle *ph) ...@@ -129,6 +141,9 @@ static int scmi_system_protocol_init(const struct scmi_protocol_handle *ph)
return -ENOMEM; return -ENOMEM;
pinfo->version = version; pinfo->version = version;
if (PROTOCOL_REV_MAJOR(pinfo->version) >= 0x2)
pinfo->graceful_timeout_supported = true;
return ph->set_priv(ph, pinfo); return ph->set_priv(ph, pinfo);
} }
......
...@@ -815,7 +815,7 @@ static int scpi_init_versions(struct scpi_drvinfo *info) ...@@ -815,7 +815,7 @@ static int scpi_init_versions(struct scpi_drvinfo *info)
info->firmware_version = le32_to_cpu(caps.platform_version); info->firmware_version = le32_to_cpu(caps.platform_version);
} }
/* Ignore error if not implemented */ /* Ignore error if not implemented */
if (scpi_info->is_legacy && ret == -EOPNOTSUPP) if (info->is_legacy && ret == -EOPNOTSUPP)
return 0; return 0;
return ret; return ret;
...@@ -913,13 +913,14 @@ static int scpi_probe(struct platform_device *pdev) ...@@ -913,13 +913,14 @@ static int scpi_probe(struct platform_device *pdev)
struct resource res; struct resource res;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct device_node *np = dev->of_node; struct device_node *np = dev->of_node;
struct scpi_drvinfo *scpi_drvinfo;
scpi_info = devm_kzalloc(dev, sizeof(*scpi_info), GFP_KERNEL); scpi_drvinfo = devm_kzalloc(dev, sizeof(*scpi_drvinfo), GFP_KERNEL);
if (!scpi_info) if (!scpi_drvinfo)
return -ENOMEM; return -ENOMEM;
if (of_match_device(legacy_scpi_of_match, &pdev->dev)) if (of_match_device(legacy_scpi_of_match, &pdev->dev))
scpi_info->is_legacy = true; scpi_drvinfo->is_legacy = true;
count = of_count_phandle_with_args(np, "mboxes", "#mbox-cells"); count = of_count_phandle_with_args(np, "mboxes", "#mbox-cells");
if (count < 0) { if (count < 0) {
...@@ -927,19 +928,19 @@ static int scpi_probe(struct platform_device *pdev) ...@@ -927,19 +928,19 @@ static int scpi_probe(struct platform_device *pdev)
return -ENODEV; return -ENODEV;
} }
scpi_info->channels = devm_kcalloc(dev, count, sizeof(struct scpi_chan), scpi_drvinfo->channels =
GFP_KERNEL); devm_kcalloc(dev, count, sizeof(struct scpi_chan), GFP_KERNEL);
if (!scpi_info->channels) if (!scpi_drvinfo->channels)
return -ENOMEM; return -ENOMEM;
ret = devm_add_action(dev, scpi_free_channels, scpi_info); ret = devm_add_action(dev, scpi_free_channels, scpi_drvinfo);
if (ret) if (ret)
return ret; return ret;
for (; scpi_info->num_chans < count; scpi_info->num_chans++) { for (; scpi_drvinfo->num_chans < count; scpi_drvinfo->num_chans++) {
resource_size_t size; resource_size_t size;
int idx = scpi_info->num_chans; int idx = scpi_drvinfo->num_chans;
struct scpi_chan *pchan = scpi_info->channels + idx; struct scpi_chan *pchan = scpi_drvinfo->channels + idx;
struct mbox_client *cl = &pchan->cl; struct mbox_client *cl = &pchan->cl;
struct device_node *shmem = of_parse_phandle(np, "shmem", idx); struct device_node *shmem = of_parse_phandle(np, "shmem", idx);
...@@ -986,45 +987,53 @@ static int scpi_probe(struct platform_device *pdev) ...@@ -986,45 +987,53 @@ static int scpi_probe(struct platform_device *pdev)
return ret; return ret;
} }
scpi_info->commands = scpi_std_commands; scpi_drvinfo->commands = scpi_std_commands;
platform_set_drvdata(pdev, scpi_info); platform_set_drvdata(pdev, scpi_drvinfo);
if (scpi_info->is_legacy) { if (scpi_drvinfo->is_legacy) {
/* Replace with legacy variants */ /* Replace with legacy variants */
scpi_ops.clk_set_val = legacy_scpi_clk_set_val; scpi_ops.clk_set_val = legacy_scpi_clk_set_val;
scpi_info->commands = scpi_legacy_commands; scpi_drvinfo->commands = scpi_legacy_commands;
/* Fill priority bitmap */ /* Fill priority bitmap */
for (idx = 0; idx < ARRAY_SIZE(legacy_hpriority_cmds); idx++) for (idx = 0; idx < ARRAY_SIZE(legacy_hpriority_cmds); idx++)
set_bit(legacy_hpriority_cmds[idx], set_bit(legacy_hpriority_cmds[idx],
scpi_info->cmd_priority); scpi_drvinfo->cmd_priority);
} }
ret = scpi_init_versions(scpi_info); scpi_info = scpi_drvinfo;
ret = scpi_init_versions(scpi_drvinfo);
if (ret) { if (ret) {
dev_err(dev, "incorrect or no SCP firmware found\n"); dev_err(dev, "incorrect or no SCP firmware found\n");
scpi_info = NULL;
return ret; return ret;
} }
if (scpi_info->is_legacy && !scpi_info->protocol_version && if (scpi_drvinfo->is_legacy && !scpi_drvinfo->protocol_version &&
!scpi_info->firmware_version) !scpi_drvinfo->firmware_version)
dev_info(dev, "SCP Protocol legacy pre-1.0 firmware\n"); dev_info(dev, "SCP Protocol legacy pre-1.0 firmware\n");
else else
dev_info(dev, "SCP Protocol %lu.%lu Firmware %lu.%lu.%lu version\n", dev_info(dev, "SCP Protocol %lu.%lu Firmware %lu.%lu.%lu version\n",
FIELD_GET(PROTO_REV_MAJOR_MASK, FIELD_GET(PROTO_REV_MAJOR_MASK,
scpi_info->protocol_version), scpi_drvinfo->protocol_version),
FIELD_GET(PROTO_REV_MINOR_MASK, FIELD_GET(PROTO_REV_MINOR_MASK,
scpi_info->protocol_version), scpi_drvinfo->protocol_version),
FIELD_GET(FW_REV_MAJOR_MASK, FIELD_GET(FW_REV_MAJOR_MASK,
scpi_info->firmware_version), scpi_drvinfo->firmware_version),
FIELD_GET(FW_REV_MINOR_MASK, FIELD_GET(FW_REV_MINOR_MASK,
scpi_info->firmware_version), scpi_drvinfo->firmware_version),
FIELD_GET(FW_REV_PATCH_MASK, FIELD_GET(FW_REV_PATCH_MASK,
scpi_info->firmware_version)); scpi_drvinfo->firmware_version));
scpi_info->scpi_ops = &scpi_ops;
scpi_drvinfo->scpi_ops = &scpi_ops;
return devm_of_platform_populate(dev); ret = devm_of_platform_populate(dev);
if (ret)
scpi_info = NULL;
return ret;
} }
static const struct of_device_id scpi_of_match[] = { static const struct of_device_id scpi_of_match[] = {
......
...@@ -560,6 +560,116 @@ struct scmi_voltage_proto_ops { ...@@ -560,6 +560,116 @@ struct scmi_voltage_proto_ops {
s32 *volt_uV); s32 *volt_uV);
}; };
/**
* struct scmi_powercap_info - Describe one available Powercap domain
*
* @id: Domain ID as advertised by the platform.
* @notify_powercap_cap_change: CAP change notification support.
* @notify_powercap_measurement_change: MEASUREMENTS change notifications
* support.
* @async_powercap_cap_set: Asynchronous CAP set support.
* @powercap_cap_config: CAP configuration support.
* @powercap_monitoring: Monitoring (measurements) support.
* @powercap_pai_config: PAI configuration support.
* @powercap_scale_mw: Domain reports power data in milliwatt units.
* @powercap_scale_uw: Domain reports power data in microwatt units.
* Note that, when both @powercap_scale_mw and
* @powercap_scale_uw are set to false, the domain
* reports power data on an abstract linear scale.
* @name: name assigned to the Powercap Domain by platform.
* @min_pai: Minimum configurable PAI.
* @max_pai: Maximum configurable PAI.
* @pai_step: Step size between two consecutive PAI values.
* @min_power_cap: Minimum configurable CAP.
* @max_power_cap: Maximum configurable CAP.
* @power_cap_step: Step size between two consecutive CAP values.
* @sustainable_power: Maximum sustainable power consumption for this domain
* under normal conditions.
* @accuracy: The accuracy with which the power is measured and reported in
* integral multiples of 0.001 percent.
* @parent_id: Identifier of the containing parent power capping domain, or the
* value 0xFFFFFFFF if this powercap domain is a root domain not
* contained in any other domain.
*/
struct scmi_powercap_info {
unsigned int id;
bool notify_powercap_cap_change;
bool notify_powercap_measurement_change;
bool async_powercap_cap_set;
bool powercap_cap_config;
bool powercap_monitoring;
bool powercap_pai_config;
bool powercap_scale_mw;
bool powercap_scale_uw;
bool fastchannels;
char name[SCMI_MAX_STR_SIZE];
unsigned int min_pai;
unsigned int max_pai;
unsigned int pai_step;
unsigned int min_power_cap;
unsigned int max_power_cap;
unsigned int power_cap_step;
unsigned int sustainable_power;
unsigned int accuracy;
#define SCMI_POWERCAP_ROOT_ZONE_ID 0xFFFFFFFFUL
unsigned int parent_id;
struct scmi_fc_info *fc_info;
};
/**
* struct scmi_powercap_proto_ops - represents the various operations provided
* by SCMI Powercap Protocol
*
* @num_domains_get: get the count of powercap domains provided by SCMI.
* @info_get: get the information for the specified domain.
* @cap_get: get the current CAP value for the specified domain.
* @cap_set: set the CAP value for the specified domain to the provided value;
* if the domain supports setting the CAP with an asynchronous command
* this request will finally trigger an asynchronous transfer, but, if
* @ignore_dresp here is set to true, this call will anyway return
* immediately without waiting for the related delayed response.
* @pai_get: get the current PAI value for the specified domain.
* @pai_set: set the PAI value for the specified domain to the provided value.
* @measurements_get: retrieve the current average power measurements for the
* specified domain and the related PAI upon which is
* calculated.
* @measurements_threshold_set: set the desired low and high power thresholds
* to be used when registering for notification
* of type POWERCAP_MEASUREMENTS_NOTIFY with this
* powercap domain.
* Note that this must be called at least once
* before registering any callback with the usual
* @scmi_notify_ops; moreover, in case this method
* is called with measurement notifications already
* enabled it will also trigger, transparently, a
* proper update of the power thresholds configured
* in the SCMI backend server.
* @measurements_threshold_get: get the currently configured low and high power
* thresholds used when registering callbacks for
* notification POWERCAP_MEASUREMENTS_NOTIFY.
*/
struct scmi_powercap_proto_ops {
int (*num_domains_get)(const struct scmi_protocol_handle *ph);
const struct scmi_powercap_info __must_check *(*info_get)
(const struct scmi_protocol_handle *ph, u32 domain_id);
int (*cap_get)(const struct scmi_protocol_handle *ph, u32 domain_id,
u32 *power_cap);
int (*cap_set)(const struct scmi_protocol_handle *ph, u32 domain_id,
u32 power_cap, bool ignore_dresp);
int (*pai_get)(const struct scmi_protocol_handle *ph, u32 domain_id,
u32 *pai);
int (*pai_set)(const struct scmi_protocol_handle *ph, u32 domain_id,
u32 pai);
int (*measurements_get)(const struct scmi_protocol_handle *ph,
u32 domain_id, u32 *average_power, u32 *pai);
int (*measurements_threshold_set)(const struct scmi_protocol_handle *ph,
u32 domain_id, u32 power_thresh_low,
u32 power_thresh_high);
int (*measurements_threshold_get)(const struct scmi_protocol_handle *ph,
u32 domain_id, u32 *power_thresh_low,
u32 *power_thresh_high);
};
/** /**
* struct scmi_notify_ops - represents notifications' operations provided by * struct scmi_notify_ops - represents notifications' operations provided by
* SCMI core * SCMI core
...@@ -624,6 +734,9 @@ struct scmi_notify_ops { ...@@ -624,6 +734,9 @@ struct scmi_notify_ops {
* *
* @dev: pointer to the SCMI device * @dev: pointer to the SCMI device
* @version: pointer to the structure containing SCMI version information * @version: pointer to the structure containing SCMI version information
* @devm_protocol_acquire: devres managed method to get hold of a protocol,
* causing its initialization and related resource
* accounting
* @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
...@@ -642,6 +755,8 @@ struct scmi_handle { ...@@ -642,6 +755,8 @@ struct scmi_handle {
struct device *dev; struct device *dev;
struct scmi_revision_info *version; struct scmi_revision_info *version;
int __must_check (*devm_protocol_acquire)(struct scmi_device *sdev,
u8 proto);
const void __must_check * const void __must_check *
(*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);
...@@ -661,6 +776,7 @@ enum scmi_std_protocol { ...@@ -661,6 +776,7 @@ enum scmi_std_protocol {
SCMI_PROTOCOL_SENSOR = 0x15, SCMI_PROTOCOL_SENSOR = 0x15,
SCMI_PROTOCOL_RESET = 0x16, SCMI_PROTOCOL_RESET = 0x16,
SCMI_PROTOCOL_VOLTAGE = 0x17, SCMI_PROTOCOL_VOLTAGE = 0x17,
SCMI_PROTOCOL_POWERCAP = 0x18,
}; };
enum scmi_system_events { enum scmi_system_events {
...@@ -762,6 +878,8 @@ enum scmi_notification_events { ...@@ -762,6 +878,8 @@ enum scmi_notification_events {
SCMI_EVENT_RESET_ISSUED = 0x0, SCMI_EVENT_RESET_ISSUED = 0x0,
SCMI_EVENT_BASE_ERROR_EVENT = 0x0, SCMI_EVENT_BASE_ERROR_EVENT = 0x0,
SCMI_EVENT_SYSTEM_POWER_STATE_NOTIFIER = 0x0, SCMI_EVENT_SYSTEM_POWER_STATE_NOTIFIER = 0x0,
SCMI_EVENT_POWERCAP_CAP_CHANGED = 0x0,
SCMI_EVENT_POWERCAP_MEASUREMENTS_CHANGED = 0x1,
}; };
struct scmi_power_state_changed_report { struct scmi_power_state_changed_report {
...@@ -781,8 +899,10 @@ struct scmi_clock_rate_notif_report { ...@@ -781,8 +899,10 @@ struct scmi_clock_rate_notif_report {
struct scmi_system_power_state_notifier_report { struct scmi_system_power_state_notifier_report {
ktime_t timestamp; ktime_t timestamp;
unsigned int agent_id; unsigned int agent_id;
#define SCMI_SYSPOWER_IS_REQUEST_GRACEFUL(flags) ((flags) & BIT(0))
unsigned int flags; unsigned int flags;
unsigned int system_state; unsigned int system_state;
unsigned int timeout;
}; };
struct scmi_perf_limits_report { struct scmi_perf_limits_report {
...@@ -830,4 +950,18 @@ struct scmi_base_error_report { ...@@ -830,4 +950,18 @@ struct scmi_base_error_report {
unsigned long long reports[]; unsigned long long reports[];
}; };
struct scmi_powercap_cap_changed_report {
ktime_t timestamp;
unsigned int agent_id;
unsigned int domain_id;
unsigned int power_cap;
unsigned int pai;
};
struct scmi_powercap_meas_changed_report {
ktime_t timestamp;
unsigned int agent_id;
unsigned int domain_id;
unsigned int power;
};
#endif /* _LINUX_SCMI_PROTOCOL_H */ #endif /* _LINUX_SCMI_PROTOCOL_H */
...@@ -7,6 +7,31 @@ ...@@ -7,6 +7,31 @@
#include <linux/tracepoint.h> #include <linux/tracepoint.h>
TRACE_EVENT(scmi_fc_call,
TP_PROTO(u8 protocol_id, u8 msg_id, u32 res_id, u32 val1, u32 val2),
TP_ARGS(protocol_id, msg_id, res_id, val1, val2),
TP_STRUCT__entry(
__field(u8, protocol_id)
__field(u8, msg_id)
__field(u32, res_id)
__field(u32, val1)
__field(u32, val2)
),
TP_fast_assign(
__entry->protocol_id = protocol_id;
__entry->msg_id = msg_id;
__entry->res_id = res_id;
__entry->val1 = val1;
__entry->val2 = val2;
),
TP_printk("[0x%02X]:[0x%02X]:[%08X]:%u:%u",
__entry->protocol_id, __entry->msg_id,
__entry->res_id, __entry->val1, __entry->val2)
);
TRACE_EVENT(scmi_xfer_begin, TRACE_EVENT(scmi_xfer_begin,
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,
bool poll), bool poll),
...@@ -112,6 +137,37 @@ TRACE_EVENT(scmi_rx_done, ...@@ -112,6 +137,37 @@ TRACE_EVENT(scmi_rx_done,
__entry->transfer_id, __entry->msg_id, __entry->protocol_id, __entry->transfer_id, __entry->msg_id, __entry->protocol_id,
__entry->seq, __entry->msg_type) __entry->seq, __entry->msg_type)
); );
TRACE_EVENT(scmi_msg_dump,
TP_PROTO(u8 protocol_id, u8 msg_id, unsigned char *tag, u16 seq,
int status, void *buf, size_t len),
TP_ARGS(protocol_id, msg_id, tag, seq, status, buf, len),
TP_STRUCT__entry(
__field(u8, protocol_id)
__field(u8, msg_id)
__array(char, tag, 5)
__field(u16, seq)
__field(int, status)
__field(size_t, len)
__dynamic_array(unsigned char, cmd, len)
),
TP_fast_assign(
__entry->protocol_id = protocol_id;
__entry->msg_id = msg_id;
strscpy(__entry->tag, tag, 5);
__entry->seq = seq;
__entry->status = status;
__entry->len = len;
memcpy(__get_dynamic_array(cmd), buf, __entry->len);
),
TP_printk("pt=%02X t=%s msg_id=%02X seq=%04X s=%d pyld=%s",
__entry->protocol_id, __entry->tag, __entry->msg_id,
__entry->seq, __entry->status,
__print_hex_str(__get_dynamic_array(cmd), __entry->len))
);
#endif /* _TRACE_SCMI_H */ #endif /* _TRACE_SCMI_H */
/* This part must be outside protection */ /* This part must be outside protection */
......
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