Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754795AbdCFOnG (ORCPT ); Mon, 6 Mar 2017 09:43:06 -0500 Received: from mail-sn1nam02on0085.outbound.protection.outlook.com ([104.47.36.85]:11232 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754727AbdCFOm0 (ORCPT ); Mon, 6 Mar 2017 09:42:26 -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 7/8] irqchip/gic-v3-its: Handle its nodes as kernel devices Date: Mon, 6 Mar 2017 13:57:38 +0100 Message-Id: <20170306125739.19445-8-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: e8da03d0-da2f-4945-c8c4-08d4649084bf X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:SN1PR07MB2351; X-Microsoft-Exchange-Diagnostics: 1;SN1PR07MB2351;3:H3c62VugveUEfinww1qi87RUEFmUzPqxOjBop+mHPdQPXM6Dl3mtYiM3qgbLR25fjJxLEgCbstNytZ3I3wJoRq18DOkZwUzc6Qdln15OSDp7gy+ghuh8/dqop/xOZR6JVDsJcgvrhW1gVaB81kAmIcfbzrlmpkCpltov3Wz3hncD1mAKxrr49VTeP+SqXIbcpw17krgBYi5a+v3nFfKz71I1y8waIrjrcHt1AGO4Rhv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2RxdLkRDCLKw61DxlPqTnvY/QWlQdPqxZG4g8gfQtgXpjrCeagO5SVYCj88LMQ1RC4Q2b/WJpVmRLKPBd2rSNsDbDM19Gb045AEMI/YhP6bRNtcgUi3v2RonHQRo4CNjBEj2ZQKJ/1I5ESbbloZPvzJc6+NOEjLMdwJuPCSBmi67EuKDDxpd5CuGSvn5NXDKktCq+l//Qtgk83RWOhJSei5zQtNFgeav5M7uUDmx3ue 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:o7P4BuzneSUMv/IyDVoBmwxHxbX1BPakf7HkNvsZJ315zbsNWgZD/IIQrxyxbd15/gxg8XWJZM2eIEHWyTSutUvBezKMmlUI4PQ/eokKGj+NmV7HPhrFRTdv2X0U1Vo9b0GirqG54iiU4w6zrPiF1fh0u7gyvQ6jYw13UFmZlZJWO+ajCxrcqLmKfZJ4m5IQo9MuE6lknC0l8Z0gMN9+3W8F6AVGMoJ1wysRe2YU8Ct/c0c/znTeKw7r6lB+hPQ+04J8k/suCVPGKLfAMt/Bf4RlkgEUJIyyV/0/PAiNPOl5Hz9++xnMLZKKn0TAKplZNYXAmt8GJzyhDXjtKuUBLV32uDRy1Hb7Y2gdLJCAYRjws/RwIaICSrNAVXqeozM63e8oYR67OZWCZtmMla5TtrrWUoxPlP+qxB3KfyxQ1JMT056ySCKEIty6IkEDc6Bh5upUfsK5I/A8ZjEvudmgB+kwL6FCHlmpS0PFK/B89hTh7CN2e39c6DmkRe5ZW5Ye5Rpm0koyQGjIg46zyJvO/gg6DLvnGvp5UFI2MXc+PM/jvCqXDBxFbMkNsWwNn4NprasInCMTomvlag0HgQ1aQkubILQ20MVMwmtT8w66Kww= 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)(6666003)(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:6SoHd973YLkzmCj3vCsCBcivDXNpBSzW9/iUsl3NZ?= =?us-ascii?Q?xu+gEN/EKKVQdNxWjurSBZd95LOaJCSMb2BMDYQAa+LoHDr9kd3Ylcw8WQJv?= =?us-ascii?Q?v9FdQvrvF4E4MTsJPMAHhV+rOHq9BKug6X/DCTiSPD7hDXyWX4uV9Hf+DbuA?= =?us-ascii?Q?qvhKNSu1/lXrYvNXJALBmlM8VQMShrQx/CGgAp6CykOiyz08V6EguBaDkeTF?= =?us-ascii?Q?DayRZ2wj/LSWcWEozQGuuWL44XcxX0YYHd7SjPqHwqUFvL8XCdzWi8cKnPS7?= =?us-ascii?Q?t1fmZkk5pnmFZudjUUhrAG191wVQ7bFMaggXL8zqI84LS73YGgphwVOS3Uxb?= =?us-ascii?Q?i6AsjgWz3wn+H/DHWyRs1avFcL74MUmQ84UGVYSwDBhyYH9Qe0/HO2/CcBD5?= =?us-ascii?Q?+QK9POMvLTrVH1M3IELJdP9UFqQV6IvcgRcboPxGLe47/gTd4W34CH+YnM07?= =?us-ascii?Q?CRdK3yPNblDYsYgStA6xGs/8IHgw3XRk3IeI9e9qc6xsP6GVaVQ/c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BGIqCzwgjrg9gja+5ocNE5vNcQugiiE45pkI8aj0GvR4OYyAiPuUCXiX6uyO2uuX9r8RI6GZAo++BIqEasfLFHsdD3o+Z9urSd4Sg6S0wsAc4DIBoF/NJbtDqYTJYW/VNt46wz71dX+IYTYHA==;24:Q1vU45IHRgJDnjSM1iGPu+QzE5eFl2kSaE5YfX1CYzFJCeijnhdjSBXEzqYKsnNx2jokOrHfmtbDgV5tO9eIWVsxqfMrHA4S5M+yVAf1B3c= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;SN1PR07MB2351;7:uvlE21lD+WicELL1zlR0mPFKOLDIyufOSf5ALQHuuFLwG4RVUVGrPgekcRzcmglgJKq4g72jKET8WJ7tlN+a4PZVEo0sKFNtg8DfB4jyO53NtNGYX+yVEuMz9cd9A6lHkTl68HLUYhynS/8EDOzejbgKs0Fcb+EUXJ2ADiHEhuWOP7t2gtfneXQQ+X/K7ABtLgHtm7GLN7hI5niq1CTZdQIx9IxFMOt2LEUqiV/pwoiuudjgYUEKX66IFrHB2z9i2pRQVgeft+20/VYe89IOiQfytVpncj22PkM7eQyfZYOrMJsp237D7R2wFBDkaysHlqDh+uYClbXm4EeEau43HQ== X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Mar 2017 12:58:41.7717 (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: 9786 Lines: 312 Manage its nodes as kernel devices. We can then use the kernel's device resource management for memory allocation. Freeing memory becomes much easier now. This also allows us to use CMA for the allocation of large its tables. Signed-off-by: Robert Richter --- drivers/irqchip/irq-gic-v3-its.c | 118 ++++++++++++++++++++------------------- 1 file changed, 60 insertions(+), 58 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index c0eaae35c631..6625b3a505f0 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -75,6 +76,7 @@ struct its_baser { * list of devices writing to it. */ struct its_node { + struct device dev; struct fwnode_handle *fwnode; raw_spinlock_t lock; struct list_head entry; @@ -400,7 +402,7 @@ static struct its_cmd_block *its_allocate_entry(struct its_node *its) while (its_queue_full(its)) { count--; if (!count) { - pr_err_ratelimited("ITS queue not draining\n"); + dev_err_ratelimited(&its->dev, "ITS queue not draining\n"); return NULL; } cpu_relax(); @@ -460,7 +462,7 @@ static void its_wait_for_range_completion(struct its_node *its, count--; if (!count) { - pr_err_ratelimited("ITS queue timeout\n"); + dev_err_ratelimited(&its->dev, "ITS queue timeout\n"); return; } cpu_relax(); @@ -480,7 +482,7 @@ static void its_send_single_command(struct its_node *its, cmd = its_allocate_entry(its); if (!cmd) { /* We're soooooo screewed... */ - pr_err_ratelimited("ITS can't allocate, dropping command\n"); + dev_err_ratelimited(&its->dev, "ITS can't allocate, dropping command\n"); raw_spin_unlock_irqrestore(&its->lock, flags); return; } @@ -490,7 +492,7 @@ static void its_send_single_command(struct its_node *its, if (sync_col) { sync_cmd = its_allocate_entry(its); if (!sync_cmd) { - pr_err_ratelimited("ITS can't SYNC, skipping\n"); + dev_err_ratelimited(&its->dev, "ITS can't SYNC, skipping\n"); goto post; } its_encode_cmd(sync_cmd, GITS_CMD_SYNC); @@ -867,14 +869,15 @@ static int its_setup_baser(struct its_node *its, struct its_baser *baser, retry_alloc_baser: alloc_pages = (PAGE_ORDER_TO_SIZE(order) / psz); if (alloc_pages > GITS_BASER_PAGES_MAX) { - pr_warn("ITS@%pa: %s too large, reduce ITS pages %u->%u\n", - &its->phys_base, its_base_type_string[type], - alloc_pages, GITS_BASER_PAGES_MAX); + dev_warn(&its->dev, "%s too large, reduce ITS pages %u->%u\n", + its_base_type_string[type], alloc_pages, + GITS_BASER_PAGES_MAX); alloc_pages = GITS_BASER_PAGES_MAX; order = get_order(GITS_BASER_PAGES_MAX * psz); } - base = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, order); + base = (void *)devm_get_free_pages(&its->dev, GFP_KERNEL | __GFP_ZERO, + order); if (!base) return -ENOMEM; @@ -926,7 +929,7 @@ static int its_setup_baser(struct its_node *its, struct its_baser *baser, * size and retry. If we reach 4K, then * something is horribly wrong... */ - free_pages((unsigned long)base, order); + devm_free_pages(&its->dev, (unsigned long)base); baser->base = NULL; switch (psz) { @@ -940,10 +943,9 @@ static int its_setup_baser(struct its_node *its, struct its_baser *baser, } if (val != tmp) { - pr_err("ITS@%pa: %s doesn't stick: %llx %llx\n", - &its->phys_base, its_base_type_string[type], - val, tmp); - free_pages((unsigned long)base, order); + dev_err(&its->dev, "%s doesn't stick: %llx %llx\n", + its_base_type_string[type], val, tmp); + devm_free_pages(&its->dev, (unsigned long)base); return -ENXIO; } @@ -952,8 +954,8 @@ static int its_setup_baser(struct its_node *its, struct its_baser *baser, baser->psz = psz; tmp = indirect ? GITS_LVL1_ENTRY_SIZE : esz; - pr_info("ITS@%pa: allocated %d %s @%lx (%s, esz %d, psz %dK, shr %d)\n", - &its->phys_base, (int)(PAGE_ORDER_TO_SIZE(order) / (int)tmp), + dev_info(&its->dev, "allocated %d %s @%lx (%s, esz %d, psz %dK, shr %d)\n", + (int)(PAGE_ORDER_TO_SIZE(order) / (int)tmp), its_base_type_string[type], (unsigned long)virt_to_phys(base), indirect ? "indirect" : "flat", (int)esz, @@ -1004,8 +1006,8 @@ static bool its_parse_baser_device(struct its_node *its, struct its_baser *baser if (new_order >= MAX_ORDER) { new_order = MAX_ORDER - 1; ids = ilog2(PAGE_ORDER_TO_SIZE(new_order) / (int)esz); - pr_warn("ITS@%pa: Device Table too large, reduce ids %u->%u\n", - &its->phys_base, its->device_ids, ids); + dev_warn(&its->dev, "Device Table too large, reduce ids %u->%u\n", + its->device_ids, ids); } *order = new_order; @@ -1013,19 +1015,6 @@ static bool its_parse_baser_device(struct its_node *its, struct its_baser *baser return indirect; } -static void its_free_tables(struct its_node *its) -{ - int i; - - for (i = 0; i < GITS_BASER_NR_REGS; i++) { - if (its->tables[i].base) { - free_pages((unsigned long)its->tables[i].base, - its->tables[i].order); - its->tables[i].base = NULL; - } - } -} - static int its_alloc_tables(struct its_node *its) { u64 typer = gic_read_typer(its->base + GITS_TYPER); @@ -1060,10 +1049,8 @@ static int its_alloc_tables(struct its_node *its) indirect = its_parse_baser_device(its, baser, psz, &order); err = its_setup_baser(its, baser, cache, shr, psz, order, indirect); - if (err < 0) { - its_free_tables(its); + if (err < 0) return err; - } /* Update settings which will be used for next BASERn */ psz = baser->psz; @@ -1347,6 +1334,9 @@ static struct its_device *its_create_device(struct its_node *its, u32 dev_id, gic_flush_dcache_to_poc(itt, sz); + /* prevent its from being released */ + get_device(&its->dev); + dev->its = its; dev->itt = itt; dev->nr_ites = nr_ites; @@ -1656,8 +1646,9 @@ static int its_init_domain(struct its_node *its) return 0; } -static void its_free(struct its_node *its) -{ +static void its_device_release(struct device *dev) { + struct its_node *its = container_of(dev, struct its_node, dev); + kfree(its); } @@ -1694,34 +1685,47 @@ static int __init its_init_one(struct its_node *its) u64 baser, tmp; int err; - its_base = ioremap(its->phys_base, its->phys_size); + /* On error always use put_device() to free devices */ + device_initialize(&its->dev); + its->dev.release = its_device_release; + + err = dev_set_name(&its->dev, "its@%pa", &its->phys_base); + if (!err) + err = device_add(&its->dev); + + if (err) { + pr_warn("ITS@%pa: Unable to register device\n", &its->phys_base); + return err; + } + + its_base = devm_ioremap(&its->dev, its->phys_base, its->phys_size); if (!its_base) { - pr_warn("ITS@%pa: Unable to map ITS registers\n", &its->phys_base); + dev_warn(&its->dev, "Unable to map ITS registers\n"); 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", &its->phys_base); + dev_warn(&its->dev, "No ITS detected, giving up\n"); err = -ENODEV; - goto out_unmap; + goto fail; } err = its_force_quiescent(its_base); if (err) { - pr_warn("ITS@%pa: Failed to quiesce, giving up\n", &its->phys_base); - goto out_unmap; + dev_warn(&its->dev, "Failed to quiesce, giving up\n"); + goto fail; } its->base = its_base; its->ite_size = ((gic_read_typer(its_base + GITS_TYPER) >> 4) & 0xf) + 1; - its->cmd_base = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, - get_order(ITS_CMD_QUEUE_SZ)); + its->cmd_base = (void *)devm_get_free_pages(&its->dev, + GFP_KERNEL | __GFP_ZERO, get_order(ITS_CMD_QUEUE_SZ)); if (!its->cmd_base) { err = -ENOMEM; - goto out_unmap; + goto fail; } its->cmd_write = its->cmd_base; @@ -1729,11 +1733,11 @@ static int __init its_init_one(struct its_node *its) err = its_alloc_tables(its); if (err) - goto out_free_cmd; + goto fail; err = its_alloc_collections(its); if (err) - goto out_free_tables; + goto fail; baser = (virt_to_phys(its->cmd_base) | GITS_CBASER_RaWaWb | @@ -1756,7 +1760,7 @@ static int __init its_init_one(struct its_node *its) baser |= GITS_CBASER_nC; gits_write_cbaser(baser, its->base + GITS_CBASER); } - pr_info("ITS: using cache flushing for cmd queue\n"); + dev_info(&its->dev, "using cache flushing for cmd queue\n"); its->flags |= ITS_FLAGS_CMDQ_NEEDS_FLUSHING; } @@ -1765,20 +1769,14 @@ static int __init its_init_one(struct its_node *its) err = its_init_domain(its); if (err) - goto out_free_tables; + goto fail; - pr_info("ITS@%pa: ITS node added\n", &its->phys_base); + dev_info(&its->dev, "ITS node added\n"); return 0; - -out_free_tables: - its_free_tables(its); -out_free_cmd: - free_pages((unsigned long)its->cmd_base, get_order(ITS_CMD_QUEUE_SZ)); -out_unmap: - iounmap(its_base); fail: - pr_err("ITS@%pa: failed probing (%d)\n", &its->phys_base, err); + device_del(&its->dev); + dev_err(&its->dev, "failed probing (%d)\n", err); return err; } @@ -1912,6 +1910,10 @@ static int __init its_init(void) spin_lock(&its_lock); + /* + * Call this for all entries. We can then use put_device() to + * release the nodes on error. + */ list_for_each_entry(its, &its_nodes, entry) { err2 = its_init_one(its); if (!err && err2) @@ -1923,7 +1925,7 @@ static int __init its_init(void) list_for_each_entry_safe(its, tmp, &its_nodes, entry) { list_del(&its->entry); - its_free(its); + put_device(&its->dev); } unlock: spin_unlock(&its_lock); -- 2.11.0