Skip to content

Commit

Permalink
mi: restore default ep timeout during admin_passthru
Browse files Browse the repository at this point in the history
Before the fix, the timeout can only increase and also it will change
the default timeout setting permanently.

After the fix, the timeout can be any value provided by the timeout_ms
parameter and also we will restore the default timeout settings.

Signed-off-by: Jinliang Wang <[email protected]>
  • Loading branch information
jinliangw authored and igaw committed May 8, 2024
1 parent cfb95e7 commit 63966d6
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/nvme/mi.c
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,7 @@ int nvme_mi_admin_admin_passthru(nvme_mi_ctrl_t ctrl, __u8 opcode, __u8 flags,
struct nvme_mi_admin_req_hdr req_hdr;
struct nvme_mi_resp resp;
struct nvme_mi_req req;
unsigned int timeout_save;
int rc;
int direction = opcode & 0x3;
bool has_write_data = false;
Expand All @@ -665,11 +666,6 @@ int nvme_mi_admin_admin_passthru(nvme_mi_ctrl_t ctrl, __u8 opcode, __u8 flags,
has_read_data = true;
}

if (timeout_ms > nvme_mi_ep_get_timeout(ctrl->ep)) {
/* Set timeout if user needs a bigger timeout */
nvme_mi_ep_set_timeout(ctrl->ep, timeout_ms);
}

nvme_mi_admin_init_req(&req, &req_hdr, ctrl->id, opcode);
req_hdr.cdw1 = cpu_to_le32(nsid);
req_hdr.cdw2 = cpu_to_le32(cdw2);
Expand Down Expand Up @@ -701,7 +697,17 @@ int nvme_mi_admin_admin_passthru(nvme_mi_ctrl_t ctrl, __u8 opcode, __u8 flags,
resp.data_len = data_len;
}

/* if the user has specified a custom timeout, save the current
* timeout and override
*/
if (timeout_ms != 0) {
timeout_save = nvme_mi_ep_get_timeout(ctrl->ep);
nvme_mi_ep_set_timeout(ctrl->ep, timeout_ms);
}
rc = nvme_mi_submit(ctrl->ep, &req, &resp);
if (timeout_ms != 0)
nvme_mi_ep_set_timeout(ctrl->ep, timeout_save);

if (rc)
return rc;

Expand Down

0 comments on commit 63966d6

Please sign in to comment.