From: Christoph Hellwig <hch@lst.de>
To: Linus Torvalds <torvalds@linux-foundation.org>,
Jens Axboe <axboe@fb.com>
Cc: Keith Busch <kbusch@kernel.org>, Sagi Grimberg <sagi@grimberg.me>,
Hugh Dickins <hughd@google.com>,
linux-nvme@lists.infradead.org
Subject: [PATCH 4/4] nvme-pci: remove the dev->q_depth field
Date: Sun, 25 Dec 2022 11:32:34 +0100 [thread overview]
Message-ID: <20221225103234.226794-5-hch@lst.de> (raw)
In-Reply-To: <20221225103234.226794-1-hch@lst.de>
This field duplicates the sqsize field in the common nvme_ctrl structure,
so remove it and use the common field instead.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/nvme/host/pci.c | 30 +++++++++++++-----------------
1 file changed, 13 insertions(+), 17 deletions(-)
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index a621dd7a0a8efa..59ef702f910efa 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -126,7 +126,6 @@ struct nvme_dev {
unsigned max_qid;
unsigned io_queues[HCTX_MAX_TYPES];
unsigned int num_vecs;
- u32 q_depth;
int io_sqes;
u32 db_stride;
void __iomem *bar;
@@ -1515,7 +1514,7 @@ static void nvme_reap_pending_cqes(struct nvme_dev *dev)
static int nvme_cmb_qdepth(struct nvme_dev *dev, int nr_io_queues,
int entry_size)
{
- int q_depth = dev->q_depth;
+ u16 q_depth = dev->ctrl.sqsize;
unsigned q_size_aligned = roundup(q_depth * entry_size,
NVME_CTRL_PAGE_SIZE);
@@ -1824,7 +1823,7 @@ static int nvme_create_io_queues(struct nvme_dev *dev)
int ret = 0;
for (i = dev->ctrl.queue_count; i <= dev->max_qid; i++) {
- if (nvme_alloc_queue(dev, i, dev->q_depth)) {
+ if (nvme_alloc_queue(dev, i, dev->ctrl.sqsize)) {
ret = -ENOMEM;
break;
}
@@ -2333,12 +2332,10 @@ static int nvme_setup_io_queues(struct nvme_dev *dev)
if (dev->cmb_use_sqes) {
result = nvme_cmb_qdepth(dev, nr_io_queues,
sizeof(struct nvme_command));
- if (result > 0) {
- dev->q_depth = result;
+ if (result > 0)
dev->ctrl.sqsize = result;
- } else {
+ else
dev->cmb_use_sqes = false;
- }
}
do {
@@ -2537,8 +2534,8 @@ 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(u32, NVME_CAP_MQES(dev->ctrl.cap) + 1,
- io_queue_depth);
+ dev->ctrl.sqsize = min_t(u32, NVME_CAP_MQES(dev->ctrl.cap) + 1,
+ io_queue_depth);
dev->db_stride = 1 << NVME_CAP_STRIDE(dev->ctrl.cap);
dev->dbs = dev->bar + 4096;
@@ -2557,16 +2554,16 @@ static int nvme_pci_enable(struct nvme_dev *dev)
* some MacBook7,1 to avoid controller resets and data loss.
*/
if (pdev->vendor == PCI_VENDOR_ID_APPLE && pdev->device == 0x2001) {
- dev->q_depth = 2;
+ dev->ctrl.sqsize = 2;
dev_warn(dev->ctrl.device, "detected Apple NVMe controller, "
"set queue depth=%u to work around controller resets\n",
- dev->q_depth);
+ dev->ctrl.sqsize);
} else if (pdev->vendor == PCI_VENDOR_ID_SAMSUNG &&
(pdev->device == 0xa821 || pdev->device == 0xa822) &&
NVME_CAP_MQES(dev->ctrl.cap) == 0) {
- dev->q_depth = 64;
+ dev->ctrl.sqsize = 64;
dev_err(dev->ctrl.device, "detected PM1725 NVMe controller, "
- "set queue depth=%u\n", dev->q_depth);
+ "set queue depth=%u\n", dev->ctrl.sqsize);
}
/*
@@ -2574,12 +2571,11 @@ static int nvme_pci_enable(struct nvme_dev *dev)
* big enough so that we get 32 tags for the admin queue
*/
if ((dev->ctrl.quirks & NVME_QUIRK_SHARED_TAGS) &&
- (dev->q_depth < (NVME_AQ_DEPTH + 2))) {
- dev->q_depth = NVME_AQ_DEPTH + 2;
+ (dev->ctrl.sqsize < NVME_AQ_DEPTH + 2)) {
+ dev->ctrl.sqsize = NVME_AQ_DEPTH + 2;
dev_warn(dev->ctrl.device, "IO queue depth clamped to %d\n",
- dev->q_depth);
+ dev->ctrl.sqsize);
}
- dev->ctrl.sqsize = dev->q_depth;
nvme_map_cmb(dev);
--
2.35.1
next prev parent reply other threads:[~2022-12-25 11:14 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-25 10:32 fix nvme sqsize on off regression Christoph Hellwig
2022-12-25 10:32 ` [PATCH 1/4] nvme: fix setting the queue depth in nvme_alloc_io_tag_set Christoph Hellwig
2022-12-25 10:51 ` Sagi Grimberg
2022-12-25 10:53 ` Sagi Grimberg
2022-12-28 16:11 ` Christoph Hellwig
2022-12-25 21:15 ` Hugh Dickins
2022-12-25 10:32 ` [PATCH 2/4] nvme-pci: update sqsize when adjusting the queue depth Christoph Hellwig
2022-12-25 11:19 ` Sagi Grimberg
2022-12-28 16:10 ` Christoph Hellwig
2022-12-29 12:07 ` Sagi Grimberg
2022-12-29 16:34 ` Keith Busch
2023-01-02 9:39 ` Sagi Grimberg
2023-01-03 16:45 ` Keith Busch
2022-12-25 21:21 ` Hugh Dickins
2022-12-25 10:32 ` [PATCH 3/4] nvme: store the actual queue size in ctrl->sqsize Christoph Hellwig
2022-12-25 11:09 ` Sagi Grimberg
2022-12-28 17:02 ` Keith Busch
2022-12-25 10:32 ` Christoph Hellwig [this message]
2022-12-25 11:19 ` [PATCH 4/4] nvme-pci: remove the dev->q_depth field Sagi Grimberg
2022-12-26 19:11 ` (subset) fix nvme sqsize on off regression Jens Axboe
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=20221225103234.226794-5-hch@lst.de \
--to=hch@lst.de \
--cc=axboe@fb.com \
--cc=hughd@google.com \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
--cc=torvalds@linux-foundation.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