1 // SPDX-License-Identifier: GPL-2.0
3 * System Control and Management Interface (SCMI) Performance Protocol
5 * Copyright (C) 2018-2021 ARM Ltd.
8 #define pr_fmt(fmt) "SCMI Notifications PERF - " fmt
10 #include <linux/bits.h>
13 #include <linux/io-64-nonatomic-hi-lo.h>
14 #include <linux/platform_device.h>
15 #include <linux/pm_opp.h>
16 #include <linux/scmi_protocol.h>
17 #include <linux/sort.h>
22 enum scmi_performance_protocol_cmd {
23 PERF_DOMAIN_ATTRIBUTES = 0x3,
24 PERF_DESCRIBE_LEVELS = 0x4,
25 PERF_LIMITS_SET = 0x5,
26 PERF_LIMITS_GET = 0x6,
29 PERF_NOTIFY_LIMITS = 0x9,
30 PERF_NOTIFY_LEVEL = 0xa,
31 PERF_DESCRIBE_FASTCHANNEL = 0xb,
40 struct scmi_msg_resp_perf_attributes {
43 #define POWER_SCALE_IN_MILLIWATT(x) ((x) & BIT(0))
44 __le32 stats_addr_low;
45 __le32 stats_addr_high;
49 struct scmi_msg_resp_perf_domain_attributes {
51 #define SUPPORTS_SET_LIMITS(x) ((x) & BIT(31))
52 #define SUPPORTS_SET_PERF_LVL(x) ((x) & BIT(30))
53 #define SUPPORTS_PERF_LIMIT_NOTIFY(x) ((x) & BIT(29))
54 #define SUPPORTS_PERF_LEVEL_NOTIFY(x) ((x) & BIT(28))
55 #define SUPPORTS_PERF_FASTCHANNELS(x) ((x) & BIT(27))
57 __le32 sustained_freq_khz;
58 __le32 sustained_perf_level;
59 u8 name[SCMI_MAX_STR_SIZE];
62 struct scmi_msg_perf_describe_levels {
67 struct scmi_perf_set_limits {
73 struct scmi_perf_get_limits {
78 struct scmi_perf_set_level {
83 struct scmi_perf_notify_level_or_limits {
88 struct scmi_perf_limits_notify_payld {
95 struct scmi_perf_level_notify_payld {
98 __le32 performance_level;
101 struct scmi_msg_resp_perf_describe_levels {
103 __le16 num_remaining;
107 __le16 transition_latency_us;
112 struct scmi_perf_get_fc_info {
117 struct scmi_msg_resp_perf_desc_fc {
119 #define SUPPORTS_DOORBELL(x) ((x) & BIT(0))
120 #define DOORBELL_REG_WIDTH(x) FIELD_GET(GENMASK(2, 1), (x))
122 __le32 chan_addr_low;
123 __le32 chan_addr_high;
129 __le32 db_preserve_lmask;
130 __le32 db_preserve_hmask;
133 struct scmi_fc_db_info {
140 struct scmi_fc_info {
141 void __iomem *level_set_addr;
142 void __iomem *limit_set_addr;
143 void __iomem *level_get_addr;
144 void __iomem *limit_get_addr;
145 struct scmi_fc_db_info *level_set_db;
146 struct scmi_fc_db_info *limit_set_db;
149 struct perf_dom_info {
152 bool perf_limit_notify;
153 bool perf_level_notify;
154 bool perf_fastchannels;
156 u32 sustained_freq_khz;
157 u32 sustained_perf_level;
159 char name[SCMI_MAX_STR_SIZE];
160 struct scmi_opp opp[MAX_OPPS];
161 struct scmi_fc_info *fc_info;
164 struct scmi_perf_info {
170 struct perf_dom_info *dom_info;
173 static enum scmi_performance_protocol_cmd evt_2_cmd[] = {
178 static int scmi_perf_attributes_get(const struct scmi_protocol_handle *ph,
179 struct scmi_perf_info *pi)
183 struct scmi_msg_resp_perf_attributes *attr;
185 ret = ph->xops->xfer_get_init(ph, PROTOCOL_ATTRIBUTES, 0,
192 ret = ph->xops->do_xfer(ph, t);
194 u16 flags = le16_to_cpu(attr->flags);
196 pi->num_domains = le16_to_cpu(attr->num_domains);
197 pi->power_scale_mw = POWER_SCALE_IN_MILLIWATT(flags);
198 pi->stats_addr = le32_to_cpu(attr->stats_addr_low) |
199 (u64)le32_to_cpu(attr->stats_addr_high) << 32;
200 pi->stats_size = le32_to_cpu(attr->stats_size);
203 ph->xops->xfer_put(ph, t);
208 scmi_perf_domain_attributes_get(const struct scmi_protocol_handle *ph,
209 u32 domain, struct perf_dom_info *dom_info)
213 struct scmi_msg_resp_perf_domain_attributes *attr;
215 ret = ph->xops->xfer_get_init(ph, PERF_DOMAIN_ATTRIBUTES,
216 sizeof(domain), sizeof(*attr), &t);
220 put_unaligned_le32(domain, t->tx.buf);
223 ret = ph->xops->do_xfer(ph, t);
225 u32 flags = le32_to_cpu(attr->flags);
227 dom_info->set_limits = SUPPORTS_SET_LIMITS(flags);
228 dom_info->set_perf = SUPPORTS_SET_PERF_LVL(flags);
229 dom_info->perf_limit_notify = SUPPORTS_PERF_LIMIT_NOTIFY(flags);
230 dom_info->perf_level_notify = SUPPORTS_PERF_LEVEL_NOTIFY(flags);
231 dom_info->perf_fastchannels = SUPPORTS_PERF_FASTCHANNELS(flags);
232 dom_info->sustained_freq_khz =
233 le32_to_cpu(attr->sustained_freq_khz);
234 dom_info->sustained_perf_level =
235 le32_to_cpu(attr->sustained_perf_level);
236 if (!dom_info->sustained_freq_khz ||
237 !dom_info->sustained_perf_level)
238 /* CPUFreq converts to kHz, hence default 1000 */
239 dom_info->mult_factor = 1000;
241 dom_info->mult_factor =
242 (dom_info->sustained_freq_khz * 1000) /
243 dom_info->sustained_perf_level;
244 strlcpy(dom_info->name, attr->name, SCMI_MAX_STR_SIZE);
247 ph->xops->xfer_put(ph, t);
251 static int opp_cmp_func(const void *opp1, const void *opp2)
253 const struct scmi_opp *t1 = opp1, *t2 = opp2;
255 return t1->perf - t2->perf;
259 scmi_perf_describe_levels_get(const struct scmi_protocol_handle *ph, u32 domain,
260 struct perf_dom_info *perf_dom)
264 u16 num_returned, num_remaining;
266 struct scmi_opp *opp;
267 struct scmi_msg_perf_describe_levels *dom_info;
268 struct scmi_msg_resp_perf_describe_levels *level_info;
270 ret = ph->xops->xfer_get_init(ph, PERF_DESCRIBE_LEVELS,
271 sizeof(*dom_info), 0, &t);
275 dom_info = t->tx.buf;
276 level_info = t->rx.buf;
279 dom_info->domain = cpu_to_le32(domain);
280 /* Set the number of OPPs to be skipped/already read */
281 dom_info->level_index = cpu_to_le32(tot_opp_cnt);
283 ret = ph->xops->do_xfer(ph, t);
287 num_returned = le16_to_cpu(level_info->num_returned);
288 num_remaining = le16_to_cpu(level_info->num_remaining);
289 if (tot_opp_cnt + num_returned > MAX_OPPS) {
290 dev_err(ph->dev, "No. of OPPs exceeded MAX_OPPS");
294 opp = &perf_dom->opp[tot_opp_cnt];
295 for (cnt = 0; cnt < num_returned; cnt++, opp++) {
296 opp->perf = le32_to_cpu(level_info->opp[cnt].perf_val);
297 opp->power = le32_to_cpu(level_info->opp[cnt].power);
298 opp->trans_latency_us = le16_to_cpu
299 (level_info->opp[cnt].transition_latency_us);
301 dev_dbg(ph->dev, "Level %d Power %d Latency %dus\n",
302 opp->perf, opp->power, opp->trans_latency_us);
305 tot_opp_cnt += num_returned;
307 ph->xops->reset_rx_to_maxsz(ph, t);
309 * check for both returned and remaining to avoid infinite
310 * loop due to buggy firmware
312 } while (num_returned && num_remaining);
314 perf_dom->opp_count = tot_opp_cnt;
315 ph->xops->xfer_put(ph, t);
317 sort(perf_dom->opp, tot_opp_cnt, sizeof(*opp), opp_cmp_func, NULL);
321 #define SCMI_PERF_FC_RING_DB(w) \
326 val = ioread##w(db->addr) & db->mask; \
327 iowrite##w((u##w)db->set | val, db->addr); \
330 static void scmi_perf_fc_ring_db(struct scmi_fc_db_info *db)
332 if (!db || !db->addr)
336 SCMI_PERF_FC_RING_DB(8);
337 else if (db->width == 2)
338 SCMI_PERF_FC_RING_DB(16);
339 else if (db->width == 4)
340 SCMI_PERF_FC_RING_DB(32);
341 else /* db->width == 8 */
343 SCMI_PERF_FC_RING_DB(64);
349 val = ioread64_hi_lo(db->addr) & db->mask;
350 iowrite64_hi_lo(db->set | val, db->addr);
355 static int scmi_perf_mb_limits_set(const struct scmi_protocol_handle *ph,
356 u32 domain, u32 max_perf, u32 min_perf)
360 struct scmi_perf_set_limits *limits;
362 ret = ph->xops->xfer_get_init(ph, PERF_LIMITS_SET,
363 sizeof(*limits), 0, &t);
368 limits->domain = cpu_to_le32(domain);
369 limits->max_level = cpu_to_le32(max_perf);
370 limits->min_level = cpu_to_le32(min_perf);
372 ret = ph->xops->do_xfer(ph, t);
374 ph->xops->xfer_put(ph, t);
378 static int scmi_perf_limits_set(const struct scmi_protocol_handle *ph,
379 u32 domain, u32 max_perf, u32 min_perf)
381 struct scmi_perf_info *pi = ph->get_priv(ph);
382 struct perf_dom_info *dom = pi->dom_info + domain;
384 if (dom->fc_info && dom->fc_info->limit_set_addr) {
385 iowrite32(max_perf, dom->fc_info->limit_set_addr);
386 iowrite32(min_perf, dom->fc_info->limit_set_addr + 4);
387 scmi_perf_fc_ring_db(dom->fc_info->limit_set_db);
391 return scmi_perf_mb_limits_set(ph, domain, max_perf, min_perf);
394 static int scmi_perf_mb_limits_get(const struct scmi_protocol_handle *ph,
395 u32 domain, u32 *max_perf, u32 *min_perf)
399 struct scmi_perf_get_limits *limits;
401 ret = ph->xops->xfer_get_init(ph, PERF_LIMITS_GET,
402 sizeof(__le32), 0, &t);
406 put_unaligned_le32(domain, t->tx.buf);
408 ret = ph->xops->do_xfer(ph, t);
412 *max_perf = le32_to_cpu(limits->max_level);
413 *min_perf = le32_to_cpu(limits->min_level);
416 ph->xops->xfer_put(ph, t);
420 static int scmi_perf_limits_get(const struct scmi_protocol_handle *ph,
421 u32 domain, u32 *max_perf, u32 *min_perf)
423 struct scmi_perf_info *pi = ph->get_priv(ph);
424 struct perf_dom_info *dom = pi->dom_info + domain;
426 if (dom->fc_info && dom->fc_info->limit_get_addr) {
427 *max_perf = ioread32(dom->fc_info->limit_get_addr);
428 *min_perf = ioread32(dom->fc_info->limit_get_addr + 4);
432 return scmi_perf_mb_limits_get(ph, domain, max_perf, min_perf);
435 static int scmi_perf_mb_level_set(const struct scmi_protocol_handle *ph,
436 u32 domain, u32 level, bool poll)
440 struct scmi_perf_set_level *lvl;
442 ret = ph->xops->xfer_get_init(ph, PERF_LEVEL_SET, sizeof(*lvl), 0, &t);
446 t->hdr.poll_completion = poll;
448 lvl->domain = cpu_to_le32(domain);
449 lvl->level = cpu_to_le32(level);
451 ret = ph->xops->do_xfer(ph, t);
453 ph->xops->xfer_put(ph, t);
457 static int scmi_perf_level_set(const struct scmi_protocol_handle *ph,
458 u32 domain, u32 level, bool poll)
460 struct scmi_perf_info *pi = ph->get_priv(ph);
461 struct perf_dom_info *dom = pi->dom_info + domain;
463 if (dom->fc_info && dom->fc_info->level_set_addr) {
464 iowrite32(level, dom->fc_info->level_set_addr);
465 scmi_perf_fc_ring_db(dom->fc_info->level_set_db);
469 return scmi_perf_mb_level_set(ph, domain, level, poll);
472 static int scmi_perf_mb_level_get(const struct scmi_protocol_handle *ph,
473 u32 domain, u32 *level, bool poll)
478 ret = ph->xops->xfer_get_init(ph, PERF_LEVEL_GET,
479 sizeof(u32), sizeof(u32), &t);
483 t->hdr.poll_completion = poll;
484 put_unaligned_le32(domain, t->tx.buf);
486 ret = ph->xops->do_xfer(ph, t);
488 *level = get_unaligned_le32(t->rx.buf);
490 ph->xops->xfer_put(ph, t);
494 static int scmi_perf_level_get(const struct scmi_protocol_handle *ph,
495 u32 domain, u32 *level, bool poll)
497 struct scmi_perf_info *pi = ph->get_priv(ph);
498 struct perf_dom_info *dom = pi->dom_info + domain;
500 if (dom->fc_info && dom->fc_info->level_get_addr) {
501 *level = ioread32(dom->fc_info->level_get_addr);
505 return scmi_perf_mb_level_get(ph, domain, level, poll);
508 static int scmi_perf_level_limits_notify(const struct scmi_protocol_handle *ph,
509 u32 domain, int message_id,
514 struct scmi_perf_notify_level_or_limits *notify;
516 ret = ph->xops->xfer_get_init(ph, message_id, sizeof(*notify), 0, &t);
521 notify->domain = cpu_to_le32(domain);
522 notify->notify_enable = enable ? cpu_to_le32(BIT(0)) : 0;
524 ret = ph->xops->do_xfer(ph, t);
526 ph->xops->xfer_put(ph, t);
530 static bool scmi_perf_fc_size_is_valid(u32 msg, u32 size)
532 if ((msg == PERF_LEVEL_GET || msg == PERF_LEVEL_SET) && size == 4)
534 if ((msg == PERF_LIMITS_GET || msg == PERF_LIMITS_SET) && size == 8)
540 scmi_perf_domain_desc_fc(const struct scmi_protocol_handle *ph, u32 domain,
541 u32 message_id, void __iomem **p_addr,
542 struct scmi_fc_db_info **p_db)
550 struct scmi_fc_db_info *db;
551 struct scmi_perf_get_fc_info *info;
552 struct scmi_msg_resp_perf_desc_fc *resp;
557 ret = ph->xops->xfer_get_init(ph, PERF_DESCRIBE_FASTCHANNEL,
558 sizeof(*info), sizeof(*resp), &t);
563 info->domain = cpu_to_le32(domain);
564 info->message_id = cpu_to_le32(message_id);
566 ret = ph->xops->do_xfer(ph, t);
571 flags = le32_to_cpu(resp->attr);
572 size = le32_to_cpu(resp->chan_size);
573 if (!scmi_perf_fc_size_is_valid(message_id, size))
576 phys_addr = le32_to_cpu(resp->chan_addr_low);
577 phys_addr |= (u64)le32_to_cpu(resp->chan_addr_high) << 32;
578 addr = devm_ioremap(ph->dev, phys_addr, size);
583 if (p_db && SUPPORTS_DOORBELL(flags)) {
584 db = devm_kzalloc(ph->dev, sizeof(*db), GFP_KERNEL);
588 size = 1 << DOORBELL_REG_WIDTH(flags);
589 phys_addr = le32_to_cpu(resp->db_addr_low);
590 phys_addr |= (u64)le32_to_cpu(resp->db_addr_high) << 32;
591 addr = devm_ioremap(ph->dev, phys_addr, size);
597 db->set = le32_to_cpu(resp->db_set_lmask);
598 db->set |= (u64)le32_to_cpu(resp->db_set_hmask) << 32;
599 db->mask = le32_to_cpu(resp->db_preserve_lmask);
600 db->mask |= (u64)le32_to_cpu(resp->db_preserve_hmask) << 32;
604 ph->xops->xfer_put(ph, t);
607 static void scmi_perf_domain_init_fc(const struct scmi_protocol_handle *ph,
608 u32 domain, struct scmi_fc_info **p_fc)
610 struct scmi_fc_info *fc;
612 fc = devm_kzalloc(ph->dev, sizeof(*fc), GFP_KERNEL);
616 scmi_perf_domain_desc_fc(ph, domain, PERF_LEVEL_SET,
617 &fc->level_set_addr, &fc->level_set_db);
618 scmi_perf_domain_desc_fc(ph, domain, PERF_LEVEL_GET,
619 &fc->level_get_addr, NULL);
620 scmi_perf_domain_desc_fc(ph, domain, PERF_LIMITS_SET,
621 &fc->limit_set_addr, &fc->limit_set_db);
622 scmi_perf_domain_desc_fc(ph, domain, PERF_LIMITS_GET,
623 &fc->limit_get_addr, NULL);
627 /* Device specific ops */
628 static int scmi_dev_domain_id(struct device *dev)
630 struct of_phandle_args clkspec;
632 if (of_parse_phandle_with_args(dev->of_node, "clocks", "#clock-cells",
636 return clkspec.args[0];
639 static int scmi_dvfs_device_opps_add(const struct scmi_protocol_handle *ph,
642 int idx, ret, domain;
644 struct scmi_opp *opp;
645 struct perf_dom_info *dom;
646 struct scmi_perf_info *pi = ph->get_priv(ph);
648 domain = scmi_dev_domain_id(dev);
652 dom = pi->dom_info + domain;
654 for (opp = dom->opp, idx = 0; idx < dom->opp_count; idx++, opp++) {
655 freq = opp->perf * dom->mult_factor;
657 ret = dev_pm_opp_add(dev, freq, 0);
659 dev_warn(dev, "failed to add opp %luHz\n", freq);
662 freq = (--opp)->perf * dom->mult_factor;
663 dev_pm_opp_remove(dev, freq);
672 scmi_dvfs_transition_latency_get(const struct scmi_protocol_handle *ph,
675 struct perf_dom_info *dom;
676 struct scmi_perf_info *pi = ph->get_priv(ph);
677 int domain = scmi_dev_domain_id(dev);
682 dom = pi->dom_info + domain;
684 return dom->opp[dom->opp_count - 1].trans_latency_us * 1000;
687 static int scmi_dvfs_freq_set(const struct scmi_protocol_handle *ph, u32 domain,
688 unsigned long freq, bool poll)
690 struct scmi_perf_info *pi = ph->get_priv(ph);
691 struct perf_dom_info *dom = pi->dom_info + domain;
693 return scmi_perf_level_set(ph, domain, freq / dom->mult_factor, poll);
696 static int scmi_dvfs_freq_get(const struct scmi_protocol_handle *ph, u32 domain,
697 unsigned long *freq, bool poll)
701 struct scmi_perf_info *pi = ph->get_priv(ph);
702 struct perf_dom_info *dom = pi->dom_info + domain;
704 ret = scmi_perf_level_get(ph, domain, &level, poll);
706 *freq = level * dom->mult_factor;
711 static int scmi_dvfs_est_power_get(const struct scmi_protocol_handle *ph,
712 u32 domain, unsigned long *freq,
713 unsigned long *power)
715 struct scmi_perf_info *pi = ph->get_priv(ph);
716 struct perf_dom_info *dom;
717 unsigned long opp_freq;
718 int idx, ret = -EINVAL;
719 struct scmi_opp *opp;
721 dom = pi->dom_info + domain;
725 for (opp = dom->opp, idx = 0; idx < dom->opp_count; idx++, opp++) {
726 opp_freq = opp->perf * dom->mult_factor;
727 if (opp_freq < *freq)
739 static bool scmi_fast_switch_possible(const struct scmi_protocol_handle *ph,
742 struct perf_dom_info *dom;
743 struct scmi_perf_info *pi = ph->get_priv(ph);
745 dom = pi->dom_info + scmi_dev_domain_id(dev);
747 return dom->fc_info && dom->fc_info->level_set_addr;
750 static bool scmi_power_scale_mw_get(const struct scmi_protocol_handle *ph)
752 struct scmi_perf_info *pi = ph->get_priv(ph);
754 return pi->power_scale_mw;
757 static const struct scmi_perf_proto_ops perf_proto_ops = {
758 .limits_set = scmi_perf_limits_set,
759 .limits_get = scmi_perf_limits_get,
760 .level_set = scmi_perf_level_set,
761 .level_get = scmi_perf_level_get,
762 .device_domain_id = scmi_dev_domain_id,
763 .transition_latency_get = scmi_dvfs_transition_latency_get,
764 .device_opps_add = scmi_dvfs_device_opps_add,
765 .freq_set = scmi_dvfs_freq_set,
766 .freq_get = scmi_dvfs_freq_get,
767 .est_power_get = scmi_dvfs_est_power_get,
768 .fast_switch_possible = scmi_fast_switch_possible,
769 .power_scale_mw_get = scmi_power_scale_mw_get,
772 static int scmi_perf_set_notify_enabled(const struct scmi_protocol_handle *ph,
773 u8 evt_id, u32 src_id, bool enable)
777 if (evt_id >= ARRAY_SIZE(evt_2_cmd))
780 cmd_id = evt_2_cmd[evt_id];
781 ret = scmi_perf_level_limits_notify(ph, src_id, cmd_id, enable);
783 pr_debug("FAIL_ENABLED - evt[%X] dom[%d] - ret:%d\n",
784 evt_id, src_id, ret);
789 static void *scmi_perf_fill_custom_report(const struct scmi_protocol_handle *ph,
790 u8 evt_id, ktime_t timestamp,
791 const void *payld, size_t payld_sz,
792 void *report, u32 *src_id)
797 case SCMI_EVENT_PERFORMANCE_LIMITS_CHANGED:
799 const struct scmi_perf_limits_notify_payld *p = payld;
800 struct scmi_perf_limits_report *r = report;
802 if (sizeof(*p) != payld_sz)
805 r->timestamp = timestamp;
806 r->agent_id = le32_to_cpu(p->agent_id);
807 r->domain_id = le32_to_cpu(p->domain_id);
808 r->range_max = le32_to_cpu(p->range_max);
809 r->range_min = le32_to_cpu(p->range_min);
810 *src_id = r->domain_id;
814 case SCMI_EVENT_PERFORMANCE_LEVEL_CHANGED:
816 const struct scmi_perf_level_notify_payld *p = payld;
817 struct scmi_perf_level_report *r = report;
819 if (sizeof(*p) != payld_sz)
822 r->timestamp = timestamp;
823 r->agent_id = le32_to_cpu(p->agent_id);
824 r->domain_id = le32_to_cpu(p->domain_id);
825 r->performance_level = le32_to_cpu(p->performance_level);
826 *src_id = r->domain_id;
837 static int scmi_perf_get_num_sources(const struct scmi_protocol_handle *ph)
839 struct scmi_perf_info *pi = ph->get_priv(ph);
844 return pi->num_domains;
847 static const struct scmi_event perf_events[] = {
849 .id = SCMI_EVENT_PERFORMANCE_LIMITS_CHANGED,
850 .max_payld_sz = sizeof(struct scmi_perf_limits_notify_payld),
851 .max_report_sz = sizeof(struct scmi_perf_limits_report),
854 .id = SCMI_EVENT_PERFORMANCE_LEVEL_CHANGED,
855 .max_payld_sz = sizeof(struct scmi_perf_level_notify_payld),
856 .max_report_sz = sizeof(struct scmi_perf_level_report),
860 static const struct scmi_event_ops perf_event_ops = {
861 .get_num_sources = scmi_perf_get_num_sources,
862 .set_notify_enabled = scmi_perf_set_notify_enabled,
863 .fill_custom_report = scmi_perf_fill_custom_report,
866 static const struct scmi_protocol_events perf_protocol_events = {
867 .queue_sz = SCMI_PROTO_QUEUE_SZ,
868 .ops = &perf_event_ops,
870 .num_events = ARRAY_SIZE(perf_events),
873 static int scmi_perf_protocol_init(const struct scmi_protocol_handle *ph)
877 struct scmi_perf_info *pinfo;
879 ph->xops->version_get(ph, &version);
881 dev_dbg(ph->dev, "Performance Version %d.%d\n",
882 PROTOCOL_REV_MAJOR(version), PROTOCOL_REV_MINOR(version));
884 pinfo = devm_kzalloc(ph->dev, sizeof(*pinfo), GFP_KERNEL);
888 scmi_perf_attributes_get(ph, pinfo);
890 pinfo->dom_info = devm_kcalloc(ph->dev, pinfo->num_domains,
891 sizeof(*pinfo->dom_info), GFP_KERNEL);
892 if (!pinfo->dom_info)
895 for (domain = 0; domain < pinfo->num_domains; domain++) {
896 struct perf_dom_info *dom = pinfo->dom_info + domain;
898 scmi_perf_domain_attributes_get(ph, domain, dom);
899 scmi_perf_describe_levels_get(ph, domain, dom);
901 if (dom->perf_fastchannels)
902 scmi_perf_domain_init_fc(ph, domain, &dom->fc_info);
905 pinfo->version = version;
907 return ph->set_priv(ph, pinfo);
910 static const struct scmi_protocol scmi_perf = {
911 .id = SCMI_PROTOCOL_PERF,
912 .instance_init = &scmi_perf_protocol_init,
913 .ops = &perf_proto_ops,
914 .events = &perf_protocol_events,
917 DEFINE_SCMI_PROTOCOL_REGISTER_UNREGISTER(perf, scmi_perf)