PM: EM: Add a skeleton code for netlink notification

Add a boilerplate code for netlink notification to register the new
protocol family. Also, initialize and register the netlink during booting.
The initialization is called at the postcore level, which is late enough
after the generic netlink is initialized.

Finally, update MAINTAINERS to include new files.

Signed-off-by: Changwoo Min <changwoo@igalia.com>
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
Link: https://patch.msgid.link/20251020220914.320832-5-changwoo@igalia.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
Changwoo Min 2025-10-21 07:09:08 +09:00 committed by Rafael J. Wysocki
parent bd26631ccd
commit e4ed8d26c5
4 changed files with 54 additions and 2 deletions

View File

@ -9183,7 +9183,7 @@ F: include/linux/energy_model.h
F: Documentation/power/energy-model.rst
F: Documentation/netlink/specs/em.yaml
F: include/uapi/linux/energy_model.h
F: kernel/power/em_netlink_autogen.*
F: kernel/power/em_netlink*.*
EPAPR HYPERVISOR BYTE CHANNEL DEVICE DRIVER
M: Laurentiu Tudor <laurentiu.tudor@nxp.com>

View File

@ -21,4 +21,6 @@ obj-$(CONFIG_PM_WAKELOCKS) += wakelock.o
obj-$(CONFIG_MAGIC_SYSRQ) += poweroff.o
obj-$(CONFIG_ENERGY_MODEL) += energy_model.o
obj-$(CONFIG_ENERGY_MODEL) += em.o
em-y := energy_model.o
em-$(CONFIG_NET) += em_netlink_autogen.o em_netlink.o

34
kernel/power/em_netlink.c Normal file
View File

@ -0,0 +1,34 @@
// SPDX-License-Identifier: GPL-2.0
/*
*
* Generic netlink for energy model.
*
* Copyright (c) 2025 Valve Corporation.
* Author: Changwoo Min <changwoo@igalia.com>
*/
#define pr_fmt(fmt) "energy_model: " fmt
#include <linux/energy_model.h>
#include <net/sock.h>
#include <net/genetlink.h>
#include <uapi/linux/energy_model.h>
#include "em_netlink.h"
#include "em_netlink_autogen.h"
int em_nl_get_pds_doit(struct sk_buff *skb, struct genl_info *info)
{
return -EOPNOTSUPP;
}
int em_nl_get_pd_table_doit(struct sk_buff *skb, struct genl_info *info)
{
return -EOPNOTSUPP;
}
static int __init em_netlink_init(void)
{
return genl_register_family(&em_nl_family);
}
postcore_initcall(em_netlink_init);

16
kernel/power/em_netlink.h Normal file
View File

@ -0,0 +1,16 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
*
* Generic netlink for energy model.
*
* Copyright (c) 2025 Valve Corporation.
* Author: Changwoo Min <changwoo@igalia.com>
*/
#ifndef _EM_NETLINK_H
#define _EM_NETLINK_H
#if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_NET)
#else
#endif
#endif /* _EM_NETLINK_H */