[RFC PATCH] nvmet: Fix conventional passthru
Adam Manzanares
a.manzanares at samsung.com
Thu Aug 12 14:04:03 PDT 2021
Currently nvme_init_cap unconditionally sets support for one or more command
sets. When namespace identify descriptors are parsed it is expected that
the command set identifier is present, which is not always true for a
conventional namespace.
Signed-off-by: Adam Manzanares <a.manzanares at samsung.com>
---
drivers/nvme/host/core.c | 5 -----
drivers/nvme/host/nvme.h | 5 +++++
drivers/nvme/target/core.c | 12 +++++++++---
3 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 2f0cbaba12ac..dd6c01105c11 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1306,11 +1306,6 @@ static int nvme_identify_ctrl(struct nvme_ctrl *dev, struct nvme_id_ctrl **id)
return error;
}
-static bool nvme_multi_css(struct nvme_ctrl *ctrl)
-{
- return (ctrl->ctrl_config & NVME_CC_CSS_MASK) == NVME_CC_CSS_CSI;
-}
-
static int nvme_process_ns_desc(struct nvme_ctrl *ctrl, struct nvme_ns_ids *ids,
struct nvme_ns_id_desc *cur, bool *csi_seen)
{
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 26511794629b..dc93d2bd68b8 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -919,4 +919,9 @@ struct nvme_ctrl *nvme_ctrl_from_file(struct file *file);
struct nvme_ns *nvme_find_get_ns(struct nvme_ctrl *ctrl, unsigned nsid);
void nvme_put_ns(struct nvme_ns *ns);
+static inline bool nvme_multi_css(struct nvme_ctrl *ctrl)
+{
+ return (ctrl->ctrl_config & NVME_CC_CSS_MASK) == NVME_CC_CSS_CSI;
+}
+
#endif /* _NVME_H */
diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index 66d05eecc2a9..d8eac7ccb54c 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -9,6 +9,7 @@
#include <linux/rculist.h>
#include <linux/pci-p2pdma.h>
#include <linux/scatterlist.h>
+#include "../host/nvme.h"
#define CREATE_TRACE_POINTS
#include "trace.h"
@@ -1196,12 +1197,13 @@ void nvmet_update_cc(struct nvmet_ctrl *ctrl, u32 new)
mutex_unlock(&ctrl->lock);
}
-static void nvmet_init_cap(struct nvmet_ctrl *ctrl)
+static void nvmet_init_cap(struct nvmet_ctrl *ctrl, struct nvme_ctrl *ptctrl)
{
/* command sets supported: NVMe command set: */
ctrl->cap = (1ULL << 37);
/* Controller supports one or more I/O Command Sets */
- ctrl->cap |= (1ULL << 43);
+ if ((ptctrl && nvme_multi_css(ptctrl)) || !ptctrl)
+ ctrl->cap |= (1ULL << 43);
/* CC.EN timeout in 500msec units: */
ctrl->cap |= (15ULL << 24);
/* maximum queue entries supported: */
@@ -1363,7 +1365,11 @@ u16 nvmet_alloc_ctrl(const char *subsysnqn, const char *hostnqn,
goto out_put_subsystem;
mutex_init(&ctrl->lock);
- nvmet_init_cap(ctrl);
+#ifdef CONFIG_NVME_TARGET_PASSTHRU
+ nvmet_init_cap(ctrl, subsys->passthru_ctrl);
+#elif
+ nvmet_init_cap(ctrl, NULL);
+#endif
ctrl->port = req->port;
--
2.25.1
More information about the Linux-nvme
mailing list