From patchwork Wed Jul 9 13:23:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 33313 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f72.google.com (mail-yh0-f72.google.com [209.85.213.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D9173208CF for ; Wed, 9 Jul 2014 13:25:58 +0000 (UTC) Received: by mail-yh0-f72.google.com with SMTP id f10sf29265333yha.11 for ; Wed, 09 Jul 2014 06:25:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:cc:subject :precedence:list-id:list-unsubscribe:list-post:list-help :list-subscribe:mime-version:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:list-archive :content-type:content-transfer-encoding; bh=fHgw/JN+XLKJK+53QXM7M/9F6RmrFx4AAEjyXXofl+w=; b=mNPQWLuEItwrIdudYo1Dy+N0JFgSXcfFPROWem4fGlLRkjqbCkdc3ZgKPhGHfJXQI8 QLA+u8o1gk6qik9dhIpovAoKgloCL7m1FczuoCrQkvrxCaogHyS85dbGHbn0soNqnNHI PaWDAIGRDHgLJieyobxiN7Z0p6ysbndh9INN7fSQEpVJxjmzLCdOHS/MfdM7c3n73/fm ljQYDfQzmqXwtNeFdQPJDUnY+7MblRoFNiojib2XkuO9XDfP+XAtjjX1WUtgZBLyg20v G8wCIA5sy7JoDKM8CpwTpDScRjqGKlnH3a6qoqkx1mBe79+sJ+KBtWZdoWzyaN4+t3v9 TX9Q== X-Gm-Message-State: ALoCoQkHpHf+tPma+ejICORlvJVb9S7U0UBEdPkDbxRBftkw3u2i1tspphlHTlICeOqnKbOk/Zbc X-Received: by 10.58.198.78 with SMTP id ja14mr3252960vec.26.1404912358619; Wed, 09 Jul 2014 06:25:58 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.37.193 with SMTP id r59ls1501053qgr.35.gmail; Wed, 09 Jul 2014 06:25:58 -0700 (PDT) X-Received: by 10.52.166.10 with SMTP id zc10mr326310vdb.61.1404912358540; Wed, 09 Jul 2014 06:25:58 -0700 (PDT) Received: from mail-ve0-f173.google.com (mail-ve0-f173.google.com [209.85.128.173]) by mx.google.com with ESMTPS id dn3si21511744vcb.40.2014.07.09.06.25.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 09 Jul 2014 06:25:58 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.173 as permitted sender) client-ip=209.85.128.173; Received: by mail-ve0-f173.google.com with SMTP id db11so7139011veb.18 for ; Wed, 09 Jul 2014 06:25:58 -0700 (PDT) X-Received: by 10.58.182.234 with SMTP id eh10mr399284vec.41.1404912358423; Wed, 09 Jul 2014 06:25:58 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp47722vcb; Wed, 9 Jul 2014 06:25:57 -0700 (PDT) X-Received: by 10.43.104.132 with SMTP id dm4mr47122794icc.56.1404912357808; Wed, 09 Jul 2014 06:25:57 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id l6si7999527igv.10.2014.07.09.06.25.56 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 09 Jul 2014 06:25:57 -0700 (PDT) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1X4rqi-0003nG-GR; Wed, 09 Jul 2014 13:23:52 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1X4rqg-0003n5-K3 for xen-devel@lists.xenproject.org; Wed, 09 Jul 2014 13:23:50 +0000 Received: from [85.158.137.68:18977] by server-8.bemta-3.messagelabs.com id 37/D2-00810-5624DB35; Wed, 09 Jul 2014 13:23:49 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-14.tower-31.messagelabs.com!1404912229!12489818!1 X-Originating-IP: [74.125.82.176] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 6.11.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 27591 invoked from network); 9 Jul 2014 13:23:49 -0000 Received: from mail-we0-f176.google.com (HELO mail-we0-f176.google.com) (74.125.82.176) by server-14.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 9 Jul 2014 13:23:49 -0000 Received: by mail-we0-f176.google.com with SMTP id u56so7490089wes.7 for ; Wed, 09 Jul 2014 06:23:48 -0700 (PDT) X-Received: by 10.180.13.47 with SMTP id e15mr11923706wic.28.1404912228577; Wed, 09 Jul 2014 06:23:48 -0700 (PDT) Received: from belegaer.uk.xensource.com ([185.25.64.249]) by mx.google.com with ESMTPSA id o9sm19359855wib.22.2014.07.09.06.23.47 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jul 2014 06:23:47 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Wed, 9 Jul 2014 14:23:42 +0100 Message-Id: <1404912223-9320-1-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 Cc: stefano.stabellini@citrix.com, Julien Grall , tim@xen.org, ian.campbell@citrix.com Subject: [Xen-devel] [PATCH v3 1/2] xen/arm: Divide GIC initialization in 2 parts X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.173 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: Currently the function to translate IRQ from the device tree is set unconditionally to be able to be able to retrieve serial/timer IRQ before the GIC has been initialized. It assumes that the xlate function won't never changed. We may also need to have the primary interrupt controller very early. Rework the gic initialization in 2 parts: - gic_preinit: Get the interrupt controller device tree node and set up GIC and xlate callbacks - gic_init: Initialize the interrupt controller and the boot CPU interrupts. The former function will be called just after the IRQ subsystem as been initialized. Signed-off-by: Julien Grall --- Changes in v3: - Patch added. --- xen/arch/arm/gic-v2.c | 27 +++++++++++++++++---------- xen/arch/arm/gic.c | 16 ++++++++++++++-- xen/arch/arm/setup.c | 3 ++- xen/include/asm-arm/gic.h | 8 ++++++++ 4 files changed, 41 insertions(+), 13 deletions(-) diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c index cc60af8..0762329 100644 --- a/xen/arch/arm/gic-v2.c +++ b/xen/arch/arm/gic-v2.c @@ -74,6 +74,7 @@ static struct { void __iomem * map_hbase; /* IO Address of virtual interface registers */ paddr_t vbase; /* Address of virtual cpu interface registers */ spinlock_t lock; + struct dt_device_node *node; } gicv2; static struct gic_info gicv2_info; @@ -560,8 +561,11 @@ static hw_irq_controller gicv2_guest_irq_type = { .set_affinity = gicv2_irq_set_affinity, }; +static int __init gicv2_init(void); + const static struct gic_hw_operations gicv2_ops = { .info = &gicv2_info, + .init = gicv2_init, .secondary_init = gicv2_secondary_cpu_init, .save_state = gicv2_save_state, .restore_state = gicv2_restore_state, @@ -585,11 +589,20 @@ const static struct gic_hw_operations gicv2_ops = { }; /* Set up the GIC */ -static int __init gicv2_init(struct dt_device_node *node, const void *data) +static int __init gicv2_preinit(struct dt_device_node *node, const void *data) { - int res; + gicv2_info.hw_version = GIC_V2; + gicv2_info.node = node; + register_gic_ops(&gicv2_ops); + dt_irq_xlate = gic_irq_xlate; - dt_device_set_used_by(node, DOMID_XEN); + return 0; +} + +static int __init gicv2_init(void) +{ + int res; + const struct dt_device_node *node = gicv2_info.node; res = dt_device_get_address(node, 0, &gicv2.dbase, NULL); if ( res || !gicv2.dbase || (gicv2.dbase & ~PAGE_MASK) ) @@ -612,9 +625,6 @@ static int __init gicv2_init(struct dt_device_node *node, const void *data) panic("GICv2: Cannot find the maintenance IRQ"); gicv2_info.maintenance_irq = res; - /* Set the GIC as the primary interrupt controller */ - dt_interrupt_controller = node; - /* TODO: Add check on distributor, cpu size */ printk("GICv2 initialization:\n" @@ -656,9 +666,6 @@ static int __init gicv2_init(struct dt_device_node *node, const void *data) spin_unlock(&gicv2.lock); - gicv2_info.hw_version = GIC_V2; - register_gic_ops(&gicv2_ops); - return 0; } @@ -671,7 +678,7 @@ static const char * const gicv2_dt_compat[] __initconst = DT_DEVICE_START(gicv2, "GICv2:", DEVICE_GIC) .compatible = gicv2_dt_compat, - .init = gicv2_init, + .init = gicv2_preinit, DT_DEVICE_END /* diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index 83b004c..91552fb 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -161,8 +161,10 @@ int gic_irq_xlate(const u32 *intspec, unsigned int intsize, return 0; } -/* Set up the GIC */ -void __init gic_init(void) +/* Find the interrupt controller and set up the callback to translate + * device tree IRQ. + */ +void __init gic_preinit(void) { int rc; struct dt_device_node *node; @@ -187,6 +189,16 @@ void __init gic_init(void) if ( !num_gics ) panic("Unable to find compatible GIC in the device tree"); + /* Set the GIC as the primary interrupt controller */ + dt_interrupt_controller = node; + dt_device_set_used_by(node, DOMID_XEN); +} + +/* Set up the GIC */ +void __init gic_init(void) +{ + if ( gic_hw_ops->init() ) + panic("Failed to initialize the GIC drivers"); /* Clear LR mask for cpu0 */ clear_cpu_lr_mask(); } diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 78dc7f5..36104fc 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -692,10 +692,11 @@ void __init start_xen(unsigned long boot_phys_offset, vm_init(); dt_unflatten_host_device_tree(); - dt_irq_xlate = gic_irq_xlate; init_IRQ(); + gic_preinit(); + dt_uart_init(); console_init_preirq(); diff --git a/xen/include/asm-arm/gic.h b/xen/include/asm-arm/gic.h index ed610cb..fec57b5 100644 --- a/xen/include/asm-arm/gic.h +++ b/xen/include/asm-arm/gic.h @@ -209,6 +209,10 @@ extern void gic_remove_from_queues(struct vcpu *v, unsigned int virtual_irq); /* Accept an interrupt from the GIC and dispatch its handler */ extern void gic_interrupt(struct cpu_user_regs *regs, int is_fiq); +/* Find the interrupt controller and set up the callback to translate + * device tree IRQ. + */ +extern void gic_preinit(void); /* Bring up the interrupt controller, and report # cpus attached */ extern void gic_init(void); /* Bring up a secondary CPU's per-CPU GIC interface */ @@ -261,11 +265,15 @@ struct gic_info { uint8_t nr_lrs; /* Maintenance irq number */ unsigned int maintenance_irq; + /* Pointer to the device tree node representing the interrupt controller */ + const struct dt_device_node *node; }; struct gic_hw_operations { /* Hold GIC HW information */ const struct gic_info *info; + /* Initialize the GIC and the boot CPU */ + int (*init)(void); /* Save GIC registers */ void (*save_state)(struct vcpu *); /* Restore GIC registers */