From: james_p_freyensee@linux.intel.com (J Freyensee)
Subject: [PATCH 05/18] nvme: use offset instead of a struct for registers
Date: Wed, 21 Oct 2015 13:28:49 -0700 [thread overview]
Message-ID: <1445459329.3307.46.camel@linux.intel.com> (raw)
In-Reply-To: <1444975128-8768-6-git-send-email-hch@lst.de>
On Fri, 2015-10-16@07:58 +0200, Christoph Hellwig wrote:
> This makes life easier for future non-PCI drivers where access to the
> registers might be more complicated. Note that Linux drivers are
> pretty evenly split between the two versions, and in fact the NVMe
> driver already uses offsets for the doorbells.
>
> Signed-off-by: Christoph Hellwig <hch at lst.de>
> Acked-by: Keith Busch <keith.busch at intel.com>
> ---
> drivers/nvme/host/nvme.h | 2 +-
> drivers/nvme/host/pci.c | 58 +++++++++++++++++++++++++-------------
> ----------
> drivers/nvme/host/scsi.c | 6 ++---
> include/linux/nvme.h | 27 +++++++++++-----------
> 4 files changed, 47 insertions(+), 46 deletions(-)
>
> diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
> index 706f678..370aa5b 100644
> --- a/drivers/nvme/host/nvme.h
> +++ b/drivers/nvme/host/nvme.h
> @@ -46,7 +46,7 @@ struct nvme_dev {
> u32 db_stride;
> u32 ctrl_config;
> struct msix_entry *entry;
> - struct nvme_bar __iomem *bar;
> + void __iomem *bar;
> struct list_head namespaces;
> struct kref kref;
> struct device *device;
> diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
> index cd731f5..6b0dcb6 100644
> --- a/drivers/nvme/host/pci.c
> +++ b/drivers/nvme/host/pci.c
> @@ -1307,7 +1307,7 @@ static void nvme_disable_queue(struct nvme_dev
> *dev, int qid)
>
> /* Don't tell the adapter to delete the admin queue.
> * Don't tell a removed adapter to delete IO queues. */
> - if (qid && readl(&dev->bar->csts) != -1) {
> + if (qid && readl(dev->bar + NVME_REG_CSTS) != -1) {
> adapter_delete_sq(dev, qid);
> adapter_delete_cq(dev, qid);
> }
> @@ -1460,7 +1460,7 @@ static int nvme_wait_ready(struct nvme_dev
> *dev, u64 cap, bool enabled)
>
> timeout = ((NVME_CAP_TIMEOUT(cap) + 1) * HZ / 2) + jiffies;
>
> - while ((readl(&dev->bar->csts) & NVME_CSTS_RDY) != bit) {
> + while ((readl(dev->bar + NVME_REG_CSTS) & NVME_CSTS_RDY) !=
> bit) {
> msleep(100);
> if (fatal_signal_pending(current))
> return -EINTR;
> @@ -1485,7 +1485,7 @@ static int nvme_disable_ctrl(struct nvme_dev
> *dev, u64 cap)
> {
> dev->ctrl_config &= ~NVME_CC_SHN_MASK;
> dev->ctrl_config &= ~NVME_CC_ENABLE;
> - writel(dev->ctrl_config, &dev->bar->cc);
> + writel(dev->ctrl_config, dev->bar + NVME_REG_CC);
>
> return nvme_wait_ready(dev, cap, false);
> }
> @@ -1494,7 +1494,7 @@ static int nvme_enable_ctrl(struct nvme_dev
> *dev, u64 cap)
> {
> dev->ctrl_config &= ~NVME_CC_SHN_MASK;
> dev->ctrl_config |= NVME_CC_ENABLE;
> - writel(dev->ctrl_config, &dev->bar->cc);
> + writel(dev->ctrl_config, dev->bar + NVME_REG_CC);
>
> return nvme_wait_ready(dev, cap, true);
> }
> @@ -1506,10 +1506,10 @@ static int nvme_shutdown_ctrl(struct nvme_dev
> *dev)
> dev->ctrl_config &= ~NVME_CC_SHN_MASK;
> dev->ctrl_config |= NVME_CC_SHN_NORMAL;
>
> - writel(dev->ctrl_config, &dev->bar->cc);
> + writel(dev->ctrl_config, dev->bar + NVME_REG_CC);
>
> timeout = SHUTDOWN_TIMEOUT + jiffies;
> - while ((readl(&dev->bar->csts) & NVME_CSTS_SHST_MASK) !=
> + while ((readl(dev->bar + NVME_REG_CSTS) &
> NVME_CSTS_SHST_MASK) !=
> NVME_CSTS_SH
> ST_CMPLT) {
> msleep(100);
> if (fatal_signal_pending(current))
> @@ -1584,7 +1584,7 @@ static int nvme_configure_admin_queue(struct
> nvme_dev *dev)
> {
> int result;
> u32 aqa;
> - u64 cap = readq(&dev->bar->cap);
> + u64 cap = readq(dev->bar + NVME_REG_CAP);
> struct nvme_queue *nvmeq;
> unsigned page_shift = PAGE_SHIFT;
> unsigned dev_page_min = NVME_CAP_MPSMIN(cap) + 12;
> @@ -1605,11 +1605,12 @@ static int nvme_configure_admin_queue(struct
> nvme_dev *dev)
> page_shift = dev_page_max;
> }
>
> - dev->subsystem = readl(&dev->bar->vs) >= NVME_VS(1, 1) ?
> + dev->subsystem = readl(dev->bar + NVME_REG_VS) >= NVME_VS(1,
> 1) ?
> NVME_CAP_NSSRC(cap)
> : 0;
>
> - if (dev->subsystem && (readl(&dev->bar->csts) &
> NVME_CSTS_NSSRO))
> - writel(NVME_CSTS_NSSRO, &dev->bar->csts);
> + if (dev->subsystem &&
> + (readl(dev->bar + NVME_REG_CSTS) & NVME_CSTS_NSSRO))
> + writel(NVME_CSTS_NSSRO, dev->bar + NVME_REG_CSTS);
>
> result = nvme_disable_ctrl(dev, cap);
> if (result < 0)
> @@ -1632,9 +1633,9 @@ static int nvme_configure_admin_queue(struct
> nvme_dev *dev)
> dev->ctrl_config |= NVME_CC_ARB_RR | NVME_CC_SHN_NONE;
> dev->ctrl_config |= NVME_CC_IOSQES | NVME_CC_IOCQES;
>
> - writel(aqa, &dev->bar->aqa);
> - writeq(nvmeq->sq_dma_addr, &dev->bar->asq);
> - writeq(nvmeq->cq_dma_addr, &dev->bar->acq);
> + writel(aqa, dev->bar + NVME_REG_AQA);
> + writeq(nvmeq->sq_dma_addr, dev->bar + NVME_REG_ASQ);
> + writeq(nvmeq->cq_dma_addr, dev->bar + NVME_REG_ACQ);
>
> result = nvme_enable_ctrl(dev, cap);
> if (result)
> @@ -1776,7 +1777,7 @@ static int nvme_subsys_reset(struct nvme_dev
> *dev)
> if (!dev->subsystem)
> return -ENOTTY;
>
> - writel(0x4E564D65, &dev->bar->nssr); /* "NVMe" */
> + writel(0x4E564D65, dev->bar + NVME_REG_NSSR); /* "NVMe" */
It would be nice if this value was a macro in a .h file as this is not
necessarily specific to PCIe.
next prev parent reply other threads:[~2015-10-21 20:28 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-16 5:58 nvme driver split V2 Christoph Hellwig
2015-10-16 5:58 ` [PATCH 01/18] nvme: add missing unmaps in nvme_queue_rq Christoph Hellwig
2015-10-20 10:04 ` Sagi Grimberg
2015-10-20 14:07 ` Busch, Keith
2015-10-16 5:58 ` [PATCH 02/18] nvme: move struct nvme_iod to pci.c Christoph Hellwig
2015-10-20 10:04 ` Sagi Grimberg
2015-10-16 5:58 ` [PATCH 03/18] nvme: split command submission helpers out of pci.c Christoph Hellwig
2015-10-20 10:07 ` Sagi Grimberg
2015-10-21 18:48 ` J Freyensee
2015-10-16 5:58 ` [PATCH 04/18] nvme: add a vendor field to struct nvme_dev Christoph Hellwig
2015-10-20 10:08 ` Sagi Grimberg
2015-10-21 18:58 ` J Freyensee
2015-10-21 19:10 ` Busch, Keith
2015-10-16 5:58 ` [PATCH 05/18] nvme: use offset instead of a struct for registers Christoph Hellwig
2015-10-16 17:30 ` Busch, Keith
2015-10-21 20:28 ` J Freyensee [this message]
2015-10-16 5:58 ` [PATCH 06/18] nvme: split a new struct nvme_ctrl out of struct nvme_dev Christoph Hellwig
2015-10-20 10:19 ` Sagi Grimberg
2015-10-20 10:26 ` Christoph Hellwig
2015-10-20 10:44 ` Sagi Grimberg
2015-10-20 11:30 ` Christoph Hellwig
2015-10-21 14:40 ` Sagi Grimberg
2015-10-21 21:23 ` J Freyensee
2015-10-21 22:51 ` Busch, Keith
2015-10-22 0:15 ` J Freyensee
2015-10-22 7:37 ` Christoph Hellwig
2015-10-16 5:58 ` [PATCH 07/18] nvme: simplify nvme_setup_prps calling convention Christoph Hellwig
2015-10-20 10:30 ` Sagi Grimberg
2015-10-16 5:58 ` [PATCH 08/18] nvme: refactor nvme_queue_rq Christoph Hellwig
2015-10-16 5:58 ` [PATCH 09/18] nvme: move nvme_error_status to common code Christoph Hellwig
2015-10-20 10:54 ` Sagi Grimberg
2015-10-16 5:58 ` [PATCH 10/18] nvme: move nvme_setup_flush and nvme_setup_rw " Christoph Hellwig
2015-10-20 11:01 ` Sagi Grimberg
2015-10-21 6:55 ` Christoph Hellwig
2015-10-21 14:41 ` Sagi Grimberg
2015-10-16 5:58 ` [PATCH 11/18] nvme: split __nvme_submit_sync_cmd Christoph Hellwig
2015-10-16 5:58 ` [PATCH 12/18] nvme: use the block layer for userspace passthrough metadata Christoph Hellwig
2015-10-16 20:04 ` Busch, Keith
2015-10-18 18:22 ` Christoph Hellwig
2015-10-16 5:58 ` [PATCH 13/18] nvme: move block_device_operations and ns/ctrl freeing to common code Christoph Hellwig
2015-10-16 5:58 ` [PATCH 14/18] nvme: add explicit quirk handling Christoph Hellwig
2015-10-16 5:58 ` [PATCH 15/18] nvme: add a common helper to read Identify Controller data Christoph Hellwig
2015-10-21 22:44 ` J Freyensee
2015-10-22 7:38 ` Christoph Hellwig
2015-10-16 5:58 ` [PATCH 16/18] nvme: move the call to nvme_init_identify earlier Christoph Hellwig
2015-10-16 5:58 ` [PATCH 17/18] nvme: move namespace scanning to common code Christoph Hellwig
2015-10-16 6:14 ` Ming Lin
2015-10-16 6:16 ` Christoph Hellwig
2015-10-21 23:27 ` J Freyensee
2015-10-22 7:39 ` Christoph Hellwig
2015-10-22 13:48 ` Busch, Keith
2015-10-22 16:30 ` Christoph Hellwig
2015-10-22 21:24 ` Busch, Keith
2015-10-23 5:41 ` Christoph Hellwig
2015-10-16 5:58 ` [PATCH 18/18] nvme: move chardev and sysfs interface " Christoph Hellwig
2015-10-22 0:11 ` J Freyensee
2015-10-22 7:45 ` Christoph Hellwig
2015-10-22 18:36 ` J Freyensee
2015-10-22 18:59 ` Jon Derrick
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=1445459329.3307.46.camel@linux.intel.com \
--to=james_p_freyensee@linux.intel.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).