nvme: move command size checks to the core
authorChristoph Hellwig <hch@lst.de>
Tue, 30 Apr 2019 15:36:52 +0000 (11:36 -0400)
committerChristoph Hellwig <hch@lst.de>
Wed, 1 May 2019 13:18:36 +0000 (09:18 -0400)
Most command aren't PCIe specific, so move the size checking for them
to core.c

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Keith Busch <keith.busch@intel.com>
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
drivers/nvme/host/core.c
drivers/nvme/host/pci.c

index 3dd043aa6d1f341e2bd1a7dc8409fc999627ea87..e970c5adee282a74495c9f40b2a664faeaffd752 100644 (file)
@@ -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)
index 9c1a8fd68b3a28294b97c4c05a12c8419f62abad..3e4fb891a95aa025907dd005fbc3aad627e9ef91 100644 (file)
@@ -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;
@@ -2988,6 +2961,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);
 }
@@ -2996,7 +2972,6 @@ static void __exit nvme_exit(void)
 {
        pci_unregister_driver(&nvme_driver);
        flush_workqueue(nvme_wq);
-       _nvme_check_size();
 }
 
 MODULE_AUTHOR("Matthew Wilcox <willy@linux.intel.com>");