[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20210812210313.262432-1-a.manzanares@samsung.com>
Date: Thu, 12 Aug 2021 21:04:03 +0000
From: Adam Manzanares <a.manzanares@...sung.com>
To: Keith Busch <kbusch@...nel.org>, Jens Axboe <axboe@...com>,
"Christoph Hellwig" <hch@....de>, Sagi Grimberg <sagi@...mberg.me>,
Chaitanya Kulkarni <chaitanya.kulkarni@....com>,
"open list:NVM EXPRESS DRIVER" <linux-nvme@...ts.infradead.org>,
open list <linux-kernel@...r.kernel.org>
CC: Adam Manzanares <a.manzanares@...sung.com>
Subject: [RFC PATCH] nvmet: Fix conventional passthru
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@...sung.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
Powered by blists - more mailing lists