qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Subject: [PULL 21/43] hw/block/nvme: factor out pci setup
Date: Wed, 17 Jun 2020 16:48:47 +0200	[thread overview]
Message-ID: <20200617144909.192176-22-kwolf@redhat.com> (raw)
In-Reply-To: <20200617144909.192176-1-kwolf@redhat.com>

From: Klaus Jensen <k.jensen@samsung.com>

Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Message-Id: <20200609190333.59390-16-its@irrelevant.dk>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 hw/block/nvme.c | 30 ++++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index c98af03f44..a4022b0291 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -1438,6 +1438,22 @@ static void nvme_init_namespace(NvmeCtrl *n, NvmeNamespace *ns, Error **errp)
     id_ns->nuse = id_ns->ncap;
 }
 
+static void nvme_init_pci(NvmeCtrl *n, PCIDevice *pci_dev)
+{
+    uint8_t *pci_conf = pci_dev->config;
+
+    pci_conf[PCI_INTERRUPT_PIN] = 1;
+    pci_config_set_prog_interface(pci_conf, 0x2);
+    pci_config_set_class(pci_conf, PCI_CLASS_STORAGE_EXPRESS);
+    pcie_endpoint_cap_init(pci_dev, 0x80);
+
+    memory_region_init_io(&n->iomem, OBJECT(n), &nvme_mmio_ops, n, "nvme",
+                          n->reg_size);
+    pci_register_bar(pci_dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY |
+                     PCI_BASE_ADDRESS_MEM_TYPE_64, &n->iomem);
+    msix_init_exclusive_bar(pci_dev, n->params.max_ioqpairs + 1, 4, NULL);
+}
+
 static void nvme_realize(PCIDevice *pci_dev, Error **errp)
 {
     NvmeCtrl *n = NVME(pci_dev);
@@ -1461,19 +1477,9 @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp)
         return;
     }
 
-    pci_conf = pci_dev->config;
-    pci_conf[PCI_INTERRUPT_PIN] = 1;
-    pci_config_set_prog_interface(pci_dev->config, 0x2);
-    pci_config_set_class(pci_dev->config, PCI_CLASS_STORAGE_EXPRESS);
-    pcie_endpoint_cap_init(pci_dev, 0x80);
-
-    memory_region_init_io(&n->iomem, OBJECT(n), &nvme_mmio_ops, n,
-                          "nvme", n->reg_size);
-    pci_register_bar(pci_dev, 0,
-        PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_64,
-        &n->iomem);
-    msix_init_exclusive_bar(pci_dev, n->params.max_ioqpairs + 1, 4, NULL);
+    nvme_init_pci(n, pci_dev);
 
+    pci_conf = pci_dev->config;
     id->vid = cpu_to_le16(pci_get_word(pci_conf + PCI_VENDOR_ID));
     id->ssvid = cpu_to_le16(pci_get_word(pci_conf + PCI_SUBSYSTEM_VENDOR_ID));
     strpadcpy((char *)id->mn, sizeof(id->mn), "QEMU NVMe Ctrl", ' ');
-- 
2.25.4



  parent reply	other threads:[~2020-06-17 14:58 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-17 14:48 [PULL 00/43] Block layer patches Kevin Wolf
2020-06-17 14:48 ` [PULL 01/43] hw/ide: Make IDEDMAOps handlers take a const IDEDMA pointer Kevin Wolf
2020-06-17 14:48 ` [PULL 02/43] icount: make dma reads deterministic Kevin Wolf
2020-06-17 14:48 ` [PULL 03/43] virtio-blk: Refactor the code that processes queued requests Kevin Wolf
2020-06-17 14:48 ` [PULL 04/43] virtio-blk: On restart, process queued requests in the proper context Kevin Wolf
2020-06-17 14:48 ` [PULL 05/43] block: Refactor subdirectory recursion during make Kevin Wolf
2020-06-17 14:48 ` [PULL 06/43] qcow2: Tweak comments on qcow2_get_persistent_dirty_bitmap_size Kevin Wolf
2020-06-17 14:48 ` [PULL 07/43] hw/block/nvme: fix pci doorbell size calculation Kevin Wolf
2020-06-17 14:48 ` [PULL 08/43] hw/block/nvme: rename trace events to pci_nvme Kevin Wolf
2020-06-17 14:48 ` [PULL 09/43] hw/block/nvme: remove superfluous breaks Kevin Wolf
2020-06-17 14:48 ` [PULL 10/43] hw/block/nvme: move device parameters to separate struct Kevin Wolf
2020-06-17 14:48 ` [PULL 11/43] hw/block/nvme: use constants in identify Kevin Wolf
2020-06-17 14:48 ` [PULL 12/43] hw/block/nvme: refactor nvme_addr_read Kevin Wolf
2020-06-17 14:48 ` [PULL 13/43] hw/block/nvme: fix pin-based interrupt behavior Kevin Wolf
2020-06-17 14:48 ` [PULL 14/43] hw/block/nvme: add max_ioqpairs device parameter Kevin Wolf
2020-06-17 14:48 ` [PULL 15/43] hw/block/nvme: remove redundant cmbloc/cmbsz members Kevin Wolf
2020-06-17 14:48 ` [PULL 16/43] hw/block/nvme: factor out property/constraint checks Kevin Wolf
2020-06-17 14:48 ` [PULL 17/43] hw/block/nvme: factor out device state setup Kevin Wolf
2020-06-17 14:48 ` [PULL 18/43] hw/block/nvme: factor out block backend setup Kevin Wolf
2020-06-17 14:48 ` [PULL 19/43] hw/block/nvme: add namespace helpers Kevin Wolf
2020-06-17 14:48 ` [PULL 20/43] hw/block/nvme: factor out namespace setup Kevin Wolf
2020-06-17 14:48 ` Kevin Wolf [this message]
2020-06-17 14:48 ` [PULL 22/43] hw/block/nvme: factor out cmb setup Kevin Wolf
2020-06-17 14:48 ` [PULL 23/43] hw/block/nvme: factor out pmr setup Kevin Wolf
2020-06-17 14:48 ` [PULL 24/43] hw/block/nvme: do cmb/pmr init as part of pci init Kevin Wolf
2020-06-17 14:48 ` [PULL 25/43] hw/block/nvme: factor out controller identify setup Kevin Wolf
2020-06-17 14:48 ` [PULL 26/43] hw/block/nvme: Verify msix_vector_use() returned value Kevin Wolf
2020-06-17 14:48 ` [PULL 27/43] hw/block/nvme: add msix_qsize parameter Kevin Wolf
2020-06-17 14:48 ` [PULL 28/43] hw/block/nvme: verify msix_init_exclusive_bar() return value Kevin Wolf
2020-06-17 14:48 ` [PULL 29/43] .gitignore: Ignore storage-daemon files Kevin Wolf
2020-06-17 14:48 ` [PULL 30/43] virtio-blk: store opt_io_size with correct size Kevin Wolf
2020-06-17 14:48 ` [PULL 31/43] block: consolidate blocksize properties consistency checks Kevin Wolf
2020-06-17 14:48 ` [PULL 32/43] qdev-properties: blocksize: use same limits in code and description Kevin Wolf
2020-06-17 14:48 ` [PULL 33/43] qdev-properties: add size32 property type Kevin Wolf
2020-06-17 14:49 ` [PULL 34/43] qdev-properties: make blocksize accept size suffixes Kevin Wolf
2020-06-17 14:49 ` [PULL 35/43] block: make BlockConf size props 32bit and " Kevin Wolf
2020-06-17 14:49 ` [PULL 36/43] qdev-properties: add getter for size32 and blocksize Kevin Wolf
2020-06-17 14:49 ` [PULL 37/43] block: lift blocksize property limit to 2 MiB Kevin Wolf
2020-06-17 14:49 ` [PULL 38/43] iotests.py: Add skip_for_formats() decorator Kevin Wolf
2020-06-17 14:49 ` [PULL 39/43] iotests/041: Skip test_small_target for qed Kevin Wolf
2020-06-17 14:49 ` [PULL 40/43] iotests/292: data_file is unsupported Kevin Wolf
2020-06-17 14:49 ` [PULL 41/43] iotests/229: " Kevin Wolf
2020-06-17 14:49 ` [PULL 42/43] iotests/{190,291}: compat=0.10 " Kevin Wolf
2020-06-17 14:49 ` [PULL 43/43] iotests: Add copyright line in qcow2.py Kevin Wolf
2020-06-17 15:48 ` [PULL 00/43] Block layer patches no-reply
2020-06-18 14:30 ` Peter Maydell
2020-06-25  8:39   ` Klaus Jensen
2020-06-25 10:39     ` Kevin Wolf

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=20200617144909.192176-22-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).