34
34
#include <linux/fb.h>
35
35
#include <linux/pci.h>
36
36
#include <linux/efi.h>
37
+ #include <linux/console.h>
37
38
38
39
#include <linux/hyperv.h>
39
40
@@ -211,6 +212,7 @@ struct hvfb_par {
211
212
212
213
struct delayed_work dwork ;
213
214
bool update ;
215
+ bool update_saved ; /* The value of 'update' before hibernation */
214
216
215
217
u32 pseudo_palette [16 ];
216
218
u8 init_buf [MAX_VMBUS_PKT_SIZE ];
@@ -878,6 +880,61 @@ static int hvfb_remove(struct hv_device *hdev)
878
880
return 0 ;
879
881
}
880
882
883
+ static int hvfb_suspend (struct hv_device * hdev )
884
+ {
885
+ struct fb_info * info = hv_get_drvdata (hdev );
886
+ struct hvfb_par * par = info -> par ;
887
+
888
+ console_lock ();
889
+
890
+ /* 1 means do suspend */
891
+ fb_set_suspend (info , 1 );
892
+
893
+ cancel_delayed_work_sync (& par -> dwork );
894
+
895
+ par -> update_saved = par -> update ;
896
+ par -> update = false;
897
+ par -> fb_ready = false;
898
+
899
+ vmbus_close (hdev -> channel );
900
+
901
+ console_unlock ();
902
+
903
+ return 0 ;
904
+ }
905
+
906
+ static int hvfb_resume (struct hv_device * hdev )
907
+ {
908
+ struct fb_info * info = hv_get_drvdata (hdev );
909
+ struct hvfb_par * par = info -> par ;
910
+ int ret ;
911
+
912
+ console_lock ();
913
+
914
+ ret = synthvid_connect_vsp (hdev );
915
+ if (ret != 0 )
916
+ goto out ;
917
+
918
+ ret = synthvid_send_config (hdev );
919
+ if (ret != 0 ) {
920
+ vmbus_close (hdev -> channel );
921
+ goto out ;
922
+ }
923
+
924
+ par -> fb_ready = true;
925
+ par -> update = par -> update_saved ;
926
+
927
+ schedule_delayed_work (& par -> dwork , HVFB_UPDATE_DELAY );
928
+
929
+ /* 0 means do resume */
930
+ fb_set_suspend (info , 0 );
931
+
932
+ out :
933
+ console_unlock ();
934
+
935
+ return ret ;
936
+ }
937
+
881
938
882
939
static const struct pci_device_id pci_stub_id_table [] = {
883
940
{
@@ -901,6 +958,8 @@ static struct hv_driver hvfb_drv = {
901
958
.id_table = id_table ,
902
959
.probe = hvfb_probe ,
903
960
.remove = hvfb_remove ,
961
+ .suspend = hvfb_suspend ,
962
+ .resume = hvfb_resume ,
904
963
.driver = {
905
964
.probe_type = PROBE_PREFER_ASYNCHRONOUS ,
906
965
},
0 commit comments