Hi

Am 13.12.19 um 11:27 schrieb Daniel Vetter:
> On Thu, Dec 12, 2019 at 08:41:17AM +0100, Thomas Zimmermann wrote:
>> Drivers that what to allocate VRAM GEM objects with additional fields
>> can now do this by implementing struct drm_driver.gem_create_object.
>>
>> v2:
>>      * only cast to gbo within if branch; set gbo directly
>>        in else branch
>>
>> Signed-off-by: Thomas Zimmermann <[email protected]>
>> ---
>>  drivers/gpu/drm/drm_gem_vram_helper.c | 9 ++++++++-
>>  1 file changed, 8 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c 
>> b/drivers/gpu/drm/drm_gem_vram_helper.c
>> index b760fd27f3c0..baa49d1e9538 100644
>> --- a/drivers/gpu/drm/drm_gem_vram_helper.c
>> +++ b/drivers/gpu/drm/drm_gem_vram_helper.c
>> @@ -2,6 +2,7 @@
>>  
>>  #include <drm/drm_debugfs.h>
>>  #include <drm/drm_device.h>
>> +#include <drm/drm_drv.h>
>>  #include <drm/drm_file.h>
>>  #include <drm/drm_framebuffer.h>
>>  #include <drm/drm_gem_ttm_helper.h>
>> @@ -145,7 +146,13 @@ struct drm_gem_vram_object *drm_gem_vram_create(struct 
>> drm_device *dev,
>>      struct drm_gem_vram_object *gbo;
>>      int ret;
>>  
>> -    gbo = kzalloc(sizeof(*gbo), GFP_KERNEL);
>> +    if (dev->driver->gem_create_object) {
>> +            struct drm_gem_object *gem =
>> +                    dev->driver->gem_create_object(dev, size);
>> +            gbo = drm_gem_vram_of_gem(gem);
>> +    } else {
>> +            gbo = kzalloc(sizeof(*gbo), GFP_KERNEL);
>> +    }
>>      if (!gbo)
> 
> See my other mail, I'd move the check too into if/else blocks. ERR_PTR
> after an upcast is always a bit scary.

What a stupid mistake. I should have seen that myself. Will be fixed in
the next iteration.

Best regards
Thomas

> -Daniel
> 
>>              return ERR_PTR(-ENOMEM);
>>  
>> -- 
>> 2.24.0
>>
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reply via email to