From patchwork Tue Jan 19 13:11:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Nowicki X-Patchwork-Id: 8061741 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 63F9CBEEE5 for ; Tue, 19 Jan 2016 13:14:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 44459203A0 for ; Tue, 19 Jan 2016 13:14:16 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2653F2039C for ; Tue, 19 Jan 2016 13:14:15 +0000 (UTC) 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 1aLW5a-0004Ao-8e; Tue, 19 Jan 2016 13:12:50 +0000 Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aLW4e-0003B3-UI for linux-arm-kernel@lists.infradead.org; Tue, 19 Jan 2016 13:11:57 +0000 Received: by mail-wm0-x234.google.com with SMTP id r129so89541049wmr.0 for ; Tue, 19 Jan 2016 05:11:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jBlEVtC9jhfkI53oEcAxhy5pfcmw4B1ONi9LolKdplY=; b=qIZwueUXvAUVSzBZQP//ECqxO8B7Q7b0qk8tDgLyPRlGt9HZU9UYocRfwxejWvxWsX gWsyrN9ESqa+ROYuGs/da8HFOt5E+RnJNCNLadhKJvFk2v4XmZnAFbnvPelDCpsR96tI i2spreb5SBQVYrIp4fLxof8Mf1JJlg8bEzS0n1flhKe2Lbz3HzVR2TLXmPXXfbkB/oHE 4gEUENmw5aqn0fmndYh/kwKbE88P7GTIuA1suuev7mAaEG3i/f92FEExhHD1B3c8ivG1 Ewe/1VSyfVJk/2cpNnM7NA+NaNgv4UzpZtm0069i6EpDCH1Vg1WEazDZVIZYnWOOpoMH zreA== 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=jBlEVtC9jhfkI53oEcAxhy5pfcmw4B1ONi9LolKdplY=; b=WAIladeCdnMhGwGojB/MTAFRO3mVcmNqk6dxHymQR0wtEVvsWjn5a8LOoRiYFlD6+8 14pEk4Jx0R+cvar2ew7/E0By4RrWIBce9eYsVuJf9zUKEl29HE8Sb3u8oznQNzmEdFX1 zd8/YKrMPabqsdeauOx9DkUAvdhQIR4pnvFko7UnfC6A1mdFJVTFxVHIYQRWgC8tgjm2 UO0XrupKFm/r5IzBI3jFTNpJmEAWBFReEPv9u/L4kEaodmWVv/wsoyzGaHQ9p0EHufe0 0t2dYEQyEp24X8poJUCVve23hgbySb0V44ljNCOcjZmPeWRcm0u1yBM/HJhJA5hwRzb7 8blQ== X-Gm-Message-State: ALoCoQnUsGC5zGIgZz0/+dV62myyOjGtnWlnl65dm1Lrf60EnQ9W1wVqE5YyUIEP7FbncS405SFtWq+qCNzb5CutnTrkS0Nstw== X-Received: by 10.194.120.134 with SMTP id lc6mr35557219wjb.130.1453209094260; Tue, 19 Jan 2016 05:11:34 -0800 (PST) Received: from tn-HP-4.semihalf.local ([80.82.22.190]) by smtp.gmail.com with ESMTPSA id w194sm17762623wmd.0.2016.01.19.05.11.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Jan 2016 05:11:33 -0800 (PST) From: Tomasz Nowicki To: marc.zyngier@arm.com, tglx@linutronix.de, jason@lakedaemon.net, rjw@rjwysocki.net, lorenzo.pieralisi@arm.com, robert.richter@caviumnetworks.com, shijie.huang@arm.com, guohanjun@huawei.com, Suravee.Suthikulpanit@amd.com Subject: [PATCH V3 06/10] irqchip, GICv3, ITS: Refator ITS dt init code to prepare for ACPI. Date: Tue, 19 Jan 2016 14:11:19 +0100 Message-Id: <1453209083-3358-7-git-send-email-tn@semihalf.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1453209083-3358-1-git-send-email-tn@semihalf.com> References: <1453209083-3358-1-git-send-email-tn@semihalf.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160119_051153_490192_D13F2C39 X-CRM114-Status: GOOD ( 17.87 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: graeme.gregory@linaro.org, Catalin.Marinas@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, hanjun.guo@linaro.org, ddaney.cavm@gmail.com, Tomasz Nowicki , mw@semihalf.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Similarly to GICv3 core, we need to extract common code before adding ACPI support. No functional changes. Signed-off-by: Hanjun Guo Signed-off-by: Tomasz Nowicki --- drivers/irqchip/irq-gic-v3-its.c | 82 +++++++++++++++++++++++--------------- drivers/irqchip/irq-gic-v3.c | 6 +-- include/linux/irqchip/arm-gic-v3.h | 2 +- 3 files changed, 52 insertions(+), 38 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 2bbed18..fecb7a6 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -813,7 +813,7 @@ static void its_free_tables(struct its_node *its) } } -static int its_alloc_tables(const char *node_name, struct its_node *its) +static int its_alloc_tables(struct its_node *its) { int err; int i; @@ -868,8 +868,8 @@ static int its_alloc_tables(const char *node_name, struct its_node *its) order); if (order >= MAX_ORDER) { order = MAX_ORDER - 1; - pr_warn("%s: Device Table too large, reduce its page order to %u\n", - node_name, order); + pr_warn("ITS@0x%lx: Device Table too large, reduce its page order to %u\n", + its->phys_base, order); } } @@ -878,8 +878,8 @@ static int its_alloc_tables(const char *node_name, struct its_node *its) if (alloc_pages > GITS_BASER_PAGES_MAX) { alloc_pages = GITS_BASER_PAGES_MAX; order = get_order(GITS_BASER_PAGES_MAX * psz); - pr_warn("%s: Device Table too large, reduce its page order to %u (%u pages)\n", - node_name, order, alloc_pages); + pr_warn("ITS@0x%lx: Device Table too large, reduce its page order to %u (%u pages)\n", + its->phys_base, order, alloc_pages); } base = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, order); @@ -948,8 +948,8 @@ retry_baser: } if (val != tmp) { - pr_err("ITS: %s: GITS_BASER%d doesn't stick: %lx %lx\n", - node_name, i, + pr_err("ITS@0x%lx: GITS_BASER%d doesn't stick: %lx %lx\n", + its->phys_base, i, (unsigned long) val, (unsigned long) tmp); err = -ENXIO; goto out_free; @@ -1424,10 +1424,11 @@ static void its_enable_quirks(struct its_node *its) gic_enable_quirks(iidr, its_quirks, its); } -static int __init its_probe(struct device_node *node, - struct irq_domain *parent) +static int __init its_probe_one(phys_addr_t phys_base, unsigned long size, + struct irq_domain *parent, + bool is_msi_controller, + struct fwnode_handle *handler) { - struct resource res; struct its_node *its; void __iomem *its_base; struct irq_domain *inner_domain; @@ -1435,33 +1436,26 @@ static int __init its_probe(struct device_node *node, u64 baser, tmp; int err; - err = of_address_to_resource(node, 0, &res); - if (err) { - pr_warn("%s: no regs?\n", node->full_name); - return -ENXIO; - } - - its_base = ioremap(res.start, resource_size(&res)); + its_base = ioremap(phys_base, size); if (!its_base) { - pr_warn("%s: unable to map registers\n", node->full_name); + pr_warn("Unable to map ITS registers\n"); return -ENOMEM; } val = readl_relaxed(its_base + GITS_PIDR2) & GIC_PIDR2_ARCH_MASK; if (val != 0x30 && val != 0x40) { - pr_warn("%s: no ITS detected, giving up\n", node->full_name); + pr_warn("No ITS detected, giving up\n"); err = -ENODEV; goto out_unmap; } err = its_force_quiescent(its_base); if (err) { - pr_warn("%s: failed to quiesce, giving up\n", - node->full_name); + pr_warn("Failed to quiesce, giving up\n"); goto out_unmap; } - pr_info("ITS: %s\n", node->full_name); + pr_info("ITS@0x%lx\n", (long)phys_base); its = kzalloc(sizeof(*its), GFP_KERNEL); if (!its) { @@ -1473,7 +1467,7 @@ static int __init its_probe(struct device_node *node, INIT_LIST_HEAD(&its->entry); INIT_LIST_HEAD(&its->its_device_list); its->base = its_base; - its->phys_base = res.start; + its->phys_base = phys_base; its->ite_size = ((readl_relaxed(its_base + GITS_TYPER) >> 4) & 0xf) + 1; its->cmd_base = kzalloc(ITS_CMD_QUEUE_SZ, GFP_KERNEL); @@ -1485,7 +1479,7 @@ static int __init its_probe(struct device_node *node, its_enable_quirks(its); - err = its_alloc_tables(node->full_name, its); + err = its_alloc_tables(its); if (err) goto out_free_cmd; @@ -1521,7 +1515,7 @@ static int __init its_probe(struct device_node *node, writeq_relaxed(0, its->base + GITS_CWRITER); writel_relaxed(GITS_CTLR_ENABLE, its->base + GITS_CTLR); - if (of_property_read_bool(node, "msi-controller")) { + if (is_msi_controller) { struct msi_domain_info *info; info = kzalloc(sizeof(*info), GFP_KERNEL); @@ -1530,7 +1524,8 @@ static int __init its_probe(struct device_node *node, goto out_free_tables; } - inner_domain = irq_domain_add_tree(node, &its_domain_ops, its); + inner_domain = irq_domain_create_tree(handler, &its_domain_ops, + its); if (!inner_domain) { err = -ENOMEM; kfree(info); @@ -1558,10 +1553,28 @@ out_free_its: kfree(its); out_unmap: iounmap(its_base); - pr_err("ITS: failed probing %s (%d)\n", node->full_name, err); + pr_err("ITS@0x%lx: failed probing (%d)\n", (long)phys_base, err); return err; } +static int __init +its_of_probe(struct device_node *node, struct irq_domain *parent) +{ + struct resource res; + bool is_msi_controller = false; + + if (of_address_to_resource(node, 0, &res)) { + pr_warn("%s: no regs?\n", node->full_name); + return -ENXIO; + } + + if (of_property_read_bool(node, "msi-controller")) + is_msi_controller = true; + + return its_probe_one(res.start, resource_size(&res), parent, + is_msi_controller, &node->fwnode); +} + static bool gic_rdists_supports_plpis(void) { return !!(readl_relaxed(gic_data_rdist_rd_base() + GICR_TYPER) & GICR_TYPER_PLPIS); @@ -1586,14 +1599,17 @@ static struct of_device_id its_device_id[] = { {}, }; -int __init its_init(struct device_node *node, struct rdists *rdists, - struct irq_domain *parent_domain) +int __init its_init(struct fwnode_handle *handle, struct rdists *rdists, + struct irq_domain *parent_domain) { - struct device_node *np; + struct device_node *np, *of_node; - for (np = of_find_matching_node(node, its_device_id); np; - np = of_find_matching_node(np, its_device_id)) { - its_probe(np, parent_domain); + of_node = to_of_node(handle); + if (of_node) { + for (np = of_find_matching_node(of_node, its_device_id); np; + np = of_find_matching_node(np, its_device_id)) { + its_of_probe(np, parent_domain); + } } if (list_empty(&its_nodes)) { diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index dd16a60..995b7251 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -832,7 +832,6 @@ static int __init gic_init_bases(void __iomem *dist_base, u64 redist_stride, struct fwnode_handle *handle) { - struct device_node *node; u32 typer; int gic_irqs; int err; @@ -872,10 +871,9 @@ static int __init gic_init_bases(void __iomem *dist_base, set_handle_irq(gic_handle_irq); - node = to_of_node(handle); if (IS_ENABLED(CONFIG_ARM_GIC_V3_ITS) && gic_dist_supports_lpis() && - node) /* Temp hack to prevent ITS init for ACPI */ - its_init(node, &gic_data.rdists, gic_data.domain); + to_of_node(handle)) /* Temp hack to prevent ITS init for ACPI */ + its_init(handle, &gic_data.rdists, gic_data.domain); gic_smp_init(); gic_dist_init(); diff --git a/include/linux/irqchip/arm-gic-v3.h b/include/linux/irqchip/arm-gic-v3.h index d5d798b..a40ed7d 100644 --- a/include/linux/irqchip/arm-gic-v3.h +++ b/include/linux/irqchip/arm-gic-v3.h @@ -332,7 +332,7 @@ struct rdists { struct irq_domain; struct device_node; int its_cpu_init(void); -int its_init(struct device_node *node, struct rdists *rdists, +int its_init(struct fwnode_handle *handle, struct rdists *rdists, struct irq_domain *domain); static inline bool gic_enable_sre(void)