linux/drivers/gpu/drm/xen/xen_drm_front.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0 OR MIT */
   2
   3/*
   4 *  Xen para-virtual DRM device
   5 *
   6 * Copyright (C) 2016-2018 EPAM Systems Inc.
   7 *
   8 * Author: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
   9 */
  10
  11#ifndef __XEN_DRM_FRONT_H_
  12#define __XEN_DRM_FRONT_H_
  13
  14#include <drm/drmP.h>
  15#include <drm/drm_simple_kms_helper.h>
  16
  17#include <linux/scatterlist.h>
  18
  19#include "xen_drm_front_cfg.h"
  20
  21/**
  22 * DOC: Driver modes of operation in terms of display buffers used
  23 *
  24 * Depending on the requirements for the para-virtualized environment, namely
  25 * requirements dictated by the accompanying DRM/(v)GPU drivers running in both
  26 * host and guest environments, display buffers can be allocated by either
  27 * frontend driver or backend.
  28 */
  29
  30/**
  31 * DOC: Buffers allocated by the frontend driver
  32 *
  33 * In this mode of operation driver allocates buffers from system memory.
  34 *
  35 * Note! If used with accompanying DRM/(v)GPU drivers this mode of operation
  36 * may require IOMMU support on the platform, so accompanying DRM/vGPU
  37 * hardware can still reach display buffer memory while importing PRIME
  38 * buffers from the frontend driver.
  39 */
  40
  41/**
  42 * DOC: Buffers allocated by the backend
  43 *
  44 * This mode of operation is run-time configured via guest domain configuration
  45 * through XenStore entries.
  46 *
  47 * For systems which do not provide IOMMU support, but having specific
  48 * requirements for display buffers it is possible to allocate such buffers
  49 * at backend side and share those with the frontend.
  50 * For example, if host domain is 1:1 mapped and has DRM/GPU hardware expecting
  51 * physically contiguous memory, this allows implementing zero-copying
  52 * use-cases.
  53 *
  54 * Note, while using this scenario the following should be considered:
  55 *
  56 * #. If guest domain dies then pages/grants received from the backend
  57 *    cannot be claimed back
  58 *
  59 * #. Misbehaving guest may send too many requests to the
  60 *    backend exhausting its grant references and memory
  61 *    (consider this from security POV)
  62 */
  63
  64/**
  65 * DOC: Driver limitations
  66 *
  67 * #. Only primary plane without additional properties is supported.
  68 *
  69 * #. Only one video mode per connector supported which is configured
  70 *    via XenStore.
  71 *
  72 * #. All CRTCs operate at fixed frequency of 60Hz.
  73 */
  74
  75/* timeout in ms to wait for backend to respond */
  76#define XEN_DRM_FRONT_WAIT_BACK_MS      3000
  77
  78#ifndef GRANT_INVALID_REF
  79/*
  80 * Note on usage of grant reference 0 as invalid grant reference:
  81 * grant reference 0 is valid, but never exposed to a PV driver,
  82 * because of the fact it is already in use/reserved by the PV console.
  83 */
  84#define GRANT_INVALID_REF       0
  85#endif
  86
  87struct xen_drm_front_info {
  88        struct xenbus_device *xb_dev;
  89        struct xen_drm_front_drm_info *drm_info;
  90
  91        /* to protect data between backend IO code and interrupt handler */
  92        spinlock_t io_lock;
  93
  94        int num_evt_pairs;
  95        struct xen_drm_front_evtchnl_pair *evt_pairs;
  96        struct xen_drm_front_cfg cfg;
  97
  98        /* display buffers */
  99        struct list_head dbuf_list;
 100};
 101
 102struct xen_drm_front_drm_pipeline {
 103        struct xen_drm_front_drm_info *drm_info;
 104
 105        int index;
 106
 107        struct drm_simple_display_pipe pipe;
 108
 109        struct drm_connector conn;
 110        /* These are only for connector mode checking */
 111        int width, height;
 112
 113        struct drm_pending_vblank_event *pending_event;
 114
 115        struct delayed_work pflip_to_worker;
 116
 117        bool conn_connected;
 118};
 119
 120struct xen_drm_front_drm_info {
 121        struct xen_drm_front_info *front_info;
 122        struct drm_device *drm_dev;
 123
 124        struct xen_drm_front_drm_pipeline pipeline[XEN_DRM_FRONT_MAX_CRTCS];
 125};
 126
 127static inline u64 xen_drm_front_fb_to_cookie(struct drm_framebuffer *fb)
 128{
 129        return (uintptr_t)fb;
 130}
 131
 132static inline u64 xen_drm_front_dbuf_to_cookie(struct drm_gem_object *gem_obj)
 133{
 134        return (uintptr_t)gem_obj;
 135}
 136
 137int xen_drm_front_mode_set(struct xen_drm_front_drm_pipeline *pipeline,
 138                           u32 x, u32 y, u32 width, u32 height,
 139                           u32 bpp, u64 fb_cookie);
 140
 141int xen_drm_front_dbuf_create(struct xen_drm_front_info *front_info,
 142                              u64 dbuf_cookie, u32 width, u32 height,
 143                              u32 bpp, u64 size, struct page **pages);
 144
 145int xen_drm_front_fb_attach(struct xen_drm_front_info *front_info,
 146                            u64 dbuf_cookie, u64 fb_cookie, u32 width,
 147                            u32 height, u32 pixel_format);
 148
 149int xen_drm_front_fb_detach(struct xen_drm_front_info *front_info,
 150                            u64 fb_cookie);
 151
 152int xen_drm_front_page_flip(struct xen_drm_front_info *front_info,
 153                            int conn_idx, u64 fb_cookie);
 154
 155void xen_drm_front_on_frame_done(struct xen_drm_front_info *front_info,
 156                                 int conn_idx, u64 fb_cookie);
 157
 158#endif /* __XEN_DRM_FRONT_H_ */
 159