use the core tagset alloc/free helpers in nvme-pci
Subsystems (3)
Christoph Hellwig
maintainerHi all,
this series switches over nvme-pci to use the common tagset alloc/free helpers.
Diffstat:
host/core.c | 25 +++++++++++----- host/fc.c | 4 +- host/nvme.h | 7 ++-- host/pci.c | 89 +++++++++++----------------------------------------------- host/rdma.c | 5 +-- host/tcp.c | 4 +- target/loop.c | 4 +- 7 files changed, 48 insertions(+), 90 deletions(-)
Christoph Hellwig
maintainerPATCH 1/5 nvme: pass nr_maps explicitly to nvme_alloc_io_tag_set
Don't look at ctrl->ops as only RDMA and TCP actually support multiple maps.
--- drivers/nvme/host/core.c | 5 ++--- drivers/nvme/host/fc.c | 2 +- drivers/nvme/host/nvme.h | 2 +- drivers/nvme/host/rdma.c | 4 +++- drivers/nvme/host/tcp.c | 1 + drivers/nvme/target/loop.c | 2 +- 6 files changed, 9 insertions(+), 7 deletions(-)
drivers/nvme/host/core.c +2 -3
@@ -4891,7 +4891,7 @@ EXPORT_SYMBOL_GPL(nvme_remove_admin_tag_set);int nvme_alloc_io_tag_set (struct nvme_ctrl *ctrl,struct blk_mq_tag_set *set,const struct blk_mq_ops *ops,unsigned int flags, -unsigned int cmd_size) +unsigned int nr_maps,unsigned int cmd_size) {int ret;
@@ -4905,8 +4905,7 @@ int nvme_alloc_io_tag_set(struct nvme_ctrl *ctrl, struct blk_mq_tag_set *set, set->driver_data = ctrl; set->nr_hw_queues = ctrl->queue_count -1 ; set->timeout =NVME_IO_TIMEOUT ; -if (ops->map_queues) - set->nr_maps = ctrl->opts->nr_poll_queues ?HCTX_MAX_TYPES :2 ; + set->nr_maps = nr_maps; ret =blk_mq_alloc_tag_set (set);if (ret)return ret;
drivers/nvme/host/fc.c +1 -1
@@ -2904,7 +2904,7 @@ nvme_fc_create_io_queues(struct nvme_fc_ctrl *ctrl)nvme_fc_init_io_queues (ctrl); ret =nvme_alloc_io_tag_set (&ctrl->ctrl, &ctrl->tag_set, - &nvme_fc_mq_ops,BLK_MQ_F_SHOULD_MERGE , + &nvme_fc_mq_ops,BLK_MQ_F_SHOULD_MERGE ,1 ,struct_size ((struct nvme_fcp_op_w_sgl *)NULL , priv, ctrl->lport->ops->fcprqst_priv_sz));if (ret)
drivers/nvme/host/nvme.h +1 -1
@@ -747,7 +747,7 @@ int nvme_alloc_admin_tag_set(struct nvme_ctrl *ctrl, struct blk_mq_tag_set *set,void nvme_remove_admin_tag_set (struct nvme_ctrl *ctrl);int nvme_alloc_io_tag_set (struct nvme_ctrl *ctrl,struct blk_mq_tag_set *set,const struct blk_mq_ops *ops,unsigned int flags, -unsigned int cmd_size); +unsigned int nr_maps,unsigned int cmd_size);void nvme_remove_io_tag_set (struct nvme_ctrl *ctrl);void nvme_remove_namespaces (struct nvme_ctrl *ctrl);
drivers/nvme/host/rdma.c +3 -1
@@ -798,7 +798,9 @@ static int nvme_rdma_alloc_tag_set(struct nvme_ctrl *ctrl)NVME_RDMA_METADATA_SGL_SIZE ;return nvme_alloc_io_tag_set (ctrl, &to_rdma_ctrl (ctrl)->tag_set, - &nvme_rdma_mq_ops,BLK_MQ_F_SHOULD_MERGE , cmd_size); + &nvme_rdma_mq_ops,BLK_MQ_F_SHOULD_MERGE , + ctrl->opts->nr_poll_queues ?HCTX_MAX_TYPES :2 , + cmd_size); }static void nvme_rdma_destroy_admin_queue (struct nvme_rdma_ctrl *ctrl)
drivers/nvme/host/tcp.c +1 -0
@@ -1859,6 +1859,7 @@ static int nvme_tcp_configure_io_queues(struct nvme_ctrl *ctrl, bool new) ret =nvme_alloc_io_tag_set (ctrl, &to_tcp_ctrl (ctrl)->tag_set, &nvme_tcp_mq_ops,BLK_MQ_F_SHOULD_MERGE |BLK_MQ_F_BLOCKING , + ctrl->opts->nr_poll_queues ?HCTX_MAX_TYPES :2 ,sizeof (struct nvme_tcp_request ));if (ret) goto out_free_io_queues;
drivers/nvme/target/loop.c +1 -1
@@ -494,7 +494,7 @@ static int nvme_loop_create_io_queues(struct nvme_loop_ctrl *ctrl)return ret; ret =nvme_alloc_io_tag_set (&ctrl->ctrl, &ctrl->tag_set, - &nvme_loop_mq_ops,BLK_MQ_F_SHOULD_MERGE , + &nvme_loop_mq_ops,BLK_MQ_F_SHOULD_MERGE ,1 ,sizeof (struct nvme_loop_iod ) +NVME_INLINE_SG_CNT *sizeof (struct scatterlist ));if (ret)
Signature · 1 line
2.30.2
Re: [PATCH 1/5] nvme: pass nr_maps explicitly to nvme_alloc_io_tag_set
Christoph Hellwig
maintainerPATCH 2/5 nvme: consolidate setting the tagset flags
In reply to Christoph HellwigAll nvme transports should be using the same flags for their tagsets, with the exception for the blocking flag that should only be set for transports that can block in ->queue_rq.
Add a NVME_F_BLOCKING flag to nvme_ctrl_ops to control the blocking behavior and lift setting the flags into nvme_alloc_{admin,io}_tag_set.
--- drivers/nvme/host/core.c | 15 +++++++++------ drivers/nvme/host/fc.c | 4 ++-- drivers/nvme/host/nvme.h | 9 +++++---- drivers/nvme/host/rdma.c | 3 +-- drivers/nvme/host/tcp.c | 3 +-- drivers/nvme/target/loop.c | 4 ++-- 6 files changed, 20 insertions(+), 18 deletions(-)
drivers/nvme/host/core.c +9 -6
@@ -4831,8 +4831,7 @@ void nvme_complete_async_event(struct nvme_ctrl *ctrl, __le16 status,EXPORT_SYMBOL_GPL (nvme_complete_async_event);int nvme_alloc_admin_tag_set (struct nvme_ctrl *ctrl,struct blk_mq_tag_set *set, -const struct blk_mq_ops *ops,unsigned int flags, -unsigned int cmd_size) +const struct blk_mq_ops *ops,unsigned int cmd_size) {int ret;
@@ -4842,7 +4841,9 @@ int nvme_alloc_admin_tag_set(struct nvme_ctrl *ctrl, struct blk_mq_tag_set *set,if (ctrl->ops->flags &NVME_F_FABRICS ) set->reserved_tags =NVMF_RESERVED_TAGS ; set->numa_node = ctrl->numa_node; - set->flags = flags; + set->flags =BLK_MQ_F_NO_SCHED ; +if (ctrl->ops->flags &NVME_F_BLOCKING ) + set->flags |=BLK_MQ_F_BLOCKING ; set->cmd_size = cmd_size; set->driver_data = ctrl; set->nr_hw_queues =1 ;
@@ -4890,8 +4891,8 @@ void nvme_remove_admin_tag_set(struct nvme_ctrl *ctrl)EXPORT_SYMBOL_GPL (nvme_remove_admin_tag_set);int nvme_alloc_io_tag_set (struct nvme_ctrl *ctrl,struct blk_mq_tag_set *set, -const struct blk_mq_ops *ops,unsigned int flags, -unsigned int nr_maps,unsigned int cmd_size) +const struct blk_mq_ops *ops,unsigned int nr_maps, +unsigned int cmd_size) {int ret;
@@ -4900,7 +4901,9 @@ int nvme_alloc_io_tag_set(struct nvme_ctrl *ctrl, struct blk_mq_tag_set *set, set->queue_depth = ctrl->sqsize +1 ; set->reserved_tags =NVMF_RESERVED_TAGS ; set->numa_node = ctrl->numa_node; - set->flags = flags; + set->flags =BLK_MQ_F_SHOULD_MERGE ; +if (ctrl->ops->flags &NVME_F_BLOCKING ) + set->flags |=BLK_MQ_F_BLOCKING ; set->cmd_size = cmd_size, set->driver_data = ctrl; set->nr_hw_queues = ctrl->queue_count -1 ;
drivers/nvme/host/fc.c +2 -2
@@ -2904,7 +2904,7 @@ nvme_fc_create_io_queues(struct nvme_fc_ctrl *ctrl)nvme_fc_init_io_queues (ctrl); ret =nvme_alloc_io_tag_set (&ctrl->ctrl, &ctrl->tag_set, - &nvme_fc_mq_ops,BLK_MQ_F_SHOULD_MERGE ,1 , + &nvme_fc_mq_ops,1 ,struct_size ((struct nvme_fcp_op_w_sgl *)NULL , priv, ctrl->lport->ops->fcprqst_priv_sz));if (ret)
@@ -3510,7 +3510,7 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,nvme_fc_init_queue (ctrl,0 ); ret =nvme_alloc_admin_tag_set (&ctrl->ctrl, &ctrl->admin_tag_set, - &nvme_fc_admin_mq_ops,BLK_MQ_F_NO_SCHED , + &nvme_fc_admin_mq_ops,struct_size ((struct nvme_fcp_op_w_sgl *)NULL , priv, ctrl->lport->ops->fcprqst_priv_sz));if (ret)
drivers/nvme/host/nvme.h +5 -4
@@ -512,6 +512,8 @@ struct nvme_ctrl_ops {unsigned int flags;#define NVME_F_FABRICS (1 << 0)#define NVME_F_METADATA_SUPPORTED (1 << 1) +#define NVME_F_BLOCKING (1 << 2) +const struct attribute_group **dev_attr_groups;int (*reg_read32)(struct nvme_ctrl *ctrl,u32 off,u32 *val);int (*reg_write32)(struct nvme_ctrl *ctrl,u32 off,u32 val);
@@ -742,12 +744,11 @@ void nvme_start_ctrl(struct nvme_ctrl *ctrl);void nvme_stop_ctrl (struct nvme_ctrl *ctrl);int nvme_init_ctrl_finish (struct nvme_ctrl *ctrl,bool was_suspended);int nvme_alloc_admin_tag_set (struct nvme_ctrl *ctrl,struct blk_mq_tag_set *set, -const struct blk_mq_ops *ops,unsigned int flags, -unsigned int cmd_size); +const struct blk_mq_ops *ops,unsigned int cmd_size);void nvme_remove_admin_tag_set (struct nvme_ctrl *ctrl);int nvme_alloc_io_tag_set (struct nvme_ctrl *ctrl,struct blk_mq_tag_set *set, -const struct blk_mq_ops *ops,unsigned int flags, -unsigned int nr_maps,unsigned int cmd_size); +const struct blk_mq_ops *ops,unsigned int nr_maps, +unsigned int cmd_size);void nvme_remove_io_tag_set (struct nvme_ctrl *ctrl);void nvme_remove_namespaces (struct nvme_ctrl *ctrl);
drivers/nvme/host/rdma.c +1 -2
@@ -798,7 +798,7 @@ static int nvme_rdma_alloc_tag_set(struct nvme_ctrl *ctrl)NVME_RDMA_METADATA_SGL_SIZE ;return nvme_alloc_io_tag_set (ctrl, &to_rdma_ctrl (ctrl)->tag_set, - &nvme_rdma_mq_ops,BLK_MQ_F_SHOULD_MERGE , + &nvme_rdma_mq_ops, ctrl->opts->nr_poll_queues ?HCTX_MAX_TYPES :2 , cmd_size); }
@@ -848,7 +848,6 @@ static int nvme_rdma_configure_admin_queue(struct nvme_rdma_ctrl *ctrl,if (new) { error =nvme_alloc_admin_tag_set (&ctrl->ctrl, &ctrl->admin_tag_set, &nvme_rdma_admin_mq_ops, -BLK_MQ_F_NO_SCHED ,sizeof (struct nvme_rdma_request ) +NVME_RDMA_DATA_SGL_SIZE );if (error)
drivers/nvme/host/tcp.c +1 -2
@@ -1858,7 +1858,6 @@ static int nvme_tcp_configure_io_queues(struct nvme_ctrl *ctrl, bool new)if (new) { ret =nvme_alloc_io_tag_set (ctrl, &to_tcp_ctrl (ctrl)->tag_set, &nvme_tcp_mq_ops, -BLK_MQ_F_SHOULD_MERGE |BLK_MQ_F_BLOCKING , ctrl->opts->nr_poll_queues ?HCTX_MAX_TYPES :2 ,sizeof (struct nvme_tcp_request ));if (ret)
@@ -1934,7 +1933,7 @@ static int nvme_tcp_configure_admin_queue(struct nvme_ctrl *ctrl, bool new)if (new) { error =nvme_alloc_admin_tag_set (ctrl, &to_tcp_ctrl (ctrl)->admin_tag_set, - &nvme_tcp_admin_mq_ops,BLK_MQ_F_BLOCKING , + &nvme_tcp_admin_mq_ops,sizeof (struct nvme_tcp_request ));if (error) goto out_free_queue;
drivers/nvme/target/loop.c +2 -2
@@ -353,7 +353,7 @@ static int nvme_loop_configure_admin_queue(struct nvme_loop_ctrl *ctrl) ctrl->ctrl.queue_count =1 ; error =nvme_alloc_admin_tag_set (&ctrl->ctrl, &ctrl->admin_tag_set, - &nvme_loop_admin_mq_ops,BLK_MQ_F_NO_SCHED , + &nvme_loop_admin_mq_ops,sizeof (struct nvme_loop_iod ) +NVME_INLINE_SG_CNT *sizeof (struct scatterlist ));if (error)
@@ -494,7 +494,7 @@ static int nvme_loop_create_io_queues(struct nvme_loop_ctrl *ctrl)return ret; ret =nvme_alloc_io_tag_set (&ctrl->ctrl, &ctrl->tag_set, - &nvme_loop_mq_ops,BLK_MQ_F_SHOULD_MERGE ,1 , + &nvme_loop_mq_ops,1 ,sizeof (struct nvme_loop_iod ) +NVME_INLINE_SG_CNT *sizeof (struct scatterlist ));if (ret)
Signature · 1 line
2.30.2
Re: [PATCH 2/5] nvme: consolidate setting the tagset flags
Quoted 69 lines · Christoph Hellwig
All nvme transports should be using the same flags for their tagsets, with the exception for the blocking flag that should only be set for transports that can block in ->queue_rq.
Add a
NVME_F_BLOCKINGflag tonvme_ctrl_opsto control the blocking behavior and lift setting the flags into nvme_alloc_{admin,io}_tag_set.Signed-off-by Christoph Hellwig <[email protected]>--- drivers/nvme/host/core.c | 15 +++++++++------ drivers/nvme/host/fc.c | 4 ++-- drivers/nvme/host/nvme.h | 9 +++++---- drivers/nvme/host/rdma.c | 3 +-- drivers/nvme/host/tcp.c | 3 +-- drivers/nvme/target/loop.c | 4 ++-- 6 files changed, 20 insertions(+), 18 deletions(-)drivers/nvme/host/core.c +9
-6@@ -4831,8 +4831,7 @@ void nvme_complete_async_event(struct nvme_ctrl *ctrl, __le16 status,EXPORT_SYMBOL_GPL (nvme_complete_async_event);int nvme_alloc_admin_tag_set (struct nvme_ctrl *ctrl,struct blk_mq_tag_set *set, -const struct blk_mq_ops *ops,unsigned int flags, -unsigned int cmd_size) +const struct blk_mq_ops *ops,unsigned int cmd_size) {int ret;@@ -4842,7 +4841,9 @@ int nvme_alloc_admin_tag_set(struct nvme_ctrl *ctrl, struct blk_mq_tag_set *set,if (ctrl->ops->flags &NVME_F_FABRICS ) set->reserved_tags =NVMF_RESERVED_TAGS ; set->numa_node = ctrl->numa_node; - set->flags = flags; + set->flags =BLK_MQ_F_NO_SCHED ; +if (ctrl->ops->flags &NVME_F_BLOCKING ) + set->flags |=BLK_MQ_F_BLOCKING ; set->cmd_size = cmd_size; set->driver_data = ctrl; set->nr_hw_queues =1 ;@@ -4890,8 +4891,8 @@ void nvme_remove_admin_tag_set(struct nvme_ctrl *ctrl)EXPORT_SYMBOL_GPL (nvme_remove_admin_tag_set);int nvme_alloc_io_tag_set (struct nvme_ctrl *ctrl,struct blk_mq_tag_set *set, -const struct blk_mq_ops *ops,unsigned int flags, -unsigned int nr_maps,unsigned int cmd_size) +const struct blk_mq_ops *ops,unsigned int nr_maps, +unsigned int cmd_size) {int ret;@@ -4900,7 +4901,9 @@ int nvme_alloc_io_tag_set(struct nvme_ctrl *ctrl, struct blk_mq_tag_set *set, set->queue_depth = ctrl->sqsize +1 ; set->reserved_tags =NVMF_RESERVED_TAGS ; set->numa_node = ctrl->numa_node; - set->flags = flags; + set->flags =BLK_MQ_F_SHOULD_MERGE ; +if (ctrl->ops->flags &NVME_F_BLOCKING ) + set->flags |=BLK_MQ_F_BLOCKING ; set->cmd_size = cmd_size, set->driver_data = ctrl; set->nr_hw_queues = ctrl->queue_count -1 ;drivers/nvme/host/tcp.c +0
-0
drivers/nvme/host/tcp.c static int nvme_tcp_configure_io_queues(struct nvme_ctrl *ctrl, bool new) · line 1861
Quoted 4 lines
drivers/nvme/host/tcp.c +0
-1@@ -1858,7 +1858,6 @@ static int nvme_tcp_configure_io_queues(struct nvme_ctrl *ctrl, bool new)if (new) { ret = nvme_alloc_io_tag_set(ctrl, &to_tcp_ctrl(ctrl)->tag_set, &nvme_tcp_mq_ops, - BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_BLOCKING,
tcp should set NVME_F_BLOCKING in ctrl->ops->flags, I did not see that in this patch. Did I miss something?
Christoph Hellwig
maintainerRe: [PATCH 2/5] nvme: consolidate setting the tagset flags
Quoted 2 lines · Chao Leng
tcp should set
NVME_F_BLOCKINGinctrl->ops->flags, I did not see that in this patch. Did I miss something?
No, I missed that I got lost during my rebase.
Re: [PATCH 2/5] nvme: consolidate setting the tagset flags
Quoted 6 lines · Chao Leng
Quoted 2 lines
tcp should set
NVME_F_BLOCKINGinctrl->ops->flags, I did not see that in this patch. Did I miss something?No, I missed that I got lost during my rebase.
With that looks good,
Christoph Hellwig
maintainerRe: [PATCH 2/5] nvme: consolidate setting the tagset flags
Quoted 8 lines · Sagi Grimberg
Quoted 6 lines · Chao Leng
Quoted 2 lines
tcp should set
NVME_F_BLOCKINGinctrl->ops->flags, I did not see that in this patch. Did I miss something?No, I missed that I got lost during my rebase.
With that looks good,
I've fixed that up and did a full blktests run with trtype=tcp.
With that I've pulled this and the remove cleanup series into nvme-6.2.
Thanks to everyone for the reviews!
Christoph Hellwig
maintainerPATCH 3/5 nvme: only set reserved_tags in nvme_alloc_io_tag_set for fabrics controllers
In reply to Christoph HellwigThe reserved_tags are only needed for fabrics controllers. Right now only fabrics drivers call this helper, so this is harmless, but we'll use it in the PCIe driver soon.
--- drivers/nvme/host/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/nvme/host/core.c +2 -1
@@ -4899,7 +4899,8 @@ int nvme_alloc_io_tag_set(struct nvme_ctrl *ctrl, struct blk_mq_tag_set *set,memset (set,0 ,sizeof (*set)); set->ops = ops; set->queue_depth = ctrl->sqsize +1 ; - set->reserved_tags =NVMF_RESERVED_TAGS ; +if (ctrl->ops->flags &NVME_F_FABRICS ) + set->reserved_tags =NVMF_RESERVED_TAGS ; set->numa_node = ctrl->numa_node; set->flags =BLK_MQ_F_SHOULD_MERGE ;if (ctrl->ops->flags &NVME_F_BLOCKING )
Signature · 1 line
2.30.2
Re: [PATCH 3/5] nvme: only set reserved_tags in nvme_alloc_io_tag_set for fabrics controllers
Christoph Hellwig
maintainerPATCH 4/5 nvme: add the Apple shared tag workaround to nvme_alloc_io_tag_set
In reply to Christoph HellwigAdd the apple shared tag workaround to nvme_alloc_io_tag_set to prepare for using that helper in the PCIe driver.
--- drivers/nvme/host/core.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/nvme/host/core.c +6 -0
@@ -4899,8 +4899,14 @@ int nvme_alloc_io_tag_set(struct nvme_ctrl *ctrl, struct blk_mq_tag_set *set,memset (set,0 ,sizeof (*set)); set->ops = ops; set->queue_depth = ctrl->sqsize +1 ; +/* +* Some Apple controllers requires tags to be unique across admin and +* the (only) I/O queue, so reserve the first 32 tags of the I/O queue. +*/ if (ctrl->ops->flags &NVME_F_FABRICS ) set->reserved_tags =NVMF_RESERVED_TAGS ; +else if (ctrl->quirks &NVME_QUIRK_SHARED_TAGS ) + set->reserved_tags =NVME_AQ_DEPTH ; set->numa_node = ctrl->numa_node; set->flags =BLK_MQ_F_SHOULD_MERGE ;if (ctrl->ops->flags &NVME_F_BLOCKING )
Signature · 1 line
2.30.2
Re: [PATCH 4/5] nvme: add the Apple shared tag workaround to nvme_alloc_io_tag_set
Christoph Hellwig
maintainerPATCH 5/5 nvme-pci: use the tagset alloc/free helpers
In reply to Christoph HellwigUse the common helpers to allocate and free the tagsets. To make this work the generic nvme_ctrl now needs to be stored in the hctx private data instead of the nvme_dev.
--- drivers/nvme/host/pci.c | 89 +++++++++-------------------------------- 1 file changed, 18 insertions(+), 71 deletions(-)
drivers/nvme/host/pci.c +18 -71
@@ -398,7 +398,7 @@ static int nvme_pci_npages_sgl(void)static int nvme_admin_init_hctx (struct blk_mq_hw_ctx *hctx,void *data,unsigned int hctx_idx) { -struct nvme_dev *dev = data; +struct nvme_dev *dev =to_nvme_dev (data);struct nvme_queue *nvmeq = &dev->queues[0 ];WARN_ON (hctx_idx !=0 );
@@ -411,7 +411,7 @@ static int nvme_admin_init_hctx(struct blk_mq_hw_ctx *hctx, void *data,static int nvme_init_hctx (struct blk_mq_hw_ctx *hctx,void *data,unsigned int hctx_idx) { -struct nvme_dev *dev = data; +struct nvme_dev *dev =to_nvme_dev (data);struct nvme_queue *nvmeq = &dev->queues[hctx_idx +1 ];WARN_ON (dev->tagset.tags[hctx_idx] != hctx->tags);
@@ -423,7 +423,7 @@ static int nvme_pci_init_request(struct blk_mq_tag_set *set, struct request *req, unsigned int hctx_idx, unsigned int numa_node) { - struct nvme_dev *dev = set->driver_data; + struct nvme_dev *dev = to_nvme_dev(set->driver_data);struct nvme_iod *iod =blk_mq_rq_to_pdu (req);nvme_req (req)->ctrl = &dev->ctrl;
@@ -442,7 +442,7 @@ static int queue_irq_offset(struct nvme_dev *dev)static void nvme_pci_map_queues (struct blk_mq_tag_set *set) { -struct nvme_dev *dev = set->driver_data; +struct nvme_dev *dev =to_nvme_dev (set->driver_data);int i, qoff, offset; offset =queue_irq_offset (dev);
@@ -1728,39 +1728,10 @@ static void nvme_dev_remove_admin(struct nvme_dev *dev)* queue to flush these to completion. */ nvme_unquiesce_admin_queue (&dev->ctrl); -blk_mq_destroy_queue (dev->ctrl.admin_q); -blk_put_queue (dev->ctrl.admin_q); -blk_mq_free_tag_set (&dev->admin_tagset); +nvme_remove_admin_tag_set (&dev->ctrl); } } -static int nvme_pci_alloc_admin_tag_set (struct nvme_dev *dev) -{ -struct blk_mq_tag_set *set = &dev->admin_tagset; - - set->ops = &nvme_mq_admin_ops; - set->nr_hw_queues =1 ; - - set->queue_depth =NVME_AQ_MQ_TAG_DEPTH ; - set->timeout =NVME_ADMIN_TIMEOUT ; - set->numa_node = dev->ctrl.numa_node; - set->cmd_size =sizeof (struct nvme_iod ); - set->flags =BLK_MQ_F_NO_SCHED ; - set->driver_data = dev; - -if (blk_mq_alloc_tag_set (set)) -return -ENOMEM ; - dev->ctrl.admin_tagset = set; - - dev->ctrl.admin_q =blk_mq_init_queue (set); -if (IS_ERR (dev->ctrl.admin_q)) { -blk_mq_free_tag_set (set); - dev->ctrl.admin_q =NULL ; -return -ENOMEM ; - } -return 0 ; -} -static unsigned long db_bar_size (struct nvme_dev *dev,unsigned nr_io_queues) {return NVME_REG_DBS + ((nr_io_queues +1 ) *8 * dev->db_stride);
@@ -2515,40 +2486,13 @@ static void nvme_delete_io_queues(struct nvme_dev *dev)__nvme_delete_io_queues (dev, nvme_admin_delete_cq); } -static void nvme_pci_alloc_tag_set (struct nvme_dev *dev) +static unsigned int nvme_pci_nr_maps (struct nvme_dev *dev) { -struct blk_mq_tag_set * set = &dev->tagset; -int ret; - - set->ops = &nvme_mq_ops; - set->nr_hw_queues = dev->online_queues -1 ; - set->nr_maps =1 ; -if (dev->io_queues[HCTX_TYPE_READ ]) - set->nr_maps =2 ;if (dev->io_queues[HCTX_TYPE_POLL ]) - set->nr_maps =3 ; - set->timeout =NVME_IO_TIMEOUT ; - set->numa_node = dev->ctrl.numa_node; - set->queue_depth =min_t (unsigned, dev->q_depth,BLK_MQ_MAX_DEPTH ) -1 ; - set->cmd_size =sizeof (struct nvme_iod ); - set->flags =BLK_MQ_F_SHOULD_MERGE ; - set->driver_data = dev; - -/* -* Some Apple controllers requires tags to be unique -* across admin and IO queue, so reserve the first 32 -* tags of the IO queue. -*/ -if (dev->ctrl.quirks &NVME_QUIRK_SHARED_TAGS ) - set->reserved_tags =NVME_AQ_DEPTH ; - - ret =blk_mq_alloc_tag_set (set); -if (ret) { -dev_warn (dev->ctrl.device, -"IO queues tagset allocation failed %d\n" , ret); -return ; - } - dev->ctrl.tagset = set; +return 3 ; +if (dev->io_queues[HCTX_TYPE_READ ]) +return 2 ; +return 1 ; }static void nvme_pci_update_nr_queues (struct nvme_dev *dev)
@@ -2770,7 +2714,7 @@ static int nvme_pci_alloc_iod_mempool(struct nvme_dev *dev)static void nvme_free_tagset (struct nvme_dev *dev) {if (dev->tagset.tags) -blk_mq_free_tag_set (&dev->tagset); +nvme_remove_io_tag_set (&dev->ctrl); dev->ctrl.tagset =NULL ; }
@@ -3101,7 +3045,8 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (result) goto out_release_iod_mempool; - result =nvme_pci_alloc_admin_tag_set (dev); + result =nvme_alloc_admin_tag_set (&dev->ctrl, &dev->admin_tagset, + &nvme_mq_admin_ops,sizeof (struct nvme_iod ));if (result) goto out_disable;
@@ -3131,12 +3076,14 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id) goto out_disable;if (dev->online_queues >1 ) { -nvme_pci_alloc_tag_set (dev); +nvme_alloc_io_tag_set (&dev->ctrl, &dev->tagset, &nvme_mq_ops, +nvme_pci_nr_maps (dev),sizeof (struct nvme_iod ));nvme_dbbuf_set (dev); - }else { -dev_warn (dev->ctrl.device,"IO queues not created\n" ); } +if (!dev->ctrl.tagset) +dev_warn (dev->ctrl.device,"IO queues not created\n" ); +if (!nvme_change_ctrl_state (&dev->ctrl,NVME_CTRL_LIVE )) {dev_warn (dev->ctrl.device,"failed to mark controller live state\n" );
Signature · 1 line
2.30.2
Re: [PATCH 5/5] nvme-pci: use the tagset alloc/free helpers
Quoted 3 lines · Christoph Hellwig
Use the common helpers to allocate and free the tagsets. To make this work the generic
nvme_ctrlnow needs to be stored in the hctx private data instead of thenvme_dev.
Looks good.
Re: [PATCH 5/5] nvme-pci: use the tagset alloc/free helpers
In reply to Christoph HellwigChristoph Hellwig
maintainerAny further comments?
Chaitanya Kulkarni
Reviewed-byQuoted 1 line · Christoph Hellwig
Any further comments?
This series looks good to me, I'll run the blktests once you merge this.
-ck