Skip to content

Commit 77d651a

Browse files
nmtadamChristoph Hellwig
authored andcommitted
nvmet: looks at the passthrough controller when initializing CAP
For a passthru controller make cap initialization dependent on the cap of the passthru controller, given that multiple Command Set support needs to be supported by the underlying controller. For that move the initialization of CAP later so that it can use the fully initialized nvmet_ctrl structure. Fixes: ab5d0b3 (nvmet: add Command Set Identifier support) Signed-off-by: Adam Manzanares <[email protected]> Reviewed-by: Keith Busch <[email protected]> [hch: refactored the code a bit to keep it more contained in passthru.c] Signed-off-by: Christoph Hellwig <[email protected]>
1 parent 43dc987 commit 77d651a

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

drivers/nvme/target/core.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,6 +1206,9 @@ static void nvmet_init_cap(struct nvmet_ctrl *ctrl)
12061206
ctrl->cap |= (15ULL << 24);
12071207
/* maximum queue entries supported: */
12081208
ctrl->cap |= NVMET_QUEUE_SIZE - 1;
1209+
1210+
if (nvmet_passthru_ctrl(ctrl->subsys))
1211+
nvmet_passthrough_override_cap(ctrl);
12091212
}
12101213

12111214
struct nvmet_ctrl *nvmet_ctrl_find_get(const char *subsysnqn,
@@ -1363,8 +1366,6 @@ u16 nvmet_alloc_ctrl(const char *subsysnqn, const char *hostnqn,
13631366
goto out_put_subsystem;
13641367
mutex_init(&ctrl->lock);
13651368

1366-
nvmet_init_cap(ctrl);
1367-
13681369
ctrl->port = req->port;
13691370

13701371
INIT_WORK(&ctrl->async_event_work, nvmet_async_event_work);
@@ -1378,6 +1379,7 @@ u16 nvmet_alloc_ctrl(const char *subsysnqn, const char *hostnqn,
13781379

13791380
kref_init(&ctrl->ref);
13801381
ctrl->subsys = subsys;
1382+
nvmet_init_cap(ctrl);
13811383
WRITE_ONCE(ctrl->aen_enabled, NVMET_AEN_CFG_OPTIONAL);
13821384

13831385
ctrl->changed_ns_list = kmalloc_array(NVME_MAX_CHANGED_NAMESPACES,

drivers/nvme/target/nvmet.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,8 @@ nvmet_req_passthru_ctrl(struct nvmet_req *req)
613613
return nvmet_passthru_ctrl(nvmet_req_subsys(req));
614614
}
615615

616+
void nvmet_passthrough_override_cap(struct nvmet_ctrl *ctrl);
617+
616618
u16 errno_to_nvme_status(struct nvmet_req *req, int errno);
617619
u16 nvmet_report_invalid_opcode(struct nvmet_req *req);
618620

drivers/nvme/target/passthru.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ MODULE_IMPORT_NS(NVME_TARGET_PASSTHRU);
2020
*/
2121
static DEFINE_XARRAY(passthru_subsystems);
2222

23+
void nvmet_passthrough_override_cap(struct nvmet_ctrl *ctrl)
24+
{
25+
/*
26+
* Multiple command set support can only be declared if the underlying
27+
* controller actually supports it.
28+
*/
29+
if (!nvme_multi_css(ctrl->subsys->passthru_ctrl))
30+
ctrl->cap &= ~(1ULL << 43);
31+
}
32+
2333
static u16 nvmet_passthru_override_id_ctrl(struct nvmet_req *req)
2434
{
2535
struct nvmet_ctrl *ctrl = req->sq->ctrl;

0 commit comments

Comments
 (0)