From: Lang Yu <Lang.Yu@amd.com>
To: <amd-gfx@lists.freedesktop.org>
Cc: Alex Deucher <alexander.deucher@amd.com>,
Yifan Zhang <yifan1.zhang@amd.com>, Lang Yu <Lang.Yu@amd.com>,
Christian Koenig <christian.koenig@amd.com>,
Arunpravin Paneer Selvam <Arunpravin.PaneerSelvam@amd.com>
Subject: [PATCH 2/2] drm/amdgpu: use amdgpu_bo_create_kernel_at() to create large TMR for APU
Date: Thu, 27 Jul 2023 15:56:20 +0800 [thread overview]
Message-ID: <20230727075620.728235-2-Lang.Yu@amd.com> (raw)
In-Reply-To: <20230727075620.728235-1-Lang.Yu@amd.com>
TMR requires physical contiguous memory, amdgpu_bo_create_kernel()
can't satisfy large(>128MB) physical contiguous memory allocation
request with default 512MB VRAM on APU.
When requested TMR size > 128MB, use amdgpu_bo_create_kernel_at()
to create the TMR BO at offset 64MB.
Signed-off-by: Lang Yu <Lang.Yu@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 42 ++++++++++++++++---------
1 file changed, 28 insertions(+), 14 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index 15217e33b51d..2eac82113d34 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -783,13 +783,38 @@ static bool psp_boottime_tmr(struct psp_context *psp)
}
}
+static inline int psp_create_tmr_bo(struct psp_context *psp, int tmr_size)
+{
+ void *tmr_buf;
+ void **pptr;
+ int ret;
+
+ if (psp->tmr_bo)
+ return 0;
+
+ pptr = amdgpu_sriov_vf(psp->adev) ? &tmr_buf : NULL;
+
+ if (psp->adev->flags & AMD_IS_APU && tmr_size > 0x8000000)
+ ret = amdgpu_bo_create_kernel_at(psp->adev, 0x4000000, tmr_size,
+ &psp->tmr_bo, &psp->tmr_mc_addr,
+ pptr);
+ else
+ ret = amdgpu_bo_create_kernel(psp->adev, tmr_size,
+ PSP_TMR_ALIGNMENT,
+ AMDGPU_HAS_VRAM(psp->adev) ?
+ AMDGPU_GEM_DOMAIN_VRAM :
+ AMDGPU_GEM_DOMAIN_GTT,
+ &psp->tmr_bo, &psp->tmr_mc_addr,
+ pptr);
+
+ return ret;
+}
+
/* Set up Trusted Memory Region */
static int psp_tmr_init(struct psp_context *psp)
{
int ret = 0;
int tmr_size;
- void *tmr_buf;
- void **pptr;
/*
* According to HW engineer, they prefer the TMR address be "naturally
@@ -813,18 +838,7 @@ static int psp_tmr_init(struct psp_context *psp)
}
}
- if (!psp->tmr_bo) {
- pptr = amdgpu_sriov_vf(psp->adev) ? &tmr_buf : NULL;
- ret = amdgpu_bo_create_kernel(psp->adev, tmr_size,
- PSP_TMR_ALIGNMENT,
- AMDGPU_HAS_VRAM(psp->adev) ?
- AMDGPU_GEM_DOMAIN_VRAM :
- AMDGPU_GEM_DOMAIN_GTT,
- &psp->tmr_bo, &psp->tmr_mc_addr,
- pptr);
- }
-
- return ret;
+ return psp_create_tmr_bo(psp, tmr_size);
}
static bool psp_skip_tmr(struct psp_context *psp)
--
2.25.1
next prev parent reply other threads:[~2023-07-27 7:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-27 7:56 [PATCH 1/2] drm/amdgpu: refine amdgpu_bo_create_kernel_at() Lang Yu
2023-07-27 7:56 ` Lang Yu [this message]
2023-07-27 8:01 ` [PATCH 2/2] drm/amdgpu: use amdgpu_bo_create_kernel_at() to create large TMR for APU Christian König
2023-07-27 8:24 ` Lang Yu
2023-07-27 8:00 ` [PATCH 1/2] drm/amdgpu: refine amdgpu_bo_create_kernel_at() Christian König
2023-07-27 8:15 ` Lang Yu
2023-07-27 11:23 ` Christian König
2023-07-27 12:04 ` Lang Yu
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=20230727075620.728235-2-Lang.Yu@amd.com \
--to=lang.yu@amd.com \
--cc=Arunpravin.PaneerSelvam@amd.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=yifan1.zhang@amd.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.