From patchwork Tue Jan 28 18:54:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 23809 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f72.google.com (mail-vb0-f72.google.com [209.85.212.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9BEF4202FA for ; Tue, 28 Jan 2014 18:54:36 +0000 (UTC) Received: by mail-vb0-f72.google.com with SMTP id w20sf1582886vbb.11 for ; Tue, 28 Jan 2014 10:54:35 -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=hJVBy/uQeS2r2AO3t2oVtmovOeG0ggHDK5uEaqWXP2c=; b=T6foMH3r+whieDm4BIEtfdXBlVZoQD1pblFxeAL/RDcTAviJMd25714Ugl3mWsdMGL GUr4EJWtBo5ryelYqIWonHbrRgXOm/6QTZYDJPBVl4/I+7HHzwegy0uwhtDMFS+YmH88 rlp2n4pcWqR04F+8NxfEzoEJ0ShlGky0ZyJAl3+unqALuJqr2iBbnLrmsbvxl9iQ6KKh HW/0xT0gZsjpuSBO64eNeetHkVnRV7MbuwidfLkmNKcqJGSSzBMXRBoBLKzn7tJhVqKK Q4qAt+H2M/xFgau6Wu5gUwW3lGEP4wmkBMF4dZdWwXUKJgJ230SDvLNJoLgU8UWftspo oTdw== X-Gm-Message-State: ALoCoQm98geNOshmz6424+pBZPLmFp06qfbRwKxIgcFiBc/SiSBSQHnPsxeut4tD5VTYZp2RW5/v X-Received: by 10.236.18.196 with SMTP id l44mr981285yhl.52.1390935275659; Tue, 28 Jan 2014 10:54:35 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.24.49 with SMTP id 46ls2171987qgq.21.gmail; Tue, 28 Jan 2014 10:54:35 -0800 (PST) X-Received: by 10.52.170.241 with SMTP id ap17mr1911997vdc.13.1390935275587; Tue, 28 Jan 2014 10:54:35 -0800 (PST) Received: from mail-ve0-f175.google.com (mail-ve0-f175.google.com [209.85.128.175]) by mx.google.com with ESMTPS id sk6si6649257vcb.77.2014.01.28.10.54.35 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 28 Jan 2014 10:54:35 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.175; Received: by mail-ve0-f175.google.com with SMTP id c14so528906vea.34 for ; Tue, 28 Jan 2014 10:54:35 -0800 (PST) X-Received: by 10.58.200.168 with SMTP id jt8mr238326vec.30.1390935275503; Tue, 28 Jan 2014 10:54:35 -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 u4csp53647vcz; Tue, 28 Jan 2014 10:54:34 -0800 (PST) X-Received: by 10.14.6.129 with SMTP id 1mr118268een.99.1390935274191; Tue, 28 Jan 2014 10:54:34 -0800 (PST) Received: from mail-ee0-f42.google.com (mail-ee0-f42.google.com [74.125.83.42]) by mx.google.com with ESMTPS id y5si29598095eee.18.2014.01.28.10.54.33 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 28 Jan 2014 10:54:34 -0800 (PST) Received-SPF: neutral (google.com: 74.125.83.42 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=74.125.83.42; Received: by mail-ee0-f42.google.com with SMTP id e49so421845eek.1 for ; Tue, 28 Jan 2014 10:54:33 -0800 (PST) X-Received: by 10.15.21.2 with SMTP id c2mr164989eeu.77.1390935273636; Tue, 28 Jan 2014 10:54:33 -0800 (PST) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id o13sm58852942eex.19.2014.01.28.10.54.30 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Jan 2014 10:54:31 -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 v2] arm/xen: Initialize event channels earlier Date: Tue, 28 Jan 2014 18:54:23 +0000 Message-Id: <1390935264-23155-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.128.175 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 Reviewed-by: Stefano Stabellini --- Changes in v2: - Check earlier if the event IRQ is valid - We can safely register the VCPU when the cpu is booting --- arch/arm/xen/enlighten.c | 71 ++++++++++++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 27 deletions(-) diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c index 293eeea..b96723e 100644 --- a/arch/arm/xen/enlighten.c +++ b/arch/arm/xen/enlighten.c @@ -23,6 +23,7 @@ #include #include #include +#include #include @@ -154,7 +155,7 @@ 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(void) { struct vcpu_register_vcpu_info info; struct vcpu_info *vcpup; @@ -193,6 +194,31 @@ static void xen_power_off(void) BUG(); } +static int xen_cpu_notification(struct notifier_block *self, + unsigned long action, + void *hcpu) +{ + switch (action) { + case CPU_STARTING: + xen_percpu_init(); + break; + default: + break; + } + + return NOTIFY_OK; +} + +static struct notifier_block xen_cpu_notifier = { + .notifier_call = xen_cpu_notification, +}; + +static irqreturn_t xen_arm_callback(int irq, void *arg) +{ + xen_hvm_evtchn_do_upcall(); + return IRQ_HANDLED; +} + /* * see Documentation/devicetree/bindings/arm/xen.txt for the * documentation of the Xen Device Tree format. @@ -229,6 +255,10 @@ static int __init xen_guest_init(void) xen_events_irq = irq_of_parse_and_map(node, 0); pr_info("Xen %s support found, events_irq=%d gnttab_frame=%pa\n", version, xen_events_irq, &grant_frames); + + if (xen_events_irq < 0) + return -ENODEV; + xen_domain_type = XEN_HVM_DOMAIN; xen_setup_features(); @@ -281,9 +311,21 @@ static int __init xen_guest_init(void) disable_cpuidle(); disable_cpufreq(); + xen_init_IRQ(); + + 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; + } + + xen_percpu_init(); + + 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 +339,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);