[Intel-gfx] [PATCH 3/3] [RFC] drm/i915: With the vtable, intel_gtt is useless
Ben Widawsky
ben at bwidawsk.net
Sun Jan 20 03:05:21 CET 2013
Signed-off-by: Ben Widawsky <ben at bwidawsk.net>
---
drivers/char/agp/intel-gtt.c | 18 +++++++++---------
drivers/gpu/drm/i915/i915_drv.h | 2 --
drivers/gpu/drm/i915/i915_gem_gtt.c | 21 ++-------------------
include/drm/intel-gtt.h | 6 +-----
4 files changed, 12 insertions(+), 35 deletions(-)
diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c
index 9d9a902..d8e7e6c 100644
--- a/drivers/char/agp/intel-gtt.c
+++ b/drivers/char/agp/intel-gtt.c
@@ -60,7 +60,6 @@ struct intel_gtt_driver {
};
static struct _intel_private {
- struct intel_gtt base;
const struct intel_gtt_driver *driver;
struct pci_dev *pcidev; /* device one */
struct pci_dev *bridge_dev;
@@ -84,6 +83,9 @@ static struct _intel_private {
unsigned int stolen_size;
/* Total number of gtt entries. */
unsigned int gtt_total_entries;
+ /* Part of the gtt that is mappable by the cpu, for those chips where
+ * this is not the full gtt. */
+ unsigned int gtt_mappable_entries;
} intel_private;
#define INTEL_GTT_GEN intel_private.driver->gen
@@ -514,7 +516,7 @@ static unsigned int intel_gtt_total_entries(void)
/* On previous hardware, the GTT size was just what was
* required to map the aperture.
*/
- return intel_private.base.gtt_mappable_entries;
+ return intel_private.gtt_mappable_entries;
}
}
@@ -580,7 +582,7 @@ static int intel_gtt_init(void)
if (ret != 0)
return ret;
- intel_private.base.gtt_mappable_entries = intel_gtt_mappable_entries();
+ intel_private.gtt_mappable_entries = intel_gtt_mappable_entries();
intel_private.gtt_total_entries = intel_gtt_total_entries();
/* save the PGETBL reg for resume */
@@ -594,7 +596,7 @@ static int intel_gtt_init(void)
dev_info(&intel_private.bridge_dev->dev,
"detected gtt size: %dK total, %dK mappable\n",
intel_private.gtt_total_entries * 4,
- intel_private.base.gtt_mappable_entries * 4);
+ intel_private.gtt_mappable_entries * 4);
gtt_map_size = intel_private.gtt_total_entries * 4;
@@ -641,8 +643,7 @@ static int intel_fake_agp_fetch_size(void)
unsigned int aper_size;
int i;
- aper_size = (intel_private.base.gtt_mappable_entries << PAGE_SHIFT)
- / MB(1);
+ aper_size = (intel_private.gtt_mappable_entries << PAGE_SHIFT) / MB(1);
for (i = 0; i < num_sizes; i++) {
if (aper_size == intel_fake_agp_sizes[i].size) {
@@ -850,7 +851,7 @@ static int intel_fake_agp_insert_entries(struct agp_memory *mem,
if (intel_private.clear_fake_agp) {
int start = intel_private.stolen_size / PAGE_SIZE;
- int end = intel_private.base.gtt_mappable_entries;
+ int end = intel_private.gtt_mappable_entries;
intel_gtt_clear_range(start, end - start);
intel_private.clear_fake_agp = false;
}
@@ -1370,11 +1371,10 @@ int intel_gmch_probe(struct pci_dev *bridge_pdev, struct pci_dev *gpu_pdev,
}
EXPORT_SYMBOL(intel_gmch_probe);
-struct intel_gtt *intel_gtt_get(size_t *gtt_total, size_t *stolen_size)
+void intel_gtt_get(size_t *gtt_total, size_t *stolen_size)
{
*gtt_total = intel_private.gtt_total_entries << PAGE_SHIFT;
*stolen_size = intel_private.stolen_size;
- return &intel_private.base;
}
EXPORT_SYMBOL(intel_gtt_get);
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 9b484dd..a2b1d2a 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -676,8 +676,6 @@ struct intel_l3_parity {
};
struct i915_gem_mm {
- /** Bridge to intel-gtt-ko */
- struct intel_gtt *gtt;
/** Memory allocator for GTT stolen memory */
struct drm_mm stolen;
/** Memory allocator for GTT */
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index ebec4f4..4aa11e6 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -721,7 +721,6 @@ void gen6_gmch_remove(struct drm_device *dev)
struct drm_i915_private *dev_priv = dev->dev_private;
iounmap(dev_priv->gtt.gsm);
teardown_scratch_page(dev);
- kfree(dev_priv->mm.gtt);
}
static const struct i915_gtt_operations gen6_gtt_ops = {
@@ -735,10 +734,6 @@ static int i915_gmch_probe(struct drm_device *dev, size_t *gtt_total,
struct drm_i915_private *dev_priv = dev->dev_private;
int ret;
- /* This is a temporary hack to make the code cleaner in
- * i915_gem_gtt_init. I promise it will go away very shortly. */
- kfree(dev_priv->mm.gtt);
-
BUG_ON(INTEL_INFO(dev)->gen >5);
ret = intel_gmch_probe(dev_priv->bridge_dev, dev->pdev, NULL);
@@ -747,13 +742,7 @@ static int i915_gmch_probe(struct drm_device *dev, size_t *gtt_total,
return -EIO;
}
- dev_priv->mm.gtt = intel_gtt_get(gtt_total, stolen);
- if (!dev_priv->mm.gtt) {
- DRM_ERROR("Failed to initialize GTT\n");
- intel_gmch_remove();
- return -ENODEV;
- }
-
+ intel_gtt_get(gtt_total, stolen);
dev_priv->gtt.do_idle_maps = needs_idle_maps(dev);
return 0;
@@ -785,16 +774,10 @@ int i915_gem_gtt_init(struct drm_device *dev)
dev_priv->gtt.mappable_base = pci_resource_start(dev->pdev, 2);
dev_priv->gtt.mappable_end = pci_resource_len(dev->pdev, 2);
- dev_priv->mm.gtt = kzalloc(sizeof(*dev_priv->mm.gtt), GFP_KERNEL);
- if (!dev_priv->mm.gtt)
- return -ENOMEM;
-
ret = dev_priv->gtt.gtt_ops->gmch_probe(dev, &dev_priv->gtt.total,
&dev_priv->gtt.stolen_size);
- if (ret) {
- kfree(dev_priv->mm.gtt);
+ if (ret)
return ret;
- }
/* For GEN6+ the PTEs for the ggtt live at 2MB + BAR0 */
gtt_bus_addr = pci_resource_start(dev->pdev, 0) + (2<<20);
diff --git a/include/drm/intel-gtt.h b/include/drm/intel-gtt.h
index 94917d2..cf10555 100644
--- a/include/drm/intel-gtt.h
+++ b/include/drm/intel-gtt.h
@@ -3,11 +3,7 @@
#ifndef _DRM_INTEL_GTT_H
#define _DRM_INTEL_GTT_H
-struct intel_gtt {
- /* Part of the gtt that is mappable by the cpu, for those chips where
- * this is not the full gtt. */
- unsigned int gtt_mappable_entries;
-} *intel_gtt_get(size_t *gtt_total, size_t *stolen_size);
+void intel_gtt_get(size_t *gtt_total, size_t *stolen_size);
int intel_gmch_probe(struct pci_dev *bridge_pdev, struct pci_dev *gpu_pdev,
struct agp_bridge_data *bridge);
--
1.8.1.1
More information about the Intel-gfx
mailing list