On 06-Nov-26 4:59 PM, Dejan Andjelkovic wrote:
On passthrough A+A the PSP keeps a framebuffer carveout the guest
cannot use. After IP discovery, ask the PSP to release it through the
GFX mailbox.
Define the enable command so the interface matches the ASP header.
The PSP locks this mailbox after the disable, so amdgpu never sends
the enable.
Grow the GFX command id field from 4 bits to 6 so these commands fit.
Signed-off-by: Dejan Andjelkovic <[email protected]>
Series is
Reviewed-by: Lijo Lazar <[email protected]>
Thanks,
Lijo
---
v5 -> v6:
- Drop the post-wait status read in amdgpu_psp_disable_fb_carveout().
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 ++++++
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 16 ++++++++++++++++
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 1 +
drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h | 10 ++++++----
4 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 9326f811c500..7ff97861f8bf 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2058,6 +2058,12 @@ static int amdgpu_device_ip_early_init(struct
amdgpu_device *adev)
break;
}
+ if (amdgpu_is_spm_passthrough(adev)) {
+ r = amdgpu_psp_disable_fb_carveout(adev);
+ if (r)
+ return r;
+ }
+
/* Check for IP version 9.4.3 with A0 hardware */
if (amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(9, 4, 3) &&
!amdgpu_device_get_rev_id(adev)) {
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index 50861175d661..bbf4264dd3c9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -3396,6 +3396,22 @@ int amdgpu_psp_read_discovery(struct amdgpu_device
*adev, uint8_t *binary,
return ret;
}
+int amdgpu_psp_disable_fb_carveout(struct amdgpu_device *adev)
+{
+ int ret;
+
+ WREG32(mmMP0_SMN_C2PMSG_64_MMIO, GFX_CTRL_CMD_ID_DISABLE_FB_CARVEOUT);
+
+ ret = __psp_wait_for(adev, mmMP0_SMN_C2PMSG_64_MMIO,
+ MBOX_TOS_RESP_FLAG, MBOX_TOS_RESP_MASK,
+ PSP_WAITREG_NOVERBOSE);
+ if (ret) {
+ dev_err(adev->dev, "disable_fb_carveout: PSP cmd failed\n");
+ }
+
+ return ret;
+}
+
int amdgpu_psp_wait_for_bootloader(struct amdgpu_device *adev)
{
struct psp_context *psp = &adev->psp;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
index fe3d053d9924..e747eb47c47b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
@@ -690,6 +690,7 @@ int is_psp_fw_valid(struct psp_bin_desc bin);
int amdgpu_psp_read_discovery(struct amdgpu_device *adev, uint8_t *binary,
GFX_CTRL_ADDR_TYPE addr_type);
+int amdgpu_psp_disable_fb_carveout(struct amdgpu_device *adev);
int amdgpu_psp_wait_for_bootloader(struct amdgpu_device *adev);
bool amdgpu_psp_get_ras_capability(struct psp_context *psp);
diff --git a/drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h b/drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h
index d13ae1756887..f42dd8ab5350 100644
--- a/drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h
+++ b/drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h
@@ -27,15 +27,15 @@
#define PSP_GFX_CMD_BUF_VERSION 0x00000001
#define GFX_CMD_STATUS_MASK 0x0000FFFF
-#define GFX_CMD_ID_MASK 0x000F0000
-#define GFX_CMD_RESERVED_MASK 0x7FF00000
+#define GFX_CMD_ID_MASK 0x003F0000
+#define GFX_CMD_RESERVED_MASK 0x7FC00000
#define GFX_CMD_RESPONSE_MASK 0x80000000
/* USBC PD FW version retrieval command */
#define C2PMSG_CMD_GFX_USB_PD_FW_VER 0x2000000
/* TEE Gfx Command IDs for the register interface.
-* Command ID must be between 0x00010000 and 0x000F0000.
+* Command ID must be between 0x00010000 and 0x003F0000.
*/
enum psp_gfx_crtl_cmd_id
{
@@ -50,8 +50,10 @@ enum psp_gfx_crtl_cmd_id
GFX_CTRL_CMD_ID_CONSUME_CMD = 0x00090000, /* send interrupt to psp
for updating write pointer of vf */
GFX_CTRL_CMD_ID_DESTROY_GPCOM_RING = 0x000C0000, /* destroy GPCOM ring */
GFX_CTRL_CMD_ID_GET_IP_DISCOVERY = 0x000D0000, /* Copy
IP_DISCOVERY_DATA to host-specified address */
+ GFX_CTRL_CMD_ID_DISABLE_FB_CARVEOUT = 0x00100000, /* Message runtime VBL
to disable FB carveout */
+ GFX_CTRL_CMD_ID_ENABLE_FB_CARVEOUT = 0x00110000, /* Message runtime VBL
to enable FB carveout */
- GFX_CTRL_CMD_ID_MAX = 0x000F0000, /* max command ID */
+ GFX_CTRL_CMD_ID_MAX = 0x003F0000, /* max command ID */
};
typedef enum