Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932305AbdCFPnF (ORCPT ); Mon, 6 Mar 2017 10:43:05 -0500 Received: from mail-by2nam03on0049.outbound.protection.outlook.com ([104.47.42.49]:62048 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753601AbdCFPm5 (ORCPT ); Mon, 6 Mar 2017 10:42:57 -0500 Authentication-Results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=cavium.com; From: Robert Richter To: Marc Zyngier Cc: Thomas Gleixner , Jason Cooper , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Robert Richter Subject: [PATCH v2 3/8] irqchip/gic-v3-its: Split probing from its node initialization Date: Mon, 6 Mar 2017 13:57:34 +0100 Message-Id: <20170306125739.19445-4-rrichter@cavium.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170306125739.19445-1-rrichter@cavium.com> References: <20170306125739.19445-1-rrichter@cavium.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [92.224.60.20] X-ClientProxiedBy: VI1PR0501CA0018.eurprd05.prod.outlook.com (10.172.9.156) To SN1PR07MB2351.namprd07.prod.outlook.com (10.169.127.17) X-MS-Office365-Filtering-Correlation-Id: b608b2a8-a510-4c14-0ac0-08d464907f7f X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:SN1PR07MB2351; X-Microsoft-Exchange-Diagnostics: 1;SN1PR07MB2351;3:iMOerSRCeoYLEw2uboN/w2vBsxKWbS6PrTmJTTOTx4/cAyN85mhluvqJItTYjAuofcv8vAIYHSKnCe2BTYDhwARNWOz+HFRHihfePmdZoaKE/f6pJiOnmaQpu4IDbkjtgEobj6w/VFsgOjaM0QT9F8iBdpVj3R59BGtsbWe0VqFsDV+aW4buyZ1yjj2q0aNuaEJgcwnFlRHuit8rvoYnE9Gh0UhhWECzCER5RihLipyV2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1toNFFDPtJQIxbmcCm+H48EWRXA+pQeMO4l8lk+NkbHh+NFp5FBy9dZVt77SFuZiK9RNleGDW+jpXayBfZV2EXN9LIYhuJMZ4oAHAEdM0o2oLnBp2CHMIgZ4IC7Cdv6fpZL73Dwd6plLTPyNI/nAB+KPxYCrzj2WLmzBUa+9Ab+K4q1FrqfWenO5pnvU6SG1hnhmYsT2hgn/JwHt4/SV6eRp3vUIZhtUrg1Oj4/RZZcKlUhNw55t7r06NmNbLurX86J6KVq9LoFgoQPuj9g X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6041248)(20161123562025)(20161123564025)(20161123555025)(20161123558025)(20161123560025)(6072148);SRVR:SN1PR07MB2351;BCL:0;PCL:0;RULEID:;SRVR:SN1PR07MB2351; X-Microsoft-Exchange-Diagnostics: 1;SN1PR07MB2351;4:cuwYwxBHkvWdV4Z76kMVSBldh7hj0YtYmkEUAdvS3L0D8SXjbZRVEv2AsVYa3c6C4DOu4G9rViRLk9zDSX+8kVE1zm0qKQu6oLwnHjjxiHGOKzeD/70UM/wFg1VroWBopmg8zIAmP54uyPB4ZZdDyTVKK9NqwvnExJwLVtY8uJSR0v61LvLF1Dmg3FbvM1K/HpkXSZIrrZdYOLV4NsvtnKozCMtrvW/eXOKNVuXilvxFkLp1WlqogURelhh92pm+od4sglvd0HLu3Or3aPSTuqZ5deRSct8cyxJ7y/0pEHv5x0fd2gRW1c8nALaoGbtF2n5DkYuCeeDgkfYvIUBa6Qv7XbU3V24h0YP9OTJXUKpkaZoN4uSpcW0MpAkOjjNJlGZUCJSBMh5fPcELsJcnkDx8b08HuTlUrSMirguz25AnJ/s1ua4WDh/jqlXiMVp3UfZNekwS7CRsaemGd/Jo4OIPxPnb7/zkgsYPl2WV37ITQLUQIv/qPGAkp/N1l0SX/el2gBPs0oy5SLCb9JfXQMoQFoH0FDB3mqL5UNk/S7mhwtmKEq7jgHAVWpxoCDbd69pm71yKMG/S72gXnknGg/AAHCW/BAxH+x69gnpBw6U= X-Forefront-PRVS: 0238AEEDB0 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(7916002)(39450400003)(6116002)(3846002)(2906002)(76176999)(7736002)(1076002)(47776003)(5003940100001)(6506006)(25786008)(6486002)(66066001)(92566002)(5660300001)(305945005)(4326008)(33646002)(50986999)(81166006)(50226002)(230783001)(6916009)(48376002)(42186005)(53936002)(54906002)(6512007)(50466002)(189998001)(575784001)(36756003)(38730400002)(110136004)(8676002)(2950100002);DIR:OUT;SFP:1101;SCL:1;SRVR:SN1PR07MB2351;H:rric.localdomain;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;SN1PR07MB2351;23:YPrYrjxYHULrGTMlVZX19rtJVxmqeX8mjFTKanL+e?= =?us-ascii?Q?KELVYfPMaTyCT/VqRj13HOvB3IEQNX6UfE4ebgAYHAiuSMrORiau+P6QUFYE?= =?us-ascii?Q?NHmcBNWUZKmU5TJg2cbxIsaCuCN2ht7O96Fm3Gxkzwu4Qd+45Oz2xRrB7Mgh?= =?us-ascii?Q?AdKk4pfWgim9UDWbWJOr3A/uEhoGsBvRhJMF7/kP3vuK95BhOYsqtnUI5wfS?= =?us-ascii?Q?po99yNOIg4MkVIukKViNzA6CZG9zO+Wee3VGEUEvXqW0VPyCOqdJXImMozsm?= =?us-ascii?Q?fwam+x939+xpcH5x4Cd6WPbpx3GVNDmPaBUqzHmRlTgWXmMpI3DlJSmzopPp?= =?us-ascii?Q?pUuAIic7yObMf5OL7yQM85twHf7bMCIV2LQuzy1gQOj8bXqb+mEoV4eFJuMT?= =?us-ascii?Q?HxhY78lTDHHQNpkD9D1FoEkUiUvy04e6UBWYI1fHcKbS8hAompjPkgk7iKAi?= =?us-ascii?Q?+gDS9DnVvPgdVsSrQbu4G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BEHd8tu9B5glA5CC2E+0hTSmZL9MDj3Q==;5:tYs0OWVbIM2sBqBv63742ckhw8H64V3Adr13ZrP/jaHqmd9K7cpLLQF+nfHmMW+ueIkzQ67vKYXn/RcrHLPRVpUqkNt2qQStQvKwbAPmuzmVgHB+/EFYOKOuhUzJiF0JvUseH8yYfmpFApb45Bj1gg==;24:ET18F5LB7rwwUnnpoCAiopiEmATsFjrM0sC8NWzVz5i/Cy+d+ZbI7Ofin5BMPATNKv8LVBnTI/J/EfgThby30PB52X7agcsGm74MeD48z4E= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;SN1PR07MB2351;7:jYwzMXnQ+HqBKomOAGaoJiJZ6x336emgxg46a3soxuUX/15w4lAHxXz16Bm1KRSOYQgRWMCcu2h+rnNZa8tbyNykJFsOqIWHy8Ub14nqk3nI+4t7sSgsyTZBt5xx4ygXUMmjHoREzmEIEdLy0944X7wrbRYuVxwjqT5aZ+hxN7et9U28gYvwky03ExJKoAMl8PmLZmF8RkBFrk8QWT7FUpI9AFyoCYPWKG6m9K4ihLa9G/1gcRYi36l7QheTN1IGIm2WFOCv91tTotBfiIu0pdLIEKZT0GA1OPDRknlIr+IpygMCi5AgGNqGLzrk5gjh8xR5KvhMQcgx+pM4NWDdXg== X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Mar 2017 12:58:32.9588 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR07MB2351 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 6976 Lines: 239 To initialize the its nodes at a later point during boot, we need to split probing from initialization. Collect all information required for initialization in struct its_node. We can then use the its node list for initialization. Signed-off-by: Robert Richter --- drivers/irqchip/irq-gic-v3-its.c | 97 ++++++++++++++++++++++++++------------ drivers/irqchip/irq-gic-v3.c | 2 +- include/linux/irqchip/arm-gic-v3.h | 4 +- 3 files changed, 69 insertions(+), 34 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index ef00ffa92915..a0ab1b83c548 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -75,10 +75,12 @@ struct its_baser { * list of devices writing to it. */ struct its_node { + struct fwnode_handle *fwnode; raw_spinlock_t lock; struct list_head entry; void __iomem *base; phys_addr_t phys_base; + phys_addr_t phys_size; struct its_cmd_block *cmd_base; struct its_cmd_block *cmd_write; struct its_baser tables[GITS_BASER_NR_REGS]; @@ -1629,7 +1631,7 @@ static void its_enable_quirks(struct its_node *its) gic_enable_quirks(iidr, its_quirks, its); } -static int its_init_domain(struct fwnode_handle *handle, struct its_node *its) +static int its_init_domain(struct its_node *its) { struct irq_domain *inner_domain; struct msi_domain_info *info; @@ -1638,7 +1640,7 @@ static int its_init_domain(struct fwnode_handle *handle, struct its_node *its) if (!info) return -ENOMEM; - inner_domain = irq_domain_create_tree(handle, &its_domain_ops, its); + inner_domain = irq_domain_create_tree(its->fwnode, &its_domain_ops, its); if (!inner_domain) { kfree(info); return -ENOMEM; @@ -1654,55 +1656,83 @@ static int its_init_domain(struct fwnode_handle *handle, struct its_node *its) return 0; } +static void its_free(struct its_node *its) +{ + spin_lock(&its_lock); + list_del(&its->entry); + spin_unlock(&its_lock); + + kfree(its); +} + +static int __init its_init_one(struct its_node *its); + static int __init its_probe_one(struct resource *res, struct fwnode_handle *handle, int numa_node) { struct its_node *its; + int err; + + its = kzalloc(sizeof(*its), GFP_KERNEL); + if (!its) + return -ENOMEM; + + raw_spin_lock_init(&its->lock); + INIT_LIST_HEAD(&its->entry); + INIT_LIST_HEAD(&its->its_device_list); + its->fwnode = handle; + its->phys_base = res->start; + its->phys_size = resource_size(res); + its->numa_node = numa_node; + + spin_lock(&its_lock); + list_add_tail(&its->entry, &its_nodes); + spin_unlock(&its_lock); + + pr_info("ITS %pR\n", res); + + err = its_init_one(its); + if (err) + its_free(its); + + return err; +} + +static int __init its_init_one(struct its_node *its) +{ void __iomem *its_base; u32 val; u64 baser, tmp; int err; - its_base = ioremap(res->start, resource_size(res)); + its_base = ioremap(its->phys_base, its->phys_size); if (!its_base) { - pr_warn("ITS@%pa: Unable to map ITS registers\n", &res->start); - return -ENOMEM; + pr_warn("ITS@%pa: Unable to map ITS registers\n", &its->phys_base); + err = -ENOMEM; + goto fail; } val = readl_relaxed(its_base + GITS_PIDR2) & GIC_PIDR2_ARCH_MASK; if (val != 0x30 && val != 0x40) { - pr_warn("ITS@%pa: No ITS detected, giving up\n", &res->start); + pr_warn("ITS@%pa: No ITS detected, giving up\n", &its->phys_base); err = -ENODEV; goto out_unmap; } err = its_force_quiescent(its_base); if (err) { - pr_warn("ITS@%pa: Failed to quiesce, giving up\n", &res->start); - goto out_unmap; - } - - pr_info("ITS %pR\n", res); - - its = kzalloc(sizeof(*its), GFP_KERNEL); - if (!its) { - err = -ENOMEM; + pr_warn("ITS@%pa: Failed to quiesce, giving up\n", &its->phys_base); goto out_unmap; } - raw_spin_lock_init(&its->lock); - INIT_LIST_HEAD(&its->entry); - INIT_LIST_HEAD(&its->its_device_list); its->base = its_base; - its->phys_base = res->start; its->ite_size = ((gic_read_typer(its_base + GITS_TYPER) >> 4) & 0xf) + 1; - its->numa_node = numa_node; its->cmd_base = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, get_order(ITS_CMD_QUEUE_SZ)); if (!its->cmd_base) { err = -ENOMEM; - goto out_free_its; + goto out_unmap; } its->cmd_write = its->cmd_base; @@ -1744,13 +1774,11 @@ static int __init its_probe_one(struct resource *res, gits_write_cwriter(0, its->base + GITS_CWRITER); writel_relaxed(GITS_CTLR_ENABLE, its->base + GITS_CTLR); - err = its_init_domain(handle, its); + err = its_init_domain(its); if (err) goto out_free_tables; - spin_lock(&its_lock); - list_add_tail(&its->entry, &its_nodes); - spin_unlock(&its_lock); + pr_info("ITS@%pa: ITS node added\n", &its->phys_base); return 0; @@ -1758,11 +1786,10 @@ static int __init its_probe_one(struct resource *res, its_free_tables(its); out_free_cmd: free_pages((unsigned long)its->cmd_base, get_order(ITS_CMD_QUEUE_SZ)); -out_free_its: - kfree(its); out_unmap: iounmap(its_base); - pr_err("ITS@%pa: failed probing (%d)\n", &res->start, err); +fail: + pr_err("ITS@%pa: failed probing (%d)\n", &its->phys_base, err); return err; } @@ -1864,8 +1891,10 @@ static void __init its_acpi_probe(void) static void __init its_acpi_probe(void) { } #endif -int __init its_init(struct fwnode_handle *handle, struct rdists *rdists, - struct irq_domain *parent_domain) +static int __init its_init(void); + +int __init its_probe(struct fwnode_handle *handle, struct rdists *rdists, + struct irq_domain *parent_domain) { struct device_node *of_node; @@ -1882,8 +1911,14 @@ int __init its_init(struct fwnode_handle *handle, struct rdists *rdists, } gic_rdists = rdists; + + return its_init(); +} + +static int __init its_init(void) +{ its_alloc_lpi_tables(); - its_lpi_init(rdists->id_bits); + its_lpi_init(gic_rdists->id_bits); return 0; } diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index c132f29322cc..b46dc9396331 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -949,7 +949,7 @@ static int __init gic_init_bases(void __iomem *dist_base, set_handle_irq(gic_handle_irq); if (IS_ENABLED(CONFIG_ARM_GIC_V3_ITS) && gic_dist_supports_lpis()) - its_init(handle, &gic_data.rdists, gic_data.domain); + its_probe(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 672cfef72fc8..a7dc1e3030ef 100644 --- a/include/linux/irqchip/arm-gic-v3.h +++ b/include/linux/irqchip/arm-gic-v3.h @@ -466,8 +466,8 @@ struct rdists { struct irq_domain; struct fwnode_handle; int its_cpu_init(void); -int its_init(struct fwnode_handle *handle, struct rdists *rdists, - struct irq_domain *domain); +int its_probe(struct fwnode_handle *handle, struct rdists *rdists, + struct irq_domain *domain); static inline bool gic_enable_sre(void) { -- 2.11.0