[Public] > -----Original Message----- > From: Lazar, Lijo <Lijo.Lazar@xxxxxxx> > Sent: Monday, February 10, 2025 2:01 AM > To: amd-gfx@xxxxxxxxxxxxxxxxxxxxx > Cc: Zhang, Hawking <Hawking.Zhang@xxxxxxx>; Deucher, Alexander > <Alexander.Deucher@xxxxxxx>; Kim, Jonathan <Jonathan.Kim@xxxxxxx> > Subject: [PATCH v2 4/4] drm/amdgpu: Use xgmi APIs for init and bandwidth > > Initialize xgmi related static information during early_init. Use xgmi > API to get max bandwidth details. > > Signed-off-by: Lijo Lazar <lijo.lazar@xxxxxxx> > --- > v2: > Move XGMI info init to early init phase (Jon) > > drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 6 ++++-- > drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +++ > 2 files changed, 7 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c > index 2c1b38c5cfc6..e6bc70fb1eb6 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c > @@ -576,6 +576,7 @@ int amdgpu_amdkfd_get_xgmi_bandwidth_mbytes(struct > amdgpu_device *dst, > bool is_min) > { > struct amdgpu_device *adev = dst, *peer_adev; > + uint32_t link_max_bandwidth; > int num_links; > > if (amdgpu_ip_version(adev, GC_HWIP, 0) < IP_VERSION(9, 4, 2)) > @@ -593,8 +594,9 @@ int amdgpu_amdkfd_get_xgmi_bandwidth_mbytes(struct > amdgpu_device *dst, > num_links = 0; > } > > - /* Aldebaran xGMI DPM is defeatured so assume x16 x 25Gbps for > bandwidth. */ > - return (num_links * 16 * 25000)/BITS_PER_BYTE; > + link_max_bandwidth = amdgpu_xgmi_get_max_bandwidth(adev); > + > + return (num_links * link_max_bandwidth)/BITS_PER_BYTE; > } I have a WIP patch that deprecates the amdgpu_amdkfd_get_xgmi_* calls and consolidates them into amdgpu_xgmi.c. This should hopefully reduce the middleman and make life easier for both parts of the driver. It'll take a day or two to fully test, but I'll send you a compile tested version offline in the meantime to give you a sense of what I'll be doing. Jon > > int amdgpu_amdkfd_get_pcie_bandwidth_mbytes(struct amdgpu_device *adev, bool > is_min) > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > index 315ab2d6717a..09aac4542ed7 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > @@ -2749,6 +2749,9 @@ static int amdgpu_device_ip_early_init(struct > amdgpu_device *adev) > if (!total) > return -ENODEV; > > + if (adev->gmc.xgmi.supported) > + amdgpu_xgmi_early_init(adev); > + > ip_block = amdgpu_device_ip_get_ip_block(adev, > AMD_IP_BLOCK_TYPE_GFX); > if (ip_block->status.valid != false) > amdgpu_amdkfd_device_probe(adev); > -- > 2.25.1