2015-02-10 19:05:47 +08:00
|
|
|
/*
|
|
|
|
* Copyright(c) 2011-2015 Intel Corporation. All rights reserved.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
* Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _I915_VGPU_H_
|
|
|
|
#define _I915_VGPU_H_
|
|
|
|
|
|
|
|
/* The MMIO offset of the shared info between guest and host emulator */
|
|
|
|
#define VGT_PVINFO_PAGE 0x78000
|
|
|
|
#define VGT_PVINFO_SIZE 0x1000
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The following structure pages are defined in GEN MMIO space
|
|
|
|
* for virtualization. (One page for now)
|
|
|
|
*/
|
2015-03-11 15:27:25 +08:00
|
|
|
#define VGT_MAGIC 0x4776544776544776ULL /* 'vGTvGTvG' */
|
2015-02-10 19:05:47 +08:00
|
|
|
#define VGT_VERSION_MAJOR 1
|
|
|
|
#define VGT_VERSION_MINOR 0
|
|
|
|
|
|
|
|
#define INTEL_VGT_IF_VERSION_ENCODE(major, minor) ((major) << 16 | (minor))
|
|
|
|
#define INTEL_VGT_IF_VERSION \
|
|
|
|
INTEL_VGT_IF_VERSION_ENCODE(VGT_VERSION_MAJOR, VGT_VERSION_MINOR)
|
|
|
|
|
2015-08-28 15:41:17 +08:00
|
|
|
/*
|
|
|
|
* notifications from guest to vgpu device model
|
|
|
|
*/
|
|
|
|
enum vgt_g2v_type {
|
|
|
|
VGT_G2V_PPGTT_L3_PAGE_TABLE_CREATE = 2,
|
|
|
|
VGT_G2V_PPGTT_L3_PAGE_TABLE_DESTROY,
|
|
|
|
VGT_G2V_PPGTT_L4_PAGE_TABLE_CREATE,
|
|
|
|
VGT_G2V_PPGTT_L4_PAGE_TABLE_DESTROY,
|
|
|
|
VGT_G2V_EXECLIST_CONTEXT_CREATE,
|
|
|
|
VGT_G2V_EXECLIST_CONTEXT_DESTROY,
|
|
|
|
VGT_G2V_MAX,
|
|
|
|
};
|
|
|
|
|
2015-02-10 19:05:47 +08:00
|
|
|
struct vgt_if {
|
|
|
|
uint64_t magic; /* VGT_MAGIC */
|
|
|
|
uint16_t version_major;
|
|
|
|
uint16_t version_minor;
|
|
|
|
uint32_t vgt_id; /* ID of vGT instance */
|
|
|
|
uint32_t rsv1[12]; /* pad to offset 0x40 */
|
|
|
|
/*
|
|
|
|
* Data structure to describe the balooning info of resources.
|
|
|
|
* Each VM can only have one portion of continuous area for now.
|
|
|
|
* (May support scattered resource in future)
|
|
|
|
* (starting from offset 0x40)
|
|
|
|
*/
|
|
|
|
struct {
|
|
|
|
/* Aperture register balooning */
|
|
|
|
struct {
|
|
|
|
uint32_t base;
|
|
|
|
uint32_t size;
|
|
|
|
} mappable_gmadr; /* aperture */
|
|
|
|
/* GMADR register balooning */
|
|
|
|
struct {
|
|
|
|
uint32_t base;
|
|
|
|
uint32_t size;
|
|
|
|
} nonmappable_gmadr; /* non aperture */
|
|
|
|
/* allowed fence registers */
|
|
|
|
uint32_t fence_num;
|
|
|
|
uint32_t rsv2[3];
|
|
|
|
} avail_rs; /* available/assigned resource */
|
|
|
|
uint32_t rsv3[0x200 - 24]; /* pad to half page */
|
|
|
|
/*
|
|
|
|
* The bottom half page is for response from Gfx driver to hypervisor.
|
|
|
|
*/
|
|
|
|
uint32_t rsv4;
|
|
|
|
uint32_t display_ready; /* ready for display owner switch */
|
2015-08-28 15:41:17 +08:00
|
|
|
|
|
|
|
uint32_t rsv5[4];
|
|
|
|
|
|
|
|
uint32_t g2v_notify;
|
|
|
|
uint32_t rsv6[7];
|
|
|
|
|
2015-11-05 05:20:12 +08:00
|
|
|
struct {
|
|
|
|
uint32_t lo;
|
|
|
|
uint32_t hi;
|
|
|
|
} pdp[4];
|
2015-08-28 15:41:17 +08:00
|
|
|
|
|
|
|
uint32_t execlist_context_descriptor_lo;
|
|
|
|
uint32_t execlist_context_descriptor_hi;
|
|
|
|
|
|
|
|
uint32_t rsv7[0x200 - 24]; /* pad to one page */
|
2015-02-10 19:05:47 +08:00
|
|
|
} __packed;
|
|
|
|
|
|
|
|
#define vgtif_reg(x) \
|
drm/i915: Type safe register read/write
Make I915_READ and I915_WRITE more type safe by wrapping the register
offset in a struct. This should eliminate most of the fumbles we've had
with misplaced parens.
This only takes care of normal mmio registers. We could extend the idea
to other register types and define each with its own struct. That way
you wouldn't be able to accidentally pass the wrong thing to a specific
register access function.
The gpio_reg setup is probably the ugliest thing left. But I figure I'd
just leave it for now, and wait for some divine inspiration to strike
before making it nice.
As for the generated code, it's actually a bit better sometimes. Eg.
looking at i915_irq_handler(), we can see the following change:
lea 0x70024(%rdx,%rax,1),%r9d
mov $0x1,%edx
- movslq %r9d,%r9
- mov %r9,%rsi
- mov %r9,-0x58(%rbp)
- callq *0xd8(%rbx)
+ mov %r9d,%esi
+ mov %r9d,-0x48(%rbp)
callq *0xd8(%rbx)
So previously gcc thought the register offset might be signed and
decided to sign extend it, just in case. The rest appears to be
mostly just minor shuffling of instructions.
v2: i915_mmio_reg_{offset,equal,valid}() helpers added
s/_REG/_MMIO/ in the register defines
mo more switch statements left to worry about
ring_emit stuff got sorted in a prep patch
cmd parser, lrc context and w/a batch buildup also in prep patch
vgpu stuff cleaned up and moved to a prep patch
all other unrelated changes split out
v3: Rebased due to BXT DSI/BLC, MOCS, etc.
v4: Rebased due to churn, s/i915_mmio_reg_t/i915_reg_t/
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: http://patchwork.freedesktop.org/patch/msgid/1447853606-2751-1-git-send-email-ville.syrjala@linux.intel.com
2015-11-18 21:33:26 +08:00
|
|
|
_MMIO((VGT_PVINFO_PAGE + (long)&((struct vgt_if *)NULL)->x))
|
2015-02-10 19:05:47 +08:00
|
|
|
|
2015-02-10 19:05:51 +08:00
|
|
|
/* vGPU display status to be used by the host side */
|
|
|
|
#define VGT_DRV_DISPLAY_NOT_READY 0
|
|
|
|
#define VGT_DRV_DISPLAY_READY 1 /* ready for display switch */
|
|
|
|
|
2015-02-10 19:05:47 +08:00
|
|
|
extern void i915_check_vgpu(struct drm_device *dev);
|
2015-02-10 19:05:48 +08:00
|
|
|
extern int intel_vgt_balloon(struct drm_device *dev);
|
|
|
|
extern void intel_vgt_deballoon(void);
|
2015-02-10 19:05:47 +08:00
|
|
|
|
|
|
|
#endif /* _I915_VGPU_H_ */
|