From patchwork Mon Feb 1 20:26:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: fu.wei@linaro.org X-Patchwork-Id: 8183461 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0777A9F3CD for ; Mon, 1 Feb 2016 20:37:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2DD1A203A1 for ; Mon, 1 Feb 2016 20:37:17 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A2FBC203A0 for ; Mon, 1 Feb 2016 20:37:14 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aQLCn-0006qI-Ty; Mon, 01 Feb 2016 20:36:13 +0000 Received: from mx1.redhat.com ([209.132.183.28]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aQL6V-0006ul-7u for linux-arm-kernel@lists.infradead.org; Mon, 01 Feb 2016 20:29:47 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 74BCC7AE88; Mon, 1 Feb 2016 20:29:22 +0000 (UTC) Received: from magi-f22.redhat.com (vpn1-6-221.pek2.redhat.com [10.72.6.221]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u11KR5X6003082; Mon, 1 Feb 2016 15:29:01 -0500 From: fu.wei@linaro.org To: rjw@rjwysocki.net, lenb@kernel.org, daniel.lezcano@linaro.org, tglx@linutronix.de, christoffer.dall@linaro.org, marc.zyngier@arm.com, gleb@kernel.org, pbonzini@redhat.com, hanjun.guo@linaro.org, wei@redhat.com, a.spyridakis@virtualopensystems.com Subject: [PATCH v3 5/6] kvm: arm64: wrapping DT support for virt arch timer Date: Tue, 2 Feb 2016 04:26:57 +0800 Message-Id: <1454358418-5157-6-git-send-email-fu.wei@linaro.org> In-Reply-To: <1454358418-5157-1-git-send-email-fu.wei@linaro.org> References: <1454358418-5157-1-git-send-email-fu.wei@linaro.org> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160201_122943_711348_02E325DB X-CRM114-Status: GOOD ( 13.38 ) X-Spam-Score: -6.3 (------) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, leo.duran@amd.com, Fu Wei , al.stone@linaro.org, kvm@vger.kernel.org, linaro-acpi@lists.linaro.org, jcm@redhat.com, richardcochran@gmail.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, davem@davemloft.net, linux-acpi@vger.kernel.org, wim@iguana.be, arnd@arndb.de, jeffrey.t.kirsher@intel.com, Suravee.Suthikulpanit@amd.com, catalin.marinas@arm.com, graeme.gregory@linaro.org, robherring2@gmail.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Wei Huang This patches wrapping DT support for virt arch timer into a function. [Fu Wei: improve the DT support, and separate ACPI support] Signed-off-by: Alexander Spyridaki Signed-off-by: Wei Huang Signed-off-by: Graeme Gregory Signed-off-by: Fu Wei --- virt/kvm/arm/arch_timer.c | 49 +++++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c index 69bca185..0a279d3 100644 --- a/virt/kvm/arm/arch_timer.c +++ b/virt/kvm/arm/arch_timer.c @@ -381,9 +381,30 @@ static const struct of_device_id arch_timer_of_match[] = { {}, }; -int kvm_timer_hyp_init(void) +static int kvm_timer_get_ppi(unsigned int *ppi) { struct device_node *np; + int ret = -EINVAL; + + np = of_find_matching_node(NULL, arch_timer_of_match); + if (!np) { + ret = -ENODEV; + *ppi = 0; + goto skip_of; + } + + *ppi = irq_of_parse_and_map(np, VIRT_PPI); + of_node_put(np); + +skip_of: + if (*ppi) + return 0; + + return ret; +} + +int kvm_timer_hyp_init(void) +{ unsigned int ppi; int err; @@ -391,17 +412,11 @@ int kvm_timer_hyp_init(void) if (!timecounter) return -ENODEV; - np = of_find_matching_node(NULL, arch_timer_of_match); - if (!np) { - kvm_err("kvm_arch_timer: can't find DT node\n"); - return -ENODEV; - } - - ppi = irq_of_parse_and_map(np, 2); - if (!ppi) { - kvm_err("kvm_arch_timer: no virtual timer interrupt\n"); - err = -EINVAL; - goto out; + err = kvm_timer_get_ppi(&ppi); + if (err) { + kvm_err("kvm_arch_timer: can't find virtual timer info or " + "config virtual timer interrupt.\n"); + return err; } err = request_percpu_irq(ppi, kvm_arch_timer_handler, @@ -409,7 +424,7 @@ int kvm_timer_hyp_init(void) if (err) { kvm_err("kvm_arch_timer: can't request interrupt %d (%d)\n", ppi, err); - goto out; + return err; } host_vtimer_irq = ppi; @@ -426,14 +441,14 @@ int kvm_timer_hyp_init(void) goto out_free; } - kvm_info("%s IRQ%d\n", np->name, ppi); + kvm_info("timer IRQ%d.\n", ppi); on_each_cpu(kvm_timer_init_interrupt, NULL, 1); - goto out; + return 0; + out_free: free_percpu_irq(ppi, kvm_get_running_vcpus()); -out: - of_node_put(np); + return err; }