From 5af87acbc2025b9f72d51b30f176e9c3909695ac Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 1 May 2008 14:20:44 -0700 Subject: checkpoint: gtt binding written. --- linux-core/drm_agpsupport.c | 47 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'linux-core/drm_agpsupport.c') diff --git a/linux-core/drm_agpsupport.c b/linux-core/drm_agpsupport.c index 0aa94a75..b37d6d9d 100644 --- a/linux-core/drm_agpsupport.c +++ b/linux-core/drm_agpsupport.c @@ -484,6 +484,53 @@ int drm_agp_unbind_memory(DRM_AGP_MEM * handle) return agp_unbind_memory(handle); } +/** + * Binds a collection of pages into AGP memory at the given offset, returning + * the AGP memory structure containing them. + * + * No reference is held on the pages during this time -- it is up to the + * caller to handle that. + */ +DRM_AGP_MEM * +drm_agp_bind_pages(struct drm_device *dev, + struct page **pages, + unsigned long num_pages, + uint32_t gtt_offset) +{ + struct page **cur_page, **last_page = pages + num_pages; + DRM_AGP_MEM *mem; + int ret; + + DRM_DEBUG("drm_agp_populate_ttm\n"); +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11) + mem = drm_agp_allocate_memory(num_pages, AGP_USER_MEMORY); +#else + mem = drm_agp_allocate_memory(dev->agp->bridge, num_pages, + AGP_USER_MEMORY); +#endif + if (mem == NULL) { + DRM_ERROR("Failed to allocate memory for %ld pages\n", + num_pages); + return NULL; + } + + mem->page_count = 0; + for (cur_page = pages; cur_page < last_page; ++cur_page) { + struct page *page = *cur_page; + + mem->memory[mem->page_count++] = + phys_to_gart(page_to_phys(page)); + } + + mem->is_flushed = TRUE; + ret = drm_agp_bind_memory(mem, gtt_offset); + if (ret != 0) { + agp_free_memory(mem); + return NULL; + } + + return mem; +} /* -- cgit v1.2.3 From ccd1bae0f676490a88240c62f02e072d2cf3b030 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 1 May 2008 15:22:21 -0700 Subject: checkpoint: relocations support. --- linux-core/drm_agpsupport.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'linux-core/drm_agpsupport.c') diff --git a/linux-core/drm_agpsupport.c b/linux-core/drm_agpsupport.c index b37d6d9d..15400386 100644 --- a/linux-core/drm_agpsupport.c +++ b/linux-core/drm_agpsupport.c @@ -493,9 +493,9 @@ int drm_agp_unbind_memory(DRM_AGP_MEM * handle) */ DRM_AGP_MEM * drm_agp_bind_pages(struct drm_device *dev, - struct page **pages, - unsigned long num_pages, - uint32_t gtt_offset) + struct page **pages, + unsigned long num_pages, + uint32_t gtt_offset) { struct page **cur_page, **last_page = pages + num_pages; DRM_AGP_MEM *mem; @@ -531,7 +531,7 @@ drm_agp_bind_pages(struct drm_device *dev, return mem; } - +EXPORT_SYMBOL(drm_agp_bind_pages); /* * AGP ttm backend interface. -- cgit v1.2.3 From ddc80651d561ef3820e205255f34dc7c60dc2e7c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 1 May 2008 17:31:29 -0700 Subject: Fix offset passed to AGP to be pages instead of bytes. Fix some utterly bonged loop while we were staring at it. --- linux-core/drm_agpsupport.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'linux-core/drm_agpsupport.c') diff --git a/linux-core/drm_agpsupport.c b/linux-core/drm_agpsupport.c index 15400386..d6594b87 100644 --- a/linux-core/drm_agpsupport.c +++ b/linux-core/drm_agpsupport.c @@ -497,9 +497,8 @@ drm_agp_bind_pages(struct drm_device *dev, unsigned long num_pages, uint32_t gtt_offset) { - struct page **cur_page, **last_page = pages + num_pages; DRM_AGP_MEM *mem; - int ret; + int ret, i; DRM_DEBUG("drm_agp_populate_ttm\n"); #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11) @@ -514,17 +513,14 @@ drm_agp_bind_pages(struct drm_device *dev, return NULL; } - mem->page_count = 0; - for (cur_page = pages; cur_page < last_page; ++cur_page) { - struct page *page = *cur_page; - - mem->memory[mem->page_count++] = - phys_to_gart(page_to_phys(page)); - } + for (i = 0; i < num_pages; i++) + mem->memory[i] = phys_to_gart(page_to_phys(pages[i])); + mem->page_count = num_pages; 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) { + DRM_ERROR("Failed to bind AGP memory: %d\n", ret); agp_free_memory(mem); return NULL; } -- cgit v1.2.3