qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Cao jin <caoj.fnst@cn.fujitsu.com>
To: qemu-devel@nongnu.org
Cc: Alex Williamson <alex.williamson@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	Marcel Apfelbaum <marcel@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>
Subject: [Qemu-devel] [PATCH v10] msix: rename and create a wrapper
Date: Tue, 7 Mar 2017 16:27:37 +0800	[thread overview]
Message-ID: <1488875257-7870-1-git-send-email-caoj.fnst@cn.fujitsu.com> (raw)
In-Reply-To: <1488011202-32121-2-git-send-email-caoj.fnst@cn.fujitsu.com>

Rename msix_init to msix_validate_and_init which doesn't assert;
New a wrapper msix_init to assert programming error.

CC: Alex Williamson <alex.williamson@redhat.com>
CC: Markus Armbruster <armbru@redhat.com>
CC: Marcel Apfelbaum <marcel@redhat.com>
CC: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
---
revert the modification in msix_init_exclusive_bar()

 hw/pci/msix.c         | 23 ++++++++++++++++++-----
 hw/vfio/pci.c         | 12 ++++++------
 include/hw/pci/msix.h |  5 +++++
 3 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/hw/pci/msix.c b/hw/pci/msix.c
index bb54e8b0ac37..02697de32dfc 100644
--- a/hw/pci/msix.c
+++ b/hw/pci/msix.c
@@ -239,6 +239,19 @@ static void msix_mask_all(struct PCIDevice *dev, unsigned nentries)
     }
 }
 
+/* Just a wrapper to check the return value */
+int msix_init(struct PCIDevice *dev, unsigned short nentries,
+              MemoryRegion *table_bar, uint8_t table_bar_nr,
+              unsigned table_offset, MemoryRegion *pba_bar,
+              uint8_t pba_bar_nr, unsigned pba_offset, uint8_t cap_pos,
+              Error **errp)
+{
+    int ret = msix_validate_and_init(dev, nentries, table_bar, table_bar_nr,
+            table_offset, pba_bar, pba_bar_nr, pba_offset, cap_pos, errp);
+
+    assert(ret != -EINVAL);
+    return ret;
+}
 /*
  * Make PCI device @dev MSI-X capable
  * @nentries is the max number of MSI-X vectors that the device support.
@@ -259,11 +272,11 @@ static void msix_mask_all(struct PCIDevice *dev, unsigned nentries)
  * also means a programming error, except device assignment, which can check
  * if a real HW is broken.
  */
-int msix_init(struct PCIDevice *dev, unsigned short nentries,
-              MemoryRegion *table_bar, uint8_t table_bar_nr,
-              unsigned table_offset, MemoryRegion *pba_bar,
-              uint8_t pba_bar_nr, unsigned pba_offset, uint8_t cap_pos,
-              Error **errp)
+int msix_validate_and_init(struct PCIDevice *dev, unsigned short nentries,
+                           MemoryRegion *table_bar, uint8_t table_bar_nr,
+                           unsigned table_offset, MemoryRegion *pba_bar,
+                           uint8_t pba_bar_nr, unsigned pba_offset,
+                           uint8_t cap_pos, Error **errp)
 {
     int cap;
     unsigned table_size, pba_size;
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 332f41d6627f..06828b537a75 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -1436,12 +1436,12 @@ static int vfio_msix_setup(VFIOPCIDevice *vdev, int pos, Error **errp)
 
     vdev->msix->pending = g_malloc0(BITS_TO_LONGS(vdev->msix->entries) *
                                     sizeof(unsigned long));
-    ret = msix_init(&vdev->pdev, vdev->msix->entries,
-                    vdev->bars[vdev->msix->table_bar].region.mem,
-                    vdev->msix->table_bar, vdev->msix->table_offset,
-                    vdev->bars[vdev->msix->pba_bar].region.mem,
-                    vdev->msix->pba_bar, vdev->msix->pba_offset, pos,
-                    &err);
+    ret = msix_validate_and_init(&vdev->pdev, vdev->msix->entries,
+                             vdev->bars[vdev->msix->table_bar].region.mem,
+                             vdev->msix->table_bar, vdev->msix->table_offset,
+                             vdev->bars[vdev->msix->pba_bar].region.mem,
+                             vdev->msix->pba_bar, vdev->msix->pba_offset, pos,
+                             &err);
     if (ret < 0) {
         if (ret == -ENOTSUP) {
             error_report_err(err);
diff --git a/include/hw/pci/msix.h b/include/hw/pci/msix.h
index 1f27658d352f..815e59bc96f3 100644
--- a/include/hw/pci/msix.h
+++ b/include/hw/pci/msix.h
@@ -11,6 +11,11 @@ int msix_init(PCIDevice *dev, unsigned short nentries,
               unsigned table_offset, MemoryRegion *pba_bar,
               uint8_t pba_bar_nr, unsigned pba_offset, uint8_t cap_pos,
               Error **errp);
+int msix_validate_and_init(PCIDevice *dev, unsigned short nentries,
+                           MemoryRegion *table_bar, uint8_t table_bar_nr,
+                           unsigned table_offset, MemoryRegion *pba_bar,
+                           uint8_t pba_bar_nr, unsigned pba_offset,
+                           uint8_t cap_pos, Error **errp);
 int msix_init_exclusive_bar(PCIDevice *dev, unsigned short nentries,
                             uint8_t bar_nr, Error **errp);
 
-- 
2.1.0

  parent reply	other threads:[~2017-03-07  8:19 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-25  8:26 [Qemu-devel] [PATCH v10 0/8] the reset of msix_init series Cao jin
2017-02-25  8:26 ` [Qemu-devel] [PATCH v10 1/8] msix: Rename and create a wrapper Cao jin
2017-03-07  7:44   ` Markus Armbruster
2017-03-07  8:08     ` Cao jin
2017-03-07  8:27   ` Cao jin [this message]
2017-03-07  8:33     ` [Qemu-devel] [PATCH v10] msix: rename " Markus Armbruster
2017-02-25  8:26 ` [Qemu-devel] [PATCH v10 2/8] megasas: change behaviour of msix switch Cao jin
2017-02-25  8:26 ` [Qemu-devel] [PATCH v10 3/8] hcd-xhci: " Cao jin
2017-02-25  8:26 ` [Qemu-devel] [PATCH v10 4/8] megasas: undo the overwrites of msi user configuration Cao jin
2017-02-25  8:26 ` [Qemu-devel] [PATCH v10 5/8] vmxnet3: fix reference leak issue Cao jin
2017-02-25  8:26 ` [Qemu-devel] [PATCH v10 6/8] vmxnet3: remove unnecessary internal msix flag Cao jin
2017-02-25  8:26 ` [Qemu-devel] [PATCH v10 7/8] msi_init: convert assert to return -errno Cao jin
2017-02-25  8:26 ` [Qemu-devel] [PATCH v10 8/8] megasas: remove unnecessary megasas_use_msix() Cao jin
2017-03-06  8:10 ` [Qemu-devel] [PATCH v10 0/8] the reset of msix_init series Cao jin
2017-03-06 15:10   ` Michael S. Tsirkin
2017-04-28  7:45   ` Cao jin

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=1488875257-7870-1-git-send-email-caoj.fnst@cn.fujitsu.com \
    --to=caoj.fnst@cn.fujitsu.com \
    --cc=alex.williamson@redhat.com \
    --cc=armbru@redhat.com \
    --cc=marcel@redhat.com \
    --cc=mst@redhat.com \
    --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).