On ma, 2016-12-12 at 11:53 +0000, Chris Wilson wrote: > Check that if we request top-down allocation with a particular alignment > from drm_mm_insert_node() that the start of the node matches our > request. > > Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> Assuming magic numbers be gone in next iteration. > +static int igt_topdown_align(void *ignored) > +{ > + struct drm_mm mm; > + struct drm_mm_node tmp, resv; > + int ret = -EINVAL; > + int n, m, err; > + > + drm_mm_init(&mm, 0, ~0ull); > + memset(&tmp, 0, sizeof(tmp)); > + memset(&resv, 0, sizeof(resv)); > + > + for (m = 0; m < 32; m++) { > + u64 end = ~0ull; > + > + if (m) { > + resv.size = BIT_ULL(m); > + end -= resv.size; > + resv.start = end; > + > + err = drm_mm_reserve_node(&mm, &resv); > + if (err) { > + pr_err("reservation of sentinel node failed\n"); > + ret = err; > + goto out; > + } > + } > + > + for (n = 0; n < 63 - m; n++) { > + u64 align = BIT_ULL(n); DRM_MM_BUG_ON(end % align); to protect somebody from modifying? (or end & (align - 1)) > + > + err = drm_mm_insert_node_generic(&mm, &tmp, 1, align, 0, > + DRM_MM_SEARCH_BELOW, > + DRM_MM_CREATE_TOP); > + drm_mm_remove_node(&tmp); Could move this after if (err) again and in the rest of the code, too. Reviewed-by: Joonas Lahtinen <joonas.lahtinen@xxxxxxxxxxxxxxx> Regards, Joonas -- Joonas Lahtinen Open Source Technology Center Intel Corporation _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx