From: "Christian König" <christian.koenig@amd.com>
To: "Timur Kristóf" <timur.kristof@gmail.com>,
amd-gfx@lists.freedesktop.org,
"Alex Deucher" <alexander.deucher@amd.com>,
"Alexandre Demers" <alexandre.f.demers@gmail.com>,
"Rodrigo Siqueira" <siqueira@igalia.com>
Subject: Re: [PATCH 11/14] drm/amdgpu/vce1: Ensure VCPU BO is in lower 32-bit address space
Date: Wed, 29 Oct 2025 12:41:07 +0100 [thread overview]
Message-ID: <8d716ca2-43d3-4c69-8d6a-e270c357c44d@amd.com> (raw)
In-Reply-To: <20251028220628.8371-12-timur.kristof@gmail.com>
On 10/28/25 23:06, Timur Kristóf wrote:
> Based on research carried out by Alexandre and Christian.
>
> VCE1 actually executes its code from the VCPU BO.
> Due to various hardware limitations, the VCE1 requires
> the VCPU BO to be in the low 32 bit address range.
> However, VRAM is typically mapped at the high address range,
> which means the VCPU can't access VRAM through the FB aperture.
>
> To solve this, we write a few page table entries to
> map the VCPU BO in the GART address range. And we make sure
> that the GART is located at the low address range.
> That way the VCE1 can access the VCPU BO.
>
> Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
> Co-developed-by: Alexandre Demers <alexandre.f.demers@gmail.com>
> Signed-off-by: Alexandre Demers <alexandre.f.demers@gmail.com>
> Co-developed-by: Christian König <christian.koenig@amd.com>
> Signed-off-by: Christian König <christian.koenig@amd.com>
Make that a suggested-by and drop co-developed and signed-off-by for me.
The code was solely written by you if I'm not completely mistaken.
Patch itself is Reviewed-by: Christian König <christian.koenig@amd.com>
Regards,
Christian.
> ---
> drivers/gpu/drm/amd/amdgpu/vce_v1_0.c | 44 +++++++++++++++++++++++++++
> 1 file changed, 44 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v1_0.c b/drivers/gpu/drm/amd/amdgpu/vce_v1_0.c
> index e62fd8ed1992..27f70146293d 100644
> --- a/drivers/gpu/drm/amd/amdgpu/vce_v1_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/vce_v1_0.c
> @@ -34,6 +34,7 @@
>
> #include "amdgpu.h"
> #include "amdgpu_vce.h"
> +#include "amdgpu_gart.h"
> #include "sid.h"
> #include "vce_v1_0.h"
> #include "vce/vce_1_0_d.h"
> @@ -46,6 +47,11 @@
> #define VCE_V1_0_DATA_SIZE (7808 * (AMDGPU_MAX_VCE_HANDLES + 1))
> #define VCE_STATUS_VCPU_REPORT_FW_LOADED_MASK 0x02
>
> +#define VCE_V1_0_GART_PAGE_START \
> + (AMDGPU_GTT_MAX_TRANSFER_SIZE * AMDGPU_GTT_NUM_TRANSFER_WINDOWS)
> +#define VCE_V1_0_GART_ADDR_START \
> + (VCE_V1_0_GART_PAGE_START * AMDGPU_GPU_PAGE_SIZE)
> +
> static void vce_v1_0_set_ring_funcs(struct amdgpu_device *adev);
> static void vce_v1_0_set_irq_funcs(struct amdgpu_device *adev);
>
> @@ -535,6 +541,38 @@ static int vce_v1_0_early_init(struct amdgpu_ip_block *ip_block)
> return 0;
> }
>
> +/**
> + * vce_v1_0_ensure_vcpu_bo_32bit_addr() - ensure the VCPU BO has a 32-bit address
> + *
> + * @adev: amdgpu_device pointer
> + *
> + * Due to various hardware limitations, the VCE1 requires
> + * the VCPU BO to be in the low 32 bit address range.
> + * Ensure that the VCPU BO has a 32-bit GPU address,
> + * or return an error code when that isn't possible.
> + */
> +static int vce_v1_0_ensure_vcpu_bo_32bit_addr(struct amdgpu_device *adev)
> +{
> + const u64 gpu_addr = amdgpu_bo_gpu_offset(adev->vce.vcpu_bo);
> + const u64 bo_size = amdgpu_bo_size(adev->vce.vcpu_bo);
> + const u64 max_vcpu_bo_addr = 0xffffffff - bo_size;
> +
> + /* Check if the VCPU BO already has a 32-bit address.
> + * Eg. if MC is configured to put VRAM in the low address range.
> + */
> + if (gpu_addr <= max_vcpu_bo_addr)
> + return 0;
> +
> + /* Check if we can map the VCPU BO in GART to a 32-bit address. */
> + if (adev->gmc.gart_start + VCE_V1_0_GART_ADDR_START > max_vcpu_bo_addr)
> + return -EINVAL;
> +
> + amdgpu_gart_bind_vram_bo(adev, VCE_V1_0_GART_ADDR_START, adev->vce.vcpu_bo,
> + AMDGPU_PTE_READABLE | AMDGPU_PTE_WRITEABLE | AMDGPU_PTE_VALID);
> + adev->vce.gpu_addr = adev->gmc.gart_start + VCE_V1_0_GART_ADDR_START;
> + return 0;
> +}
> +
> static int vce_v1_0_sw_init(struct amdgpu_ip_block *ip_block)
> {
> struct amdgpu_device *adev = ip_block->adev;
> @@ -554,6 +592,9 @@ static int vce_v1_0_sw_init(struct amdgpu_ip_block *ip_block)
> if (r)
> return r;
> r = vce_v1_0_load_fw_signature(adev);
> + if (r)
> + return r;
> + r = vce_v1_0_ensure_vcpu_bo_32bit_addr(adev);
> if (r)
> return r;
>
> @@ -669,6 +710,9 @@ static int vce_v1_0_resume(struct amdgpu_ip_block *ip_block)
> if (r)
> return r;
> r = vce_v1_0_load_fw_signature(adev);
> + if (r)
> + return r;
> + r = vce_v1_0_ensure_vcpu_bo_32bit_addr(adev);
> if (r)
> return r;
>
next prev parent reply other threads:[~2025-10-29 11:41 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-28 22:06 [PATCH 00/14] drm/amdgpu: Support VCE1 IP block Timur Kristóf
2025-10-28 22:06 ` [PATCH 01/14] drm/amdgpu/gmc: Don't hardcode GART page count before GTT Timur Kristóf
2025-10-29 10:00 ` Christian König
2025-10-29 11:41 ` Timur Kristóf
2025-10-28 22:06 ` [PATCH 02/14] drm/amdgpu/gmc6: Place gart at low address range Timur Kristóf
2025-10-29 10:00 ` Christian König
2025-10-28 22:06 ` [PATCH 03/14] drm/amdgpu/gmc6: Add GART space for VCPU BO Timur Kristóf
2025-10-29 10:05 ` Christian König
2025-10-29 11:26 ` Timur Kristóf
2025-10-28 22:06 ` [PATCH 04/14] drm/amdgpu/gart: Add helper to bind VRAM BO Timur Kristóf
2025-10-29 10:16 ` Christian König
2025-10-29 10:57 ` Timur Kristóf
2025-10-28 22:06 ` [PATCH 05/14] drm/amdgpu/vce: Clear VCPU BO before copying firmware to it Timur Kristóf
2025-10-29 10:19 ` Christian König
2025-10-29 10:48 ` Timur Kristóf
2025-10-28 22:06 ` [PATCH 06/14] drm/amdgpu/vce: Move firmware load to amdgpu_vce_early_init Timur Kristóf
2025-10-29 10:26 ` Christian König
2025-10-29 17:16 ` Liu, Leo
2025-10-28 22:06 ` [PATCH 07/14] drm/amdgpu/si, cik, vi: Verify IP block when querying video codecs Timur Kristóf
2025-10-29 10:35 ` Christian König
2025-10-29 10:54 ` [PATCH 07/14] drm/amdgpu/si,cik,vi: " Timur Kristóf
2025-10-28 22:06 ` [PATCH 08/14] drm/amdgpu/vce1: Clean up register definitions Timur Kristóf
2025-10-29 11:23 ` Christian König
2025-10-28 22:06 ` [PATCH 09/14] drm/amdgpu/vce1: Load VCE1 firmware Timur Kristóf
2025-10-29 11:28 ` Christian König
2025-10-28 22:06 ` [PATCH 10/14] drm/amdgpu/vce1: Implement VCE1 IP block Timur Kristóf
2025-10-29 11:38 ` Christian König
2025-10-29 22:48 ` Timur Kristóf
2025-10-30 11:12 ` Christian König
2025-10-30 13:47 ` Timur Kristóf
2025-10-30 13:56 ` Christian König
2025-10-28 22:06 ` [PATCH 11/14] drm/amdgpu/vce1: Ensure VCPU BO is in lower 32-bit address space Timur Kristóf
2025-10-29 11:41 ` Christian König [this message]
2025-10-28 22:06 ` [PATCH 12/14] drm/amd/pm/si: Hook up VCE1 to SI DPM Timur Kristóf
2025-10-29 11:47 ` Christian König
2025-10-28 22:06 ` [PATCH 13/14] drm/amdgpu/vce1: Enable VCE1 on Tahiti, Pitcairn, Cape Verde GPUs Timur Kristóf
2025-10-29 11:51 ` Christian König
2025-10-28 22:06 ` [PATCH 14/14] drm/amdgpu/vce1: Tolerate VCE PLL timeout better Timur Kristóf
2025-10-29 12:02 ` Christian König
2025-10-29 19:46 ` Deucher, Alexander
2025-11-03 16:01 ` timur.kristof
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=8d716ca2-43d3-4c69-8d6a-e270c357c44d@amd.com \
--to=christian.koenig@amd.com \
--cc=alexander.deucher@amd.com \
--cc=alexandre.f.demers@gmail.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=siqueira@igalia.com \
--cc=timur.kristof@gmail.com \
/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.