Drivers: hv: vmbus: Implement suspend/resume for VSC drivers for hibernation
The high-level VSC drivers will implement device-specific callbacks. Signed-off-by: Dexuan Cui <decui@microsoft.com> Reviewed-by: Michael Kelley <mikelley@microsoft.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
ed56ef675a
commit
271b2224d4
@ -911,6 +911,43 @@ static void vmbus_shutdown(struct device *child_device)
|
|||||||
drv->shutdown(dev);
|
drv->shutdown(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* vmbus_suspend - Suspend a vmbus device
|
||||||
|
*/
|
||||||
|
static int vmbus_suspend(struct device *child_device)
|
||||||
|
{
|
||||||
|
struct hv_driver *drv;
|
||||||
|
struct hv_device *dev = device_to_hv_device(child_device);
|
||||||
|
|
||||||
|
/* The device may not be attached yet */
|
||||||
|
if (!child_device->driver)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
drv = drv_to_hv_drv(child_device->driver);
|
||||||
|
if (!drv->suspend)
|
||||||
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
|
return drv->suspend(dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* vmbus_resume - Resume a vmbus device
|
||||||
|
*/
|
||||||
|
static int vmbus_resume(struct device *child_device)
|
||||||
|
{
|
||||||
|
struct hv_driver *drv;
|
||||||
|
struct hv_device *dev = device_to_hv_device(child_device);
|
||||||
|
|
||||||
|
/* The device may not be attached yet */
|
||||||
|
if (!child_device->driver)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
drv = drv_to_hv_drv(child_device->driver);
|
||||||
|
if (!drv->resume)
|
||||||
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
|
return drv->resume(dev);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* vmbus_device_release - Final callback release of the vmbus child device
|
* vmbus_device_release - Final callback release of the vmbus child device
|
||||||
@ -926,6 +963,14 @@ static void vmbus_device_release(struct device *device)
|
|||||||
kfree(hv_dev);
|
kfree(hv_dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Note: we must use SET_NOIRQ_SYSTEM_SLEEP_PM_OPS rather than
|
||||||
|
* SET_SYSTEM_SLEEP_PM_OPS: see the comment before vmbus_bus_pm.
|
||||||
|
*/
|
||||||
|
static const struct dev_pm_ops vmbus_pm = {
|
||||||
|
SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(vmbus_suspend, vmbus_resume)
|
||||||
|
};
|
||||||
|
|
||||||
/* The one and only one */
|
/* The one and only one */
|
||||||
static struct bus_type hv_bus = {
|
static struct bus_type hv_bus = {
|
||||||
.name = "vmbus",
|
.name = "vmbus",
|
||||||
@ -936,6 +981,7 @@ static struct bus_type hv_bus = {
|
|||||||
.uevent = vmbus_uevent,
|
.uevent = vmbus_uevent,
|
||||||
.dev_groups = vmbus_dev_groups,
|
.dev_groups = vmbus_dev_groups,
|
||||||
.drv_groups = vmbus_drv_groups,
|
.drv_groups = vmbus_drv_groups,
|
||||||
|
.pm = &vmbus_pm,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct onmessage_work_context {
|
struct onmessage_work_context {
|
||||||
|
@ -1157,6 +1157,9 @@ struct hv_driver {
|
|||||||
int (*remove)(struct hv_device *);
|
int (*remove)(struct hv_device *);
|
||||||
void (*shutdown)(struct hv_device *);
|
void (*shutdown)(struct hv_device *);
|
||||||
|
|
||||||
|
int (*suspend)(struct hv_device *);
|
||||||
|
int (*resume)(struct hv_device *);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Base device object */
|
/* Base device object */
|
||||||
|
Loading…
Reference in New Issue
Block a user