[Mesa-dev] [PATCH 2/3] nvc0: check return value of nvc0_screen_resize_tls_area()

Samuel Pitoiset samuel.pitoiset at gmail.com
Tue Aug 30 16:30:20 UTC 2016



On 08/30/2016 04:53 PM, Ilia Mirkin wrote:
> On Tue, Aug 30, 2016 at 10:45 AM, Samuel Pitoiset
> <samuel.pitoiset at gmail.com> wrote:
>> While we are at it, make it static and change the return values
>> policy to be consistent.
>>
>> Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
>> ---
>>  src/gallium/drivers/nouveau/nvc0/nvc0_screen.c | 16 ++++++++--------
>>  src/gallium/drivers/nouveau/nvc0/nvc0_screen.h |  3 ---
>>  2 files changed, 8 insertions(+), 11 deletions(-)
>>
>> diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
>> index b5be71a..abf2d0f 100644
>> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
>> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
>> @@ -671,7 +671,7 @@ nvc0_screen_init_compute(struct nvc0_screen *screen)
>>     }
>>  }
>>
>> -bool
>> +static int
>>  nvc0_screen_resize_tls_area(struct nvc0_screen *screen,
>>                              uint32_t lpos, uint32_t lneg, uint32_t cstack)
>>  {
>> @@ -681,7 +681,7 @@ nvc0_screen_resize_tls_area(struct nvc0_screen *screen,
>>
>>     if (size >= (1 << 20)) {
>>        NOUVEAU_ERR("requested TLS size too large: 0x%"PRIx64"\n", size);
>> -      return false;
>> +      return 1;
>
> It's more common to return -1 on error.
>
>>     }
>>
>>     size *= (screen->base.device->chipset >= 0xe0) ? 64 : 48; /* max warps */
>> @@ -692,13 +692,11 @@ nvc0_screen_resize_tls_area(struct nvc0_screen *screen,
>>
>>     ret = nouveau_bo_new(screen->base.device, NV_VRAM_DOMAIN(&screen->base), 1 << 17, size,
>>                          NULL, &bo);
>> -   if (ret) {
>> -      NOUVEAU_ERR("failed to allocate TLS area, size: 0x%"PRIx64"\n", size);
>> -      return false;
>> -   }
>> +   if (ret)
>> +      return 1;

Just noticed that it should be better to return ret instead.

Thanks for the review.

>>     nouveau_bo_ref(NULL, &screen->tls);
>>     screen->tls = bo;
>> -   return true;
>> +   return 0;
>>  }
>>
>>  #define FAIL_SCREEN_INIT(str, err)                    \
>> @@ -1040,7 +1038,9 @@ nvc0_screen_create(struct nouveau_device *dev)
>>     screen->mp_count = value >> 8;
>>     screen->mp_count_compute = screen->mp_count;
>>
>> -   nvc0_screen_resize_tls_area(screen, 128 * 16, 0, 0x200);
>> +   ret = nvc0_screen_resize_tls_area(screen, 128 * 16, 0, 0x200);
>> +   if (ret)
>> +      FAIL_SCREEN_INIT("Error allocating TLS area: %d\n", ret);
>>
>>     BEGIN_NVC0(push, NVC0_3D(CODE_ADDRESS_HIGH), 2);
>>     PUSH_DATAh(push, screen->text->offset);
>> diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h
>> index 4a89794..672d515 100644
>> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h
>> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h
>> @@ -136,9 +136,6 @@ int nvc0_screen_tsc_alloc(struct nvc0_screen *, void *);
>>  int nve4_screen_compute_setup(struct nvc0_screen *, struct nouveau_pushbuf *);
>>  int nvc0_screen_compute_setup(struct nvc0_screen *, struct nouveau_pushbuf *);
>>
>> -bool nvc0_screen_resize_tls_area(struct nvc0_screen *, uint32_t lpos,
>> -                                 uint32_t lneg, uint32_t cstack);
>> -
>>  static inline void
>>  nvc0_resource_fence(struct nv04_resource *res, uint32_t flags)
>>  {
>> --
>> 2.9.3
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list