AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] drm/amdgpu/gmc: add a way to force a particular placement for GART
@ 2023-09-21 21:40 Alex Deucher
  2023-09-26 17:30 ` Alex Deucher
  0 siblings, 1 reply; 9+ messages in thread
From: Alex Deucher @ 2023-09-21 21:40 UTC (permalink / raw)
  To: amd-gfx; +Cc: Alex Deucher

We normally place GART based on the location of VRAM and the
available address space around that, but provide an option
to force a particular location for hardware that needs it.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 19 +++++++++++++++----
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h |  8 ++++++++
 2 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
index f74a51a93ebb..d1d98488373b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
@@ -287,11 +287,22 @@ void amdgpu_gmc_gart_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc)
 		mc->gart_size = max(size_bf, size_af);
 	}
 
-	if ((size_bf >= mc->gart_size && size_bf < size_af) ||
-	    (size_af < mc->gart_size))
-		mc->gart_start = 0;
-	else
+	switch (mc->gart_placement) {
+	case AMDGPU_GART_PLACEMENT_HIGH:
 		mc->gart_start = max_mc_address - mc->gart_size + 1;
+		break;
+	case AMDGPU_GART_PLACEMENT_LOW:
+		mc->gart_start = 0;
+		break;
+	case AMDGPU_GART_PLACEMENT_BEST_FIT:
+	default:
+		if ((size_bf >= mc->gart_size && size_bf < size_af) ||
+		    (size_af < mc->gart_size))
+			mc->gart_start = 0;
+		else
+			mc->gart_start = max_mc_address - mc->gart_size + 1;
+		break;
+	}
 
 	mc->gart_start &= ~(four_gb - 1);
 	mc->gart_end = mc->gart_start + mc->gart_size - 1;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
index dd0ede75e5d7..fcef057b9213 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
@@ -199,6 +199,12 @@ struct amdgpu_mem_partition_info {
 
 #define INVALID_PFN    -1
 
+enum amdgpu_gart_placement {
+	AMDGPU_GART_PLACEMENT_BEST_FIT = 0,
+	AMDGPU_GART_PLACEMENT_HIGH,
+	AMDGPU_GART_PLACEMENT_LOW,
+};
+
 struct amdgpu_gmc {
 	/* FB's physical address in MMIO space (for CPU to
 	 * map FB). This is different compared to the agp/
@@ -339,6 +345,8 @@ struct amdgpu_gmc {
 	bool flush_tlb_needs_extra_type_0;
 	bool flush_tlb_needs_extra_type_2;
 	bool flush_pasid_uses_kiq;
+
+	enum amdgpu_gart_placement gart_placement;
 };
 
 #define amdgpu_gmc_emit_flush_gpu_tlb(r, vmid, addr) (r)->adev->gmc.gmc_funcs->emit_flush_gpu_tlb((r), (vmid), (addr))
-- 
2.41.0


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

* Re: [PATCH 1/2] drm/amdgpu/gmc: add a way to force a particular placement for GART
  2023-09-21 21:40 Alex Deucher
@ 2023-09-26 17:30 ` Alex Deucher
  2023-09-27  5:37   ` Christian König
  2023-09-27 14:12   ` Wang, Yang(Kevin)
  0 siblings, 2 replies; 9+ messages in thread
From: Alex Deucher @ 2023-09-26 17:30 UTC (permalink / raw)
  To: Alex Deucher; +Cc: amd-gfx

Ping on this series?

On Thu, Sep 21, 2023 at 5:46 PM Alex Deucher <alexander.deucher@amd.com> wrote:
>
> We normally place GART based on the location of VRAM and the
> available address space around that, but provide an option
> to force a particular location for hardware that needs it.
>
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 19 +++++++++++++++----
>  drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h |  8 ++++++++
>  2 files changed, 23 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> index f74a51a93ebb..d1d98488373b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> @@ -287,11 +287,22 @@ void amdgpu_gmc_gart_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc)
>                 mc->gart_size = max(size_bf, size_af);
>         }
>
> -       if ((size_bf >= mc->gart_size && size_bf < size_af) ||
> -           (size_af < mc->gart_size))
> -               mc->gart_start = 0;
> -       else
> +       switch (mc->gart_placement) {
> +       case AMDGPU_GART_PLACEMENT_HIGH:
>                 mc->gart_start = max_mc_address - mc->gart_size + 1;
> +               break;
> +       case AMDGPU_GART_PLACEMENT_LOW:
> +               mc->gart_start = 0;
> +               break;
> +       case AMDGPU_GART_PLACEMENT_BEST_FIT:
> +       default:
> +               if ((size_bf >= mc->gart_size && size_bf < size_af) ||
> +                   (size_af < mc->gart_size))
> +                       mc->gart_start = 0;
> +               else
> +                       mc->gart_start = max_mc_address - mc->gart_size + 1;
> +               break;
> +       }
>
>         mc->gart_start &= ~(four_gb - 1);
>         mc->gart_end = mc->gart_start + mc->gart_size - 1;
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
> index dd0ede75e5d7..fcef057b9213 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
> @@ -199,6 +199,12 @@ struct amdgpu_mem_partition_info {
>
>  #define INVALID_PFN    -1
>
> +enum amdgpu_gart_placement {
> +       AMDGPU_GART_PLACEMENT_BEST_FIT = 0,
> +       AMDGPU_GART_PLACEMENT_HIGH,
> +       AMDGPU_GART_PLACEMENT_LOW,
> +};
> +
>  struct amdgpu_gmc {
>         /* FB's physical address in MMIO space (for CPU to
>          * map FB). This is different compared to the agp/
> @@ -339,6 +345,8 @@ struct amdgpu_gmc {
>         bool flush_tlb_needs_extra_type_0;
>         bool flush_tlb_needs_extra_type_2;
>         bool flush_pasid_uses_kiq;
> +
> +       enum amdgpu_gart_placement gart_placement;
>  };
>
>  #define amdgpu_gmc_emit_flush_gpu_tlb(r, vmid, addr) (r)->adev->gmc.gmc_funcs->emit_flush_gpu_tlb((r), (vmid), (addr))
> --
> 2.41.0
>

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

* Re: [PATCH 1/2] drm/amdgpu/gmc: add a way to force a particular placement for GART
  2023-09-26 17:30 ` Alex Deucher
@ 2023-09-27  5:37   ` Christian König
  2023-09-27 15:13     ` Alex Deucher
  2023-09-27 14:12   ` Wang, Yang(Kevin)
  1 sibling, 1 reply; 9+ messages in thread
From: Christian König @ 2023-09-27  5:37 UTC (permalink / raw)
  To: Alex Deucher, Alex Deucher; +Cc: amd-gfx

I'm still not happy with moving the GART fixed to the end. We abandoned 
this for good reasons.

If we really go this way I would prefer to have this as parameter to the 
amdgpu_gmc_gart_location() function and not in the gmc structure.

Regards,
Christian.

Am 26.09.23 um 19:30 schrieb Alex Deucher:
> Ping on this series?
>
> On Thu, Sep 21, 2023 at 5:46 PM Alex Deucher <alexander.deucher@amd.com> wrote:
>> We normally place GART based on the location of VRAM and the
>> available address space around that, but provide an option
>> to force a particular location for hardware that needs it.
>>
>> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 19 +++++++++++++++----
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h |  8 ++++++++
>>   2 files changed, 23 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
>> index f74a51a93ebb..d1d98488373b 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
>> @@ -287,11 +287,22 @@ void amdgpu_gmc_gart_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc)
>>                  mc->gart_size = max(size_bf, size_af);
>>          }
>>
>> -       if ((size_bf >= mc->gart_size && size_bf < size_af) ||
>> -           (size_af < mc->gart_size))
>> -               mc->gart_start = 0;
>> -       else
>> +       switch (mc->gart_placement) {
>> +       case AMDGPU_GART_PLACEMENT_HIGH:
>>                  mc->gart_start = max_mc_address - mc->gart_size + 1;
>> +               break;
>> +       case AMDGPU_GART_PLACEMENT_LOW:
>> +               mc->gart_start = 0;
>> +               break;
>> +       case AMDGPU_GART_PLACEMENT_BEST_FIT:
>> +       default:
>> +               if ((size_bf >= mc->gart_size && size_bf < size_af) ||
>> +                   (size_af < mc->gart_size))
>> +                       mc->gart_start = 0;
>> +               else
>> +                       mc->gart_start = max_mc_address - mc->gart_size + 1;
>> +               break;
>> +       }
>>
>>          mc->gart_start &= ~(four_gb - 1);
>>          mc->gart_end = mc->gart_start + mc->gart_size - 1;
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
>> index dd0ede75e5d7..fcef057b9213 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
>> @@ -199,6 +199,12 @@ struct amdgpu_mem_partition_info {
>>
>>   #define INVALID_PFN    -1
>>
>> +enum amdgpu_gart_placement {
>> +       AMDGPU_GART_PLACEMENT_BEST_FIT = 0,
>> +       AMDGPU_GART_PLACEMENT_HIGH,
>> +       AMDGPU_GART_PLACEMENT_LOW,
>> +};
>> +
>>   struct amdgpu_gmc {
>>          /* FB's physical address in MMIO space (for CPU to
>>           * map FB). This is different compared to the agp/
>> @@ -339,6 +345,8 @@ struct amdgpu_gmc {
>>          bool flush_tlb_needs_extra_type_0;
>>          bool flush_tlb_needs_extra_type_2;
>>          bool flush_pasid_uses_kiq;
>> +
>> +       enum amdgpu_gart_placement gart_placement;
>>   };
>>
>>   #define amdgpu_gmc_emit_flush_gpu_tlb(r, vmid, addr) (r)->adev->gmc.gmc_funcs->emit_flush_gpu_tlb((r), (vmid), (addr))
>> --
>> 2.41.0
>>


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

* RE: [PATCH 1/2] drm/amdgpu/gmc: add a way to force a particular placement for GART
  2023-09-26 17:30 ` Alex Deucher
  2023-09-27  5:37   ` Christian König
@ 2023-09-27 14:12   ` Wang, Yang(Kevin)
  1 sibling, 0 replies; 9+ messages in thread
From: Wang, Yang(Kevin) @ 2023-09-27 14:12 UTC (permalink / raw)
  To: Alex Deucher, Deucher, Alexander; +Cc: amd-gfx@lists.freedesktop.org

[AMD Official Use Only - General]

Series is

Reviewed-by: Yang Wang <kevinyang.wang@amd.com>

Best Regards,
Kevin

-----Original Message-----
From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of Alex Deucher
Sent: Wednesday, September 27, 2023 1:30 AM
To: Deucher, Alexander <Alexander.Deucher@amd.com>
Cc: amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH 1/2] drm/amdgpu/gmc: add a way to force a particular placement for GART

Ping on this series?

On Thu, Sep 21, 2023 at 5:46 PM Alex Deucher <alexander.deucher@amd.com> wrote:
>
> We normally place GART based on the location of VRAM and the available
> address space around that, but provide an option to force a particular
> location for hardware that needs it.
>
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 19 +++++++++++++++----
> drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h |  8 ++++++++
>  2 files changed, 23 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> index f74a51a93ebb..d1d98488373b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> @@ -287,11 +287,22 @@ void amdgpu_gmc_gart_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc)
>                 mc->gart_size = max(size_bf, size_af);
>         }
>
> -       if ((size_bf >= mc->gart_size && size_bf < size_af) ||
> -           (size_af < mc->gart_size))
> -               mc->gart_start = 0;
> -       else
> +       switch (mc->gart_placement) {
> +       case AMDGPU_GART_PLACEMENT_HIGH:
>                 mc->gart_start = max_mc_address - mc->gart_size + 1;
> +               break;
> +       case AMDGPU_GART_PLACEMENT_LOW:
> +               mc->gart_start = 0;
> +               break;
> +       case AMDGPU_GART_PLACEMENT_BEST_FIT:
> +       default:
> +               if ((size_bf >= mc->gart_size && size_bf < size_af) ||
> +                   (size_af < mc->gart_size))
> +                       mc->gart_start = 0;
> +               else
> +                       mc->gart_start = max_mc_address - mc->gart_size + 1;
> +               break;
> +       }
>
>         mc->gart_start &= ~(four_gb - 1);
>         mc->gart_end = mc->gart_start + mc->gart_size - 1; diff --git
> a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
> index dd0ede75e5d7..fcef057b9213 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
> @@ -199,6 +199,12 @@ struct amdgpu_mem_partition_info {
>
>  #define INVALID_PFN    -1
>
> +enum amdgpu_gart_placement {
> +       AMDGPU_GART_PLACEMENT_BEST_FIT = 0,
> +       AMDGPU_GART_PLACEMENT_HIGH,
> +       AMDGPU_GART_PLACEMENT_LOW,
> +};
> +
>  struct amdgpu_gmc {
>         /* FB's physical address in MMIO space (for CPU to
>          * map FB). This is different compared to the agp/ @@ -339,6
> +345,8 @@ struct amdgpu_gmc {
>         bool flush_tlb_needs_extra_type_0;
>         bool flush_tlb_needs_extra_type_2;
>         bool flush_pasid_uses_kiq;
> +
> +       enum amdgpu_gart_placement gart_placement;
>  };
>
>  #define amdgpu_gmc_emit_flush_gpu_tlb(r, vmid, addr)
> (r)->adev->gmc.gmc_funcs->emit_flush_gpu_tlb((r), (vmid), (addr))
> --
> 2.41.0
>

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

* Re: [PATCH 1/2] drm/amdgpu/gmc: add a way to force a particular placement for GART
  2023-09-27  5:37   ` Christian König
@ 2023-09-27 15:13     ` Alex Deucher
  0 siblings, 0 replies; 9+ messages in thread
From: Alex Deucher @ 2023-09-27 15:13 UTC (permalink / raw)
  To: Christian König; +Cc: Alex Deucher, amd-gfx

On Wed, Sep 27, 2023 at 1:37 AM Christian König
<ckoenig.leichtzumerken@gmail.com> wrote:
>
> I'm still not happy with moving the GART fixed to the end. We abandoned
> this for good reasons.

We didn't abandon it, there is still code which decides where to put
the gart based on the relative sizes of the address space before and
after vram.  It really comes down to where the vbios decides to put
vram.  If it starts somewhere lower in the future, gart will naturally
end up higher.  Also windows always puts gart above vram.

>
> If we really go this way I would prefer to have this as parameter to the
> amdgpu_gmc_gart_location() function and not in the gmc structure.

I can do that.

Alex

>
> Regards,
> Christian.
>
> Am 26.09.23 um 19:30 schrieb Alex Deucher:
> > Ping on this series?
> >
> > On Thu, Sep 21, 2023 at 5:46 PM Alex Deucher <alexander.deucher@amd.com> wrote:
> >> We normally place GART based on the location of VRAM and the
> >> available address space around that, but provide an option
> >> to force a particular location for hardware that needs it.
> >>
> >> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
> >> ---
> >>   drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 19 +++++++++++++++----
> >>   drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h |  8 ++++++++
> >>   2 files changed, 23 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> >> index f74a51a93ebb..d1d98488373b 100644
> >> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> >> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> >> @@ -287,11 +287,22 @@ void amdgpu_gmc_gart_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc)
> >>                  mc->gart_size = max(size_bf, size_af);
> >>          }
> >>
> >> -       if ((size_bf >= mc->gart_size && size_bf < size_af) ||
> >> -           (size_af < mc->gart_size))
> >> -               mc->gart_start = 0;
> >> -       else
> >> +       switch (mc->gart_placement) {
> >> +       case AMDGPU_GART_PLACEMENT_HIGH:
> >>                  mc->gart_start = max_mc_address - mc->gart_size + 1;
> >> +               break;
> >> +       case AMDGPU_GART_PLACEMENT_LOW:
> >> +               mc->gart_start = 0;
> >> +               break;
> >> +       case AMDGPU_GART_PLACEMENT_BEST_FIT:
> >> +       default:
> >> +               if ((size_bf >= mc->gart_size && size_bf < size_af) ||
> >> +                   (size_af < mc->gart_size))
> >> +                       mc->gart_start = 0;
> >> +               else
> >> +                       mc->gart_start = max_mc_address - mc->gart_size + 1;
> >> +               break;
> >> +       }
> >>
> >>          mc->gart_start &= ~(four_gb - 1);
> >>          mc->gart_end = mc->gart_start + mc->gart_size - 1;
> >> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
> >> index dd0ede75e5d7..fcef057b9213 100644
> >> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
> >> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
> >> @@ -199,6 +199,12 @@ struct amdgpu_mem_partition_info {
> >>
> >>   #define INVALID_PFN    -1
> >>
> >> +enum amdgpu_gart_placement {
> >> +       AMDGPU_GART_PLACEMENT_BEST_FIT = 0,
> >> +       AMDGPU_GART_PLACEMENT_HIGH,
> >> +       AMDGPU_GART_PLACEMENT_LOW,
> >> +};
> >> +
> >>   struct amdgpu_gmc {
> >>          /* FB's physical address in MMIO space (for CPU to
> >>           * map FB). This is different compared to the agp/
> >> @@ -339,6 +345,8 @@ struct amdgpu_gmc {
> >>          bool flush_tlb_needs_extra_type_0;
> >>          bool flush_tlb_needs_extra_type_2;
> >>          bool flush_pasid_uses_kiq;
> >> +
> >> +       enum amdgpu_gart_placement gart_placement;
> >>   };
> >>
> >>   #define amdgpu_gmc_emit_flush_gpu_tlb(r, vmid, addr) (r)->adev->gmc.gmc_funcs->emit_flush_gpu_tlb((r), (vmid), (addr))
> >> --
> >> 2.41.0
> >>
>

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

* [PATCH 1/2] drm/amdgpu/gmc: add a way to force a particular placement for GART
@ 2023-09-27 18:12 Alex Deucher
  2023-09-27 18:12 ` [PATCH 2/2] drm/amdgpu/gmc11: set gart placement GC11 Alex Deucher
  2023-09-28 13:23 ` [PATCH 1/2] drm/amdgpu/gmc: add a way to force a particular placement for GART Alex Deucher
  0 siblings, 2 replies; 9+ messages in thread
From: Alex Deucher @ 2023-09-27 18:12 UTC (permalink / raw)
  To: amd-gfx; +Cc: Alex Deucher

We normally place GART based on the location of VRAM and the
available address space around that, but provide an option
to force a particular location for hardware that needs it.

v2: Switch to passing the placement via parameter

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 22 +++++++++++++++++-----
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h |  9 ++++++++-
 drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c  |  2 +-
 drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c  |  2 +-
 drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c   |  2 +-
 drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c   |  2 +-
 drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c   |  2 +-
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c   |  2 +-
 8 files changed, 31 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
index 2bfeaacd050c..60c81c3d29d5 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
@@ -269,7 +269,8 @@ void amdgpu_gmc_sysvm_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc
  * If GART size is bigger than space left then we ajust GART size.
  * Thus function will never fails.
  */
-void amdgpu_gmc_gart_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc)
+void amdgpu_gmc_gart_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc,
+			      enum amdgpu_gart_placement gart_placement)
 {
 	const uint64_t four_gb = 0x100000000ULL;
 	u64 size_af, size_bf;
@@ -287,11 +288,22 @@ void amdgpu_gmc_gart_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc)
 		mc->gart_size = max(size_bf, size_af);
 	}
 
-	if ((size_bf >= mc->gart_size && size_bf < size_af) ||
-	    (size_af < mc->gart_size))
-		mc->gart_start = 0;
-	else
+	switch (gart_placement) {
+	case AMDGPU_GART_PLACEMENT_HIGH:
 		mc->gart_start = max_mc_address - mc->gart_size + 1;
+		break;
+	case AMDGPU_GART_PLACEMENT_LOW:
+		mc->gart_start = 0;
+		break;
+	case AMDGPU_GART_PLACEMENT_BEST_FIT:
+	default:
+		if ((size_bf >= mc->gart_size && size_bf < size_af) ||
+		    (size_af < mc->gart_size))
+			mc->gart_start = 0;
+		else
+			mc->gart_start = max_mc_address - mc->gart_size + 1;
+		break;
+	}
 
 	mc->gart_start &= ~(four_gb - 1);
 	mc->gart_end = mc->gart_start + mc->gart_size - 1;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
index f593259a66c3..e699d1ca8deb 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
@@ -199,6 +199,12 @@ struct amdgpu_mem_partition_info {
 
 #define INVALID_PFN    -1
 
+enum amdgpu_gart_placement {
+	AMDGPU_GART_PLACEMENT_BEST_FIT = 0,
+	AMDGPU_GART_PLACEMENT_HIGH,
+	AMDGPU_GART_PLACEMENT_LOW,
+};
+
 struct amdgpu_gmc {
 	/* FB's physical address in MMIO space (for CPU to
 	 * map FB). This is different compared to the agp/
@@ -391,7 +397,8 @@ void amdgpu_gmc_sysvm_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc
 void amdgpu_gmc_vram_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc,
 			      u64 base);
 void amdgpu_gmc_gart_location(struct amdgpu_device *adev,
-			      struct amdgpu_gmc *mc);
+			      struct amdgpu_gmc *mc,
+			      enum amdgpu_gart_placement gart_placement);
 void amdgpu_gmc_agp_location(struct amdgpu_device *adev,
 			     struct amdgpu_gmc *mc);
 void amdgpu_gmc_set_agp_default(struct amdgpu_device *adev,
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
index 70370b412d24..8e6e36279389 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
@@ -670,7 +670,7 @@ static void gmc_v10_0_vram_gtt_location(struct amdgpu_device *adev,
 	base += adev->gmc.xgmi.physical_node_id * adev->gmc.xgmi.node_segment_size;
 
 	amdgpu_gmc_vram_location(adev, &adev->gmc, base);
-	amdgpu_gmc_gart_location(adev, mc);
+	amdgpu_gmc_gart_location(adev, mc, AMDGPU_GART_PLACEMENT_BEST_FIT);
 	if (!amdgpu_sriov_vf(adev))
 		amdgpu_gmc_agp_location(adev, mc);
 
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c
index d0a9ee2f12d3..d611d2efce3b 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c
@@ -634,7 +634,7 @@ static void gmc_v11_0_vram_gtt_location(struct amdgpu_device *adev,
 	base = adev->mmhub.funcs->get_fb_location(adev);
 
 	amdgpu_gmc_vram_location(adev, &adev->gmc, base);
-	amdgpu_gmc_gart_location(adev, mc);
+	amdgpu_gmc_gart_location(adev, mc, AMDGPU_GART_PLACEMENT_BEST_FIT);
 	if (!amdgpu_sriov_vf(adev) ||
 	    (amdgpu_ip_version(adev, GC_HWIP, 0) < IP_VERSION(11, 5, 0)))
 		amdgpu_gmc_agp_location(adev, mc);
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
index 3f31f268e0eb..7f66954fd302 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
@@ -212,7 +212,7 @@ static void gmc_v6_0_vram_gtt_location(struct amdgpu_device *adev,
 	base <<= 24;
 
 	amdgpu_gmc_vram_location(adev, mc, base);
-	amdgpu_gmc_gart_location(adev, mc);
+	amdgpu_gmc_gart_location(adev, mc, AMDGPU_GART_PLACEMENT_BEST_FIT);
 }
 
 static void gmc_v6_0_mc_program(struct amdgpu_device *adev)
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
index a72dc21cf6fc..3869cefab7bd 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
@@ -240,7 +240,7 @@ static void gmc_v7_0_vram_gtt_location(struct amdgpu_device *adev,
 	base <<= 24;
 
 	amdgpu_gmc_vram_location(adev, mc, base);
-	amdgpu_gmc_gart_location(adev, mc);
+	amdgpu_gmc_gart_location(adev, mc, AMDGPU_GART_PLACEMENT_BEST_FIT);
 }
 
 /**
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
index 8ce77d074d17..4126172feb7f 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
@@ -414,7 +414,7 @@ static void gmc_v8_0_vram_gtt_location(struct amdgpu_device *adev,
 	base <<= 24;
 
 	amdgpu_gmc_vram_location(adev, mc, base);
-	amdgpu_gmc_gart_location(adev, mc);
+	amdgpu_gmc_gart_location(adev, mc, AMDGPU_GART_PLACEMENT_BEST_FIT);
 }
 
 /**
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
index 6b15677c0314..37e96d9d30a3 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
@@ -1611,7 +1611,7 @@ static void gmc_v9_0_vram_gtt_location(struct amdgpu_device *adev,
 		amdgpu_gmc_sysvm_location(adev, mc);
 	} else {
 		amdgpu_gmc_vram_location(adev, mc, base);
-		amdgpu_gmc_gart_location(adev, mc);
+		amdgpu_gmc_gart_location(adev, mc, AMDGPU_GART_PLACEMENT_BEST_FIT);
 		if (!amdgpu_sriov_vf(adev))
 			amdgpu_gmc_agp_location(adev, mc);
 	}
-- 
2.41.0


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

* [PATCH 2/2] drm/amdgpu/gmc11: set gart placement GC11
  2023-09-27 18:12 [PATCH 1/2] drm/amdgpu/gmc: add a way to force a particular placement for GART Alex Deucher
@ 2023-09-27 18:12 ` Alex Deucher
  2023-09-28 13:23 ` [PATCH 1/2] drm/amdgpu/gmc: add a way to force a particular placement for GART Alex Deucher
  1 sibling, 0 replies; 9+ messages in thread
From: Alex Deucher @ 2023-09-27 18:12 UTC (permalink / raw)
  To: amd-gfx; +Cc: Alex Deucher

Needed to avoid a hardware issue.

v2: force high for all GC11 parts for consistency (Alex)
v3: rebase

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c
index d611d2efce3b..07f50ca8d481 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c
@@ -634,7 +634,7 @@ static void gmc_v11_0_vram_gtt_location(struct amdgpu_device *adev,
 	base = adev->mmhub.funcs->get_fb_location(adev);
 
 	amdgpu_gmc_vram_location(adev, &adev->gmc, base);
-	amdgpu_gmc_gart_location(adev, mc, AMDGPU_GART_PLACEMENT_BEST_FIT);
+	amdgpu_gmc_gart_location(adev, mc, AMDGPU_GART_PLACEMENT_HIGH);
 	if (!amdgpu_sriov_vf(adev) ||
 	    (amdgpu_ip_version(adev, GC_HWIP, 0) < IP_VERSION(11, 5, 0)))
 		amdgpu_gmc_agp_location(adev, mc);
-- 
2.41.0


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

* Re: [PATCH 1/2] drm/amdgpu/gmc: add a way to force a particular placement for GART
  2023-09-27 18:12 [PATCH 1/2] drm/amdgpu/gmc: add a way to force a particular placement for GART Alex Deucher
  2023-09-27 18:12 ` [PATCH 2/2] drm/amdgpu/gmc11: set gart placement GC11 Alex Deucher
@ 2023-09-28 13:23 ` Alex Deucher
  2023-09-29 10:41   ` Christian König
  1 sibling, 1 reply; 9+ messages in thread
From: Alex Deucher @ 2023-09-28 13:23 UTC (permalink / raw)
  To: Alex Deucher; +Cc: amd-gfx

Ping on this series?  Fixes an issue for SR-IOV in stress tests.

Alex

On Wed, Sep 27, 2023 at 2:31 PM Alex Deucher <alexander.deucher@amd.com> wrote:
>
> We normally place GART based on the location of VRAM and the
> available address space around that, but provide an option
> to force a particular location for hardware that needs it.
>
> v2: Switch to passing the placement via parameter
>
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 22 +++++++++++++++++-----
>  drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h |  9 ++++++++-
>  drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c  |  2 +-
>  drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c  |  2 +-
>  drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c   |  2 +-
>  drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c   |  2 +-
>  drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c   |  2 +-
>  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c   |  2 +-
>  8 files changed, 31 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> index 2bfeaacd050c..60c81c3d29d5 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> @@ -269,7 +269,8 @@ void amdgpu_gmc_sysvm_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc
>   * If GART size is bigger than space left then we ajust GART size.
>   * Thus function will never fails.
>   */
> -void amdgpu_gmc_gart_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc)
> +void amdgpu_gmc_gart_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc,
> +                             enum amdgpu_gart_placement gart_placement)
>  {
>         const uint64_t four_gb = 0x100000000ULL;
>         u64 size_af, size_bf;
> @@ -287,11 +288,22 @@ void amdgpu_gmc_gart_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc)
>                 mc->gart_size = max(size_bf, size_af);
>         }
>
> -       if ((size_bf >= mc->gart_size && size_bf < size_af) ||
> -           (size_af < mc->gart_size))
> -               mc->gart_start = 0;
> -       else
> +       switch (gart_placement) {
> +       case AMDGPU_GART_PLACEMENT_HIGH:
>                 mc->gart_start = max_mc_address - mc->gart_size + 1;
> +               break;
> +       case AMDGPU_GART_PLACEMENT_LOW:
> +               mc->gart_start = 0;
> +               break;
> +       case AMDGPU_GART_PLACEMENT_BEST_FIT:
> +       default:
> +               if ((size_bf >= mc->gart_size && size_bf < size_af) ||
> +                   (size_af < mc->gart_size))
> +                       mc->gart_start = 0;
> +               else
> +                       mc->gart_start = max_mc_address - mc->gart_size + 1;
> +               break;
> +       }
>
>         mc->gart_start &= ~(four_gb - 1);
>         mc->gart_end = mc->gart_start + mc->gart_size - 1;
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
> index f593259a66c3..e699d1ca8deb 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
> @@ -199,6 +199,12 @@ struct amdgpu_mem_partition_info {
>
>  #define INVALID_PFN    -1
>
> +enum amdgpu_gart_placement {
> +       AMDGPU_GART_PLACEMENT_BEST_FIT = 0,
> +       AMDGPU_GART_PLACEMENT_HIGH,
> +       AMDGPU_GART_PLACEMENT_LOW,
> +};
> +
>  struct amdgpu_gmc {
>         /* FB's physical address in MMIO space (for CPU to
>          * map FB). This is different compared to the agp/
> @@ -391,7 +397,8 @@ void amdgpu_gmc_sysvm_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc
>  void amdgpu_gmc_vram_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc,
>                               u64 base);
>  void amdgpu_gmc_gart_location(struct amdgpu_device *adev,
> -                             struct amdgpu_gmc *mc);
> +                             struct amdgpu_gmc *mc,
> +                             enum amdgpu_gart_placement gart_placement);
>  void amdgpu_gmc_agp_location(struct amdgpu_device *adev,
>                              struct amdgpu_gmc *mc);
>  void amdgpu_gmc_set_agp_default(struct amdgpu_device *adev,
> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
> index 70370b412d24..8e6e36279389 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
> @@ -670,7 +670,7 @@ static void gmc_v10_0_vram_gtt_location(struct amdgpu_device *adev,
>         base += adev->gmc.xgmi.physical_node_id * adev->gmc.xgmi.node_segment_size;
>
>         amdgpu_gmc_vram_location(adev, &adev->gmc, base);
> -       amdgpu_gmc_gart_location(adev, mc);
> +       amdgpu_gmc_gart_location(adev, mc, AMDGPU_GART_PLACEMENT_BEST_FIT);
>         if (!amdgpu_sriov_vf(adev))
>                 amdgpu_gmc_agp_location(adev, mc);
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c
> index d0a9ee2f12d3..d611d2efce3b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c
> @@ -634,7 +634,7 @@ static void gmc_v11_0_vram_gtt_location(struct amdgpu_device *adev,
>         base = adev->mmhub.funcs->get_fb_location(adev);
>
>         amdgpu_gmc_vram_location(adev, &adev->gmc, base);
> -       amdgpu_gmc_gart_location(adev, mc);
> +       amdgpu_gmc_gart_location(adev, mc, AMDGPU_GART_PLACEMENT_BEST_FIT);
>         if (!amdgpu_sriov_vf(adev) ||
>             (amdgpu_ip_version(adev, GC_HWIP, 0) < IP_VERSION(11, 5, 0)))
>                 amdgpu_gmc_agp_location(adev, mc);
> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
> index 3f31f268e0eb..7f66954fd302 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
> @@ -212,7 +212,7 @@ static void gmc_v6_0_vram_gtt_location(struct amdgpu_device *adev,
>         base <<= 24;
>
>         amdgpu_gmc_vram_location(adev, mc, base);
> -       amdgpu_gmc_gart_location(adev, mc);
> +       amdgpu_gmc_gart_location(adev, mc, AMDGPU_GART_PLACEMENT_BEST_FIT);
>  }
>
>  static void gmc_v6_0_mc_program(struct amdgpu_device *adev)
> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
> index a72dc21cf6fc..3869cefab7bd 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
> @@ -240,7 +240,7 @@ static void gmc_v7_0_vram_gtt_location(struct amdgpu_device *adev,
>         base <<= 24;
>
>         amdgpu_gmc_vram_location(adev, mc, base);
> -       amdgpu_gmc_gart_location(adev, mc);
> +       amdgpu_gmc_gart_location(adev, mc, AMDGPU_GART_PLACEMENT_BEST_FIT);
>  }
>
>  /**
> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
> index 8ce77d074d17..4126172feb7f 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
> @@ -414,7 +414,7 @@ static void gmc_v8_0_vram_gtt_location(struct amdgpu_device *adev,
>         base <<= 24;
>
>         amdgpu_gmc_vram_location(adev, mc, base);
> -       amdgpu_gmc_gart_location(adev, mc);
> +       amdgpu_gmc_gart_location(adev, mc, AMDGPU_GART_PLACEMENT_BEST_FIT);
>  }
>
>  /**
> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> index 6b15677c0314..37e96d9d30a3 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> @@ -1611,7 +1611,7 @@ static void gmc_v9_0_vram_gtt_location(struct amdgpu_device *adev,
>                 amdgpu_gmc_sysvm_location(adev, mc);
>         } else {
>                 amdgpu_gmc_vram_location(adev, mc, base);
> -               amdgpu_gmc_gart_location(adev, mc);
> +               amdgpu_gmc_gart_location(adev, mc, AMDGPU_GART_PLACEMENT_BEST_FIT);
>                 if (!amdgpu_sriov_vf(adev))
>                         amdgpu_gmc_agp_location(adev, mc);
>         }
> --
> 2.41.0
>

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

* Re: [PATCH 1/2] drm/amdgpu/gmc: add a way to force a particular placement for GART
  2023-09-28 13:23 ` [PATCH 1/2] drm/amdgpu/gmc: add a way to force a particular placement for GART Alex Deucher
@ 2023-09-29 10:41   ` Christian König
  0 siblings, 0 replies; 9+ messages in thread
From: Christian König @ 2023-09-29 10:41 UTC (permalink / raw)
  To: Alex Deucher, Alex Deucher; +Cc: amd-gfx

As discussed on yesterdays call feel free to add my rb to the series.

Christian.

Am 28.09.23 um 15:23 schrieb Alex Deucher:
> Ping on this series?  Fixes an issue for SR-IOV in stress tests.
>
> Alex
>
> On Wed, Sep 27, 2023 at 2:31 PM Alex Deucher <alexander.deucher@amd.com> wrote:
>> We normally place GART based on the location of VRAM and the
>> available address space around that, but provide an option
>> to force a particular location for hardware that needs it.
>>
>> v2: Switch to passing the placement via parameter
>>
>> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 22 +++++++++++++++++-----
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h |  9 ++++++++-
>>   drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c  |  2 +-
>>   drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c  |  2 +-
>>   drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c   |  2 +-
>>   drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c   |  2 +-
>>   drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c   |  2 +-
>>   drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c   |  2 +-
>>   8 files changed, 31 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
>> index 2bfeaacd050c..60c81c3d29d5 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
>> @@ -269,7 +269,8 @@ void amdgpu_gmc_sysvm_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc
>>    * If GART size is bigger than space left then we ajust GART size.
>>    * Thus function will never fails.
>>    */
>> -void amdgpu_gmc_gart_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc)
>> +void amdgpu_gmc_gart_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc,
>> +                             enum amdgpu_gart_placement gart_placement)
>>   {
>>          const uint64_t four_gb = 0x100000000ULL;
>>          u64 size_af, size_bf;
>> @@ -287,11 +288,22 @@ void amdgpu_gmc_gart_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc)
>>                  mc->gart_size = max(size_bf, size_af);
>>          }
>>
>> -       if ((size_bf >= mc->gart_size && size_bf < size_af) ||
>> -           (size_af < mc->gart_size))
>> -               mc->gart_start = 0;
>> -       else
>> +       switch (gart_placement) {
>> +       case AMDGPU_GART_PLACEMENT_HIGH:
>>                  mc->gart_start = max_mc_address - mc->gart_size + 1;
>> +               break;
>> +       case AMDGPU_GART_PLACEMENT_LOW:
>> +               mc->gart_start = 0;
>> +               break;
>> +       case AMDGPU_GART_PLACEMENT_BEST_FIT:
>> +       default:
>> +               if ((size_bf >= mc->gart_size && size_bf < size_af) ||
>> +                   (size_af < mc->gart_size))
>> +                       mc->gart_start = 0;
>> +               else
>> +                       mc->gart_start = max_mc_address - mc->gart_size + 1;
>> +               break;
>> +       }
>>
>>          mc->gart_start &= ~(four_gb - 1);
>>          mc->gart_end = mc->gart_start + mc->gart_size - 1;
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
>> index f593259a66c3..e699d1ca8deb 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
>> @@ -199,6 +199,12 @@ struct amdgpu_mem_partition_info {
>>
>>   #define INVALID_PFN    -1
>>
>> +enum amdgpu_gart_placement {
>> +       AMDGPU_GART_PLACEMENT_BEST_FIT = 0,
>> +       AMDGPU_GART_PLACEMENT_HIGH,
>> +       AMDGPU_GART_PLACEMENT_LOW,
>> +};
>> +
>>   struct amdgpu_gmc {
>>          /* FB's physical address in MMIO space (for CPU to
>>           * map FB). This is different compared to the agp/
>> @@ -391,7 +397,8 @@ void amdgpu_gmc_sysvm_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc
>>   void amdgpu_gmc_vram_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc,
>>                                u64 base);
>>   void amdgpu_gmc_gart_location(struct amdgpu_device *adev,
>> -                             struct amdgpu_gmc *mc);
>> +                             struct amdgpu_gmc *mc,
>> +                             enum amdgpu_gart_placement gart_placement);
>>   void amdgpu_gmc_agp_location(struct amdgpu_device *adev,
>>                               struct amdgpu_gmc *mc);
>>   void amdgpu_gmc_set_agp_default(struct amdgpu_device *adev,
>> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
>> index 70370b412d24..8e6e36279389 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
>> @@ -670,7 +670,7 @@ static void gmc_v10_0_vram_gtt_location(struct amdgpu_device *adev,
>>          base += adev->gmc.xgmi.physical_node_id * adev->gmc.xgmi.node_segment_size;
>>
>>          amdgpu_gmc_vram_location(adev, &adev->gmc, base);
>> -       amdgpu_gmc_gart_location(adev, mc);
>> +       amdgpu_gmc_gart_location(adev, mc, AMDGPU_GART_PLACEMENT_BEST_FIT);
>>          if (!amdgpu_sriov_vf(adev))
>>                  amdgpu_gmc_agp_location(adev, mc);
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c
>> index d0a9ee2f12d3..d611d2efce3b 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c
>> @@ -634,7 +634,7 @@ static void gmc_v11_0_vram_gtt_location(struct amdgpu_device *adev,
>>          base = adev->mmhub.funcs->get_fb_location(adev);
>>
>>          amdgpu_gmc_vram_location(adev, &adev->gmc, base);
>> -       amdgpu_gmc_gart_location(adev, mc);
>> +       amdgpu_gmc_gart_location(adev, mc, AMDGPU_GART_PLACEMENT_BEST_FIT);
>>          if (!amdgpu_sriov_vf(adev) ||
>>              (amdgpu_ip_version(adev, GC_HWIP, 0) < IP_VERSION(11, 5, 0)))
>>                  amdgpu_gmc_agp_location(adev, mc);
>> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
>> index 3f31f268e0eb..7f66954fd302 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
>> @@ -212,7 +212,7 @@ static void gmc_v6_0_vram_gtt_location(struct amdgpu_device *adev,
>>          base <<= 24;
>>
>>          amdgpu_gmc_vram_location(adev, mc, base);
>> -       amdgpu_gmc_gart_location(adev, mc);
>> +       amdgpu_gmc_gart_location(adev, mc, AMDGPU_GART_PLACEMENT_BEST_FIT);
>>   }
>>
>>   static void gmc_v6_0_mc_program(struct amdgpu_device *adev)
>> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
>> index a72dc21cf6fc..3869cefab7bd 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
>> @@ -240,7 +240,7 @@ static void gmc_v7_0_vram_gtt_location(struct amdgpu_device *adev,
>>          base <<= 24;
>>
>>          amdgpu_gmc_vram_location(adev, mc, base);
>> -       amdgpu_gmc_gart_location(adev, mc);
>> +       amdgpu_gmc_gart_location(adev, mc, AMDGPU_GART_PLACEMENT_BEST_FIT);
>>   }
>>
>>   /**
>> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
>> index 8ce77d074d17..4126172feb7f 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
>> @@ -414,7 +414,7 @@ static void gmc_v8_0_vram_gtt_location(struct amdgpu_device *adev,
>>          base <<= 24;
>>
>>          amdgpu_gmc_vram_location(adev, mc, base);
>> -       amdgpu_gmc_gart_location(adev, mc);
>> +       amdgpu_gmc_gart_location(adev, mc, AMDGPU_GART_PLACEMENT_BEST_FIT);
>>   }
>>
>>   /**
>> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
>> index 6b15677c0314..37e96d9d30a3 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
>> @@ -1611,7 +1611,7 @@ static void gmc_v9_0_vram_gtt_location(struct amdgpu_device *adev,
>>                  amdgpu_gmc_sysvm_location(adev, mc);
>>          } else {
>>                  amdgpu_gmc_vram_location(adev, mc, base);
>> -               amdgpu_gmc_gart_location(adev, mc);
>> +               amdgpu_gmc_gart_location(adev, mc, AMDGPU_GART_PLACEMENT_BEST_FIT);
>>                  if (!amdgpu_sriov_vf(adev))
>>                          amdgpu_gmc_agp_location(adev, mc);
>>          }
>> --
>> 2.41.0
>>


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

end of thread, other threads:[~2023-09-29 10:41 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-27 18:12 [PATCH 1/2] drm/amdgpu/gmc: add a way to force a particular placement for GART Alex Deucher
2023-09-27 18:12 ` [PATCH 2/2] drm/amdgpu/gmc11: set gart placement GC11 Alex Deucher
2023-09-28 13:23 ` [PATCH 1/2] drm/amdgpu/gmc: add a way to force a particular placement for GART Alex Deucher
2023-09-29 10:41   ` Christian König
  -- strict thread matches above, loose matches on Subject: below --
2023-09-21 21:40 Alex Deucher
2023-09-26 17:30 ` Alex Deucher
2023-09-27  5:37   ` Christian König
2023-09-27 15:13     ` Alex Deucher
2023-09-27 14:12   ` Wang, Yang(Kevin)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox