diff options
author | Dexuan Cui <decui@microsoft.com> | 2019-09-05 19:01:17 -0400 |
---|---|---|
committer | Sasha Levin <sashal@kernel.org> | 2019-09-06 14:52:44 -0400 |
commit | 271b2224d42f88870e6b060924ee374871c131fc (patch) | |
tree | d25ba2bce5a00dc6b667eee734ec4ad69347c35f | |
parent | ed56ef675ae6ef0e6f7d42b9c42dae61172f0960 (diff) |
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>
-rw-r--r-- | drivers/hv/vmbus_drv.c | 46 | ||||
-rw-r--r-- | include/linux/hyperv.h | 3 |
2 files changed, 49 insertions, 0 deletions
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index 2ef375ce58ac..a30c70adf9a0 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c | |||
@@ -911,6 +911,43 @@ static void vmbus_shutdown(struct device *child_device) | |||
911 | drv->shutdown(dev); | 911 | drv->shutdown(dev); |
912 | } | 912 | } |
913 | 913 | ||
914 | /* | ||
915 | * vmbus_suspend - Suspend a vmbus device | ||
916 | */ | ||
917 | static int vmbus_suspend(struct device *child_device) | ||
918 | { | ||
919 | struct hv_driver *drv; | ||
920 | struct hv_device *dev = device_to_hv_device(child_device); | ||
921 | |||
922 | /* The device may not be attached yet */ | ||
923 | if (!child_device->driver) | ||
924 | return 0; | ||
925 | |||
926 | drv = drv_to_hv_drv(child_device->driver); | ||
927 | if (!drv->suspend) | ||
928 | return -EOPNOTSUPP; | ||
929 | |||
930 | return drv->suspend(dev); | ||
931 | } | ||
932 | |||
933 | /* | ||
934 | * vmbus_resume - Resume a vmbus device | ||
935 | */ | ||
936 | static int vmbus_resume(struct device *child_device) | ||
937 | { | ||
938 | struct hv_driver *drv; | ||
939 | struct hv_device *dev = device_to_hv_device(child_device); | ||
940 | |||
941 | /* The device may not be attached yet */ | ||
942 | if (!child_device->driver) | ||
943 | return 0; | ||
944 | |||
945 | drv = drv_to_hv_drv(child_device->driver); | ||
946 | if (!drv->resume) | ||
947 | return -EOPNOTSUPP; | ||
948 | |||
949 | return drv->resume(dev); | ||
950 | } | ||
914 | 951 | ||
915 | /* | 952 | /* |
916 | * vmbus_device_release - Final callback release of the vmbus child device | 953 | * vmbus_device_release - Final callback release of the vmbus child device |
@@ -926,6 +963,14 @@ static void vmbus_device_release(struct device *device) | |||
926 | kfree(hv_dev); | 963 | kfree(hv_dev); |
927 | } | 964 | } |
928 | 965 | ||
966 | /* | ||
967 | * Note: we must use SET_NOIRQ_SYSTEM_SLEEP_PM_OPS rather than | ||
968 | * SET_SYSTEM_SLEEP_PM_OPS: see the comment before vmbus_bus_pm. | ||
969 | */ | ||
970 | static const struct dev_pm_ops vmbus_pm = { | ||
971 | SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(vmbus_suspend, vmbus_resume) | ||
972 | }; | ||
973 | |||
929 | /* The one and only one */ | 974 | /* The one and only one */ |
930 | static struct bus_type hv_bus = { | 975 | static struct bus_type hv_bus = { |
931 | .name = "vmbus", | 976 | .name = "vmbus", |
@@ -936,6 +981,7 @@ static struct bus_type hv_bus = { | |||
936 | .uevent = vmbus_uevent, | 981 | .uevent = vmbus_uevent, |
937 | .dev_groups = vmbus_dev_groups, | 982 | .dev_groups = vmbus_dev_groups, |
938 | .drv_groups = vmbus_drv_groups, | 983 | .drv_groups = vmbus_drv_groups, |
984 | .pm = &vmbus_pm, | ||
939 | }; | 985 | }; |
940 | 986 | ||
941 | struct onmessage_work_context { | 987 | struct onmessage_work_context { |
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index 2d39248cff96..8a60e7766037 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h | |||
@@ -1157,6 +1157,9 @@ struct hv_driver { | |||
1157 | int (*remove)(struct hv_device *); | 1157 | int (*remove)(struct hv_device *); |
1158 | void (*shutdown)(struct hv_device *); | 1158 | void (*shutdown)(struct hv_device *); |
1159 | 1159 | ||
1160 | int (*suspend)(struct hv_device *); | ||
1161 | int (*resume)(struct hv_device *); | ||
1162 | |||
1160 | }; | 1163 | }; |
1161 | 1164 | ||
1162 | /* Base device object */ | 1165 | /* Base device object */ |