From patchwork Thu Oct 9 14:29:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yingjoe Chen X-Patchwork-Id: 38522 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f71.google.com (mail-ee0-f71.google.com [74.125.83.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A7763202E7 for ; Thu, 9 Oct 2014 14:33:14 +0000 (UTC) Received: by mail-ee0-f71.google.com with SMTP id d17sf1057729eek.2 for ; Thu, 09 Oct 2014 07:33:13 -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:subject:date:message-id :in-reply-to:references:mime-version:cc:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:content-type :content-transfer-encoding; bh=zbMX8TRekJzVoP0114Wb8BybmMGK4D0tng8jW390xpY=; b=kQSk3etHM23J6uE0sf+jlk/vbmkIXYdNDktCQO6iS4I7IvFLzqdpiwE/WyDARxlN9L XbABjSmuPhPSBlXikh0WgYeA4IGfTpVnCI2aBy0ZJEa9Y535trYtl/yCTQw/yjOXNkbx KlZMOeoS6Us8O3bVY3AV5oJjmxP43tRX9RnI/DZEsXapaamZYMT55z6LURvRA82RqRWy zTqUPl5RZYHDzRR7EQ1Kp6VCOtgC9Om7Ue618BI7pfoc0kBZqW3isJEqz395p5FVaYox NUyL7ix1DUTTzJnuNAK1IUFCgMFYB09P2UfPXJkQnEe0+A0Qz+kt012CBrXiw1UCO7X2 hCXw== X-Gm-Message-State: ALoCoQm/0jQtI3p1mSYmKfxMMSL9FIwNFs8e89dJnOsRxwLE6AuQaGatwHAGVeCSysVJOpmFIRx8 X-Received: by 10.112.34.147 with SMTP id z19mr283870lbi.16.1412865193758; Thu, 09 Oct 2014 07:33:13 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.23.227 with SMTP id p3ls190348laf.39.gmail; Thu, 09 Oct 2014 07:33:13 -0700 (PDT) X-Received: by 10.152.206.35 with SMTP id ll3mr19003494lac.88.1412865193569; Thu, 09 Oct 2014 07:33:13 -0700 (PDT) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com [209.85.215.54]) by mx.google.com with ESMTPS id pt7si4485372lbb.120.2014.10.09.07.33.13 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 09 Oct 2014 07:33:13 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) client-ip=209.85.215.54; Received: by mail-la0-f54.google.com with SMTP id gm9so1295893lab.41 for ; Thu, 09 Oct 2014 07:33:13 -0700 (PDT) X-Received: by 10.112.164.71 with SMTP id yo7mr18212994lbb.73.1412865190426; Thu, 09 Oct 2014 07:33:10 -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.112.84.229 with SMTP id c5csp259317lbz; Thu, 9 Oct 2014 07:33:09 -0700 (PDT) X-Received: by 10.202.69.196 with SMTP id s187mr1899628oia.18.1412865188674; Thu, 09 Oct 2014 07:33:08 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id l63si1109876oif.27.2014.10.09.07.33.08 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Oct 2014 07:33:08 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XcEkd-0004qS-Ir; Thu, 09 Oct 2014 14:31:31 +0000 Received: from [210.61.82.184] (helo=mailgw02.mediatek.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XcEji-0004EU-VG for linux-arm-kernel@lists.infradead.org; Thu, 09 Oct 2014 14:30:36 +0000 X-Listener-Flag: 11101 Received: from mtkhts09.mediatek.inc [(172.21.101.70)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 202423969; Thu, 09 Oct 2014 22:30:10 +0800 Received: from mtksdtcf02.mediatek.inc (10.21.12.142) by mtkhts09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 14.3.181.6; Thu, 9 Oct 2014 22:30:04 +0800 From: Joe.C To: , Rob Herring , Thomas Gleixner , Jiang Liu , Marc Zyngier , Mark Rutland Subject: [PATCH v3 3/7] irqchip: gic: Support hierarchy irq domain. Date: Thu, 9 Oct 2014 22:29:36 +0800 Message-ID: <1412864980-20273-4-git-send-email-yingjoe.chen@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1412864980-20273-1-git-send-email-yingjoe.chen@mediatek.com> References: <1412864980-20273-1-git-send-email-yingjoe.chen@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141009_073035_487980_D0A85DE5 X-CRM114-Status: GOOD ( 17.60 ) X-Spam-Score: 1.3 (+) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (1.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS Cc: Benjamin Herrenschmidt , Sricharan R , Florian Fainelli , Russell King , yingjoe.chen@gmail.com, yh.chen@mediatek.com, nathan.chung@mediatek.com, Grant Likely , "Joe.C" , Arnd Bergmann , devicetree@vger.kernel.org, Jason Cooper , Pawel Moll , Matt Porter , Marc Carino , Matthias Brugger , eddie.huang@mediatek.com, linux-arm-kernel@lists.infradead.org, srv_heupstream@mediatek.com, hc.yen@mediatek.com, linux-kernel@vger.kernel.org, Santosh Shilimkar , Sascha Hauer , Olof Johansson X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: yingjoe.chen@mediatek.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.54 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 From: "Joe.C" Add support to use gic as a parent for stacked irq domain. Signed-off-by: Joe.C --- drivers/irqchip/irq-gic.c | 56 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 8 deletions(-) diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c index dda6dbc..17f5aa6 100644 --- a/drivers/irqchip/irq-gic.c +++ b/drivers/irqchip/irq-gic.c @@ -767,19 +767,17 @@ void __init gic_init_physaddr(struct device_node *node) static int gic_irq_domain_map(struct irq_domain *d, unsigned int irq, irq_hw_number_t hw) { + irq_domain_set_hwirq_and_chip(d, irq, hw, &gic_chip, d->host_data); if (hw < 32) { irq_set_percpu_devid(irq); - irq_set_chip_and_handler(irq, &gic_chip, - handle_percpu_devid_irq); + irq_set_handler(irq, handle_percpu_devid_irq); set_irq_flags(irq, IRQF_VALID | IRQF_NOAUTOEN); } else { - irq_set_chip_and_handler(irq, &gic_chip, - handle_fasteoi_irq); + irq_set_handler(irq, handle_fasteoi_irq); set_irq_flags(irq, IRQF_VALID | IRQF_PROBE); gic_routable_irq_domain_ops->map(d, irq, hw); } - irq_set_chip_data(irq, d->host_data); return 0; } @@ -795,8 +793,6 @@ static int gic_irq_domain_xlate(struct irq_domain *d, { unsigned long ret = 0; - if (d->of_node != controller) - return -EINVAL; if (intsize < 3) return -EINVAL; @@ -839,6 +835,46 @@ static struct notifier_block gic_cpu_notifier = { }; #endif + +#ifdef CONFIG_IRQ_DOMAIN_HIERARCHY +static int gic_irq_domain_alloc(struct irq_domain *domain, unsigned int virq, + unsigned int nr_irqs, void *arg) +{ + int i, ret; + irq_hw_number_t hwirq; + unsigned int type = IRQ_TYPE_NONE; + struct of_phandle_args *irq_data = arg; + + ret = gic_irq_domain_xlate(domain, irq_data->np, irq_data->args, + irq_data->args_count, &hwirq, &type); + if (ret) + return ret; + + for (i = 0; i < nr_irqs; i++) + gic_irq_domain_map(domain, virq+i, hwirq+i); + + return 0; +} + +static void gic_irq_domain_free(struct irq_domain *domain, unsigned int virq, + unsigned int nr_irqs) +{ + int i; + + for (i = 0; i < nr_irqs; i++) { + irq_set_handler(virq + i, NULL); + irq_domain_set_hwirq_and_chip(domain, virq + i, 0, NULL, NULL); + } +} + +static const struct irq_domain_ops gic_irq_domain_hierarchy_ops = { + .alloc = gic_irq_domain_alloc, + .free = gic_irq_domain_free, +}; +#else +#define gic_irq_domain_hierarchy_ops 0 +#endif /* CONFIG_IRQ_DOMAIN_HIERARCHY */ + static const struct irq_domain_ops gic_irq_domain_ops = { .map = gic_irq_domain_map, .unmap = gic_irq_domain_unmap, @@ -952,7 +988,11 @@ void __init gic_init_bases(unsigned int gic_nr, int irq_start, gic_irqs -= hwirq_base; /* calculate # of irqs to allocate */ - if (of_property_read_u32(node, "arm,routable-irqs", + if (IS_ENABLED(CONFIG_IRQ_DOMAIN_HIERARCHY) && + of_find_property(node, "arm,irq-domain-hierarchy", NULL)) + gic->domain = irq_domain_add_linear(node, gic_irqs, + &gic_irq_domain_hierarchy_ops, gic); + else if (of_property_read_u32(node, "arm,routable-irqs", &nr_routable_irqs)) { irq_base = irq_alloc_descs(irq_start, 16, gic_irqs, numa_node_id());