All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] nvme: code cleanup and type fixes
@ 2020-06-02  2:41 Chaitanya Kulkarni
  2020-06-02  2:41 ` [PATCH 1/4] nvme-core: use u16 type for direcives Chaitanya Kulkarni
                   ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: Chaitanya Kulkarni @ 2020-06-02  2:41 UTC (permalink / raw)
  To: linux-nvme; +Cc: kbusch, hch, Chaitanya Kulkarni, sagi

Hi,

This is a small patch series which fixes few type mismatch issues
and clears up the code.

Please consider this for nvme-5.8.

Regards,
Chaitanya

Chaitanya Kulkarni (4):
  nvme-core: use u16 type for direcives
  nvme-core: use u16 type for ctrl->sqsize
  nvme-pci: use unsigned for io queue depth
  nvme-pci: code cleanup for nvme_alloc_host_mem()

 drivers/nvme/host/core.c |  4 ++--
 drivers/nvme/host/pci.c  | 27 ++++++++++++++-------------
 2 files changed, 16 insertions(+), 15 deletions(-)

-- 
2.22.1


_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/4] nvme-core: use u16 type for direcives
  2020-06-02  2:41 [PATCH 0/4] nvme: code cleanup and type fixes Chaitanya Kulkarni
@ 2020-06-02  2:41 ` Chaitanya Kulkarni
  2020-06-03 21:07   ` Sagi Grimberg
  2020-06-02  2:41 ` [PATCH 2/4] nvme-core: use u16 type for ctrl->sqsize Chaitanya Kulkarni
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Chaitanya Kulkarni @ 2020-06-02  2:41 UTC (permalink / raw)
  To: linux-nvme; +Cc: kbusch, hch, Chaitanya Kulkarni, sagi

In nvme_configure_directives() when calculating number of streams use
u16 instead of unsigned type in the min_t() since target variable
ctrl->nr_streams is of type u16.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 drivers/nvme/host/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index a3a4dbc59af1..8d05dbf29d76 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -555,7 +555,7 @@ static int nvme_configure_directives(struct nvme_ctrl *ctrl)
 		goto out_disable_stream;
 	}
 
-	ctrl->nr_streams = min_t(unsigned, ctrl->nssa, BLK_MAX_WRITE_HINTS - 1);
+	ctrl->nr_streams = min_t(u16, ctrl->nssa, BLK_MAX_WRITE_HINTS - 1);
 	dev_info(ctrl->device, "Using %u streams\n", ctrl->nr_streams);
 	return 0;
 
-- 
2.22.1


_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/4] nvme-core: use u16 type for ctrl->sqsize
  2020-06-02  2:41 [PATCH 0/4] nvme: code cleanup and type fixes Chaitanya Kulkarni
  2020-06-02  2:41 ` [PATCH 1/4] nvme-core: use u16 type for direcives Chaitanya Kulkarni
@ 2020-06-02  2:41 ` Chaitanya Kulkarni
  2020-06-03 21:07   ` Sagi Grimberg
  2020-06-02  2:41 ` [PATCH 3/4] nvme-pci: use unsigned for io queue depth Chaitanya Kulkarni
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Chaitanya Kulkarni @ 2020-06-02  2:41 UTC (permalink / raw)
  To: linux-nvme; +Cc: kbusch, hch, Chaitanya Kulkarni, sagi

In nvme_init_identify() when calculating submission queue size use u16
instead of int type in the min_t() since target variable ctrl->sqsize is
of type u16.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 drivers/nvme/host/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 8d05dbf29d76..d463b3060543 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2866,7 +2866,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);
+	ctrl->sqsize = min_t(u16, NVME_CAP_MQES(ctrl->cap), ctrl->sqsize);
 
 	if (ctrl->vs >= NVME_VS(1, 1, 0))
 		ctrl->subsystem = NVME_CAP_NSSRC(ctrl->cap);
-- 
2.22.1


_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 3/4] nvme-pci: use unsigned for io queue depth
  2020-06-02  2:41 [PATCH 0/4] nvme: code cleanup and type fixes Chaitanya Kulkarni
  2020-06-02  2:41 ` [PATCH 1/4] nvme-core: use u16 type for direcives Chaitanya Kulkarni
  2020-06-02  2:41 ` [PATCH 2/4] nvme-core: use u16 type for ctrl->sqsize Chaitanya Kulkarni
@ 2020-06-02  2:41 ` Chaitanya Kulkarni
  2020-06-03 21:07   ` Sagi Grimberg
  2020-06-02  2:41 ` [PATCH 4/4] nvme-pci: code cleanup for nvme_alloc_host_mem() Chaitanya Kulkarni
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Chaitanya Kulkarni @ 2020-06-02  2:41 UTC (permalink / raw)
  To: linux-nvme; +Cc: kbusch, hch, Chaitanya Kulkarni, sagi

The NVMe PCIe declares module parameter io_queue_depth as int. Change
this to u16 as queue depth can never be negative. Now to reflect this
update module parameter getter function from param_get_int() ->
param_get_uint() and respective setter function with type of n changed
from int to u16 with param_set_int() to param_set_ushort(). Finally
update struct nvme_dev q_depth member to u16 and use u16 in min_t()
when calculating dev->q_depth in the nvme_pci_enable() (since q_depth is
now u16) and use unsigned int instead of int when calculating
dev->tagset.queue_depth as target variable tagset->queue_depth is of type
unsigned int in nvme_dev_add().

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 drivers/nvme/host/pci.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index b307c06a783d..6bf8514bbbfb 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -61,10 +61,10 @@ MODULE_PARM_DESC(sgl_threshold,
 static int io_queue_depth_set(const char *val, const struct kernel_param *kp);
 static const struct kernel_param_ops io_queue_depth_ops = {
 	.set = io_queue_depth_set,
-	.get = param_get_int,
+	.get = param_get_uint,
 };
 
-static int io_queue_depth = 1024;
+static unsigned int io_queue_depth = 1024;
 module_param_cb(io_queue_depth, &io_queue_depth_ops, &io_queue_depth, 0644);
 MODULE_PARM_DESC(io_queue_depth, "set io queue depth, should >= 2");
 
@@ -115,7 +115,7 @@ struct nvme_dev {
 	unsigned max_qid;
 	unsigned io_queues[HCTX_MAX_TYPES];
 	unsigned int num_vecs;
-	int q_depth;
+	u16 q_depth;
 	int io_sqes;
 	u32 db_stride;
 	void __iomem *bar;
@@ -151,13 +151,14 @@ struct nvme_dev {
 
 static int io_queue_depth_set(const char *val, const struct kernel_param *kp)
 {
-	int n = 0, ret;
+	int ret;
+	u16 n;
 
-	ret = kstrtoint(val, 10, &n);
+	ret = kstrtou16(val, 10, &n);
 	if (ret != 0 || n < 2)
 		return -EINVAL;
 
-	return param_set_int(val, kp);
+	return param_set_ushort(val, kp);
 }
 
 static inline unsigned int sq_idx(unsigned int qid, u32 stride)
@@ -2250,8 +2251,8 @@ static void nvme_dev_add(struct nvme_dev *dev)
 			dev->tagset.nr_maps++;
 		dev->tagset.timeout = NVME_IO_TIMEOUT;
 		dev->tagset.numa_node = dev_to_node(dev->dev);
-		dev->tagset.queue_depth =
-				min_t(int, dev->q_depth, BLK_MQ_MAX_DEPTH) - 1;
+		dev->tagset.queue_depth = min_t(unsigned int, dev->q_depth,
+						BLK_MQ_MAX_DEPTH) - 1;
 		dev->tagset.cmd_size = sizeof(struct nvme_iod);
 		dev->tagset.flags = BLK_MQ_F_SHOULD_MERGE;
 		dev->tagset.driver_data = dev;
@@ -2310,7 +2311,7 @@ static int nvme_pci_enable(struct nvme_dev *dev)
 
 	dev->ctrl.cap = lo_hi_readq(dev->bar + NVME_REG_CAP);
 
-	dev->q_depth = min_t(int, NVME_CAP_MQES(dev->ctrl.cap) + 1,
+	dev->q_depth = min_t(u16, 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);
-- 
2.22.1


_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 4/4] nvme-pci: code cleanup for nvme_alloc_host_mem()
  2020-06-02  2:41 [PATCH 0/4] nvme: code cleanup and type fixes Chaitanya Kulkarni
                   ` (2 preceding siblings ...)
  2020-06-02  2:41 ` [PATCH 3/4] nvme-pci: use unsigned for io queue depth Chaitanya Kulkarni
@ 2020-06-02  2:41 ` Chaitanya Kulkarni
  2020-06-03 21:07   ` Sagi Grimberg
  2020-06-03 13:09 ` [PATCH 0/4] nvme: code cleanup and type fixes Christoph Hellwig
  2020-06-09 13:52 ` Christoph Hellwig
  5 siblings, 1 reply; 12+ messages in thread
From: Chaitanya Kulkarni @ 2020-06-02  2:41 UTC (permalink / raw)
  To: linux-nvme; +Cc: kbusch, hch, Chaitanya Kulkarni, sagi

Although use of for loop is preferred it is not a common practice to
have 80 char long for loop initialization and comparison section.

Use temp variables for calculating values and replace them in the
for loop with size of all variables to set to u64 since preferred
variable is declared as u64.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 drivers/nvme/host/pci.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 6bf8514bbbfb..171185d75194 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -1922,12 +1922,12 @@ static int __nvme_alloc_host_mem(struct nvme_dev *dev, u64 preferred,
 
 static int nvme_alloc_host_mem(struct nvme_dev *dev, u64 min, u64 preferred)
 {
-	u32 chunk_size;
+	u64 min_chunk = min_t(u64, preferred, PAGE_SIZE * MAX_ORDER_NR_PAGES);
+	u64 hmminds = max_t(u32, dev->ctrl.hmminds * 4096, PAGE_SIZE * 2);
+	u64 chunk_size;
 
 	/* start big and work our way down */
-	for (chunk_size = min_t(u64, preferred, PAGE_SIZE * MAX_ORDER_NR_PAGES);
-	     chunk_size >= max_t(u32, dev->ctrl.hmminds * 4096, PAGE_SIZE * 2);
-	     chunk_size /= 2) {
+	for (chunk_size = min_chunk; chunk_size >= hmminds; chunk_size /= 2) {
 		if (!__nvme_alloc_host_mem(dev, preferred, chunk_size)) {
 			if (!min || dev->host_mem_size >= min)
 				return 0;
-- 
2.22.1


_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/4] nvme: code cleanup and type fixes
  2020-06-02  2:41 [PATCH 0/4] nvme: code cleanup and type fixes Chaitanya Kulkarni
                   ` (3 preceding siblings ...)
  2020-06-02  2:41 ` [PATCH 4/4] nvme-pci: code cleanup for nvme_alloc_host_mem() Chaitanya Kulkarni
@ 2020-06-03 13:09 ` Christoph Hellwig
  2020-06-03 22:31   ` Chaitanya Kulkarni
  2020-06-09 13:52 ` Christoph Hellwig
  5 siblings, 1 reply; 12+ messages in thread
From: Christoph Hellwig @ 2020-06-03 13:09 UTC (permalink / raw)
  To: Chaitanya Kulkarni; +Cc: kbusch, hch, linux-nvme, sagi

On Mon, Jun 01, 2020 at 07:41:10PM -0700, Chaitanya Kulkarni wrote:
> Hi,
> 
> This is a small patch series which fixes few type mismatch issues
> and clears up the code.
> 
> Please consider this for nvme-5.8.

We're done with the 5.8 merge window.  That being said the cleanups look
ok and they can go into the 5.9 tree.

_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/4] nvme-core: use u16 type for direcives
  2020-06-02  2:41 ` [PATCH 1/4] nvme-core: use u16 type for direcives Chaitanya Kulkarni
@ 2020-06-03 21:07   ` Sagi Grimberg
  0 siblings, 0 replies; 12+ messages in thread
From: Sagi Grimberg @ 2020-06-03 21:07 UTC (permalink / raw)
  To: Chaitanya Kulkarni, linux-nvme; +Cc: kbusch, hch

Reviewed-by: Sagi Grimberg <sagi@grimberg.me>

_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/4] nvme-core: use u16 type for ctrl->sqsize
  2020-06-02  2:41 ` [PATCH 2/4] nvme-core: use u16 type for ctrl->sqsize Chaitanya Kulkarni
@ 2020-06-03 21:07   ` Sagi Grimberg
  0 siblings, 0 replies; 12+ messages in thread
From: Sagi Grimberg @ 2020-06-03 21:07 UTC (permalink / raw)
  To: Chaitanya Kulkarni, linux-nvme; +Cc: kbusch, hch

Reviewed-by: Sagi Grimberg <sagi@grimberg.me>

_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/4] nvme-pci: use unsigned for io queue depth
  2020-06-02  2:41 ` [PATCH 3/4] nvme-pci: use unsigned for io queue depth Chaitanya Kulkarni
@ 2020-06-03 21:07   ` Sagi Grimberg
  0 siblings, 0 replies; 12+ messages in thread
From: Sagi Grimberg @ 2020-06-03 21:07 UTC (permalink / raw)
  To: Chaitanya Kulkarni, linux-nvme; +Cc: kbusch, hch

Reviewed-by: Sagi Grimberg <sagi@grimberg.me>

_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 4/4] nvme-pci: code cleanup for nvme_alloc_host_mem()
  2020-06-02  2:41 ` [PATCH 4/4] nvme-pci: code cleanup for nvme_alloc_host_mem() Chaitanya Kulkarni
@ 2020-06-03 21:07   ` Sagi Grimberg
  0 siblings, 0 replies; 12+ messages in thread
From: Sagi Grimberg @ 2020-06-03 21:07 UTC (permalink / raw)
  To: Chaitanya Kulkarni, linux-nvme; +Cc: kbusch, hch

Reviewed-by: Sagi Grimberg <sagi@grimberg.me>

_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/4] nvme: code cleanup and type fixes
  2020-06-03 13:09 ` [PATCH 0/4] nvme: code cleanup and type fixes Christoph Hellwig
@ 2020-06-03 22:31   ` Chaitanya Kulkarni
  0 siblings, 0 replies; 12+ messages in thread
From: Chaitanya Kulkarni @ 2020-06-03 22:31 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: kbusch, sagi, linux-nvme

On 6/3/20 6:10 AM, Christoph Hellwig wrote:
> We're done with the 5.8 merge window.  That being said the cleanups look
> ok and they can go into the 5.9 tree.

Sorry my bad. I didn't send this seres in time, thanks.

_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/4] nvme: code cleanup and type fixes
  2020-06-02  2:41 [PATCH 0/4] nvme: code cleanup and type fixes Chaitanya Kulkarni
                   ` (4 preceding siblings ...)
  2020-06-03 13:09 ` [PATCH 0/4] nvme: code cleanup and type fixes Christoph Hellwig
@ 2020-06-09 13:52 ` Christoph Hellwig
  5 siblings, 0 replies; 12+ messages in thread
From: Christoph Hellwig @ 2020-06-09 13:52 UTC (permalink / raw)
  To: Chaitanya Kulkarni; +Cc: kbusch, hch, linux-nvme, sagi

Thanks,

applied to nvme-5.9.

_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-06-09 13:53 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-02  2:41 [PATCH 0/4] nvme: code cleanup and type fixes Chaitanya Kulkarni
2020-06-02  2:41 ` [PATCH 1/4] nvme-core: use u16 type for direcives Chaitanya Kulkarni
2020-06-03 21:07   ` Sagi Grimberg
2020-06-02  2:41 ` [PATCH 2/4] nvme-core: use u16 type for ctrl->sqsize Chaitanya Kulkarni
2020-06-03 21:07   ` Sagi Grimberg
2020-06-02  2:41 ` [PATCH 3/4] nvme-pci: use unsigned for io queue depth Chaitanya Kulkarni
2020-06-03 21:07   ` Sagi Grimberg
2020-06-02  2:41 ` [PATCH 4/4] nvme-pci: code cleanup for nvme_alloc_host_mem() Chaitanya Kulkarni
2020-06-03 21:07   ` Sagi Grimberg
2020-06-03 13:09 ` [PATCH 0/4] nvme: code cleanup and type fixes Christoph Hellwig
2020-06-03 22:31   ` Chaitanya Kulkarni
2020-06-09 13:52 ` Christoph Hellwig

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.