diff options
author | Ben Widawsky <ben@bwidawsk.net> | 2013-02-08 14:32:47 -0500 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2013-02-15 04:30:38 -0500 |
commit | 41907ddc1b71aaa4ef5290f46f0ec49d581d6aac (patch) | |
tree | 5cb9829dfc0753d61713246f2cd60955827b19e8 | |
parent | d46da4377689bd938795e53c4e2fb54dbcaeea44 (diff) |
drm/i915: Fix gen2 mappable calculations
When I refactored the code initially, I forgot that gen2 uses a
different bar for the CPU mappable aperture. The agp-less code knows
nothing of generations less than 5, so we have to expand the gtt_probe
function to include the mappable base and end.
It was originally broken by me:
commit baa09f5fd8a6d033ec075355dda99a65b7f6a0f3
Author: Ben Widawsky <ben@bwidawsk.net>
Date: Thu Jan 24 13:49:57 2013 -0800
drm/i915: Add probe and remove to the gtt ops
Reported-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r-- | drivers/char/agp/intel-gtt.c | 5 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/i915_drv.h | 3 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/i915_gem_gtt.c | 23 | ||||
-rw-r--r-- | include/drm/intel-gtt.h | 3 |
4 files changed, 22 insertions, 12 deletions
diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c index d8e7e6c9114e..207e5c36e9ec 100644 --- a/drivers/char/agp/intel-gtt.c +++ b/drivers/char/agp/intel-gtt.c | |||
@@ -1371,10 +1371,13 @@ int intel_gmch_probe(struct pci_dev *bridge_pdev, struct pci_dev *gpu_pdev, | |||
1371 | } | 1371 | } |
1372 | EXPORT_SYMBOL(intel_gmch_probe); | 1372 | EXPORT_SYMBOL(intel_gmch_probe); |
1373 | 1373 | ||
1374 | void intel_gtt_get(size_t *gtt_total, size_t *stolen_size) | 1374 | void intel_gtt_get(size_t *gtt_total, size_t *stolen_size, |
1375 | phys_addr_t *mappable_base, unsigned long *mappable_end) | ||
1375 | { | 1376 | { |
1376 | *gtt_total = intel_private.gtt_total_entries << PAGE_SHIFT; | 1377 | *gtt_total = intel_private.gtt_total_entries << PAGE_SHIFT; |
1377 | *stolen_size = intel_private.stolen_size; | 1378 | *stolen_size = intel_private.stolen_size; |
1379 | *mappable_base = intel_private.gma_bus_addr; | ||
1380 | *mappable_end = intel_private.gtt_mappable_entries << PAGE_SHIFT; | ||
1378 | } | 1381 | } |
1379 | EXPORT_SYMBOL(intel_gtt_get); | 1382 | EXPORT_SYMBOL(intel_gtt_get); |
1380 | 1383 | ||
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index a7860ea21af9..0f1d15bac517 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h | |||
@@ -399,7 +399,8 @@ struct i915_gtt { | |||
399 | 399 | ||
400 | /* global gtt ops */ | 400 | /* global gtt ops */ |
401 | int (*gtt_probe)(struct drm_device *dev, size_t *gtt_total, | 401 | int (*gtt_probe)(struct drm_device *dev, size_t *gtt_total, |
402 | size_t *stolen); | 402 | size_t *stolen, phys_addr_t *mappable_base, |
403 | unsigned long *mappable_end); | ||
403 | void (*gtt_remove)(struct drm_device *dev); | 404 | void (*gtt_remove)(struct drm_device *dev); |
404 | void (*gtt_clear_range)(struct drm_device *dev, | 405 | void (*gtt_clear_range)(struct drm_device *dev, |
405 | unsigned int first_entry, | 406 | unsigned int first_entry, |
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c index bdaca3f47988..926a1e2dd234 100644 --- a/drivers/gpu/drm/i915/i915_gem_gtt.c +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c | |||
@@ -725,7 +725,9 @@ static inline size_t gen7_get_stolen_size(u16 snb_gmch_ctl) | |||
725 | 725 | ||
726 | static int gen6_gmch_probe(struct drm_device *dev, | 726 | static int gen6_gmch_probe(struct drm_device *dev, |
727 | size_t *gtt_total, | 727 | size_t *gtt_total, |
728 | size_t *stolen) | 728 | size_t *stolen, |
729 | phys_addr_t *mappable_base, | ||
730 | unsigned long *mappable_end) | ||
729 | { | 731 | { |
730 | struct drm_i915_private *dev_priv = dev->dev_private; | 732 | struct drm_i915_private *dev_priv = dev->dev_private; |
731 | phys_addr_t gtt_bus_addr; | 733 | phys_addr_t gtt_bus_addr; |
@@ -733,11 +735,13 @@ static int gen6_gmch_probe(struct drm_device *dev, | |||
733 | u16 snb_gmch_ctl; | 735 | u16 snb_gmch_ctl; |
734 | int ret; | 736 | int ret; |
735 | 737 | ||
738 | *mappable_base = pci_resource_start(dev->pdev, 2); | ||
739 | *mappable_end = pci_resource_len(dev->pdev, 2); | ||
740 | |||
736 | /* 64/512MB is the current min/max we actually know of, but this is just | 741 | /* 64/512MB is the current min/max we actually know of, but this is just |
737 | * a coarse sanity check. | 742 | * a coarse sanity check. |
738 | */ | 743 | */ |
739 | if ((dev_priv->gtt.mappable_end < (64<<20) || | 744 | if ((*mappable_end < (64<<20) || (*mappable_end > (512<<20)))) { |
740 | (dev_priv->gtt.mappable_end > (512<<20)))) { | ||
741 | DRM_ERROR("Unknown GMADR size (%lx)\n", | 745 | DRM_ERROR("Unknown GMADR size (%lx)\n", |
742 | dev_priv->gtt.mappable_end); | 746 | dev_priv->gtt.mappable_end); |
743 | return -ENXIO; | 747 | return -ENXIO; |
@@ -782,7 +786,9 @@ static void gen6_gmch_remove(struct drm_device *dev) | |||
782 | 786 | ||
783 | static int i915_gmch_probe(struct drm_device *dev, | 787 | static int i915_gmch_probe(struct drm_device *dev, |
784 | size_t *gtt_total, | 788 | size_t *gtt_total, |
785 | size_t *stolen) | 789 | size_t *stolen, |
790 | phys_addr_t *mappable_base, | ||
791 | unsigned long *mappable_end) | ||
786 | { | 792 | { |
787 | struct drm_i915_private *dev_priv = dev->dev_private; | 793 | struct drm_i915_private *dev_priv = dev->dev_private; |
788 | int ret; | 794 | int ret; |
@@ -793,7 +799,7 @@ static int i915_gmch_probe(struct drm_device *dev, | |||
793 | return -EIO; | 799 | return -EIO; |
794 | } | 800 | } |
795 | 801 | ||
796 | intel_gtt_get(gtt_total, stolen); | 802 | intel_gtt_get(gtt_total, stolen, mappable_base, mappable_end); |
797 | 803 | ||
798 | dev_priv->gtt.do_idle_maps = needs_idle_maps(dev_priv->dev); | 804 | dev_priv->gtt.do_idle_maps = needs_idle_maps(dev_priv->dev); |
799 | dev_priv->gtt.gtt_clear_range = i915_ggtt_clear_range; | 805 | dev_priv->gtt.gtt_clear_range = i915_ggtt_clear_range; |
@@ -814,9 +820,6 @@ int i915_gem_gtt_init(struct drm_device *dev) | |||
814 | unsigned long gtt_size; | 820 | unsigned long gtt_size; |
815 | int ret; | 821 | int ret; |
816 | 822 | ||
817 | gtt->mappable_base = pci_resource_start(dev->pdev, 2); | ||
818 | gtt->mappable_end = pci_resource_len(dev->pdev, 2); | ||
819 | |||
820 | if (INTEL_INFO(dev)->gen <= 5) { | 823 | if (INTEL_INFO(dev)->gen <= 5) { |
821 | dev_priv->gtt.gtt_probe = i915_gmch_probe; | 824 | dev_priv->gtt.gtt_probe = i915_gmch_probe; |
822 | dev_priv->gtt.gtt_remove = i915_gmch_remove; | 825 | dev_priv->gtt.gtt_remove = i915_gmch_remove; |
@@ -826,7 +829,9 @@ int i915_gem_gtt_init(struct drm_device *dev) | |||
826 | } | 829 | } |
827 | 830 | ||
828 | ret = dev_priv->gtt.gtt_probe(dev, &dev_priv->gtt.total, | 831 | ret = dev_priv->gtt.gtt_probe(dev, &dev_priv->gtt.total, |
829 | &dev_priv->gtt.stolen_size); | 832 | &dev_priv->gtt.stolen_size, |
833 | >t->mappable_base, | ||
834 | >t->mappable_end); | ||
830 | if (ret) | 835 | if (ret) |
831 | return ret; | 836 | return ret; |
832 | 837 | ||
diff --git a/include/drm/intel-gtt.h b/include/drm/intel-gtt.h index cf105557fea9..b08bdade6002 100644 --- a/include/drm/intel-gtt.h +++ b/include/drm/intel-gtt.h | |||
@@ -3,7 +3,8 @@ | |||
3 | #ifndef _DRM_INTEL_GTT_H | 3 | #ifndef _DRM_INTEL_GTT_H |
4 | #define _DRM_INTEL_GTT_H | 4 | #define _DRM_INTEL_GTT_H |
5 | 5 | ||
6 | void intel_gtt_get(size_t *gtt_total, size_t *stolen_size); | 6 | void intel_gtt_get(size_t *gtt_total, size_t *stolen_size, |
7 | phys_addr_t *mappable_base, unsigned long *mappable_end); | ||
7 | 8 | ||
8 | int intel_gmch_probe(struct pci_dev *bridge_pdev, struct pci_dev *gpu_pdev, | 9 | int intel_gmch_probe(struct pci_dev *bridge_pdev, struct pci_dev *gpu_pdev, |
9 | struct agp_bridge_data *bridge); | 10 | struct agp_bridge_data *bridge); |