SCMI updates for v4.20

1. Addition of interface to fetch estimated power from the firmware
    corresponding to each OPP of a device
 
 2. Cleanup using strlcpy to ensure NULL-terminated strings for name
    strings instead of relying on the firmware to do the same
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABCAAGBQJboNR3AAoJEABBurwxfuKY3cwP/jpDt5dlO4mXgYbq/nSzCSUE
 ll67qW9qAhJAxbf6k+eC6pZkbNNErUfsmeD30864S/1G80OqdsRHbOeAIS6NIKsW
 LH6ZPnU9JGzsyLpT/QC1Tk84GzjqqGuBCFFbKqXIC5I5U4srvi+S6h/K+PE++cXe
 wIB0HoGMzFdB6pGQfQOWCgNgSgk7poHoCuIlUP3S7lwUT0fSAWrC5zblxmG+VNo0
 8jj+k4IbF+EqqsjYM/p8KUtCl7hvXtCRBaIdfCyhZBYxepVNbLjC5lNu41hou5Pn
 Xzs6T8atELcJvjqcuHAr9PKa5MY7Ztb/9biaslaJn/WRBwHPPcVqgMw30pZIY2ZY
 6Y81jnKm21jIR0tgTjHKQm3obny5utCwUqNrPkyE+HOZBvCfKHIFFZMEd3EZ0J0h
 H8+xA9MFYWEUnShs8p63gaguwMK2ZPkacGgCVRPHmPCzZ3hv739Oz4JPMGQmPg9C
 XpNu1budX1CplHTjbTTo9xhN7VcubLoJdLta2JiMQKOy1+XiDpp4aqqfydO2Cbbk
 nBwyWza3qDhxd289tYTQPn+FCCHQXq/T+cbfBMQkTx9MQE0Z4cl9DI29/jxPScMY
 m0MIxeSdgIKtUi0t4ybV90VuUdQw9GcPiJpAtgPf/SM0/MpXJjE9GkzqsKETDNZ2
 0iscZDH1DQle+OMyo54f
 =ux6I
 -----END PGP SIGNATURE-----

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

SCMI updates for v4.20

1. Addition of interface to fetch estimated power from the firmware
   corresponding to each OPP of a device

2. Cleanup using strlcpy to ensure NULL-terminated strings for name
   strings instead of relying on the firmware to do the same

* tag 'scmi-updates-4.20' of git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux:
  firmware: arm_scmi: add a getter for power of performance states
  firmware: arm_scmi: use strlcpy to ensure NULL-terminated strings

Signed-off-by: Olof Johansson <olof@lixom.net>
This commit is contained in:
Olof Johansson 2018-09-25 11:31:00 -07:00
commit 5bc45db5d2
6 changed files with 37 additions and 5 deletions

View File

@ -208,7 +208,7 @@ static int scmi_base_discover_agent_get(const struct scmi_handle *handle,
ret = scmi_do_xfer(handle, t);
if (!ret)
memcpy(name, t->rx.buf, SCMI_MAX_STR_SIZE);
strlcpy(name, t->rx.buf, SCMI_MAX_STR_SIZE);
scmi_xfer_put(handle, t);

View File

@ -111,7 +111,7 @@ static int scmi_clock_attributes_get(const struct scmi_handle *handle,
ret = scmi_do_xfer(handle, t);
if (!ret)
memcpy(clk->name, attr->name, SCMI_MAX_STR_SIZE);
strlcpy(clk->name, attr->name, SCMI_MAX_STR_SIZE);
else
clk->name[0] = '\0';

View File

@ -174,7 +174,7 @@ scmi_perf_domain_attributes_get(const struct scmi_handle *handle, u32 domain,
dom_info->mult_factor =
(dom_info->sustained_freq_khz * 1000) /
dom_info->sustained_perf_level;
memcpy(dom_info->name, attr->name, SCMI_MAX_STR_SIZE);
strlcpy(dom_info->name, attr->name, SCMI_MAX_STR_SIZE);
}
scmi_xfer_put(handle, t);
@ -427,6 +427,33 @@ static int scmi_dvfs_freq_get(const struct scmi_handle *handle, u32 domain,
return ret;
}
static int scmi_dvfs_est_power_get(const struct scmi_handle *handle, u32 domain,
unsigned long *freq, unsigned long *power)
{
struct scmi_perf_info *pi = handle->perf_priv;
struct perf_dom_info *dom;
unsigned long opp_freq;
int idx, ret = -EINVAL;
struct scmi_opp *opp;
dom = pi->dom_info + domain;
if (!dom)
return -EIO;
for (opp = dom->opp, idx = 0; idx < dom->opp_count; idx++, opp++) {
opp_freq = opp->perf * dom->mult_factor;
if (opp_freq < *freq)
continue;
*freq = opp_freq;
*power = opp->power;
ret = 0;
break;
}
return ret;
}
static struct scmi_perf_ops perf_ops = {
.limits_set = scmi_perf_limits_set,
.limits_get = scmi_perf_limits_get,
@ -437,6 +464,7 @@ static struct scmi_perf_ops perf_ops = {
.device_opps_add = scmi_dvfs_device_opps_add,
.freq_set = scmi_dvfs_freq_set,
.freq_get = scmi_dvfs_freq_get,
.est_power_get = scmi_dvfs_est_power_get,
};
static int scmi_perf_protocol_init(struct scmi_handle *handle)

View File

@ -106,7 +106,7 @@ scmi_power_domain_attributes_get(const struct scmi_handle *handle, u32 domain,
dom_info->state_set_notify = SUPPORTS_STATE_SET_NOTIFY(flags);
dom_info->state_set_async = SUPPORTS_STATE_SET_ASYNC(flags);
dom_info->state_set_sync = SUPPORTS_STATE_SET_SYNC(flags);
memcpy(dom_info->name, attr->name, SCMI_MAX_STR_SIZE);
strlcpy(dom_info->name, attr->name, SCMI_MAX_STR_SIZE);
}
scmi_xfer_put(handle, t);

View File

@ -140,7 +140,7 @@ static int scmi_sensor_description_get(const struct scmi_handle *handle,
s = &si->sensors[desc_index + cnt];
s->id = le32_to_cpu(buf->desc[cnt].id);
s->type = SENSOR_TYPE(attrh);
memcpy(s->name, buf->desc[cnt].name, SCMI_MAX_STR_SIZE);
strlcpy(s->name, buf->desc[cnt].name, SCMI_MAX_STR_SIZE);
}
desc_index += num_returned;

View File

@ -91,6 +91,8 @@ struct scmi_clk_ops {
* to sustained performance level mapping
* @freq_get: gets the frequency for a given device using sustained frequency
* to sustained performance level mapping
* @est_power_get: gets the estimated power cost for a given performance domain
* at a given frequency
*/
struct scmi_perf_ops {
int (*limits_set)(const struct scmi_handle *handle, u32 domain,
@ -110,6 +112,8 @@ struct scmi_perf_ops {
unsigned long rate, bool poll);
int (*freq_get)(const struct scmi_handle *handle, u32 domain,
unsigned long *rate, bool poll);
int (*est_power_get)(const struct scmi_handle *handle, u32 domain,
unsigned long *rate, unsigned long *power);
};
/**