Skip to contentSkip to conversation

drm/i915: flush system agent TLBs on SNB so we can WC map the PTEs

PATCH In review Jesse Barnes 4 participants 9 messages Oct 11, 2012 – Oct 22, 2012 Agpgart driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915: flush system agent TLBs on SNB so we can WC map the PTEs

I've only lightly tested this so far, but the corruption seems to be gone if I write the GFX_FLSH_CNTL reg after binding an object. This register should control the TLB for the system agent, which is what CPU mapped objects will go through.

drivers/char/agp/intel-agp.h +3 -0
index 6ec0fff..95f0d4d 100644
@@ -99,6 +99,9 @@
 #define GFX_FLSH_CNTL		0x2170 /* 915+ */
 #define GFX_FLSH_CNTL_VLV	0x101008
 
+#define GFX_FLSH_CNTL		0x101008
+#define   GFX_FLSH_CNTL_EN	(1<<0)
+
 #define I810_DRAM_CTL		0x3000
 #define I810_DRAM_ROW_0		0x00000001
 #define I810_DRAM_ROW_0_SDRAM	0x00000001
drivers/char/agp/intel-gtt.c +5 -7
index e01f5ea..08844d6 100644
@@ -667,12 +667,8 @@ static int intel_gtt_init(void)
 	gtt_map_size = intel_private.base.gtt_total_entries * 4;
 
 	intel_private.gtt = NULL;
-	if (INTEL_GTT_GEN < 6)
-		intel_private.gtt = ioremap_wc(intel_private.gtt_bus_addr,
-					       gtt_map_size);
-	if (intel_private.gtt == NULL)
-		intel_private.gtt = ioremap(intel_private.gtt_bus_addr,
-					    gtt_map_size);
+	intel_private.gtt = ioremap_wc(intel_private.gtt_bus_addr,
+				       gtt_map_size);
 	if (intel_private.gtt == NULL) {
 		intel_private.driver->cleanup();
 		iounmap(intel_private.registers);
@@ -897,6 +893,7 @@ void intel_gtt_insert_sg_entries(struct sg_table *st,
 		}
 	}
 	readl(intel_private.gtt+j-1);
+	writel(GFX_FLSH_CNTL_EN, intel_private.registers + GFX_FLSH_CNTL);
 }
 EXPORT_SYMBOL(intel_gtt_insert_sg_entries);
 
@@ -913,6 +910,7 @@ static void intel_gtt_insert_pages(unsigned int first_entry,
 						  j, flags);
 	}
 	readl(intel_private.gtt+j-1);
+	writel(GFX_FLSH_CNTL_EN, intel_private.registers + GFX_FLSH_CNTL);
 }
 
 static int intel_fake_agp_insert_entries(struct agp_memory *mem,
@@ -1256,7 +1254,7 @@ static int i9xx_setup(void)
 
 	reg_addr &= 0xfff80000;
 
-	if (INTEL_GTT_GEN >= 7)
+	if (INTEL_GTT_GEN >= 6)
 		size = MB(2);
 
 	intel_private.registers = ioremap(reg_addr, size);
#1 lore raw

Hi

2012/10/11 Jesse Barnes <[email protected]>:

Quoted 6 lines

I've only lightly tested this so far, but the corruption seems to be gone if I write the GFX_FLSH_CNTL reg after binding an object. This register should control the TLB for the system agent, which is what CPU mapped objects will go through.

I'm not sure if this is the patch you asked me to test on IRC, but, well this is the patch I tested :)

I tested it on HSW on top of dinq + some other patches. Booted the machine, ran mostly xfterm4 under Xfce, but I also ran firefox, gnome-shell and restarted X a few times. No GPU hangs so far. I'm testing this for about 3-4 hours.

I do have to say that I could not find this register on the HSW documentation, but I also did no see any "Unclaimed write" messages containing the 101008 address... I'm a little confused.

And the interesting thing: intel_gpu_tools is useless now. I keep getting "Couldn't map MMIO region: Resource temporarily unavailable". Do you see this too?

Quoted 63 lines
drivers/char/agp/intel-agp.h +3 -0
index 6ec0fff..95f0d4d 100644
@@ -99,6 +99,9 @@
 #define GFX_FLSH_CNTL          0x2170 /* 915+ */
 #define GFX_FLSH_CNTL_VLV      0x101008
 
+#define GFX_FLSH_CNTL          0x101008
+#define   GFX_FLSH_CNTL_EN     (1<<0)
+
 #define I810_DRAM_CTL          0x3000
 #define I810_DRAM_ROW_0                0x00000001
 #define I810_DRAM_ROW_0_SDRAM  0x00000001
drivers/char/agp/intel-gtt.c +5 -7
index e01f5ea..08844d6 100644
@@ -667,12 +667,8 @@ static int intel_gtt_init(void)
        gtt_map_size = intel_private.base.gtt_total_entries * 4;
 
        intel_private.gtt = NULL;
-       if (INTEL_GTT_GEN < 6)
-               intel_private.gtt = ioremap_wc(intel_private.gtt_bus_addr,
-                                              gtt_map_size);
-       if (intel_private.gtt == NULL)
-               intel_private.gtt = ioremap(intel_private.gtt_bus_addr,
-                                           gtt_map_size);
+       intel_private.gtt = ioremap_wc(intel_private.gtt_bus_addr,
+                                      gtt_map_size);
        if (intel_private.gtt == NULL) {
                intel_private.driver->cleanup();
                iounmap(intel_private.registers);
@@ -897,6 +893,7 @@ void intel_gtt_insert_sg_entries(struct sg_table *st,
                }
        }
        readl(intel_private.gtt+j-1);
+       writel(GFX_FLSH_CNTL_EN, intel_private.registers + GFX_FLSH_CNTL);
 }
 EXPORT_SYMBOL(intel_gtt_insert_sg_entries);
 
@@ -913,6 +910,7 @@ static void intel_gtt_insert_pages(unsigned int first_entry,
                                                  j, flags);
        }
        readl(intel_private.gtt+j-1);
+       writel(GFX_FLSH_CNTL_EN, intel_private.registers + GFX_FLSH_CNTL);
 }
 
 static int intel_fake_agp_insert_entries(struct agp_memory *mem,
@@ -1256,7 +1254,7 @@ static int i9xx_setup(void)
 
        reg_addr &= 0xfff80000;
 
-       if (INTEL_GTT_GEN >= 7)
+       if (INTEL_GTT_GEN >= 6)
                size = MB(2);
 
        intel_private.registers = ioremap(reg_addr, size);

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Signature · 1 line
Paulo Zanoni
#2 lore raw
Quoted 18 lines · On Thu, 11 Oct 2012 20:29:47 -0300 Paulo Zanoni <[email protected]> wrote:

Hi

2012/10/11 Jesse Barnes <[email protected]>:

Quoted 6 lines

I've only lightly tested this so far, but the corruption seems to be gone if I write the GFX_FLSH_CNTL reg after binding an object. This register should control the TLB for the system agent, which is what CPU mapped objects will go through.

I'm not sure if this is the patch you asked me to test on IRC, but, well this is the patch I tested :)

I tested it on HSW on top of dinq + some other patches. Booted the machine, ran mostly xfterm4 under Xfce, but I also ran firefox, gnome-shell and restarted X a few times. No GPU hangs so far. I'm testing this for about 3-4 hours.

Quoted 7 lines

I do have to say that I could not find this register on the HSW documentation, but I also did no see any "Unclaimed write" messages containing the 101008 address... I'm a little confused.

And the interesting thing: intel_gpu_tools is useless now. I keep getting "Couldn't map MMIO region: Resource temporarily unavailable". Do you see this too?

No I haven't seen that, I ran some tests today with the tip of the tree too... Dunno why the resource files would return EBUSY? Maybe because a driver is bound?

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
#3 lore raw
Quoted 25 lines · Jesse Barnes
Quoted 22 lines · On Thu, 11 Oct 2012 20:29:47 -0300 Paulo Zanoni <[email protected]> wrote:

Hi

2012/10/11 Jesse Barnes <[email protected]>:

Quoted 6 lines

I've only lightly tested this so far, but the corruption seems to be gone if I write the GFX_FLSH_CNTL reg after binding an object. This register should control the TLB for the system agent, which is what CPU mapped objects will go through.

I'm not sure if this is the patch you asked me to test on IRC, but, well this is the patch I tested :)

I tested it on HSW on top of dinq + some other patches. Booted the machine, ran mostly xfterm4 under Xfce, but I also ran firefox, gnome-shell and restarted X a few times. No GPU hangs so far. I'm testing this for about 3-4 hours.

I do have to say that I could not find this register on the HSW documentation, but I also did no see any "Unclaimed write" messages containing the 101008 address... I'm a little confused.

Quoted 7 lines
Quoted 3 lines

And the interesting thing: intel_gpu_tools is useless now. I keep getting "Couldn't map MMIO region: Resource temporarily unavailable". Do you see this too?

No I haven't seen that, I ran some tests today with the tip of the tree too... Dunno why the resource files would return EBUSY? Maybe because a driver is bound?

More likely because of some WB/WC/UC collision. We don't like aliases.

Dave.

#4 lore raw
Quoted 30 lines · Dave Airlie
Quoted 29 lines · Jesse Barnes
Quoted 25 lines · On Thu, 11 Oct 2012 20:29:47 -0300 Paulo Zanoni <[email protected]> wrote:

Hi

2012/10/11 Jesse Barnes <[email protected]>:

Quoted 6 lines

I've only lightly tested this so far, but the corruption seems to be gone if I write the GFX_FLSH_CNTL reg after binding an object. This register should control the TLB for the system agent, which is what CPU mapped objects will go through.

I'm not sure if this is the patch you asked me to test on IRC, but, well this is the patch I tested :)

I tested it on HSW on top of dinq + some other patches. Booted the machine, ran mostly xfterm4 under Xfce, but I also ran firefox, gnome-shell and restarted X a few times. No GPU hangs so far. I'm testing this for about 3-4 hours.

I do have to say that I could not find this register on the HSW documentation, but I also did no see any "Unclaimed write" messages containing the 101008 address... I'm a little confused.

And the interesting thing: intel_gpu_tools is useless now. I keep getting "Couldn't map MMIO region: Resource temporarily unavailable". Do you see this too?

Quoted 5 lines
Quoted 3 lines

No I haven't seen that, I ran some tests today with the tip of the tree too... Dunno why the resource files would return EBUSY? Maybe because a driver is bound?

More likely because of some WB/WC/UC collision. We don't like aliases.

Yep, you need to upgrade, latest i-g-t should handle the wc/uc split correctly. The important testcase is gem_gtt_cpu_tlb, if that one works this patch is good.
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
Tested-by
#5 lore raw

Hi

2012/10/12 Daniel Vetter <[email protected]>:

Quoted 35 lines · Dave Airlie
Quoted 34 lines · Jesse Barnes
Quoted 32 lines
Quoted 18 lines · On Thu, 11 Oct 2012 20:29:47 -0300 Paulo Zanoni <[email protected]> wrote:

Hi

2012/10/11 Jesse Barnes <[email protected]>:

Quoted 6 lines

I've only lightly tested this so far, but the corruption seems to be gone if I write the GFX_FLSH_CNTL reg after binding an object. This register should control the TLB for the system agent, which is what CPU mapped objects will go through.

I'm not sure if this is the patch you asked me to test on IRC, but, well this is the patch I tested :)

I tested it on HSW on top of dinq + some other patches. Booted the machine, ran mostly xfterm4 under Xfce, but I also ran firefox, gnome-shell and restarted X a few times. No GPU hangs so far. I'm testing this for about 3-4 hours.

Quoted 7 lines

I do have to say that I could not find this register on the HSW documentation, but I also did no see any "Unclaimed write" messages containing the 101008 address... I'm a little confused.

And the interesting thing: intel_gpu_tools is useless now. I keep getting "Couldn't map MMIO region: Resource temporarily unavailable". Do you see this too?

No I haven't seen that, I ran some tests today with the tip of the tree too... Dunno why the resource files would return EBUSY? Maybe because a driver is bound?

Quoted 5 lines
Quoted 1 line

More likely because of some WB/WC/UC collision. We don't like aliases.

Yep, you need to upgrade, latest i-g-t should handle the wc/uc split correctly. The important testcase is gem_gtt_cpu_tlb, if that one works this patch is good.

You are right, thanks. A git pull on i-g-t makes everything work again :) And gem_gtt_cpu_tlb also passes.

Quoted 9 lines

-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Signature · 1 line
Paulo Zanoni
#6 lore raw
In reply to Jesse Barnes

2012/10/11 Jesse Barnes <[email protected]>:

Quoted 12 lines

I've only lightly tested this so far, but the corruption seems to be gone if I write the GFX_FLSH_CNTL reg after binding an object. This register should control the TLB for the system agent, which is what CPU mapped objects will go through.

drivers/char/agp/intel-agp.h +0 -0
index 6ec0fff..95f0d4d 100644

drivers/char/agp/intel-agp.h line 103

Quoted 5 lines
drivers/char/agp/intel-agp.h +2 -0
@@ -99,6 +99,9 @@
 #define GFX_FLSH_CNTL          0x2170 /* 915+ */
 #define GFX_FLSH_CNTL_VLV      0x101008
 
+#define GFX_FLSH_CNTL          0x101008
+#define   GFX_FLSH_CNTL_EN     (1<<0)

Notice that there's a redefinition of GFX_FLSH_CNTL with a different value just 3 lines above. We're probably fixing gen6+ and breaking gen5-

We write 0 to this reg in some places, but I believe that shouldn't matter.

Quoted 52 lines
drivers/char/agp/intel-agp.h +1 -0
+
 #define I810_DRAM_CTL          0x3000
 #define I810_DRAM_ROW_0                0x00000001
 #define I810_DRAM_ROW_0_SDRAM  0x00000001
drivers/char/agp/intel-gtt.c +5 -7
index e01f5ea..08844d6 100644
@@ -667,12 +667,8 @@ static int intel_gtt_init(void)
        gtt_map_size = intel_private.base.gtt_total_entries * 4;
 
        intel_private.gtt = NULL;
-       if (INTEL_GTT_GEN < 6)
-               intel_private.gtt = ioremap_wc(intel_private.gtt_bus_addr,
-                                              gtt_map_size);
-       if (intel_private.gtt == NULL)
-               intel_private.gtt = ioremap(intel_private.gtt_bus_addr,
-                                           gtt_map_size);
+       intel_private.gtt = ioremap_wc(intel_private.gtt_bus_addr,
+                                      gtt_map_size);
        if (intel_private.gtt == NULL) {
                intel_private.driver->cleanup();
                iounmap(intel_private.registers);
@@ -897,6 +893,7 @@ void intel_gtt_insert_sg_entries(struct sg_table *st,
                }
        }
        readl(intel_private.gtt+j-1);
+       writel(GFX_FLSH_CNTL_EN, intel_private.registers + GFX_FLSH_CNTL);
 }
 EXPORT_SYMBOL(intel_gtt_insert_sg_entries);
 
@@ -913,6 +910,7 @@ static void intel_gtt_insert_pages(unsigned int first_entry,
                                                  j, flags);
        }
        readl(intel_private.gtt+j-1);
+       writel(GFX_FLSH_CNTL_EN, intel_private.registers + GFX_FLSH_CNTL);
 }
 
 static int intel_fake_agp_insert_entries(struct agp_memory *mem,
@@ -1256,7 +1254,7 @@ static int i9xx_setup(void)
 
        reg_addr &= 0xfff80000;
 
-       if (INTEL_GTT_GEN >= 7)
+       if (INTEL_GTT_GEN >= 6)
                size = MB(2);
 
        intel_private.registers = ioremap(reg_addr, size);

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Signature · 1 line
Paulo Zanoni
#7 lore raw
Quoted 16 lines · Paulo Zanoni

2012/10/11 Jesse Barnes <[email protected]>:

Quoted 15 lines

I've only lightly tested this so far, but the corruption seems to be gone if I write the GFX_FLSH_CNTL reg after binding an object. This register should control the TLB for the system agent, which is what CPU mapped objects will go through.

drivers/char/agp/intel-agp.h +0 -0
index 6ec0fff..95f0d4d 100644
@@ -99,6 +99,9 @@
 #define GFX_FLSH_CNTL          0x2170 /* 915+ */
 #define GFX_FLSH_CNTL_VLV      0x101008
 
Quoted 6 lines

drivers/char/agp/intel-agp.h line 103

Quoted 2 lines
drivers/char/agp/intel-agp.h +2 -0
+#define GFX_FLSH_CNTL          0x101008
+#define   GFX_FLSH_CNTL_EN     (1<<0)

Notice that there's a redefinition of GFX_FLSH_CNTL with a different value just 3 lines above. We're probably fixing gen6+ and breaking gen5-

Yeah, Jesse needs to fix up this patch (or me, since it'll conflict anyway with -fixes, so I need a backmerge first).

Quoted 1 line

We write 0 to this reg in some places, but I believe that shouldn't matter.

This is one of the magic registers we have: Read always returns 0, it doesn't matter what you write into it, but something special happens as a side-effect of writing to it. In this case we flush the cpu gtt tlb. We have a few others of this kind.
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#8 lore raw
In reply to Jesse Barnes
Quoted 6 lines · Jesse Barnes

I've only lightly tested this so far, but the corruption seems to be gone if I write the GFX_FLSH_CNTL reg after binding an object. This register should control the TLB for the system agent, which is what CPU mapped objects will go through.

Ok, I've pushed out a new dinq with -rc2 backmerged. Can you please resubmit, with the conflicts resolved and GFX_FLSH_CNTL bikeshedded to GFX_FLSH_CNTL_GEN6? There's also a _VLV #define variant which needs to be killed since it's redundant now ...

Thanks, Daniel

Quoted 63 lines
drivers/char/agp/intel-agp.h +3 -0
index 6ec0fff..95f0d4d 100644
@@ -99,6 +99,9 @@
 #define GFX_FLSH_CNTL		0x2170 /* 915+ */
 #define GFX_FLSH_CNTL_VLV	0x101008
 
+#define GFX_FLSH_CNTL		0x101008
+#define   GFX_FLSH_CNTL_EN	(1<<0)
+
 #define I810_DRAM_CTL		0x3000
 #define I810_DRAM_ROW_0		0x00000001
 #define I810_DRAM_ROW_0_SDRAM	0x00000001
drivers/char/agp/intel-gtt.c +5 -7
index e01f5ea..08844d6 100644
@@ -667,12 +667,8 @@ static int intel_gtt_init(void)
 	gtt_map_size = intel_private.base.gtt_total_entries * 4;
 
 	intel_private.gtt = NULL;
-	if (INTEL_GTT_GEN < 6)
-		intel_private.gtt = ioremap_wc(intel_private.gtt_bus_addr,
-					       gtt_map_size);
-	if (intel_private.gtt == NULL)
-		intel_private.gtt = ioremap(intel_private.gtt_bus_addr,
-					    gtt_map_size);
+	intel_private.gtt = ioremap_wc(intel_private.gtt_bus_addr,
+				       gtt_map_size);
 	if (intel_private.gtt == NULL) {
 		intel_private.driver->cleanup();
 		iounmap(intel_private.registers);
@@ -897,6 +893,7 @@ void intel_gtt_insert_sg_entries(struct sg_table *st,
 		}
 	}
 	readl(intel_private.gtt+j-1);
+	writel(GFX_FLSH_CNTL_EN, intel_private.registers + GFX_FLSH_CNTL);
 }
 EXPORT_SYMBOL(intel_gtt_insert_sg_entries);
 
@@ -913,6 +910,7 @@ static void intel_gtt_insert_pages(unsigned int first_entry,
 						  j, flags);
 	}
 	readl(intel_private.gtt+j-1);
+	writel(GFX_FLSH_CNTL_EN, intel_private.registers + GFX_FLSH_CNTL);
 }
 
 static int intel_fake_agp_insert_entries(struct agp_memory *mem,
@@ -1256,7 +1254,7 @@ static int i9xx_setup(void)
 
 	reg_addr &= 0xfff80000;
 
-	if (INTEL_GTT_GEN >= 7)
+	if (INTEL_GTT_GEN >= 6)
 		size = MB(2);
 
 	intel_private.registers = ioremap(reg_addr, size);

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch