drm/xen-front: Add support for Xen PV display frontend
Subsystems (4)
PATCH v2 7/8 drm/xen-front: Implement GEM operations and backend communication
In reply to Oleksandr AndrushchenkoFrom: Oleksandr Andrushchenko <[email protected]>
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.
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.
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.
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
--- drivers/gpu/drm/xen/Kconfig | 13 ++ drivers/gpu/drm/xen/Makefile | 6 + drivers/gpu/drm/xen/xen_drm_front.c | 324 ++++++++++++++++++++++++++- drivers/gpu/drm/xen/xen_drm_front.h | 8 + drivers/gpu/drm/xen/xen_drm_front_conn.c | 31 ++- drivers/gpu/drm/xen/xen_drm_front_drv.c | 70 +++++- drivers/gpu/drm/xen/xen_drm_front_drv.h | 13 ++ drivers/gpu/drm/xen/xen_drm_front_gem.c | 335 ++++++++++++++++++++++++++++ drivers/gpu/drm/xen/xen_drm_front_gem.h | 41 ++++ drivers/gpu/drm/xen/xen_drm_front_gem_cma.c | 74 ++++++ drivers/gpu/drm/xen/xen_drm_front_kms.c | 44 +++- drivers/gpu/drm/xen/xen_drm_front_kms.h | 3 + 12 files changed, 953 insertions(+), 9 deletions(-) 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
drivers/gpu/drm/xen/Kconfig +13 -0
@@ -15,3 +15,16 @@ config DRM_XEN_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 +6 -0
@@ -8,4 +8,10 @@ drm_xen_front-objs := xen_drm_front.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 +319 -5
375 lines not on this page · raw message
drivers/gpu/drm/xen/xen_drm_front.h +8 -0
@@ -15,6 +15,9 @@#include "xen_drm_front_cfg.h" +/* timeout in ms to wait for backend to respond */ +#define XEN_DRM_FRONT_WAIT_BACK_MS 3000 +#ifndef GRANT_INVALID_REF /* * Note on usage of grant reference 0 as invalid grant reference:
@@ -30,6 +33,8 @@ struct xen_drm_front_info {struct xenbus_device *xb_dev;/* to protect data between backend IO code and interrupt handler */ spinlock_t io_lock; +/* serializer for backend IO: request/response */ +struct mutex req_io_lock;bool drm_pdrv_registered;/* virtual DRM platform device */ struct platform_device *drm_pdev;
@@ -37,6 +42,9 @@ struct xen_drm_front_info {int num_evt_pairs;struct xen_drm_front_evtchnl_pair *evt_pairs;struct xen_drm_front_cfg cfg; + +/* display buffers */ +struct list_head dbuf_list; }; int xen_drm_front_mode_set(struct xen_drm_front_drm_pipeline *pipeline,
drivers/gpu/drm/xen/xen_drm_front_conn.c +29 -2
@@ -15,6 +15,7 @@#include "xen_drm_front_conn.h" #include "xen_drm_front_drv.h" +#include "xen_drm_front_kms.h" static struct xen_drm_front_drm_pipeline *to_xen_drm_pipeline (struct drm_connector *connector)
@@ -43,10 +44,28 @@ static int connector_detect(struct drm_connector *connector, struct drm_modeset_acquire_ctx *ctx, bool force) { +struct xen_drm_front_drm_pipeline *pipeline = +to_xen_drm_pipeline (connector); +struct xen_drm_front_info *front_info = pipeline->drm_info->front_info; +unsigned long flags; + +/* check if there is a frame done event time-out */ +spin_lock_irqsave (&front_info->io_lock, flags); +if (pipeline->pflip_timeout && +time_after_eq (jiffies, pipeline->pflip_timeout)) { +DRM_ERROR ("Frame done event timed-out\n" ); + + pipeline->pflip_timeout =0 ; + pipeline->conn_connected = false; +xen_drm_front_kms_send_pending_event (pipeline); + } +spin_unlock_irqrestore (&front_info->io_lock, flags); +if (drm_dev_is_unplugged (connector->dev)) - return connector_status_disconnected; + pipeline->conn_connected = false; -return connector_status_connected; +return pipeline->conn_connected ? connector_status_connected : + connector_status_disconnected; }#define XEN_DRM_NUM_VIDEO_MODES 1
@@ -112,8 +131,16 @@ static const struct drm_connector_funcs connector_funcs = {int xen_drm_front_conn_init (struct xen_drm_front_drm_info *drm_info,struct drm_connector *connector) { +struct xen_drm_front_drm_pipeline *pipeline = +to_xen_drm_pipeline (connector); +drm_connector_helper_add (connector, &connector_helper_funcs); + pipeline->conn_connected = true; + + connector->polled =DRM_CONNECTOR_POLL_CONNECT | +DRM_CONNECTOR_POLL_DISCONNECT ; +return drm_connector_init (drm_info->drm_dev, connector, &connector_funcs,DRM_MODE_CONNECTOR_VIRTUAL ); }
drivers/gpu/drm/xen/xen_drm_front_drv.c +69 -1
122 lines not on this page · raw message
drivers/gpu/drm/xen/xen_drm_front_drv.h +13 -0
@@ -30,6 +30,19 @@ struct xen_drm_front_drm_pipeline {int width, height;struct drm_pending_vblank_event *pending_event; + +/* +* pflip_timeout is set to current jiffies once we send a page flip and +* reset to 0 when we receive frame done event from the backed. +* It is checked during drm_connector_helper_funcs.detect_ctx to detect +* time-outs for frame done event, e.g. due to backend errors. +* +* This must be protected with front_info->io_lock, so races between +* interrupt handler and rest of the code are properly handled. +*/ +unsigned long pflip_timeout; + +bool conn_connected; };struct xen_drm_front_drm_info {
drivers/gpu/drm/xen/xen_drm_front_gem.c new file +335 -0
335 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 +74 -0
74 lines not on this page · raw message
drivers/gpu/drm/xen/xen_drm_front_kms.c +43 -1
112 lines not on this page · raw message
drivers/gpu/drm/xen/xen_drm_front_kms.h +3 -0
@@ -19,4 +19,7 @@ void xen_drm_front_kms_on_frame_done(struct xen_drm_front_drm_pipeline *pipeline, uint64_t fb_cookie); +void xen_drm_front_kms_send_pending_event ( +struct xen_drm_front_drm_pipeline *pipeline); +#endif /* __XEN_DRM_FRONT_KMS_H_ */
Signature · 1 line
2.7.4
PATCH v2 8/8 drm/xen-front: Provide kernel documentation
In reply to Oleksandr AndrushchenkoFrom: Oleksandr Andrushchenko <[email protected]>
Provide kernel documentation for the Xen para-virtualized frontend DRM driver.
--- Documentation/gpu/index.rst | 1 + Documentation/gpu/xen-front.rst | 77 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 Documentation/gpu/xen-front.rst
Documentation/gpu/index.rst +1 -0
@@ -20,6 +20,7 @@ Linux GPU Driver Developer's Guide vga-switcheroo vgaarbiter bridge/dw-hdmi + xen-front todo .. only:: subproject and html
Documentation/gpu/xen-front.rst new file +77 -0
77 lines not on this page · raw message
Signature · 1 line
2.7.4
v2 cover drm/xen-front: Add support for Xen PV display frontend
From: Oleksandr Andrushchenko <[email protected]>
Hello!
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 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
Oleksandr Andrushchenko (8):
drm/xen-front: Introduce Xen para-virtualized frontend driver drm/xen-front: Implement Xen bus state handling drm/xen-front: Read driver configuration from Xen store drm/xen-front: Implement Xen event channel handling drm/xen-front: Implement handling of shared display buffers drm/xen-front: Introduce DRM/KMS virtual display driver drm/xen-front: Implement GEM operations and backend communication drm/xen-front: Provide kernel documentation
Documentation/gpu/index.rst | 1 + Documentation/gpu/xen-front.rst | 77 ++++ drivers/gpu/drm/Kconfig | 2 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/xen/Kconfig | 30 ++ drivers/gpu/drm/xen/Makefile | 17 + drivers/gpu/drm/xen/xen_drm_front.c | 690 ++++++++++++++++++++++++++++ drivers/gpu/drm/xen/xen_drm_front.h | 77 ++++ 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 | 146 ++++++ drivers/gpu/drm/xen/xen_drm_front_conn.h | 27 ++ drivers/gpu/drm/xen/xen_drm_front_drv.c | 239 ++++++++++ drivers/gpu/drm/xen/xen_drm_front_drv.h | 78 ++++ drivers/gpu/drm/xen/xen_drm_front_evtchnl.c | 383 +++++++++++++++ drivers/gpu/drm/xen/xen_drm_front_evtchnl.h | 79 ++++ drivers/gpu/drm/xen/xen_drm_front_gem.c | 335 ++++++++++++++ drivers/gpu/drm/xen/xen_drm_front_gem.h | 41 ++ drivers/gpu/drm/xen/xen_drm_front_gem_cma.c | 74 +++ drivers/gpu/drm/xen/xen_drm_front_kms.c | 324 +++++++++++++ drivers/gpu/drm/xen/xen_drm_front_kms.h | 25 + drivers/gpu/drm/xen/xen_drm_front_shbuf.c | 432 +++++++++++++++++ drivers/gpu/drm/xen/xen_drm_front_shbuf.h | 72 +++ 23 files changed, 3264 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_drv.c create mode 100644 drivers/gpu/drm/xen/xen_drm_front_drv.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.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 1/8 drm/xen-front: Introduce Xen para-virtualized frontend driver
From: Oleksandr Andrushchenko <[email protected]>
Introduce skeleton of the para-virtualized Xen display frontend driver. This patch only adds required essential stubs.
--- drivers/gpu/drm/Kconfig | 2 ++ drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/xen/Kconfig | 17 +++++++++ drivers/gpu/drm/xen/Makefile | 5 +++ drivers/gpu/drm/xen/xen_drm_front.c | 70 +++++++++++++++++++++++++++++++++++++ 5 files changed, 95 insertions(+) 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
drivers/gpu/drm/Kconfig +2 -0
@@ -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
@@ -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 +17 -0
@@ -0,0 +1,17 @@ +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.
drivers/gpu/drm/xen/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0 OR MIT + +drm_xen_front-objs := xen_drm_front.o + +obj-$(CONFIG_DRM_XEN_FRONTEND) += drm_xen_front.o
drivers/gpu/drm/xen/xen_drm_front.c new file +70 -0
70 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 1/8 drm/xen-front: Introduce Xen para-virtualized frontend driver
In reply to Oleksandr AndrushchenkoFrom: Oleksandr Andrushchenko <[email protected]>
Introduce skeleton of the para-virtualized Xen display frontend driver. This patch only adds required essential stubs.
--- drivers/gpu/drm/Kconfig | 2 ++ drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/xen/Kconfig | 17 +++++++++ drivers/gpu/drm/xen/Makefile | 5 +++ drivers/gpu/drm/xen/xen_drm_front.c | 70 +++++++++++++++++++++++++++++++++++++ 5 files changed, 95 insertions(+) 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
drivers/gpu/drm/Kconfig +2 -0
@@ -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
@@ -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 +17 -0
@@ -0,0 +1,17 @@ +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.
drivers/gpu/drm/xen/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0 OR MIT + +drm_xen_front-objs := xen_drm_front.o + +obj-$(CONFIG_DRM_XEN_FRONTEND) += drm_xen_front.o
drivers/gpu/drm/xen/xen_drm_front.c new file +70 -0
70 lines not on this page · raw message
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 2/8 drm/xen-front: Implement Xen bus state handling
In reply to Oleksandr AndrushchenkoFrom: Oleksandr Andrushchenko <[email protected]>
Initial handling for Xen bus states: 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.
--- drivers/gpu/drm/xen/xen_drm_front.c | 124 +++++++++++++++++++++++++++++++++++- drivers/gpu/drm/xen/xen_drm_front.h | 18 ++++++ 2 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/xen/xen_drm_front.h
drivers/gpu/drm/xen/xen_drm_front.c +123 -1
@@ -16,19 +16,141 @@#include <xen/interface/io/displif.h> +#include "xen_drm_front.h" + +static void xen_drv_remove_internal (struct xen_drm_front_info *front_info) +{ +} + +static int displback_initwait (struct xen_drm_front_info *front_info) +{ +return 0 ; +} + +static int displback_connect (struct xen_drm_front_info *front_info) +{ +return 0 ; +} + +static void displback_disconnect (struct xen_drm_front_info *front_info) +{ +xenbus_switch_state (front_info->xb_dev, XenbusStateInitialising); +} +static void displback_changed (struct xenbus_device *xb_dev,enum xenbus_state backend_state) { +struct xen_drm_front_info *front_info =dev_get_drvdata (&xb_dev->dev); +int ret; + +DRM_DEBUG ("Backend state is %s, front is %s\n" , +xenbus_strstate (backend_state), +xenbus_strstate (xb_dev->state)); + +switch (backend_state) { +case XenbusStateReconfiguring: +/* fall through */ +case XenbusStateReconfigured: +/* fall through */ +case XenbusStateInitialised: +break ; + +case XenbusStateInitialising: +/* recovering after backend unexpected closure */ +displback_disconnect (front_info); +break ; + +case XenbusStateInitWait: +/* recovering after backend unexpected closure */ +displback_disconnect (front_info); +if (xb_dev->state != XenbusStateInitialising) +break ; + + ret =displback_initwait (front_info); +if (ret <0 ) +xenbus_dev_fatal (xb_dev, ret, +"initializing frontend" ); +else +xenbus_switch_state (xb_dev, XenbusStateInitialised); +break ; + +case XenbusStateConnected: +if (xb_dev->state != XenbusStateInitialised) +break ; + + ret =displback_connect (front_info); +if (ret <0 ) +xenbus_dev_fatal (xb_dev, ret, +"initializing DRM driver" ); +else +xenbus_switch_state (xb_dev, XenbusStateConnected); +break ; + +case XenbusStateClosing: +/* +* in this state backend starts freeing resources, +* so let it go into closed state, so we can also +* remove ours +*/ +break ; + +case XenbusStateUnknown: +/* fall through */ +case XenbusStateClosed: +if (xb_dev->state == XenbusStateClosed) +break ; + +displback_disconnect (front_info); +break ; + } }static int xen_drv_probe (struct xenbus_device *xb_dev,const struct xenbus_device_id *id) { -return 0 ; +struct xen_drm_front_info *front_info; + + front_info =devm_kzalloc (&xb_dev->dev, +sizeof (*front_info),GFP_KERNEL ); +if (!front_info) +return -ENOMEM ; + + front_info->xb_dev = xb_dev; +dev_set_drvdata (&xb_dev->dev, front_info); +return xenbus_switch_state (xb_dev, XenbusStateInitialising); }static int xen_drv_remove (struct xenbus_device *dev) { +struct xen_drm_front_info *front_info =dev_get_drvdata (&dev->dev); +int to =100 ; + +xenbus_switch_state (dev, XenbusStateClosing); + +/* +* On driver removal it is disconnected from XenBus, +* so no backend state change events come via .otherend_changed +* callback. This prevents us from exiting gracefully, e.g. +* signaling the backend to free event channels, waiting for its +* state to change to XenbusStateClosed and cleaning at our end. +* Normally when front driver removed backend will finally go into +* XenbusStateInitWait state. +* +* Workaround: read backend's state manually and wait with time-out. +*/ +while ((xenbus_read_unsigned (front_info->xb_dev->otherend, +"state" , XenbusStateUnknown) != XenbusStateInitWait) && + to--) +msleep (10 ); + +if (!to) +DRM_ERROR ("Backend state is %s while removing driver\n" , +xenbus_strstate (xenbus_read_unsigned ( + front_info->xb_dev->otherend, +"state" , XenbusStateUnknown))); + +xen_drv_remove_internal (front_info); +xenbus_frontend_closed (dev);return 0 ; }
drivers/gpu/drm/xen/xen_drm_front.h new file +18 -0
@@ -0,0 +1,18 @@ +/* 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_H_ +#define __XEN_DRM_FRONT_H_ + +struct xen_drm_front_info { +struct xenbus_device *xb_dev; +}; + +#endif /* __XEN_DRM_FRONT_H_ */
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 2/8 drm/xen-front: Implement Xen bus state handling
In reply to Oleksandr AndrushchenkoFrom: Oleksandr Andrushchenko <[email protected]>
Initial handling for Xen bus states: 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.
--- drivers/gpu/drm/xen/xen_drm_front.c | 124 +++++++++++++++++++++++++++++++++++- drivers/gpu/drm/xen/xen_drm_front.h | 18 ++++++ 2 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/xen/xen_drm_front.h
drivers/gpu/drm/xen/xen_drm_front.c +123 -1
@@ -16,19 +16,141 @@#include <xen/interface/io/displif.h> +#include "xen_drm_front.h" + +static void xen_drv_remove_internal (struct xen_drm_front_info *front_info) +{ +} + +static int displback_initwait (struct xen_drm_front_info *front_info) +{ +return 0 ; +} + +static int displback_connect (struct xen_drm_front_info *front_info) +{ +return 0 ; +} + +static void displback_disconnect (struct xen_drm_front_info *front_info) +{ +xenbus_switch_state (front_info->xb_dev, XenbusStateInitialising); +} +static void displback_changed (struct xenbus_device *xb_dev,enum xenbus_state backend_state) { +struct xen_drm_front_info *front_info =dev_get_drvdata (&xb_dev->dev); +int ret; + +DRM_DEBUG ("Backend state is %s, front is %s\n" , +xenbus_strstate (backend_state), +xenbus_strstate (xb_dev->state)); + +switch (backend_state) { +case XenbusStateReconfiguring: +/* fall through */ +case XenbusStateReconfigured: +/* fall through */ +case XenbusStateInitialised: +break ; + +case XenbusStateInitialising: +/* recovering after backend unexpected closure */ +displback_disconnect (front_info); +break ; + +case XenbusStateInitWait: +/* recovering after backend unexpected closure */ +displback_disconnect (front_info); +if (xb_dev->state != XenbusStateInitialising) +break ; + + ret =displback_initwait (front_info); +if (ret <0 ) +xenbus_dev_fatal (xb_dev, ret, +"initializing frontend" ); +else +xenbus_switch_state (xb_dev, XenbusStateInitialised); +break ; + +case XenbusStateConnected: +if (xb_dev->state != XenbusStateInitialised) +break ; + + ret =displback_connect (front_info); +if (ret <0 ) +xenbus_dev_fatal (xb_dev, ret, +"initializing DRM driver" ); +else +xenbus_switch_state (xb_dev, XenbusStateConnected); +break ; + +case XenbusStateClosing: +/* +* in this state backend starts freeing resources, +* so let it go into closed state, so we can also +* remove ours +*/ +break ; + +case XenbusStateUnknown: +/* fall through */ +case XenbusStateClosed: +if (xb_dev->state == XenbusStateClosed) +break ; + +displback_disconnect (front_info); +break ; + } }static int xen_drv_probe (struct xenbus_device *xb_dev,const struct xenbus_device_id *id) { -return 0 ; +struct xen_drm_front_info *front_info; + + front_info =devm_kzalloc (&xb_dev->dev, +sizeof (*front_info),GFP_KERNEL ); +if (!front_info) +return -ENOMEM ; + + front_info->xb_dev = xb_dev; +dev_set_drvdata (&xb_dev->dev, front_info); +return xenbus_switch_state (xb_dev, XenbusStateInitialising); }static int xen_drv_remove (struct xenbus_device *dev) { +struct xen_drm_front_info *front_info =dev_get_drvdata (&dev->dev); +int to =100 ; + +xenbus_switch_state (dev, XenbusStateClosing); + +/* +* On driver removal it is disconnected from XenBus, +* so no backend state change events come via .otherend_changed +* callback. This prevents us from exiting gracefully, e.g. +* signaling the backend to free event channels, waiting for its +* state to change to XenbusStateClosed and cleaning at our end. +* Normally when front driver removed backend will finally go into +* XenbusStateInitWait state. +* +* Workaround: read backend's state manually and wait with time-out. +*/ +while ((xenbus_read_unsigned (front_info->xb_dev->otherend, +"state" , XenbusStateUnknown) != XenbusStateInitWait) && + to--) +msleep (10 ); + +if (!to) +DRM_ERROR ("Backend state is %s while removing driver\n" , +xenbus_strstate (xenbus_read_unsigned ( + front_info->xb_dev->otherend, +"state" , XenbusStateUnknown))); + +xen_drv_remove_internal (front_info); +xenbus_frontend_closed (dev);return 0 ; }
drivers/gpu/drm/xen/xen_drm_front.h new file +18 -0
@@ -0,0 +1,18 @@ +/* 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_H_ +#define __XEN_DRM_FRONT_H_ + +struct xen_drm_front_info { +struct xenbus_device *xb_dev; +}; + +#endif /* __XEN_DRM_FRONT_H_ */
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 3/8 drm/xen-front: Read driver configuration from Xen store
In reply to Oleksandr AndrushchenkoFrom: Oleksandr Andrushchenko <[email protected]>
Read configuration values from Xen store according to xen/interface/io/displif.h protocol:
- read connector(s) configuration
- read buffer allocation mode (backend/frontend)
--- drivers/gpu/drm/xen/Makefile | 3 +- drivers/gpu/drm/xen/xen_drm_front.c | 9 ++++ drivers/gpu/drm/xen/xen_drm_front.h | 3 ++ drivers/gpu/drm/xen/xen_drm_front_cfg.c | 77 +++++++++++++++++++++++++++++++++ drivers/gpu/drm/xen/xen_drm_front_cfg.h | 37 ++++++++++++++++ 5 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/xen/xen_drm_front_cfg.c create mode 100644 drivers/gpu/drm/xen/xen_drm_front_cfg.h
drivers/gpu/drm/xen/Makefile +2 -1
@@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 OR MIT -drm_xen_front-objs := xen_drm_front.o +drm_xen_front-objs := xen_drm_front.o \ + xen_drm_front_cfg.o obj-$(CONFIG_DRM_XEN_FRONTEND) += drm_xen_front.o
drivers/gpu/drm/xen/xen_drm_front.c +9 -0
@@ -24,6 +24,15 @@ static void xen_drv_remove_internal(struct xen_drm_front_info *front_info)static int displback_initwait (struct xen_drm_front_info *front_info) { +struct xen_drm_front_cfg *cfg = &front_info->cfg; +int ret; + + cfg->front_info = front_info; + ret =xen_drm_front_cfg_card (front_info, cfg); +if (ret <0 ) +return ret; + +DRM_INFO ("Have %d conector(s)\n" , cfg->num_connectors);return 0 ; }
drivers/gpu/drm/xen/xen_drm_front.h +3 -0
@@ -11,8 +11,11 @@#ifndef __XEN_DRM_FRONT_H_#define __XEN_DRM_FRONT_H_ +#include "xen_drm_front_cfg.h" +struct xen_drm_front_info {struct xenbus_device *xb_dev; +struct xen_drm_front_cfg cfg; };#endif /* __XEN_DRM_FRONT_H_ */
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
@@ -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_ */
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 3/8 drm/xen-front: Read driver configuration from Xen store
In reply to Oleksandr AndrushchenkoFrom: Oleksandr Andrushchenko <[email protected]>
Read configuration values from Xen store according to xen/interface/io/displif.h protocol:
- read connector(s) configuration
- read buffer allocation mode (backend/frontend)
--- drivers/gpu/drm/xen/Makefile | 3 +- drivers/gpu/drm/xen/xen_drm_front.c | 9 ++++ drivers/gpu/drm/xen/xen_drm_front.h | 3 ++ drivers/gpu/drm/xen/xen_drm_front_cfg.c | 77 +++++++++++++++++++++++++++++++++ drivers/gpu/drm/xen/xen_drm_front_cfg.h | 37 ++++++++++++++++ 5 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/xen/xen_drm_front_cfg.c create mode 100644 drivers/gpu/drm/xen/xen_drm_front_cfg.h
drivers/gpu/drm/xen/Makefile +2 -1
@@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 OR MIT -drm_xen_front-objs := xen_drm_front.o +drm_xen_front-objs := xen_drm_front.o \ + xen_drm_front_cfg.o obj-$(CONFIG_DRM_XEN_FRONTEND) += drm_xen_front.o
drivers/gpu/drm/xen/xen_drm_front.c +9 -0
@@ -24,6 +24,15 @@ static void xen_drv_remove_internal(struct xen_drm_front_info *front_info)static int displback_initwait (struct xen_drm_front_info *front_info) { +struct xen_drm_front_cfg *cfg = &front_info->cfg; +int ret; + + cfg->front_info = front_info; + ret =xen_drm_front_cfg_card (front_info, cfg); +if (ret <0 ) +return ret; + +DRM_INFO ("Have %d conector(s)\n" , cfg->num_connectors);return 0 ; }
drivers/gpu/drm/xen/xen_drm_front.h +3 -0
@@ -11,8 +11,11 @@#ifndef __XEN_DRM_FRONT_H_#define __XEN_DRM_FRONT_H_ +#include "xen_drm_front_cfg.h" +struct xen_drm_front_info {struct xenbus_device *xb_dev; +struct xen_drm_front_cfg cfg; };#endif /* __XEN_DRM_FRONT_H_ */
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
@@ -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_ */
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 4/8 drm/xen-front: Implement Xen event channel handling
In reply to Oleksandr AndrushchenkoFrom: Oleksandr Andrushchenko <[email protected]>
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
--- drivers/gpu/drm/xen/Makefile | 1 + drivers/gpu/drm/xen/xen_drm_front.c | 12 +- drivers/gpu/drm/xen/xen_drm_front.h | 16 ++ drivers/gpu/drm/xen/xen_drm_front_evtchnl.c | 381 ++++++++++++++++++++++++++++ drivers/gpu/drm/xen/xen_drm_front_evtchnl.h | 79 ++++++ 5 files changed, 488 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/xen/xen_drm_front_evtchnl.c create mode 100644 drivers/gpu/drm/xen/xen_drm_front_evtchnl.h
drivers/gpu/drm/xen/Makefile +1 -0
@@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 OR MIT drm_xen_front-objs := xen_drm_front.o \ + xen_drm_front_evtchnl.o \ xen_drm_front_cfg.o obj-$(CONFIG_DRM_XEN_FRONTEND) += drm_xen_front.o
drivers/gpu/drm/xen/xen_drm_front.c +11 -1
@@ -17,9 +17,11 @@#include <xen/interface/io/displif.h> #include "xen_drm_front.h" +#include "xen_drm_front_evtchnl.h" static void xen_drv_remove_internal (struct xen_drm_front_info *front_info) { +xen_drm_front_evtchnl_free_all (front_info); }static int displback_initwait (struct xen_drm_front_info *front_info)
@@ -33,16 +35,23 @@ static int displback_initwait(struct xen_drm_front_info *front_info)return ret;DRM_INFO ("Have %d conector(s)\n" , cfg->num_connectors); -return 0 ; +/* Create event channels for all connectors and publish */ + ret =xen_drm_front_evtchnl_create_all (front_info); +if (ret <0 ) +return ret; + +return xen_drm_front_evtchnl_publish_all (front_info); }static int displback_connect (struct xen_drm_front_info *front_info) { +xen_drm_front_evtchnl_set_state (front_info,EVTCHNL_STATE_CONNECTED );return 0 ; }static void displback_disconnect (struct xen_drm_front_info *front_info) { +xen_drm_front_evtchnl_set_state (front_info,EVTCHNL_STATE_DISCONNECTED );xenbus_switch_state (front_info->xb_dev, XenbusStateInitialising); }
@@ -125,6 +134,7 @@ static int xen_drv_probe(struct xenbus_device *xb_dev,return -ENOMEM ; front_info->xb_dev = xb_dev; +spin_lock_init (&front_info->io_lock);dev_set_drvdata (&xb_dev->dev, front_info);return xenbus_switch_state (xb_dev, XenbusStateInitialising); }
drivers/gpu/drm/xen/xen_drm_front.h +16 -0
@@ -13,8 +13,24 @@#include "xen_drm_front_cfg.h" +#ifndef GRANT_INVALID_REF +/* +* Note on usage of grant reference 0 as invalid grant reference: +* grant reference 0 is valid, but never exposed to a PV driver, +* because of the fact it is already in use/reserved by the PV console. +*/ +#define GRANT_INVALID_REF 0 +#endif +struct xen_drm_front_info {struct xenbus_device *xb_dev; +/* to protect data between backend IO code and interrupt handler */ +spinlock_t io_lock; +/* virtual DRM platform device */ +struct platform_device *drm_pdev; + +int num_evt_pairs; +struct xen_drm_front_evtchnl_pair *evt_pairs;struct xen_drm_front_cfg cfg; };
drivers/gpu/drm/xen/xen_drm_front_evtchnl.c new file +381 -0
381 lines not on this page · raw message
drivers/gpu/drm/xen/xen_drm_front_evtchnl.h new file +79 -0
79 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 4/8 drm/xen-front: Implement Xen event channel handling
In reply to Oleksandr AndrushchenkoFrom: Oleksandr Andrushchenko <[email protected]>
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
--- drivers/gpu/drm/xen/Makefile | 1 + drivers/gpu/drm/xen/xen_drm_front.c | 12 +- drivers/gpu/drm/xen/xen_drm_front.h | 16 ++ drivers/gpu/drm/xen/xen_drm_front_evtchnl.c | 381 ++++++++++++++++++++++++++++ drivers/gpu/drm/xen/xen_drm_front_evtchnl.h | 79 ++++++ 5 files changed, 488 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/xen/xen_drm_front_evtchnl.c create mode 100644 drivers/gpu/drm/xen/xen_drm_front_evtchnl.h
drivers/gpu/drm/xen/Makefile +1 -0
@@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 OR MIT drm_xen_front-objs := xen_drm_front.o \ + xen_drm_front_evtchnl.o \ xen_drm_front_cfg.o obj-$(CONFIG_DRM_XEN_FRONTEND) += drm_xen_front.o
drivers/gpu/drm/xen/xen_drm_front.c +11 -1
@@ -17,9 +17,11 @@#include <xen/interface/io/displif.h> #include "xen_drm_front.h" +#include "xen_drm_front_evtchnl.h" static void xen_drv_remove_internal (struct xen_drm_front_info *front_info) { +xen_drm_front_evtchnl_free_all (front_info); }static int displback_initwait (struct xen_drm_front_info *front_info)
@@ -33,16 +35,23 @@ static int displback_initwait(struct xen_drm_front_info *front_info)return ret;DRM_INFO ("Have %d conector(s)\n" , cfg->num_connectors); -return 0 ; +/* Create event channels for all connectors and publish */ + ret =xen_drm_front_evtchnl_create_all (front_info); +if (ret <0 ) +return ret; + +return xen_drm_front_evtchnl_publish_all (front_info); }static int displback_connect (struct xen_drm_front_info *front_info) { +xen_drm_front_evtchnl_set_state (front_info,EVTCHNL_STATE_CONNECTED );return 0 ; }static void displback_disconnect (struct xen_drm_front_info *front_info) { +xen_drm_front_evtchnl_set_state (front_info,EVTCHNL_STATE_DISCONNECTED );xenbus_switch_state (front_info->xb_dev, XenbusStateInitialising); }
@@ -125,6 +134,7 @@ static int xen_drv_probe(struct xenbus_device *xb_dev,return -ENOMEM ; front_info->xb_dev = xb_dev; +spin_lock_init (&front_info->io_lock);dev_set_drvdata (&xb_dev->dev, front_info);return xenbus_switch_state (xb_dev, XenbusStateInitialising); }
drivers/gpu/drm/xen/xen_drm_front.h +16 -0
@@ -13,8 +13,24 @@#include "xen_drm_front_cfg.h" +#ifndef GRANT_INVALID_REF +/* +* Note on usage of grant reference 0 as invalid grant reference: +* grant reference 0 is valid, but never exposed to a PV driver, +* because of the fact it is already in use/reserved by the PV console. +*/ +#define GRANT_INVALID_REF 0 +#endif +struct xen_drm_front_info {struct xenbus_device *xb_dev; +/* to protect data between backend IO code and interrupt handler */ +spinlock_t io_lock; +/* virtual DRM platform device */ +struct platform_device *drm_pdev; + +int num_evt_pairs; +struct xen_drm_front_evtchnl_pair *evt_pairs;struct xen_drm_front_cfg cfg; };
drivers/gpu/drm/xen/xen_drm_front_evtchnl.c new file +381 -0
381 lines not on this page · raw message
drivers/gpu/drm/xen/xen_drm_front_evtchnl.h new file +79 -0
79 lines not on this page · raw message
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 5/8 drm/xen-front: Implement handling of shared display buffers
In reply to Oleksandr AndrushchenkoFrom: Oleksandr Andrushchenko <[email protected]>
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)
--- drivers/gpu/drm/xen/Makefile | 1 + drivers/gpu/drm/xen/xen_drm_front.c | 8 + drivers/gpu/drm/xen/xen_drm_front_shbuf.c | 432 ++++++++++++++++++++++++++++++ drivers/gpu/drm/xen/xen_drm_front_shbuf.h | 72 +++++ 4 files changed, 513 insertions(+) create mode 100644 drivers/gpu/drm/xen/xen_drm_front_shbuf.c create mode 100644 drivers/gpu/drm/xen/xen_drm_front_shbuf.h
drivers/gpu/drm/xen/Makefile +1 -0
@@ -2,6 +2,7 @@ drm_xen_front-objs := xen_drm_front.o \ xen_drm_front_evtchnl.o \ + xen_drm_front_shbuf.o \ xen_drm_front_cfg.o obj-$(CONFIG_DRM_XEN_FRONTEND) += drm_xen_front.o
drivers/gpu/drm/xen/xen_drm_front.c +8 -0
@@ -18,6 +18,7 @@#include "xen_drm_front.h" #include "xen_drm_front_evtchnl.h" +#include "xen_drm_front_shbuf.h" static void xen_drv_remove_internal (struct xen_drm_front_info *front_info) {
@@ -187,6 +188,13 @@ static struct xenbus_driver xen_driver = {static int __init xen_drv_init (void ) { +/* At the moment we only support case with XEN_PAGE_SIZE == PAGE_SIZE */ +if (XEN_PAGE_SIZE !=PAGE_SIZE ) { +DRM_ERROR (XENDISPL_DRIVER_NAME ": different kernel and Xen page sizes are not supported: XEN_PAGE_SIZE (%lu) != PAGE_SIZE (%lu)\n" , +XEN_PAGE_SIZE ,PAGE_SIZE ); +return -ENODEV ; + } +if (!xen_domain ())return -ENODEV ;
drivers/gpu/drm/xen/xen_drm_front_shbuf.c new file +432 -0
432 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
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 5/8 drm/xen-front: Implement handling of shared display buffers
In reply to Oleksandr AndrushchenkoFrom: Oleksandr Andrushchenko <[email protected]>
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)
--- drivers/gpu/drm/xen/Makefile | 1 + drivers/gpu/drm/xen/xen_drm_front.c | 8 + drivers/gpu/drm/xen/xen_drm_front_shbuf.c | 432 ++++++++++++++++++++++++++++++ drivers/gpu/drm/xen/xen_drm_front_shbuf.h | 72 +++++ 4 files changed, 513 insertions(+) create mode 100644 drivers/gpu/drm/xen/xen_drm_front_shbuf.c create mode 100644 drivers/gpu/drm/xen/xen_drm_front_shbuf.h
drivers/gpu/drm/xen/Makefile +1 -0
@@ -2,6 +2,7 @@ drm_xen_front-objs := xen_drm_front.o \ xen_drm_front_evtchnl.o \ + xen_drm_front_shbuf.o \ xen_drm_front_cfg.o obj-$(CONFIG_DRM_XEN_FRONTEND) += drm_xen_front.o
drivers/gpu/drm/xen/xen_drm_front.c +8 -0
@@ -18,6 +18,7 @@#include "xen_drm_front.h" #include "xen_drm_front_evtchnl.h" +#include "xen_drm_front_shbuf.h" static void xen_drv_remove_internal (struct xen_drm_front_info *front_info) {
@@ -187,6 +188,13 @@ static struct xenbus_driver xen_driver = {static int __init xen_drv_init (void ) { +/* At the moment we only support case with XEN_PAGE_SIZE == PAGE_SIZE */ +if (XEN_PAGE_SIZE !=PAGE_SIZE ) { +DRM_ERROR (XENDISPL_DRIVER_NAME ": different kernel and Xen page sizes are not supported: XEN_PAGE_SIZE (%lu) != PAGE_SIZE (%lu)\n" , +XEN_PAGE_SIZE ,PAGE_SIZE ); +return -ENODEV ; + } +if (!xen_domain ())return -ENODEV ;
drivers/gpu/drm/xen/xen_drm_front_shbuf.c new file +432 -0
432 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
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 6/8 drm/xen-front: Introduce DRM/KMS virtual display driver
In reply to Oleksandr AndrushchenkoFrom: Oleksandr Andrushchenko <[email protected]>
Implement essential initialization of the display driver:
- introduce required data structures
- handle DRM/KMS driver registration
- register driver on backend connection
- remove driver on backend disconnect
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
--- drivers/gpu/drm/xen/Makefile | 3 + drivers/gpu/drm/xen/xen_drm_front.c | 161 +++++++++++++++- drivers/gpu/drm/xen/xen_drm_front.h | 32 ++++ drivers/gpu/drm/xen/xen_drm_front_conn.c | 119 ++++++++++++ drivers/gpu/drm/xen/xen_drm_front_conn.h | 27 +++ drivers/gpu/drm/xen/xen_drm_front_drv.c | 171 +++++++++++++++++ drivers/gpu/drm/xen/xen_drm_front_drv.h | 65 +++++++ drivers/gpu/drm/xen/xen_drm_front_evtchnl.c | 4 +- drivers/gpu/drm/xen/xen_drm_front_kms.c | 282 ++++++++++++++++++++++++++++ drivers/gpu/drm/xen/xen_drm_front_kms.h | 22 +++ 10 files changed, 883 insertions(+), 3 deletions(-) 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_drv.c create mode 100644 drivers/gpu/drm/xen/xen_drm_front_drv.h create mode 100644 drivers/gpu/drm/xen/xen_drm_front_kms.c create mode 100644 drivers/gpu/drm/xen/xen_drm_front_kms.h
drivers/gpu/drm/xen/Makefile +3 -0
@@ -1,6 +1,9 @@ # SPDX-License-Identifier: GPL-2.0 OR MIT drm_xen_front-objs := xen_drm_front.o \ + xen_drm_front_drv.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
drivers/gpu/drm/xen/xen_drm_front.c +159 -2
195 lines not on this page · raw message
drivers/gpu/drm/xen/xen_drm_front.h +32 -0
@@ -11,6 +11,8 @@#ifndef __XEN_DRM_FRONT_H_#define __XEN_DRM_FRONT_H_ +#include <linux/scatterlist.h> +#include "xen_drm_front_cfg.h" #ifndef GRANT_INVALID_REF
@@ -22,10 +24,13 @@#define GRANT_INVALID_REF 0#endif +struct xen_drm_front_drm_pipeline ; +struct xen_drm_front_info {struct xenbus_device *xb_dev;/* to protect data between backend IO code and interrupt handler */ spinlock_t io_lock; +bool drm_pdrv_registered;/* virtual DRM platform device */ struct platform_device *drm_pdev;
@@ -34,4 +39,31 @@ struct xen_drm_front_info {struct xen_drm_front_cfg cfg; }; +int xen_drm_front_mode_set (struct xen_drm_front_drm_pipeline *pipeline, +uint32_t x,uint32_t y,uint32_t width,uint32_t height, +uint32_t bpp,uint64_t fb_cookie); + +int xen_drm_front_dbuf_create_from_sgt (struct xen_drm_front_info *front_info, +uint64_t dbuf_cookie,uint32_t width,uint32_t height, +uint32_t bpp,uint64_t size,struct sg_table *sgt); + +int xen_drm_front_dbuf_create_from_pages (struct xen_drm_front_info *front_info, +uint64_t dbuf_cookie,uint32_t width,uint32_t height, +uint32_t bpp,uint64_t size,struct page **pages); + +int xen_drm_front_dbuf_destroy (struct xen_drm_front_info *front_info, +uint64_t dbuf_cookie); + +int xen_drm_front_fb_attach (struct xen_drm_front_info *front_info, +uint64_t dbuf_cookie,uint64_t fb_cookie,uint32_t width, +uint32_t height,uint32_t pixel_format); + +int xen_drm_front_fb_detach (struct xen_drm_front_info *front_info, +uint64_t fb_cookie); + +int xen_drm_front_page_flip (struct xen_drm_front_info *front_info, +int conn_idx,uint64_t fb_cookie); + +void xen_drm_front_unload (struct xen_drm_front_info *front_info); +#endif /* __XEN_DRM_FRONT_H_ */
drivers/gpu/drm/xen/xen_drm_front_conn.c new file +119 -0
119 lines not on this page · raw message
drivers/gpu/drm/xen/xen_drm_front_conn.h new file +27 -0
@@ -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_drv.c new file +171 -0
171 lines not on this page · raw message
drivers/gpu/drm/xen/xen_drm_front_drv.h new file +65 -0
65 lines not on this page · raw message
drivers/gpu/drm/xen/xen_drm_front_evtchnl.c +3 -1
@@ -18,6 +18,7 @@#include <xen/grant_table.h> #include "xen_drm_front.h" +#include "xen_drm_front_drv.h" #include "xen_drm_front_evtchnl.h" static irqreturn_t evtchnl_interrupt_ctrl (int irq,void *dev_id)
@@ -105,7 +106,8 @@ static irqreturn_t evtchnl_interrupt_evt(int irq, void *dev_id)switch (event->type) {case XENDISPL_EVT_PG_FLIP : -/* placeholder */ +xen_drm_front_on_frame_done (front_info->drm_pdev, + evtchnl->index, event->op.pg_flip.fb_cookie);break ; } }
drivers/gpu/drm/xen/xen_drm_front_kms.c new file +282 -0
282 lines not on this page · raw message
drivers/gpu/drm/xen/xen_drm_front_kms.h new file +22 -0
@@ -0,0 +1,22 @@ +/* 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 "xen_drm_front_drv.h" + +int xen_drm_front_kms_init (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_ */
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 6/8 drm/xen-front: Introduce DRM/KMS virtual display driver
In reply to Oleksandr AndrushchenkoFrom: Oleksandr Andrushchenko <[email protected]>
Implement essential initialization of the display driver:
- introduce required data structures
- handle DRM/KMS driver registration
- register driver on backend connection
- remove driver on backend disconnect
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
--- drivers/gpu/drm/xen/Makefile | 3 + drivers/gpu/drm/xen/xen_drm_front.c | 161 +++++++++++++++- drivers/gpu/drm/xen/xen_drm_front.h | 32 ++++ drivers/gpu/drm/xen/xen_drm_front_conn.c | 119 ++++++++++++ drivers/gpu/drm/xen/xen_drm_front_conn.h | 27 +++ drivers/gpu/drm/xen/xen_drm_front_drv.c | 171 +++++++++++++++++ drivers/gpu/drm/xen/xen_drm_front_drv.h | 65 +++++++ drivers/gpu/drm/xen/xen_drm_front_evtchnl.c | 4 +- drivers/gpu/drm/xen/xen_drm_front_kms.c | 282 ++++++++++++++++++++++++++++ drivers/gpu/drm/xen/xen_drm_front_kms.h | 22 +++ 10 files changed, 883 insertions(+), 3 deletions(-) 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_drv.c create mode 100644 drivers/gpu/drm/xen/xen_drm_front_drv.h create mode 100644 drivers/gpu/drm/xen/xen_drm_front_kms.c create mode 100644 drivers/gpu/drm/xen/xen_drm_front_kms.h
drivers/gpu/drm/xen/Makefile +3 -0
@@ -1,6 +1,9 @@ # SPDX-License-Identifier: GPL-2.0 OR MIT drm_xen_front-objs := xen_drm_front.o \ + xen_drm_front_drv.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
drivers/gpu/drm/xen/xen_drm_front.c +159 -2
195 lines not on this page · raw message
drivers/gpu/drm/xen/xen_drm_front.h +32 -0
@@ -11,6 +11,8 @@#ifndef __XEN_DRM_FRONT_H_#define __XEN_DRM_FRONT_H_ +#include <linux/scatterlist.h> +#include "xen_drm_front_cfg.h" #ifndef GRANT_INVALID_REF
@@ -22,10 +24,13 @@#define GRANT_INVALID_REF 0#endif +struct xen_drm_front_drm_pipeline ; +struct xen_drm_front_info {struct xenbus_device *xb_dev;/* to protect data between backend IO code and interrupt handler */ spinlock_t io_lock; +bool drm_pdrv_registered;/* virtual DRM platform device */ struct platform_device *drm_pdev;
@@ -34,4 +39,31 @@ struct xen_drm_front_info {struct xen_drm_front_cfg cfg; }; +int xen_drm_front_mode_set (struct xen_drm_front_drm_pipeline *pipeline, +uint32_t x,uint32_t y,uint32_t width,uint32_t height, +uint32_t bpp,uint64_t fb_cookie); + +int xen_drm_front_dbuf_create_from_sgt (struct xen_drm_front_info *front_info, +uint64_t dbuf_cookie,uint32_t width,uint32_t height, +uint32_t bpp,uint64_t size,struct sg_table *sgt); + +int xen_drm_front_dbuf_create_from_pages (struct xen_drm_front_info *front_info, +uint64_t dbuf_cookie,uint32_t width,uint32_t height, +uint32_t bpp,uint64_t size,struct page **pages); + +int xen_drm_front_dbuf_destroy (struct xen_drm_front_info *front_info, +uint64_t dbuf_cookie); + +int xen_drm_front_fb_attach (struct xen_drm_front_info *front_info, +uint64_t dbuf_cookie,uint64_t fb_cookie,uint32_t width, +uint32_t height,uint32_t pixel_format); + +int xen_drm_front_fb_detach (struct xen_drm_front_info *front_info, +uint64_t fb_cookie); + +int xen_drm_front_page_flip (struct xen_drm_front_info *front_info, +int conn_idx,uint64_t fb_cookie); + +void xen_drm_front_unload (struct xen_drm_front_info *front_info); +#endif /* __XEN_DRM_FRONT_H_ */
drivers/gpu/drm/xen/xen_drm_front_conn.c new file +119 -0
119 lines not on this page · raw message
drivers/gpu/drm/xen/xen_drm_front_conn.h new file +27 -0
@@ -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_drv.c new file +171 -0
171 lines not on this page · raw message
drivers/gpu/drm/xen/xen_drm_front_drv.h new file +65 -0
65 lines not on this page · raw message
drivers/gpu/drm/xen/xen_drm_front_evtchnl.c +3 -1
@@ -18,6 +18,7 @@#include <xen/grant_table.h> #include "xen_drm_front.h" +#include "xen_drm_front_drv.h" #include "xen_drm_front_evtchnl.h" static irqreturn_t evtchnl_interrupt_ctrl (int irq,void *dev_id)
@@ -105,7 +106,8 @@ static irqreturn_t evtchnl_interrupt_evt(int irq, void *dev_id)switch (event->type) {case XENDISPL_EVT_PG_FLIP : -/* placeholder */ +xen_drm_front_on_frame_done (front_info->drm_pdev, + evtchnl->index, event->op.pg_flip.fb_cookie);break ; } }
drivers/gpu/drm/xen/xen_drm_front_kms.c new file +282 -0
282 lines not on this page · raw message
drivers/gpu/drm/xen/xen_drm_front_kms.h new file +22 -0
@@ -0,0 +1,22 @@ +/* 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 "xen_drm_front_drv.h" + +int xen_drm_front_kms_init (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_ */
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 8/8 drm/xen-front: Provide kernel documentation
In reply to Oleksandr AndrushchenkoFrom: Oleksandr Andrushchenko <[email protected]>
Provide kernel documentation for the Xen para-virtualized frontend DRM driver.
--- Documentation/gpu/index.rst | 1 + Documentation/gpu/xen-front.rst | 77 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 Documentation/gpu/xen-front.rst
Documentation/gpu/index.rst +1 -0
@@ -20,6 +20,7 @@ Linux GPU Driver Developer's Guide vga-switcheroo vgaarbiter bridge/dw-hdmi + xen-front todo .. only:: subproject and html
Documentation/gpu/xen-front.rst new file +77 -0
77 lines not on this page · raw message
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 7/8 drm/xen-front: Implement GEM operations and backend communication
In reply to Oleksandr AndrushchenkoFrom: Oleksandr Andrushchenko <[email protected]>
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.
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.
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.
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
--- drivers/gpu/drm/xen/Kconfig | 13 ++ drivers/gpu/drm/xen/Makefile | 6 + drivers/gpu/drm/xen/xen_drm_front.c | 324 ++++++++++++++++++++++++++- drivers/gpu/drm/xen/xen_drm_front.h | 8 + drivers/gpu/drm/xen/xen_drm_front_conn.c | 31 ++- drivers/gpu/drm/xen/xen_drm_front_drv.c | 70 +++++- drivers/gpu/drm/xen/xen_drm_front_drv.h | 13 ++ drivers/gpu/drm/xen/xen_drm_front_gem.c | 335 ++++++++++++++++++++++++++++ drivers/gpu/drm/xen/xen_drm_front_gem.h | 41 ++++ drivers/gpu/drm/xen/xen_drm_front_gem_cma.c | 74 ++++++ drivers/gpu/drm/xen/xen_drm_front_kms.c | 44 +++- drivers/gpu/drm/xen/xen_drm_front_kms.h | 3 + 12 files changed, 953 insertions(+), 9 deletions(-) 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
drivers/gpu/drm/xen/Kconfig +13 -0
@@ -15,3 +15,16 @@ config DRM_XEN_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 +6 -0
@@ -8,4 +8,10 @@ drm_xen_front-objs := xen_drm_front.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 +319 -5
375 lines not on this page · raw message
drivers/gpu/drm/xen/xen_drm_front.h +8 -0
@@ -15,6 +15,9 @@#include "xen_drm_front_cfg.h" +/* timeout in ms to wait for backend to respond */ +#define XEN_DRM_FRONT_WAIT_BACK_MS 3000 +#ifndef GRANT_INVALID_REF /* * Note on usage of grant reference 0 as invalid grant reference:
@@ -30,6 +33,8 @@ struct xen_drm_front_info {struct xenbus_device *xb_dev;/* to protect data between backend IO code and interrupt handler */ spinlock_t io_lock; +/* serializer for backend IO: request/response */ +struct mutex req_io_lock;bool drm_pdrv_registered;/* virtual DRM platform device */ struct platform_device *drm_pdev;
@@ -37,6 +42,9 @@ struct xen_drm_front_info {int num_evt_pairs;struct xen_drm_front_evtchnl_pair *evt_pairs;struct xen_drm_front_cfg cfg; + +/* display buffers */ +struct list_head dbuf_list; }; int xen_drm_front_mode_set(struct xen_drm_front_drm_pipeline *pipeline,
drivers/gpu/drm/xen/xen_drm_front_conn.c +29 -2
@@ -15,6 +15,7 @@#include "xen_drm_front_conn.h" #include "xen_drm_front_drv.h" +#include "xen_drm_front_kms.h" static struct xen_drm_front_drm_pipeline *to_xen_drm_pipeline (struct drm_connector *connector)
@@ -43,10 +44,28 @@ static int connector_detect(struct drm_connector *connector, struct drm_modeset_acquire_ctx *ctx, bool force) { +struct xen_drm_front_drm_pipeline *pipeline = +to_xen_drm_pipeline (connector); +struct xen_drm_front_info *front_info = pipeline->drm_info->front_info; +unsigned long flags; + +/* check if there is a frame done event time-out */ +spin_lock_irqsave (&front_info->io_lock, flags); +if (pipeline->pflip_timeout && +time_after_eq (jiffies, pipeline->pflip_timeout)) { +DRM_ERROR ("Frame done event timed-out\n" ); + + pipeline->pflip_timeout =0 ; + pipeline->conn_connected = false; +xen_drm_front_kms_send_pending_event (pipeline); + } +spin_unlock_irqrestore (&front_info->io_lock, flags); +if (drm_dev_is_unplugged (connector->dev)) - return connector_status_disconnected; + pipeline->conn_connected = false; -return connector_status_connected; +return pipeline->conn_connected ? connector_status_connected : + connector_status_disconnected; }#define XEN_DRM_NUM_VIDEO_MODES 1
@@ -112,8 +131,16 @@ static const struct drm_connector_funcs connector_funcs = {int xen_drm_front_conn_init (struct xen_drm_front_drm_info *drm_info,struct drm_connector *connector) { +struct xen_drm_front_drm_pipeline *pipeline = +to_xen_drm_pipeline (connector); +drm_connector_helper_add (connector, &connector_helper_funcs); + pipeline->conn_connected = true; + + connector->polled =DRM_CONNECTOR_POLL_CONNECT | +DRM_CONNECTOR_POLL_DISCONNECT ; +return drm_connector_init (drm_info->drm_dev, connector, &connector_funcs,DRM_MODE_CONNECTOR_VIRTUAL ); }
drivers/gpu/drm/xen/xen_drm_front_drv.c +69 -1
122 lines not on this page · raw message
drivers/gpu/drm/xen/xen_drm_front_drv.h +13 -0
@@ -30,6 +30,19 @@ struct xen_drm_front_drm_pipeline {int width, height;struct drm_pending_vblank_event *pending_event; + +/* +* pflip_timeout is set to current jiffies once we send a page flip and +* reset to 0 when we receive frame done event from the backed. +* It is checked during drm_connector_helper_funcs.detect_ctx to detect +* time-outs for frame done event, e.g. due to backend errors. +* +* This must be protected with front_info->io_lock, so races between +* interrupt handler and rest of the code are properly handled. +*/ +unsigned long pflip_timeout; + +bool conn_connected; };struct xen_drm_front_drm_info {
drivers/gpu/drm/xen/xen_drm_front_gem.c new file +335 -0
335 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 +74 -0
74 lines not on this page · raw message
drivers/gpu/drm/xen/xen_drm_front_kms.c +43 -1
112 lines not on this page · raw message
drivers/gpu/drm/xen/xen_drm_front_kms.h +3 -0
@@ -19,4 +19,7 @@ void xen_drm_front_kms_on_frame_done(struct xen_drm_front_drm_pipeline *pipeline, uint64_t fb_cookie); +void xen_drm_front_kms_send_pending_event ( +struct xen_drm_front_drm_pipeline *pipeline); +#endif /* __XEN_DRM_FRONT_KMS_H_ */
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel