[PATCH 10/18] drm/amdgpu: add ip block with instance

Boyuan Zhang Boyuan.Zhang at amd.com
Fri Oct 4 18:44:26 UTC 2024


On 2024-10-02 13:32, Alex Deucher wrote:
> On Wed, Oct 2, 2024 at 12:39 AM <boyuan.zhang at amd.com> wrote:
>> From: Boyuan Zhang <boyuan.zhang at amd.com>
>>
>> Add instance number to ip block to track which instance the ip block
>> belongs to.
>>
>> Also, add a new function to allow ip block to save the instance number
>> along with other ip block driver information.
>>
>> Signed-off-by: Boyuan Zhang <boyuan.zhang at amd.com>
> I think the logic can be added to the existing
> amdgpu_device_ip_block_add().  Something like the attached patch.
>
> Alex


Thanks for the suggestion. And yes, this is a much smarter way =)

Applied in the new v2 patch set.

Regards,
Boyuan


>
>
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  5 +++
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 39 ++++++++++++++++++++++
>>   2 files changed, 44 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
>> index 84a9749dcd7d..d77db73c71f7 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
>> @@ -386,6 +386,7 @@ struct amdgpu_ip_block {
>>          struct amdgpu_ip_block_status status;
>>          const struct amdgpu_ip_block_version *version;
>>          struct amdgpu_device *adev;
>> +       unsigned int instance;
>>   };
>>
>>   int amdgpu_device_ip_block_version_cmp(struct amdgpu_device *adev,
>> @@ -399,6 +400,10 @@ amdgpu_device_ip_get_ip_block(struct amdgpu_device *adev,
>>   int amdgpu_device_ip_block_add(struct amdgpu_device *adev,
>>                                 const struct amdgpu_ip_block_version *ip_block_version);
>>
>> +int amdgpu_device_ip_block_add_instance(struct amdgpu_device *adev,
>> +                              const struct amdgpu_ip_block_version *ip_block_version,
>> +                              unsigned int inst);
>> +
>>   /*
>>    * BIOS.
>>    */
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>> index 263f25ac2d63..4bc109a0d832 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>> @@ -2321,6 +2321,45 @@ int amdgpu_device_ip_block_add(struct amdgpu_device *adev,
>>          return 0;
>>   }
>>
>> +/**
>> + * amdgpu_device_ip_block_add_instance
>> + *
>> + * @adev: amdgpu_device pointer
>> + * @ip_block_version: pointer to the IP to add
>> + *
>> + * Adds the IP block driver information and instance number
>> + * to the collection of IPs on the asic.
>> + */
>> +int amdgpu_device_ip_block_add_instance(struct amdgpu_device *adev,
>> +                              const struct amdgpu_ip_block_version *ip_block_version,
>> +                              unsigned int inst)
>> +{
>> +       if (!ip_block_version)
>> +               return -EINVAL;
>> +
>> +       switch (ip_block_version->type) {
>> +       case AMD_IP_BLOCK_TYPE_VCN:
>> +               if (adev->harvest_ip_mask & AMD_HARVEST_IP_VCN_MASK)
>> +                       return 0;
>> +               break;
>> +       case AMD_IP_BLOCK_TYPE_JPEG:
>> +               if (adev->harvest_ip_mask & AMD_HARVEST_IP_JPEG_MASK)
>> +                       return 0;
>> +               break;
>> +       default:
>> +               break;
>> +       }
>> +
>> +       DRM_INFO("add ip block number %d <%s>\n", adev->num_ip_blocks,
>> +                 ip_block_version->funcs->name);
>> +
>> +       adev->ip_blocks[adev->num_ip_blocks].adev = adev;
>> +       adev->ip_blocks[adev->num_ip_blocks].instance = inst;
>> +       adev->ip_blocks[adev->num_ip_blocks++].version = ip_block_version;
>> +
>> +       return 0;
>> +}
>> +
>>   /**
>>    * amdgpu_device_enable_virtual_display - enable virtual display feature
>>    *
>> --
>> 2.34.1
>>


More information about the amd-gfx mailing list