Skip to contentSkip to conversation

drm/xen-front: Add support for Xen PV display frontend

PATCH Superseded Oleksandr Andrushchenko 2 participants 7 messages Mar 29, 2018

Subsystems (4)

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v5 cover drm/xen-front: Add support for Xen PV display frontend

From: Oleksandr Andrushchenko <[email protected]>

Hello!

Boris/Daniel, I put your R-b tags, so please do let me know if this is not acceptable, so I remove the tags.

This patch series adds support for Xen [1] para-virtualized frontend display driver. It implements the protocol from include/xen/interface/io/displif.h [2].
Accompanying backend [3] is implemented as a user-space application and its helper library [4], capable of running as a Weston client or DRM master.
Configuration of both backend and frontend is done via Xen guest domain configuration options [5].

*******************************************************************************
* Driver limitations
*******************************************************************************
1. Configuration options 1.1 (contiguous display buffers) and 2 (backend allocated buffers) below are not supported at the same time.

2. Only primary plane without additional properties is supported.

3. Only one video mode supported which resolution is configured via XenStore.

4. All CRTCs operate at fixed frequency of 60Hz.

*******************************************************************************
* Driver modes of operation in terms of display buffers used
*******************************************************************************
Depending on the requirements for the para-virtualized environment, namely requirements dictated by the accompanying DRM/(v)GPU drivers running in both host and guest environments, number of operating modes of para-virtualized display driver are supported:
- display buffers can be allocated by either frontend driver or backend
- display buffers can be allocated to be contiguous in memory or not

Note! Frontend driver itself has no dependency on contiguous memory for
its operation.

*******************************************************************************
* 1. Buffers allocated by the frontend driver.
*******************************************************************************

The below modes of operation are configured at compile-time via frontend driver's kernel configuration.

1.1. Front driver configured to use GEM CMA helpers
This use-case is useful when used with accompanying DRM/vGPU driver in guest domain which was designed to only work with contiguous buffers, e.g. DRM driver based on GEM CMA helpers: such drivers can only import contiguous PRIME buffers, thus requiring frontend driver to provide such. In order to implement this mode of operation para-virtualized frontend driver can be configured to use GEM CMA helpers.

1.2. Front driver doesn't use GEM CMA
If accompanying drivers can cope with non-contiguous memory then, to lower pressure on CMA subsystem of the kernel, driver can allocate buffers from system memory.

Note! If used with accompanying DRM/(v)GPU drivers this mode of operation
may require IOMMU support on the platform, so accompanying DRM/vGPU hardware can still reach display buffer memory while importing PRIME buffers from the frontend driver.

*******************************************************************************
* 2. Buffers allocated by the backend
*******************************************************************************

This mode of operation is run-time configured via guest domain configuration through XenStore entries.

For systems which do not provide IOMMU support, but having specific requirements for display buffers it is possible to allocate such buffers at backend side and share those with the frontend.
For example, if host domain is 1:1 mapped and has DRM/GPU hardware expecting physically contiguous memory, this allows implementing zero-copying use-cases.

I would like to thank at least, but not at last the following people/communities who helped this driver to happen ;)

1. My team at EPAM for continuous support
2. Xen community for answering tons of questions on different modes of operation of the driver with respect to virtualized environment.
3. Rob Clark for "GEM allocation for para-virtualized DRM driver" [6]
4. Maarten Lankhorst for "Atomic driver and old remove FB behavior" [7]
5. Ville Syrjälä for "Questions on page flips and atomic modeset" [8]

Changes since v4:
*******************************************************************************
- updated the driver after "drm/simple-kms-helper: Plumb plane state to the enable hook" [14]
- made display_mode_valid static
- fixed page leak on event channel error path
- changed title of the documentation to match the rest of the drivers
- removed from the series the patch from Noralf Trønnes [12] as it was sent out as a standalone one

Changes since v3:
*******************************************************************************
- no changes to Xen related code (shared buffer handling, event channels etc.), but minor changes to xenbus_driver state machine due to re-worked unplug
implementation: additional state checks added
- re-worked dumb creation code to fix race condition (drm_gem_handle_create)
- use drm_dev_{enter|exit} to protect code which must not run when unplugged
- re-work unplug code to fully support "zombie" DRM devices on backend disconnect
- implement a dedicated page flip time-out worker, remove logic from connector detect callback
- move mode_valid from drm_connector_helper_funcs to drm_simple_display_pipe_funcs
- use drm_gem_object_put_unlocked instead of obsolete drm_gem_object_unreference_unlocked
- minor cleanups

Changes since v2:
*******************************************************************************
- no changes to Xen related code (shared buffer handling, event channels etc.)
- rework DRM driver release with hotplug (Daniel)
- squash xen_drm_front and xen_drm_front_drv as they depend on each other too heavily now
- remove platform driver and instantiate DRM device
from xenbus driver directly
- have serializing mutex per connector, not a single one,
so we don't introduce a bottle neck for multiple connectors
- minor comments addressed (Daniel)

Changes since v1:
*******************************************************************************
- use SPDX license identifier, set license to GPLv2 OR MIT
- changed midlayers to direct function calls, removed:
- front_ops
- gem_ops
- renamed xenbus_driver callbacks to align with exisitng PV drivers
- re-worked backend error handling with connector hotplug uevents
- removed vblank handling so user-space doesn't have an impression we really support that
- directly use front's mode_set in display enable/disable
- removed BUG_ON, error handling implemented
- moved driver documentation into Documentation/gpu
- other comments from Xen community addressed (Boris and Juergen)
- squashed Xen and DRM patches for better interrconnection visibility
- for your convenience driver is available at [11]

Thank you,
Oleksandr Andrushchenko

[1] https://wiki.xen.org/wiki/Paravirtualization_(PV)#PV_IO_Drivers
[2] https://elixir.bootlin.com/linux/v4.16-rc2/source/include/xen/interface/io/displif.h
[3] https://github.com/xen-troops/displ_be
[4] https://github.com/xen-troops/libxenbe
[5] https://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=docs/man/xl.cfg.pod.5.in;h=a699367779e2ae1212ff8f638eff0206ec1a1cc9;hb=refs/heads/master#l1257
[6] https://lists.freedesktop.org/archives/dri-devel/2017-March/136038.html
[7] https://www.spinics.net/lists/dri-devel/msg164102.html
[8] https://www.spinics.net/lists/dri-devel/msg164463.html
[9] https://patchwork.freedesktop.org/series/38073/
[10] https://patchwork.freedesktop.org/series/38139/
[11] https://github.com/andr2000/linux/commits/drm_tip_pv_drm_v2
[12] https://patchwork.freedesktop.org/patch/175779/
[13] https://www.spinics.net/lists/dri-devel/msg170453.html
[14] https://patchwork.freedesktop.org/patch/212321/

Oleksandr Andrushchenko (1):
drm/xen-front: Add support for Xen PV display frontend

 Documentation/gpu/drivers.rst               |   1 +
 Documentation/gpu/xen-front.rst             |  43 ++
 drivers/gpu/drm/Kconfig                     |   2 +
 drivers/gpu/drm/Makefile                    |   1 +
 drivers/gpu/drm/xen/Kconfig                 |  30 +
 drivers/gpu/drm/xen/Makefile                |  16 +
 drivers/gpu/drm/xen/xen_drm_front.c         | 880 ++++++++++++++++++++++++++++
 drivers/gpu/drm/xen/xen_drm_front.h         | 189 ++++++
 drivers/gpu/drm/xen/xen_drm_front_cfg.c     |  77 +++
 drivers/gpu/drm/xen/xen_drm_front_cfg.h     |  37 ++
 drivers/gpu/drm/xen/xen_drm_front_conn.c    | 115 ++++
 drivers/gpu/drm/xen/xen_drm_front_conn.h    |  27 +
 drivers/gpu/drm/xen/xen_drm_front_evtchnl.c | 386 ++++++++++++
 drivers/gpu/drm/xen/xen_drm_front_evtchnl.h |  81 +++
 drivers/gpu/drm/xen/xen_drm_front_gem.c     | 309 ++++++++++
 drivers/gpu/drm/xen/xen_drm_front_gem.h     |  41 ++
 drivers/gpu/drm/xen/xen_drm_front_gem_cma.c |  78 +++
 drivers/gpu/drm/xen/xen_drm_front_kms.c     | 372 ++++++++++++
 drivers/gpu/drm/xen/xen_drm_front_kms.h     |  27 +
 drivers/gpu/drm/xen/xen_drm_front_shbuf.c   | 432 ++++++++++++++
 drivers/gpu/drm/xen/xen_drm_front_shbuf.h   |  72 +++
 21 files changed, 3216 insertions(+)
 create mode 100644 Documentation/gpu/xen-front.rst
 create mode 100644 drivers/gpu/drm/xen/Kconfig
 create mode 100644 drivers/gpu/drm/xen/Makefile
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front.c
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front.h
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front_cfg.c
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front_cfg.h
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front_conn.c
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front_conn.h
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front_evtchnl.c
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front_evtchnl.h
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front_gem.c
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front_gem.h
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front_gem_cma.c
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front_kms.c
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front_kms.h
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front_shbuf.c
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front_shbuf.h
Signature · 6 lines
2.16.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

PATCH v5 1/1 drm/xen-front: Add support for Xen PV display frontend

From: Oleksandr Andrushchenko <[email protected]>

Add support for Xen para-virtualized frontend display driver. Accompanying backend [1] is implemented as a user-space application and its helper library [2], capable of running as a Weston client or DRM master.
Configuration of both backend and frontend is done via Xen guest domain configuration options [3].

Driver limitations:
1. Only primary plane without additional properties is supported.
2. Only one video mode supported which resolution is configured via XenStore.
3. All CRTCs operate at fixed frequency of 60Hz.

1. Implement Xen bus state machine for the frontend driver according to the state diagram and recovery flow from display para-virtualized
protocol: xen/interface/io/displif.h.

2. Read configuration values from Xen store according to xen/interface/io/displif.h protocol:
- read connector(s) configuration
- read buffer allocation mode (backend/frontend)

3. Handle Xen event channels:
- create for all configured connectors and publish corresponding ring references and event channels in Xen store, so backend can connect
- implement event channels interrupt handlers
- create and destroy event channels with respect to Xen bus state

4. Implement shared buffer handling according to the para-virtualized display device protocol at xen/interface/io/displif.h:
- handle page directories according to displif protocol:
- allocate and share page directories
- grant references to the required set of pages for the page directory
- allocate xen balllooned pages via Xen balloon driver with alloc_xenballooned_pages/free_xenballooned_pages
- grant references to the required set of pages for the shared buffer itself
- implement pages map/unmap for the buffers allocated by the backend (gnttab_map_refs/gnttab_unmap_refs)

5. Implement kernel modesetiing/connector handling using DRM simple KMS helper pipeline:

- implement KMS part of the driver with the help of DRM simple pipepline helper which is possible due to the fact that the para-virtualized driver only supports a single (primary) plane:
- initialize connectors according to XenStore configuration
- handle frame done events from the backend
- create and destroy frame buffers and propagate those to the backend
- propagate set/reset mode configuration to the backend on display enable/disable callbacks
- send page flip request to the backend and implement logic for reporting backend IO errors on prepare fb callback

- implement virtual connector handling:
- support only pixel formats suitable for single plane modes
- make sure the connector is always connected
- support a single video mode as per para-virtualized driver configuration

6. Implement GEM handling depending on driver mode of operation:
depending on the requirements for the para-virtualized environment, namely requirements dictated by the accompanying DRM/(v)GPU drivers running in both host and guest environments, number of operating modes of para-virtualized display driver are supported:
- display buffers can be allocated by either frontend driver or backend
- display buffers can be allocated to be contiguous in memory or not

Note! Frontend driver itself has no dependency on contiguous memory for its operation.

6.1. Buffers allocated by the frontend driver.

The below modes of operation are configured at compile-time via frontend driver's kernel configuration.

6.1.1. Front driver configured to use GEM CMA helpers
This use-case is useful when used with accompanying DRM/vGPU driver in guest domain which was designed to only work with contiguous buffers, e.g. DRM driver based on GEM CMA helpers: such drivers can only import contiguous PRIME buffers, thus requiring frontend driver to provide such. In order to implement this mode of operation para-virtualized frontend driver can be configured to use GEM CMA helpers.

6.1.2. Front driver doesn't use GEM CMA
If accompanying drivers can cope with non-contiguous memory then, to lower pressure on CMA subsystem of the kernel, driver can allocate buffers from system memory.

Note! If used with accompanying DRM/(v)GPU drivers this mode of operation may require IOMMU support on the platform, so accompanying DRM/vGPU hardware can still reach display buffer memory while importing PRIME buffers from the frontend driver.

6.2. Buffers allocated by the backend

This mode of operation is run-time configured via guest domain configuration through XenStore entries.

For systems which do not provide IOMMU support, but having specific requirements for display buffers it is possible to allocate such buffers at backend side and share those with the frontend.
For example, if host domain is 1:1 mapped and has DRM/GPU hardware expecting physically contiguous memory, this allows implementing zero-copying use-cases.

Note, while using this scenario the following should be considered:
a) If guest domain dies then pages/grants received from the backend cannot be claimed back
b) Misbehaving guest may send too many requests to the backend exhausting its grant references and memory (consider this from security POV).

Note! Configuration options 1.1 (contiguous display buffers) and 2 (backend allocated buffers) are not supported at the same time.

7. Handle communication with the backend:
- send requests and wait for the responses according to the displif protocol
- serialize access to the communication channel
- time-out used for backend communication is set to 3000 ms
- manage display buffers shared with the backend

[1] https://github.com/xen-troops/displ_be
[2] https://github.com/xen-troops/libxenbe
[3] https://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=docs/man/xl.cfg.pod.5.in;h=a699367779e2ae1212ff8f638eff0206ec1a1cc9;hb=refs/heads/master#l1257

---
 Documentation/gpu/drivers.rst               |   1 +
 Documentation/gpu/xen-front.rst             |  43 ++
 drivers/gpu/drm/Kconfig                     |   2 +
 drivers/gpu/drm/Makefile                    |   1 +
 drivers/gpu/drm/xen/Kconfig                 |  30 +
 drivers/gpu/drm/xen/Makefile                |  16 +
 drivers/gpu/drm/xen/xen_drm_front.c         | 880 ++++++++++++++++++++++++++++
 drivers/gpu/drm/xen/xen_drm_front.h         | 189 ++++++
 drivers/gpu/drm/xen/xen_drm_front_cfg.c     |  77 +++
 drivers/gpu/drm/xen/xen_drm_front_cfg.h     |  37 ++
 drivers/gpu/drm/xen/xen_drm_front_conn.c    | 115 ++++
 drivers/gpu/drm/xen/xen_drm_front_conn.h    |  27 +
 drivers/gpu/drm/xen/xen_drm_front_evtchnl.c | 386 ++++++++++++
 drivers/gpu/drm/xen/xen_drm_front_evtchnl.h |  81 +++
 drivers/gpu/drm/xen/xen_drm_front_gem.c     | 309 ++++++++++
 drivers/gpu/drm/xen/xen_drm_front_gem.h     |  41 ++
 drivers/gpu/drm/xen/xen_drm_front_gem_cma.c |  78 +++
 drivers/gpu/drm/xen/xen_drm_front_kms.c     | 372 ++++++++++++
 drivers/gpu/drm/xen/xen_drm_front_kms.h     |  27 +
 drivers/gpu/drm/xen/xen_drm_front_shbuf.c   | 432 ++++++++++++++
 drivers/gpu/drm/xen/xen_drm_front_shbuf.h   |  72 +++
 21 files changed, 3216 insertions(+)
 create mode 100644 Documentation/gpu/xen-front.rst
 create mode 100644 drivers/gpu/drm/xen/Kconfig
 create mode 100644 drivers/gpu/drm/xen/Makefile
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front.c
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front.h
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front_cfg.c
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front_cfg.h
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front_conn.c
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front_conn.h
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front_evtchnl.c
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front_evtchnl.h
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front_gem.c
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front_gem.h
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front_gem_cma.c
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front_kms.c
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front_kms.h
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front_shbuf.c
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front_shbuf.h
Documentation/gpu/drivers.rst +1 -0
index e8c84419a2a1..d3ab6abae838 100644
@@ -12,6 +12,7 @@ GPU Driver Documentation
    tve200
    vc4
    bridge/dw-hdmi
+   xen-front
 
 .. only::  subproject and html
 
Documentation/gpu/xen-front.rst new file +43 -0

43 lines not on this page · raw message

drivers/gpu/drm/Kconfig +2 -0
index deeefa7a1773..757825ac60df 100644
@@ -289,6 +289,8 @@ source "drivers/gpu/drm/pl111/Kconfig"
 
 source "drivers/gpu/drm/tve200/Kconfig"
 
+source "drivers/gpu/drm/xen/Kconfig"
+
 # Keep legacy drivers last
 
 menuconfig DRM_LEGACY
drivers/gpu/drm/Makefile +1 -0
index 50093ff4479b..9d66657ea117 100644
@@ -103,3 +103,4 @@ obj-$(CONFIG_DRM_MXSFB)	+= mxsfb/
 obj-$(CONFIG_DRM_TINYDRM) += tinydrm/
 obj-$(CONFIG_DRM_PL111) += pl111/
 obj-$(CONFIG_DRM_TVE200) += tve200/
+obj-$(CONFIG_DRM_XEN) += xen/
drivers/gpu/drm/xen/Kconfig new file +30 -0
new file mode 100644
index 000000000000..4f4abc91f3b6
@@ -0,0 +1,30 @@
+config DRM_XEN
+	bool "DRM Support for Xen guest OS"
+	depends on XEN
+	help
+	  Choose this option if you want to enable DRM support
+	  for Xen.
+
+config DRM_XEN_FRONTEND
+	tristate "Para-virtualized frontend driver for Xen guest OS"
+	depends on DRM_XEN
+	depends on DRM
+	select DRM_KMS_HELPER
+	select VIDEOMODE_HELPERS
+	select XEN_XENBUS_FRONTEND
+	help
+	  Choose this option if you want to enable a para-virtualized
+	  frontend DRM/KMS driver for Xen guest OSes.
+
+config DRM_XEN_FRONTEND_CMA
+	bool "Use DRM CMA to allocate dumb buffers"
+	depends on DRM_XEN_FRONTEND
+	select DRM_KMS_CMA_HELPER
+	select DRM_GEM_CMA_HELPER
+	help
+	  Use DRM CMA helpers to allocate display buffers.
+	  This is useful for the use-cases when guest driver needs to
+	  share or export buffers to other drivers which only expect
+	  contiguous buffers.
+	  Note: in this mode driver cannot use buffers allocated
+	  by the backend.
drivers/gpu/drm/xen/Makefile new file +16 -0
new file mode 100644
index 000000000000..352730dc6c13
@@ -0,0 +1,16 @@
+# SPDX-License-Identifier: GPL-2.0 OR MIT
+
+drm_xen_front-objs := xen_drm_front.o \
+		      xen_drm_front_kms.o \
+		      xen_drm_front_conn.o \
+		      xen_drm_front_evtchnl.o \
+		      xen_drm_front_shbuf.o \
+		      xen_drm_front_cfg.o
+
+ifeq ($(CONFIG_DRM_XEN_FRONTEND_CMA),y)
+	drm_xen_front-objs += xen_drm_front_gem_cma.o
+else
+	drm_xen_front-objs += xen_drm_front_gem.o
+endif
+
+obj-$(CONFIG_DRM_XEN_FRONTEND) += drm_xen_front.o
drivers/gpu/drm/xen/xen_drm_front.c new file +880 -0

880 lines not on this page · raw message

drivers/gpu/drm/xen/xen_drm_front.h new file +189 -0

189 lines not on this page · raw message

drivers/gpu/drm/xen/xen_drm_front_cfg.c new file +77 -0

77 lines not on this page · raw message

drivers/gpu/drm/xen/xen_drm_front_cfg.h new file +37 -0
new file mode 100644
index 000000000000..6e7af670f8cd
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: GPL-2.0 OR MIT */
+
+/*
+ *  Xen para-virtual DRM device
+ *
+ * Copyright (C) 2016-2018 EPAM Systems Inc.
+ *
+ * Author: Oleksandr Andrushchenko <[email protected]>
+ */
+
+#ifndef __XEN_DRM_FRONT_CFG_H_
+#define __XEN_DRM_FRONT_CFG_H_
+
+#include <linux/types.h>
+
+#define XEN_DRM_FRONT_MAX_CRTCS	4
+
+struct xen_drm_front_cfg_connector {
+	int width;
+	int height;
+	char *xenstore_path;
+};
+
+struct xen_drm_front_cfg {
+	struct xen_drm_front_info *front_info;
+	/* number of connectors in this configuration */
+	int num_connectors;
+	/* connector configurations */
+	struct xen_drm_front_cfg_connector connectors[XEN_DRM_FRONT_MAX_CRTCS];
+	/* set if dumb buffers are allocated externally on backend side */
+	bool be_alloc;
+};
+
+int xen_drm_front_cfg_card(struct xen_drm_front_info *front_info,
+		struct xen_drm_front_cfg *cfg);
+
+#endif /* __XEN_DRM_FRONT_CFG_H_ */
drivers/gpu/drm/xen/xen_drm_front_conn.c new file +115 -0

115 lines not on this page · raw message

drivers/gpu/drm/xen/xen_drm_front_conn.h new file +27 -0
new file mode 100644
index 000000000000..f38c4b6db5df
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0 OR MIT */
+
+/*
+ *  Xen para-virtual DRM device
+ *
+ * Copyright (C) 2016-2018 EPAM Systems Inc.
+ *
+ * Author: Oleksandr Andrushchenko <[email protected]>
+ */
+
+#ifndef __XEN_DRM_FRONT_CONN_H_
+#define __XEN_DRM_FRONT_CONN_H_
+
+#include <drm/drmP.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_encoder.h>
+
+#include <linux/wait.h>
+
+struct xen_drm_front_drm_info;
+
+int xen_drm_front_conn_init(struct xen_drm_front_drm_info *drm_info,
+		struct drm_connector *connector);
+
+const uint32_t *xen_drm_front_conn_get_formats(int *format_count);
+
+#endif /* __XEN_DRM_FRONT_CONN_H_ */
drivers/gpu/drm/xen/xen_drm_front_evtchnl.c new file +386 -0

386 lines not on this page · raw message

drivers/gpu/drm/xen/xen_drm_front_evtchnl.h new file +81 -0

81 lines not on this page · raw message

drivers/gpu/drm/xen/xen_drm_front_gem.c new file +309 -0

309 lines not on this page · raw message

drivers/gpu/drm/xen/xen_drm_front_gem.h new file +41 -0

41 lines not on this page · raw message

drivers/gpu/drm/xen/xen_drm_front_gem_cma.c new file +78 -0

78 lines not on this page · raw message

drivers/gpu/drm/xen/xen_drm_front_kms.c new file +372 -0

372 lines not on this page · raw message

drivers/gpu/drm/xen/xen_drm_front_kms.h new file +27 -0
new file mode 100644
index 000000000000..1c3a64c36dbb
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0 OR MIT */
+
+/*
+ *  Xen para-virtual DRM device
+ *
+ * Copyright (C) 2016-2018 EPAM Systems Inc.
+ *
+ * Author: Oleksandr Andrushchenko <[email protected]>
+ */
+
+#ifndef __XEN_DRM_FRONT_KMS_H_
+#define __XEN_DRM_FRONT_KMS_H_
+
+#include <linux/types.h>
+
+struct xen_drm_front_drm_info;
+struct xen_drm_front_drm_pipeline;
+
+int xen_drm_front_kms_init(struct xen_drm_front_drm_info *drm_info);
+
+void xen_drm_front_kms_fini(struct xen_drm_front_drm_info *drm_info);
+
+void xen_drm_front_kms_on_frame_done(
+		struct xen_drm_front_drm_pipeline *pipeline,
+		uint64_t fb_cookie);
+
+#endif /* __XEN_DRM_FRONT_KMS_H_ */
drivers/gpu/drm/xen/xen_drm_front_shbuf.c new file +432 -0

273 lines not on this page · raw message

drivers/gpu/drm/xen/xen_drm_front_shbuf.h new file +72 -0

72 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 6 lines
2.16.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Part of the diff is not shown here. View the raw message.

#2 lore raw
Thank you for the patch! Yet something to improve:

Hi Oleksandr,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on drm/drm-next]
[also build test ERROR on next-20180329]
[cannot apply to v4.16-rc7]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Oleksandr-Andrushchenko/drm-xen-front-Add-support-for-Xen-PV-display-frontend/20180329-191740
base:   git://people.freedesktop.org/~airlied/linux.git drm-next
config: x86_64-allmodconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

drivers/gpu/drm/xen/xen_drm_front.c:484:13: sparse: undefined identifier 'drm_dev_enter' drivers/gpu/drm/xen/xen_drm_front.c:487:17: sparse: undefined identifier 'drm_dev_exit' drivers/gpu/drm/xen/xen_drm_front.c:484:26: sparse: call with no type! drivers/gpu/drm/xen/xen_drm_front.c:487:29: sparse: call with no type! drivers/gpu/drm/xen/xen_drm_front.c: In function 'xen_drm_drv_free_object_unlocked':

>> drivers/gpu/drm/xen/xen_drm_front.c:484:6: error: implicit declaration of function 'drm_dev_enter'; did you mean 'drm_dev_unref'? [-Werror=implicit-function-declaration]
     if (drm_dev_enter(obj->dev, &idx)) {
         ^~~~~~~~~~~~~
         drm_dev_unref
>> drivers/gpu/drm/xen/xen_drm_front.c:487:3: error: implicit declaration of function 'drm_dev_exit'; did you mean 'drm_dev_init'? [-Werror=implicit-function-declaration]
      drm_dev_exit(idx);
      ^~~~~~~~~~~~
      drm_dev_init

cc1: some warnings being treated as errors
--
drivers/gpu/drm/xen/xen_drm_front_kms.c:40:13: sparse: undefined identifier 'drm_dev_enter' drivers/gpu/drm/xen/xen_drm_front_kms.c:43:17: sparse: undefined identifier 'drm_dev_exit' drivers/gpu/drm/xen/xen_drm_front_kms.c:119:14: sparse: undefined identifier 'drm_dev_enter' drivers/gpu/drm/xen/xen_drm_front_kms.c:132:9: sparse: undefined identifier 'drm_dev_exit' drivers/gpu/drm/xen/xen_drm_front_kms.c:141:13: sparse: undefined identifier 'drm_dev_enter' drivers/gpu/drm/xen/xen_drm_front_kms.c:144:17: sparse: undefined identifier 'drm_dev_exit' drivers/gpu/drm/xen/xen_drm_front_kms.c:258:14: sparse: undefined identifier 'drm_dev_enter' drivers/gpu/drm/xen/xen_drm_front_kms.c:274:9: sparse: undefined identifier 'drm_dev_exit' drivers/gpu/drm/xen/xen_drm_front_kms.c:296:19: sparse: incorrect type in initializer (different argument counts)
drivers/gpu/drm/xen/xen_drm_front_kms.c:296:19: expected void ( *enable )( ... )
drivers/gpu/drm/xen/xen_drm_front_kms.c:296:19: got void ( *<noident> )( ... )
drivers/gpu/drm/xen/xen_drm_front_kms.c:40:26: sparse: call with no type! drivers/gpu/drm/xen/xen_drm_front_kms.c:43:29: sparse: call with no type! drivers/gpu/drm/xen/xen_drm_front_kms.c:119:27: sparse: call with no type! drivers/gpu/drm/xen/xen_drm_front_kms.c:132:21: sparse: call with no type! drivers/gpu/drm/xen/xen_drm_front_kms.c:141:26: sparse: call with no type! drivers/gpu/drm/xen/xen_drm_front_kms.c:144:29: sparse: call with no type! drivers/gpu/drm/xen/xen_drm_front_kms.c:258:27: sparse: call with no type! drivers/gpu/drm/xen/xen_drm_front_kms.c:274:21: sparse: call with no type! drivers/gpu/drm/xen/xen_drm_front_kms.c: In function 'fb_destroy':

>> drivers/gpu/drm/xen/xen_drm_front_kms.c:40:6: error: implicit declaration of function 'drm_dev_enter'; did you mean 'drm_dev_unref'? [-Werror=implicit-function-declaration]
     if (drm_dev_enter(fb->dev, &idx)) {
         ^~~~~~~~~~~~~
         drm_dev_unref
>> drivers/gpu/drm/xen/xen_drm_front_kms.c:43:3: error: implicit declaration of function 'drm_dev_exit'; did you mean 'drm_dev_init'? [-Werror=implicit-function-declaration]
      drm_dev_exit(idx);
      ^~~~~~~~~~~~
      drm_dev_init

drivers/gpu/drm/xen/xen_drm_front_kms.c: At top level:
drivers/gpu/drm/xen/xen_drm_front_kms.c:296:12: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
.enable = display_enable,
^~~~~~~~~~~~~~
drivers/gpu/drm/xen/xen_drm_front_kms.c:296:12: note: (near initialization for 'display_funcs.enable')
cc1: some warnings being treated as errors

sparse warnings: (new ones prefixed by >>)

drivers/gpu/drm/xen/xen_drm_front.c:484:13: sparse: undefined identifier 'drm_dev_enter' drivers/gpu/drm/xen/xen_drm_front.c:487:17: sparse: undefined identifier 'drm_dev_exit'

>> drivers/gpu/drm/xen/xen_drm_front.c:484:26: sparse: call with no type!
   drivers/gpu/drm/xen/xen_drm_front.c:487:29: sparse: call with no type!
   drivers/gpu/drm/xen/xen_drm_front.c: In function 'xen_drm_drv_free_object_unlocked':
   drivers/gpu/drm/xen/xen_drm_front.c:484:6: error: implicit declaration of function 'drm_dev_enter'; did you mean 'drm_dev_unref'? [-Werror=implicit-function-declaration]
     if (drm_dev_enter(obj->dev, &idx)) {
         ^~~~~~~~~~~~~
         drm_dev_unref
   drivers/gpu/drm/xen/xen_drm_front.c:487:3: error: implicit declaration of function 'drm_dev_exit'; did you mean 'drm_dev_init'? [-Werror=implicit-function-declaration]
      drm_dev_exit(idx);
      ^~~~~~~~~~~~
      drm_dev_init

cc1: some warnings being treated as errors
--
drivers/gpu/drm/xen/xen_drm_front_kms.c:40:13: sparse: undefined identifier 'drm_dev_enter' drivers/gpu/drm/xen/xen_drm_front_kms.c:43:17: sparse: undefined identifier 'drm_dev_exit' drivers/gpu/drm/xen/xen_drm_front_kms.c:119:14: sparse: undefined identifier 'drm_dev_enter' drivers/gpu/drm/xen/xen_drm_front_kms.c:132:9: sparse: undefined identifier 'drm_dev_exit' drivers/gpu/drm/xen/xen_drm_front_kms.c:141:13: sparse: undefined identifier 'drm_dev_enter' drivers/gpu/drm/xen/xen_drm_front_kms.c:144:17: sparse: undefined identifier 'drm_dev_exit' drivers/gpu/drm/xen/xen_drm_front_kms.c:258:14: sparse: undefined identifier 'drm_dev_enter' drivers/gpu/drm/xen/xen_drm_front_kms.c:274:9: sparse: undefined identifier 'drm_dev_exit'
drivers/gpu/drm/xen/xen_drm_front_kms.c:296:19: sparse: incorrect type in initializer (different argument counts) @@ expected void ( *enable )( ... ) @@ got void ( *enable )( ... ) @@
drivers/gpu/drm/xen/xen_drm_front_kms.c:296:19: expected void ( *enable )( ... )
drivers/gpu/drm/xen/xen_drm_front_kms.c:296:19: got void ( *<noident> )( ... )

>> drivers/gpu/drm/xen/xen_drm_front_kms.c:40:26: sparse: call with no type!
   drivers/gpu/drm/xen/xen_drm_front_kms.c:43:29: sparse: call with no type!
   drivers/gpu/drm/xen/xen_drm_front_kms.c:119:27: sparse: call with no type!
   drivers/gpu/drm/xen/xen_drm_front_kms.c:132:21: sparse: call with no type!
   drivers/gpu/drm/xen/xen_drm_front_kms.c:141:26: sparse: call with no type!
   drivers/gpu/drm/xen/xen_drm_front_kms.c:144:29: sparse: call with no type!
   drivers/gpu/drm/xen/xen_drm_front_kms.c:258:27: sparse: call with no type!
   drivers/gpu/drm/xen/xen_drm_front_kms.c:274:21: sparse: call with no type!
   drivers/gpu/drm/xen/xen_drm_front_kms.c: In function 'fb_destroy':
   drivers/gpu/drm/xen/xen_drm_front_kms.c:40:6: error: implicit declaration of function 'drm_dev_enter'; did you mean 'drm_dev_unref'? [-Werror=implicit-function-declaration]
     if (drm_dev_enter(fb->dev, &idx)) {
         ^~~~~~~~~~~~~
         drm_dev_unref
   drivers/gpu/drm/xen/xen_drm_front_kms.c:43:3: error: implicit declaration of function 'drm_dev_exit'; did you mean 'drm_dev_init'? [-Werror=implicit-function-declaration]
      drm_dev_exit(idx);
      ^~~~~~~~~~~~
      drm_dev_init

drivers/gpu/drm/xen/xen_drm_front_kms.c: At top level:
drivers/gpu/drm/xen/xen_drm_front_kms.c:296:12: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
.enable = display_enable,
^~~~~~~~~~~~~~
drivers/gpu/drm/xen/xen_drm_front_kms.c:296:12: note: (near initialization for 'display_funcs.enable')
cc1: some warnings being treated as errors

vim +484 drivers/gpu/drm/xen/xen_drm_front.c

478
479 static void xen_drm_drv_free_object_unlocked(struct drm_gem_object *obj)
480 {
481 struct xen_drm_front_drm_info *drm_info = obj->dev->dev_private;
482 int idx;
483

 > 484		if (drm_dev_enter(obj->dev, &idx)) {
   485			xen_drm_front_dbuf_destroy(drm_info->front_info,
   486					xen_drm_front_dbuf_to_cookie(obj));
 > 487			drm_dev_exit(idx);

488 } else
489 dbuf_free(&drm_info->front_info->dbuf_list,
490 xen_drm_front_dbuf_to_cookie(obj));
491
492 xen_drm_front_gem_free_object_unlocked(obj);
493 }
494

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw
In reply to Oleksandr Andrushchenko
Thank you for the patch! Yet something to improve:

Hi Oleksandr,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on drm/drm-next]
[also build test ERROR on next-20180329]
[cannot apply to v4.16-rc7]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Oleksandr-Andrushchenko/drm-xen-front-Add-support-for-Xen-PV-display-frontend/20180329-191740
base:   git://people.freedesktop.org/~airlied/linux.git drm-next
config: x86_64-allmodconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

drivers/gpu/drm/xen/xen_drm_front.c:484:13: sparse: undefined identifier 'drm_dev_enter' drivers/gpu/drm/xen/xen_drm_front.c:487:17: sparse: undefined identifier 'drm_dev_exit' drivers/gpu/drm/xen/xen_drm_front.c:484:26: sparse: call with no type! drivers/gpu/drm/xen/xen_drm_front.c:487:29: sparse: call with no type! drivers/gpu/drm/xen/xen_drm_front.c: In function 'xen_drm_drv_free_object_unlocked':

>> drivers/gpu/drm/xen/xen_drm_front.c:484:6: error: implicit declaration of function 'drm_dev_enter'; did you mean 'drm_dev_unref'? [-Werror=implicit-function-declaration]
     if (drm_dev_enter(obj->dev, &idx)) {
         ^~~~~~~~~~~~~
         drm_dev_unref
>> drivers/gpu/drm/xen/xen_drm_front.c:487:3: error: implicit declaration of function 'drm_dev_exit'; did you mean 'drm_dev_init'? [-Werror=implicit-function-declaration]
      drm_dev_exit(idx);
      ^~~~~~~~~~~~
      drm_dev_init

cc1: some warnings being treated as errors
--
drivers/gpu/drm/xen/xen_drm_front_kms.c:40:13: sparse: undefined identifier 'drm_dev_enter' drivers/gpu/drm/xen/xen_drm_front_kms.c:43:17: sparse: undefined identifier 'drm_dev_exit' drivers/gpu/drm/xen/xen_drm_front_kms.c:119:14: sparse: undefined identifier 'drm_dev_enter' drivers/gpu/drm/xen/xen_drm_front_kms.c:132:9: sparse: undefined identifier 'drm_dev_exit' drivers/gpu/drm/xen/xen_drm_front_kms.c:141:13: sparse: undefined identifier 'drm_dev_enter' drivers/gpu/drm/xen/xen_drm_front_kms.c:144:17: sparse: undefined identifier 'drm_dev_exit' drivers/gpu/drm/xen/xen_drm_front_kms.c:258:14: sparse: undefined identifier 'drm_dev_enter' drivers/gpu/drm/xen/xen_drm_front_kms.c:274:9: sparse: undefined identifier 'drm_dev_exit' drivers/gpu/drm/xen/xen_drm_front_kms.c:296:19: sparse: incorrect type in initializer (different argument counts)
drivers/gpu/drm/xen/xen_drm_front_kms.c:296:19: expected void ( *enable )( ... )
drivers/gpu/drm/xen/xen_drm_front_kms.c:296:19: got void ( *<noident> )( ... )
drivers/gpu/drm/xen/xen_drm_front_kms.c:40:26: sparse: call with no type! drivers/gpu/drm/xen/xen_drm_front_kms.c:43:29: sparse: call with no type! drivers/gpu/drm/xen/xen_drm_front_kms.c:119:27: sparse: call with no type! drivers/gpu/drm/xen/xen_drm_front_kms.c:132:21: sparse: call with no type! drivers/gpu/drm/xen/xen_drm_front_kms.c:141:26: sparse: call with no type! drivers/gpu/drm/xen/xen_drm_front_kms.c:144:29: sparse: call with no type! drivers/gpu/drm/xen/xen_drm_front_kms.c:258:27: sparse: call with no type! drivers/gpu/drm/xen/xen_drm_front_kms.c:274:21: sparse: call with no type! drivers/gpu/drm/xen/xen_drm_front_kms.c: In function 'fb_destroy':

>> drivers/gpu/drm/xen/xen_drm_front_kms.c:40:6: error: implicit declaration of function 'drm_dev_enter'; did you mean 'drm_dev_unref'? [-Werror=implicit-function-declaration]
     if (drm_dev_enter(fb->dev, &idx)) {
         ^~~~~~~~~~~~~
         drm_dev_unref
>> drivers/gpu/drm/xen/xen_drm_front_kms.c:43:3: error: implicit declaration of function 'drm_dev_exit'; did you mean 'drm_dev_init'? [-Werror=implicit-function-declaration]
      drm_dev_exit(idx);
      ^~~~~~~~~~~~
      drm_dev_init

drivers/gpu/drm/xen/xen_drm_front_kms.c: At top level:
drivers/gpu/drm/xen/xen_drm_front_kms.c:296:12: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
.enable = display_enable,
^~~~~~~~~~~~~~
drivers/gpu/drm/xen/xen_drm_front_kms.c:296:12: note: (near initialization for 'display_funcs.enable')
cc1: some warnings being treated as errors

sparse warnings: (new ones prefixed by >>)

drivers/gpu/drm/xen/xen_drm_front.c:484:13: sparse: undefined identifier 'drm_dev_enter' drivers/gpu/drm/xen/xen_drm_front.c:487:17: sparse: undefined identifier 'drm_dev_exit'

>> drivers/gpu/drm/xen/xen_drm_front.c:484:26: sparse: call with no type!
   drivers/gpu/drm/xen/xen_drm_front.c:487:29: sparse: call with no type!
   drivers/gpu/drm/xen/xen_drm_front.c: In function 'xen_drm_drv_free_object_unlocked':
   drivers/gpu/drm/xen/xen_drm_front.c:484:6: error: implicit declaration of function 'drm_dev_enter'; did you mean 'drm_dev_unref'? [-Werror=implicit-function-declaration]
     if (drm_dev_enter(obj->dev, &idx)) {
         ^~~~~~~~~~~~~
         drm_dev_unref
   drivers/gpu/drm/xen/xen_drm_front.c:487:3: error: implicit declaration of function 'drm_dev_exit'; did you mean 'drm_dev_init'? [-Werror=implicit-function-declaration]
      drm_dev_exit(idx);
      ^~~~~~~~~~~~
      drm_dev_init

cc1: some warnings being treated as errors
--
drivers/gpu/drm/xen/xen_drm_front_kms.c:40:13: sparse: undefined identifier 'drm_dev_enter' drivers/gpu/drm/xen/xen_drm_front_kms.c:43:17: sparse: undefined identifier 'drm_dev_exit' drivers/gpu/drm/xen/xen_drm_front_kms.c:119:14: sparse: undefined identifier 'drm_dev_enter' drivers/gpu/drm/xen/xen_drm_front_kms.c:132:9: sparse: undefined identifier 'drm_dev_exit' drivers/gpu/drm/xen/xen_drm_front_kms.c:141:13: sparse: undefined identifier 'drm_dev_enter' drivers/gpu/drm/xen/xen_drm_front_kms.c:144:17: sparse: undefined identifier 'drm_dev_exit' drivers/gpu/drm/xen/xen_drm_front_kms.c:258:14: sparse: undefined identifier 'drm_dev_enter' drivers/gpu/drm/xen/xen_drm_front_kms.c:274:9: sparse: undefined identifier 'drm_dev_exit'
drivers/gpu/drm/xen/xen_drm_front_kms.c:296:19: sparse: incorrect type in initializer (different argument counts) @@ expected void ( *enable )( ... ) @@ got void ( *enable )( ... ) @@
drivers/gpu/drm/xen/xen_drm_front_kms.c:296:19: expected void ( *enable )( ... )
drivers/gpu/drm/xen/xen_drm_front_kms.c:296:19: got void ( *<noident> )( ... )

>> drivers/gpu/drm/xen/xen_drm_front_kms.c:40:26: sparse: call with no type!
   drivers/gpu/drm/xen/xen_drm_front_kms.c:43:29: sparse: call with no type!
   drivers/gpu/drm/xen/xen_drm_front_kms.c:119:27: sparse: call with no type!
   drivers/gpu/drm/xen/xen_drm_front_kms.c:132:21: sparse: call with no type!
   drivers/gpu/drm/xen/xen_drm_front_kms.c:141:26: sparse: call with no type!
   drivers/gpu/drm/xen/xen_drm_front_kms.c:144:29: sparse: call with no type!
   drivers/gpu/drm/xen/xen_drm_front_kms.c:258:27: sparse: call with no type!
   drivers/gpu/drm/xen/xen_drm_front_kms.c:274:21: sparse: call with no type!
   drivers/gpu/drm/xen/xen_drm_front_kms.c: In function 'fb_destroy':
   drivers/gpu/drm/xen/xen_drm_front_kms.c:40:6: error: implicit declaration of function 'drm_dev_enter'; did you mean 'drm_dev_unref'? [-Werror=implicit-function-declaration]
     if (drm_dev_enter(fb->dev, &idx)) {
         ^~~~~~~~~~~~~
         drm_dev_unref
   drivers/gpu/drm/xen/xen_drm_front_kms.c:43:3: error: implicit declaration of function 'drm_dev_exit'; did you mean 'drm_dev_init'? [-Werror=implicit-function-declaration]
      drm_dev_exit(idx);
      ^~~~~~~~~~~~
      drm_dev_init

drivers/gpu/drm/xen/xen_drm_front_kms.c: At top level:
drivers/gpu/drm/xen/xen_drm_front_kms.c:296:12: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
.enable = display_enable,
^~~~~~~~~~~~~~
drivers/gpu/drm/xen/xen_drm_front_kms.c:296:12: note: (near initialization for 'display_funcs.enable')
cc1: some warnings being treated as errors

vim +484 drivers/gpu/drm/xen/xen_drm_front.c

478
479 static void xen_drm_drv_free_object_unlocked(struct drm_gem_object *obj)
480 {
481 struct xen_drm_front_drm_info *drm_info = obj->dev->dev_private;
482 int idx;
483

 > 484		if (drm_dev_enter(obj->dev, &idx)) {
   485			xen_drm_front_dbuf_destroy(drm_info->front_info,
   486					xen_drm_front_dbuf_to_cookie(obj));
 > 487			drm_dev_exit(idx);

488 } else
489 dbuf_free(&drm_info->front_info->dbuf_list,
490 xen_drm_front_dbuf_to_cookie(obj));
491
492 xen_drm_front_gem_free_object_unlocked(obj);
493 }
494

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#4 lore raw

PATCH v5 1/1 drm/xen-front: Add support for Xen PV display frontend

In reply to Oleksandr Andrushchenko

From: Oleksandr Andrushchenko <[email protected]>

Add support for Xen para-virtualized frontend display driver. Accompanying backend [1] is implemented as a user-space application and its helper library [2], capable of running as a Weston client or DRM master.
Configuration of both backend and frontend is done via Xen guest domain configuration options [3].

Driver limitations:
1. Only primary plane without additional properties is supported.
2. Only one video mode supported which resolution is configured via XenStore.
3. All CRTCs operate at fixed frequency of 60Hz.

1. Implement Xen bus state machine for the frontend driver according to the state diagram and recovery flow from display para-virtualized
protocol: xen/interface/io/displif.h.

2. Read configuration values from Xen store according to xen/interface/io/displif.h protocol:
- read connector(s) configuration
- read buffer allocation mode (backend/frontend)

3. Handle Xen event channels:
- create for all configured connectors and publish corresponding ring references and event channels in Xen store, so backend can connect
- implement event channels interrupt handlers
- create and destroy event channels with respect to Xen bus state

4. Implement shared buffer handling according to the para-virtualized display device protocol at xen/interface/io/displif.h:
- handle page directories according to displif protocol:
- allocate and share page directories
- grant references to the required set of pages for the page directory
- allocate xen balllooned pages via Xen balloon driver with alloc_xenballooned_pages/free_xenballooned_pages
- grant references to the required set of pages for the shared buffer itself
- implement pages map/unmap for the buffers allocated by the backend (gnttab_map_refs/gnttab_unmap_refs)

5. Implement kernel modesetiing/connector handling using DRM simple KMS helper pipeline:

- implement KMS part of the driver with the help of DRM simple pipepline helper which is possible due to the fact that the para-virtualized driver only supports a single (primary) plane:
- initialize connectors according to XenStore configuration
- handle frame done events from the backend
- create and destroy frame buffers and propagate those to the backend
- propagate set/reset mode configuration to the backend on display enable/disable callbacks
- send page flip request to the backend and implement logic for reporting backend IO errors on prepare fb callback

- implement virtual connector handling:
- support only pixel formats suitable for single plane modes
- make sure the connector is always connected
- support a single video mode as per para-virtualized driver configuration

6. Implement GEM handling depending on driver mode of operation:
depending on the requirements for the para-virtualized environment, namely requirements dictated by the accompanying DRM/(v)GPU drivers running in both host and guest environments, number of operating modes of para-virtualized display driver are supported:
- display buffers can be allocated by either frontend driver or backend
- display buffers can be allocated to be contiguous in memory or not

Note! Frontend driver itself has no dependency on contiguous memory for its operation.

6.1. Buffers allocated by the frontend driver.

The below modes of operation are configured at compile-time via frontend driver's kernel configuration.

6.1.1. Front driver configured to use GEM CMA helpers
This use-case is useful when used with accompanying DRM/vGPU driver in guest domain which was designed to only work with contiguous buffers, e.g. DRM driver based on GEM CMA helpers: such drivers can only import contiguous PRIME buffers, thus requiring frontend driver to provide such. In order to implement this mode of operation para-virtualized frontend driver can be configured to use GEM CMA helpers.

6.1.2. Front driver doesn't use GEM CMA
If accompanying drivers can cope with non-contiguous memory then, to lower pressure on CMA subsystem of the kernel, driver can allocate buffers from system memory.

Note! If used with accompanying DRM/(v)GPU drivers this mode of operation may require IOMMU support on the platform, so accompanying DRM/vGPU hardware can still reach display buffer memory while importing PRIME buffers from the frontend driver.

6.2. Buffers allocated by the backend

This mode of operation is run-time configured via guest domain configuration through XenStore entries.

For systems which do not provide IOMMU support, but having specific requirements for display buffers it is possible to allocate such buffers at backend side and share those with the frontend.
For example, if host domain is 1:1 mapped and has DRM/GPU hardware expecting physically contiguous memory, this allows implementing zero-copying use-cases.

Note, while using this scenario the following should be considered:
a) If guest domain dies then pages/grants received from the backend cannot be claimed back
b) Misbehaving guest may send too many requests to the backend exhausting its grant references and memory (consider this from security POV).

Note! Configuration options 1.1 (contiguous display buffers) and 2 (backend allocated buffers) are not supported at the same time.

7. Handle communication with the backend:
- send requests and wait for the responses according to the displif protocol
- serialize access to the communication channel
- time-out used for backend communication is set to 3000 ms
- manage display buffers shared with the backend

[1] https://github.com/xen-troops/displ_be
[2] https://github.com/xen-troops/libxenbe
[3] https://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=docs/man/xl.cfg.pod.5.in;h=a699367779e2ae1212ff8f638eff0206ec1a1cc9;hb=refs/heads/master#l1257

---
 Documentation/gpu/drivers.rst               |   1 +
 Documentation/gpu/xen-front.rst             |  43 ++
 drivers/gpu/drm/Kconfig                     |   2 +
 drivers/gpu/drm/Makefile                    |   1 +
 drivers/gpu/drm/xen/Kconfig                 |  30 +
 drivers/gpu/drm/xen/Makefile                |  16 +
 drivers/gpu/drm/xen/xen_drm_front.c         | 880 ++++++++++++++++++++++++++++
 drivers/gpu/drm/xen/xen_drm_front.h         | 189 ++++++
 drivers/gpu/drm/xen/xen_drm_front_cfg.c     |  77 +++
 drivers/gpu/drm/xen/xen_drm_front_cfg.h     |  37 ++
 drivers/gpu/drm/xen/xen_drm_front_conn.c    | 115 ++++
 drivers/gpu/drm/xen/xen_drm_front_conn.h    |  27 +
 drivers/gpu/drm/xen/xen_drm_front_evtchnl.c | 386 ++++++++++++
 drivers/gpu/drm/xen/xen_drm_front_evtchnl.h |  81 +++
 drivers/gpu/drm/xen/xen_drm_front_gem.c     | 309 ++++++++++
 drivers/gpu/drm/xen/xen_drm_front_gem.h     |  41 ++
 drivers/gpu/drm/xen/xen_drm_front_gem_cma.c |  78 +++
 drivers/gpu/drm/xen/xen_drm_front_kms.c     | 372 ++++++++++++
 drivers/gpu/drm/xen/xen_drm_front_kms.h     |  27 +
 drivers/gpu/drm/xen/xen_drm_front_shbuf.c   | 432 ++++++++++++++
 drivers/gpu/drm/xen/xen_drm_front_shbuf.h   |  72 +++
 21 files changed, 3216 insertions(+)
 create mode 100644 Documentation/gpu/xen-front.rst
 create mode 100644 drivers/gpu/drm/xen/Kconfig
 create mode 100644 drivers/gpu/drm/xen/Makefile
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front.c
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front.h
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front_cfg.c
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front_cfg.h
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front_conn.c
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front_conn.h
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front_evtchnl.c
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front_evtchnl.h
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front_gem.c
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front_gem.h
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front_gem_cma.c
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front_kms.c
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front_kms.h
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front_shbuf.c
 create mode 100644 drivers/gpu/drm/xen/xen_drm_front_shbuf.h
Documentation/gpu/drivers.rst +1 -0
index e8c84419a2a1..d3ab6abae838 100644
@@ -12,6 +12,7 @@ GPU Driver Documentation
    tve200
    vc4
    bridge/dw-hdmi
+   xen-front
 
 .. only::  subproject and html
 
Documentation/gpu/xen-front.rst new file +43 -0

43 lines not on this page · raw message

drivers/gpu/drm/Kconfig +2 -0
index deeefa7a1773..757825ac60df 100644
@@ -289,6 +289,8 @@ source "drivers/gpu/drm/pl111/Kconfig"
 
 source "drivers/gpu/drm/tve200/Kconfig"
 
+source "drivers/gpu/drm/xen/Kconfig"
+
 # Keep legacy drivers last
 
 menuconfig DRM_LEGACY
drivers/gpu/drm/Makefile +1 -0
index 50093ff4479b..9d66657ea117 100644
@@ -103,3 +103,4 @@ obj-$(CONFIG_DRM_MXSFB)	+= mxsfb/
 obj-$(CONFIG_DRM_TINYDRM) += tinydrm/
 obj-$(CONFIG_DRM_PL111) += pl111/
 obj-$(CONFIG_DRM_TVE200) += tve200/
+obj-$(CONFIG_DRM_XEN) += xen/
drivers/gpu/drm/xen/Kconfig new file +30 -0
new file mode 100644
index 000000000000..4f4abc91f3b6
@@ -0,0 +1,30 @@
+config DRM_XEN
+	bool "DRM Support for Xen guest OS"
+	depends on XEN
+	help
+	  Choose this option if you want to enable DRM support
+	  for Xen.
+
+config DRM_XEN_FRONTEND
+	tristate "Para-virtualized frontend driver for Xen guest OS"
+	depends on DRM_XEN
+	depends on DRM
+	select DRM_KMS_HELPER
+	select VIDEOMODE_HELPERS
+	select XEN_XENBUS_FRONTEND
+	help
+	  Choose this option if you want to enable a para-virtualized
+	  frontend DRM/KMS driver for Xen guest OSes.
+
+config DRM_XEN_FRONTEND_CMA
+	bool "Use DRM CMA to allocate dumb buffers"
+	depends on DRM_XEN_FRONTEND
+	select DRM_KMS_CMA_HELPER
+	select DRM_GEM_CMA_HELPER
+	help
+	  Use DRM CMA helpers to allocate display buffers.
+	  This is useful for the use-cases when guest driver needs to
+	  share or export buffers to other drivers which only expect
+	  contiguous buffers.
+	  Note: in this mode driver cannot use buffers allocated
+	  by the backend.
drivers/gpu/drm/xen/Makefile new file +16 -0
new file mode 100644
index 000000000000..352730dc6c13
@@ -0,0 +1,16 @@
+# SPDX-License-Identifier: GPL-2.0 OR MIT
+
+drm_xen_front-objs := xen_drm_front.o \
+		      xen_drm_front_kms.o \
+		      xen_drm_front_conn.o \
+		      xen_drm_front_evtchnl.o \
+		      xen_drm_front_shbuf.o \
+		      xen_drm_front_cfg.o
+
+ifeq ($(CONFIG_DRM_XEN_FRONTEND_CMA),y)
+	drm_xen_front-objs += xen_drm_front_gem_cma.o
+else
+	drm_xen_front-objs += xen_drm_front_gem.o
+endif
+
+obj-$(CONFIG_DRM_XEN_FRONTEND) += drm_xen_front.o
drivers/gpu/drm/xen/xen_drm_front.c new file +880 -0

880 lines not on this page · raw message

drivers/gpu/drm/xen/xen_drm_front.h new file +189 -0

189 lines not on this page · raw message

drivers/gpu/drm/xen/xen_drm_front_cfg.c new file +77 -0

77 lines not on this page · raw message

drivers/gpu/drm/xen/xen_drm_front_cfg.h new file +37 -0
new file mode 100644
index 000000000000..6e7af670f8cd
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: GPL-2.0 OR MIT */
+
+/*
+ *  Xen para-virtual DRM device
+ *
+ * Copyright (C) 2016-2018 EPAM Systems Inc.
+ *
+ * Author: Oleksandr Andrushchenko <[email protected]>
+ */
+
+#ifndef __XEN_DRM_FRONT_CFG_H_
+#define __XEN_DRM_FRONT_CFG_H_
+
+#include <linux/types.h>
+
+#define XEN_DRM_FRONT_MAX_CRTCS	4
+
+struct xen_drm_front_cfg_connector {
+	int width;
+	int height;
+	char *xenstore_path;
+};
+
+struct xen_drm_front_cfg {
+	struct xen_drm_front_info *front_info;
+	/* number of connectors in this configuration */
+	int num_connectors;
+	/* connector configurations */
+	struct xen_drm_front_cfg_connector connectors[XEN_DRM_FRONT_MAX_CRTCS];
+	/* set if dumb buffers are allocated externally on backend side */
+	bool be_alloc;
+};
+
+int xen_drm_front_cfg_card(struct xen_drm_front_info *front_info,
+		struct xen_drm_front_cfg *cfg);
+
+#endif /* __XEN_DRM_FRONT_CFG_H_ */
drivers/gpu/drm/xen/xen_drm_front_conn.c new file +115 -0

115 lines not on this page · raw message

drivers/gpu/drm/xen/xen_drm_front_conn.h new file +27 -0
new file mode 100644
index 000000000000..f38c4b6db5df
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0 OR MIT */
+
+/*
+ *  Xen para-virtual DRM device
+ *
+ * Copyright (C) 2016-2018 EPAM Systems Inc.
+ *
+ * Author: Oleksandr Andrushchenko <[email protected]>
+ */
+
+#ifndef __XEN_DRM_FRONT_CONN_H_
+#define __XEN_DRM_FRONT_CONN_H_
+
+#include <drm/drmP.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_encoder.h>
+
+#include <linux/wait.h>
+
+struct xen_drm_front_drm_info;
+
+int xen_drm_front_conn_init(struct xen_drm_front_drm_info *drm_info,
+		struct drm_connector *connector);
+
+const uint32_t *xen_drm_front_conn_get_formats(int *format_count);
+
+#endif /* __XEN_DRM_FRONT_CONN_H_ */
drivers/gpu/drm/xen/xen_drm_front_evtchnl.c new file +386 -0

386 lines not on this page · raw message

drivers/gpu/drm/xen/xen_drm_front_evtchnl.h new file +81 -0

81 lines not on this page · raw message

drivers/gpu/drm/xen/xen_drm_front_gem.c new file +309 -0

309 lines not on this page · raw message

drivers/gpu/drm/xen/xen_drm_front_gem.h new file +41 -0

41 lines not on this page · raw message

drivers/gpu/drm/xen/xen_drm_front_gem_cma.c new file +78 -0

78 lines not on this page · raw message

drivers/gpu/drm/xen/xen_drm_front_kms.c new file +372 -0

372 lines not on this page · raw message

drivers/gpu/drm/xen/xen_drm_front_kms.h new file +27 -0
new file mode 100644
index 000000000000..1c3a64c36dbb
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0 OR MIT */
+
+/*
+ *  Xen para-virtual DRM device
+ *
+ * Copyright (C) 2016-2018 EPAM Systems Inc.
+ *
+ * Author: Oleksandr Andrushchenko <[email protected]>
+ */
+
+#ifndef __XEN_DRM_FRONT_KMS_H_
+#define __XEN_DRM_FRONT_KMS_H_
+
+#include <linux/types.h>
+
+struct xen_drm_front_drm_info;
+struct xen_drm_front_drm_pipeline;
+
+int xen_drm_front_kms_init(struct xen_drm_front_drm_info *drm_info);
+
+void xen_drm_front_kms_fini(struct xen_drm_front_drm_info *drm_info);
+
+void xen_drm_front_kms_on_frame_done(
+		struct xen_drm_front_drm_pipeline *pipeline,
+		uint64_t fb_cookie);
+
+#endif /* __XEN_DRM_FRONT_KMS_H_ */
drivers/gpu/drm/xen/xen_drm_front_shbuf.c new file +432 -0

273 lines not on this page · raw message

drivers/gpu/drm/xen/xen_drm_front_shbuf.h new file +72 -0

72 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 7 lines
2.16.2


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Part of the diff is not shown here. View the raw message.

#5 lore raw
In reply to Oleksandr Andrushchenko
Quoted 1 line · Oleksandr Andrushchenko

Changes since v4:

For your convenience I am attaching diff between v4..v5

Documentation/gpu/xen-front.rst +3 -3
index 8188e03c9d23..009d942386c5 100644
@@ -1,6 +1,6 @@
-====================================
-Xen para-virtualized frontend driver
-====================================
+====================================================
+ drm/xen-front Xen para-virtualized frontend driver
+====================================================
 
 This frontend driver implements Xen para-virtualized display
 according to the display protocol described at
drivers/gpu/drm/xen/xen_drm_front_evtchnl.c +6 -2
index e521785fd22b..02b6f3d9fe4c 100644
@@ -186,8 +186,10 @@ static int evtchnl_alloc(struct xen_drm_front_info *front_info, int index,
 				sring, XEN_PAGE_SIZE);
 
 		ret = xenbus_grant_ring(xb_dev, sring, 1, &gref);
-		if (ret < 0)
+		if (ret < 0) {
+			free_page(page);
 			goto fail;
+		}
 
 		handler = evtchnl_interrupt_ctrl;
 	} else {
@@ -195,8 +197,10 @@ static int evtchnl_alloc(struct xen_drm_front_info *front_info, int index,
 
 		ret = gnttab_grant_foreign_access(xb_dev->otherend_id,
 				virt_to_gfn((void *)page), 0);
-		if (ret < 0)
+		if (ret < 0) {
+			free_page(page);
 			goto fail;
+		}
 
 		gref = ret;
 		handler = evtchnl_interrupt_evt;
drivers/gpu/drm/xen/xen_drm_front_kms.c +4 -3
index 545049dfaf0a..f3ef9dfb4dfb 100644
@@ -107,12 +107,13 @@ static void send_pending_event(struct xen_drm_front_drm_pipeline *pipeline)
 }
 
 static void display_enable(struct drm_simple_display_pipe *pipe,
-		struct drm_crtc_state *crtc_state)
+		struct drm_crtc_state *crtc_state,
+		struct drm_plane_state *plane_state)
 {
 	struct xen_drm_front_drm_pipeline *pipeline =
 			to_xen_drm_pipeline(pipe);
 	struct drm_crtc *crtc = &pipe->crtc;
-	struct drm_framebuffer *fb = pipe->plane.state->fb;
+	struct drm_framebuffer *fb = plane_state->fb;
 	int ret, idx;
 
 	if (!drm_dev_enter(pipe->crtc.dev, &idx))
@@ -273,7 +274,7 @@ static void display_update(struct drm_simple_display_pipe *pipe,
 	drm_dev_exit(idx);
 }
 
-enum drm_mode_status display_mode_valid(struct drm_crtc *crtc,
+static enum drm_mode_status display_mode_valid(struct drm_crtc *crtc,
 		const struct drm_display_mode *mode)
 {
 	struct xen_drm_front_drm_pipeline *pipeline =
#6 lore raw
In reply to Oleksandr Andrushchenko
Quoted 1 line · Oleksandr Andrushchenko

Changes since v4:

For your convenience I am attaching diff between v4..v5

Documentation/gpu/xen-front.rst +3 -3
index 8188e03c9d23..009d942386c5 100644
@@ -1,6 +1,6 @@
-====================================
-Xen para-virtualized frontend driver
-====================================
+====================================================
+ drm/xen-front Xen para-virtualized frontend driver
+====================================================
 
 This frontend driver implements Xen para-virtualized display
 according to the display protocol described at
drivers/gpu/drm/xen/xen_drm_front_evtchnl.c +6 -2
index e521785fd22b..02b6f3d9fe4c 100644
@@ -186,8 +186,10 @@ static int evtchnl_alloc(struct xen_drm_front_info *front_info, int index,
 				sring, XEN_PAGE_SIZE);
 
 		ret = xenbus_grant_ring(xb_dev, sring, 1, &gref);
-		if (ret < 0)
+		if (ret < 0) {
+			free_page(page);
 			goto fail;
+		}
 
 		handler = evtchnl_interrupt_ctrl;
 	} else {
@@ -195,8 +197,10 @@ static int evtchnl_alloc(struct xen_drm_front_info *front_info, int index,
 
 		ret = gnttab_grant_foreign_access(xb_dev->otherend_id,
 				virt_to_gfn((void *)page), 0);
-		if (ret < 0)
+		if (ret < 0) {
+			free_page(page);
 			goto fail;
+		}
 
 		gref = ret;
 		handler = evtchnl_interrupt_evt;
drivers/gpu/drm/xen/xen_drm_front_kms.c +4 -3
index 545049dfaf0a..f3ef9dfb4dfb 100644
@@ -107,12 +107,13 @@ static void send_pending_event(struct xen_drm_front_drm_pipeline *pipeline)
 }
 
 static void display_enable(struct drm_simple_display_pipe *pipe,
-		struct drm_crtc_state *crtc_state)
+		struct drm_crtc_state *crtc_state,
+		struct drm_plane_state *plane_state)
 {
 	struct xen_drm_front_drm_pipeline *pipeline =
 			to_xen_drm_pipeline(pipe);
 	struct drm_crtc *crtc = &pipe->crtc;
-	struct drm_framebuffer *fb = pipe->plane.state->fb;
+	struct drm_framebuffer *fb = plane_state->fb;
 	int ret, idx;
 
 	if (!drm_dev_enter(pipe->crtc.dev, &idx))
@@ -273,7 +274,7 @@ static void display_update(struct drm_simple_display_pipe *pipe,
 	drm_dev_exit(idx);
 }
 
-enum drm_mode_status display_mode_valid(struct drm_crtc *crtc,
+static enum drm_mode_status display_mode_valid(struct drm_crtc *crtc,
 		const struct drm_display_mode *mode)
 {
 	struct xen_drm_front_drm_pipeline *pipeline =

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel