drm/amdgpu: Add PSP spatial parition interface
authorLijo Lazar <lijo.lazar@amd.com>
Fri, 10 Mar 2023 10:08:19 +0000 (15:38 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 9 Jun 2023 13:57:53 +0000 (09:57 -0400)
Add PSP ring command interface for spatial partitioning.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h

index ea47012..d62746b 100644 (file)
@@ -991,6 +991,27 @@ static int psp_rl_load(struct amdgpu_device *adev)
        return ret;
 }
 
+int psp_spatial_partition(struct psp_context *psp, int mode)
+{
+       struct psp_gfx_cmd_resp *cmd;
+       int ret;
+
+       if (amdgpu_sriov_vf(psp->adev))
+               return 0;
+
+       cmd = acquire_psp_cmd_buf(psp);
+
+       cmd->cmd_id = GFX_CMD_ID_SRIOV_SPATIAL_PART;
+       cmd->cmd.cmd_spatial_part.mode = mode;
+
+       dev_info(psp->adev->dev, "Requesting %d paritions through PSP", mode);
+       ret = psp_cmd_submit_buf(psp, NULL, cmd, psp->fence_buf_mc_addr);
+
+       release_psp_cmd_buf(psp);
+
+       return ret;
+}
+
 static int psp_asd_initialize(struct psp_context *psp)
 {
        int ret;
index cf4f60c..0a409da 100644 (file)
@@ -519,6 +519,8 @@ int psp_load_fw_list(struct psp_context *psp,
                     struct amdgpu_firmware_info **ucode_list, int ucode_count);
 void psp_copy_fw(struct psp_context *psp, uint8_t *start_addr, uint32_t bin_size);
 
+int psp_spatial_partition(struct psp_context *psp, int mode);
+
 int is_psp_fw_valid(struct psp_bin_desc bin);
 
 int amdgpu_psp_sysfs_init(struct amdgpu_device *adev);
index 22c775f..18917df 100644 (file)
@@ -102,6 +102,7 @@ enum psp_gfx_cmd_id
     GFX_CMD_ID_LOAD_TOC           = 0x00000020,   /* Load TOC and obtain TMR size */
     GFX_CMD_ID_AUTOLOAD_RLC       = 0x00000021,   /* Indicates all graphics fw loaded, start RLC autoload */
     GFX_CMD_ID_BOOT_CFG           = 0x00000022,   /* Boot Config */
+    GFX_CMD_ID_SRIOV_SPATIAL_PART = 0x00000027,   /* Configure spatial partitioning mode */
 };
 
 /* PSP boot config sub-commands */
@@ -338,6 +339,13 @@ struct psp_gfx_cmd_boot_cfg
     uint32_t                        boot_config_valid;    /* dynamic boot configuration valid bits bitmask */
 };
 
+struct psp_gfx_cmd_sriov_spatial_part {
+       uint32_t mode;
+       uint32_t override_ips;
+       uint32_t override_xcds_avail;
+       uint32_t override_this_aid;
+};
+
 /* All GFX ring buffer commands. */
 union psp_gfx_commands
 {
@@ -351,6 +359,7 @@ union psp_gfx_commands
     struct psp_gfx_cmd_setup_tmr        cmd_setup_vmr;
     struct psp_gfx_cmd_load_toc         cmd_load_toc;
     struct psp_gfx_cmd_boot_cfg         boot_cfg;
+    struct psp_gfx_cmd_sriov_spatial_part cmd_spatial_part;
 };
 
 struct psp_gfx_uresp_reserved