From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dexuan Cui Subject: [PATCH] video: hyperv_fb: Add the support of hibernation Date: Wed, 11 Sep 2019 23:34:10 +0000 Message-ID: <1568244833-66476-1-git-send-email-decui@microsoft.com> Reply-To: Dexuan Cui Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org To: KY Srinivasan , Haiyang Zhang , Stephen Hemminger , "sashal@kernel.org" , "b.zolnierkie@samsung.com" , "linux-hyperv@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , "linux-fbdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Michael Kelley Cc: Dexuan Cui List-Id: dri-devel@lists.freedesktop.org This patch depends on the vmbus side change of the definition of struct hv_driver. Signed-off-by: Dexuan Cui --- This patch is basically a pure Hyper-V specific change and it has a build dependency on the commit 271b2224d42f ("Drivers: hv: vmbus: Implement suspend/resume for VSC drivers for hibernation"), which is on Sasha Levin's Hyper-V tree's hyperv-next branch: https://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git/log/?h=3Dh= yperv-next I request this patch should go through Sasha's tree rather than the fbdev tree. drivers/video/fbdev/hyperv_fb.c | 59 +++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 59 insertions(+) diff --git a/drivers/video/fbdev/hyperv_fb.c b/drivers/video/fbdev/hyperv_f= b.c index 2dcb7c5..fe4731f 100644 --- a/drivers/video/fbdev/hyperv_fb.c +++ b/drivers/video/fbdev/hyperv_fb.c @@ -34,6 +34,7 @@ #include #include #include +#include =20 #include =20 @@ -211,6 +212,7 @@ struct hvfb_par { =20 struct delayed_work dwork; bool update; + bool update_saved; /* The value of 'update' before hibernation */ =20 u32 pseudo_palette[16]; u8 init_buf[MAX_VMBUS_PKT_SIZE]; @@ -878,6 +880,61 @@ static int hvfb_remove(struct hv_device *hdev) return 0; } =20 +static int hvfb_suspend(struct hv_device *hdev) +{ + struct fb_info *info =3D hv_get_drvdata(hdev); + struct hvfb_par *par =3D info->par; + + console_lock(); + + /* 1 means do suspend */ + fb_set_suspend(info, 1); + + cancel_delayed_work_sync(&par->dwork); + + par->update_saved =3D par->update; + par->update =3D false; + par->fb_ready =3D false; + + vmbus_close(hdev->channel); + + console_unlock(); + + return 0; +} + +static int hvfb_resume(struct hv_device *hdev) +{ + struct fb_info *info =3D hv_get_drvdata(hdev); + struct hvfb_par *par =3D info->par; + int ret; + + console_lock(); + + ret =3D synthvid_connect_vsp(hdev); + if (ret !=3D 0) + goto out; + + ret =3D synthvid_send_config(hdev); + if (ret !=3D 0) { + vmbus_close(hdev->channel); + goto out; + } + + par->fb_ready =3D true; + par->update =3D par->update_saved; + + schedule_delayed_work(&par->dwork, HVFB_UPDATE_DELAY); + + /* 0 means do resume */ + fb_set_suspend(info, 0); + +out: + console_unlock(); + + return ret; +} + =20 static const struct pci_device_id pci_stub_id_table[] =3D { { @@ -901,6 +958,8 @@ static int hvfb_remove(struct hv_device *hdev) .id_table =3D id_table, .probe =3D hvfb_probe, .remove =3D hvfb_remove, + .suspend =3D hvfb_suspend, + .resume =3D hvfb_resume, .driver =3D { .probe_type =3D PROBE_PREFER_ASYNCHRONOUS, }, --=20 1.8.3.1