small set of nvme cleanups
Subsystems (3)
Sagi Grimberg
maintainercover small set of nvme cleanups
Centralizes queue size settings for fabrics and removes redundant argument to nvme_disable/enable_ctrl.
Sagi Grimberg (4):
nvme: have nvme_init_identify set ctrl->cap
nvme: move sqsize setting to the core
nvme: don't pass cap to nvme_disable_ctrl
nvme: don't pass cap to nvme_enable_ctrl
drivers/nvme/host/core.c | 19 ++++++++++--------- drivers/nvme/host/fc.c | 12 +----------- drivers/nvme/host/nvme.h | 4 ++-- drivers/nvme/host/pci.c | 7 ++++--- drivers/nvme/host/rdma.c | 15 ++------------- drivers/nvme/host/tcp.c | 13 ++----------- drivers/nvme/target/loop.c | 12 +----------- 7 files changed, 22 insertions(+), 60 deletions(-)
Signature · 1 line
2.17.1
Sagi Grimberg
maintainerPATCH 1/4 nvme: have nvme_init_identify set ctrl->cap
No need to use a stack cap variable.
--- drivers/nvme/host/core.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/nvme/host/core.c +3 -4
@@ -2563,7 +2563,6 @@ static int nvme_get_effects_log(struct nvme_ctrl *ctrl)int nvme_init_identify (struct nvme_ctrl *ctrl) {struct nvme_id_ctrl *id; -u64 cap;int ret, page_shift;u32 max_hw_sectors;bool prev_apst_enabled;
@@ -2574,15 +2573,15 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)return ret; } - ret = ctrl->ops->reg_read64 (ctrl,NVME_REG_CAP , &cap); + ret = ctrl->ops->reg_read64 (ctrl,NVME_REG_CAP , &ctrl->cap);if (ret) {dev_err (ctrl->device,"Reading CAP failed (%d)\n" , ret);return ret; } - page_shift =NVME_CAP_MPSMIN (cap) +12 ; + page_shift =NVME_CAP_MPSMIN (ctrl->cap) +12 ;if (ctrl->vs >=NVME_VS (1 ,1 ,0 )) - ctrl->subsystem =NVME_CAP_NSSRC (cap); + ctrl->subsystem =NVME_CAP_NSSRC (ctrl->cap); ret =nvme_identify_ctrl (ctrl, &id);if (ret) {
Signature · 1 line
2.17.1
PATCH 1/4 nvme: have nvme_init_identify set ctrl->cap
Quoted 3 lines · Sagi Grimberg
No need to use a stack cap variable.
Signed-off-by Sagi Grimberg <sagi at grimberg.me>
This looks good to me.
PATCH 1/4 nvme: have nvme_init_identify set ctrl->cap
Sagi,
I think the ctrl->cap is already configured frmo the following functions which are all before the nvme_init_identify():
pci: nvme_pci_enable()
rdma: nvme_rdma_configure_admin_queue()
fc: nvme_fc_create_association()
Even it's already stored before it can be read again, but should we really make it read again here?
Also I can see the 2nd patch description which tells that nvme_init_identify() loaded the ctrl->cap value instead of the functinos above.
If there's somethiig I missed here, Please let me know!
Thanks!
PATCH 1/4 nvme: have nvme_init_identify set ctrl->cap
In reply to Sagi GrimbergLooks good to me.
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
Quoted 39 lines · Sagi Grimberg
No need to use a stack cap variable.
Signed-off-by Sagi Grimberg <sagi at grimberg.me>--- drivers/nvme/host/core.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)drivers/nvme/host/core.c +3
-4@@ -2563,7 +2563,6 @@ static int nvme_get_effects_log(struct nvme_ctrl *ctrl)int nvme_init_identify (struct nvme_ctrl *ctrl) {struct nvme_id_ctrl *id; -u64 cap;int ret, page_shift;u32 max_hw_sectors;bool prev_apst_enabled;@@ -2574,15 +2573,15 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)return ret; } - ret = ctrl->ops->reg_read64 (ctrl,NVME_REG_CAP , &cap); + ret = ctrl->ops->reg_read64 (ctrl,NVME_REG_CAP , &ctrl->cap);if (ret) {dev_err (ctrl->device,"Reading CAP failed (%d)\n" , ret);return ret; } - page_shift =NVME_CAP_MPSMIN (cap) +12 ; + page_shift =NVME_CAP_MPSMIN (ctrl->cap) +12 ;if (ctrl->vs >=NVME_VS (1 ,1 ,0 )) - ctrl->subsystem =NVME_CAP_NSSRC (cap); + ctrl->subsystem =NVME_CAP_NSSRC (ctrl->cap); ret =nvme_identify_ctrl (ctrl, &id);if (ret) {
Sagi Grimberg
maintainerPATCH 2/4 nvme: move sqsize setting to the core
In reply to Sagi Grimbergnvme_init_identify reads the cap register right after, so no need to do that locally in the transport driver.
--- drivers/nvme/host/core.c | 1 + drivers/nvme/host/fc.c | 10 ---------- drivers/nvme/host/pci.c | 1 + drivers/nvme/host/rdma.c | 11 ----------- drivers/nvme/host/tcp.c | 9 --------- drivers/nvme/target/loop.c | 10 ---------- 6 files changed, 2 insertions(+), 40 deletions(-)
drivers/nvme/host/core.c +1 -0
@@ -2579,6 +2579,7 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)return ret; } page_shift =NVME_CAP_MPSMIN (ctrl->cap) +12 ; + ctrl->sqsize =min_t (int,NVME_CAP_MQES (ctrl->cap), ctrl->sqsize);if (ctrl->vs >=NVME_VS (1 ,1 ,0 )) ctrl->subsystem =NVME_CAP_NSSRC (ctrl->cap);
drivers/nvme/host/fc.c +0 -10
@@ -2647,16 +2647,6 @@ nvme_fc_create_association(struct nvme_fc_ctrl *ctrl)* prior connection values */ - ret =nvmf_reg_read64 (&ctrl->ctrl,NVME_REG_CAP , &ctrl->ctrl.cap); -if (ret) { -dev_err (ctrl->ctrl.device, -"prop_get NVME_REG_CAP failed\n" ); - goto out_disconnect_admin_queue; - } - - ctrl->ctrl.sqsize = -min_t (int,NVME_CAP_MQES (ctrl->ctrl.cap), ctrl->ctrl.sqsize); - ret =nvme_enable_ctrl (&ctrl->ctrl, ctrl->ctrl.cap);if (ret) goto out_disconnect_admin_queue;
drivers/nvme/host/pci.c +1 -0
@@ -2316,6 +2316,7 @@ static int nvme_pci_enable(struct nvme_dev *dev) dev->q_depth =min_t (int,NVME_CAP_MQES (dev->ctrl.cap) +1 , io_queue_depth); + dev->ctrl.sqsize = dev->q_depth -1 ;/* 0's based queue depth */ dev->db_stride =1 <<NVME_CAP_STRIDE (dev->ctrl.cap); dev->dbs = dev->bar +4096 ;
drivers/nvme/host/rdma.c +0 -11
@@ -809,17 +809,6 @@ static int nvme_rdma_configure_admin_queue(struct nvme_rdma_ctrl *ctrl,if (error) goto out_cleanup_queue; - error = ctrl->ctrl.ops->reg_read64 (&ctrl->ctrl,NVME_REG_CAP , - &ctrl->ctrl.cap); -if (error) { -dev_err (ctrl->ctrl.device, -"prop_get NVME_REG_CAP failed\n" ); - goto out_stop_queue; - } - - ctrl->ctrl.sqsize = -min_t (int,NVME_CAP_MQES (ctrl->ctrl.cap), ctrl->ctrl.sqsize); - error =nvme_enable_ctrl (&ctrl->ctrl, ctrl->ctrl.cap);if (error) goto out_stop_queue;
drivers/nvme/host/tcp.c +0 -9
@@ -1721,15 +1721,6 @@ static int nvme_tcp_configure_admin_queue(struct nvme_ctrl *ctrl, bool new)if (error) goto out_cleanup_queue; - error = ctrl->ops->reg_read64 (ctrl,NVME_REG_CAP , &ctrl->cap); -if (error) { -dev_err (ctrl->device, -"prop_get NVME_REG_CAP failed\n" ); - goto out_stop_queue; - } - - ctrl->sqsize =min_t (int,NVME_CAP_MQES (ctrl->cap), ctrl->sqsize); - error =nvme_enable_ctrl (ctrl, ctrl->cap);if (error) goto out_stop_queue;
drivers/nvme/target/loop.c +0 -10
@@ -369,16 +369,6 @@ static int nvme_loop_configure_admin_queue(struct nvme_loop_ctrl *ctrl)set_bit (NVME_LOOP_Q_LIVE , &ctrl->queues[0 ].flags); - error =nvmf_reg_read64 (&ctrl->ctrl,NVME_REG_CAP , &ctrl->ctrl.cap); -if (error) { -dev_err (ctrl->ctrl.device, -"prop_get NVME_REG_CAP failed\n" ); - goto out_cleanup_queue; - } - - ctrl->ctrl.sqsize = -min_t (int,NVME_CAP_MQES (ctrl->ctrl.cap), ctrl->ctrl.sqsize); - error =nvme_enable_ctrl (&ctrl->ctrl, ctrl->ctrl.cap);if (error) goto out_cleanup_queue;
Signature · 1 line
2.17.1
PATCH 2/4 nvme: move sqsize setting to the core
Quoted 4 lines · Sagi Grimberg
nvme_init_identifyreads the cap register right after, so no need to do that locally in the transport driver.Signed-off-by Sagi Grimberg <sagi at grimberg.me>
If the first patch is good to be picked up, I'm fine with this patch.
PATCH 2/4 nvme: move sqsize setting to the core
In reply to Sagi GrimbergLooks good to me.
Quoted 122 lines · Sagi Grimberg
nvme_init_identifyreads the cap register right after, so no need to do that locally in the transport driver.Signed-off-by Sagi Grimberg <sagi at grimberg.me>--- drivers/nvme/host/core.c | 1 + drivers/nvme/host/fc.c | 10 ---------- drivers/nvme/host/pci.c | 1 + drivers/nvme/host/rdma.c | 11 ----------- drivers/nvme/host/tcp.c | 9 --------- drivers/nvme/target/loop.c | 10 ---------- 6 files changed, 2 insertions(+), 40 deletions(-)drivers/nvme/host/core.c +1
-0@@ -2579,6 +2579,7 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)return ret; } page_shift =NVME_CAP_MPSMIN (ctrl->cap) +12 ; + ctrl->sqsize =min_t (int,NVME_CAP_MQES (ctrl->cap), ctrl->sqsize);if (ctrl->vs >=NVME_VS (1 ,1 ,0 )) ctrl->subsystem =NVME_CAP_NSSRC (ctrl->cap);drivers/nvme/host/fc.c +0
-10@@ -2647,16 +2647,6 @@ nvme_fc_create_association(struct nvme_fc_ctrl *ctrl)* prior connection values */ - ret =nvmf_reg_read64 (&ctrl->ctrl,NVME_REG_CAP , &ctrl->ctrl.cap); -if (ret) { -dev_err (ctrl->ctrl.device, -"prop_get NVME_REG_CAP failed\n" ); - goto out_disconnect_admin_queue; - } - - ctrl->ctrl.sqsize = -min_t (int,NVME_CAP_MQES (ctrl->ctrl.cap), ctrl->ctrl.sqsize); - ret =nvme_enable_ctrl (&ctrl->ctrl, ctrl->ctrl.cap);if (ret) goto out_disconnect_admin_queue;drivers/nvme/host/pci.c +1
-0@@ -2316,6 +2316,7 @@ static int nvme_pci_enable(struct nvme_dev *dev) dev->q_depth =min_t (int,NVME_CAP_MQES (dev->ctrl.cap) +1 , io_queue_depth); + dev->ctrl.sqsize = dev->q_depth -1 ;/* 0's based queue depth */ dev->db_stride =1 <<NVME_CAP_STRIDE (dev->ctrl.cap); dev->dbs = dev->bar +4096 ;drivers/nvme/host/rdma.c +0
-11@@ -809,17 +809,6 @@ static int nvme_rdma_configure_admin_queue(struct nvme_rdma_ctrl *ctrl,if (error) goto out_cleanup_queue; - error = ctrl->ctrl.ops->reg_read64 (&ctrl->ctrl,NVME_REG_CAP , - &ctrl->ctrl.cap); -if (error) { -dev_err (ctrl->ctrl.device, -"prop_get NVME_REG_CAP failed\n" ); - goto out_stop_queue; - } - - ctrl->ctrl.sqsize = -min_t (int,NVME_CAP_MQES (ctrl->ctrl.cap), ctrl->ctrl.sqsize); - error =nvme_enable_ctrl (&ctrl->ctrl, ctrl->ctrl.cap);if (error) goto out_stop_queue;drivers/nvme/host/tcp.c +0
-9@@ -1721,15 +1721,6 @@ static int nvme_tcp_configure_admin_queue(struct nvme_ctrl *ctrl, bool new)if (error) goto out_cleanup_queue; - error = ctrl->ops->reg_read64 (ctrl,NVME_REG_CAP , &ctrl->cap); -if (error) { -dev_err (ctrl->device, -"prop_get NVME_REG_CAP failed\n" ); - goto out_stop_queue; - } - - ctrl->sqsize =min_t (int,NVME_CAP_MQES (ctrl->cap), ctrl->sqsize); - error =nvme_enable_ctrl (ctrl, ctrl->cap);if (error) goto out_stop_queue;drivers/nvme/target/loop.c +0
-10@@ -369,16 +369,6 @@ static int nvme_loop_configure_admin_queue(struct nvme_loop_ctrl *ctrl)set_bit (NVME_LOOP_Q_LIVE , &ctrl->queues[0 ].flags); - error =nvmf_reg_read64 (&ctrl->ctrl,NVME_REG_CAP , &ctrl->ctrl.cap); -if (error) { -dev_err (ctrl->ctrl.device, -"prop_get NVME_REG_CAP failed\n" ); - goto out_cleanup_queue; - } - - ctrl->ctrl.sqsize = -min_t (int,NVME_CAP_MQES (ctrl->ctrl.cap), ctrl->ctrl.sqsize); - error =nvme_enable_ctrl (&ctrl->ctrl, ctrl->ctrl.cap);if (error) goto out_cleanup_queue;
Sagi Grimberg
maintainerPATCH 3/4 nvme: don't pass cap to nvme_disable_ctrl
In reply to Sagi GrimbergAll seem to call it with ctrl->cap so no need to pass it at all.
--- drivers/nvme/host/core.c | 4 ++-- drivers/nvme/host/nvme.h | 2 +- drivers/nvme/host/pci.c | 4 ++-- drivers/nvme/host/rdma.c | 2 +- drivers/nvme/host/tcp.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-)
drivers/nvme/host/core.c +2 -2
@@ -1949,7 +1949,7 @@ static int nvme_wait_ready(struct nvme_ctrl *ctrl, u64 cap, bool enabled)* bits', but doing so may cause the device to complete commands to the * admin queue ... and we don't know what memory that might be pointing at! */ -int nvme_disable_ctrl (struct nvme_ctrl *ctrl,u64 cap) +int nvme_disable_ctrl (struct nvme_ctrl *ctrl) {int ret;
@@ -1963,7 +1963,7 @@ int nvme_disable_ctrl(struct nvme_ctrl *ctrl, u64 cap)if (ctrl->quirks &NVME_QUIRK_DELAY_BEFORE_CHK_RDY )msleep (NVME_QUIRK_DELAY_AMOUNT ); -return nvme_wait_ready (ctrl, cap, false); +return nvme_wait_ready (ctrl, ctrl->cap, false); }EXPORT_SYMBOL_GPL (nvme_disable_ctrl);
drivers/nvme/host/nvme.h +1 -1
@@ -426,7 +426,7 @@ void nvme_complete_rq(struct request *req);bool nvme_cancel_request (struct request *req,void *data,bool reserved);bool nvme_change_ctrl_state (struct nvme_ctrl *ctrl,enum nvme_ctrl_state new_state); -int nvme_disable_ctrl (struct nvme_ctrl *ctrl,u64 cap); +int nvme_disable_ctrl (struct nvme_ctrl *ctrl);int nvme_enable_ctrl (struct nvme_ctrl *ctrl,u64 cap);int nvme_shutdown_ctrl (struct nvme_ctrl *ctrl); int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,
drivers/nvme/host/pci.c +2 -2
@@ -1403,7 +1403,7 @@ static void nvme_disable_admin_queue(struct nvme_dev *dev, bool shutdown)if (shutdown)nvme_shutdown_ctrl (&dev->ctrl);else -nvme_disable_ctrl (&dev->ctrl, dev->ctrl.cap); +nvme_disable_ctrl (&dev->ctrl);nvme_poll_irqdisable (nvmeq,-1 ); }
@@ -1679,7 +1679,7 @@ static int nvme_pci_configure_admin_queue(struct nvme_dev *dev) (readl(dev->bar + NVME_REG_CSTS) & NVME_CSTS_NSSRO))writel (NVME_CSTS_NSSRO , dev->bar +NVME_REG_CSTS ); - result =nvme_disable_ctrl (&dev->ctrl, dev->ctrl.cap); + result =nvme_disable_ctrl (&dev->ctrl);if (result <0 )return result;
drivers/nvme/host/rdma.c +1 -1
@@ -1860,7 +1860,7 @@ static void nvme_rdma_shutdown_ctrl(struct nvme_rdma_ctrl *ctrl, bool shutdown)if (shutdown)nvme_shutdown_ctrl (&ctrl->ctrl);else -nvme_disable_ctrl (&ctrl->ctrl, ctrl->ctrl.cap); +nvme_disable_ctrl (&ctrl->ctrl);nvme_rdma_teardown_admin_queue (ctrl, shutdown); }
drivers/nvme/host/tcp.c +1 -1
@@ -1896,7 +1896,7 @@ static void nvme_tcp_teardown_ctrl(struct nvme_ctrl *ctrl, bool shutdown)if (shutdown)nvme_shutdown_ctrl (ctrl);else -nvme_disable_ctrl (ctrl, ctrl->cap); +nvme_disable_ctrl (ctrl);nvme_tcp_teardown_admin_queue (ctrl, shutdown); }
Signature · 1 line
2.17.1
PATCH 3/4 nvme: don't pass cap to nvme_disable_ctrl
Quoted 4 lines · Sagi Grimberg
All seem to call it with
ctrl->capso no need to pass it at all.Signed-off-by Sagi Grimberg <sagi at grimberg.me>
Looks good to me.
PATCH 3/4 nvme: don't pass cap to nvme_disable_ctrl
In reply to Sagi GrimbergLooks good to me.
Quoted 96 lines · Sagi Grimberg
All seem to call it with
ctrl->capso no need to pass it at all.Signed-off-by Sagi Grimberg <sagi at grimberg.me>--- drivers/nvme/host/core.c | 4 ++-- drivers/nvme/host/nvme.h | 2 +- drivers/nvme/host/pci.c | 4 ++-- drivers/nvme/host/rdma.c | 2 +- drivers/nvme/host/tcp.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-)drivers/nvme/host/core.c +2
-2@@ -1949,7 +1949,7 @@ static int nvme_wait_ready(struct nvme_ctrl *ctrl, u64 cap, bool enabled)* bits', but doing so may cause the device to complete commands to the * admin queue ... and we don't know what memory that might be pointing at! */ -int nvme_disable_ctrl (struct nvme_ctrl *ctrl,u64 cap) +int nvme_disable_ctrl (struct nvme_ctrl *ctrl) {int ret;@@ -1963,7 +1963,7 @@ int nvme_disable_ctrl(struct nvme_ctrl *ctrl, u64 cap)if (ctrl->quirks &NVME_QUIRK_DELAY_BEFORE_CHK_RDY )msleep (NVME_QUIRK_DELAY_AMOUNT ); -return nvme_wait_ready (ctrl, cap, false); +return nvme_wait_ready (ctrl, ctrl->cap, false); }EXPORT_SYMBOL_GPL (nvme_disable_ctrl);drivers/nvme/host/nvme.h +1
-1@@ -426,7 +426,7 @@ void nvme_complete_rq(struct request *req);bool nvme_cancel_request (struct request *req,void *data,bool reserved);bool nvme_change_ctrl_state (struct nvme_ctrl *ctrl,enum nvme_ctrl_state new_state); -int nvme_disable_ctrl (struct nvme_ctrl *ctrl,u64 cap); +int nvme_disable_ctrl (struct nvme_ctrl *ctrl);int nvme_enable_ctrl (struct nvme_ctrl *ctrl,u64 cap);int nvme_shutdown_ctrl (struct nvme_ctrl *ctrl); int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,drivers/nvme/host/pci.c +2
-2@@ -1403,7 +1403,7 @@ static void nvme_disable_admin_queue(struct nvme_dev *dev, bool shutdown)if (shutdown)nvme_shutdown_ctrl (&dev->ctrl);else -nvme_disable_ctrl (&dev->ctrl, dev->ctrl.cap); +nvme_disable_ctrl (&dev->ctrl);nvme_poll_irqdisable (nvmeq,-1 ); }@@ -1679,7 +1679,7 @@ static int nvme_pci_configure_admin_queue(struct nvme_dev *dev) (readl(dev->bar + NVME_REG_CSTS) & NVME_CSTS_NSSRO))writel (NVME_CSTS_NSSRO , dev->bar +NVME_REG_CSTS ); - result =nvme_disable_ctrl (&dev->ctrl, dev->ctrl.cap); + result =nvme_disable_ctrl (&dev->ctrl);if (result <0 )return result;drivers/nvme/host/rdma.c +1
-1@@ -1860,7 +1860,7 @@ static void nvme_rdma_shutdown_ctrl(struct nvme_rdma_ctrl *ctrl, bool shutdown)if (shutdown)nvme_shutdown_ctrl (&ctrl->ctrl);else -nvme_disable_ctrl (&ctrl->ctrl, ctrl->ctrl.cap); +nvme_disable_ctrl (&ctrl->ctrl);nvme_rdma_teardown_admin_queue (ctrl, shutdown); }drivers/nvme/host/tcp.c +1
-1@@ -1896,7 +1896,7 @@ static void nvme_tcp_teardown_ctrl(struct nvme_ctrl *ctrl, bool shutdown)if (shutdown)nvme_shutdown_ctrl (ctrl);else -nvme_disable_ctrl (ctrl, ctrl->cap); +nvme_disable_ctrl (ctrl);nvme_tcp_teardown_admin_queue (ctrl, shutdown); }
Sagi Grimberg
maintainerPATCH 4/4 nvme: don't pass cap to nvme_enable_ctrl
In reply to Sagi GrimbergAll seem to call it with ctrl->cap so no need to pass it at all.
--- drivers/nvme/host/core.c | 7 ++++--- drivers/nvme/host/fc.c | 2 +- drivers/nvme/host/nvme.h | 2 +- drivers/nvme/host/pci.c | 2 +- drivers/nvme/host/rdma.c | 2 +- drivers/nvme/host/tcp.c | 2 +- drivers/nvme/target/loop.c | 2 +- 7 files changed, 10 insertions(+), 9 deletions(-)
drivers/nvme/host/core.c +4 -3
@@ -1967,14 +1967,15 @@ int nvme_disable_ctrl(struct nvme_ctrl *ctrl) }EXPORT_SYMBOL_GPL (nvme_disable_ctrl); -int nvme_enable_ctrl (struct nvme_ctrl *ctrl,u64 cap) +int nvme_enable_ctrl (struct nvme_ctrl *ctrl) {/* * Default to a 4K page size, with the intention to update this * path in the future to accomodate architectures with differing * kernel and IO page sizes. */ -unsigned dev_page_min =NVME_CAP_MPSMIN (cap) +12 , page_shift =12 ; +unsigned dev_page_min =NVME_CAP_MPSMIN (ctrl->cap) +12 ; +unsigned page_shift =12 ;int ret;if (page_shift < dev_page_min) {
@@ -1995,7 +1996,7 @@ int nvme_enable_ctrl(struct nvme_ctrl *ctrl, u64 cap) ret = ctrl->ops->reg_write32 (ctrl,NVME_REG_CC , ctrl->ctrl_config);if (ret)return ret; -return nvme_wait_ready (ctrl, cap, true); +return nvme_wait_ready (ctrl, ctrl->cap, true); }EXPORT_SYMBOL_GPL (nvme_enable_ctrl);
drivers/nvme/host/fc.c +1 -1
@@ -2647,7 +2647,7 @@ nvme_fc_create_association(struct nvme_fc_ctrl *ctrl)* prior connection values */ - ret =nvme_enable_ctrl (&ctrl->ctrl, ctrl->ctrl.cap); + ret =nvme_enable_ctrl (&ctrl->ctrl);if (ret) goto out_disconnect_admin_queue;
drivers/nvme/host/nvme.h +1 -1
@@ -427,7 +427,7 @@ bool nvme_cancel_request(struct request *req, void *data, bool reserved);bool nvme_change_ctrl_state (struct nvme_ctrl *ctrl,enum nvme_ctrl_state new_state);int nvme_disable_ctrl (struct nvme_ctrl *ctrl); -int nvme_enable_ctrl (struct nvme_ctrl *ctrl,u64 cap); +int nvme_enable_ctrl (struct nvme_ctrl *ctrl);int nvme_shutdown_ctrl (struct nvme_ctrl *ctrl);int nvme_init_ctrl (struct nvme_ctrl *ctrl,struct device *dev,const struct nvme_ctrl_ops *ops,unsigned long quirks);
drivers/nvme/host/pci.c +1 -1
@@ -1695,7 +1695,7 @@ static int nvme_pci_configure_admin_queue(struct nvme_dev *dev)lo_hi_writeq (nvmeq->sq_dma_addr, dev->bar +NVME_REG_ASQ );lo_hi_writeq (nvmeq->cq_dma_addr, dev->bar +NVME_REG_ACQ ); - result =nvme_enable_ctrl (&dev->ctrl, dev->ctrl.cap); + result =nvme_enable_ctrl (&dev->ctrl);if (result)return result;
drivers/nvme/host/rdma.c +1 -1
@@ -809,7 +809,7 @@ static int nvme_rdma_configure_admin_queue(struct nvme_rdma_ctrl *ctrl,if (error) goto out_cleanup_queue; - error =nvme_enable_ctrl (&ctrl->ctrl, ctrl->ctrl.cap); + error =nvme_enable_ctrl (&ctrl->ctrl);if (error) goto out_stop_queue;
drivers/nvme/host/tcp.c +1 -1
@@ -1721,7 +1721,7 @@ static int nvme_tcp_configure_admin_queue(struct nvme_ctrl *ctrl, bool new)if (error) goto out_cleanup_queue; - error =nvme_enable_ctrl (ctrl, ctrl->cap); + error =nvme_enable_ctrl (ctrl);if (error) goto out_stop_queue;
drivers/nvme/target/loop.c +1 -1
@@ -369,7 +369,7 @@ static int nvme_loop_configure_admin_queue(struct nvme_loop_ctrl *ctrl)set_bit (NVME_LOOP_Q_LIVE , &ctrl->queues[0 ].flags); - error =nvme_enable_ctrl (&ctrl->ctrl, ctrl->ctrl.cap); + error =nvme_enable_ctrl (&ctrl->ctrl);if (error) goto out_cleanup_queue;
Signature · 1 line
2.17.1
PATCH 4/4 nvme: don't pass cap to nvme_enable_ctrl
Looks good to me.
Quoted 124 lines · Sagi Grimberg
All seem to call it with
ctrl->capso no need to pass it at all.Signed-off-by Sagi Grimberg <sagi at grimberg.me>--- drivers/nvme/host/core.c | 7 ++++--- drivers/nvme/host/fc.c | 2 +- drivers/nvme/host/nvme.h | 2 +- drivers/nvme/host/pci.c | 2 +- drivers/nvme/host/rdma.c | 2 +- drivers/nvme/host/tcp.c | 2 +- drivers/nvme/target/loop.c | 2 +- 7 files changed, 10 insertions(+), 9 deletions(-)drivers/nvme/host/core.c +4
-3@@ -1967,14 +1967,15 @@ int nvme_disable_ctrl(struct nvme_ctrl *ctrl) }EXPORT_SYMBOL_GPL (nvme_disable_ctrl); -int nvme_enable_ctrl (struct nvme_ctrl *ctrl,u64 cap) +int nvme_enable_ctrl (struct nvme_ctrl *ctrl) {/* * Default to a 4K page size, with the intention to update this * path in the future to accomodate architectures with differing * kernel and IO page sizes. */ -unsigned dev_page_min =NVME_CAP_MPSMIN (cap) +12 , page_shift =12 ; +unsigned dev_page_min =NVME_CAP_MPSMIN (ctrl->cap) +12 ; +unsigned page_shift =12 ;int ret;if (page_shift < dev_page_min) {@@ -1995,7 +1996,7 @@ int nvme_enable_ctrl(struct nvme_ctrl *ctrl, u64 cap) ret = ctrl->ops->reg_write32 (ctrl,NVME_REG_CC , ctrl->ctrl_config);if (ret)return ret; -return nvme_wait_ready (ctrl, cap, true); +return nvme_wait_ready (ctrl, ctrl->cap, true); }EXPORT_SYMBOL_GPL (nvme_enable_ctrl);drivers/nvme/host/fc.c +1
-1@@ -2647,7 +2647,7 @@ nvme_fc_create_association(struct nvme_fc_ctrl *ctrl)* prior connection values */ - ret =nvme_enable_ctrl (&ctrl->ctrl, ctrl->ctrl.cap); + ret =nvme_enable_ctrl (&ctrl->ctrl);if (ret) goto out_disconnect_admin_queue;drivers/nvme/host/nvme.h +1
-1@@ -427,7 +427,7 @@ bool nvme_cancel_request(struct request *req, void *data, bool reserved);bool nvme_change_ctrl_state (struct nvme_ctrl *ctrl,enum nvme_ctrl_state new_state);int nvme_disable_ctrl (struct nvme_ctrl *ctrl); -int nvme_enable_ctrl (struct nvme_ctrl *ctrl,u64 cap); +int nvme_enable_ctrl (struct nvme_ctrl *ctrl);int nvme_shutdown_ctrl (struct nvme_ctrl *ctrl);int nvme_init_ctrl (struct nvme_ctrl *ctrl,struct device *dev,const struct nvme_ctrl_ops *ops,unsigned long quirks);drivers/nvme/host/pci.c +1
-1@@ -1695,7 +1695,7 @@ static int nvme_pci_configure_admin_queue(struct nvme_dev *dev)lo_hi_writeq (nvmeq->sq_dma_addr, dev->bar +NVME_REG_ASQ );lo_hi_writeq (nvmeq->cq_dma_addr, dev->bar +NVME_REG_ACQ ); - result =nvme_enable_ctrl (&dev->ctrl, dev->ctrl.cap); + result =nvme_enable_ctrl (&dev->ctrl);if (result)return result;drivers/nvme/host/rdma.c +1
-1@@ -809,7 +809,7 @@ static int nvme_rdma_configure_admin_queue(struct nvme_rdma_ctrl *ctrl,if (error) goto out_cleanup_queue; - error =nvme_enable_ctrl (&ctrl->ctrl, ctrl->ctrl.cap); + error =nvme_enable_ctrl (&ctrl->ctrl);if (error) goto out_stop_queue;drivers/nvme/host/tcp.c +1
-1@@ -1721,7 +1721,7 @@ static int nvme_tcp_configure_admin_queue(struct nvme_ctrl *ctrl, bool new)if (error) goto out_cleanup_queue; - error =nvme_enable_ctrl (ctrl, ctrl->cap); + error =nvme_enable_ctrl (ctrl);if (error) goto out_stop_queue;drivers/nvme/target/loop.c +1
-1@@ -369,7 +369,7 @@ static int nvme_loop_configure_admin_queue(struct nvme_loop_ctrl *ctrl)set_bit (NVME_LOOP_Q_LIVE , &ctrl->queues[0 ].flags); - error =nvme_enable_ctrl (&ctrl->ctrl, ctrl->ctrl.cap); + error =nvme_enable_ctrl (&ctrl->ctrl);if (error) goto out_cleanup_queue;
cover small set of nvme cleanups
In reply to Sagi GrimbergQuoted 9 lines · Sagi Grimberg
Centralizes queue size settings for fabrics and removes redundant argument to nvme_disable/enable_ctrl.
Sagi Grimberg (4):
nvme: havenvme_init_identifysetctrl->cap
nvme: move sqsize setting to the core
nvme: don't pass cap tonvme_disable_ctrl
nvme: don't pass cap tonvme_enable_ctrl
Quoted 9 lines
drivers/nvme/host/core.c | 19 ++++++++++--------- drivers/nvme/host/fc.c | 12 +----------- drivers/nvme/host/nvme.h | 4 ++-- drivers/nvme/host/pci.c | 7 ++++--- drivers/nvme/host/rdma.c | 15 ++------------- drivers/nvme/host/tcp.c | 13 ++----------- drivers/nvme/target/loop.c | 12 +----------- 7 files changed, 22 insertions(+), 60 deletions(-)
The changes look fine except for 1 main issue:? All of the nvmf transports call nvme_enable_ctrl(), which still references ctrl->cap, before they call nvme_init_identify().
-- james
Sagi Grimberg
maintainercover small set of nvme cleanups
Quoted 4 lines
The changes look fine except for 1 main issue:? All of the nvmf transports call
nvme_enable_ctrl(), which still referencesctrl->cap, before they callnvme_init_identify().
You're right, I'll move the cap register read to nvme_enable_ctrl.
Thanks!