[PATCH] NVMe: Use CMB for the SQ if available

Christoph Hellwig hch at infradead.org
Sun Jun 21 22:41:46 PDT 2015


On Fri, Jun 19, 2015 at 03:45:57PM -0600, Jon Derrick wrote:
> +static inline void nvme_put_cmd(struct nvme_queue *nvmeq,
> +				struct nvme_command *cmd)
> +{
> +	if (nvmeq->cmb_mapped)
> +		memcpy_toio(&nvmeq->sq_cmds[nvmeq->sq_tail], cmd,
> +				sizeof(*cmd));
> +}

You'll need a separate sq_cmds replacement that's __iomem annotated
for this case.

> +static inline struct nvme_command *nvme_get_cmd(struct nvme_queue *nvmeq)
> +{
> +	if (nvmeq->cmb_mapped)
> +		return &nvmeq->cmb_cmd;

> +
> +	return &nvmeq->sq_cmds[nvmeq->sq_tail];
> +}

I think you really want to restructure the submission helpers to not
need this.  We always overwrite the whole command using memcpy/memset,
so I'd suggest to replace the remaining direct accesses to ->sq_cmds
with calls to __nvme_submit_cmd in a preparatory patch.

> +	if (qid && NVME_CMB_SQS(dev->cmbsz) && dev->cmb) {
> +		unsigned offset = (qid - 1) *
> +					roundup(SQ_SIZE(depth), dev->page_size);
> +		nvmeq->cmb_mapped = true;
> +		nvmeq->sq_dma_addr = dev->cmb_dma_addr + offset;
> +		return (void *)((uintptr_t)dev->cmb + offset);

Just do the arithmetics on the void pointer, that's a gcc extension
much of the Linux codebase assumes to be present.



More information about the Linux-nvme mailing list