aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/agp/ali-agp.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2007-10-14 20:19:16 -0400
committerDave Airlie <airlied@optimus.(none)>2007-10-14 20:32:15 -0400
commita2721e998ede079db10f65e4b42310f79dc8f135 (patch)
tree32963c9bf40f3e0871d4d549bb6c3cf13abbb24c /drivers/char/agp/ali-agp.c
parent23fd50450a34f2558070ceabb0bfebc1c9604af5 (diff)
AGP fix race condition between unmapping and freeing pages
With Andi's clflush fixup, we were getting hangs on server exit, flushing the mappings after freeing each page helped. This showed up a race condition where the pages after being freed could be reused before the agp mappings had been flushed. Flushing after each single page is a bad thing for future drm work, so make the page destroy a two pass unmapping all the pages, flushing the mappings, and then destroying the pages. Signed-off-by: Dave Airlie <airlied@linux.ie> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'drivers/char/agp/ali-agp.c')
-rw-r--r--drivers/char/agp/ali-agp.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/drivers/char/agp/ali-agp.c b/drivers/char/agp/ali-agp.c
index 4941ddb78939..aa5ddb716ffb 100644
--- a/drivers/char/agp/ali-agp.c
+++ b/drivers/char/agp/ali-agp.c
@@ -156,29 +156,34 @@ static void *m1541_alloc_page(struct agp_bridge_data *bridge)
156 return addr; 156 return addr;
157} 157}
158 158
159static void ali_destroy_page(void * addr) 159static void ali_destroy_page(void * addr, int flags)
160{ 160{
161 if (addr) { 161 if (addr) {
162 global_cache_flush(); /* is this really needed? --hch */ 162 if (flags & AGP_PAGE_DESTROY_UNMAP) {
163 agp_generic_destroy_page(addr); 163 global_cache_flush(); /* is this really needed? --hch */
164 global_flush_tlb(); 164 agp_generic_destroy_page(addr, flags);
165 global_flush_tlb();
166 } else
167 agp_generic_destroy_page(addr, flags);
165 } 168 }
166} 169}
167 170
168static void m1541_destroy_page(void * addr) 171static void m1541_destroy_page(void * addr, int flags)
169{ 172{
170 u32 temp; 173 u32 temp;
171 174
172 if (addr == NULL) 175 if (addr == NULL)
173 return; 176 return;
174 177
175 global_cache_flush(); 178 if (flags & AGP_PAGE_DESTROY_UNMAP) {
179 global_cache_flush();
176 180
177 pci_read_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, &temp); 181 pci_read_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, &temp);
178 pci_write_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, 182 pci_write_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL,
179 (((temp & ALI_CACHE_FLUSH_ADDR_MASK) | 183 (((temp & ALI_CACHE_FLUSH_ADDR_MASK) |
180 virt_to_gart(addr)) | ALI_CACHE_FLUSH_EN)); 184 virt_to_gart(addr)) | ALI_CACHE_FLUSH_EN));
181 agp_generic_destroy_page(addr); 185 }
186 agp_generic_destroy_page(addr, flags);
182} 187}
183 188
184 189