On Mon, Apr 11, 2022 at 11:25 AM Zhang, Jesse(Jie) <Jesse.Zhang@xxxxxxx> wrote: > > [AMD Official Use Only] > > > > + Deucher, Alexander > > > > From: Zhang, Jesse(Jie) > Sent: Monday, 11 April 2022 11:15 pm > To: amd-gfx@xxxxxxxxxxxxxxxxxxxxx > Cc: Huang, Ray <Ray.Huang@xxxxxxx>; Zhang, Yifan <Yifan1.Zhang@xxxxxxx> > Subject: [PATCH ] drm/amdgpu: fix discovery ip failed > > > > [AMD Official Use Only] > > > > Fix discovery ip failed, and the log: > > 56.129549] [drm:amdgpu_discovery_validate_ip [amdgpu]] *ERROR* Unexpected number_instance (64) from ip discovery blob > [ 56.130129] [drm:amdgpu_discovery_validate_ip [amdgpu]] *ERROR* Unexpected hw_id (45056) from ip discovery blob > [ 56.130701] [drm:amdgpu_discovery_validate_ip [amdgpu]] *ERROR* Unexpected number_instance (66) from ip discovery blob > [ 56.131283] [drm:amdgpu_discovery_validate_ip [amdgpu]] *ERROR* Unexpected hw_id (45568) from ip discovery blob > [ 56.131855] [drm:amdgpu_discovery_validate_ip [amdgpu]] *ERROR* Unexpected number_instance (66) from ip discovery blob > [ 56.132436] [drm:amdgpu_discovery_validate_ip [amdgpu]] *ERROR* Unexpected hw_id (480) from ip discovery blob > [ 56.133053] [drm:amdgpu_discovery_validate_ip [amdgpu]] *ERROR* Unexpected hw_id (608) from ip discovery blob > [ 56.133626] [drm:amdgpu_discovery_validate_ip [amdgpu]] *ERROR* Unexpected hw_id (640) from ip discovery blob > [ 56.134207] [drm:amdgpu_discovery_validate_ip [amdgpu]] *ERROR* Unexpected number_instance (64) from ip discovery blob > [ 56.134780] [drm:amdgpu_discovery_validate_ip [amdgpu]] *ERROR* Unexpected number_instance (64) from ip discovery blob > [ 56.135360] [drm:amdgpu_discovery_validate_ip [amdgpu]] *ERROR* Unexpected hw_id (28672) from ip discovery blob > Please add a description of what the fix is doing and add your signed-off-by. Alex > > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c > > index 766006a075ec..a778b0392e9f 100644 > > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c > > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c > > @@ -798,7 +798,7 @@ static int amdgpu_discovery_sysfs_ips(struct amdgpu_device *adev, > > res = kobject_add(&ip_hw_instance->kobj, NULL, > > "%d", ip_hw_instance->num_instance); > > next_ip: > > - ip_offset += sizeof(*ip) + 4 * (ip->num_base_address - 1); > > + ip_offset += struct_size(ip, base_address, ip->num_base_address); > > } > > } > > > > @@ -1063,7 +1063,7 @@ int amdgpu_discovery_reg_base_init(struct amdgpu_device *adev) > > } > > > > next_ip: > > - ip_offset += sizeof(*ip) + 4 * (ip->num_base_address - 1); > > + ip_offset += struct_size(ip, base_address, ip->num_base_address); > > } > > } > > > > @@ -1113,7 +1113,7 @@ int amdgpu_discovery_get_ip_version(struct amdgpu_device *adev, int hw_id, int n > > *revision = ip->revision; > > return 0; > > } > > - ip_offset += sizeof(*ip) + 4 * (ip->num_base_address - 1); > > + ip_offset += struct_size(ip, base_address, ip->num_base_address); > > } > > }