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 5/7] KVM: GICv2: Add ACPI probing function
Date: Fri, 5 Feb 2016 12:07:32 -0500 [thread overview]
Message-ID: <1454692054-8984-6-git-send-email-wei@redhat.com> (raw)
In-Reply-To: <1454692054-8984-1-git-send-email-wei@redhat.com>
This patch implements ACPI probing for GICv2.
Signed-off-by: Wei Huang <wei@redhat.com>
---
virt/kvm/arm/vgic-v2.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 68 insertions(+)
diff --git a/virt/kvm/arm/vgic-v2.c b/virt/kvm/arm/vgic-v2.c
index b60e73a..7de2a1f 100644
--- a/virt/kvm/arm/vgic-v2.c
+++ b/virt/kvm/arm/vgic-v2.c
@@ -23,6 +23,7 @@
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_irq.h>
+#include <linux/acpi.h>
#include <linux/irqchip/arm-gic.h>
@@ -226,6 +227,71 @@ out:
return ret;
}
+#ifdef CONFIG_ACPI
+static struct acpi_madt_generic_interrupt *vgic_acpi;
+static void gic_get_acpi_header(struct acpi_subtable_header *header)
+{
+ vgic_acpi = (struct acpi_madt_generic_interrupt *)header;
+}
+
+static struct acpi_madt_generic_distributor *dist_acpi;
+static void gic_get_dist_header(struct acpi_subtable_header *header)
+{
+ dist_acpi = (struct acpi_madt_generic_distributor *)header;
+}
+
+static int vgic_v2_acpi_probe(struct vgic_params *vgic)
+{
+ int irq_mode, ret = 0;
+
+ ret = acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_INTERRUPT,
+ (acpi_tbl_entry_handler)gic_get_acpi_header, 0);
+ if (!ret) {
+ ret = -ENODEV;
+ goto out;
+ }
+
+ ret = acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR,
+ (acpi_tbl_entry_handler)gic_get_dist_header, 0);
+ if (!ret) {
+ kvm_err("Cannot get distributor entry from ACPI\n");
+ ret = -ENODEV;
+ goto out;
+ }
+
+ if (dist_acpi->version >= ACPI_MADT_GIC_VERSION_V3) {
+ ret = -ENODEV;
+ goto out;
+ }
+
+ irq_mode = (vgic_acpi->flags & ACPI_MADT_VGIC_IRQ_MODE) ?
+ ACPI_EDGE_SENSITIVE : ACPI_LEVEL_SENSITIVE;
+ /* According to GIC-400 manual, PPIs are active-LOW, level-sensative.
+ * We register IRQ as active-low.
+ */
+ vgic->maint_irq = acpi_register_gsi(NULL, vgic_acpi->vgic_interrupt,
+ irq_mode, ACPI_ACTIVE_LOW);
+ if (!vgic->maint_irq) {
+ kvm_err("Cannot register vgic maintenance irq from ACPI\n");
+ ret = -ENXIO;
+ goto out;
+ }
+
+ vgic->vctrl_phys_base = vgic_acpi->gich_base_address;
+ vgic->vctrl_size = SZ_8K;
+
+ vgic->vcpu_phys_base = vgic_acpi->gicv_base_address;
+ vgic->vcpu_size = 0; /* unavailable in ACPI, set to 0 */
+out:
+ return ret;
+}
+#else
+static inline int vgic_v2_acpi_probe(struct vgic_params *vgic)
+{
+ return -ENODEV;
+}
+#endif /* CONFIG_ACPI */
+
/**
* vgic_v2_probe - probe for a GICv2 compatible interrupt controller
* @ops: address of a pointer to the GICv2 operations
@@ -242,6 +308,8 @@ int vgic_v2_probe(const struct vgic_ops **ops,
struct vgic_params *vgic = &vgic_v2_params;
ret = vgic_v2_dt_probe(vgic);
+ if (ret && !acpi_disabled)
+ ret = vgic_v2_acpi_probe(vgic);
if (ret)
goto err_out;
--
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 ` [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 ` Wei Huang [this message]
2016-02-05 17:07 ` [PATCH V1 6/7] KVM: GICv3: " 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-6-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