From patchwork Tue Jan 28 14:54:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 3546941 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E969C9F2E9 for ; Tue, 28 Jan 2014 14:54:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C705A2015E for ; Tue, 28 Jan 2014 14:54:48 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C57DF2015A for ; Tue, 28 Jan 2014 14:54:46 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W8A3l-0000HQ-KN; Tue, 28 Jan 2014 14:54:41 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1W8A3j-0007eg-4X; Tue, 28 Jan 2014 14:54:39 +0000 Received: from mail-ea0-f180.google.com ([209.85.215.180]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W8A3g-0007e2-FY for linux-arm-kernel@lists.infradead.org; Tue, 28 Jan 2014 14:54:37 +0000 Received: by mail-ea0-f180.google.com with SMTP id o10so292768eaj.39 for ; Tue, 28 Jan 2014 06:54:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=T6A0TJK8S4lJ8O869KqdWMOhEru/9+3aUGUvAnd1/38=; b=E0gIV3GTYkg0UeHypBE63cH00AaETYs5hWnUwulLQM1eF+4RV2DO713dcUS4TYkh12 59vqMF5RuWq317Wasp+FDPldioazdoZh4y2gebsBeSt3L+GZtgZ0phBgdUBVNeDVnwfu mwgH3O8PTmgrvv1lisDi80LAPaKBuRQCiZxDJQXMXjye7OMHTyM5Ttzyl0zWMeWPg+ha BYhkKpN92INvouNt8XOvm7feWeFDwRWPMdB0LUGQizQkSF11IBar3s1vkUpc0ZzTG1cg 2SHPuz81sFZfUVvXpwOE++ik84oYPVBWLPxpooiIOb7OguGYdZkV7d6gXBNdFwK4GTb+ v1Sw== X-Gm-Message-State: ALoCoQmADMubBN731CRzZFChWdNInGDMlOp/3j4IKckQVQGRPGCJnNzyzLYWgcgNzTqIZLGAnLKM X-Received: by 10.14.32.67 with SMTP id n43mr2301557eea.17.1390920853172; Tue, 28 Jan 2014 06:54:13 -0800 (PST) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id 46sm56508424ees.4.2014.01.28.06.54.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Jan 2014 06:54:12 -0800 (PST) From: Julien Grall To: linux-kernel@vger.kernel.org, stefano.stabellini@eu.citrix.com Subject: [PATCH] arm/xen: Initialize event channels earlier Date: Tue, 28 Jan 2014 14:54:02 +0000 Message-Id: <1390920842-21886-1-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140128_095436_677266_8D9BC069 X-CRM114-Status: GOOD ( 16.55 ) X-Spam-Score: -2.6 (--) Cc: Julien Grall , ian.campbell@citrix.com, patches@linaro.org, konrad.wilk@oracle.com, david.vrabel@citrix.com, xen-devel@lists.xenproject.org, boris.ostrovsky@oracle.com, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 Event channels driver needs to be initialized very early. Until now, Xen initialization was done after all CPUs was bring up. We can safely move the initialization to an early initcall. Also use a cpu notifier to: - Register the VCPU when the CPU is prepared - Enable event channel IRQ when the CPU is running Signed-off-by: Julien Grall --- arch/arm/xen/enlighten.c | 84 ++++++++++++++++++++++++++++++---------------- 1 file changed, 55 insertions(+), 29 deletions(-) diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c index 293eeea..39b668e 100644 --- a/arch/arm/xen/enlighten.c +++ b/arch/arm/xen/enlighten.c @@ -23,6 +23,7 @@ #include #include #include +#include #include @@ -154,12 +155,11 @@ int xen_unmap_domain_mfn_range(struct vm_area_struct *vma, } EXPORT_SYMBOL_GPL(xen_unmap_domain_mfn_range); -static void __init xen_percpu_init(void *unused) +static void xen_percpu_init(int cpu) { struct vcpu_register_vcpu_info info; struct vcpu_info *vcpup; int err; - int cpu = get_cpu(); pr_info("Xen: initializing cpu%d\n", cpu); vcpup = per_cpu_ptr(xen_vcpu_info, cpu); @@ -170,9 +170,11 @@ static void __init xen_percpu_init(void *unused) err = HYPERVISOR_vcpu_op(VCPUOP_register_vcpu_info, cpu, &info); BUG_ON(err); per_cpu(xen_vcpu, cpu) = vcpup; +} +static void xen_interrupt_init(void) +{ enable_percpu_irq(xen_events_irq, 0); - put_cpu(); } static void xen_restart(enum reboot_mode reboot_mode, const char *cmd) @@ -193,6 +195,36 @@ static void xen_power_off(void) BUG(); } +static irqreturn_t xen_arm_callback(int irq, void *arg) +{ + xen_hvm_evtchn_do_upcall(); + return IRQ_HANDLED; +} + +static int xen_cpu_notification(struct notifier_block *self, + unsigned long action, + void *hcpu) +{ + int cpu = (long)hcpu; + + switch (action) { + case CPU_UP_PREPARE: + xen_percpu_init(cpu); + break; + case CPU_STARTING: + xen_interrupt_init(); + break; + default: + break; + } + + return NOTIFY_OK; +} + +static struct notifier_block xen_cpu_notifier = { + .notifier_call = xen_cpu_notification, +}; + /* * see Documentation/devicetree/bindings/arm/xen.txt for the * documentation of the Xen Device Tree format. @@ -209,6 +241,7 @@ static int __init xen_guest_init(void) const char *xen_prefix = "xen,xen-"; struct resource res; phys_addr_t grant_frames; + int cpu; node = of_find_compatible_node(NULL, NULL, "xen,xen"); if (!node) { @@ -281,9 +314,27 @@ static int __init xen_guest_init(void) disable_cpuidle(); disable_cpufreq(); + xen_init_IRQ(); + + if (xen_events_irq < 0) + return -ENODEV; + + if (request_percpu_irq(xen_events_irq, xen_arm_callback, + "events", &xen_vcpu)) { + pr_err("Error request IRQ %d\n", xen_events_irq); + return -EINVAL; + } + + cpu = get_cpu(); + xen_percpu_init(cpu); + xen_interrupt_init(); + put_cpu(); + + register_cpu_notifier(&xen_cpu_notifier); + return 0; } -core_initcall(xen_guest_init); +early_initcall(xen_guest_init); static int __init xen_pm_init(void) { @@ -297,31 +348,6 @@ static int __init xen_pm_init(void) } late_initcall(xen_pm_init); -static irqreturn_t xen_arm_callback(int irq, void *arg) -{ - xen_hvm_evtchn_do_upcall(); - return IRQ_HANDLED; -} - -static int __init xen_init_events(void) -{ - if (!xen_domain() || xen_events_irq < 0) - return -ENODEV; - - xen_init_IRQ(); - - if (request_percpu_irq(xen_events_irq, xen_arm_callback, - "events", &xen_vcpu)) { - pr_err("Error requesting IRQ %d\n", xen_events_irq); - return -EINVAL; - } - - on_each_cpu(xen_percpu_init, NULL, 0); - - return 0; -} -postcore_initcall(xen_init_events); - /* In the hypervisor.S file. */ EXPORT_SYMBOL_GPL(HYPERVISOR_event_channel_op); EXPORT_SYMBOL_GPL(HYPERVISOR_grant_table_op);