From: Javier González <javier.gonz@xxxxxxxxxxx> Allow the called of nvme_get_effects_log() to force re-reading the log page from the device instead of getting the cached version when available. Signed-off-by: Javier González <javier.gonz@xxxxxxxxxxx> --- drivers/nvme/host/core.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index fff90200497c..e4c79f1d2e96 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -2951,18 +2951,20 @@ int nvme_get_log(struct nvme_ctrl *ctrl, u32 nsid, u8 log_page, u8 lsp, u8 csi, return nvme_submit_sync_cmd(ctrl->admin_q, &c, log, size); } -static int nvme_get_effects_log(struct nvme_ctrl *ctrl, u8 csi, - struct nvme_effects_log **log) +static int nvme_get_effects_log(struct nvme_ctrl *ctrl, u8 csi, struct nvme_effects_log **log, + bool force) { struct nvme_cel *cel = xa_load(&ctrl->cels, csi); int ret; - if (cel) + if (cel && !force) goto out; - cel = kzalloc(sizeof(*cel), GFP_KERNEL); - if (!cel) - return -ENOMEM; + if (!cel) { + cel = kzalloc(sizeof(*cel), GFP_KERNEL); + if (!cel) + return -ENOMEM; + } ret = nvme_get_log(ctrl, 0x00, NVME_LOG_CMD_EFFECTS, 0, csi, &cel->log, sizeof(cel->log), 0); @@ -3008,7 +3010,7 @@ int nvme_init_identify(struct nvme_ctrl *ctrl) } if (id->lpa & NVME_CTRL_LPA_CMD_EFFECTS_LOG) { - ret = nvme_get_effects_log(ctrl, NVME_CSI_NVM, &ctrl->effects); + ret = nvme_get_effects_log(ctrl, NVME_CSI_NVM, &ctrl->effects, false); if (ret < 0) goto out_free; } @@ -3725,7 +3727,7 @@ static struct nvme_ns_head *nvme_alloc_ns_head(struct nvme_ctrl *ctrl, } if (head->ids.csi) { - ret = nvme_get_effects_log(ctrl, head->ids.csi, &head->effects); + ret = nvme_get_effects_log(ctrl, head->ids.csi, &head->effects, false); if (ret) goto out_cleanup_srcu; } else -- 2.17.1