All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: Alex Deucher <alexander.deucher@amd.com>, amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/amdgpu/gmc: use PCI BARs for APUs in passthrough
Date: Wed, 16 Mar 2022 08:18:06 +0100	[thread overview]
Message-ID: <c7e4568e-5bee-ab1c-cc4f-5985200f0fa8@gmail.com> (raw)
In-Reply-To: <20220315181300.2808453-1-alexander.deucher@amd.com>

Am 15.03.22 um 19:13 schrieb Alex Deucher:
> If the GPU is passed through to a guest VM, use the PCI
> BAR for CPU FB access rather than the physical address of
> carve out.  The physical address is not valid in a guest.
>
> v2: Fix HDP handing as suggested by Michel
>
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

Might be a good idea to have a function or macro to figure out if we 
should use the BAR or not on APUs.

Anyway patch is Reviewed-by: Christian König <christian.koenig@amd.com>.

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 ++--
>   drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c     | 2 +-
>   drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c      | 5 +++--
>   drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c      | 2 +-
>   drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c      | 2 +-
>   5 files changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index 1b313a95c7e5..eb902654f35d 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -5733,7 +5733,7 @@ void amdgpu_device_flush_hdp(struct amdgpu_device *adev,
>   		struct amdgpu_ring *ring)
>   {
>   #ifdef CONFIG_X86_64
> -	if (adev->flags & AMD_IS_APU)
> +	if ((adev->flags & AMD_IS_APU) && !amdgpu_passthrough(adev))
>   		return;
>   #endif
>   	if (adev->gmc.xgmi.connected_to_cpu)
> @@ -5749,7 +5749,7 @@ void amdgpu_device_invalidate_hdp(struct amdgpu_device *adev,
>   		struct amdgpu_ring *ring)
>   {
>   #ifdef CONFIG_X86_64
> -	if (adev->flags & AMD_IS_APU)
> +	if ((adev->flags & AMD_IS_APU) && !amdgpu_passthrough(adev))
>   		return;
>   #endif
>   	if (adev->gmc.xgmi.connected_to_cpu)
> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
> index f60b7bd4dbf5..9887a60e8eae 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
> @@ -814,7 +814,7 @@ static int gmc_v10_0_mc_init(struct amdgpu_device *adev)
>   	adev->gmc.aper_size = pci_resource_len(adev->pdev, 0);
>   
>   #ifdef CONFIG_X86_64
> -	if (adev->flags & AMD_IS_APU) {
> +	if ((adev->flags & AMD_IS_APU) && !amdgpu_passthrough(adev)) {
>   		adev->gmc.aper_base = adev->gfxhub.funcs->get_mc_fb_offset(adev);
>   		adev->gmc.aper_size = adev->gmc.real_vram_size;
>   	}
> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
> index 344d819b4c1b..979da6f510e8 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
> @@ -381,8 +381,9 @@ static int gmc_v7_0_mc_init(struct amdgpu_device *adev)
>   	adev->gmc.aper_size = pci_resource_len(adev->pdev, 0);
>   
>   #ifdef CONFIG_X86_64
> -	if (adev->flags & AMD_IS_APU &&
> -	    adev->gmc.real_vram_size > adev->gmc.aper_size) {
> +	if ((adev->flags & AMD_IS_APU) &&
> +	    adev->gmc.real_vram_size > adev->gmc.aper_size &&
> +	    !amdgpu_passthrough(adev)) {
>   		adev->gmc.aper_base = ((u64)RREG32(mmMC_VM_FB_OFFSET)) << 22;
>   		adev->gmc.aper_size = adev->gmc.real_vram_size;
>   	}
> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
> index ca9841d5669f..1932a3e4af7e 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
> @@ -581,7 +581,7 @@ static int gmc_v8_0_mc_init(struct amdgpu_device *adev)
>   	adev->gmc.aper_size = pci_resource_len(adev->pdev, 0);
>   
>   #ifdef CONFIG_X86_64
> -	if (adev->flags & AMD_IS_APU) {
> +	if ((adev->flags & AMD_IS_APU) && !amdgpu_passthrough(adev)) {
>   		adev->gmc.aper_base = ((u64)RREG32(mmMC_VM_FB_OFFSET)) << 22;
>   		adev->gmc.aper_size = adev->gmc.real_vram_size;
>   	}
> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> index 431742eb7811..5fa613d41799 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> @@ -1456,7 +1456,7 @@ static int gmc_v9_0_mc_init(struct amdgpu_device *adev)
>   	 */
>   
>   	/* check whether both host-gpu and gpu-gpu xgmi links exist */
> -	if ((adev->flags & AMD_IS_APU) ||
> +	if (((adev->flags & AMD_IS_APU) && !amdgpu_passthrough(adev)) ||
>   	    (adev->gmc.xgmi.supported &&
>   	     adev->gmc.xgmi.connected_to_cpu)) {
>   		adev->gmc.aper_base =


  reply	other threads:[~2022-03-16  7:18 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-15 18:13 [PATCH] drm/amdgpu/gmc: use PCI BARs for APUs in passthrough Alex Deucher
2022-03-16  7:18 ` Christian König [this message]
2022-03-16 15:59   ` Michel Dänzer
  -- strict thread matches above, loose matches on Subject: below --
2022-03-10 18:06 Alex Deucher
2022-03-11 10:24 ` Michel Dänzer
2022-03-11 10:32   ` Christian König
2022-03-11 17:43     ` Michel Dänzer
2022-03-16 15:52       ` Michel Dänzer
2022-03-16 15:55         ` Alex Deucher
2022-03-16 15:58           ` Michel Dänzer
2022-03-11 12:17 ` Christian König

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c7e4568e-5bee-ab1c-cc4f-5985200f0fa8@gmail.com \
    --to=ckoenig.leichtzumerken@gmail.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.