Skip to content
Permalink
Browse files
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@samsung.com>
  • Loading branch information
nmtadam authored and intel-lab-lkp committed Aug 12, 2021
1 parent f8fbb47 commit 05175480696ae235d783d7a46b5cc1f42a0ad4c6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
@@ -1305,11 +1305,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)
{
@@ -874,4 +874,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 */
@@ -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"
@@ -1195,12 +1196,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: */
@@ -1362,7 +1364,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;

0 comments on commit 0517548

Please sign in to comment.