On Fri, Dec 16, 2016 at 04:02:12PM +0200, Joonas Lahtinen wrote: > On pe, 2016-12-16 at 07:46 +0000, Chris Wilson wrote: > > Exercise drm_mm_insert_node(), check that we can't overfill a range and > > that the lists are correct after reserving/removing. > > > > v2: Extract helpers for the repeated tests > > v3: Iterate over all allocation flags > > > > Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> > > <SNIP> > > > +static u64 misaligned(struct drm_mm_node *node, u64 alignment) > > I'm not sure if 'misalignment' would be better name or not. This makes > me think of bool returning one. > > > +static bool expect_insert_fail(struct drm_mm *mm, u64 size) > > +{ > > + struct drm_mm_node tmp = {}; > > + int err; > > + > > + err = drm_mm_insert_node(mm, &tmp, size, 0, DRM_MM_SEARCH_DEFAULT); > > + if (err != -ENOSPC) { > > For speed (this function gets called a lot); > > if (likely(err == -ENOSPC)) > return true; > > > +static int __igt_insert(unsigned int count, u64 size) > > +{ > > <SNIP> > > > > > + for (mode = insert_modes; mode->name; mode++) { > > + for (n = 0; n < count; n++) { > > + node = &nodes[n]; > > + err = drm_mm_insert_node_generic(&mm, node, size, 0, n, > > + mode->search_flags, > > + mode->create_flags); > > + if (err || !assert_node(node, &mm, size, 0, n)) { > > + pr_err("%s insert failed, size %llu step %d\n", > > + mode->name, size, n); > > + ret = err ?: -EINVAL; > > + goto out; > > + } > > This construct is three times in this patch; Could be > expect_insert_generic? In this patch alone, indeed it gets used again and again. I resisted making it an insert and check function simply because I didn't want to fall into the trap of using it everywhere and so missing out exercising drm_mm_insert_node and friends. However, 3 occurences of the same in one patch... -Chris -- Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx