Fix offset passed to AGP to be pages instead of bytes.

Fix some utterly bonged loop while we were staring at it.
This commit is contained in:
Eric Anholt 2008-05-01 17:31:29 -07:00
parent 3f641b56c7
commit ddc80651d5

View file

@ -497,9 +497,8 @@ drm_agp_bind_pages(struct drm_device *dev,
unsigned long num_pages, unsigned long num_pages,
uint32_t gtt_offset) uint32_t gtt_offset)
{ {
struct page **cur_page, **last_page = pages + num_pages;
DRM_AGP_MEM *mem; DRM_AGP_MEM *mem;
int ret; int ret, i;
DRM_DEBUG("drm_agp_populate_ttm\n"); DRM_DEBUG("drm_agp_populate_ttm\n");
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11) #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11)
@ -514,17 +513,14 @@ drm_agp_bind_pages(struct drm_device *dev,
return NULL; return NULL;
} }
mem->page_count = 0; for (i = 0; i < num_pages; i++)
for (cur_page = pages; cur_page < last_page; ++cur_page) { mem->memory[i] = phys_to_gart(page_to_phys(pages[i]));
struct page *page = *cur_page; mem->page_count = num_pages;
mem->memory[mem->page_count++] =
phys_to_gart(page_to_phys(page));
}
mem->is_flushed = TRUE; mem->is_flushed = TRUE;
ret = drm_agp_bind_memory(mem, gtt_offset); ret = drm_agp_bind_memory(mem, gtt_offset / PAGE_SIZE);
if (ret != 0) { if (ret != 0) {
DRM_ERROR("Failed to bind AGP memory: %d\n", ret);
agp_free_memory(mem); agp_free_memory(mem);
return NULL; return NULL;
} }