drivers/pmdomain/core.c
Source file repositories/reference/linux-study-clean/drivers/pmdomain/core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pmdomain/core.c- Extension
.c- Size
- 108547 bytes
- Lines
- 4161
- Domain
- Driver Families
- Bucket
- drivers/pmdomain
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/delay.hlinux/idr.hlinux/kernel.hlinux/io.hlinux/platform_device.hlinux/pm_opp.hlinux/pm_runtime.hlinux/pm_domain.hlinux/pm_qos.hlinux/pm_clock.hlinux/slab.hlinux/err.hlinux/sched.hlinux/suspend.hlinux/export.hlinux/cpu.hlinux/debugfs.h
Detected Declarations
struct genpd_lock_opsstruct of_genpd_providerfunction genpd_lock_mtxfunction genpd_lock_nested_mtxfunction genpd_lock_interruptible_mtxfunction genpd_unlock_mtxfunction genpd_lock_spinfunction genpd_lock_nested_spinfunction genpd_lock_interruptible_spinfunction genpd_unlock_spinfunction genpd_lock_raw_spinfunction genpd_lock_nested_raw_spinfunction genpd_lock_interruptible_raw_spinfunction genpd_unlock_raw_spinfunction irq_safe_dev_in_sleep_domainfunction genpd_stop_devfunction genpd_start_devfunction genpd_sd_counter_decfunction genpd_sd_counter_incfunction genpd_debug_removefunction genpd_update_accountingfunction genpd_reflect_residencyfunction genpd_debug_addfunction genpd_xlate_performance_statefunction _genpd_rollback_parent_statefunction _genpd_set_parent_statefunction _genpd_set_performance_statefunction list_for_each_entryfunction list_for_each_entry_reversefunction genpd_set_performance_statefunction genpd_drop_performance_statefunction genpd_restore_performance_statefunction genpd_dev_pm_set_performance_statefunction dev_pm_genpd_set_performance_statefunction dev_pm_genpd_set_next_wakeupfunction dev_pm_genpd_get_next_hrtimerfunction dev_pm_genpd_synced_powerofffunction dev_pm_genpd_set_hwmodefunction dev_pm_genpd_get_hwmodefunction dev_pm_genpd_rpm_always_onfunction dev_pm_genpd_is_onfunction pm_genpd_inc_rejectedfunction _genpd_power_onfunction _genpd_power_offfunction genpd_power_offfunction genpd_power_offfunction deepestfunction list_for_each_entry
Annotated Snippet
static const struct bus_type genpd_provider_bus_type = {
.name = "genpd_provider",
};
#define GENPD_RETRY_MAX_MS 250 /* Approximate */
#define GENPD_DEV_CALLBACK(genpd, type, callback, dev) \
({ \
type (*__routine)(struct device *__d); \
type __ret = (type)0; \
\
__routine = genpd->dev_ops.callback; \
if (__routine) { \
__ret = __routine(dev); \
} \
__ret; \
})
static LIST_HEAD(gpd_list);
static DEFINE_MUTEX(gpd_list_lock);
struct genpd_lock_ops {
void (*lock)(struct generic_pm_domain *genpd);
void (*lock_nested)(struct generic_pm_domain *genpd, int depth);
int (*lock_interruptible)(struct generic_pm_domain *genpd);
void (*unlock)(struct generic_pm_domain *genpd);
};
static void genpd_lock_mtx(struct generic_pm_domain *genpd)
{
mutex_lock(&genpd->mlock);
}
static void genpd_lock_nested_mtx(struct generic_pm_domain *genpd,
int depth)
{
mutex_lock_nested(&genpd->mlock, depth);
}
static int genpd_lock_interruptible_mtx(struct generic_pm_domain *genpd)
{
return mutex_lock_interruptible(&genpd->mlock);
}
static void genpd_unlock_mtx(struct generic_pm_domain *genpd)
{
return mutex_unlock(&genpd->mlock);
}
static const struct genpd_lock_ops genpd_mtx_ops = {
.lock = genpd_lock_mtx,
.lock_nested = genpd_lock_nested_mtx,
.lock_interruptible = genpd_lock_interruptible_mtx,
.unlock = genpd_unlock_mtx,
};
static void genpd_lock_spin(struct generic_pm_domain *genpd)
__acquires(&genpd->slock)
{
unsigned long flags;
spin_lock_irqsave(&genpd->slock, flags);
genpd->lock_flags = flags;
}
static void genpd_lock_nested_spin(struct generic_pm_domain *genpd,
int depth)
__acquires(&genpd->slock)
{
unsigned long flags;
spin_lock_irqsave_nested(&genpd->slock, flags, depth);
genpd->lock_flags = flags;
}
static int genpd_lock_interruptible_spin(struct generic_pm_domain *genpd)
__acquires(&genpd->slock)
{
unsigned long flags;
spin_lock_irqsave(&genpd->slock, flags);
genpd->lock_flags = flags;
return 0;
}
static void genpd_unlock_spin(struct generic_pm_domain *genpd)
__releases(&genpd->slock)
{
spin_unlock_irqrestore(&genpd->slock, genpd->lock_flags);
}
Annotation
- Immediate include surface: `linux/delay.h`, `linux/idr.h`, `linux/kernel.h`, `linux/io.h`, `linux/platform_device.h`, `linux/pm_opp.h`, `linux/pm_runtime.h`, `linux/pm_domain.h`.
- Detected declarations: `struct genpd_lock_ops`, `struct of_genpd_provider`, `function genpd_lock_mtx`, `function genpd_lock_nested_mtx`, `function genpd_lock_interruptible_mtx`, `function genpd_unlock_mtx`, `function genpd_lock_spin`, `function genpd_lock_nested_spin`, `function genpd_lock_interruptible_spin`, `function genpd_unlock_spin`.
- Atlas domain: Driver Families / drivers/pmdomain.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.