[PATCH 3/4] nvme: store the actual queue size in ctrl->sqsize
Keith Busch
kbusch at kernel.org
Wed Dec 28 09:02:37 PST 2022
On Sun, Dec 25, 2022 at 11:32:33AM +0100, 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.
s/filed/field
> @@ -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);
Did you mean '+ 1' instead of '- 1'? The minimum MQES value per spec is
1, giving 2 slots. Subtracting 1 from that possible value would give you
sqsize 0.
But I'm confused why this is being changed. The ctrl->sqsize isn't a 0's
based value. It's normal 1-based value that tells blk-mq how many tags
to allocate.
> +static ssize_t sqsize_show(struct device *dev,
> + struct device_attribute *attr, char *buf)
> +{
> + struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
> +
> + /* Report the 0s based register value for historic reasons: */
> + return sysfs_emit(buf, "%d\n", ctrl->sqsize - 1);
> +}
Weird indentation here.
More information about the Linux-nvme
mailing list