drm/hyperv: Add DRM driver for hyperv synthetic video device
Subsystems (5)
PATCH v5 1/3 drm/hyperv: Add DRM driver for hyperv synthetic video device
DRM driver for hyperv synthetic video device, based on hyperv_fb framebuffer driver. Also added config option "DRM_HYPERV" to enabled this driver.
v2:
- Add support for gen2 VM
- Fixed review comments
v3:
- Split into multiple files as suggested by Thomas Zimmermann
- Fixed hibernation issue as suggested by Dexuan Cui
- Use ioremap_cache as suggested by Dexuan Cui
- Incorporated other review comments
v4:
- Fix bitrotted code
- Review comments
- Updated the copyright and license to match hyperv_fb
v5:
- Address review comments and rebased with drm-misc-next
--- drivers/gpu/drm/Kconfig | 12 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/hyperv/Makefile | 8 + drivers/gpu/drm/hyperv/hyperv_drm.h | 51 +++ drivers/gpu/drm/hyperv/hyperv_drm_drv.c | 307 +++++++++++++ drivers/gpu/drm/hyperv/hyperv_drm_modeset.c | 231 ++++++++++ drivers/gpu/drm/hyperv/hyperv_drm_proto.c | 478 ++++++++++++++++++++ 7 files changed, 1088 insertions(+) create mode 100644 drivers/gpu/drm/hyperv/Makefile create mode 100644 drivers/gpu/drm/hyperv/hyperv_drm.h create mode 100644 drivers/gpu/drm/hyperv/hyperv_drm_drv.c create mode 100644 drivers/gpu/drm/hyperv/hyperv_drm_modeset.c create mode 100644 drivers/gpu/drm/hyperv/hyperv_drm_proto.c
drivers/gpu/drm/Kconfig +12 -0
@@ -380,6 +380,18 @@ source "drivers/gpu/drm/xlnx/Kconfig" source "drivers/gpu/drm/gud/Kconfig" +config DRM_HYPERV + tristate "DRM Support for hyperv synthetic video device" + depends on DRM && PCI && MMU && HYPERV + select DRM_KMS_HELPER + select DRM_GEM_SHMEM_HELPER + help + This is a KMS driver for hyperv synthetic video device. Choose this + option if you would like to enable drm driver for Hyper-V virtual + machine. + + If M is selected the module will be called hyperv_drm. + # Keep legacy drivers last menuconfig DRM_LEGACY
drivers/gpu/drm/Makefile +1 -0
@@ -126,3 +126,4 @@ obj-$(CONFIG_DRM_MCDE) += mcde/ obj-$(CONFIG_DRM_TIDSS) += tidss/ obj-y += xlnx/ obj-y += gud/ +obj-$(CONFIG_DRM_HYPERV) += hyperv/
drivers/gpu/drm/hyperv/Makefile new file +8 -0
@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0-only + +hyperv_drm-y := \ + hyperv_drm_drv.o \ + hyperv_drm_modeset.o \ + hyperv_drm_proto.o + +obj-$(CONFIG_DRM_HYPERV) += hyperv_drm.o
drivers/gpu/drm/hyperv/hyperv_drm.h new file +51 -0
51 lines not on this page · raw message
drivers/gpu/drm/hyperv/hyperv_drm_drv.c new file +307 -0
307 lines not on this page · raw message
drivers/gpu/drm/hyperv/hyperv_drm_modeset.c new file +231 -0
231 lines not on this page · raw message
drivers/gpu/drm/hyperv/hyperv_drm_proto.c new file +478 -0
478 lines not on this page · raw message
Signature · 1 line
2.31.1
PATCH v5 2/3 drm/hyperv: Handle feature change message from device
Virtual device inform if screen update is needed or not with SYNTHVID_FEATURE_CHANGE message. Handle this message to set dirt_needed flag.
--- drivers/gpu/drm/hyperv/hyperv_drm.h | 1 + drivers/gpu/drm/hyperv/hyperv_drm_drv.c | 2 ++ drivers/gpu/drm/hyperv/hyperv_drm_proto.c | 7 +++++++ 3 files changed, 10 insertions(+)
drivers/gpu/drm/hyperv/hyperv_drm.h +1 -0
@@ -29,6 +29,7 @@ struct hyperv_drm_device {struct completion wait;u32 synthvid_version;u32 mmio_megabytes; +bool dirt_needed;u8 init_buf[VMBUS_MAX_PACKET_SIZE ];u8 recv_buf[VMBUS_MAX_PACKET_SIZE ];
drivers/gpu/drm/hyperv/hyperv_drm_drv.c +2 -0
@@ -198,6 +198,8 @@ static int hyperv_vmbus_probe(struct hv_device *hdev,if (ret)drm_warn (dev,"Failed to update vram location.\n" ); + hv->dirt_needed = true; + ret =hyperv_mode_config_init (hv);if (ret) goto err_vmbus_close;
drivers/gpu/drm/hyperv/hyperv_drm_proto.c +7 -0
@@ -301,8 +301,12 @@ int hyperv_update_situation(struct hv_device *hdev, u8 active, u32 bpp,int hyperv_update_dirt (struct hv_device *hdev,struct drm_rect *rect) { +struct hyperv_drm_device *hv =hv_get_drvdata (hdev);struct synthvid_msg msg; +if (!hv->dirt_needed) +return 0 ; +memset (&msg,0 ,sizeof (struct synthvid_msg )); msg.vid_hdr.type =SYNTHVID_DIRT ;
@@ -387,6 +391,9 @@ static void hyperv_receive_sub(struct hv_device *hdev)complete (&hv->wait);return ; } + +if (msg->vid_hdr.type ==SYNTHVID_FEATURE_CHANGE ) + hv->dirt_needed = msg->feature_chg.is_dirt_needed; }static void hyperv_receive (void *ctx)
Signature · 1 line
2.31.1
PATCH v5 3/3 MAINTAINERS: Add maintainer for hyperv video device
In reply to Deepak RawatMaintainer for hyperv synthetic video device.
--- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+)
MAINTAINERS +8 -0
@@ -6084,6 +6084,14 @@ T: git git://anongit.freedesktop.org/drm/drm-misc F: Documentation/devicetree/bindings/display/hisilicon/ F: drivers/gpu/drm/hisilicon/ +DRM DRIVER FOR HYPERV SYNTHETIC VIDEO DEVICE +M: Deepak Rawat <[email protected]> +L: [email protected] +L: [email protected] +S: Maintained +T: git git://anongit.freedesktop.org/drm/drm-misc +F: drivers/gpu/drm/hyperv + DRM DRIVERS FOR LIMA M: Qiang Yu <[email protected]> L: [email protected]
Signature · 1 line
2.31.1
Dexuan Cui
maintainerdrivers/gpu/drm/hyperv/hyperv_drm_drv.c line 241
Quoted 9 lines
From: Deepak Rawat <[email protected]>
Sent: Wednesday, May 19, 2021 9:38 AM
...drivers/gpu/drm/hyperv/hyperv_drm_drv.c new file +6
-0+static int hyperv_vmbus_suspend (struct hv_device *hdev) +{ +struct drm_device *dev =hv_get_drvdata (hdev); +int ret; + + ret =drm_mode_config_helper_suspend (dev);
If 'ret' is not zero, return immediately?
drivers/gpu/drm/hyperv/hyperv_drm_drv.c line 307
Quoted 8 lines
drivers/gpu/drm/hyperv/hyperv_drm_drv.c new file +6
-0+ +vmbus_close (hdev->channel); + +return ret; +} +MODULE_DESCRIPTION ("DRM driver for hyperv synthetic video device" );
s/hyperv/Hyper-V ?
Thomas Zimmermann
maintainerHi
Am 20.05.21 um 07:41 schrieb Dexuan Cui:
Quoted 19 lines
drivers/gpu/drm/hyperv/hyperv_drm_drv.c line 241
Quoted 9 lines
From: Deepak Rawat <[email protected]>
Sent: Wednesday, May 19, 2021 9:38 AM
...drivers/gpu/drm/hyperv/hyperv_drm_drv.c new file +6
-0+static int hyperv_vmbus_suspend (struct hv_device *hdev) +{ +struct drm_device *dev =hv_get_drvdata (hdev); +int ret; + + ret =drm_mode_config_helper_suspend (dev);If 'ret' is not zero, return immediately?
Quoted 5 lines
drivers/gpu/drm/hyperv/hyperv_drm_drv.c new file +5
-0+ +vmbus_close (hdev->channel); + +return ret; +}
Quoted 4 lines
Quoted 1 line
+MODULE_DESCRIPTION("DRM driver for hyperv synthetic video device");
s/hyperv/Hyper-V ?
Maybe let's fix these points and then get the driver merged.
Best regards
Thomas
Signature · 6 lines
Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Felix Imendörffer
Quoted 22 lines · Thomas Zimmermann
Hi
Am 20.05.21 um 07:41 schrieb Dexuan Cui:
Quoted 19 lines
drivers/gpu/drm/hyperv/hyperv_drm_drv.c line 241
Quoted 9 lines
From: Deepak Rawat <[email protected]>
Sent: Wednesday, May 19, 2021 9:38 AM
...drivers/gpu/drm/hyperv/hyperv_drm_drv.c new file +6
-0+static int hyperv_vmbus_suspend (struct hv_device *hdev) +{ + struct drm_device *dev = hv_get_drvdata(hdev); + int ret; + + ret = drm_mode_config_helper_suspend(dev);If 'ret' is not zero, return immediately?
Quoted 5 lines
drivers/gpu/drm/hyperv/hyperv_drm_drv.c new file +5
-0+ + vmbus_close(hdev->channel); + + return ret; +}
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
+MODULE_DESCRIPTION("DRM driver for hyperv synthetic video device");
s/hyperv/Hyper-V ?
Maybe let's fix these points and then get the driver merged.
Hi Thomas, sure. This was on my list to fix before merge. One patch is missing ack/review, so it would be nice if that also is reviewed.
Thanks,
Deepak
Quoted 4 lines
Best regards
Thomas