Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752415AbdHHMXf (ORCPT ); Tue, 8 Aug 2017 08:23:35 -0400 Received: from mail-by2nam01on0071.outbound.protection.outlook.com ([104.47.34.71]:50201 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752381AbdHHMXb (ORCPT ); Tue, 8 Aug 2017 08:23:31 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Robert.Richter@cavium.com; From: Robert Richter To: Thomas Gleixner , Jason Cooper , Marc Zyngier Cc: Shanker Donthineni , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Robert Richter Subject: [PATCH v3 3/8] irqchip/gic-v3-its: Split probing from its node initialization Date: Tue, 8 Aug 2017 14:22:53 +0200 Message-Id: <20170808122259.6299-4-rrichter@cavium.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170808122259.6299-1-rrichter@cavium.com> References: <20170808122259.6299-1-rrichter@cavium.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [78.55.120.224] X-ClientProxiedBy: AM5PR06CA0030.eurprd06.prod.outlook.com (10.167.168.43) To CY1PR07MB2346.namprd07.prod.outlook.com (10.166.194.145) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 87f1a1d5-933a-4acb-2462-08d4de58474a X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:CY1PR07MB2346; X-Microsoft-Exchange-Diagnostics: 1;CY1PR07MB2346;3:9GmFXG9Yf2MnYUcQsrj+Gv1RYKF22dLVpV9pPYEF61T2vvFA8XQ6N4YEbsLif+VdX/GBbAo/v3mCMeuwugOPVfv+i703WwQPcJ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F+WYg7NVse5nhDaRCfYClfSgt/PS7J6Uh4BAZ/WocOlchX+egm6wowxDtekAvWAiYCbabFwpRUGqdt4r/LFwG3hkjanWKmo42wnDdvVKs/vVnrvS5YubjScjdFRa8NtMnJUPVNvEiQ00MZCwsm/F1XocvvbiG53uJwwHhVq271wljabzFFQCyvPsN+BdCv8mQ7h7SqcnW54H4TOF2DwFaFqiCuqaB5LqRW1qRSrHZW2blO2;4:GxOQYYNhJjK0hy9X4ejGnZtAT9N7J1Tj8kyvTg7XLFt82qlByFRE/Fj3ZBKLDRkgJ6BVFqKqNb5BlQNh3gbSEBY7vcdKuy9XKEX/esj+e6lfBVhlKM8lqfQShGeVzn3cBTVxlhxMf2TadI4owICse0Ffe5ES2e7LbMAUD9LbFX384IWTQORkbnGlwOwB6lYRY78zqTtu6ZJH37WBQM/KVAkx0amhZzciG9RHCUo0QteKRlVgwRnjMLpUNfTpF9j9 X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(100000703101)(100105400095)(93006095)(93001095)(10201501046)(3002001)(6041248)(20161123558100)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123560025)(20161123564025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:CY1PR07MB2346;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:CY1PR07MB2346; X-Forefront-PRVS: 03932714EB X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(7370300001)(4630300001)(6009001)(39840400002)(39410400002)(39850400002)(39400400002)(39450400003)(199003)(189002)(33646002)(66066001)(106356001)(68736007)(2950100002)(189998001)(54906002)(6116002)(3846002)(97736004)(72206003)(6666003)(81166006)(50226002)(6486002)(25786009)(5003940100001)(107886003)(38730400002)(4326008)(305945005)(50986999)(101416001)(5660300001)(42186005)(81156014)(230783001)(2906002)(7736002)(6512007)(36756003)(76176999)(1076002)(105586002)(7350300001)(6506006)(48376002)(47776003)(478600001)(53936002)(50466002)(8676002);DIR:OUT;SFP:1101;SCL:1;SRVR:CY1PR07MB2346;H:rric.localdomain;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CY1PR07MB2346;23:1Yx93wy10NOVl+s/Ta3XCf2NWqAu8+kaYMg0geEGj?= =?us-ascii?Q?ZSJou9Kbom7I9CMDC2n7/IAmGZ7ZAlJuTFprraq13pcuIwdIpUGQNuy9Grsl?= =?us-ascii?Q?+B28L2ZZmSt8/zQH3oDc4lLDAof3lhqQOKAP3Wc+YHJhu4YjJbBQn+CuFOPq?= =?us-ascii?Q?upPh+ybpcMbaWfaiWKigIdKB4/g5PkI9GAr61zlq8ZSiKvQBEakNVDRvEVSj?= =?us-ascii?Q?gEjHo3MjGAiX0l9TwS+Lju5uol6RkCBbVgCOAbiVESiz74bCXFGvPV1zaUo+?= =?us-ascii?Q?SfF/dy5ACtBiCKd65JhdrBiU97MLSkavxOxQ+77s3hG2tg7gVvdjrxgz4gB/?= =?us-ascii?Q?GBto8ws6bpUUgQUgC06mq7byY9P03fT9kvtdFEShVEDlq+2r3RkaJg18nF8v?= =?us-ascii?Q?vBppaytwy6OI2f6icOoyqMdnXcoG/EwsugxwRoQetS1n3YkdQrrohTIOzFUd?= =?us-ascii?Q?UXKibHWK7wN8ASDbNW4IPHkvAB6eh3OLxW3ubS8xJKw1XjsBW25ofpfaonqp?= =?us-ascii?Q?+MyKtOWJoKORieMGbmLsdODcB/j94DJhASOttzZGxO1qLatsSlTb4rPrhHGP?= =?us-ascii?Q?YdBSA7J53hden+zwxvRzXnXjuErHkhAIIJn9o9McKecpmTYe2k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/JbRMf4EQ3+2Xo56UcMDd+PJ691bWnCrvOw2AQKgSk1VoEjB1iD8bXGrUaGeqKNNviCKhfkZzr72QI13qQWlSkWWTtdiM8KTYB5JdZsmbSnnQr0yWdRFYwQ1NjN0U4ffem2zKs1DHPcQ==;5:EsB2Hv4cps9kkAFMeNjkaWs9GbUI6JIBxC6dbWUNk79tWPMvUG5oYlVA9KRr/Lufn1Pb/K2LS/5Q9LDjzGUq1lFmB4wFJSp476uGCQ5+bVsHP2yhAItOV6zngvj3Y4j+HaIS2euQHk5KFXcFJMwnNw==;24:h0IEijohWgvv17dCUPAvhpnLDaaCWHN/FSf/A3MYJIIJSdfxMZLcV7LTKW1mcLEA2Ap+4v4WewCZUFehpVSjqeeURSzrY0RJpMUesW/3J7Y=;7:qajF8wWzxJ5D+Xvc/G/XWfLrPg918cQadlD6NiGccErzhdqyyM0pByKBa4YLNFI5zggsXx8wtCTrnIITsAUVvQ7fAASmSjlIMJTpX65WhUVj9LoYU4esSKa/CMk+XXmEZp8uUWnxdm25PnYJyqi6QGN6iGUThX4VzRkceLZonPp2NkHg700M6DyBYPJTJDHDmmsHOZs0A4Tjv/D+Iit2E5Dtw8svtNJedi8J0RT6jGA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Aug 2017 12:23:28.5142 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2346 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 6899 Lines: 235 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 | 95 ++++++++++++++++++++++++++------------ drivers/irqchip/irq-gic-v3.c | 2 +- include/linux/irqchip/arm-gic-v3.h | 4 +- 3 files changed, 68 insertions(+), 33 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 92c66c86a63f..b51a1208588b 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]; @@ -1647,7 +1649,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; @@ -1656,7 +1658,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; @@ -1672,55 +1674,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; @@ -1762,13 +1792,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; @@ -1776,11 +1804,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; } @@ -1956,8 +1983,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; @@ -1974,5 +2003,11 @@ int __init its_init(struct fwnode_handle *handle, struct rdists *rdists, } gic_rdists = rdists; + + return its_init(); +} + +static int __init its_init(void) +{ return its_alloc_lpi_tables(); } diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index dbffb7ab6203..886e70ab2159 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -952,7 +952,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 6a1f87ff94e2..c4f9c968728f 100644 --- a/include/linux/irqchip/arm-gic-v3.h +++ b/include/linux/irqchip/arm-gic-v3.h @@ -492,8 +492,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