From 10444e06d4f4edaf8e8cd9370f450ce7c047efac Mon Sep 17 00:00:00 2001 From: Leif Delgass Date: Tue, 8 Apr 2003 01:30:43 +0000 Subject: Use list_entry() to get container struct from struct list_head pointers. Build fix for RedHat 9 kernel (5 args to remap_page_range()). --- linux/Makefile.linux | 5 +++++ linux/drmP.h | 33 +++++++++++++++++++++------------ linux/drm_bufs.h | 2 +- linux/drm_context.h | 2 +- linux/drm_dma.h | 9 +++++---- linux/drm_ioctl.h | 2 +- linux/drm_os_linux.h | 47 +++++++++++++++++++++++------------------------ linux/drm_proc.h | 2 +- linux/drm_vm.h | 6 +++--- linux/gamma_dma.c | 4 ++-- linux/i810_dma.c | 2 +- linux/i830_dma.c | 2 +- 12 files changed, 65 insertions(+), 51 deletions(-) (limited to 'linux') diff --git a/linux/Makefile.linux b/linux/Makefile.linux index 065d6f62..63bec30d 100644 --- a/linux/Makefile.linux +++ b/linux/Makefile.linux @@ -144,6 +144,8 @@ AGP := $(shell gcc -E -nostdinc -I$(TREE) picker.c 2>/dev/null \ MACHINE := $(shell echo `uname -m`) # Red Hat's kernels have 4 args to do_munmap() DOMUNMAP := $(shell grep do_munmap $(TREE)/linux/mm.h | grep -c acct) +# Red Hat 9 kernel has 5 args to remap_page_range() +RPR := $(shell grep remap_page_range $(TREE)/linux/mm.h | grep -c vma) ifeq ($(AGP),0) AGP := $(shell gcc -E -nostdinc -I$(TREE) picker.c 2>/dev/null \ | grep -s 'AGP_MODULE = ' | cut -d' ' -f3) @@ -152,6 +154,9 @@ endif ifeq ($(DOMUNMAP),1) MODCFLAGS += -DDO_MUNMAP_4_ARGS endif +ifeq ($(RPR),1) +MODCFLAGS += -DREMAP_PAGE_RANGE_5_ARGS +endif ifeq ($(AGP),1) MODCFLAGS += -DCONFIG_AGP -DCONFIG_AGP_MODULE DRMTEMPLATES += drm_agpsupport.h diff --git a/linux/drmP.h b/linux/drmP.h index a6b32285..59a445ea 100644 --- a/linux/drmP.h +++ b/linux/drmP.h @@ -172,6 +172,15 @@ pos = n, n = pos->next) #endif +#ifndef list_for_each_entry +#define list_for_each_entry(pos, head, member) \ + for (pos = list_entry((head)->next, typeof(*pos), member), \ + prefetch(pos->member.next); \ + &pos->member != (head); \ + pos = list_entry(pos->member.next, typeof(*pos), member), \ + prefetch(pos->member.next)) +#endif + #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,19) static inline struct page * vmalloc_to_page(void * vmalloc_addr) { @@ -197,7 +206,7 @@ static inline struct page * vmalloc_to_page(void * vmalloc_addr) } #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) +#ifndef REMAP_PAGE_RANGE_5_ARGS /* #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) */ #define DRM_RPR_ARG(vma) #else #define DRM_RPR_ARG(vma) vma, @@ -249,17 +258,17 @@ static inline struct page * vmalloc_to_page(void * vmalloc_addr) DRM(ioremapfree)( (map)->handle, (map)->size ); \ } while (0) -#define DRM_FIND_MAP(_map, _o) \ -do { \ - struct list_head *_list; \ - list_for_each( _list, &dev->maplist->head ) { \ - drm_map_list_t *_entry = (drm_map_list_t *)_list; \ - if ( _entry->map && \ - _entry->map->offset == (_o) ) { \ - (_map) = _entry->map; \ - break; \ - } \ - } \ +#define DRM_FIND_MAP(_map, _o) \ +do { \ + struct list_head *_list; \ + list_for_each( _list, &dev->maplist->head ) { \ + drm_map_list_t *_entry = list_entry( _list, drm_map_list_t, head ); \ + if ( _entry->map && \ + _entry->map->offset == (_o) ) { \ + (_map) = _entry->map; \ + break; \ + } \ + } \ } while(0) #define DRM_DROP_MAP(_map) diff --git a/linux/drm_bufs.h b/linux/drm_bufs.h index b4e73699..b27987f1 100644 --- a/linux/drm_bufs.h +++ b/linux/drm_bufs.h @@ -211,7 +211,7 @@ int DRM(rmmap)(struct inode *inode, struct file *filp, down(&dev->struct_sem); list = &dev->maplist->head; list_for_each(list, &dev->maplist->head) { - r_list = (drm_map_list_t *) list; + r_list = list_entry(list, drm_map_list_t, head); if(r_list->map && r_list->map->handle == request.handle && diff --git a/linux/drm_context.h b/linux/drm_context.h index 39267b14..88b485ff 100644 --- a/linux/drm_context.h +++ b/linux/drm_context.h @@ -195,7 +195,7 @@ int DRM(setsareactx)(struct inode *inode, struct file *filp, down(&dev->struct_sem); list_for_each(list, &dev->maplist->head) { - r_list = (drm_map_list_t *)list; + r_list = list_entry(list, drm_map_list_t, head); if(r_list->map && r_list->map->handle == request.handle) goto found; diff --git a/linux/drm_dma.h b/linux/drm_dma.h index 4ea6b07d..71e25b3d 100644 --- a/linux/drm_dma.h +++ b/linux/drm_dma.h @@ -655,7 +655,7 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS ) * for the same vblank sequence number; nothing to be done in * that case */ - list_for_each( ( (struct list_head *) vbl_sig ), &dev->vbl_sigs.head ) { + list_for_each_entry( vbl_sig, &dev->vbl_sigs.head, head ) { if (vbl_sig->sequence == vblwait.request.sequence && vbl_sig->info.si_signo == vblwait.request.signal && vbl_sig->task == current) @@ -706,19 +706,20 @@ done: void DRM(vbl_send_signals)( drm_device_t *dev ) { - struct list_head *tmp; + struct list_head *list, *tmp; drm_vbl_sig_t *vbl_sig; unsigned int vbl_seq = atomic_read( &dev->vbl_received ); unsigned long flags; spin_lock_irqsave( &dev->vbl_lock, flags ); - list_for_each_safe( ( (struct list_head *) vbl_sig ), tmp, &dev->vbl_sigs.head ) { + list_for_each_safe( list, tmp, &dev->vbl_sigs.head ) { + vbl_sig = list_entry( list, drm_vbl_sig_t, head ); if ( ( vbl_seq - vbl_sig->sequence ) <= (1<<23) ) { vbl_sig->info.si_code = vbl_seq; send_sig_info( vbl_sig->info.si_signo, &vbl_sig->info, vbl_sig->task ); - list_del( (struct list_head *) vbl_sig ); + list_del( list ); DRM_FREE( vbl_sig, sizeof(*vbl_sig) ); diff --git a/linux/drm_ioctl.h b/linux/drm_ioctl.h index d753cce0..9b1069a1 100644 --- a/linux/drm_ioctl.h +++ b/linux/drm_ioctl.h @@ -205,7 +205,7 @@ int DRM(getmap)( struct inode *inode, struct file *filp, i = 0; list_for_each(list, &dev->maplist->head) { if(i == idx) { - r_list = (drm_map_list_t *)list; + r_list = list_entry(list, drm_map_list_t, head); break; } i++; diff --git a/linux/drm_os_linux.h b/linux/drm_os_linux.h index b57efd34..b760c169 100644 --- a/linux/drm_os_linux.h +++ b/linux/drm_os_linux.h @@ -47,9 +47,8 @@ #define DRM_GETSAREA() \ do { \ - struct list_head *list; \ - list_for_each( list, &dev->maplist->head ) { \ - drm_map_list_t *entry = (drm_map_list_t *)list; \ + drm_map_list_t *entry; \ + list_for_each_entry( entry, &dev->maplist->head, head ) { \ if ( entry->map && \ entry->map->type == _DRM_SHM && \ (entry->map->flags & _DRM_CONTAINS_LOCK) ) { \ @@ -61,28 +60,28 @@ do { \ #define DRM_HZ HZ -#define DRM_WAIT_ON( ret, queue, timeout, condition ) \ -do { \ - DECLARE_WAITQUEUE(entry, current); \ - unsigned long end = jiffies + (timeout); \ - add_wait_queue(&(queue), &entry); \ - \ - for (;;) { \ - current->state = TASK_INTERRUPTIBLE; \ - if (condition) \ - break; \ - if((signed)(end - jiffies) <= 0) { \ - ret = -EBUSY; \ - break; \ - } \ +#define DRM_WAIT_ON( ret, queue, timeout, condition ) \ +do { \ + DECLARE_WAITQUEUE(entry, current); \ + unsigned long end = jiffies + (timeout); \ + add_wait_queue(&(queue), &entry); \ + \ + for (;;) { \ + current->state = TASK_INTERRUPTIBLE; \ + if (condition) \ + break; \ + if((signed)(end - jiffies) <= 0) { \ + ret = -EBUSY; \ + break; \ + } \ schedule_timeout((HZ/100 > 1) ? HZ/100 : 1); \ - if (signal_pending(current)) { \ - ret = -EINTR; \ - break; \ - } \ - } \ - current->state = TASK_RUNNING; \ - remove_wait_queue(&(queue), &entry); \ + if (signal_pending(current)) { \ + ret = -EINTR; \ + break; \ + } \ + } \ + current->state = TASK_RUNNING; \ + remove_wait_queue(&(queue), &entry); \ } while (0) diff --git a/linux/drm_proc.h b/linux/drm_proc.h index 8524d204..5af8ddea 100644 --- a/linux/drm_proc.h +++ b/linux/drm_proc.h @@ -187,7 +187,7 @@ static int DRM(_vm_info)(char *buf, char **start, off_t offset, int request, "address mtrr\n\n"); i = 0; if (dev->maplist != NULL) list_for_each(list, &dev->maplist->head) { - r_list = (drm_map_list_t *)list; + r_list = list_entry(list, drm_map_list_t, head); map = r_list->map; if(!map) continue; if (map->type < 0 || map->type > 4) type = "??"; diff --git a/linux/drm_vm.h b/linux/drm_vm.h index 9101e136..76a10cf5 100644 --- a/linux/drm_vm.h +++ b/linux/drm_vm.h @@ -74,7 +74,7 @@ struct page *DRM(vm_nopage)(struct vm_area_struct *vma, if(!dev->agp || !dev->agp->cant_use_aperture) goto vm_nopage_error; list_for_each(list, &dev->maplist->head) { - r_list = (drm_map_list_t *)list; + r_list = list_entry(list, drm_map_list_t, head); map = r_list->map; if (!map) continue; if (map->offset == VM_OFFSET(vma)) break; @@ -190,7 +190,7 @@ void DRM(vm_shm_close)(struct vm_area_struct *vma) found_maps = 0; list = &dev->maplist->head; list_for_each(list, &dev->maplist->head) { - r_list = (drm_map_list_t *) list; + r_list = list_entry(list, drm_map_list_t, head); if (r_list->map == map) found_maps++; } @@ -393,7 +393,7 @@ int DRM(mmap)(struct file *filp, struct vm_area_struct *vma) list_for_each(list, &dev->maplist->head) { unsigned long off; - r_list = (drm_map_list_t *)list; + r_list = list_entry(list, drm_map_list_t, head); map = r_list->map; if (!map) continue; off = DRIVER_GET_MAP_OFS(); diff --git a/linux/gamma_dma.c b/linux/gamma_dma.c index a3c21d11..5b4d84bc 100644 --- a/linux/gamma_dma.c +++ b/linux/gamma_dma.c @@ -607,7 +607,7 @@ static int gamma_do_init_dma( drm_device_t *dev, drm_gamma_init_t *init ) memset( dev_priv, 0, sizeof(drm_gamma_private_t) ); list_for_each(list, &dev->maplist->head) { - drm_map_list_t *r_list = (drm_map_list_t *)list; + drm_map_list_t *r_list = list_entry(list, drm_map_list_t, head); if( r_list->map && r_list->map->type == _DRM_SHM && r_list->map->flags & _DRM_CONTAINS_LOCK ) { @@ -811,7 +811,7 @@ int gamma_setsareactx(struct inode *inode, struct file *filp, down(&dev->struct_sem); r_list = NULL; list_for_each(list, &dev->maplist->head) { - r_list = (drm_map_list_t *)list; + r_list = list_entry(list, drm_map_list_t, head); if(r_list->map && r_list->map->handle == request.handle) break; } diff --git a/linux/i810_dma.c b/linux/i810_dma.c index de9345e3..b0a1b6aa 100644 --- a/linux/i810_dma.c +++ b/linux/i810_dma.c @@ -347,7 +347,7 @@ static int i810_dma_initialize(drm_device_t *dev, memset(dev_priv, 0, sizeof(drm_i810_private_t)); list_for_each(list, &dev->maplist->head) { - drm_map_list_t *r_list = (drm_map_list_t *)list; + drm_map_list_t *r_list = list_entry(list, drm_map_list_t, head); if( r_list->map && r_list->map->type == _DRM_SHM && r_list->map->flags & _DRM_CONTAINS_LOCK ) { diff --git a/linux/i830_dma.c b/linux/i830_dma.c index 47f10d56..1018fdcb 100644 --- a/linux/i830_dma.c +++ b/linux/i830_dma.c @@ -370,7 +370,7 @@ static int i830_dma_initialize(drm_device_t *dev, memset(dev_priv, 0, sizeof(drm_i830_private_t)); list_for_each(list, &dev->maplist->head) { - drm_map_list_t *r_list = (drm_map_list_t *)list; + drm_map_list_t *r_list = list_entry(list, drm_map_list_t, head); if( r_list->map && r_list->map->type == _DRM_SHM && r_list->map->flags & _DRM_CONTAINS_LOCK ) { -- cgit v1.2.3