Commit 36c08237 authored by Oak Zeng's avatar Oak Zeng Committed by Alex Deucher

drm/amdgpu: Introduce new SETUP_TMR interface

This new interface passes both virtual and physical address
to PSP. It is backward compatible with old interface.

v2: use a function to simplify tmr physical address calc (Lijo)
Signed-off-by: default avatarOak Zeng <Oak.Zeng@amd.com>
Reviewed-by: default avatarHarish Kasiviswanathan <Harish.Kasiviswanathan@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 0ca565ab
...@@ -328,8 +328,12 @@ psp_cmd_submit_buf(struct psp_context *psp, ...@@ -328,8 +328,12 @@ psp_cmd_submit_buf(struct psp_context *psp,
static void psp_prep_tmr_cmd_buf(struct psp_context *psp, static void psp_prep_tmr_cmd_buf(struct psp_context *psp,
struct psp_gfx_cmd_resp *cmd, struct psp_gfx_cmd_resp *cmd,
uint64_t tmr_mc, uint32_t size) uint64_t tmr_mc, struct amdgpu_bo *tmr_bo)
{ {
struct amdgpu_device *adev = psp->adev;
uint32_t size = amdgpu_bo_size(tmr_bo);
uint64_t tmr_pa = amdgpu_gmc_vram_pa(adev, tmr_bo);
if (amdgpu_sriov_vf(psp->adev)) if (amdgpu_sriov_vf(psp->adev))
cmd->cmd_id = GFX_CMD_ID_SETUP_VMR; cmd->cmd_id = GFX_CMD_ID_SETUP_VMR;
else else
...@@ -337,6 +341,9 @@ static void psp_prep_tmr_cmd_buf(struct psp_context *psp, ...@@ -337,6 +341,9 @@ static void psp_prep_tmr_cmd_buf(struct psp_context *psp,
cmd->cmd.cmd_setup_tmr.buf_phy_addr_lo = lower_32_bits(tmr_mc); cmd->cmd.cmd_setup_tmr.buf_phy_addr_lo = lower_32_bits(tmr_mc);
cmd->cmd.cmd_setup_tmr.buf_phy_addr_hi = upper_32_bits(tmr_mc); cmd->cmd.cmd_setup_tmr.buf_phy_addr_hi = upper_32_bits(tmr_mc);
cmd->cmd.cmd_setup_tmr.buf_size = size; cmd->cmd.cmd_setup_tmr.buf_size = size;
cmd->cmd.cmd_setup_tmr.bitfield.virt_phy_addr = 1;
cmd->cmd.cmd_setup_tmr.system_phy_addr_lo = lower_32_bits(tmr_pa);
cmd->cmd.cmd_setup_tmr.system_phy_addr_hi = upper_32_bits(tmr_pa);
} }
static void psp_prep_load_toc_cmd_buf(struct psp_gfx_cmd_resp *cmd, static void psp_prep_load_toc_cmd_buf(struct psp_gfx_cmd_resp *cmd,
...@@ -466,8 +473,7 @@ static int psp_tmr_load(struct psp_context *psp) ...@@ -466,8 +473,7 @@ static int psp_tmr_load(struct psp_context *psp)
if (!cmd) if (!cmd)
return -ENOMEM; return -ENOMEM;
psp_prep_tmr_cmd_buf(psp, cmd, psp->tmr_mc_addr, psp_prep_tmr_cmd_buf(psp, cmd, psp->tmr_mc_addr, psp->tmr_bo);
amdgpu_bo_size(psp->tmr_bo));
DRM_INFO("reserve 0x%lx from 0x%llx for PSP TMR\n", DRM_INFO("reserve 0x%lx from 0x%llx for PSP TMR\n",
amdgpu_bo_size(psp->tmr_bo), psp->tmr_mc_addr); amdgpu_bo_size(psp->tmr_bo), psp->tmr_mc_addr);
......
...@@ -185,10 +185,19 @@ struct psp_gfx_cmd_setup_tmr ...@@ -185,10 +185,19 @@ struct psp_gfx_cmd_setup_tmr
uint32_t buf_phy_addr_lo; /* bits [31:0] of GPU Virtual address of TMR buffer (must be 4 KB aligned) */ uint32_t buf_phy_addr_lo; /* bits [31:0] of GPU Virtual address of TMR buffer (must be 4 KB aligned) */
uint32_t buf_phy_addr_hi; /* bits [63:32] of GPU Virtual address of TMR buffer */ uint32_t buf_phy_addr_hi; /* bits [63:32] of GPU Virtual address of TMR buffer */
uint32_t buf_size; /* buffer size in bytes (must be multiple of 4 KB) */ uint32_t buf_size; /* buffer size in bytes (must be multiple of 4 KB) */
union {
struct {
uint32_t sriov_enabled:1; /* whether the device runs under SR-IOV*/
uint32_t virt_phy_addr:1; /* driver passes both virtual and physical address to PSP*/
uint32_t reserved:30;
} bitfield;
uint32_t tmr_flags;
};
uint32_t system_phy_addr_lo; /* bits [31:0] of system physical address of TMR buffer (must be 4 KB aligned) */
uint32_t system_phy_addr_hi; /* bits [63:32] of system physical address of TMR buffer */
}; };
/* FW types for GFX_CMD_ID_LOAD_IP_FW command. Limit 31. */ /* FW types for GFX_CMD_ID_LOAD_IP_FW command. Limit 31. */
enum psp_gfx_fw_type { enum psp_gfx_fw_type {
GFX_FW_TYPE_NONE = 0, /* */ GFX_FW_TYPE_NONE = 0, /* */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment