[Intel-gfx] [PATCH 30/34] drm: Optimise power-of-two alignments in drm_mm_scan_add_block()
Joonas Lahtinen
joonas.lahtinen at linux.intel.com
Tue Dec 13 15:55:37 UTC 2016
On ma, 2016-12-12 at 11:53 +0000, Chris Wilson wrote:
> For power-of-two alignments, we can avoid the 64bit divide and do a
> simple bitwise add instead.
>
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> ---
> drivers/gpu/drm/drm_mm.c | 9 ++++++++-
> include/drm/drm_mm.h | 1 +
> 2 files changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c
> index eec0a46f5b38..7245483f1111 100644
> --- a/drivers/gpu/drm/drm_mm.c
> +++ b/drivers/gpu/drm/drm_mm.c
> @@ -741,8 +741,12 @@ void drm_mm_scan_init_with_range(struct drm_mm_scan *scan,
>
> scan->mm = mm;
>
> + if (alignment <= 1)
> + alignment = 0;
> +
> scan->color = color;
> scan->alignment = alignment;
> + scan->alignment_mask = is_power_of_2(alignment) ? alignment - 1 : 0;
One would assume alignment_mask to be the bit-opposite, really.
reminder_mask should describe it better.
And sprinkle a likely() for the POT case, because I think that's
something to expect.
With above comments;
Reviewed-by: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>
Regards, Joonas
--
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
More information about the Intel-gfx
mailing list