All of lore.kernel.org
 help / color / mirror / Atom feed
* [BISECTED] agp/intel: revert "Remove confusion of stolen entries not stolen memory"
@ 2010-12-20 18:12 Arnd Bergmann
  2010-12-20 18:53 ` Chris Wilson
  0 siblings, 1 reply; 39+ messages in thread
From: Arnd Bergmann @ 2010-12-20 18:12 UTC (permalink / raw)
  To: Chris Wilson; +Cc: linux-kernel, David Airlie

Commit c64f7ba5f10 "agp/intel: Remove confusion of stolen entries not stolen memory" caused a regression on my Intel G45 based system, using the VESA
Xorg driver or uvesafb. I have not tried if i915 with KMS shows the same
behaviour, but can try if necessary.

Reverting the patch on Friday's linux-next restores the normal behaviour
and lets me use X again.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c
index 356f73e..7812a3a 100644
--- a/drivers/char/agp/intel-gtt.c
+++ b/drivers/char/agp/intel-gtt.c
@@ -342,12 +342,13 @@ static const struct aper_size_info_fixed intel_fake_agp_sizes[] = {
 	{512, 131072, 7},
 };
 
-static unsigned int intel_gtt_stolen_size(void)
+static unsigned int intel_gtt_stolen_entries(void)
 {
 	u16 gmch_ctrl;
 	u8 rdct;
 	int local = 0;
 	static const int ddt[4] = { 0, 16, 32, 64 };
+	unsigned int overhead_entries;
 	unsigned int stolen_size = 0;
 
 	if (INTEL_GTT_GEN == 1)
@@ -356,6 +357,14 @@ static unsigned int intel_gtt_stolen_size(void)
 	pci_read_config_word(intel_private.bridge_dev,
 			     I830_GMCH_CTRL, &gmch_ctrl);
 
+	if (INTEL_GTT_GEN > 4 || IS_PINEVIEW)
+		overhead_entries = 0;
+	else
+		overhead_entries = intel_private.base.gtt_mappable_entries
+			/ 1024;
+
+	overhead_entries += 1; /* BIOS popup */
+
 	if (intel_private.bridge_dev->device == PCI_DEVICE_ID_INTEL_82830_HB ||
 	    intel_private.bridge_dev->device == PCI_DEVICE_ID_INTEL_82845G_HB) {
 		switch (gmch_ctrl & I830_GMCH_GMS_MASK) {
@@ -490,7 +499,7 @@ static unsigned int intel_gtt_stolen_size(void)
 		stolen_size = 0;
 	}
 
-	return stolen_size;
+	return stolen_size/KB(4) - overhead_entries;
 }
 
 static void i965_adjust_pgetbl_size(unsigned int size_flag)
@@ -686,7 +695,7 @@ static int intel_gtt_init(void)
 
 	global_cache_flush();   /* FIXME: ? */
 
-	intel_private.base.stolen_size = intel_gtt_stolen_size();
+	intel_private.base.gtt_stolen_entries = intel_gtt_stolen_entries();
 
 	ret = intel_gtt_setup_scratch_page();
 	if (ret != 0) {
@@ -867,7 +876,8 @@ static int intel_fake_agp_configure(void)
 
 	agp_bridge->gart_bus_addr = intel_private.gma_bus_addr;
 
-	for (i = 0; i < intel_private.base.gtt_total_entries; i++) {
+	for (i = intel_private.base.gtt_stolen_entries;
+			i < intel_private.base.gtt_total_entries; i++) {
 		intel_private.driver->write_entry(intel_private.scratch_page_dma,
 						  i, 0);
 	}
@@ -942,7 +952,17 @@ static int intel_fake_agp_insert_entries(struct agp_memory *mem,
 	if (mem->page_count == 0)
 		goto out;
 
-	if (pg_start + mem->page_count > intel_private.base.gtt_total_entries)
+	if (pg_start < intel_private.base.gtt_stolen_entries) {
+		dev_printk(KERN_DEBUG, &intel_private.pcidev->dev,
+			   "pg_start == 0x%.8lx, gtt_stolen_entries == 0x%.8x\n",
+			   pg_start, intel_private.base.gtt_stolen_entries);
+
+		dev_info(&intel_private.pcidev->dev,
+			 "trying to insert into local/stolen memory\n");
+		goto out_err;
+	}
+
+	if ((pg_start + mem->page_count) > intel_private.base.gtt_total_entries)
 		goto out_err;
 
 	if (type != mem->type)
@@ -991,6 +1011,12 @@ static int intel_fake_agp_remove_entries(struct agp_memory *mem,
 	if (mem->page_count == 0)
 		return 0;
 
+	if (pg_start < intel_private.base.gtt_stolen_entries) {
+		dev_info(&intel_private.pcidev->dev,
+			 "trying to disable local/stolen memory\n");
+		return -EINVAL;
+	}
+
 	if (intel_private.base.needs_dmar) {
 		intel_gtt_unmap_memory(mem->sg_list, mem->num_sg);
 		mem->sg_list = NULL;
@@ -1489,7 +1515,7 @@ int intel_gmch_probe(struct pci_dev *pdev,
 }
 EXPORT_SYMBOL(intel_gmch_probe);
 
-const struct intel_gtt *intel_gtt_get(void)
+struct intel_gtt *intel_gtt_get(void)
 {
 	return &intel_private.base;
 }
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 3f7b203..1655c39 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -1049,7 +1049,7 @@ static unsigned long i915_stolen_to_phys(struct drm_device *dev, u32 offset)
 		pci_read_config_byte(pdev, 0x9c, &val);
 		base = val >> 3 << 27;
 	}
-	base -= dev_priv->mm.gtt->stolen_size;
+	base -= dev_priv->mm.gtt->gtt_stolen_entries << PAGE_SHIFT;
 #endif
 
 	return base + offset;
@@ -1173,7 +1173,7 @@ static int i915_load_modeset_init(struct drm_device *dev)
 	unsigned long prealloc_size, gtt_size, mappable_size;
 	int ret = 0;
 
-	prealloc_size = dev_priv->mm.gtt->stolen_size;
+	prealloc_size = dev_priv->mm.gtt->gtt_stolen_entries << PAGE_SHIFT;
 	gtt_size = dev_priv->mm.gtt->gtt_total_entries << PAGE_SHIFT;
 	mappable_size = dev_priv->mm.gtt->gtt_mappable_entries << PAGE_SHIFT;
 
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 30780f2..b41edf6 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -532,7 +532,7 @@ typedef struct drm_i915_private {
 
 	struct {
 		/** Bridge to intel-gtt-ko */
-		const struct intel_gtt *gtt;
+		struct intel_gtt *gtt;
 		/** Memory allocator for GTT stolen memory */
 		struct drm_mm stolen;
 		/** Memory allocator for GTT */
diff --git a/include/drm/intel-gtt.h b/include/drm/intel-gtt.h
index 9e343c0..75c2088 100644
--- a/include/drm/intel-gtt.h
+++ b/include/drm/intel-gtt.h
@@ -2,10 +2,9 @@
 
 #ifndef _DRM_INTEL_GTT_H
 #define	_DRM_INTEL_GTT_H
-
-const struct intel_gtt {
-	/* Size of memory reserved for graphics by the BIOS */
-	unsigned int stolen_size;
+struct intel_gtt {
+	/* Number of stolen gtt entries at the beginning. */
+	unsigned int gtt_stolen_entries;
 	/* Total number of gtt entries. */
 	unsigned int gtt_total_entries;
 	/* Part of the gtt that is mappable by the cpu, for those chips where

^ permalink raw reply related	[flat|nested] 39+ messages in thread

end of thread, other threads:[~2011-06-18  4:40 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-20 18:12 [BISECTED] agp/intel: revert "Remove confusion of stolen entries not stolen memory" Arnd Bergmann
2010-12-20 18:53 ` Chris Wilson
2010-12-20 19:47   ` Arnd Bergmann
2010-12-20 19:52     ` Chris Wilson
2010-12-20 20:52       ` Arnd Bergmann
2010-12-20 21:06         ` Chris Wilson
2010-12-20 21:54           ` Arnd Bergmann
2010-12-20 22:08             ` Dave Airlie
2011-01-20 23:24           ` Frederic Weisbecker
2011-01-21 10:58             ` [PATCH] drm/i915,agp/intel: Do not clear stolen entries Chris Wilson
2011-01-21 16:26               ` Jiri Olsa
2011-01-23  1:12               ` Frederic Weisbecker
2011-01-23 11:01                 ` Chris Wilson
2011-01-23 17:59                   ` Frederic Weisbecker
2011-01-24  7:40                     ` Hugh Dickins
2011-01-24 10:10                       ` Chris Wilson
2011-01-26 21:39                         ` Arnd Bergmann
2011-01-28 22:00                         ` Hugh Dickins
2011-01-29  2:59                           ` Mario Kleiner
2011-01-30  0:28                             ` Hugh Dickins
2011-01-30  4:13                               ` Mario Kleiner
2011-01-30  9:55                                 ` Chris Wilson
2011-01-31 10:57                                   ` [PATCH] drm/i915: Suppress spurious vblank interrupts Chris Wilson
2011-02-01 17:34                                     ` Hugh Dickins
2011-02-01 17:46                                       ` Chris Wilson
2011-02-01 17:46                                       ` Jesse Barnes
2011-02-01 18:08                                         ` Jesse Barnes
2011-02-01 18:46                                           ` Hugh Dickins
2011-02-01 19:32                                             ` Jesse Barnes
2011-02-02  3:37                                               ` Hugh Dickins
2011-02-02 17:18                                                 ` Jesse Barnes
2011-02-08 19:52                                                   ` Hugh Dickins
2011-02-10 10:16                                                     ` [PATCH] drm/i915/tv: Use polling rather than interrupt-based hotplug Chris Wilson
2011-02-11  6:34                                                       ` Hugh Dickins
2011-02-11 18:21                                                     ` [PATCH] drm/i915: Suppress spurious vblank interrupts Mario Kleiner
2011-02-14 17:41                                                       ` Hugh Dickins
2011-06-18  4:40                                                         ` Hugh Dickins
2011-01-30  8:52                               ` [PATCH] drm/i915,agp/intel: Do not clear stolen entries Chris Clayton
2011-01-21 16:05             ` [BISECTED] agp/intel: revert "Remove confusion of stolen entries not stolen memory" Jiri Olsa

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.