From: helen.koike@collabora.com (Helen Koike)
Subject: [PATCH v7 RFC] nvme: improve performance for virtual NVMe devices
Date: Sat, 1 Apr 2017 18:50:03 -0300 [thread overview]
Message-ID: <b421e5a1-d60d-10b0-1d26-33a38298e01e@collabora.com> (raw)
In-Reply-To: <20170331070128.GA28852@infradead.org>
Hi Christoph,
Thanks for reviewing this patch
On 2017-03-31 04:01 AM, Christoph Hellwig wrote:
> I'd still prefer to not hide the MMIO path behind nvme_write_doorbell,
> but except for that this looks fine to me:
>
Do you mean wrapping the call to writel()? What do you think if I send a new
version with the changes below? It wouldn't hide the call to writel()
inside nvme_write_doorbell anymore.
Helen
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 3ce705a..0e5f2a1 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -277,8 +277,9 @@ static inline int nvme_dbbuf_need_event(u16
event_idx, u16 new_idx, u16 old)
return (u16)(new_idx - event_idx - 1) < (u16)(new_idx - old);
}
-static void nvme_write_doorbell(u16 value, u32 __iomem *db, u32 *dbbuf_db,
- volatile u32 *dbbuf_ei)
+/* Update dbbuf and return true if a MMIO is required */
+static bool nvme_dbbuf_update_and_check_event(u16 value, u32 *dbbuf_db,
+ volatile u32 *dbbuf_ei)
{
if (dbbuf_db) {
u16 old_value;
@@ -291,11 +292,12 @@ static void nvme_write_doorbell(u16 value, u32
__iomem *db, u32 *dbbuf_db,
old_value = *dbbuf_db;
*dbbuf_db = value;
+
if (!nvme_dbbuf_need_event(*dbbuf_ei, value, old_value))
- return;
+ return false;
}
- writel(value, db);
+ return true;
}
/*
@@ -422,8 +424,9 @@ static void __nvme_submit_cmd(struct nvme_queue *nvmeq,
if (++tail == nvmeq->q_depth)
tail = 0;
- nvme_write_doorbell(tail, nvmeq->q_db, nvmeq->dbbuf_sq_db,
- nvmeq->dbbuf_sq_ei);
+ if (nvme_dbbuf_update_and_check_event(tail, nvmeq->dbbuf_sq_db,
+ nvmeq->dbbuf_sq_ei))
+ writel(tail, nvmeq->q_db);
nvmeq->sq_tail = tail;
}
@@ -839,8 +842,9 @@ static void __nvme_process_cq(struct nvme_queue
*nvmeq, unsigned int *tag)
return;
if (likely(nvmeq->cq_vector >= 0))
- nvme_write_doorbell(head, nvmeq->q_db +
nvmeq->dev->db_stride,
- nvmeq->dbbuf_cq_db, nvmeq->dbbuf_cq_ei);
+ if (nvme_dbbuf_update_and_check_event(head,
nvmeq->dbbuf_cq_db,
+ nvmeq->dbbuf_cq_ei))
+ writel(head, nvmeq->q_db + nvmeq->dev->db_stride);
nvmeq->cq_head = head;
nvmeq->cq_phase = phase;
next prev parent reply other threads:[~2017-04-01 21:50 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-14 18:04 [PATCH v2 RFC] nvme: improve performance for virtual NVMe devices Helen Mae Koike Fornazier
2016-04-21 13:33 ` Helen Koike
2016-04-21 13:38 ` Christoph Hellwig
2016-04-21 18:11 ` Ming Lin
2016-04-27 15:26 ` Helen Koike
2016-05-03 8:05 ` Christoph Hellwig
2016-05-04 16:48 ` Helen Koike
2016-05-05 14:17 ` Christoph Hellwig
2016-05-11 16:50 ` Helen Koike
2016-05-11 17:43 ` Keith Busch
2016-05-12 4:05 ` Helen Koike
2016-05-12 7:05 ` Christoph Hellwig
[not found] ` <CALu-fzt8=kmzZDqKsRYE42Q+F+Zu3U_s6XErpd9izXdxG1cUMA@mail.gmail.com>
[not found] ` <CAPst7KAAymUqbNwzxNAczduF6iLXQAMm5-auEdXZ_zHwhHtbWQ@mail.gmail.com>
2016-05-12 17:29 ` Mike Waychison
2016-05-05 15:15 ` Helen Koike
2016-05-05 15:24 ` Helen Koike
2016-08-16 1:41 ` [PATCH v3 RFC 0/2] Virtual NVMe device optimization Helen Koike
2016-08-16 1:41 ` [PATCH v3 RFC 2/2] nvme: improve performance for virtual NVMe devices Helen Koike
2016-08-16 20:45 ` J Freyensee
2016-08-16 23:45 ` Keith Busch
2017-03-17 21:44 ` [PATCH v4 RFC] " Helen Koike
2017-03-17 22:28 ` Keith Busch
2017-03-17 22:26 ` Helen Koike
2017-03-24 4:23 ` [PATCH v5 " Helen Koike
2017-03-27 9:49 ` Christoph Hellwig
2017-03-27 16:04 ` Helen Koike
2017-03-27 16:25 ` Helen Koike
2017-03-27 14:43 ` Keith Busch
2017-03-27 16:50 ` [PATCH v6 " Helen Koike
2017-03-30 17:33 ` Keith Busch
2017-03-30 17:46 ` [PATCH v7 " Helen Koike
2017-03-31 7:01 ` Christoph Hellwig
2017-04-01 21:50 ` Helen Koike [this message]
2017-04-10 15:31 ` Helen Koike
2017-04-10 15:37 ` Christoph Hellwig
2017-04-10 15:51 ` [PATCH v8] " Helen Koike
2017-04-14 18:10 ` Helen Koike
2017-04-17 23:01 ` Keith Busch
2017-04-17 23:20 ` Helen Koike
2017-04-20 10:22 ` Sagi Grimberg
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=b421e5a1-d60d-10b0-1d26-33a38298e01e@collabora.com \
--to=helen.koike@collabora.com \
/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;
as well as URLs for NNTP newsgroup(s).