On Wed, Oct 15, 2025 at 9:12 AM Alex Deucher <[email protected]> wrote:
>
> On Tue, Oct 14, 2025 at 4:21 PM Ellen Pan <[email protected]> wrote:
> >
> > - During guest driver init, asa VFs receive PF msg to
> >         init dynamic critical region(v2), VFs reuse fw_vram_usage_*
> >          from ttm to store critical region tables in a 5MB chunk.
> >
> > Signed-off-by: Ellen Pan <[email protected]>
> > ---
> >  .../gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c  | 29 ++++++++++---------
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c       | 12 ++++----
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c      |  9 ++++++
> >  3 files changed, 31 insertions(+), 19 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c 
> > b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
> > index c7d32fb216e4..636385c80f64 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
> > @@ -181,19 +181,22 @@ int amdgpu_atomfirmware_allocate_fb_scratch(struct 
> > amdgpu_device *adev)
> >         u8 frev, crev;
> >         int usage_bytes = 0;
> >
> > -       if (amdgpu_atom_parse_data_header(ctx, index, NULL, &frev, &crev, 
> > &data_offset)) {
> > -               if (frev == 2 && crev == 1) {
> > -                       fw_usage_v2_1 =
> > -                               (struct vram_usagebyfirmware_v2_1 
> > *)(ctx->bios + data_offset);
> > -                       amdgpu_atomfirmware_allocate_fb_v2_1(adev,
> > -                                       fw_usage_v2_1,
> > -                                       &usage_bytes);
> > -               } else if (frev >= 2 && crev >= 2) {
> > -                       fw_usage_v2_2 =
> > -                               (struct vram_usagebyfirmware_v2_2 
> > *)(ctx->bios + data_offset);
> > -                       amdgpu_atomfirmware_allocate_fb_v2_2(adev,
> > -                                       fw_usage_v2_2,
> > -                                       &usage_bytes);
> > +       /* Skip atomfirmware allocation for SRIOV VFs when dynamic crit 
> > regn is enabled */
> > +       if (!(amdgpu_sriov_vf(adev) && 
> > adev->virt.is_dynamic_crit_regn_enabled)) {
> > +               if (amdgpu_atom_parse_data_header(ctx, index, NULL, &frev, 
> > &crev, &data_offset)) {
>
> Do you need this check here?  Is vram_usagebyfirmware valid on V2
> systems?  If that table if not present on V2 systems, then you don't
> need to change anything here since amdgpu_atom_parse_data_header()
> will return an error.  Other than that, looks good to me.

Sorry, I missed your previous reply.  This patch is:
Reviewed-by: Alex Deucher <[email protected]>

>
> Alex
>
> > +                       if (frev == 2 && crev == 1) {
> > +                               fw_usage_v2_1 =
> > +                                       (struct vram_usagebyfirmware_v2_1 
> > *)(ctx->bios + data_offset);
> > +                               amdgpu_atomfirmware_allocate_fb_v2_1(adev,
> > +                                               fw_usage_v2_1,
> > +                                               &usage_bytes);
> > +                       } else if (frev >= 2 && crev >= 2) {
> > +                               fw_usage_v2_2 =
> > +                                       (struct vram_usagebyfirmware_v2_2 
> > *)(ctx->bios + data_offset);
> > +                               amdgpu_atomfirmware_allocate_fb_v2_2(adev,
> > +                                               fw_usage_v2_2,
> > +                                               &usage_bytes);
> > +                       }
> >                 }
> >         }
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
> > b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> > index 96bd0185f936..b5148a33b6f5 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> > @@ -1944,19 +1944,19 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
> >                 return r;
> >
> >         /*
> > -        *The reserved vram for driver must be pinned to the specified
> > -        *place on the VRAM, so reserve it early.
> > +        * The reserved VRAM for the driver must be pinned to a specific
> > +        * location in VRAM, so reserve it early.
> >          */
> >         r = amdgpu_ttm_drv_reserve_vram_init(adev);
> >         if (r)
> >                 return r;
> >
> >         /*
> > -        * only NAVI10 and onwards ASIC support for IP discovery.
> > -        * If IP discovery enabled, a block of memory should be
> > -        * reserved for IP discovey.
> > +        * only NAVI10 and later ASICs support IP discovery.
> > +        * If IP discovery is enabled, a block of memory should be
> > +        * reserved for it.
> >          */
> > -       if (adev->mman.discovery_bin) {
> > +       if (adev->mman.discovery_bin && 
> > !adev->virt.is_dynamic_crit_regn_enabled) {
> >                 r = amdgpu_ttm_reserve_tmr(adev);
> >                 if (r)
> >                         return r;
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c 
> > b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
> > index 27235f3f3b81..820dab538164 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
> > @@ -940,6 +940,15 @@ int amdgpu_virt_init_critical_region(struct 
> > amdgpu_device *adev)
> >         
> > adev->virt.crit_regn_tbl[AMD_SRIOV_MSG_BAD_PAGE_INFO_TABLE_ID].size_kb =
> >                 init_data_hdr->bad_page_size_in_kb;
> >
> > +       /* reserved memory starts from crit region base offset with the 
> > size of 5MB */
> > +       adev->mman.fw_vram_usage_start_offset = adev->virt.crit_regn.offset;
> > +       adev->mman.fw_vram_usage_size = adev->virt.crit_regn.size_kb << 10;
> > +       dev_info(adev->dev,
> > +               "critical region v%d requested to reserve memory start at 
> > %08x with %d KB.\n",
> > +                       init_data_hdr->version,
> > +                       adev->mman.fw_vram_usage_start_offset,
> > +                       adev->mman.fw_vram_usage_size >> 10);
> > +
> >         adev->virt.is_dynamic_crit_regn_enabled = true;
> >
> >  out:
> > --
> > 2.34.1
> >

Reply via email to