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: 23796 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f197.google.com (mail-qc0-f197.google.com [209.85.216.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6C22B202B2 for ; Tue, 28 Jan 2014 14:54:16 +0000 (UTC) Received: by mail-qc0-f197.google.com with SMTP id e16sf941759qcx.0 for ; Tue, 28 Jan 2014 06:54:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=T6A0TJK8S4lJ8O869KqdWMOhEru/9+3aUGUvAnd1/38=; b=AprO47FrgVoeqLvQujCHU7pIgewqeywMBV6Ylx4Oca0Ek0XVUhHS5rSTBaqdPJsrbB XGHABRu6D5OCYNLIyQNcNAUQo7wSqlieEWa+B0cmtzRcj+knEBle63+l5FXrUTx+G4Rm KTS+L7OZOQa+8VeH3wE1fAtniFMRtBtOPwcgreX/BgP5xiQLIhjHpDmSoeAHo0GeLsvM pDzdVOOP64Goecpdm2z9eXsgUD6t81N6HAK/JNjzhflERFvOGwvrAbSygIcS4IitD9dd F8m2Nba0zWwGxcwcbczSJiZvh3WNSMn2pEQoyN1YfNfkat79reY/ZMTwnfFNBJr4f2ec lhCw== X-Gm-Message-State: ALoCoQkGkbR4YIPg+rxA8GbFvhC5Gw7u0tyCJfozztGzVakM45KAPx26ylyXWXIvIxb5Zvhc91fe X-Received: by 10.58.144.41 with SMTP id sj9mr645623veb.8.1390920855321; Tue, 28 Jan 2014 06:54:15 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.50.5 with SMTP id r5ls2033158qga.22.gmail; Tue, 28 Jan 2014 06:54:15 -0800 (PST) X-Received: by 10.58.155.162 with SMTP id vx2mr54001veb.46.1390920855219; Tue, 28 Jan 2014 06:54:15 -0800 (PST) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id gq1si6411564vec.99.2014.01.28.06.54.15 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 28 Jan 2014 06:54:15 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id ik5so312119vcb.9 for ; Tue, 28 Jan 2014 06:54:15 -0800 (PST) X-Received: by 10.52.227.193 with SMTP id sc1mr1158937vdc.1.1390920855141; Tue, 28 Jan 2014 06:54:15 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp36424vcz; Tue, 28 Jan 2014 06:54:14 -0800 (PST) X-Received: by 10.15.91.3 with SMTP id r3mr2436152eez.18.1390920853967; Tue, 28 Jan 2014 06:54:13 -0800 (PST) Received: from mail-ea0-f177.google.com (mail-ea0-f177.google.com [209.85.215.177]) by mx.google.com with ESMTPS id g47si28118418eet.192.2014.01.28.06.54.13 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 28 Jan 2014 06:54:13 -0800 (PST) Received-SPF: neutral (google.com: 209.85.215.177 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=209.85.215.177; Received: by mail-ea0-f177.google.com with SMTP id n15so291016ead.22 for ; Tue, 28 Jan 2014 06:54:13 -0800 (PST) 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 Cc: linux-arm-kernel@lists.infradead.org, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, ian.campbell@citrix.com, xen-devel@lists.xenproject.org, patches@linaro.org, david.vrabel@citrix.com, Julien Grall 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-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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);