[igt-dev] [PATCH i-g-t v13 06/31] lib/intel_allocator: Add intel_allocator core

Chris Wilson chris at chris-wilson.co.uk
Mon Jan 11 12:06:05 UTC 2021


Quoting Zbigniew Kempczyński (2021-01-11 10:24:47)
> +static struct intel_allocator *allocator_open(int fd, uint32_t ctx,
> +                                             uint8_t allocator_type)
> +{
> +       struct intel_allocator *ial;
> +
> +       pthread_mutex_lock(&map_mutex);
> +
> +       ial = __allocator_get(fd, ctx);
> +       if (ial) {
> +               if (ial->type != allocator_type)
> +                       pthread_mutex_unlock(&map_mutex);
> +               igt_assert_f(ial->type == allocator_type,
> +                            "Allocator must be same type for fd/ctx\n");
> +       } else {
> +               alloc_debug("Allocator fd: %d, ctx: %u not found, creating one\n",
> +                           fd, ctx);
> +               ial = intel_allocator_create(fd, ctx, allocator_type);
> +       }
> +
> +       pthread_mutex_unlock(&map_mutex);

       pthread_mutex_lock(&map_mutex);

       ial = __allocator_get(fd, ctx);
       if (!ial) {
               alloc_debug("Allocator fd: %d, ctx: %u not found, creating one\n",
                           fd, ctx);
               ial = intel_allocator_create(fd, ctx, allocator_type);
       }

       pthread_mutex_unlock(&map_mutex);
       igt_assert_f(ial->type == allocator_type,
		    "Allocator must be same type for fd/ctx, ial->type:%d, requested:%d\n",
		    ial->type, allocator_type);

> +
> +       return ial;
> +}


More information about the igt-dev mailing list