From patchwork Mon Nov 3 16:46:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frediano Ziglio X-Patchwork-Id: 40044 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 81D2A21894 for ; Mon, 3 Nov 2014 16:49:22 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id h11sf2982614wiw.11 for ; Mon, 03 Nov 2014 08:49:21 -0800 (PST) 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:in-reply-to :references:mime-version:cc:subject:precedence:list-id :list-unsubscribe:list-post:list-help:list-subscribe:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:list-archive:content-type:content-transfer-encoding; bh=N/4RSACC7s1jVGdohMGvhhtw1gHAg3K/g1UHBcd/4YY=; b=FhMhfbAaRI83R82HMPtKQF3z+LI6haKxh7bKwC7JwoiDfG57TX25aAorOdru+TKDR/ BF/J0vzzpIjR/SwZ0dPw0l9LbtUEbCLIYOy5GENG5YXbX1fn0ZAMSieZQOEs636jyR9z sUB7C6NtfwFGZPe+3Nni2To1IjeCmeLSCxaX8/no9MdQ5GwEbNV/baJHzR174JnH6uvp sboWxOq1UCFhEyZHREYdvN7BTJji3TRH8dL32j8DN2Vph2jr8ViNPfrfbCX6XSu5k684 CplE3u54RNrjbcdguosEo676bZ/2mh7ifbYL0yqBhq0D8P4Bl/AGCd+s9v4d2FvUdXZT Wb8w== X-Gm-Message-State: ALoCoQm/ygZpxgPA+offCcrT4pecjf4mpHnLclOsM/CkVi67V/0y6ErChWk7E9g9d/A1nyTx69lS X-Received: by 10.180.39.66 with SMTP id n2mr3094348wik.6.1415033361761; Mon, 03 Nov 2014 08:49:21 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.87.4 with SMTP id t4ls787831laz.33.gmail; Mon, 03 Nov 2014 08:49:21 -0800 (PST) X-Received: by 10.152.29.8 with SMTP id f8mr52335628lah.56.1415033361478; Mon, 03 Nov 2014 08:49:21 -0800 (PST) Received: from mail-la0-f42.google.com (mail-la0-f42.google.com. [209.85.215.42]) by mx.google.com with ESMTPS id d5si33215453lag.46.2014.11.03.08.49.21 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 03 Nov 2014 08:49:21 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) client-ip=209.85.215.42; Received: by mail-la0-f42.google.com with SMTP id gq15so9930098lab.15 for ; Mon, 03 Nov 2014 08:49:21 -0800 (PST) X-Received: by 10.152.87.98 with SMTP id w2mr51619610laz.27.1415033361323; Mon, 03 Nov 2014 08:49:21 -0800 (PST) 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.112.141.34 with SMTP id rl2csp19903lbb; Mon, 3 Nov 2014 08:49:20 -0800 (PST) X-Received: by 10.220.94.70 with SMTP id y6mr1529347vcm.27.1415033358778; Mon, 03 Nov 2014 08:49:18 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id a11si3508734vcv.41.2014.11.03.08.49.18 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 03 Nov 2014 08:49:18 -0800 (PST) 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 1XlKn2-0000TI-0Q; Mon, 03 Nov 2014 16:47:36 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XlKn0-0000Rq-7a for xen-devel@lists.xen.org; Mon, 03 Nov 2014 16:47:34 +0000 Received: from [193.109.254.147] by server-5.bemta-14.messagelabs.com id 5E/11-08051-5A1B7545; Mon, 03 Nov 2014 16:47:33 +0000 X-Env-Sender: frediano.ziglio@huawei.com X-Msg-Ref: server-12.tower-27.messagelabs.com!1415033248!12289172!1 X-Originating-IP: [119.145.14.66] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTE5LjE0NS4xNC42NiA9PiA4NTI3\n X-StarScan-Received: X-StarScan-Version: 6.12.4; banners=-,-,- X-VirusChecked: Checked Received: (qmail 3377 invoked from network); 3 Nov 2014 16:47:32 -0000 Received: from szxga03-in.huawei.com (HELO szxga03-in.huawei.com) (119.145.14.66) by server-12.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 3 Nov 2014 16:47:32 -0000 Received: from 172.24.2.119 (EHLO szxeml424-hub.china.huawei.com) ([172.24.2.119]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id AWO48421; Tue, 04 Nov 2014 00:47:27 +0800 (CST) Received: from localhost.localdomain (10.47.77.41) by szxeml424-hub.china.huawei.com (10.82.67.163) with Microsoft SMTP Server id 14.3.158.1; Tue, 4 Nov 2014 00:47:17 +0800 From: Frediano Ziglio To: Ian Campbell , Stefano Stabellini , Tim Deegan , Julien Grall , Date: Mon, 3 Nov 2014 16:46:32 +0000 Message-ID: <1415033196-30529-4-git-send-email-frediano.ziglio@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1415033196-30529-1-git-send-email-frediano.ziglio@huawei.com> References: <1415033196-30529-1-git-send-email-frediano.ziglio@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.77.41] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A02020A.5457B19F.02CB, ss=1, re=0.001, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 6e285cda9b082c24c7709211b7dfa722 Cc: zoltan.kiss@huawei.com, xen-devel@lists.xen.org Subject: [Xen-devel] [PATCH v2 3/7] xen/arm: Make gic-v2 code handle hip04-d01 platform 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: , 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: frediano.ziglio@huawei.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 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: The GIC in this platform is mainly compatible with the standard GICv2 beside: - ITARGET is extended to 16 bit to support 16 CPUs; - SGI mask is extended to support 16 CPUs; - maximum supported interrupt is 510. Signed-off-by: Frediano Ziglio Signed-off-by: Zoltan Kiss --- xen/arch/arm/gic-v2.c | 89 +++++++++++++++++++++++++++++++++++++++-------- xen/arch/arm/gic.c | 3 +- xen/include/asm-arm/gic.h | 4 ++- 3 files changed, 80 insertions(+), 16 deletions(-) diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c index faad1ff..9461fe3 100644 --- a/xen/arch/arm/gic-v2.c +++ b/xen/arch/arm/gic-v2.c @@ -79,16 +79,23 @@ static struct gic_info gicv2_info; * logical CPU numbering. Let's use mapping as returned by the GIC * itself */ -static DEFINE_PER_CPU(u8, gic_cpu_id); +static DEFINE_PER_CPU(u16, gic_cpu_id); /* Maximum cpu interface per GIC */ -#define NR_GIC_CPU_IF 8 +static unsigned int nr_gic_cpu_if = 8; +static unsigned int gicd_sgi_target_shift = GICD_SGI_TARGET_SHIFT; +static unsigned int gic_cpu_mask = 0xff; static inline void writeb_gicd(uint8_t val, unsigned int offset) { writeb_relaxed(val, gicv2.map_dbase + offset); } +static inline void writew_gicd(uint16_t val, unsigned int offset) +{ + writew_relaxed(val, gicv2.map_dbase + offset); +} + static inline void writel_gicd(uint32_t val, unsigned int offset) { writel_relaxed(val, gicv2.map_dbase + offset); @@ -132,7 +139,7 @@ static unsigned int gicv2_cpu_mask(const cpumask_t *cpumask) cpumask_and(&possible_mask, cpumask, &cpu_possible_map); for_each_cpu( cpu, &possible_mask ) { - ASSERT(cpu < NR_GIC_CPU_IF); + ASSERT(cpu < nr_gic_cpu_if); mask |= per_cpu(gic_cpu_id, cpu); } @@ -203,6 +210,15 @@ static unsigned int gicv2_read_irq(void) return (readl_gicc(GICC_IAR) & GICC_IA_IRQ); } +/* Set target CPU mask (RAZ/WI on uniprocessor) */ +static void gicv2_set_irq_mask(int irq, unsigned int mask) +{ + if ( nr_gic_cpu_if == 16 ) + writew_gicd(mask, GICD_ITARGETSR + irq * 2); + else + writeb_gicd(mask, GICD_ITARGETSR + irq); +} + /* * needs to be called with a valid cpu_mask, ie each cpu in the mask has * already called gic_cpu_init @@ -230,7 +246,7 @@ static void gicv2_set_irq_properties(struct irq_desc *desc, writel_gicd(cfg, GICD_ICFGR + (irq / 16) * 4); /* Set target CPU mask (RAZ/WI on uniprocessor) */ - writeb_gicd(mask, GICD_ITARGETSR + irq); + gicv2_set_irq_mask(irq, mask); /* Set priority */ writeb_gicd(priority, GICD_IPRIORITYR + irq); @@ -244,16 +260,21 @@ static void __init gicv2_dist_init(void) uint32_t gic_cpus; int i; - cpumask = readl_gicd(GICD_ITARGETSR) & 0xff; - cpumask |= cpumask << 8; - cpumask |= cpumask << 16; + cpumask = readl_gicd(GICD_ITARGETSR) & gic_cpu_mask; /* Disable the distributor */ writel_gicd(0, GICD_CTLR); type = readl_gicd(GICD_TYPER); gicv2_info.nr_lines = 32 * ((type & GICD_TYPE_LINES) + 1); - gic_cpus = 1 + ((type & GICD_TYPE_CPUS) >> 5); + if ( nr_gic_cpu_if == 16 ) + { + gic_cpus = 16; + } + else + { + gic_cpus = 1 + ((type & GICD_TYPE_CPUS) >> 5); + } printk("GICv2: %d lines, %d cpu%s%s (IID %8.8x).\n", gicv2_info.nr_lines, gic_cpus, (gic_cpus == 1) ? "" : "s", (type & GICD_TYPE_SEC) ? ", secure" : "", @@ -264,8 +285,19 @@ static void __init gicv2_dist_init(void) writel_gicd(0x0, GICD_ICFGR + (i / 16) * 4); /* Route all global IRQs to this CPU */ - for ( i = 32; i < gicv2_info.nr_lines; i += 4 ) - writel_gicd(cpumask, GICD_ITARGETSR + (i / 4) * 4); + if ( nr_gic_cpu_if == 16 ) + { + cpumask |= cpumask << 16; + for ( i = 32; i < gicv2_info.nr_lines; i += 2 ) + writel_gicd(cpumask, GICD_ITARGETSR + (i / 2) * 4); + } + else + { + cpumask |= cpumask << 8; + cpumask |= cpumask << 16; + for ( i = 32; i < gicv2_info.nr_lines; i += 4 ) + writel_gicd(cpumask, GICD_ITARGETSR + (i / 4) * 4); + } /* Default priority for global interrupts */ for ( i = 32; i < gicv2_info.nr_lines; i += 4 ) @@ -285,7 +317,7 @@ static void __cpuinit gicv2_cpu_init(void) { int i; - this_cpu(gic_cpu_id) = readl_gicd(GICD_ITARGETSR) & 0xff; + this_cpu(gic_cpu_id) = readl_gicd(GICD_ITARGETSR) & gic_cpu_mask; /* The first 32 interrupts (PPI and SGI) are banked per-cpu, so * even though they are controlled with GICD registers, they must @@ -366,7 +398,7 @@ static void gicv2_send_SGI(enum gic_sgi sgi, enum gic_sgi_mode irqmode, cpumask_and(&online_mask, cpu_mask, &cpu_online_map); mask = gicv2_cpu_mask(&online_mask); writel_gicd(GICD_SGI_TARGET_LIST | - (mask << GICD_SGI_TARGET_SHIFT) | sgi, + (mask << gicd_sgi_target_shift) | sgi, GICD_SGIR); break; default: @@ -581,7 +613,7 @@ static void gicv2_irq_set_affinity(struct irq_desc *desc, const cpumask_t *cpu_m mask = gicv2_cpu_mask(cpu_mask); /* Set target CPU mask (RAZ/WI on uniprocessor) */ - writeb_gicd(mask, GICD_ITARGETSR + desc->irq); + gicv2_set_irq_mask(desc->irq, mask); spin_unlock(&gicv2.lock); } @@ -684,12 +716,19 @@ 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_init_common(struct dt_device_node *node, const void *data, bool hip04) { int res; dt_device_set_used_by(node, DOMID_XEN); + if ( hip04 ) + { + nr_gic_cpu_if = 16; + gicd_sgi_target_shift = 8; + gic_cpu_mask = 0xffff; + } + res = dt_device_get_address(node, 0, &gicv2.dbase, NULL); if ( res || !gicv2.dbase || (gicv2.dbase & ~PAGE_MASK) ) panic("GICv2: Cannot find a valid address for the distributor"); @@ -764,6 +803,16 @@ static int __init gicv2_init(struct dt_device_node *node, const void *data) return 0; } +static int __init gicv2_init(struct dt_device_node *node, const void *data) +{ + return gicv2_init_common(node, data, false); +} + +static int __init hip04_gicv2_init(struct dt_device_node *node, const void *data) +{ + return gicv2_init_common(node, data, true); +} + static const char * const gicv2_dt_compat[] __initconst = { DT_COMPAT_GIC_CORTEX_A15, @@ -777,6 +826,18 @@ DT_DEVICE_START(gicv2, "GICv2:", DEVICE_GIC) .init = gicv2_init, DT_DEVICE_END +static const char * const hip04_gicv2_dt_compat[] __initconst = +{ + DT_COMPAT_GIC_HIP04, + NULL +}; + +DT_DEVICE_START(hip04_gicv2, "GICv2:", DEVICE_GIC) + .compatible = hip04_gicv2_dt_compat, + .init = hip04_gicv2_init, +DT_DEVICE_END + + /* * Local variables: * mode: C diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index 70d10d6..8050a65 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -563,12 +563,13 @@ static void do_sgi(struct cpu_user_regs *regs, enum gic_sgi sgi) void gic_interrupt(struct cpu_user_regs *regs, int is_fiq) { unsigned int irq; + unsigned int max_irq = gic_hw_ops->info->nr_lines; do { /* Reading IRQ will ACK it */ irq = gic_hw_ops->read_irq(); - if ( likely(irq >= 16 && irq < 1021) ) + if ( likely(irq >= 16 && irq < max_irq) ) { local_irq_enable(); do_IRQ(regs, irq, is_fiq); diff --git a/xen/include/asm-arm/gic.h b/xen/include/asm-arm/gic.h index 187dc46..5adb628 100644 --- a/xen/include/asm-arm/gic.h +++ b/xen/include/asm-arm/gic.h @@ -155,10 +155,12 @@ #define DT_COMPAT_GIC_400 "arm,gic-400" #define DT_COMPAT_GIC_CORTEX_A15 "arm,cortex-a15-gic" #define DT_COMPAT_GIC_CORTEX_A7 "arm,cortex-a7-gic" +#define DT_COMPAT_GIC_HIP04 "hisilicon,hip04-gic" #define DT_MATCH_GIC_V2 DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_CORTEX_A15), \ DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_CORTEX_A7), \ - DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_400) + DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_400), \ + DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_HIP04) #define DT_COMPAT_GIC_V3 "arm,gic-v3"