diff mbox series

[1/2] nvme: allow to force refresh of effects log

Message ID 20201111124639.11305-1-javier@samsung.com (mailing list archive)
State New, archived
Headers show
Series [1/2] nvme: allow to force refresh of effects log | expand

Commit Message

Javier González Nov. 11, 2020, 12:46 p.m. UTC
From: Javier González <javier.gonz@samsung.com>

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@samsung.com>
---
 drivers/nvme/host/core.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
diff mbox series

Patch

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