Skip to content

Commit

Permalink
drm/i915/vgpu: improve vgpu abstractions
Browse files Browse the repository at this point in the history
Add intel_vgpu_register() abstraction, rename i915_detect_vgpu() to
intel_vgpu_detect() to match other function naming, un-inline
intel_vgpu_active(), intel_vgpu_has_full_ppgtt() and
intel_vgpu_has_huge_gtt() to reduce header interdependencies.

The i915_vgpu.[ch] filename and intel_vgpu_ prefix discrepancy remains.

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200227144408.24345-1-jani.nikula@intel.com
  • Loading branch information
Jani Nikula committed Mar 3, 2020
1 parent 3a4a32d commit 9e859eb
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 31 deletions.
1 change: 1 addition & 0 deletions drivers/gpu/drm/i915/display/intel_fbc.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

#include "i915_drv.h"
#include "i915_trace.h"
#include "i915_vgpu.h"
#include "intel_display_types.h"
#include "intel_fbc.h"
#include "intel_frontbuffer.h"
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/i915/display/intel_sprite.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

#include "i915_drv.h"
#include "i915_trace.h"
#include "i915_vgpu.h"
#include "intel_atomic_plane.h"
#include "intel_display_types.h"
#include "intel_frontbuffer.h"
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/i915/gem/i915_gem_stolen.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "gem/i915_gem_region.h"
#include "i915_drv.h"
#include "i915_gem_stolen.h"
#include "i915_vgpu.h"

/*
* The BIOS typically reserves some of the system's memory for the exclusive
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/i915/gt/gen8_ppgtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "gen8_ppgtt.h"
#include "i915_scatterlist.h"
#include "i915_trace.h"
#include "i915_pvinfo.h"
#include "i915_vgpu.h"
#include "intel_gt.h"
#include "intel_gtt.h"
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/i915/gt/intel_rc6.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <linux/pm_runtime.h>

#include "i915_drv.h"
#include "i915_vgpu.h"
#include "intel_gt.h"
#include "intel_gt_pm.h"
#include "intel_rc6.h"
Expand Down
10 changes: 2 additions & 8 deletions drivers/gpu/drm/i915/i915_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -759,13 +759,7 @@ static void i915_driver_register(struct drm_i915_private *dev_priv)
i915_gem_driver_register(dev_priv);
i915_pmu_register(dev_priv);

/*
* Notify a valid surface after modesetting,
* when running inside a VM.
*/
if (intel_vgpu_active(dev_priv))
intel_uncore_write(&dev_priv->uncore, vgtif_reg(display_ready),
VGT_DRV_DISPLAY_READY);
intel_vgpu_register(dev_priv);

/* Reveal our presence to userspace */
if (drm_dev_register(dev, 0) == 0) {
Expand Down Expand Up @@ -972,7 +966,7 @@ int i915_driver_probe(struct pci_dev *pdev, const struct pci_device_id *ent)

disable_rpm_wakeref_asserts(&i915->runtime_pm);

i915_detect_vgpu(i915);
intel_vgpu_detect(i915);

ret = i915_driver_mmio_probe(i915);
if (ret < 0)
Expand Down
5 changes: 0 additions & 5 deletions drivers/gpu/drm/i915/i915_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1677,11 +1677,6 @@ static inline bool intel_gvt_active(struct drm_i915_private *dev_priv)
return dev_priv->gvt;
}

static inline bool intel_vgpu_active(struct drm_i915_private *dev_priv)
{
return dev_priv->vgpu.active;
}

int i915_getparam_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);

Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/i915/i915_gem_fence_reg.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include "i915_drv.h"
#include "i915_scatterlist.h"
#include "i915_pvinfo.h"
#include "i915_vgpu.h"

/**
Expand Down
31 changes: 29 additions & 2 deletions drivers/gpu/drm/i915/i915_vgpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
* SOFTWARE.
*/

#include "i915_drv.h"
#include "i915_pvinfo.h"
#include "i915_vgpu.h"

/**
Expand Down Expand Up @@ -51,13 +53,13 @@
*/

/**
* i915_detect_vgpu - detect virtual GPU
* intel_vgpu_detect - detect virtual GPU
* @dev_priv: i915 device private
*
* This function is called at the initialization stage, to detect whether
* running on a vGPU.
*/
void i915_detect_vgpu(struct drm_i915_private *dev_priv)
void intel_vgpu_detect(struct drm_i915_private *dev_priv)
{
struct pci_dev *pdev = dev_priv->drm.pdev;
u64 magic;
Expand Down Expand Up @@ -102,11 +104,36 @@ void i915_detect_vgpu(struct drm_i915_private *dev_priv)
pci_iounmap(pdev, shared_area);
}

void intel_vgpu_register(struct drm_i915_private *i915)
{
/*
* Notify a valid surface after modesetting, when running inside a VM.
*/
if (intel_vgpu_active(i915))
intel_uncore_write(&i915->uncore, vgtif_reg(display_ready),
VGT_DRV_DISPLAY_READY);
}

bool intel_vgpu_active(struct drm_i915_private *dev_priv)
{
return dev_priv->vgpu.active;
}

bool intel_vgpu_has_full_ppgtt(struct drm_i915_private *dev_priv)
{
return dev_priv->vgpu.caps & VGT_CAPS_FULL_PPGTT;
}

bool intel_vgpu_has_hwsp_emulation(struct drm_i915_private *dev_priv)
{
return dev_priv->vgpu.caps & VGT_CAPS_HWSP_EMULATION;
}

bool intel_vgpu_has_huge_gtt(struct drm_i915_private *dev_priv)
{
return dev_priv->vgpu.caps & VGT_CAPS_HUGE_GTT;
}

struct _balloon_info_ {
/*
* There are up to 2 regions per mappable/unmappable graphic
Expand Down
25 changes: 9 additions & 16 deletions drivers/gpu/drm/i915/i915_vgpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,17 @@
#ifndef _I915_VGPU_H_
#define _I915_VGPU_H_

#include "i915_drv.h"
#include "i915_pvinfo.h"
#include <linux/types.h>

void i915_detect_vgpu(struct drm_i915_private *dev_priv);
struct drm_i915_private;
struct i915_ggtt;

bool intel_vgpu_has_full_ppgtt(struct drm_i915_private *dev_priv);

static inline bool
intel_vgpu_has_hwsp_emulation(struct drm_i915_private *dev_priv)
{
return dev_priv->vgpu.caps & VGT_CAPS_HWSP_EMULATION;
}

static inline bool
intel_vgpu_has_huge_gtt(struct drm_i915_private *dev_priv)
{
return dev_priv->vgpu.caps & VGT_CAPS_HUGE_GTT;
}
void intel_vgpu_detect(struct drm_i915_private *i915);
bool intel_vgpu_active(struct drm_i915_private *i915);
void intel_vgpu_register(struct drm_i915_private *i915);
bool intel_vgpu_has_full_ppgtt(struct drm_i915_private *i915);
bool intel_vgpu_has_hwsp_emulation(struct drm_i915_private *i915);
bool intel_vgpu_has_huge_gtt(struct drm_i915_private *i915);

int intel_vgt_balloon(struct i915_ggtt *ggtt);
void intel_vgt_deballoon(struct i915_ggtt *ggtt);
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/i915/intel_gvt.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
*/

#include "i915_drv.h"
#include "i915_vgpu.h"
#include "intel_gvt.h"

/**
Expand Down

0 comments on commit 9e859eb

Please sign in to comment.