Calculate the number of pages the GATT spans when reading from each page
to flush the TLB instead of hardcoding a size of 33 pages. Apertures of 32MB and 64MB only use a 16 page GATT and an aperture of 128MB only uses a 32 page GATT, so without this the code could walk off the end of the pointer and cause a page fault if the next page was unmapped. Also, for aperture sizes > 128MB, not all of the pages would be read. The Linux driver has the same bug. MFC after: 1 week Tested by: Frédéric PRACA frederic.praca of freebsd-fr.org
This commit is contained in:
parent
56315a2bc3
commit
1607c7dea2
@ -347,7 +347,7 @@ agp_nvidia_flush_tlb (device_t dev, int offset)
|
||||
struct agp_nvidia_softc *sc;
|
||||
u_int32_t wbc_reg, temp;
|
||||
volatile u_int32_t *ag_virtual;
|
||||
int i;
|
||||
int i, pages;
|
||||
|
||||
sc = (struct agp_nvidia_softc *)device_get_softc(dev);
|
||||
|
||||
@ -373,9 +373,10 @@ agp_nvidia_flush_tlb (device_t dev, int offset)
|
||||
ag_virtual = (volatile u_int32_t *)sc->gatt->ag_virtual;
|
||||
|
||||
/* Flush TLB entries. */
|
||||
for(i = 0; i < 32 + 1; i++)
|
||||
pages = sc->gatt->ag_entries * sizeof(u_int32_t) / PAGE_SIZE;
|
||||
for(i = 0; i < pages; i++)
|
||||
temp = ag_virtual[i * PAGE_SIZE / sizeof(u_int32_t)];
|
||||
for(i = 0; i < 32 + 1; i++)
|
||||
for(i = 0; i < pages; i++)
|
||||
temp = ag_virtual[i * PAGE_SIZE / sizeof(u_int32_t)];
|
||||
|
||||
return (0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user