drm/amdgpu: Abort guest trn during ras reset
Subsystems (2)
PATCH 1/1 drm/amdgpu: Abort guest trn during ras reset
From: Will Aitken <[email protected]>
In sriov, if the guest tries to send a message just before the host begins a ras wgr recovery attempt, the host will never see that message since it is busy with the recovery. The host then completes the reset and is waiting for the guest to recover. Meanwhile, the guest spins waiting for a response to its original message until it eventually times out and proceeds with reset recovery. This patch prevents the guest from sending the message in the first place by peeking the rcv mailbox before sending. If the bar is down it means a reset is underway and the transmission should be dropped. Doing so prevents about one minute of idling in this scenario.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 2 +- drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c | 4 +++- drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c | 30 +++++++++++++++++------- 4 files changed, 26 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +1 -1
@@ -102,7 +102,7 @@ int amdgpu_virt_request_full_gpu(struct amdgpu_device *adev, bool init)if (virt->ops && virt->ops->req_full_gpu) { r = virt->ops->req_full_gpu (adev, init); -if (r) { +if (r && r != -EBUSY ) { adev->no_hw_access = true;return r; }
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +1 -1
@@ -106,7 +106,7 @@ struct amdgpu_virt_ops {int (*reset_gpu)(struct amdgpu_device *adev);void (*ready_to_reset)(struct amdgpu_device *adev);int (*wait_reset)(struct amdgpu_device *adev); -void (*trans_msg)(struct amdgpu_device *adev,enum idh_request req, +int (*trans_msg)(struct amdgpu_device *adev,enum idh_request req,u32 data1,u32 data2,u32 data3);void (*ras_poison_handler)(struct amdgpu_device *adev,enum amdgpu_ras_block block);
drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c +3 -1
@@ -116,7 +116,7 @@ static int xgpu_ai_poll_msg(struct amdgpu_device *adev, enum idh_event event)return -ETIME ; } -static void xgpu_ai_mailbox_trans_msg (struct amdgpu_device *adev, +static int xgpu_ai_mailbox_trans_msg (struct amdgpu_device *adev,enum idh_request req,u32 data1,u32 data2,u32 data3) {u32 reg;int r;
@@ -158,6 +158,8 @@ static void xgpu_ai_mailbox_trans_msg (struct amdgpu_device *adev,dev_err (adev->dev,"Doesn't get ack from pf, continue\n" );xgpu_ai_mailbox_set_valid (adev, false); + +return r; } static int xgpu_ai_send_access_requests(struct amdgpu_device *adev,
drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c +21 -9
@@ -82,12 +82,22 @@ static uint8_t xgpu_nv_peek_ack(struct amdgpu_device *adev)return RREG8 (NV_MAIBOX_CONTROL_TRN_OFFSET_BYTE ) &2 ; } +static bool xgpu_nv_rcvd_ras_intr (struct amdgpu_device *adev) +{ +enum idh_event msg =xgpu_nv_mailbox_peek_msg (adev); + +return (msg ==IDH_RAS_ERROR_DETECTED || msg ==0xFFFFFFFF ); +} +static int xgpu_nv_poll_ack (struct amdgpu_device *adev) {int timeout =NV_MAILBOX_POLL_ACK_TIMEDOUT ;u8 reg; do { + if (xgpu_nv_rcvd_ras_intr(adev)) + return -EBUSY; + reg = RREG8(NV_MAIBOX_CONTROL_TRN_OFFSET_BYTE); if (reg & 2) return 0;
@@ -136,7 +146,7 @@ static int xgpu_nv_poll_msg(struct amdgpu_device *adev, enum idh_event event)return -ETIME ; } -static void xgpu_nv_mailbox_trans_msg (struct amdgpu_device *adev, +static int xgpu_nv_mailbox_trans_msg (struct amdgpu_device *adev,enum idh_request req,u32 data1,u32 data2,u32 data3) {int r;
@@ -149,6 +159,9 @@ static void xgpu_nv_mailbox_trans_msg (struct amdgpu_device *adev,* will return immediatly */ do { + if (xgpu_nv_rcvd_ras_intr(adev)) + return -EBUSY; + xgpu_nv_mailbox_set_valid(adev, false); trn = xgpu_nv_peek_ack(adev); if (trn) {
@@ -170,6 +183,8 @@ static void xgpu_nv_mailbox_trans_msg (struct amdgpu_device *adev,dev_err (adev->dev,"Doesn't get ack from pf, continue\n" );xgpu_nv_mailbox_set_valid (adev, false); + +return r; } static int xgpu_nv_send_access_requests_with_param(struct amdgpu_device *adev,
@@ -187,7 +202,11 @@ static int xgpu_nv_send_access_requests_with_param(struct amdgpu_device *adev, goto out; } -xgpu_nv_mailbox_trans_msg (adev, req, data1, data2, data3); + r =xgpu_nv_mailbox_trans_msg (adev, req, data1, data2, data3); +if (r == -EBUSY ) { +dev_warn (adev->dev,"Ras interrupt detected, dropping request 0x%x\n" , req); + goto out; + }switch (req) {case IDH_REQ_GPU_INIT_ACCESS :
@@ -573,13 +592,6 @@ static void xgpu_nv_ras_poison_handler(struct amdgpu_device *adev, } } -static bool xgpu_nv_rcvd_ras_intr (struct amdgpu_device *adev) -{ -enum idh_event msg =xgpu_nv_mailbox_peek_msg (adev); - -return (msg ==IDH_RAS_ERROR_DETECTED || msg ==0xFFFFFFFF ); -} -static int xgpu_nv_req_ras_err_count (struct amdgpu_device *adev) {return xgpu_nv_send_access_requests (adev,IDH_REQ_RAS_ERROR_COUNT );
Signature · 1 line
2.43.0
Quoted 13 lines · On 11-Nov-26 7:41 PM, [email protected] wrote:
From: Will Aitken <[email protected]>
In sriov, if the guest tries to send a message just before the host begins a ras wgr recovery attempt, the host will never see that message since it is busy with the recovery. The host then completes the reset and is waiting for the guest to recover. Meanwhile, the guest spins waiting for a response to its original message until it eventually times out and proceeds with reset recovery. This patch prevents the guest from sending the message in the first place by peeking the rcv mailbox before sending. If the bar is down it means a reset is underway and the transmission should be dropped. Doing so prevents about one minute of idling in this scenario.
Quoted 1 line
Signed-off-by Will Aitken <[email protected]>
Thanks,
Lijo
Quoted 137 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 2 +- drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c | 4 +++- drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c | 30 +++++++++++++++++------- 4 files changed, 26 insertions(+), 12 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +1
-1@@ -102,7 +102,7 @@ int amdgpu_virt_request_full_gpu(struct amdgpu_device *adev, bool init)if (virt->ops && virt->ops->req_full_gpu) { r = virt->ops->req_full_gpu (adev, init); -if (r) { +if (r && r != -EBUSY ) { adev->no_hw_access = true;return r; }drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +1
-1@@ -106,7 +106,7 @@ struct amdgpu_virt_ops {int (*reset_gpu)(struct amdgpu_device *adev);void (*ready_to_reset)(struct amdgpu_device *adev);int (*wait_reset)(struct amdgpu_device *adev); -void (*trans_msg)(struct amdgpu_device *adev,enum idh_request req, +int (*trans_msg)(struct amdgpu_device *adev,enum idh_request req,u32 data1,u32 data2,u32 data3);void (*ras_poison_handler)(struct amdgpu_device *adev,enum amdgpu_ras_block block);drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c +3
-1@@ -116,7 +116,7 @@ static int xgpu_ai_poll_msg(struct amdgpu_device *adev, enum idh_event event)return -ETIME ; } -static void xgpu_ai_mailbox_trans_msg (struct amdgpu_device *adev, +static int xgpu_ai_mailbox_trans_msg (struct amdgpu_device *adev,enum idh_request req,u32 data1,u32 data2,u32 data3) {u32 reg;int r;@@ -158,6 +158,8 @@ static void xgpu_ai_mailbox_trans_msg (struct amdgpu_device *adev,dev_err (adev->dev,"Doesn't get ack from pf, continue\n" );xgpu_ai_mailbox_set_valid (adev, false); + +return r; } static int xgpu_ai_send_access_requests(struct amdgpu_device *adev,drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c +21
-9@@ -82,12 +82,22 @@ static uint8_t xgpu_nv_peek_ack(struct amdgpu_device *adev)return RREG8 (NV_MAIBOX_CONTROL_TRN_OFFSET_BYTE ) &2 ; } +static bool xgpu_nv_rcvd_ras_intr (struct amdgpu_device *adev) +{ +enum idh_event msg =xgpu_nv_mailbox_peek_msg (adev); + +return (msg ==IDH_RAS_ERROR_DETECTED || msg ==0xFFFFFFFF ); +} +static int xgpu_nv_poll_ack (struct amdgpu_device *adev) {int timeout =NV_MAILBOX_POLL_ACK_TIMEDOUT ;u8 reg; do { + if (xgpu_nv_rcvd_ras_intr(adev)) + return -EBUSY; + reg = RREG8(NV_MAIBOX_CONTROL_TRN_OFFSET_BYTE); if (reg & 2) return 0;@@ -136,7 +146,7 @@ static int xgpu_nv_poll_msg(struct amdgpu_device *adev, enum idh_event event)return -ETIME ; } -static void xgpu_nv_mailbox_trans_msg (struct amdgpu_device *adev, +static int xgpu_nv_mailbox_trans_msg (struct amdgpu_device *adev,enum idh_request req,u32 data1,u32 data2,u32 data3) {int r;@@ -149,6 +159,9 @@ static void xgpu_nv_mailbox_trans_msg (struct amdgpu_device *adev,* will return immediatly */ do { + if (xgpu_nv_rcvd_ras_intr(adev)) + return -EBUSY; + xgpu_nv_mailbox_set_valid(adev, false); trn = xgpu_nv_peek_ack(adev); if (trn) {@@ -170,6 +183,8 @@ static void xgpu_nv_mailbox_trans_msg (struct amdgpu_device *adev,dev_err (adev->dev,"Doesn't get ack from pf, continue\n" );xgpu_nv_mailbox_set_valid (adev, false); + +return r; } static int xgpu_nv_send_access_requests_with_param(struct amdgpu_device *adev,@@ -187,7 +202,11 @@ static int xgpu_nv_send_access_requests_with_param(struct amdgpu_device *adev, goto out; } -xgpu_nv_mailbox_trans_msg (adev, req, data1, data2, data3); + r =xgpu_nv_mailbox_trans_msg (adev, req, data1, data2, data3); +if (r == -EBUSY ) { +dev_warn (adev->dev,"Ras interrupt detected, dropping request 0x%x\n" , req); + goto out; + }switch (req) {case IDH_REQ_GPU_INIT_ACCESS :@@ -573,13 +592,6 @@ static void xgpu_nv_ras_poison_handler(struct amdgpu_device *adev, } } -static bool xgpu_nv_rcvd_ras_intr (struct amdgpu_device *adev) -{ -enum idh_event msg =xgpu_nv_mailbox_peek_msg (adev); - -return (msg ==IDH_RAS_ERROR_DETECTED || msg ==0xFFFFFFFF ); -} -static int xgpu_nv_req_ras_err_count (struct amdgpu_device *adev) {return xgpu_nv_send_access_requests (adev,IDH_REQ_RAS_ERROR_COUNT );