From: Wei Huang <wei@redhat.com>
To: kvmarm@lists.cs.columbia.edu
Cc: al.stone@linaro.org, kvm@vger.kernel.org, marc.zyngier@arm.com,
fu.wei@linaro.org, hanjun.guo@linaro.org
Subject: [PATCH V1 3/7] KVM: GIC: Create a common probe function for GIC
Date: Fri, 5 Feb 2016 12:07:30 -0500 [thread overview]
Message-ID: <1454692054-8984-4-git-send-email-wei@redhat.com> (raw)
In-Reply-To: <1454692054-8984-1-git-send-email-wei@redhat.com>
This patch creates common functions for both GICv2 and GICv3. The
existing functions are renamed to new names specifically for DT.
Signed-off-by: Wei Huang <wei@redhat.com>
---
virt/kvm/arm/vgic-v2.c | 44 +++++++++++++++++++++++++++++++-------------
virt/kvm/arm/vgic-v3.c | 37 ++++++++++++++++++++++++-------------
2 files changed, 55 insertions(+), 26 deletions(-)
diff --git a/virt/kvm/arm/vgic-v2.c b/virt/kvm/arm/vgic-v2.c
index 6540a6d..7dd5fb3 100644
--- a/virt/kvm/arm/vgic-v2.c
+++ b/virt/kvm/arm/vgic-v2.c
@@ -182,23 +182,16 @@ static const struct of_device_id vgic_v2_ids[] = {
{},
};
-/**
- * vgic_v2_probe - probe for a GICv2 compatible interrupt controller in DT
- * @ops: address of a pointer to the GICv2 operations
- * @params: address of a pointer to HW-specific parameters
- *
- * Returns 0 if a GICv2 has been found, with the low level operations
- * in *ops and the HW parameters in *params. Returns an error code
- * otherwise.
+/*
+ * Returns 0 if a GICv2 can be found in DT and the details of GICv2
+ * configuration are stored in *vgic. Otherwise returns an error code.
*/
-int vgic_v2_probe(const struct vgic_ops **ops,
- const struct vgic_params **params)
+static int vgic_v2_dt_probe(struct vgic_params *vgic)
{
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) {
@@ -269,8 +262,6 @@ int vgic_v2_probe(const struct vgic_ops **ops,
vgic->type = VGIC_V2;
vgic->max_gic_vcpus = VGIC_V2_MAX_CPUS;
- *ops = &vgic_v2_ops;
- *params = vgic;
goto out;
out_unmap:
@@ -279,3 +270,30 @@ out:
of_node_put(vgic_node);
return ret;
}
+
+/**
+ * vgic_v2_probe - probe for a GICv2 compatible interrupt controller
+ * @ops: address of a pointer to the GICv2 operations
+ * @params: address of a pointer to HW-specific parameters
+ *
+ * Returns 0 if a GICv2 has been found, with the low level operations
+ * in *ops and the HW parameters in *params. Returns an error code
+ * otherwise.
+ */
+int vgic_v2_probe(const struct vgic_ops **ops,
+ const struct vgic_params **params)
+{
+ int ret;
+ struct vgic_params *vgic = &vgic_v2_params;
+
+ ret = vgic_v2_dt_probe(vgic);
+ if (ret)
+ goto err_out;
+
+ *ops = &vgic_v2_ops;
+ *params = vgic;
+
+ return 0;
+err_out:
+ return ret;
+}
diff --git a/virt/kvm/arm/vgic-v3.c b/virt/kvm/arm/vgic-v3.c
index 33a5fdf..b036134 100644
--- a/virt/kvm/arm/vgic-v3.c
+++ b/virt/kvm/arm/vgic-v3.c
@@ -220,23 +220,16 @@ static const struct of_device_id vgic_v3_ids[] = {
{},
};
-/**
- * vgic_v3_probe - probe for a GICv3 compatible interrupt controller in DT
- * @ops: address of a pointer to the GICv3 operations
- * @params: address of a pointer to HW-specific parameters
- *
- * Returns 0 if a GICv3 has been found, with the low level operations
- * in *ops and the HW parameters in *params. Returns an error code
- * otherwise.
+/*
+ * Returns 0 if a GICv3 can be found in DT and the details of GICv3
+ * configuration are stored in *vgic. Otherwise returns an error code.
*/
-int vgic_v3_probe(const struct vgic_ops **ops,
- const struct vgic_params **params)
+static int vgic_v3_dt_probe(struct vgic_params *vgic)
{
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) {
@@ -292,11 +285,29 @@ int vgic_v3_probe(const struct vgic_ops **ops,
kvm_info("%s@%llx IRQ%d\n", vgic_node->name,
vcpu_res.start, vgic->maint_irq);
+out:
+ of_node_put(vgic_node);
+ return ret;
+}
+/**
+ * vgic_v3_probe - probe for a GICv3 compatible interrupt controller
+ * @ops: address of a pointer to the GICv3 operations
+ * @params: address of a pointer to HW-specific parameters
+ *
+ * Returns 0 if a GICv3 has been found, with the low level operations
+ * in *ops and the HW parameters in *params. Returns an error code
+ * otherwise.
+ */
+int vgic_v3_probe(const struct vgic_ops **ops,
+ const struct vgic_params **params)
+{
+ int ret = 0;
+ struct vgic_params *vgic = &vgic_v3_params;
+
+ ret = vgic_v3_dt_probe(vgic);
*ops = &vgic_v3_ops;
*params = vgic;
-out:
- of_node_put(vgic_node);
return 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 ` [PATCH V1 1/7] KVM: GIC: Move GIC DT probing code to GICv2 and GICv3 files Wei Huang
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 ` Wei Huang [this message]
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-4-git-send-email-wei@redhat.com \
--to=wei@redhat.com \
--cc=al.stone@linaro.org \
--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