From mboxrd@z Thu Jan 1 00:00:00 1970 From: Hanjun Guo Subject: Re: [PATCH V2 1/5] kvm: arm64: Enable ACPI support for virt arch timer Date: Thu, 11 Jun 2015 19:27:25 +0800 Message-ID: <5579709D.7080905@linaro.org> References: <1433909767-12189-1-git-send-email-wei@redhat.com> <1433909767-12189-2-git-send-email-wei@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, marc.zyngier@arm.com, christoffer.dall@linaro.org, pbonzini@redhat.com, drjones@redhat.com, a.spyridakis@virtualopensystems.com To: Wei Huang , kvmarm@lists.cs.columbia.edu Return-path: Received: from mail-pd0-f171.google.com ([209.85.192.171]:35381 "EHLO mail-pd0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751244AbbFKL1j (ORCPT ); Thu, 11 Jun 2015 07:27:39 -0400 Received: by pdbnf5 with SMTP id nf5so2922381pdb.2 for ; Thu, 11 Jun 2015 04:27:38 -0700 (PDT) In-Reply-To: <1433909767-12189-2-git-send-email-wei@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 06/10/2015 12:16 PM, Wei Huang wrote: > This patches enables ACPI support for KVM virtual arch timer. It allows > KVM to parse ACPI table for arch timer PPI when DT table is not present. > > Signed-off-by: Alexander Spyridaki > Signed-off-by: Wei Huang > --- > virt/kvm/arm/arch_timer.c | 75 +++++++++++++++++++++++++++++++++++++++-------- > 1 file changed, 62 insertions(+), 13 deletions(-) > > diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c > index 98c95f2..a9da75a 100644 > --- a/virt/kvm/arm/arch_timer.c > +++ b/virt/kvm/arm/arch_timer.c > @@ -21,6 +21,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -274,9 +275,57 @@ static const struct of_device_id arch_timer_of_match[] = { > {}, > }; > > -int kvm_timer_hyp_init(void) > +static int kvm_timer_ppi_dt_parse(unsigned int *ppi) > { > struct device_node *np; > + > + np = of_find_matching_node(NULL, arch_timer_of_match); > + if (!np) > + return -ENODEV; > + > + *ppi = irq_of_parse_and_map(np, 2); > + if (*ppi == 0) { > + of_node_put(np); > + return -EINVAL; > + } > + > + return 0; > +} > + > +#ifdef CONFIG_ACPI > +struct acpi_table_gtdt *gtdt_acpi; > +static void arch_timer_acpi_parse(struct acpi_table_header *table) > +{ > + gtdt_acpi = container_of(table, struct acpi_table_gtdt, header); > +} > + > +static int kvm_timer_ppi_acpi_parse(unsigned int *ppi) > +{ > + u32 flags; > + int trigger, polarity; > + > + /*Get the interrupt number from the GTDT table */ > + acpi_table_parse(ACPI_SIG_GTDT, > + (acpi_tbl_table_handler)arch_timer_acpi_parse); > + > + if (!gtdt_acpi->virtual_timer_interrupt) > + return -EINVAL; ... > + > + flags = gtdt_acpi->virtual_timer_flags; > + trigger = (flags & ACPI_GTDT_INTERRUPT_MODE) ? ACPI_EDGE_SENSITIVE > + : ACPI_LEVEL_SENSITIVE; > + polarity = (flags & ACPI_GTDT_INTERRUPT_POLARITY) ? ACPI_ACTIVE_LOW > + : ACPI_ACTIVE_HIGH; > + > + *ppi = acpi_register_gsi(NULL, gtdt_acpi->virtual_timer_interrupt, > + trigger, polarity); Hmm, this is another duplication of getting trigger/polarity and registering the interrupt, currently we are working on introducing gtdt.c and put common used functions there [1], but I think this is just some nitpick, we can refactor it later when that patch set is accepted. [1]: https://lkml.org/lkml/2015/6/10/367 Thanks Hanjun