Skip to content

Commit b95a0c0

Browse files
multics69rafaeljw
authored andcommitted
PM: EM: Implement em_notify_pd_created/updated()
Implement two event notifications when a performance domain is created (EM_CMD_PD_CREATED) and updated (EM_CMD_PD_UPDATED). The message format of these two event notifications is the same as EM_CMD_GET_PD_TABLE -- containing the performance domain's ID and its energy model table. Signed-off-by: Changwoo Min <changwoo@igalia.com> Reviewed-by: Lukasz Luba <lukasz.luba@arm.com> Link: https://patch.msgid.link/20251020220914.320832-10-changwoo@igalia.com Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent b2b1bbc commit b95a0c0

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

kernel/power/em_netlink.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,50 @@ int em_nl_get_pd_table_doit(struct sk_buff *skb, struct genl_info *info)
215215

216216

217217
/**************************** Event encoding *********************************/
218+
static void __em_notify_pd_table(const struct em_perf_domain *pd, int ntf_type)
219+
{
220+
struct sk_buff *msg;
221+
int msg_sz, ret = -EMSGSIZE;
222+
void *hdr;
223+
224+
if (!genl_has_listeners(&em_nl_family, &init_net, EM_NLGRP_EVENT))
225+
return;
226+
227+
msg_sz = __em_nl_get_pd_table_size(pd);
228+
229+
msg = genlmsg_new(msg_sz, GFP_KERNEL);
230+
if (!msg)
231+
return;
232+
233+
hdr = genlmsg_put(msg, 0, 0, &em_nl_family, 0, ntf_type);
234+
if (!hdr)
235+
goto out_free_msg;
236+
237+
ret = __em_nl_get_pd_table(msg, pd);
238+
if (ret)
239+
goto out_free_msg;
240+
241+
genlmsg_end(msg, hdr);
242+
243+
genlmsg_multicast(&em_nl_family, msg, 0, EM_NLGRP_EVENT, GFP_KERNEL);
244+
245+
return;
246+
247+
out_free_msg:
248+
nlmsg_free(msg);
249+
return;
250+
}
251+
252+
void em_notify_pd_created(const struct em_perf_domain *pd)
253+
{
254+
__em_notify_pd_table(pd, EM_CMD_PD_CREATED);
255+
}
256+
257+
void em_notify_pd_updated(const struct em_perf_domain *pd)
258+
{
259+
__em_notify_pd_table(pd, EM_CMD_PD_UPDATED);
260+
}
261+
218262
static int __em_notify_pd_deleted_size(const struct em_perf_domain *pd)
219263
{
220264
int id_sz = nla_total_size(sizeof(u32)); /* EM_A_PD_TABLE_PD_ID */

kernel/power/em_netlink.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
int for_each_em_perf_domain(int (*cb)(struct em_perf_domain*, void *),
1414
void *data);
1515
struct em_perf_domain *em_perf_domain_get_by_id(int id);
16+
void em_notify_pd_created(const struct em_perf_domain *pd);
1617
void em_notify_pd_deleted(const struct em_perf_domain *pd);
18+
void em_notify_pd_updated(const struct em_perf_domain *pd);
1719
#else
1820
static inline
1921
int for_each_em_perf_domain(int (*cb)(struct em_perf_domain*, void *),
@@ -27,7 +29,11 @@ struct em_perf_domain *em_perf_domain_get_by_id(int id)
2729
return NULL;
2830
}
2931

32+
static inline void em_notify_pd_created(const struct em_perf_domain *pd) {}
33+
3034
static inline void em_notify_pd_deleted(const struct em_perf_domain *pd) {}
35+
36+
static inline void em_notify_pd_updated(const struct em_perf_domain *pd) {}
3137
#endif
3238

3339
#endif /* _EM_NETLINK_H */

0 commit comments

Comments
 (0)