[PATCH 1/5] drm/amdgpu: allow variable BO struct creation

Nirmoy nirmodas at amd.com
Fri Mar 5 14:48:33 UTC 2021


On 3/5/21 3:37 PM, Christian König wrote:
>
>
> Am 05.03.21 um 15:35 schrieb Nirmoy Das:
>> Allow allocating BO structures with different structure size
>> than struct amdgpu_bo.
>>
>> Signed-off-by: Nirmoy Das <nirmoy.das at amd.com>
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 2 ++
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 1 +
>>   2 files changed, 3 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c 
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
>> index 0bd22ed1dacf..745393472564 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
>> @@ -551,6 +551,8 @@ static int amdgpu_bo_do_create(struct 
>> amdgpu_device *adev,
>>         acc_size = ttm_bo_dma_acc_size(&adev->mman.bdev, size,
>>                          sizeof(struct amdgpu_bo));
>> +    if (bp->bo_ptr_size < sizeof(struct amdgpu_bo))
>> +        bp->bo_ptr_size = sizeof(struct amdgpu_bo);
>
> You should probably rather fix up all callers and make sure that the 
> parameter structure is correctly filled in.


Ok will resend with that change.


Thanks,

Nirmoy


>
> Christian.
>
>>         bo = kzalloc(sizeof(struct amdgpu_bo), GFP_KERNEL);
>>       if (bo == NULL)
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h 
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
>> index 8cd96c9330dd..848dc0a017dd 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
>> @@ -40,6 +40,7 @@
>>   struct amdgpu_bo_param {
>>       unsigned long            size;
>>       int                byte_align;
>> +    u32                bo_ptr_size;
>>       u32                domain;
>>       u32                preferred_domain;
>>       u64                flags;
>


More information about the amd-gfx mailing list