Re: [igt-dev] [PATCH i-g-t 4/4] lib/igt_fb: Generalize the slow read from gtt mmap handling

Ville Syrjälä
2018-11-02T19:37:17Z

On Fri, Nov 02, 2018 at 07:32:02PM +0000, Chris Wilson wrote:
> Quoting Ville Syrjälä (2018-11-02 19:30:29)
> > On Fri, Nov 02, 2018 at 07:17:03PM +0000, Chris Wilson wrote:
> > > Quoting Ville Syrjala (2018-11-02 19:06:51)
> > > > +static void *convert_src_get(const struct fb_convert *cvt)
> > > > +{
> > > > + void *buf;
> > > > +
> > > > + if (!cvt->src.slow_reads)
> > > > + return cvt->src.ptr;
> > > > +
> > > > + /*
> > > > + * Reading from the BO is awfully slow because of lack of read caching,
> > > > + * it's faster to copy the whole BO to a temporary buffer and convert
> > > > + * from there.
> > > > + */
> > > > + buf = malloc(cvt->src.fb->size);
> > >
> > > if (!buf)
> > > return cvt->src.ptr;
> >
> > Sure, why not.
>
> The other choice being igt_assert(buf) or igt_xmalloc() :)

I figured the NULL ptr explosion is as good as an assert. But
since it's trivial to handle it gracefully let's do that.

--
Ville Syrjälä
Intel