From: Tom Yan <tom.ty89@gmail.com>
To: linux-nvme@lists.infradead.org, hch@lst.de
Cc: Tom Yan <tom.ty89@gmail.com>
Subject: [PATCH 1/2] nvme: use UINT_MAX >> SECTOR_SHIFT for maximums in number of sectors
Date: Tue, 17 Aug 2021 02:11:01 +0800 [thread overview]
Message-ID: <20210816181102.4412-1-tom.ty89@gmail.com> (raw)
The block layer uses UINT_MAX for maximums in bytes.
Signed-off-by: Tom Yan <tom.ty89@gmail.com>
---
drivers/nvme/host/core.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index dfd9dec0c1f6..3a1bfb45da2a 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1640,7 +1640,7 @@ static void nvme_config_discard(struct gendisk *disk, struct nvme_ns *ns)
blk_queue_max_discard_segments(queue, ctrl->max_discard_segments);
if (ctrl->quirks & NVME_QUIRK_DEALLOCATE_ZEROES)
- blk_queue_max_write_zeroes_sectors(queue, UINT_MAX);
+ blk_queue_max_write_zeroes_sectors(queue, UINT_MAX >> SECTOR_SHIFT);
}
static bool nvme_ns_ids_valid(struct nvme_ns_ids *ids)
@@ -2762,7 +2762,7 @@ static inline u32 nvme_mps_to_sectors(struct nvme_ctrl *ctrl, u32 units)
u32 page_shift = NVME_CAP_MPSMIN(ctrl->cap) + 12, val;
if (check_shl_overflow(1U, units + page_shift - 9, &val))
- return UINT_MAX;
+ return UINT_MAX >> SECTOR_SHIFT;
return val;
}
@@ -2773,7 +2773,7 @@ static int nvme_init_non_mdts_limits(struct nvme_ctrl *ctrl)
int ret;
if (ctrl->oncs & NVME_CTRL_ONCS_DSM) {
- ctrl->max_discard_sectors = UINT_MAX;
+ ctrl->max_discard_sectors = UINT_MAX >> SECTOR_SHIFT;
ctrl->max_discard_segments = NVME_DSM_MAX_RANGES;
} else {
ctrl->max_discard_sectors = 0;
@@ -2883,7 +2883,7 @@ static int nvme_init_identify(struct nvme_ctrl *ctrl)
if (id->mdts)
max_hw_sectors = nvme_mps_to_sectors(ctrl, id->mdts);
else
- max_hw_sectors = UINT_MAX;
+ max_hw_sectors = UINT_MAX >> SECTOR_SHIFT;
ctrl->max_hw_sectors =
min_not_zero(ctrl->max_hw_sectors, max_hw_sectors);
--
2.32.0
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
next reply other threads:[~2021-08-16 18:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-16 18:11 Tom Yan [this message]
2021-08-16 18:11 ` [PATCH 2/2] nvme: round max_discard_sectors down against discard_granularity Tom Yan
2021-08-16 21:43 ` [PATCH 1/2] nvme: use UINT_MAX >> SECTOR_SHIFT for maximums in number of sectors Keith Busch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210816181102.4412-1-tom.ty89@gmail.com \
--to=tom.ty89@gmail.com \
--cc=hch@lst.de \
--cc=linux-nvme@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox