Skip to contentSkip to conversation

nvme: move nvme_dsm_range size check to _nvme_check_size()

PATCH In review Guixin Liu 3 participants 4 messages Feb 23, 2024 – Mar 7, 2024 NVMe

lore
Share & tools
lore

Guixin Liu

author
#0 lore raw

PATCH 1/1 nvme: move nvme_dsm_range size check to _nvme_check_size()

Move nvme_dsm_range size check to _nvme_check_size(), and remove redundant same check.

---
 drivers/nvme/host/core.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/nvme/host/core.c +2 -5
index 5cdd22f591f9..848d4b896fec 100644
@@ -1800,9 +1800,6 @@ static void nvme_config_discard(struct nvme_ctrl *ctrl, struct gendisk *disk,
 		return;
 	}
 
-	BUILD_BUG_ON(PAGE_SIZE / sizeof(struct nvme_dsm_range) <
-			NVME_DSM_MAX_RANGES);
-
 	/*
 	 * If discard is already enabled, don't reset queue limits.
 	 *
@@ -4602,8 +4599,6 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,
 	ctrl->ka_cmd.common.opcode = nvme_admin_keep_alive;
 	ctrl->ka_last_check_time = jiffies;
 
-	BUILD_BUG_ON(NVME_DSM_MAX_RANGES * sizeof(struct nvme_dsm_range) >
-			PAGE_SIZE);
 	ctrl->discard_page = alloc_page(GFP_KERNEL);
 	if (!ctrl->discard_page) {
 		ret = -ENOMEM;
@@ -4823,6 +4818,8 @@ static inline void _nvme_check_size(void)
 	BUILD_BUG_ON(sizeof(struct nvme_dbbuf) != 64);
 	BUILD_BUG_ON(sizeof(struct nvme_directive_cmd) != 64);
 	BUILD_BUG_ON(sizeof(struct nvme_feat_host_behavior) != 512);
+	BUILD_BUG_ON(NVME_DSM_MAX_RANGES * sizeof(struct nvme_dsm_range) >
+			PAGE_SIZE);
 }
 
 
Signature · 1 line
2.43.0
author
#1 lore raw

Hi,

    Gentle ping...

Best Regards,

Guixin Liu

Quoted 40 lines · Guixin Liu

Move nvme_dsm_range size check to _nvme_check_size(), and remove redundant same check.

---
  drivers/nvme/host/core.c | 7 ++-----
  1 file changed, 2 insertions(+), 5 deletions(-)
drivers/nvme/host/core.c +2 -5
index 5cdd22f591f9..848d4b896fec 100644
@@ -1800,9 +1800,6 @@ static void nvme_config_discard(struct nvme_ctrl *ctrl, struct gendisk *disk,
  		return;
  	}
 
-	BUILD_BUG_ON(PAGE_SIZE / sizeof(struct nvme_dsm_range) <
-			NVME_DSM_MAX_RANGES);
-
  	/*
  	 * If discard is already enabled, don't reset queue limits.
  	 *
@@ -4602,8 +4599,6 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,
  	ctrl->ka_cmd.common.opcode = nvme_admin_keep_alive;
  	ctrl->ka_last_check_time = jiffies;
 
-	BUILD_BUG_ON(NVME_DSM_MAX_RANGES * sizeof(struct nvme_dsm_range) >
-			PAGE_SIZE);
  	ctrl->discard_page = alloc_page(GFP_KERNEL);
  	if (!ctrl->discard_page) {
  		ret = -ENOMEM;
@@ -4823,6 +4818,8 @@ static inline void _nvme_check_size(void)
  	BUILD_BUG_ON(sizeof(struct nvme_dbbuf) != 64);
  	BUILD_BUG_ON(sizeof(struct nvme_directive_cmd) != 64);
  	BUILD_BUG_ON(sizeof(struct nvme_feat_host_behavior) != 512);
+	BUILD_BUG_ON(NVME_DSM_MAX_RANGES * sizeof(struct nvme_dsm_range) >
+			PAGE_SIZE);
  }
 
 
#2 lore raw

This is not a check for a spec provided struct size, so it should not be grouped with them.

maintainer
#3 lore raw
Quoted 3 lines · Christoph Hellwig

This is not a check for a spec provided struct size, so it should not be grouped with them.

Agreed.