All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] nvme: move command size checks to the core
@ 2019-04-30 15:38 Christoph Hellwig
  2019-04-30 15:38 ` [PATCH 2/2] nvme: mark nvme_core_init and nvme_core_exit static Christoph Hellwig
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Christoph Hellwig @ 2019-04-30 15:38 UTC (permalink / raw)


Most command aren't PCIe specific, so move the size checking for them
to core.c

Signed-off-by: Christoph Hellwig <hch at lst.de>
---
 drivers/nvme/host/core.c | 27 +++++++++++++++++++++++++++
 drivers/nvme/host/pci.c  | 31 +++----------------------------
 2 files changed, 30 insertions(+), 28 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 3dd043aa6d1f..e970c5adee28 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3879,10 +3879,37 @@ void nvme_start_queues(struct nvme_ctrl *ctrl)
 }
 EXPORT_SYMBOL_GPL(nvme_start_queues);
 
+/*
+ * Check we didn't inadvertently grow the command structure sizes:
+ */
+static inline void _nvme_check_size(void)
+{
+	BUILD_BUG_ON(sizeof(struct nvme_common_command) != 64);
+	BUILD_BUG_ON(sizeof(struct nvme_rw_command) != 64);
+	BUILD_BUG_ON(sizeof(struct nvme_identify) != 64);
+	BUILD_BUG_ON(sizeof(struct nvme_features) != 64);
+	BUILD_BUG_ON(sizeof(struct nvme_download_firmware) != 64);
+	BUILD_BUG_ON(sizeof(struct nvme_format_cmd) != 64);
+	BUILD_BUG_ON(sizeof(struct nvme_dsm_cmd) != 64);
+	BUILD_BUG_ON(sizeof(struct nvme_write_zeroes_cmd) != 64);
+	BUILD_BUG_ON(sizeof(struct nvme_abort_cmd) != 64);
+	BUILD_BUG_ON(sizeof(struct nvme_get_log_page_command) != 64);
+	BUILD_BUG_ON(sizeof(struct nvme_command) != 64);
+	BUILD_BUG_ON(sizeof(struct nvme_id_ctrl) != NVME_IDENTIFY_DATA_SIZE);
+	BUILD_BUG_ON(sizeof(struct nvme_id_ns) != NVME_IDENTIFY_DATA_SIZE);
+	BUILD_BUG_ON(sizeof(struct nvme_lba_range_type) != 64);
+	BUILD_BUG_ON(sizeof(struct nvme_smart_log) != 512);
+	BUILD_BUG_ON(sizeof(struct nvme_dbbuf) != 64);
+	BUILD_BUG_ON(sizeof(struct nvme_directive_cmd) != 64);
+}
+
+
 int __init nvme_core_init(void)
 {
 	int result = -ENOMEM;
 
+	_nvme_check_size();
+
 	nvme_wq = alloc_workqueue("nvme-wq",
 			WQ_UNBOUND | WQ_MEM_RECLAIM | WQ_SYSFS, 0);
 	if (!nvme_wq)
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 9b02c4576591..1c4da31a97c2 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -226,33 +226,6 @@ struct nvme_iod {
 	struct scatterlist *sg;
 };
 
-/*
- * Check we didin't inadvertently grow the command struct
- */
-static inline void _nvme_check_size(void)
-{
-	BUILD_BUG_ON(sizeof(struct nvme_common_command) != 64);
-	BUILD_BUG_ON(sizeof(struct nvme_rw_command) != 64);
-	BUILD_BUG_ON(sizeof(struct nvme_identify) != 64);
-	BUILD_BUG_ON(sizeof(struct nvme_create_cq) != 64);
-	BUILD_BUG_ON(sizeof(struct nvme_create_sq) != 64);
-	BUILD_BUG_ON(sizeof(struct nvme_delete_queue) != 64);
-	BUILD_BUG_ON(sizeof(struct nvme_features) != 64);
-	BUILD_BUG_ON(sizeof(struct nvme_download_firmware) != 64);
-	BUILD_BUG_ON(sizeof(struct nvme_format_cmd) != 64);
-	BUILD_BUG_ON(sizeof(struct nvme_dsm_cmd) != 64);
-	BUILD_BUG_ON(sizeof(struct nvme_write_zeroes_cmd) != 64);
-	BUILD_BUG_ON(sizeof(struct nvme_abort_cmd) != 64);
-	BUILD_BUG_ON(sizeof(struct nvme_get_log_page_command) != 64);
-	BUILD_BUG_ON(sizeof(struct nvme_command) != 64);
-	BUILD_BUG_ON(sizeof(struct nvme_id_ctrl) != NVME_IDENTIFY_DATA_SIZE);
-	BUILD_BUG_ON(sizeof(struct nvme_id_ns) != NVME_IDENTIFY_DATA_SIZE);
-	BUILD_BUG_ON(sizeof(struct nvme_lba_range_type) != 64);
-	BUILD_BUG_ON(sizeof(struct nvme_smart_log) != 512);
-	BUILD_BUG_ON(sizeof(struct nvme_dbbuf) != 64);
-	BUILD_BUG_ON(sizeof(struct nvme_directive_cmd) != 64);
-}
-
 static unsigned int max_io_queues(void)
 {
 	return num_possible_cpus() + write_queues + poll_queues;
@@ -2981,6 +2954,9 @@ static struct pci_driver nvme_driver = {
 
 static int __init nvme_init(void)
 {
+	BUILD_BUG_ON(sizeof(struct nvme_create_cq) != 64);
+	BUILD_BUG_ON(sizeof(struct nvme_create_sq) != 64);
+	BUILD_BUG_ON(sizeof(struct nvme_delete_queue) != 64);
 	BUILD_BUG_ON(IRQ_AFFINITY_MAX_SETS < 2);
 	return pci_register_driver(&nvme_driver);
 }
@@ -2989,7 +2965,6 @@ static void __exit nvme_exit(void)
 {
 	pci_unregister_driver(&nvme_driver);
 	flush_workqueue(nvme_wq);
-	_nvme_check_size();
 }
 
 MODULE_AUTHOR("Matthew Wilcox <willy at linux.intel.com>");
-- 
2.20.1

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

* [PATCH 2/2] nvme: mark nvme_core_init and nvme_core_exit static
  2019-04-30 15:38 [PATCH 1/2] nvme: move command size checks to the core Christoph Hellwig
@ 2019-04-30 15:38 ` Christoph Hellwig
  2019-04-30 15:52   ` Keith Busch
                     ` (2 more replies)
  2019-04-30 15:51 ` [PATCH 1/2] nvme: move command size checks to the core Keith Busch
                   ` (2 subsequent siblings)
  3 siblings, 3 replies; 9+ messages in thread
From: Christoph Hellwig @ 2019-04-30 15:38 UTC (permalink / raw)


Signed-off-by: Christoph Hellwig <hch at lst.de>
---
 drivers/nvme/host/core.c | 4 ++--
 drivers/nvme/host/nvme.h | 3 ---
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index e970c5adee28..cd16d98d1f1a 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3904,7 +3904,7 @@ static inline void _nvme_check_size(void)
 }
 
 
-int __init nvme_core_init(void)
+static int __init nvme_core_init(void)
 {
 	int result = -ENOMEM;
 
@@ -3956,7 +3956,7 @@ int __init nvme_core_init(void)
 	return result;
 }
 
-void __exit nvme_core_exit(void)
+static void __exit nvme_core_exit(void)
 {
 	ida_destroy(&nvme_subsystems_ida);
 	class_destroy(nvme_subsys_class);
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 527d64545023..5ee75b5ff83f 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -577,7 +577,4 @@ static inline struct nvme_ns *nvme_get_ns_from_dev(struct device *dev)
 	return dev_to_disk(dev)->private_data;
 }
 
-int __init nvme_core_init(void);
-void __exit nvme_core_exit(void);
-
 #endif /* _NVME_H */
-- 
2.20.1

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

* [PATCH 1/2] nvme: move command size checks to the core
  2019-04-30 15:38 [PATCH 1/2] nvme: move command size checks to the core Christoph Hellwig
  2019-04-30 15:38 ` [PATCH 2/2] nvme: mark nvme_core_init and nvme_core_exit static Christoph Hellwig
@ 2019-04-30 15:51 ` Keith Busch
  2019-04-30 16:58 ` Bart Van Assche
  2019-04-30 21:30 ` Chaitanya Kulkarni
  3 siblings, 0 replies; 9+ messages in thread
From: Keith Busch @ 2019-04-30 15:51 UTC (permalink / raw)


On Tue, Apr 30, 2019@08:38:32AM -0700, Christoph Hellwig wrote:
> Most command aren't PCIe specific, so move the size checking for them
> to core.c
> 
> Signed-off-by: Christoph Hellwig <hch at lst.de>

Looks good.

Reviewed-by: Keith Busch <keith.busch at intel.com>

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

* [PATCH 2/2] nvme: mark nvme_core_init and nvme_core_exit static
  2019-04-30 15:38 ` [PATCH 2/2] nvme: mark nvme_core_init and nvme_core_exit static Christoph Hellwig
@ 2019-04-30 15:52   ` Keith Busch
  2019-04-30 16:57   ` Bart Van Assche
  2019-04-30 21:30   ` Chaitanya Kulkarni
  2 siblings, 0 replies; 9+ messages in thread
From: Keith Busch @ 2019-04-30 15:52 UTC (permalink / raw)


Good catch.

Reviewed-by: Keith Busch <keith.busch at intel.com>

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

* [PATCH 2/2] nvme: mark nvme_core_init and nvme_core_exit static
  2019-04-30 15:38 ` [PATCH 2/2] nvme: mark nvme_core_init and nvme_core_exit static Christoph Hellwig
  2019-04-30 15:52   ` Keith Busch
@ 2019-04-30 16:57   ` Bart Van Assche
  2019-04-30 21:30   ` Chaitanya Kulkarni
  2 siblings, 0 replies; 9+ messages in thread
From: Bart Van Assche @ 2019-04-30 16:57 UTC (permalink / raw)


On Tue, 2019-04-30@11:38 -0400, Christoph Hellwig wrote:
> [ ... ]

Reviewed-by: Bart Van Assche <bvanassche at acm.org>

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

* [PATCH 1/2] nvme: move command size checks to the core
  2019-04-30 15:38 [PATCH 1/2] nvme: move command size checks to the core Christoph Hellwig
  2019-04-30 15:38 ` [PATCH 2/2] nvme: mark nvme_core_init and nvme_core_exit static Christoph Hellwig
  2019-04-30 15:51 ` [PATCH 1/2] nvme: move command size checks to the core Keith Busch
@ 2019-04-30 16:58 ` Bart Van Assche
  2019-04-30 21:30 ` Chaitanya Kulkarni
  3 siblings, 0 replies; 9+ messages in thread
From: Bart Van Assche @ 2019-04-30 16:58 UTC (permalink / raw)


On Tue, 2019-04-30@11:38 -0400, Christoph Hellwig wrote:
> Most command aren't PCIe specific, so move the size checking for them
> to core.c

Reviewed-by: Bart Van Assche <bvanassche at acm.org>

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

* [PATCH 1/2] nvme: move command size checks to the core
  2019-04-30 15:38 [PATCH 1/2] nvme: move command size checks to the core Christoph Hellwig
                   ` (2 preceding siblings ...)
  2019-04-30 16:58 ` Bart Van Assche
@ 2019-04-30 21:30 ` Chaitanya Kulkarni
  2019-05-01 13:18   ` Christoph Hellwig
  3 siblings, 1 reply; 9+ messages in thread
From: Chaitanya Kulkarni @ 2019-04-30 21:30 UTC (permalink / raw)


Looks good. Just one question about _nvme_check_size(), is there any 
significance for one _ over __ ?

Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>

On 4/30/19 8:39 AM, Christoph Hellwig wrote:
> Most command aren't PCIe specific, so move the size checking for them
> to core.c
> 
> Signed-off-by: Christoph Hellwig <hch at lst.de>
> ---
>   drivers/nvme/host/core.c | 27 +++++++++++++++++++++++++++
>   drivers/nvme/host/pci.c  | 31 +++----------------------------
>   2 files changed, 30 insertions(+), 28 deletions(-)
> 
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 3dd043aa6d1f..e970c5adee28 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -3879,10 +3879,37 @@ void nvme_start_queues(struct nvme_ctrl *ctrl)
>   }
>   EXPORT_SYMBOL_GPL(nvme_start_queues);
>   
> +/*
> + * Check we didn't inadvertently grow the command structure sizes:
> + */
> +static inline void _nvme_check_size(void)
> +{
> +	BUILD_BUG_ON(sizeof(struct nvme_common_command) != 64);
> +	BUILD_BUG_ON(sizeof(struct nvme_rw_command) != 64);
> +	BUILD_BUG_ON(sizeof(struct nvme_identify) != 64);
> +	BUILD_BUG_ON(sizeof(struct nvme_features) != 64);
> +	BUILD_BUG_ON(sizeof(struct nvme_download_firmware) != 64);
> +	BUILD_BUG_ON(sizeof(struct nvme_format_cmd) != 64);
> +	BUILD_BUG_ON(sizeof(struct nvme_dsm_cmd) != 64);
> +	BUILD_BUG_ON(sizeof(struct nvme_write_zeroes_cmd) != 64);
> +	BUILD_BUG_ON(sizeof(struct nvme_abort_cmd) != 64);
> +	BUILD_BUG_ON(sizeof(struct nvme_get_log_page_command) != 64);
> +	BUILD_BUG_ON(sizeof(struct nvme_command) != 64);
> +	BUILD_BUG_ON(sizeof(struct nvme_id_ctrl) != NVME_IDENTIFY_DATA_SIZE);
> +	BUILD_BUG_ON(sizeof(struct nvme_id_ns) != NVME_IDENTIFY_DATA_SIZE);
> +	BUILD_BUG_ON(sizeof(struct nvme_lba_range_type) != 64);
> +	BUILD_BUG_ON(sizeof(struct nvme_smart_log) != 512);
> +	BUILD_BUG_ON(sizeof(struct nvme_dbbuf) != 64);
> +	BUILD_BUG_ON(sizeof(struct nvme_directive_cmd) != 64);
> +}
> +
> +
>   int __init nvme_core_init(void)
>   {
>   	int result = -ENOMEM;
>   
> +	_nvme_check_size();
> +
>   	nvme_wq = alloc_workqueue("nvme-wq",
>   			WQ_UNBOUND | WQ_MEM_RECLAIM | WQ_SYSFS, 0);
>   	if (!nvme_wq)
> diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
> index 9b02c4576591..1c4da31a97c2 100644
> --- a/drivers/nvme/host/pci.c
> +++ b/drivers/nvme/host/pci.c
> @@ -226,33 +226,6 @@ struct nvme_iod {
>   	struct scatterlist *sg;
>   };
>   
> -/*
> - * Check we didin't inadvertently grow the command struct
> - */
> -static inline void _nvme_check_size(void)
> -{
> -	BUILD_BUG_ON(sizeof(struct nvme_common_command) != 64);
> -	BUILD_BUG_ON(sizeof(struct nvme_rw_command) != 64);
> -	BUILD_BUG_ON(sizeof(struct nvme_identify) != 64);
> -	BUILD_BUG_ON(sizeof(struct nvme_create_cq) != 64);
> -	BUILD_BUG_ON(sizeof(struct nvme_create_sq) != 64);
> -	BUILD_BUG_ON(sizeof(struct nvme_delete_queue) != 64);
> -	BUILD_BUG_ON(sizeof(struct nvme_features) != 64);
> -	BUILD_BUG_ON(sizeof(struct nvme_download_firmware) != 64);
> -	BUILD_BUG_ON(sizeof(struct nvme_format_cmd) != 64);
> -	BUILD_BUG_ON(sizeof(struct nvme_dsm_cmd) != 64);
> -	BUILD_BUG_ON(sizeof(struct nvme_write_zeroes_cmd) != 64);
> -	BUILD_BUG_ON(sizeof(struct nvme_abort_cmd) != 64);
> -	BUILD_BUG_ON(sizeof(struct nvme_get_log_page_command) != 64);
> -	BUILD_BUG_ON(sizeof(struct nvme_command) != 64);
> -	BUILD_BUG_ON(sizeof(struct nvme_id_ctrl) != NVME_IDENTIFY_DATA_SIZE);
> -	BUILD_BUG_ON(sizeof(struct nvme_id_ns) != NVME_IDENTIFY_DATA_SIZE);
> -	BUILD_BUG_ON(sizeof(struct nvme_lba_range_type) != 64);
> -	BUILD_BUG_ON(sizeof(struct nvme_smart_log) != 512);
> -	BUILD_BUG_ON(sizeof(struct nvme_dbbuf) != 64);
> -	BUILD_BUG_ON(sizeof(struct nvme_directive_cmd) != 64);
> -}
> -
>   static unsigned int max_io_queues(void)
>   {
>   	return num_possible_cpus() + write_queues + poll_queues;
> @@ -2981,6 +2954,9 @@ static struct pci_driver nvme_driver = {
>   
>   static int __init nvme_init(void)
>   {
> +	BUILD_BUG_ON(sizeof(struct nvme_create_cq) != 64);
> +	BUILD_BUG_ON(sizeof(struct nvme_create_sq) != 64);
> +	BUILD_BUG_ON(sizeof(struct nvme_delete_queue) != 64);
>   	BUILD_BUG_ON(IRQ_AFFINITY_MAX_SETS < 2);
>   	return pci_register_driver(&nvme_driver);
>   }
> @@ -2989,7 +2965,6 @@ static void __exit nvme_exit(void)
>   {
>   	pci_unregister_driver(&nvme_driver);
>   	flush_workqueue(nvme_wq);
> -	_nvme_check_size();
>   }
>   
>   MODULE_AUTHOR("Matthew Wilcox <willy at linux.intel.com>");
> 

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

* [PATCH 2/2] nvme: mark nvme_core_init and nvme_core_exit static
  2019-04-30 15:38 ` [PATCH 2/2] nvme: mark nvme_core_init and nvme_core_exit static Christoph Hellwig
  2019-04-30 15:52   ` Keith Busch
  2019-04-30 16:57   ` Bart Van Assche
@ 2019-04-30 21:30   ` Chaitanya Kulkarni
  2 siblings, 0 replies; 9+ messages in thread
From: Chaitanya Kulkarni @ 2019-04-30 21:30 UTC (permalink / raw)


Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>

On 4/30/19 8:39 AM, Christoph Hellwig wrote:
> Signed-off-by: Christoph Hellwig <hch at lst.de>
> ---
>   drivers/nvme/host/core.c | 4 ++--
>   drivers/nvme/host/nvme.h | 3 ---
>   2 files changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index e970c5adee28..cd16d98d1f1a 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -3904,7 +3904,7 @@ static inline void _nvme_check_size(void)
>   }
>   
>   
> -int __init nvme_core_init(void)
> +static int __init nvme_core_init(void)
>   {
>   	int result = -ENOMEM;
>   
> @@ -3956,7 +3956,7 @@ int __init nvme_core_init(void)
>   	return result;
>   }
>   
> -void __exit nvme_core_exit(void)
> +static void __exit nvme_core_exit(void)
>   {
>   	ida_destroy(&nvme_subsystems_ida);
>   	class_destroy(nvme_subsys_class);
> diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
> index 527d64545023..5ee75b5ff83f 100644
> --- a/drivers/nvme/host/nvme.h
> +++ b/drivers/nvme/host/nvme.h
> @@ -577,7 +577,4 @@ static inline struct nvme_ns *nvme_get_ns_from_dev(struct device *dev)
>   	return dev_to_disk(dev)->private_data;
>   }
>   
> -int __init nvme_core_init(void);
> -void __exit nvme_core_exit(void);
> -
>   #endif /* _NVME_H */
> 

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

* [PATCH 1/2] nvme: move command size checks to the core
  2019-04-30 21:30 ` Chaitanya Kulkarni
@ 2019-05-01 13:18   ` Christoph Hellwig
  0 siblings, 0 replies; 9+ messages in thread
From: Christoph Hellwig @ 2019-05-01 13:18 UTC (permalink / raw)


On Tue, Apr 30, 2019@09:30:26PM +0000, Chaitanya Kulkarni wrote:
> Looks good. Just one question about _nvme_check_size(), is there any 
> significance for one _ over __ ?

None.  I have just copied over what we had before.

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

end of thread, other threads:[~2019-05-01 13:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-30 15:38 [PATCH 1/2] nvme: move command size checks to the core Christoph Hellwig
2019-04-30 15:38 ` [PATCH 2/2] nvme: mark nvme_core_init and nvme_core_exit static Christoph Hellwig
2019-04-30 15:52   ` Keith Busch
2019-04-30 16:57   ` Bart Van Assche
2019-04-30 21:30   ` Chaitanya Kulkarni
2019-04-30 15:51 ` [PATCH 1/2] nvme: move command size checks to the core Keith Busch
2019-04-30 16:58 ` Bart Van Assche
2019-04-30 21:30 ` Chaitanya Kulkarni
2019-05-01 13:18   ` 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.