mirror of
https://github.com/torvalds/linux.git
synced 2026-01-25 07:47:50 +00:00
syscore: Pass context data to callbacks
Several drivers can benefit from registering per-instance data along with the syscore operations. To achieve this, move the modifiable fields out of the syscore_ops structure and into a separate struct syscore that can be registered with the framework. Add a void * driver data field for drivers to store contextual data that will be passed to the syscore ops. Acked-by: Rafael J. Wysocki (Intel) <rafael@kernel.org> Signed-off-by: Thierry Reding <treding@nvidia.com>
This commit is contained in:
@@ -5629,7 +5629,7 @@ static int kvm_offline_cpu(unsigned int cpu)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void kvm_shutdown(void)
|
||||
static void kvm_shutdown(void *data)
|
||||
{
|
||||
/*
|
||||
* Disable hardware virtualization and set kvm_rebooting to indicate
|
||||
@@ -5647,7 +5647,7 @@ static void kvm_shutdown(void)
|
||||
on_each_cpu(kvm_disable_virtualization_cpu, NULL, 1);
|
||||
}
|
||||
|
||||
static int kvm_suspend(void)
|
||||
static int kvm_suspend(void *data)
|
||||
{
|
||||
/*
|
||||
* Secondary CPUs and CPU hotplug are disabled across the suspend/resume
|
||||
@@ -5664,7 +5664,7 @@ static int kvm_suspend(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void kvm_resume(void)
|
||||
static void kvm_resume(void *data)
|
||||
{
|
||||
lockdep_assert_not_held(&kvm_usage_lock);
|
||||
lockdep_assert_irqs_disabled();
|
||||
@@ -5672,12 +5672,16 @@ static void kvm_resume(void)
|
||||
WARN_ON_ONCE(kvm_enable_virtualization_cpu());
|
||||
}
|
||||
|
||||
static struct syscore_ops kvm_syscore_ops = {
|
||||
static const struct syscore_ops kvm_syscore_ops = {
|
||||
.suspend = kvm_suspend,
|
||||
.resume = kvm_resume,
|
||||
.shutdown = kvm_shutdown,
|
||||
};
|
||||
|
||||
static struct syscore kvm_syscore = {
|
||||
.ops = &kvm_syscore_ops,
|
||||
};
|
||||
|
||||
int kvm_enable_virtualization(void)
|
||||
{
|
||||
int r;
|
||||
@@ -5694,7 +5698,7 @@ int kvm_enable_virtualization(void)
|
||||
if (r)
|
||||
goto err_cpuhp;
|
||||
|
||||
register_syscore_ops(&kvm_syscore_ops);
|
||||
register_syscore(&kvm_syscore);
|
||||
|
||||
/*
|
||||
* Undo virtualization enabling and bail if the system is going down.
|
||||
@@ -5716,7 +5720,7 @@ int kvm_enable_virtualization(void)
|
||||
return 0;
|
||||
|
||||
err_rebooting:
|
||||
unregister_syscore_ops(&kvm_syscore_ops);
|
||||
unregister_syscore(&kvm_syscore);
|
||||
cpuhp_remove_state(CPUHP_AP_KVM_ONLINE);
|
||||
err_cpuhp:
|
||||
kvm_arch_disable_virtualization();
|
||||
@@ -5732,7 +5736,7 @@ void kvm_disable_virtualization(void)
|
||||
if (--kvm_usage_count)
|
||||
return;
|
||||
|
||||
unregister_syscore_ops(&kvm_syscore_ops);
|
||||
unregister_syscore(&kvm_syscore);
|
||||
cpuhp_remove_state(CPUHP_AP_KVM_ONLINE);
|
||||
kvm_arch_disable_virtualization();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user