From: Wei Huang <wei@redhat.com>
To: kvmarm@lists.cs.columbia.edu
Cc: marc.zyngier@arm.com, christoffer.dall@linaro.org,
kvm@vger.kernel.org, hanjun.guo@linaro.org, fu.wei@linaro.org,
drjones@redhat.com, wei@redhat.com, al.stone@linaro.org
Subject: [PATCH V1 1/7] KVM: GIC: Move GIC DT probing code to GICv2 and GICv3 files
Date: Fri, 5 Feb 2016 12:07:28 -0500 [thread overview]
Message-ID: <1454692054-8984-2-git-send-email-wei@redhat.com> (raw)
In-Reply-To: <1454692054-8984-1-git-send-email-wei@redhat.com>
This patch moves GIC DT probing code from vgic.c to GICv2 & GICv3
sub-files. The probing will start from GICv2. If the probing fails,
KVM will try to probe GICv3 then.
Signed-off-by: Wei Huang <wei@redhat.com>
---
include/kvm/arm_vgic.h | 6 ++----
virt/kvm/arm/vgic-v2.c | 17 ++++++++++++++---
virt/kvm/arm/vgic-v3.c | 15 ++++++++++++---
virt/kvm/arm/vgic.c | 22 ++--------------------
4 files changed, 30 insertions(+), 30 deletions(-)
diff --git a/include/kvm/arm_vgic.h b/include/kvm/arm_vgic.h
index 13a3d53..59428d4 100644
--- a/include/kvm/arm_vgic.h
+++ b/include/kvm/arm_vgic.h
@@ -357,12 +357,10 @@ bool kvm_vgic_map_is_active(struct kvm_vcpu *vcpu, struct irq_phys_map *map);
#define vgic_initialized(k) (!!((k)->arch.vgic.nr_cpus))
#define vgic_ready(k) ((k)->arch.vgic.ready)
-int vgic_v2_probe(struct device_node *vgic_node,
- const struct vgic_ops **ops,
+int vgic_v2_probe(const struct vgic_ops **ops,
const struct vgic_params **params);
#ifdef CONFIG_KVM_ARM_VGIC_V3
-int vgic_v3_probe(struct device_node *vgic_node,
- const struct vgic_ops **ops,
+int vgic_v3_probe(const struct vgic_ops **ops,
const struct vgic_params **params);
#else
static inline int vgic_v3_probe(struct device_node *vgic_node,
diff --git a/virt/kvm/arm/vgic-v2.c b/virt/kvm/arm/vgic-v2.c
index ff02f08..dc9ceab 100644
--- a/virt/kvm/arm/vgic-v2.c
+++ b/virt/kvm/arm/vgic-v2.c
@@ -175,10 +175,15 @@ static const struct vgic_ops vgic_v2_ops = {
};
static struct vgic_params vgic_v2_params;
+static const struct of_device_id vgic_v2_ids[] = {
+ { .compatible = "arm,cortex-a15-gic" },
+ { .compatible = "arm,cortex-a7-gic" },
+ { .compatible = "arm,gic-400" },
+ {},
+};
/**
* vgic_v2_probe - probe for a GICv2 compatible interrupt controller in DT
- * @node: pointer to the DT node
* @ops: address of a pointer to the GICv2 operations
* @params: address of a pointer to HW-specific parameters
*
@@ -186,15 +191,21 @@ static struct vgic_params vgic_v2_params;
* in *ops and the HW parameters in *params. Returns an error code
* otherwise.
*/
-int vgic_v2_probe(struct device_node *vgic_node,
- const struct vgic_ops **ops,
+int vgic_v2_probe(const struct vgic_ops **ops,
const struct vgic_params **params)
{
int ret;
struct resource vctrl_res;
struct resource vcpu_res;
+ struct device_node *vgic_node;
struct vgic_params *vgic = &vgic_v2_params;
+ vgic_node = of_find_matching_node(NULL, vgic_v2_ids);
+ if (!vgic_node) {
+ ret = -ENODEV;
+ goto out;
+ }
+
vgic->maint_irq = irq_of_parse_and_map(vgic_node, 0);
if (!vgic->maint_irq) {
kvm_err("error getting vgic maintenance irq from DT\n");
diff --git a/virt/kvm/arm/vgic-v3.c b/virt/kvm/arm/vgic-v3.c
index 453eafd..5fa5fa7 100644
--- a/virt/kvm/arm/vgic-v3.c
+++ b/virt/kvm/arm/vgic-v3.c
@@ -215,10 +215,13 @@ static const struct vgic_ops vgic_v3_ops = {
};
static struct vgic_params vgic_v3_params;
+static const struct of_device_id vgic_v3_ids[] = {
+ { .compatible = "arm,gic-v3" },
+ {},
+};
/**
* vgic_v3_probe - probe for a GICv3 compatible interrupt controller in DT
- * @node: pointer to the DT node
* @ops: address of a pointer to the GICv3 operations
* @params: address of a pointer to HW-specific parameters
*
@@ -226,15 +229,21 @@ static struct vgic_params vgic_v3_params;
* in *ops and the HW parameters in *params. Returns an error code
* otherwise.
*/
-int vgic_v3_probe(struct device_node *vgic_node,
- const struct vgic_ops **ops,
+int vgic_v3_probe(const struct vgic_ops **ops,
const struct vgic_params **params)
{
int ret = 0;
u32 gicv_idx;
struct resource vcpu_res;
+ struct device_node *vgic_node;
struct vgic_params *vgic = &vgic_v3_params;
+ vgic_node = of_find_matching_node(NULL, vgic_v3_ids);
+ if (!vgic_node) {
+ ret = -ENODEV;
+ goto out;
+ }
+
vgic->maint_irq = irq_of_parse_and_map(vgic_node, 0);
if (!vgic->maint_irq) {
kvm_err("error getting vgic maintenance irq from DT\n");
diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
index 043032c..0d3d6b7 100644
--- a/virt/kvm/arm/vgic.c
+++ b/virt/kvm/arm/vgic.c
@@ -2389,34 +2389,16 @@ static struct notifier_block vgic_cpu_nb = {
.notifier_call = vgic_cpu_notify,
};
-static const struct of_device_id vgic_ids[] = {
- { .compatible = "arm,cortex-a15-gic", .data = vgic_v2_probe, },
- { .compatible = "arm,cortex-a7-gic", .data = vgic_v2_probe, },
- { .compatible = "arm,gic-400", .data = vgic_v2_probe, },
- { .compatible = "arm,gic-v3", .data = vgic_v3_probe, },
- {},
-};
-
int kvm_vgic_hyp_init(void)
{
- const struct of_device_id *matched_id;
- const int (*vgic_probe)(struct device_node *,const struct vgic_ops **,
- const struct vgic_params **);
- struct device_node *vgic_node;
int ret;
- vgic_node = of_find_matching_node_and_match(NULL,
- vgic_ids, &matched_id);
- if (!vgic_node) {
+ /* try GICv2 probing first, then GICv3 probing */
+ if (vgic_v2_probe(&vgic_ops, &vgic) || vgic_v3_probe(&vgic_ops, &vgic)) {
kvm_err("error: no compatible GIC node found\n");
return -ENODEV;
}
- vgic_probe = matched_id->data;
- ret = vgic_probe(vgic_node, &vgic_ops, &vgic);
- if (ret)
- return ret;
-
ret = request_percpu_irq(vgic->maint_irq, vgic_maintenance_handler,
"vgic", kvm_get_running_vcpus());
if (ret) {
--
1.8.3.1
next prev parent reply other threads:[~2016-02-05 17:07 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-05 17:07 [PATCH V1 0/7] Enable ACPI support for ARM KVM GIC Wei Huang
2016-02-05 17:07 ` Wei Huang [this message]
2016-02-05 17:07 ` [PATCH V1 2/7] KVM: GIC: Add extra fields to store GICH and GICV resource info Wei Huang
2016-02-05 17:07 ` [PATCH V1 3/7] KVM: GIC: Create a common probe function for GIC Wei Huang
2016-02-05 17:07 ` [PATCH V1 4/7] KVM: GICv2: Extract the common code from DT Wei Huang
2016-02-05 17:07 ` [PATCH V1 5/7] KVM: GICv2: Add ACPI probing function Wei Huang
2016-02-05 17:07 ` [PATCH V1 6/7] KVM: GICv3: Extract the common code from DT Wei Huang
2016-02-05 17:07 ` [PATCH V1 7/7] KVM: GICv3: Add ACPI probing function Wei Huang
2016-02-08 9:59 ` [PATCH V1 0/7] Enable ACPI support for ARM KVM GIC Marc Zyngier
2016-02-08 16:35 ` Wei Huang
2016-02-08 16:42 ` Marc Zyngier
2016-02-08 16:39 ` Julien Grall
2016-02-08 16:47 ` Wei Huang
2016-02-08 16:56 ` Marc Zyngier
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=1454692054-8984-2-git-send-email-wei@redhat.com \
--to=wei@redhat.com \
--cc=al.stone@linaro.org \
--cc=christoffer.dall@linaro.org \
--cc=drjones@redhat.com \
--cc=fu.wei@linaro.org \
--cc=hanjun.guo@linaro.org \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=marc.zyngier@arm.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