On pe, 2016-12-09 at 13:08 +0000, Chris Wilson wrote:
> Check that we can request alignment to any power-of-two or prime using a
> plain drm_mm_node_insert().
> 
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

<SNIP>

> +static int igt_align(void *ignored)
> +{
> +     struct drm_mm mm;
> +     struct drm_mm_node *node, *next;
> +     int ret = -EINVAL;
> +     int n;
> +
> +     drm_mm_init(&mm, 1, -2);

U64_MAX - 1?

> +     if (!drm_mm_clean(&mm)) {
> +             pr_err("mm not empty on creation\n");
> +             goto out;
> +     }
> +

Can be dropped.

> +     for_each_prime(n, 8192) {

This is one more spot, how about DRM_SELFTEST_MAX_PRIME or so?

> +             int err;
> +
> +             node = kzalloc(sizeof(*node), GFP_KERNEL);
> +             if (!node) {
> +                     ret = -ENOMEM;
> +                     goto out;
> +             }
> +
> +             err = drm_mm_insert_node_generic(&mm, node,
> +                                              next_prime_number(n),/* size 
> */
> +                                              n, /* alignment */

<rant>If there just was a way of naming variables so this comments was
not needed.</rant> Maybe the variable could be "align".

> +static int igt_align_pot(int max)
> +{
> +     struct drm_mm mm;
> +     struct drm_mm_node *node, *next;
> +     int bit;
> +     int ret = -EINVAL;
> +
> +     drm_mm_init(&mm, 1, -2);
> +     if (!drm_mm_clean(&mm)) {
> +             pr_err("mm not empty on creation\n");
> +             goto out;
> +     }
> +
> +     for (bit = max - 1; bit; bit--) {
> +             int err;
> +
> +             node = kzalloc(sizeof(*node), GFP_KERNEL);
> +             if (!node) {
> +                     ret = -ENOMEM;
> +                     goto out;
> +             }
> +
> +             err = drm_mm_insert_node_generic(&mm, node, 1,
> +                                              BIT_ULL(bit), bit,

The color is not used, so just set it to 0.

Reviewed-by: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>

Regards, Joonas
-- 
Joonas Lahtinen
Open Source Technology Center
Intel Corporation

Reply via email to