Skip to content

Commit b2b1bbc

Browse files
multics69rafaeljw
authored andcommitted
PM: EM: Implement em_notify_pd_deleted()
Add the event notification infrastructure and implement the event notification for when a performance domain is deleted (EM_CMD_PD_DELETED). The event contains the ID of the performance domain (EM_A_PD_TABLE_PD_ID) so the userspace can identify the changed performance domain for further processing. Signed-off-by: Changwoo Min <changwoo@igalia.com> Reviewed-by: Lukasz Luba <lukasz.luba@arm.com> Link: https://patch.msgid.link/20251020220914.320832-9-changwoo@igalia.com Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent f2d2946 commit b2b1bbc

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

kernel/power/em_netlink.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,50 @@ int em_nl_get_pd_table_doit(struct sk_buff *skb, struct genl_info *info)
213213
return ret;
214214
}
215215

216+
217+
/**************************** Event encoding *********************************/
218+
static int __em_notify_pd_deleted_size(const struct em_perf_domain *pd)
219+
{
220+
int id_sz = nla_total_size(sizeof(u32)); /* EM_A_PD_TABLE_PD_ID */
221+
222+
return nlmsg_total_size(genlmsg_msg_size(id_sz));
223+
}
224+
225+
void em_notify_pd_deleted(const struct em_perf_domain *pd)
226+
{
227+
struct sk_buff *msg;
228+
void *hdr;
229+
int msg_sz;
230+
231+
if (!genl_has_listeners(&em_nl_family, &init_net, EM_NLGRP_EVENT))
232+
return;
233+
234+
msg_sz = __em_notify_pd_deleted_size(pd);
235+
236+
msg = genlmsg_new(msg_sz, GFP_KERNEL);
237+
if (!msg)
238+
return;
239+
240+
hdr = genlmsg_put(msg, 0, 0, &em_nl_family, 0, EM_CMD_PD_DELETED);
241+
if (!hdr)
242+
goto out_free_msg;
243+
244+
if (nla_put_u32(msg, EM_A_PD_TABLE_PD_ID, pd->id)) {
245+
goto out_free_msg;
246+
}
247+
248+
genlmsg_end(msg, hdr);
249+
250+
genlmsg_multicast(&em_nl_family, msg, 0, EM_NLGRP_EVENT, GFP_KERNEL);
251+
252+
return;
253+
254+
out_free_msg:
255+
nlmsg_free(msg);
256+
return;
257+
}
258+
259+
/**************************** Initialization *********************************/
216260
static int __init em_netlink_init(void)
217261
{
218262
return genl_register_family(&em_nl_family);

kernel/power/em_netlink.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
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_deleted(const struct em_perf_domain *pd);
1617
#else
1718
static inline
1819
int for_each_em_perf_domain(int (*cb)(struct em_perf_domain*, void *),
@@ -25,6 +26,8 @@ struct em_perf_domain *em_perf_domain_get_by_id(int id)
2526
{
2627
return NULL;
2728
}
29+
30+
static inline void em_notify_pd_deleted(const struct em_perf_domain *pd) {}
2831
#endif
2932

3033
#endif /* _EM_NETLINK_H */

0 commit comments

Comments
 (0)