Signed-off-by: Ben Widawsky <ben at bwidawsk.net> --- drivers/gpu/drm/i915/i915_drv.h | 3 +++ drivers/gpu/drm/i915/i915_gem_gtt.c | 20 +++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 4c0e670..d462875 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -369,6 +369,9 @@ struct i915_gtt_operations { int (*gmch_probe)(struct i915_gtt *gtt, size_t *gtt_total, size_t *stolen); void (*gmch_remove)(struct i915_gtt *gtt); + + /* GEN6+ helpers */ + size_t (*get_stolen_size)(u16 gmch_ctl); }; /* The Graphics Translation Table is the way in which GEN hardware translates a diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c index d383add..2f2b1ba 100644 --- a/drivers/gpu/drm/i915/i915_gem_gtt.c +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c @@ -707,11 +707,7 @@ static int gen6_gmch_probe(struct i915_gtt *gtt, pci_read_config_word(dev->pdev, SNB_GMCH_CTRL, &snb_gmch_ctl); gtt_size = gen6_get_total_gtt_size(snb_gmch_ctl); - if (IS_GEN7(dev)) - *stolen = gen7_get_stolen_size(snb_gmch_ctl); - else - *stolen = gen6_get_stolen_size(snb_gmch_ctl); - + *stolen = gtt->gtt_ops->get_stolen_size(snb_gmch_ctl); *gtt_total = (gtt_size / sizeof(gtt_pte_t)) << PAGE_SHIFT; /* For GEN6+ the PTEs for the ggtt live at 2MB + BAR0 */ @@ -740,6 +736,13 @@ void gen6_gmch_remove(struct i915_gtt *gtt) static const struct i915_gtt_operations gen6_gtt_ops = { .gmch_probe = gen6_gmch_probe, .gmch_remove = gen6_gmch_remove, + .get_stolen_size = gen6_get_stolen_size, +}; + +static const struct i915_gtt_operations gen7_gtt_ops = { + .gmch_probe = gen6_gmch_probe, + .gmch_remove = gen6_gmch_remove, + .get_stolen_size = gen7_get_stolen_size, }; static int i915_gmch_probe(struct i915_gtt *gtt, @@ -792,9 +795,12 @@ int i915_gem_gtt_init(struct drm_device *dev) if (INTEL_INFO(dev)->gen <= 5) gtt->gtt_ops = &legacy_gtt_ops; - else + else if(IS_GEN6(dev)) gtt->gtt_ops = &gen6_gtt_ops; - + else if(IS_GEN7(dev)) + gtt->gtt_ops = &gen7_gtt_ops; + else + BUG(); ret = gtt->gtt_ops->gmch_probe(gtt, &dev_priv->gtt.total, &dev_priv->gtt.stolen_size); if (ret) -- 1.8.1.1