Skip to content

Commit da503fa

Browse files
Jan Beulichairlied
authored andcommitted
agp: two-stage page destruction issue
besides it apparently being useful only in 2.6.24 (the changes in 2.6.25 really mean that it could be converted back to a single-stage mechanism), I'm seeing an issue in Xen Dom0 kernels, which is caused by the calling of gart_to_virt() in the second stage invocations of the destroy function. I think that besides this being a real issue with Xen (where unmap_page_from_agp() is not just a page table attribute change), this also is invalid from a theoretical perspective: One should not assume that gart_to_virt() is still valid after unmapping a page. So minimally (keeping the 2-stage mechanism) a patch like the one below would be needed. Jan Signed-off-by: Dave Airlie <airlied@redhat.com>
1 parent dcd981a commit da503fa

3 files changed

Lines changed: 17 additions & 12 deletions

File tree

‎drivers/char/agp/backend.c‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,10 @@ static int agp_backend_initialize(struct agp_bridge_data *bridge)
188188

189189
err_out:
190190
if (bridge->driver->needs_scratch_page) {
191-
bridge->driver->agp_destroy_page(gart_to_virt(bridge->scratch_page_real),
192-
AGP_PAGE_DESTROY_UNMAP);
193-
bridge->driver->agp_destroy_page(gart_to_virt(bridge->scratch_page_real),
194-
AGP_PAGE_DESTROY_FREE);
191+
void *va = gart_to_virt(bridge->scratch_page_real);
192+
193+
bridge->driver->agp_destroy_page(va, AGP_PAGE_DESTROY_UNMAP);
194+
bridge->driver->agp_destroy_page(va, AGP_PAGE_DESTROY_FREE);
195195
}
196196
if (got_gatt)
197197
bridge->driver->free_gatt_table(bridge);
@@ -215,10 +215,10 @@ static void agp_backend_cleanup(struct agp_bridge_data *bridge)
215215

216216
if (bridge->driver->agp_destroy_page &&
217217
bridge->driver->needs_scratch_page) {
218-
bridge->driver->agp_destroy_page(gart_to_virt(bridge->scratch_page_real),
219-
AGP_PAGE_DESTROY_UNMAP);
220-
bridge->driver->agp_destroy_page(gart_to_virt(bridge->scratch_page_real),
221-
AGP_PAGE_DESTROY_FREE);
218+
void *va = gart_to_virt(bridge->scratch_page_real);
219+
220+
bridge->driver->agp_destroy_page(va, AGP_PAGE_DESTROY_UNMAP);
221+
bridge->driver->agp_destroy_page(va, AGP_PAGE_DESTROY_FREE);
222222
}
223223
}
224224

‎drivers/char/agp/generic.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,13 @@ void agp_free_memory(struct agp_memory *curr)
202202
}
203203
if (curr->page_count != 0) {
204204
for (i = 0; i < curr->page_count; i++) {
205-
curr->bridge->driver->agp_destroy_page(gart_to_virt(curr->memory[i]), AGP_PAGE_DESTROY_UNMAP);
205+
curr->memory[i] = (unsigned long)gart_to_virt(curr->memory[i]);
206+
curr->bridge->driver->agp_destroy_page((void *)curr->memory[i],
207+
AGP_PAGE_DESTROY_UNMAP);
206208
}
207209
for (i = 0; i < curr->page_count; i++) {
208-
curr->bridge->driver->agp_destroy_page(gart_to_virt(curr->memory[i]), AGP_PAGE_DESTROY_FREE);
210+
curr->bridge->driver->agp_destroy_page((void *)curr->memory[i],
211+
AGP_PAGE_DESTROY_FREE);
209212
}
210213
}
211214
agp_free_key(curr->key);

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,9 +418,11 @@ static void intel_i810_free_by_type(struct agp_memory *curr)
418418
if (curr->page_count == 4)
419419
i8xx_destroy_pages(gart_to_virt(curr->memory[0]));
420420
else {
421-
agp_bridge->driver->agp_destroy_page(gart_to_virt(curr->memory[0]),
421+
void *va = gart_to_virt(curr->memory[0]);
422+
423+
agp_bridge->driver->agp_destroy_page(va,
422424
AGP_PAGE_DESTROY_UNMAP);
423-
agp_bridge->driver->agp_destroy_page(gart_to_virt(curr->memory[0]),
425+
agp_bridge->driver->agp_destroy_page(va,
424426
AGP_PAGE_DESTROY_FREE);
425427
}
426428
agp_free_page_array(curr);

0 commit comments

Comments
 (0)