[PATCH 3/4] nvme: store the actual queue size in ctrl->sqsize

Sagi Grimberg sagi at grimberg.me
Sun Dec 25 03:09:24 PST 2022



On 12/25/22 12:32, Christoph Hellwig wrote:
> Convert from the strange on the wire 0s based value to a regular size
> when reading the filed to avoid adjustments all over.
> 
> Signed-off-by: Christoph Hellwig <hch at lst.de>
> ---
>   drivers/nvme/host/apple.c   |  3 +--
>   drivers/nvme/host/core.c    | 19 +++++++++++++++++--
>   drivers/nvme/host/fabrics.c |  2 +-
>   drivers/nvme/host/fc.c      | 12 ++++++------
>   drivers/nvme/host/pci.c     |  4 ++--
>   drivers/nvme/host/rdma.c    | 23 +++++++++++------------
>   drivers/nvme/host/tcp.c     | 12 ++++++------
>   7 files changed, 44 insertions(+), 31 deletions(-)
> 
> diff --git a/drivers/nvme/host/apple.c b/drivers/nvme/host/apple.c
> index e36aeb50b4edc1..073a1e8c021c14 100644
> --- a/drivers/nvme/host/apple.c
> +++ b/drivers/nvme/host/apple.c
> @@ -1080,8 +1080,7 @@ static void apple_nvme_reset_work(struct work_struct *work)
>   	writeq(anv->ioq.tcb_dma_addr,
>   	       anv->mmio_nvme + APPLE_NVMMU_IOSQ_TCB_BASE);
>   
> -	anv->ctrl.sqsize =
> -		APPLE_ANS_MAX_QUEUE_DEPTH - 1; /* 0's based queue depth */
> +	anv->ctrl.sqsize = APPLE_ANS_MAX_QUEUE_DEPTH;
>   	anv->ctrl.cap = readq(anv->mmio_nvme + NVME_REG_CAP);
>   
>   	dev_dbg(anv->dev, "Enabling controller now");
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index cda1361e6d4fbb..f2b7bb8bcc31fa 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -3242,7 +3242,8 @@ int nvme_init_ctrl_finish(struct nvme_ctrl *ctrl, bool was_suspended)
>   		return ret;
>   	}
>   
> -	ctrl->sqsize = min_t(u16, NVME_CAP_MQES(ctrl->cap), ctrl->sqsize);
> +	/* CAP.MQES is 0s based */
> +	ctrl->sqsize = min_t(u16, NVME_CAP_MQES(ctrl->cap) - 1, ctrl->sqsize);

Shoudn't this be NVME_CAP_MQES(ctrl->cap) + 1 ?



More information about the Linux-nvme mailing list