diff options
Diffstat (limited to 'linux-core')
| -rw-r--r-- | linux-core/Makefile.kernel | 2 | ||||
| -rw-r--r-- | linux-core/drmP.h | 4 | ||||
| -rw-r--r-- | linux-core/drm_memrange.c | 25 | 
3 files changed, 30 insertions, 1 deletions
| diff --git a/linux-core/Makefile.kernel b/linux-core/Makefile.kernel index 5b309bc1..97d53622 100644 --- a/linux-core/Makefile.kernel +++ b/linux-core/Makefile.kernel @@ -20,7 +20,7 @@ r128-objs   := r128_drv.o r128_cce.o r128_state.o r128_irq.o  mga-objs    := mga_drv.o mga_dma.o mga_state.o mga_warp.o mga_irq.o  i810-objs   := i810_drv.o i810_dma.o  i915-objs   := i915_drv.o i915_dma.o i915_irq.o i915_mem.o i915_fence.o \ -		i915_buffer.o i915_compat.o i915_execbuf.o +		i915_buffer.o i915_compat.o i915_execbuf.o i915_mm.o  nouveau-objs := nouveau_drv.o nouveau_state.o nouveau_fifo.o nouveau_mem.o \  		nouveau_object.o nouveau_irq.o nouveau_notifier.o nouveau_swmthd.o \  		nouveau_sgdma.o nouveau_dma.o nouveau_bo.o nouveau_fence.o \ diff --git a/linux-core/drmP.h b/linux-core/drmP.h index 29dd4321..113cbecb 100644 --- a/linux-core/drmP.h +++ b/linux-core/drmP.h @@ -1278,6 +1278,10 @@ extern int drm_memrange_remove_space_from_tail(struct drm_memrange *mm,  					       unsigned long size);  extern int drm_memrange_add_space_to_tail(struct drm_memrange *mm,  					  unsigned long size); +extern int drm_memrange_for_each(struct drm_memrange *mm, +				 int (*callback)(struct drm_memrange_node *node, +						 void *data), +				 void *data);  static inline struct drm_memrange *drm_get_mm(struct drm_memrange_node *block)  { diff --git a/linux-core/drm_memrange.c b/linux-core/drm_memrange.c index 0ae03655..e1d2233b 100644 --- a/linux-core/drm_memrange.c +++ b/linux-core/drm_memrange.c @@ -273,6 +273,31 @@ int drm_memrange_init(struct drm_memrange * mm, unsigned long start, unsigned lo  	return drm_memrange_create_tail_node(mm, start, size);  } +/** + * Walks the list of allocated memory ranges and calls the callback on + * one. + */ +int drm_memrange_for_each(struct drm_memrange *mm, +			  int (*callback)(struct drm_memrange_node *node, +					  void *data), +			  void *data) +{ +	struct list_head *list, *next; + +	list_for_each_safe(list, next, &mm->ml_entry) { +		struct drm_memrange_node *cur; +		int ret; + +		cur = list_entry(list, struct drm_memrange_node, ml_entry); + +		ret = callback(cur, data); +		if (ret != 0) +			return ret; +	} + +	return 0; +} +  EXPORT_SYMBOL(drm_memrange_init);  void drm_memrange_takedown(struct drm_memrange * mm) | 
