All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: Add stolen reserved memory for MI25 SRIOV.
@ 2022-03-14 21:10 Yongqiang Sun
  2022-03-14 21:22 ` Alex Deucher
  0 siblings, 1 reply; 2+ messages in thread
From: Yongqiang Sun @ 2022-03-14 21:10 UTC (permalink / raw)
  To: amd-gfx; +Cc: alexander.deucher, Yongqiang Sun

MI25 SRIOV guest driver loading failed due to allocate
memory overlaps with private memory area.
Add below change to fix the issue:
1. Allocate stolen reserved memory for MI25 SRIOV specifically to avoid
the memory overlap.
2. Move allocate reserve allocation to vbios allocation since both the
two functions are doing similar asic type check and no need to have
separate functions.

Signed-off-by: Yongqiang Sun <yongqiang.sun@amd.com>
Change-Id: I142127513047a3e81573eb983c510d763b548a24
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 38 ++++++++++++-------------
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h |  1 -
 drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c  |  1 -
 3 files changed, 19 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
index 7c2a9555b7cc..7e4d298e8df8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
@@ -626,6 +626,13 @@ void amdgpu_gmc_get_vbios_allocations(struct amdgpu_device *adev)
 {
 	unsigned size;
 
+	/*
+	 * Some ASICs need to reserve a region of video memory to avoid access
+	 * from driver
+	 */
+	adev->mman.stolen_reserved_offset = 0;
+	adev->mman.stolen_reserved_size = 0;
+
 	/*
 	 * TODO:
 	 * Currently there is a bug where some memory client outside
@@ -636,10 +643,22 @@ void amdgpu_gmc_get_vbios_allocations(struct amdgpu_device *adev)
 	 */
 	switch (adev->asic_type) {
 	case CHIP_VEGA10:
+		adev->mman.keep_stolen_vga_memory = true;
+		if (amdgpu_sriov_vf(adev)) {
+			adev->mman.stolen_reserved_offset = 0x100000;
+			adev->mman.stolen_reserved_size = 0x600000;
+		}
+		break;
 	case CHIP_RAVEN:
 	case CHIP_RENOIR:
 		adev->mman.keep_stolen_vga_memory = true;
 		break;
+	case CHIP_YELLOW_CARP:
+		if (amdgpu_discovery == 0) {
+			adev->mman.stolen_reserved_offset = 0x1ffb0000;
+			adev->mman.stolen_reserved_size = 64 * PAGE_SIZE;
+		}
+		break;
 	default:
 		adev->mman.keep_stolen_vga_memory = false;
 		break;
@@ -760,25 +779,6 @@ uint64_t amdgpu_gmc_vram_cpu_pa(struct amdgpu_device *adev, struct amdgpu_bo *bo
 	return amdgpu_bo_gpu_offset(bo) - adev->gmc.vram_start + adev->gmc.aper_base;
 }
 
-void amdgpu_gmc_get_reserved_allocation(struct amdgpu_device *adev)
-{
-	/* Some ASICs need to reserve a region of video memory to avoid access
-	 * from driver */
-	adev->mman.stolen_reserved_offset = 0;
-	adev->mman.stolen_reserved_size = 0;
-
-	switch (adev->asic_type) {
-	case CHIP_YELLOW_CARP:
-		if (amdgpu_discovery == 0) {
-			adev->mman.stolen_reserved_offset = 0x1ffb0000;
-			adev->mman.stolen_reserved_size = 64 * PAGE_SIZE;
-		}
-		break;
-	default:
-		break;
-	}
-}
-
 int amdgpu_gmc_vram_checking(struct amdgpu_device *adev)
 {
 	struct amdgpu_bo *vram_bo = NULL;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
index 93505bb0a36c..032b0313f277 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
@@ -331,7 +331,6 @@ amdgpu_gmc_set_vm_fault_masks(struct amdgpu_device *adev, int hub_type,
 			      bool enable);
 
 void amdgpu_gmc_get_vbios_allocations(struct amdgpu_device *adev);
-void amdgpu_gmc_get_reserved_allocation(struct amdgpu_device *adev);
 
 void amdgpu_gmc_init_pdb0(struct amdgpu_device *adev);
 uint64_t amdgpu_gmc_vram_mc2pa(struct amdgpu_device *adev, uint64_t mc_addr);
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
index f60b7bd4dbf5..3c1d440824a7 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
@@ -948,7 +948,6 @@ static int gmc_v10_0_sw_init(void *handle)
 		return r;
 
 	amdgpu_gmc_get_vbios_allocations(adev);
-	amdgpu_gmc_get_reserved_allocation(adev);
 
 	/* Memory manager */
 	r = amdgpu_bo_init(adev);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm/amdgpu: Add stolen reserved memory for MI25 SRIOV.
  2022-03-14 21:10 [PATCH] drm/amdgpu: Add stolen reserved memory for MI25 SRIOV Yongqiang Sun
@ 2022-03-14 21:22 ` Alex Deucher
  0 siblings, 0 replies; 2+ messages in thread
From: Alex Deucher @ 2022-03-14 21:22 UTC (permalink / raw)
  To: Yongqiang Sun; +Cc: Deucher, Alexander, amd-gfx list

On Mon, Mar 14, 2022 at 5:10 PM Yongqiang Sun <yongqiang.sun@amd.com> wrote:
>
> MI25 SRIOV guest driver loading failed due to allocate
> memory overlaps with private memory area.

maybe instead of "private memory area", say something like "firmware
reserved area".

> Add below change to fix the issue:
> 1. Allocate stolen reserved memory for MI25 SRIOV specifically to avoid
> the memory overlap.
> 2. Move allocate reserve allocation to vbios allocation since both the
> two functions are doing similar asic type check and no need to have
> separate functions.

These could be split into two patches, one to merge
amdgpu_gmc_get_reserved_allocation() into
amdgpu_gmc_get_vbios_allocations(), and one to add the
stolen_reserved_* for vega10.

>
> Signed-off-by: Yongqiang Sun <yongqiang.sun@amd.com>
> Change-Id: I142127513047a3e81573eb983c510d763b548a24

With the above changes addressed:
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 38 ++++++++++++-------------
>  drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h |  1 -
>  drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c  |  1 -
>  3 files changed, 19 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> index 7c2a9555b7cc..7e4d298e8df8 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> @@ -626,6 +626,13 @@ void amdgpu_gmc_get_vbios_allocations(struct amdgpu_device *adev)
>  {
>         unsigned size;
>
> +       /*
> +        * Some ASICs need to reserve a region of video memory to avoid access
> +        * from driver
> +        */
> +       adev->mman.stolen_reserved_offset = 0;
> +       adev->mman.stolen_reserved_size = 0;
> +
>         /*
>          * TODO:
>          * Currently there is a bug where some memory client outside
> @@ -636,10 +643,22 @@ void amdgpu_gmc_get_vbios_allocations(struct amdgpu_device *adev)
>          */
>         switch (adev->asic_type) {
>         case CHIP_VEGA10:
> +               adev->mman.keep_stolen_vga_memory = true;
> +               if (amdgpu_sriov_vf(adev)) {
> +                       adev->mman.stolen_reserved_offset = 0x100000;
> +                       adev->mman.stolen_reserved_size = 0x600000;
> +               }
> +               break;
>         case CHIP_RAVEN:
>         case CHIP_RENOIR:
>                 adev->mman.keep_stolen_vga_memory = true;
>                 break;
> +       case CHIP_YELLOW_CARP:
> +               if (amdgpu_discovery == 0) {
> +                       adev->mman.stolen_reserved_offset = 0x1ffb0000;
> +                       adev->mman.stolen_reserved_size = 64 * PAGE_SIZE;
> +               }
> +               break;
>         default:
>                 adev->mman.keep_stolen_vga_memory = false;
>                 break;
> @@ -760,25 +779,6 @@ uint64_t amdgpu_gmc_vram_cpu_pa(struct amdgpu_device *adev, struct amdgpu_bo *bo
>         return amdgpu_bo_gpu_offset(bo) - adev->gmc.vram_start + adev->gmc.aper_base;
>  }
>
> -void amdgpu_gmc_get_reserved_allocation(struct amdgpu_device *adev)
> -{
> -       /* Some ASICs need to reserve a region of video memory to avoid access
> -        * from driver */
> -       adev->mman.stolen_reserved_offset = 0;
> -       adev->mman.stolen_reserved_size = 0;
> -
> -       switch (adev->asic_type) {
> -       case CHIP_YELLOW_CARP:
> -               if (amdgpu_discovery == 0) {
> -                       adev->mman.stolen_reserved_offset = 0x1ffb0000;
> -                       adev->mman.stolen_reserved_size = 64 * PAGE_SIZE;
> -               }
> -               break;
> -       default:
> -               break;
> -       }
> -}
> -
>  int amdgpu_gmc_vram_checking(struct amdgpu_device *adev)
>  {
>         struct amdgpu_bo *vram_bo = NULL;
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
> index 93505bb0a36c..032b0313f277 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
> @@ -331,7 +331,6 @@ amdgpu_gmc_set_vm_fault_masks(struct amdgpu_device *adev, int hub_type,
>                               bool enable);
>
>  void amdgpu_gmc_get_vbios_allocations(struct amdgpu_device *adev);
> -void amdgpu_gmc_get_reserved_allocation(struct amdgpu_device *adev);
>
>  void amdgpu_gmc_init_pdb0(struct amdgpu_device *adev);
>  uint64_t amdgpu_gmc_vram_mc2pa(struct amdgpu_device *adev, uint64_t mc_addr);
> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
> index f60b7bd4dbf5..3c1d440824a7 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
> @@ -948,7 +948,6 @@ static int gmc_v10_0_sw_init(void *handle)
>                 return r;
>
>         amdgpu_gmc_get_vbios_allocations(adev);
> -       amdgpu_gmc_get_reserved_allocation(adev);
>
>         /* Memory manager */
>         r = amdgpu_bo_init(adev);
> --
> 2.25.1
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-14 21:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-14 21:10 [PATCH] drm/amdgpu: Add stolen reserved memory for MI25 SRIOV Yongqiang Sun
2022-03-14 21:22 ` Alex Deucher

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.