From: Roger Pau Monne <roger.pau@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
julien.grall@arm.com, Jan Beulich <jbeulich@suse.com>,
boris.ostrovsky@oracle.com,
Roger Pau Monne <roger.pau@citrix.com>
Subject: [PATCH v3 7/9] vpci: add a priority field to the vPCI register initializer
Date: Thu, 27 Apr 2017 15:35:44 +0100 [thread overview]
Message-ID: <20170427143546.14662-8-roger.pau@citrix.com> (raw)
In-Reply-To: <20170427143546.14662-1-roger.pau@citrix.com>
And mark the capability and header vPCI register initializers as high priority,
so that they are initialized first.
This is needed for MSI-X, since MSI-X needs to know the position of the BARs in
order to perform it's initialization, and in order to mask or enable the
MSI/MSI-X functionality on demand.
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
---
tools/tests/vpci/Makefile | 4 ++--
xen/drivers/vpci/capabilities.c | 2 +-
| 2 +-
xen/drivers/vpci/vpci.c | 14 ++++++++++++--
xen/include/xen/vpci.h | 13 +++++++++++--
5 files changed, 27 insertions(+), 8 deletions(-)
diff --git a/tools/tests/vpci/Makefile b/tools/tests/vpci/Makefile
index 7969fcbd82..e5edc4f512 100644
--- a/tools/tests/vpci/Makefile
+++ b/tools/tests/vpci/Makefile
@@ -31,8 +31,8 @@ vpci.c: $(XEN_ROOT)/xen/drivers/vpci/vpci.c
# Trick the compiler so it doesn't complain about missing symbols
sed -e '/#include/d' \
-e '1s;^;#include "emul.h"\
- const vpci_register_init_t __start_vpci_array[1]\;\
- const vpci_register_init_t __end_vpci_array[1]\;\
+ const struct vpci_register_init __start_vpci_array[1]\;\
+ const struct vpci_register_init __end_vpci_array[1]\;\
;' <$< >$@
rbtree.h: $(XEN_ROOT)/xen/include/xen/rbtree.h
diff --git a/xen/drivers/vpci/capabilities.c b/xen/drivers/vpci/capabilities.c
index b2a3326aa7..204355e673 100644
--- a/xen/drivers/vpci/capabilities.c
+++ b/xen/drivers/vpci/capabilities.c
@@ -145,7 +145,7 @@ static int vpci_capabilities_init(struct pci_dev *pdev)
return 0;
}
-REGISTER_VPCI_INIT(vpci_capabilities_init);
+REGISTER_VPCI_INIT(vpci_capabilities_init, true);
/*
* Local variables:
--git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c
index a401cf6915..3deec53efd 100644
--- a/xen/drivers/vpci/header.c
+++ b/xen/drivers/vpci/header.c
@@ -278,7 +278,7 @@ static int vpci_init_bars(struct pci_dev *pdev)
return 0;
}
-REGISTER_VPCI_INIT(vpci_init_bars);
+REGISTER_VPCI_INIT(vpci_init_bars, true);
/*
* Local variables:
diff --git a/xen/drivers/vpci/vpci.c b/xen/drivers/vpci/vpci.c
index b159f0db80..e6154b742e 100644
--- a/xen/drivers/vpci/vpci.c
+++ b/xen/drivers/vpci/vpci.c
@@ -20,7 +20,7 @@
#include <xen/sched.h>
#include <xen/vpci.h>
-extern const vpci_register_init_t __start_vpci_array[], __end_vpci_array[];
+extern const struct vpci_register_init __start_vpci_array[], __end_vpci_array[];
#define NUM_VPCI_INIT (__end_vpci_array - __start_vpci_array)
#define vpci_init __start_vpci_array
@@ -37,6 +37,7 @@ struct vpci_register {
int xen_vpci_add_handlers(struct pci_dev *pdev)
{
int i, rc = 0;
+ bool priority = true;
if ( !has_vpci(pdev->domain) )
return 0;
@@ -47,9 +48,13 @@ int xen_vpci_add_handlers(struct pci_dev *pdev)
pdev->vpci->handlers = RB_ROOT;
+ again:
for ( i = 0; i < NUM_VPCI_INIT; i++ )
{
- rc = vpci_init[i](pdev);
+ if ( priority != vpci_init[i].priority )
+ continue;
+
+ rc = vpci_init[i].init(pdev);
if ( rc )
break;
}
@@ -69,6 +74,11 @@ int xen_vpci_add_handlers(struct pci_dev *pdev)
}
xfree(pdev->vpci);
}
+ else if ( priority )
+ {
+ priority = false;
+ goto again;
+ }
return rc;
}
diff --git a/xen/include/xen/vpci.h b/xen/include/xen/vpci.h
index d41277f39b..2bf61d6c15 100644
--- a/xen/include/xen/vpci.h
+++ b/xen/include/xen/vpci.h
@@ -29,8 +29,17 @@ typedef int (*vpci_write_t)(struct pci_dev *pdev, unsigned int reg,
typedef int (*vpci_register_init_t)(struct pci_dev *dev);
-#define REGISTER_VPCI_INIT(x) \
- static const vpci_register_init_t x##_entry __used_section(".data.vpci") = x
+struct vpci_register_init {
+ vpci_register_init_t init;
+ bool priority;
+};
+
+#define REGISTER_VPCI_INIT(f, p) \
+ static const struct vpci_register_init \
+ x##_entry __used_section(".data.vpci") = { \
+ .init = f, \
+ .priority = p, \
+}
/* Add vPCI handlers to device. */
int xen_vpci_add_handlers(struct pci_dev *dev);
--
2.11.0 (Apple Git-81)
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-04-27 14:45 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-27 14:35 [PATCH v3 0/9] vpci: PCI config space emulation Roger Pau Monne
2017-04-27 14:35 ` [PATCH v3 1/9] xen/vpci: introduce basic handlers to trap accesses to the PCI config space Roger Pau Monne
2017-05-19 11:35 ` Jan Beulich
2017-05-29 12:57 ` Roger Pau Monne
2017-05-29 14:16 ` Jan Beulich
2017-05-29 15:05 ` Roger Pau Monne
2017-05-29 15:26 ` Jan Beulich
2017-04-27 14:35 ` [PATCH v3 2/9] x86/ecam: add handlers for the PVH Dom0 MMCFG areas Roger Pau Monne
2017-05-19 13:25 ` Jan Beulich
2017-06-20 11:56 ` Roger Pau Monne
2017-06-20 13:14 ` Jan Beulich
2017-06-20 15:04 ` Roger Pau Monne
2017-04-27 14:35 ` [PATCH v3 3/9] xen/mm: move modify_identity_mmio to global file and drop __init Roger Pau Monne
2017-05-19 13:35 ` Jan Beulich
2017-06-21 11:11 ` Roger Pau Monne
2017-06-21 11:57 ` Jan Beulich
2017-06-21 12:43 ` Roger Pau Monne
2017-06-21 12:51 ` Jan Beulich
2017-06-21 13:10 ` Roger Pau Monne
2017-06-21 13:29 ` Jan Beulich
2017-04-27 14:35 ` [PATCH v3 4/9] xen/pci: split code to size BARs from pci_add_device Roger Pau Monne
2017-05-19 13:56 ` Jan Beulich
2017-06-21 15:16 ` Roger Pau Monne
2017-04-27 14:35 ` [PATCH v3 5/9] xen/vpci: add handlers to map the BARs Roger Pau Monne
2017-05-19 15:21 ` Jan Beulich
2017-05-22 11:38 ` Julien Grall
2017-06-22 17:13 ` Roger Pau Monne
2017-06-23 8:58 ` Jan Beulich
2017-06-23 10:55 ` Roger Pau Monne
2017-04-27 14:35 ` [PATCH v3 6/9] xen/vpci: trap access to the list of PCI capabilities Roger Pau Monne
2017-05-23 12:49 ` Jan Beulich
2017-06-26 11:50 ` Roger Pau Monne
2017-06-27 6:44 ` Jan Beulich
2017-05-29 13:32 ` Jan Beulich
2017-04-27 14:35 ` Roger Pau Monne [this message]
2017-05-23 12:52 ` [PATCH v3 7/9] vpci: add a priority field to the vPCI register initializer Jan Beulich
2017-06-26 14:41 ` Roger Pau Monne
2017-04-27 14:35 ` [PATCH v3 8/9] vpci/msi: add MSI handlers Roger Pau Monne
2017-05-26 15:26 ` Jan Beulich
2017-06-27 10:22 ` Roger Pau Monne
2017-06-27 11:44 ` Jan Beulich
2017-06-27 12:44 ` Roger Pau Monné
2017-04-27 14:35 ` [PATCH v3 9/9] vpci/msix: add MSI-X handlers Roger Pau Monne
2017-05-29 13:29 ` Jan Beulich
2017-06-28 15:29 ` Roger Pau Monne
2017-06-29 6:19 ` Jan Beulich
2017-06-29 8:25 ` Roger Pau Monné
2017-05-29 13:38 ` [PATCH v3 0/9] vpci: PCI config space emulation Jan Beulich
2017-05-29 14:14 ` Roger Pau Monne
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=20170427143546.14662-8-roger.pau@citrix.com \
--to=roger.pau@citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=boris.ostrovsky@oracle.com \
--cc=jbeulich@suse.com \
--cc=julien.grall@arm.com \
--cc=xen-devel@lists.xenproject.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).