[RFC] nvme: Do not reject dynamic controller cntlid

Keith Busch kbusch at kernel.org
Thu Jan 27 09:17:58 PST 2022


On Thu, Jan 27, 2022 at 02:36:48PM +0100, Daniel Wagner wrote:
> index dd18861f77c0..918abb54771c 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -2701,7 +2701,7 @@ static bool nvme_validate_cntlid(struct nvme_subsystem *subsys,
>  		if (nvme_state_terminal(tmp))
>  			continue;
>  
> -		if (tmp->cntlid == ctrl->cntlid) {
> +		if (!nvme_ctrl_dynamic(tmp) && tmp->cntlid == ctrl->cntlid) {
>  			dev_err(ctrl->device,
>  				"Duplicate cntlid %u with %s, subsys %s, rejecting\n",
>  				ctrl->cntlid, dev_name(tmp->device),
> diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
> index a162f6c6da6e..ed75245263f5 100644
> --- a/drivers/nvme/host/nvme.h
> +++ b/drivers/nvme/host/nvme.h
> @@ -539,6 +539,11 @@ static inline struct request *nvme_cid_to_rq(struct blk_mq_tags *tags,
>  	return blk_mq_tag_to_rq(tags, nvme_tag_from_cid(command_id));
>  }
>  
> +static inline bool nvme_ctrl_dynamic(struct nvme_ctrl *ctrl)
> +{
> +	return ctrl->cntlid == 0xffff;
> +}

It's probably safe to assume 0xffff is dynamic, but spec suggests we
check ID_CTRL.FCATT bit 0.



More information about the Linux-nvme mailing list