Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdgpu: Add PSP interface for NPS switch

Implement PSP ring command interface for memory partitioning on the fly
on the supported asics.

Signed-off-by: Rajneesh Bhardwaj <rajneesh.bhardwaj@amd.com>
Reviewed-by: Feifei Xu <Feifei.Xu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Rajneesh Bhardwaj and committed by
Alex Deucher
212cc241 82e2ccaa

+37 -3
+25
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
··· 1045 1045 return ret; 1046 1046 } 1047 1047 1048 + int psp_memory_partition(struct psp_context *psp, int mode) 1049 + { 1050 + struct psp_gfx_cmd_resp *cmd; 1051 + int ret; 1052 + 1053 + if (amdgpu_sriov_vf(psp->adev)) 1054 + return 0; 1055 + 1056 + cmd = acquire_psp_cmd_buf(psp); 1057 + 1058 + cmd->cmd_id = GFX_CMD_ID_FB_NPS_MODE; 1059 + cmd->cmd.cmd_memory_part.mode = mode; 1060 + 1061 + dev_info(psp->adev->dev, 1062 + "Requesting %d memory partition change through PSP", mode); 1063 + ret = psp_cmd_submit_buf(psp, NULL, cmd, psp->fence_buf_mc_addr); 1064 + if (ret) 1065 + dev_err(psp->adev->dev, 1066 + "PSP request failed to change to NPS%d mode\n", mode); 1067 + 1068 + release_psp_cmd_buf(psp); 1069 + 1070 + return ret; 1071 + } 1072 + 1048 1073 int psp_spatial_partition(struct psp_context *psp, int mode) 1049 1074 { 1050 1075 struct psp_gfx_cmd_resp *cmd;
+1
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
··· 553 553 void psp_copy_fw(struct psp_context *psp, uint8_t *start_addr, uint32_t bin_size); 554 554 555 555 int psp_spatial_partition(struct psp_context *psp, int mode); 556 + int psp_memory_partition(struct psp_context *psp, int mode); 556 557 557 558 int is_psp_fw_valid(struct psp_bin_desc bin); 558 559
+11 -3
drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h
··· 103 103 GFX_CMD_ID_AUTOLOAD_RLC = 0x00000021, /* Indicates all graphics fw loaded, start RLC autoload */ 104 104 GFX_CMD_ID_BOOT_CFG = 0x00000022, /* Boot Config */ 105 105 GFX_CMD_ID_SRIOV_SPATIAL_PART = 0x00000027, /* Configure spatial partitioning mode */ 106 - /*IDs of performance monitoring/profiling*/ 107 - GFX_CMD_ID_CONFIG_SQ_PERFMON = 0x00000046, /* Config CGTT_SQ_CLK_CTRL */ 106 + /*IDs of performance monitoring/profiling*/ 107 + GFX_CMD_ID_CONFIG_SQ_PERFMON = 0x00000046, /* Config CGTT_SQ_CLK_CTRL */ 108 + /* Dynamic memory partitioninig (NPS mode change)*/ 109 + GFX_CMD_ID_FB_NPS_MODE = 0x00000048, /* Configure memory partitioning mode */ 108 110 }; 109 111 110 112 /* PSP boot config sub-commands */ ··· 364 362 uint8_t reserved[5]; 365 363 }; 366 364 365 + struct psp_gfx_cmd_fb_memory_part { 366 + uint32_t mode; /* requested NPS mode */ 367 + uint32_t resvd; 368 + }; 369 + 367 370 /* All GFX ring buffer commands. */ 368 371 union psp_gfx_commands 369 372 { ··· 383 376 struct psp_gfx_cmd_load_toc cmd_load_toc; 384 377 struct psp_gfx_cmd_boot_cfg boot_cfg; 385 378 struct psp_gfx_cmd_sriov_spatial_part cmd_spatial_part; 386 - struct psp_gfx_cmd_config_sq_perfmon config_sq_perfmon; 379 + struct psp_gfx_cmd_config_sq_perfmon config_sq_perfmon; 380 + struct psp_gfx_cmd_fb_memory_part cmd_memory_part; 387 381 }; 388 382 389 383 struct psp_gfx_uresp_reserved