Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] drm/amdgpu: amdgpu_acpi_find_gpu_memory_in_srat() always
  returns -ENOENT
--

commit eababb17e2adcd526ed509506729f9c07f446351
Author: Zhigang Luo <[email protected]>

drm/amdgpu: keep the A+A VF VRAM base at the SRAT address

This commit reads the ACPI SRAT entry in mmhub_v4_2_0_get_xgmi_info() on A+A
SPM VFs to set the framebuffer offset and single-node XGMI segment size from
the SRAT address and length.

> diff --git a/drivers/gpu/drm/amd/amdgpu/mmhub_v4_2_0.c 
> b/drivers/gpu/drm/amd/amdgpu/mmhub_v4_2_0.c
> index 4495d52b4b07c..8593453445e38 100644
> --- a/drivers/gpu/drm/amd/amdgpu/mmhub_v4_2_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/mmhub_v4_2_0.c
> @@ -132,6 +132,27 @@ static int mmhub_v4_2_0_get_xgmi_info(struct 
> amdgpu_device *adev)
>       if (!adev->gmc.xgmi.connected_to_cpu)
>               return 0;
>  
> +     /* The SRAT entry is the VF's whole VRAM. PF_LFB_REGION describes
> +      * the physical GPU, not the VF, so report a single node. The
> +      * length is the segment size; the address is the FB offset.
> +      * aper_base is filled from those later.
> +      */
> +     if (amdgpu_virt_vram_is_spm(adev)) {
> +             u64 fb_offset;
> +             int r;
> +
> +             r = amdgpu_acpi_find_gpu_memory_in_srat(adev, &fb_offset,
> +                                                     &seg_size);
> +             if (r)
> +                     return r;

[Severity: High]
Does calling amdgpu_acpi_find_gpu_memory_in_srat() here cause
mmhub_v4_2_0_get_xgmi_info() to always fail with -ENOENT on mainline builds?
The real implementation of amdgpu_acpi_find_gpu_memory_in_srat() is guarded
by HAVE_ACPI_SRAT_GENERIC_AFFINITY, which is never defined in the kernel
tree:

drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c:
#ifdef HAVE_ACPI_SRAT_GENERIC_AFFINITY
...
int amdgpu_acpi_find_gpu_memory_in_srat(struct amdgpu_device *adev,
                                        uint64_t *base_addr, uint64_t *length)
{
...
}
#else
int amdgpu_acpi_find_gpu_memory_in_srat(struct amdgpu_device *adev,
                                        uint64_t *base_addr, uint64_t *length)
{
        if (!base_addr || !length)
                return -EINVAL;

        return -ENOENT;
}
#endif

Because only the #else stub is compiled, mmhub_v4_2_0_get_xgmi_info() returns
-ENOENT and aborts amdgpu_device_init() on all A+A SPM VFs.

-- 
Sashiko AI review · 
https://sashiko.dev/#/patchset/[email protected]?part=7

Reply via email to