[PATCHv2 2/2] NVMe: Use CMB for the SQ if available

Christoph Hellwig hch at infradead.org
Wed Jun 24 05:21:58 PDT 2015


> +++ b/drivers/block/nvme-core.c
> @@ -102,12 +102,16 @@ struct nvme_queue {
>  	struct nvme_dev *dev;
>  	char irqname[24];	/* nvme4294967295-65535\0 */
>  	spinlock_t q_lock;
> -	struct nvme_command *sq_cmds;
> +	union {
> +		struct nvme_command *sq_cmds;
> +		struct nvme_command __iomem *sq_cmds_io;
> +	};
>  	volatile struct nvme_completion *cqes;
>  	struct blk_mq_tags **tags;
>  	dma_addr_t sq_dma_addr;
>  	dma_addr_t cq_dma_addr;
>  	u32 __iomem *q_db;
> +	bool cmb_mapped;

If you remove the union you'll get better error checking because
using the wrong member won't work, and you can remove the cmb_mapped
flag and instead check for a non-NULL sq_cmds_io.

Otherwise this looks reasonable to me.

Note that I have a WIP patch to make all command submissions go through
nvme_queue_rq, in which case we might be able to get rid of the on-stack
cmds again.  But until that happens I think the refactoring in the first
patch is preferable to the earlier version.



More information about the Linux-nvme mailing list