Skip to content

Commit

Permalink
nvmet: Fix conventional passthru
Browse files Browse the repository at this point in the history
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 0517548
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
5 changes: 0 additions & 5 deletions drivers/nvme/host/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
5 changes: 5 additions & 0 deletions drivers/nvme/host/nvme.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
12 changes: 9 additions & 3 deletions drivers/nvme/target/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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: */
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 0517548

Please sign in to comment.