[Intel-gfx] [PATCH v4 37/38] drm: Improve drm_mm search (and fix topdown allocation) with rbtrees

Chris Wilson chris at chris-wilson.co.uk
Wed Dec 28 11:08:11 UTC 2016


On Thu, Dec 22, 2016 at 08:36:40AM +0000, Chris Wilson wrote:
>  /**
>   * drm_mm_for_each_hole - iterator to walk over all holes
>   * @entry: drm_mm_node used internally to track progress
> @@ -274,57 +263,27 @@ static inline u64 drm_mm_hole_node_end(const struct drm_mm_node *hole_node)
>   * Implementation Note:
>   * We need to inline list_for_each_entry in order to be able to set hole_start
>   * and hole_end on each iteration while keeping the macro sane.
> - *
> - * The __drm_mm_for_each_hole version is similar, but with added support for
> - * going backwards.
>   */
> -#define drm_mm_for_each_hole(entry, mm, hole_start, hole_end) \
> -	__drm_mm_for_each_hole(entry, mm, hole_start, hole_end, 0)
> +#define drm_mm_for_each_hole(pos, mm, hole_start, hole_end) \
> +	for (pos = list_first_entry(&(mm)->hole_stack, \
> +				    typeof(*pos), hole_stack); \
> +	     &pos->hole_stack != &(mm)->hole_stack ? \
> +	     hole_start = drm_mm_hole_node_start(pos), \
> +	     hole_end = hole_start + pos->hole_size : 0; \

Oh, that was silly, should be

	hole_end = hole_start + pos->hole_size, \
	1 : 0; \

so the compiler is less confused.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the Intel-gfx mailing list