[Public]

In that case, how do we know we can skip the gart setup in 
amdgpu_ttm_alloc_gart()?

Alex
________________________________
From: Koenig, Christian <christian.koe...@amd.com>
Sent: Friday, November 10, 2023 9:20 AM
To: Deucher, Alexander <alexander.deuc...@amd.com>; Zhang, Yifan 
<yifan1.zh...@amd.com>; amd-gfx@lists.freedesktop.org 
<amd-gfx@lists.freedesktop.org>
Cc: Zhang, Jesse(Jie) <jesse.zh...@amd.com>
Subject: Re: [PATCH] drm/amdgpu: exclude domain start when calucales offset for 
AGP aperture BOs

No, that's broken as well.

The problem is in amdgpu_ttm_alloc_gart():

        if (addr != AMDGPU_BO_INVALID_OFFSET) {
                bo->resource->start = addr >> PAGE_SHIFT;
                return 0;
        }

bo->resource->start is relative to the GART address, so we can't assign the AGP 
address here in the first place.

What we need to do is to drop this and call amdgpu_gmc_agp_addr() from 
amdgpu_bo_gpu_offset_no_check().

Regards,
Christian.

Am 10.11.23 um 15:17 schrieb Deucher, Alexander:

[Public]

I think the proper fix is probably to just drop the addition of agp_start in 
amdgpu_gmc_agp_addr().

Alex
________________________________
From: Deucher, Alexander 
<alexander.deuc...@amd.com><mailto:alexander.deuc...@amd.com>
Sent: Friday, November 10, 2023 9:16 AM
To: Koenig, Christian 
<christian.koe...@amd.com><mailto:christian.koe...@amd.com>; Zhang, Yifan 
<yifan1.zh...@amd.com><mailto:yifan1.zh...@amd.com>; 
amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org> 
<amd-gfx@lists.freedesktop.org><mailto:amd-gfx@lists.freedesktop.org>
Cc: Zhang, Jesse(Jie) <jesse.zh...@amd.com><mailto:jesse.zh...@amd.com>
Subject: Re: [PATCH] drm/amdgpu: exclude domain start when calucales offset for 
AGP aperture BOs

It happens in amdgpu_gmc_agp_addr() which is called from 
amdgpu_ttm_alloc_gart().

Alex
________________________________
From: Koenig, Christian 
<christian.koe...@amd.com><mailto:christian.koe...@amd.com>
Sent: Friday, November 10, 2023 9:14 AM
To: Zhang, Yifan <yifan1.zh...@amd.com><mailto:yifan1.zh...@amd.com>; 
amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org> 
<amd-gfx@lists.freedesktop.org><mailto:amd-gfx@lists.freedesktop.org>
Cc: Deucher, Alexander 
<alexander.deuc...@amd.com><mailto:alexander.deuc...@amd.com>; Zhang, 
Jesse(Jie) <jesse.zh...@amd.com><mailto:jesse.zh...@amd.com>
Subject: Re: [PATCH] drm/amdgpu: exclude domain start when calucales offset for 
AGP aperture BOs

Am 10.11.23 um 13:52 schrieb Yifan Zhang:
> For BOs in AGP aperture, tbo.resource->start includes AGP aperture start.


Well big NAK to that. tbo.resource->start should never ever include the
AGP aperture start in the first place.

How did that happen?

Regards,
Christian.

> Don't add it again in amdgpu_bo_gpu_offset. This issue was mitigated due to
> GART aperture start was 0 until this patch ("a013c94d5aca drm/amdgpu/gmc11:
> set gart placement GC11") changes GART start to a non-zero value.
>
> Reported-by: Jesse Zhang <jesse.zh...@amd.com><mailto:jesse.zh...@amd.com>
> Signed-off-by: Yifan Zhang <yifan1.zh...@amd.com><mailto:yifan1.zh...@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c    |  7 +++++++
>   drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h    |  1 +
>   drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 10 ++++++++--
>   3 files changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> index 5f71414190e9..00e940eb69ab 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> @@ -169,6 +169,13 @@ int amdgpu_gmc_set_pte_pde(struct amdgpu_device *adev, 
> void *cpu_pt_addr,
>        return 0;
>   }
>
> +bool bo_in_agp_aperture(struct amdgpu_bo *bo)
> +{
> +     struct ttm_buffer_object *tbo = &(bo->tbo);
> +     struct amdgpu_device *adev = amdgpu_ttm_adev(tbo->bdev);
> +
> +     return (tbo->resource->start << PAGE_SHIFT) > adev->gmc.agp_start;
> +}
>   /**
>    * amdgpu_gmc_agp_addr - return the address in the AGP address space
>    *
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
> index e699d1ca8deb..448dc08e83de 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
> @@ -393,6 +393,7 @@ int amdgpu_gmc_set_pte_pde(struct amdgpu_device *adev, 
> void *cpu_pt_addr,
>                                uint64_t flags);
>   uint64_t amdgpu_gmc_pd_addr(struct amdgpu_bo *bo);
>   uint64_t amdgpu_gmc_agp_addr(struct ttm_buffer_object *bo);
> +bool bo_in_agp_aperture(struct amdgpu_bo *bo);
>   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);
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> index cef920a93924..91a011d63ab4 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> @@ -39,6 +39,7 @@
>   #include "amdgpu.h"
>   #include "amdgpu_trace.h"
>   #include "amdgpu_amdkfd.h"
> +#include "amdgpu_gmc.h"
>
>   /**
>    * DOC: amdgpu_object
> @@ -1529,8 +1530,13 @@ u64 amdgpu_bo_gpu_offset_no_check(struct amdgpu_bo *bo)
>        struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
>        uint64_t offset;
>
> -     offset = (bo->tbo.resource->start << PAGE_SHIFT) +
> -              amdgpu_ttm_domain_start(adev, bo->tbo.resource->mem_type);
> +     /* tbo.resource->start includes agp_start for AGP BOs */
> +     if (bo_in_agp_aperture(bo)) {
> +             offset = (bo->tbo.resource->start << PAGE_SHIFT);
> +     } else {
> +             offset = (bo->tbo.resource->start << PAGE_SHIFT) +
> +                      amdgpu_ttm_domain_start(adev, 
> bo->tbo.resource->mem_type);
> +     }
>
>        return amdgpu_gmc_sign_extend(offset);
>   }


Reply via email to