If there's a failure, report it back to the host with a sense reason. Signed-off-by: Thinh Nguyen <Thinh.Nguyen@xxxxxxxxxxxx> --- drivers/usb/gadget/function/f_tcm.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/function/f_tcm.c b/drivers/usb/gadget/function/f_tcm.c index 7162be5fdf2f..fb9b71158c4b 100644 --- a/drivers/usb/gadget/function/f_tcm.c +++ b/drivers/usb/gadget/function/f_tcm.c @@ -669,6 +669,9 @@ static int uasp_send_read_response(struct usbg_cmd *cmd) pr_err("%s(%d) => %d\n", __func__, __LINE__, ret); } out: + if (ret) + transport_send_check_condition_and_sense(&cmd->se_cmd, + TCM_CHECK_CONDITION_UNIT_ATTENTION, 0); return ret; } @@ -711,6 +714,9 @@ static int uasp_send_write_request(struct usbg_cmd *cmd) } cleanup: + if (ret) + transport_send_check_condition_and_sense(&cmd->se_cmd, + TCM_CHECK_CONDITION_UNIT_ATTENTION, 0); return ret; } @@ -955,7 +961,15 @@ static void usbg_data_write_cmpl(struct usb_ep *ep, struct usb_request *req) return; cleanup: - transport_generic_free_cmd(&cmd->se_cmd, 0); + /* Command was aborted */ + if (cmd->state == UASP_QUEUE_COMMAND) { + transport_generic_free_cmd(se_cmd, 0); + return; + } + + cmd->state = UASP_QUEUE_COMMAND; + transport_send_check_condition_and_sense(se_cmd, + TCM_CHECK_CONDITION_UNIT_ATTENTION, 0); } static int usbg_prepare_w_request(struct usbg_cmd *cmd, struct usb_request *req) -- 2.28.0