[Intel-gfx] [i-g-t PATCH v1 08/14] lib: Add igt_create_bo_with_dimensions

Tomeu Vizoso tomeu.vizoso at collabora.com
Thu Nov 10 13:17:03 UTC 2016


On 1 November 2016 at 16:44, Tvrtko Ursulin <tursulin at ursulin.net> wrote:
>
> Hi,
>
>
>
> On 02/03/16 14:00, Tomeu Vizoso wrote:
>>
>> igt_create_bo_with_dimensions() is intended to abstract differences
>> between drivers in buffer object creation.
>>
>> The driver-specific ioctls will be called if the driver that is being
>> tested can satisfy the needs of the calling subtest, or it will be
>> skipped otherwise.
>>
>> Signed-off-by: Tomeu Vizoso <tomeu.vizoso at collabora.com>
>> ---
>>
>>  lib/igt_fb.c | 83
>> ++++++++++++++++++++++++++++++++++++++++++------------------
>>  lib/igt_fb.h |  6 +++++
>>  2 files changed, 65 insertions(+), 24 deletions(-)
>>
>> diff --git a/lib/igt_fb.c b/lib/igt_fb.c
>> index cd1605308308..0a3526f4e4ea 100644
>> --- a/lib/igt_fb.c
>> +++ b/lib/igt_fb.c
>> @@ -174,30 +174,66 @@ void igt_calc_fb_size(int fd, int width, int height,
>> int bpp, uint64_t tiling,
>>         *size_ret = size;
>>  }
>>
>> +int igt_create_bo_with_dimensions(int fd, int width, int height,
>> +                                 uint32_t format, uint64_t modifier,
>> +                                 unsigned stride, unsigned *size_ret,
>> +                                 unsigned *stride_ret, bool *is_dumb)
>> +{
>> +       int bpp = igt_drm_format_to_bpp(format);
>> +       int bo;
>> +
>> +       igt_assert((modifier && stride) || (!modifier && !stride));
>> +
>> +       if (modifier) {
>> +               unsigned size, calculated_stride;
>> +
>> +               igt_calc_fb_size(fd, width, height, bpp, modifier, &size,
>> +                                &calculated_stride);
>> +               if (stride == 0)
>> +                       stride = calculated_stride;
>> +
>> +               if (is_dumb)
>> +                       *is_dumb = false;
>> +
>> +               if (is_i915_device(fd)) {
>> +
>> +                       bo = gem_create(fd, size);
>> +                       gem_set_tiling(fd, bo, modifier, stride);
>
>
> This is broken, gem_set_tiling does not take a fb modifier but an object
> tiling mode.
>
> You can demonstrate the failure if you got a Skylake system with:
>
> tests/kms_flip_tiling --r flip-changes-tiling-Yf

Hi,

that subtest fails occasionally here due to CRC issues, but the one
that fails due to the tiling constant passed to gem_set_tiling is
flip-Yf-tiled.

Have fixed it by converting the modifier to a tiling mode, but I also
needed to make sure that we don't pass to the kernel the Yf or Ys
constants as the kernel doesn't know about those.

Both fixes have been pushed already.

> I would like to be able to tell you that all subtests there should pass,
> since they have been at some point, but I have a feeling that there are
> other breakages affecting it these days. :(

Yeah, at least I can say that they are passing now in this particular
machine (i3-6100U).

To make such issues less likely in the future, I have sent a patch
that makes clear when a variable contains a fb modifier constant, and
when a tiling mode. Haven't pushed it because I'm not 100% sure it's
worth it, so I would appreciate any opinions.

Thanks,

Tomeu

> Regards,
>
> Tvrtko
>
>
>
>> +
>> +                       if (size_ret)
>> +                               *size_ret = size;
>> +
>> +                       if (stride_ret)
>> +                               *stride_ret = stride;
>> +
>> +                       return bo;
>> +               } else {
>> +                       bool driver_has_tiling_support = false;
>> +
>> +                       igt_require(driver_has_tiling_support);
>> +                       return -EINVAL;
>> +               }
>> +       } else {
>> +               if (is_dumb)
>> +                       *is_dumb = true;
>> +               return dumb_create(fd, width, height, bpp, stride_ret,
>> size_ret);
>> +       }
>> +}
>> +
>>  /* helpers to create nice-looking framebuffers */
>> -static int create_bo_for_fb(int fd, int width, int height, int bpp,
>> +static int create_bo_for_fb(int fd, int width, int height, uint32_t
>> format,
>>                             uint64_t tiling, unsigned bo_size,
>>                             unsigned bo_stride, uint32_t *gem_handle_ret,
>> -                           unsigned *size_ret, unsigned *stride_ret)
>> +                           unsigned *size_ret, unsigned *stride_ret,
>> +                           bool *is_dumb)
>>  {
>>         uint32_t gem_handle;
>>         int ret = 0;
>> -       unsigned size, stride;
>> -
>> -       igt_calc_fb_size(fd, width, height, bpp, tiling, &size, &stride);
>> -       if (bo_size == 0)
>> -               bo_size = size;
>> -       if (bo_stride == 0)
>> -               bo_stride = stride;
>> -
>> -       gem_handle = gem_create(fd, bo_size);
>>
>> -       if (tiling == LOCAL_I915_FORMAT_MOD_X_TILED)
>> -               ret = __gem_set_tiling(fd, gem_handle, I915_TILING_X,
>> -                                      bo_stride);
>> +       gem_handle = igt_create_bo_with_dimensions(fd, width, height,
>> format,
>> +                                                  tiling, bo_stride,
>> size_ret,
>> +                                                  stride_ret, is_dumb);
>>
>> -       *stride_ret = bo_stride;
>> -       *size_ret = bo_size;
>>         *gem_handle_ret = gem_handle;
>>
>>         return ret;
>> @@ -501,17 +537,14 @@ igt_create_fb_with_bo_size(int fd, int width, int
>> height,
>>                            unsigned bo_stride)
>>  {
>>         uint32_t fb_id;
>> -       int bpp;
>>
>>         memset(fb, 0, sizeof(*fb));
>>
>> -       bpp = igt_drm_format_to_bpp(format);
>> -
>> -       igt_debug("%s(width=%d, height=%d, format=0x%x [bpp=%d],
>> tiling=0x%"PRIx64", size=%d)\n",
>> -                 __func__, width, height, format, bpp, tiling, bo_size);
>> -       do_or_die(create_bo_for_fb(fd, width, height, bpp, tiling,
>> bo_size,
>> +       igt_debug("%s(width=%d, height=%d, format=0x%x,
>> tiling=0x%"PRIx64", size=%d)\n",
>> +                 __func__, width, height, format, tiling, bo_size);
>> +       do_or_die(create_bo_for_fb(fd, width, height, format, tiling,
>> bo_size,
>>                                    bo_stride, &fb->gem_handle, &fb->size,
>> -                                  &fb->stride));
>> +                                  &fb->stride, &fb->is_dumb));
>>
>>         igt_debug("%s(handle=%d, pitch=%d)\n",
>>                   __func__, fb->gem_handle, fb->stride);
>> @@ -860,6 +893,7 @@ struct fb_blit_upload {
>>                 uint32_t handle;
>>                 unsigned size, stride;
>>                 uint8_t *map;
>> +               bool is_dumb;
>>         } linear;
>>  };
>>
>> @@ -928,7 +962,8 @@ static void create_cairo_surface__blit(int fd, struct
>> igt_fb *fb)
>>                                 LOCAL_DRM_FORMAT_MOD_NONE, 0, 0,
>>                                 &blit->linear.handle,
>>                                 &blit->linear.size,
>> -                               &blit->linear.stride);
>> +                               &blit->linear.stride,
>> +                               &blit->linear.is_dumb);
>>
>>         igt_assert(ret == 0);
>>
>> diff --git a/lib/igt_fb.h b/lib/igt_fb.h
>> index 4e6a76947c18..10e59deebe88 100644
>> --- a/lib/igt_fb.h
>> +++ b/lib/igt_fb.h
>> @@ -47,6 +47,7 @@ typedef struct _cairo cairo_t;
>>  struct igt_fb {
>>         uint32_t fb_id;
>>         uint32_t gem_handle;
>> +       bool is_dumb;
>>         uint32_t drm_format;
>>         int width;
>>         int height;
>> @@ -97,6 +98,11 @@ unsigned int igt_create_stereo_fb(int drm_fd,
>> drmModeModeInfo *mode,
>>                                   uint32_t format, uint64_t tiling);
>>  void igt_remove_fb(int fd, struct igt_fb *fb);
>>
>> +int igt_create_bo_with_dimensions(int fd, int width, int height, uint32_t
>> format,
>> +                                 uint64_t modifier, unsigned stride,
>> +                                 unsigned *stride_out, unsigned
>> *size_out,
>> +                                 bool *is_dumb);
>> +
>>  /* cairo-based painting */
>>  cairo_t *igt_get_cairo_ctx(int fd, struct igt_fb *fb);
>>  void igt_paint_color(cairo_t *cr, int x, int y, int w, int h,
>>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx


More information about the Intel-gfx mailing list