From patchwork Tue Nov 17 09:40:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 56731 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1826030lbb; Tue, 17 Nov 2015 01:45:38 -0800 (PST) X-Received: by 10.140.33.139 with SMTP id j11mr40881751qgj.49.1447753538640; Tue, 17 Nov 2015 01:45:38 -0800 (PST) Return-Path: Received: from lists.xen.org (lists.xenproject.org. [50.57.142.19]) by mx.google.com with ESMTPS id d81si29175218qkb.124.2015.11.17.01.45.38 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 17 Nov 2015 01:45:38 -0800 (PST) Received-SPF: neutral (google.com: 50.57.142.19 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=50.57.142.19; Authentication-Results: mx.google.com; spf=neutral (google.com: 50.57.142.19 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org; dkim=neutral (body hash did not verify) header.i=@linaro_org.20150623.gappssmtp.com Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZycoK-00040O-Fl; Tue, 17 Nov 2015 09:44:24 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZycoJ-0003z8-Ja for xen-devel@lists.xen.org; Tue, 17 Nov 2015 09:44:23 +0000 Received: from [193.109.254.147] by server-3.bemta-14.messagelabs.com id 40/E3-25435-7F6FA465; Tue, 17 Nov 2015 09:44:23 +0000 X-Env-Sender: shannon.zhao@linaro.org X-Msg-Ref: server-16.tower-27.messagelabs.com!1447753461!3768430!1 X-Originating-IP: [74.125.82.44] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 7.19.2; banners=-,-,- X-VirusChecked: Checked Received: (qmail 41098 invoked from network); 17 Nov 2015 09:44:21 -0000 Received: from mail-wm0-f44.google.com (HELO mail-wm0-f44.google.com) (74.125.82.44) by server-16.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Nov 2015 09:44:21 -0000 Received: by wmww144 with SMTP id w144so145603211wmw.1 for ; Tue, 17 Nov 2015 01:44:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0Gz4thGVVVvCsUEVvMNjI/mQC6/7L7ePi7av8IfM3Bc=; b=jIHvCwUo2EGq3C8UAQh+xrgW9tKMNgdSQDOk0SO/Vq0xKPgYYuy9BikvqRBVYu+i4A bo3at0xjREMizz7kTQu/ivzLS9H5C52WtqI7U++Ntsrr3pDuohA4NuMUAAs8Sp1+s9+K J1knqA152d6PfNMXqpSeXuZnOEfuwve9/UjuZ2erXPJZy4MC3tcYsn5osS4bzbTJrnis 6cG0KWD+O6yzt187BpQHr0g6kPbJ8BHwDkoBQigh6LrNloYLhix55gpgo6DmgS83xSqa 9a/rfHWq12KUkQz+Brg6Ew7HwrFnI3pVJNqrpU5YpG5kn6TYyO07n9xLKY5/xKn/y39I +r2g== 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:in-reply-to :references; bh=0Gz4thGVVVvCsUEVvMNjI/mQC6/7L7ePi7av8IfM3Bc=; b=CJdZP9ByGg8ibwn68MaP0dNTDtgeoSljYVURaK+NUUGm4WbGC4PE5dhHLi6kiCu6/p 6u8y+VhtHOGz645c1vcz+1jdfCEtqzeH40dcIF2csbqeJ+6UpRDTGcuRUP0hd7bFb/0Z RqSEhiOEeZRM1QP0Qnqqkb1HvER4HKbYN3GdH6kUHacxMZfakpmeiD1AVG4py1S61PBQ bGsH9xDdX21l2XTJKjZg2rLxjtmJN0JvAC3ryaWG9lSdL7S7snWgpJK5kI3fM9Lq0+j5 nlYlhr8Q4x8U2yFjM/Lh2bOn+Zk9y6pyAWCoTRrrOaNTmf7J0bfPGy2nyO5wi1XBbA+l OrMw== X-Gm-Message-State: ALoCoQm0V7Tl8KxyLYkRY43hcME06BkPqr49Y+hvy4fjjDSHfA4l2l3A5ZEScWQRfH9au9gNUO8y X-Received: by 10.194.90.50 with SMTP id bt18mr14121500wjb.118.1447753461140; Tue, 17 Nov 2015 01:44:21 -0800 (PST) Received: from localhost ([78.129.251.54]) by smtp.gmail.com with ESMTPSA id i18sm23031314wmf.6.2015.11.17.01.44.18 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 17 Nov 2015 01:44:20 -0800 (PST) From: shannon.zhao@linaro.org To: ian.campbell@citrix.com, stefano.stabellini@citrix.com, keir@xen.org, jbeulich@suse.com, andrew.cooper3@citrix.com, julien.grall@citrix.com, xen-devel@lists.xen.org Date: Tue, 17 Nov 2015 17:40:21 +0800 Message-Id: <1447753261-7552-23-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1447753261-7552-1-git-send-email-shannon.zhao@linaro.org> References: <1447753261-7552-1-git-send-email-shannon.zhao@linaro.org> Cc: mark.rutland@arm.com, hangaohuai@huawei.com, ard.biesheuvel@linaro.org, shannon.zhao@linaro.org, christoffer.dall@linaro.org, peter.huangpeng@huawei.com, david.vrabel@citrix.com, zhaoshenglong@huawei.com, linux-arm-kernel@lists.infradead.org, roger.pau@citrix.com Subject: [Xen-devel] [PATCH v3 22/62] arm/gic-v3: Refactor gicv3_init into generic and dt specific parts X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion 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 From: Shannon Zhao Refactor gic-v3 related functions into dt and generic parts. This will be helpful when adding acpi support for gic-v3. Signed-off-by: Shannon Zhao --- xen/arch/arm/gic-v3.c | 95 +++++++++++++++++++++++++++------------------------ 1 file changed, 51 insertions(+), 44 deletions(-) -- 2.1.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c index 4fe0c37..bd13010 100644 --- a/xen/arch/arm/gic-v3.c +++ b/xen/arch/arm/gic-v3.c @@ -1138,62 +1138,27 @@ static int __init cmp_rdist(const void *a, const void *b) return ( l->base < r->base) ? -1 : 0; } +static paddr_t __initdata dbase = 0, cbase = 0, csize = 0, vbase = 0; + /* If the GICv3 supports GICv2, initialize it */ -static void __init gicv3_init_v2(const struct dt_device_node *node, - paddr_t dbase) +static void __init gicv3_init_v2(void) { - int res; - paddr_t cbase, csize; - paddr_t vbase, vsize; - - /* - * For GICv3 supporting GICv2, GICC and GICV base address will be - * provided. - */ - res = dt_device_get_address(node, 1 + gicv3.rdist_count, - &cbase, &csize); - if ( res ) + if ( cbase == 0 || vbase == 0 ) return; - res = dt_device_get_address(node, 1 + gicv3.rdist_count + 2, - &vbase, &vsize); - if ( res ) - return; - - /* - * We emulate a vGICv2 using a GIC CPU interface of GUEST_GICC_SIZE. - * So only support GICv2 on GICv3 when the virtual CPU interface is - * at least GUEST_GICC_SIZE. - */ - if ( vsize < GUEST_GICC_SIZE ) - { - printk(XENLOG_WARNING - "GICv3: WARNING: Not enabling support for GICv2 compat mode.\n" - "Size of GICV (%#"PRIpaddr") must at least be %#llx.\n", - vsize, GUEST_GICC_SIZE); - return; - } - printk("GICv3 compatible with GICv2 cbase %#"PRIpaddr" vbase %#"PRIpaddr"\n", cbase, vbase); vgic_v2_setup_hw(dbase, cbase, csize, vbase, 0); } -/* Set up the GIC */ -static int __init gicv3_init(void) +static void __init dt_gicv3_init(void) { struct rdist_region *rdist_regs; int res, i; uint32_t reg; const struct dt_device_node *node = gicv3_info.node; - paddr_t dbase; - - if ( !cpu_has_gicv3 ) - { - dprintk(XENLOG_ERR, "GICv3: driver requires system register support\n"); - return -ENODEV; - } + paddr_t vsize; res = dt_device_get_address(node, 0, &dbase, NULL); if ( res ) @@ -1248,6 +1213,48 @@ static int __init gicv3_init(void) panic("GICv3: Cannot find the maintenance IRQ"); gicv3_info.maintenance_irq = res; + /* + * For GICv3 supporting GICv2, GICC and GICV base address will be + * provided. + */ + res = dt_device_get_address(node, 1 + gicv3.rdist_count, + &cbase, &csize); + if ( res ) + return; + + res = dt_device_get_address(node, 1 + gicv3.rdist_count + 2, + &vbase, &vsize); + if ( res ) + return; + + /* + * We emulate a vGICv2 using a GIC CPU interface of GUEST_GICC_SIZE. + * So only support GICv2 on GICv3 when the virtual CPU interface is + * at least GUEST_GICC_SIZE. + */ + if ( vsize < GUEST_GICC_SIZE ) + { + printk(XENLOG_WARNING + "GICv3: WARNING: Not enabling support for GICv2 compat mode.\n" + "Size of GICV (%#"PRIpaddr") must at least be %#llx.\n", + vsize, GUEST_GICC_SIZE); + return; + } +} + +/* Set up the GIC */ +static int __init gicv3_init(void) +{ + int res, i; + + if ( !cpu_has_gicv3 ) + { + dprintk(XENLOG_ERR, "GICv3: driver requires system register support\n"); + return -ENODEV; + } + + dt_gicv3_init(); + for ( i = 0; i < gicv3.rdist_count; i++ ) { /* map dbase & rdist regions */ @@ -1277,7 +1284,7 @@ static int __init gicv3_init(void) vgic_v3_setup_hw(dbase, gicv3.rdist_count, gicv3.rdist_regions, gicv3.rdist_stride); - gicv3_init_v2(node, dbase); + gicv3_init_v2(); spin_lock_init(&gicv3.lock); @@ -1317,7 +1324,7 @@ static const struct gic_hw_operations gicv3_ops = { .make_hwdom_dt_node = gicv3_make_hwdom_dt_node, }; -static int __init gicv3_preinit(struct dt_device_node *node, const void *data) +static int __init dt_gicv3_preinit(struct dt_device_node *node, const void *data) { gicv3_info.hw_version = GIC_V3; gicv3_info.node = node; @@ -1335,7 +1342,7 @@ static const struct dt_device_match gicv3_dt_match[] __initconst = DT_DEVICE_START(gicv3, "GICv3", DEVICE_GIC) .dt_match = gicv3_dt_match, - .init = gicv3_preinit, + .init = dt_gicv3_preinit, DT_DEVICE_END /*