Introduce struct dev_liveupdate and add it to struct device. Use the new struct to track a device's liveupdate states. - requested: The device is requested for a live update. - depended: One of the child devices is requested for live update. When the device is requested, the dev->lu.requested will set to 1. Signed-off-by: Chris Li <chrisl@xxxxxxxxxx> --- drivers/pci/liveupdate.c | 3 +++ include/linux/dev_liveupdate.h | 35 +++++++++++++++++++++++++++++++++++ include/linux/device.h | 6 ++++++ 3 files changed, 44 insertions(+) diff --git a/drivers/pci/liveupdate.c b/drivers/pci/liveupdate.c index 86b4f3a2fb44781c6e323ba029db510450556fa9..1c69adf412255c8ee5bc6db588ff04b1642e8e19 100644 --- a/drivers/pci/liveupdate.c +++ b/drivers/pci/liveupdate.c @@ -6,8 +6,11 @@ */ #define pr_fmt(fmt) "PCI liveupdate: " fmt +#define dev_fmt(fmt) "PCI liveupdate: " fmt +#include <linux/types.h> #include <linux/liveupdate.h> +#include "pci.h" #define PCI_SUBSYSTEM_NAME "pci" diff --git a/include/linux/dev_liveupdate.h b/include/linux/dev_liveupdate.h new file mode 100644 index 0000000000000000000000000000000000000000..057407c030b0872bfa8cd666e6ffc305f7aa4083 --- /dev/null +++ b/include/linux/dev_liveupdate.h @@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* + * Copyright (c) 2025, Google LLC. + * Pasha Tatashin <pasha.tatashin@xxxxxxxxxx> + * Chris Li <chrisl@xxxxxxxxxx> + */ +#ifndef _LINUX_DEV_LIVEUPDATE_H +#define _LINUX_DEV_LIVEUPDATE_H + +#include <linux/liveupdate.h> + +#ifdef CONFIG_LIVEUPDATE + +/** + * struct dev_liveupdate - Device state for live update operations + * @lu_next: List head for linking the device into live update + * related lists (e.g., a list of devices participating + * in a live update sequence). + * @requested: Set if a live update has been requested for this + * device (i.e. device will participate in live update). + * @depended: Set if the device participtate the live update due to + * one of its child device is requested in live update. + * + * This structure holds the state information required for performing + * live update operations on a device. It is embedded within a struct device. + */ +struct dev_liveupdate { + struct list_head lu_next; + bool requested:1; + bool depended:1; +}; + +#endif /* CONFIG_LIVEUPDATE */ +#endif /* _LINUX_DEV_LIVEUPDATE_H */ diff --git a/include/linux/device.h b/include/linux/device.h index 4940db137fffff4ceacf819b32433a0f4898b125..4aee7912218865168a73fe4c6d3a82646b8dd86f 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -21,6 +21,7 @@ #include <linux/lockdep.h> #include <linux/compiler.h> #include <linux/types.h> +#include <linux/dev_liveupdate.h> #include <linux/mutex.h> #include <linux/pm.h> #include <linux/atomic.h> @@ -508,6 +509,7 @@ struct device_physical_location { * @pm_domain: Provide callbacks that are executed during system suspend, * hibernation, system resume and during runtime PM transitions * along with subsystem-level and driver-level callbacks. + * @lu: Live update state. * @em_pd: device's energy model performance domain * @pins: For device pin management. * See Documentation/driver-api/pin-control.rst for details. @@ -603,6 +605,10 @@ struct device { struct dev_pm_info power; struct dev_pm_domain *pm_domain; +#ifdef CONFIG_LIVEUPDATE + struct dev_liveupdate lu; +#endif + #ifdef CONFIG_ENERGY_MODEL struct em_perf_domain *em_pd; #endif -- 2.50.1.487.gc89ff58d15-goog