Tomas Carnecky wrote:
Wow, there are a lot ifdefs in the code.Exactly what I was thinking when I saw the patch. ;) But I was too lazy to think for a solution. Thanks for doing that for me. :)
Here comes the result.
Cheers, Johannes
>From 36daa6eccb466164da7538ad7dd7d540ec0eb6b9 Mon Sep 17 00:00:00 2001 From: Johannes Engel <[EMAIL PROTECTED]> Date: Tue, 29 Jul 2008 22:17:04 +0100 Subject: [PATCH 1/1] Replace nopfn by fault This is necessary since kernel 2.6.27 will ship whithout nopfn. The method .fault is assumed to be present in kernels >= 2.6.23. Signed-off-by: Johannes Engel <[EMAIL PROTECTED]> --- linux-core/drm_compat.h | 11 +++++++++++ linux-core/drm_vm.c | 36 +++++++++++++++++++++++++++--------- 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/linux-core/drm_compat.h b/linux-core/drm_compat.h index 6e5d252..c5118bf 100644 --- a/linux-core/drm_compat.h +++ b/linux-core/drm_compat.h @@ -174,8 +174,19 @@ static __inline__ void *kcalloc(size_t nmemb, size_t size, int flags) #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21)) #define DRM_FULL_MM_COMPAT + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)) +#define DRM_HAS_FAULT +#define DRM_FAULT_SIGBUS VM_FAULT_SIGBUS +#define DRM_FAULT_OOM VM_FAULT_OOM +#define DRM_FAULT_NOPAGE VM_FAULT_NOPAGE +#else +#define DRM_FAULT_SIGBUS NOPFN_SIGBUS +#define DRM_FAULT_OOM NOPFN_OOM +#define DRM_FAULT_NOPAGE NOPFN_REFAULT #endif +#endif /* * Flush relevant caches and clear a VMA structure so that page references diff --git a/linux-core/drm_vm.c b/linux-core/drm_vm.c index 6618c0a..a0bd8bf 100644 --- a/linux-core/drm_vm.c +++ b/linux-core/drm_vm.c @@ -699,8 +699,13 @@ EXPORT_SYMBOL(drm_mmap); */ #ifdef DRM_FULL_MM_COMPAT +#ifdef DRM_HAS_FAULT +static int drm_bo_vm_fault(struct vm_area_struct *vma, + struct vm_fault *vmf) +#else static unsigned long drm_bo_vm_nopfn(struct vm_area_struct *vma, unsigned long address) +#endif { struct drm_buffer_object *bo = (struct drm_buffer_object *) vma->vm_private_data; unsigned long page_offset; @@ -712,25 +717,30 @@ static unsigned long drm_bo_vm_nopfn(struct vm_area_struct *vma, unsigned long bus_base; unsigned long bus_offset; unsigned long bus_size; - unsigned long ret = NOPFN_REFAULT; +#ifdef DRM_HAS_FAULT + unsigned long address = (unsigned long)vmf->virtual_address; + int ret = DRM_FAULT_NOPAGE; +#else + unsigned long ret = DRM_FAULT_NOPAGE; +#endif if (address > vma->vm_end) - return NOPFN_SIGBUS; + return DRM_FAULT_SIGBUS; dev = bo->dev; err = drm_bo_read_lock(&dev->bm.bm_lock, 1); if (err) - return NOPFN_REFAULT; + return DRM_FAULT_NOPAGE; err = mutex_lock_interruptible(&bo->mutex); if (err) { drm_bo_read_unlock(&dev->bm.bm_lock); - return NOPFN_REFAULT; + return DRM_FAULT_NOPAGE; } err = drm_bo_wait(bo, 0, 1, 0, 1); if (err) { - ret = (err != -EAGAIN) ? NOPFN_SIGBUS : NOPFN_REFAULT; + ret = (err != -EAGAIN) ? DRM_FAULT_SIGBUS : DRM_FAULT_NOPAGE; bo->priv_flags &= ~_DRM_BO_FLAG_UNLOCKED; goto out_unlock; } @@ -748,7 +758,7 @@ static unsigned long drm_bo_vm_nopfn(struct vm_area_struct *vma, DRM_BO_FLAG_FORCE_MAPPABLE; err = drm_bo_move_buffer(bo, new_flags, 0, 0); if (err) { - ret = (err != -EAGAIN) ? NOPFN_SIGBUS : NOPFN_REFAULT; + ret = (err != -EAGAIN) ? DRM_FAULT_SIGBUS : DRM_FAULT_NOPAGE; goto out_unlock; } } @@ -757,11 +767,15 @@ static unsigned long drm_bo_vm_nopfn(struct vm_area_struct *vma, &bus_size); if (err) { - ret = NOPFN_SIGBUS; + ret = DRM_FAULT_SIGBUS; goto out_unlock; } +#ifdef DRM_HAS_FAULT + page_offset = 0 >> PAGE_SHIFT; +#else page_offset = (address - vma->vm_start) >> PAGE_SHIFT; +#endif if (bus_size) { struct drm_mem_type_manager *man = &dev->bm.man[bo->mem.mem_type]; @@ -774,7 +788,7 @@ static unsigned long drm_bo_vm_nopfn(struct vm_area_struct *vma, drm_ttm_fixup_caching(ttm); page = drm_ttm_get_page(ttm, page_offset); if (!page) { - ret = NOPFN_OOM; + ret = DRM_FAULT_OOM; goto out_unlock; } pfn = page_to_pfn(page); @@ -785,7 +799,7 @@ static unsigned long drm_bo_vm_nopfn(struct vm_area_struct *vma, err = vm_insert_pfn(vma, address, pfn); if (err) { - ret = (err != -EAGAIN) ? NOPFN_OOM : NOPFN_REFAULT; + ret = (err != -EAGAIN) ? DRM_FAULT_OOM : DRM_FAULT_NOPAGE; goto out_unlock; } out_unlock: @@ -849,7 +863,11 @@ static void drm_bo_vm_close(struct vm_area_struct *vma) static struct vm_operations_struct drm_bo_vm_ops = { #ifdef DRM_FULL_MM_COMPAT +#ifdef DRM_HAS_FAULT + .fault = drm_bo_vm_fault, +#else .nopfn = drm_bo_vm_nopfn, +#endif #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) .nopfn = drm_bo_vm_nopfn, -- 1.5.4.5
------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/
-- _______________________________________________ Dri-devel mailing list Dri-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/dri-devel