Skip to content

Commit bdb8b97

Browse files
committed
agp/intel: Experiment with a 855GM GWB bit
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=27187 Tested-by: Thorsten Vollmer <thorsten@thvo.de> (DFI-ACP G5M150-N w/852GME) Tested-by: Moritz Brunner <2points@gmx.org> (Asus M2400N/i855GM) Tested-by: Indan Zupancic <indan@nul.nu> (Thinkpad X40/855GM rev 02) Tested-by: Eric Anholt <eric@anholt.net> (865G) Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
1 parent a36dbec commit bdb8b97

2 files changed

Lines changed: 22 additions & 35 deletions

File tree

‎drivers/char/agp/intel-agp.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@
130130
#define INTEL_GMCH_GMS_STOLEN_352M (0xd << 4)
131131

132132
#define I915_IFPADDR 0x60
133+
#define I830_HIC 0x70
133134

134135
/* Intel 965G registers */
135136
#define I965_MSAC 0x62

‎drivers/char/agp/intel-gtt.c‎

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <linux/kernel.h>
2222
#include <linux/pagemap.h>
2323
#include <linux/agp_backend.h>
24+
#include <linux/delay.h>
2425
#include <asm/smp.h>
2526
#include "agp.h"
2627
#include "intel-agp.h"
@@ -70,12 +71,8 @@ static struct _intel_private {
7071
u32 __iomem *gtt; /* I915G */
7172
bool clear_fake_agp; /* on first access via agp, fill with scratch */
7273
int num_dcache_entries;
73-
union {
74-
void __iomem *i9xx_flush_page;
75-
void *i8xx_flush_page;
76-
};
74+
void __iomem *i9xx_flush_page;
7775
char *i81x_gtt_table;
78-
struct page *i8xx_page;
7976
struct resource ifp_resource;
8077
int resource_valid;
8178
struct page *scratch_page;
@@ -722,28 +719,6 @@ static int intel_fake_agp_fetch_size(void)
722719

723720
static void i830_cleanup(void)
724721
{
725-
if (intel_private.i8xx_flush_page) {
726-
kunmap(intel_private.i8xx_flush_page);
727-
intel_private.i8xx_flush_page = NULL;
728-
}
729-
730-
__free_page(intel_private.i8xx_page);
731-
intel_private.i8xx_page = NULL;
732-
}
733-
734-
static void intel_i830_setup_flush(void)
735-
{
736-
/* return if we've already set the flush mechanism up */
737-
if (intel_private.i8xx_page)
738-
return;
739-
740-
intel_private.i8xx_page = alloc_page(GFP_KERNEL);
741-
if (!intel_private.i8xx_page)
742-
return;
743-
744-
intel_private.i8xx_flush_page = kmap(intel_private.i8xx_page);
745-
if (!intel_private.i8xx_flush_page)
746-
i830_cleanup();
747722
}
748723

749724
/* The chipset_flush interface needs to get data that has already been
@@ -758,14 +733,27 @@ static void intel_i830_setup_flush(void)
758733
*/
759734
static void i830_chipset_flush(void)
760735
{
761-
unsigned int *pg = intel_private.i8xx_flush_page;
736+
unsigned long timeout = jiffies + msecs_to_jiffies(1000);
737+
738+
/* Forcibly evict everything from the CPU write buffers.
739+
* clflush appears to be insufficient.
740+
*/
741+
wbinvd_on_all_cpus();
742+
743+
/* Now we've only seen documents for this magic bit on 855GM,
744+
* we hope it exists for the other gen2 chipsets...
745+
*
746+
* Also works as advertised on my 845G.
747+
*/
748+
writel(readl(intel_private.registers+I830_HIC) | (1<<31),
749+
intel_private.registers+I830_HIC);
762750

763-
memset(pg, 0, 1024);
751+
while (readl(intel_private.registers+I830_HIC) & (1<<31)) {
752+
if (time_after(jiffies, timeout))
753+
break;
764754

765-
if (cpu_has_clflush)
766-
clflush_cache_range(pg, 1024);
767-
else if (wbinvd_on_all_cpus() != 0)
768-
printk(KERN_ERR "Timed out waiting for cache flush.\n");
755+
udelay(50);
756+
}
769757
}
770758

771759
static void i830_write_entry(dma_addr_t addr, unsigned int entry,
@@ -849,8 +837,6 @@ static int i830_setup(void)
849837

850838
intel_private.gtt_bus_addr = reg_addr + I810_PTE_BASE;
851839

852-
intel_i830_setup_flush();
853-
854840
return 0;
855841
}
856842

0 commit comments

Comments
 (0)