From patchwork Mon Sep 12 18:32:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Nowicki X-Patchwork-Id: 9327531 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 12CE060231 for ; Mon, 12 Sep 2016 18:35:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0960428D84 for ; Mon, 12 Sep 2016 18:35:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EDD5A28E39; Mon, 12 Sep 2016 18:35:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 530D528D84 for ; Mon, 12 Sep 2016 18:35:41 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bjW3d-0005Cf-TL; Mon, 12 Sep 2016 18:34:17 +0000 Received: from mail-lf0-x229.google.com ([2a00:1450:4010:c07::229]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bjW32-0004qI-9B for linux-arm-kernel@lists.infradead.org; Mon, 12 Sep 2016 18:33:43 +0000 Received: by mail-lf0-x229.google.com with SMTP id g62so93817332lfe.3 for ; Mon, 12 Sep 2016 11:33:19 -0700 (PDT) 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=DcQQtUQ4acqozErS36Vi8ijnizJVxmknq4k/mEYVHYI=; b=yP620FitZjJzz3p8tj9nbLQ26Yn3dZCd9iGjUCQZmGr588+SqYeFRaFTTKFxJPLxu+ LImTlPt2DdvknohQ7IW/SDeeNstFx28CHgP1+LkoFrkUdp20oxAfl+W2Av4X+gr02OVH i/yB9hrmppoNqdvxGHOjAGKmdeH0tjpgmAzacORR3aN25KulYvX5Ads5Xn2TDILUCVue KLIeFkJETZwoSNz2IOnbtxR6JnNJYnb2R1c92hj9cfSdjM0bxs3TXctLpLATz2aLnsan iETUxktD3FXaurbxMW7tPgcC4tinMo4aww0teoABouIyo1FYPq94UreqQWGH6lutBNS0 BU9Q== 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=DcQQtUQ4acqozErS36Vi8ijnizJVxmknq4k/mEYVHYI=; b=aVXlSFqDQxOsSnlpdlfSYGXL6h3mg+epZqjUjsYNx1aX1pkUCG9IXVi8h7SS15Mzgk 8SCbH1CbSTqh6HrPRIAIX1WrJv8IIE12oE3V+MPjp/uRkYV1w+vxQ4NknC4tQ8If1Z77 3QRe2Mp34lHTzVNalPz3Jy4osTn2lpWafgg64JpOM5rk/kSCDuqC2voG2UnisT8Zn/Zo pEHJ/sPqEK+sLgeBVhzHvVzRMzc4IHeh00hb2RQZgryYCr+qaBcVqvUzVBll8Ytkgbm+ mHJKJeQz0aMiiOGugdatfQZ5ILgvVPKszQfQmSBqlJlyG5RuHP8lHx3y+PRgwKhKlMXu s9nQ== X-Gm-Message-State: AE9vXwNeDQPqEebH0iNbolVax09/lBzJjLO8wAVW78fo6G2iLuwPIPm8lSUIqjikSpa9xQ== X-Received: by 10.25.75.196 with SMTP id y187mr2539090lfa.151.1473705197267; Mon, 12 Sep 2016 11:33:17 -0700 (PDT) Received: from localhost.localdomain ([87.116.212.139]) by smtp.gmail.com with ESMTPSA id s3sm3318460lja.49.2016.09.12.11.33.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 12 Sep 2016 11:33:16 -0700 (PDT) From: Tomasz Nowicki To: marc.zyngier@arm.com, tglx@linutronix.de, jason@lakedaemon.net, rjw@rjwysocki.net, helgaas@kernel.org, rafael@kernel.org, Lorenzo.Pieralisi@arm.com Subject: [PATCH V11 4/8] irqchip/gicv3-its: Cleanup for ITS domain initialization Date: Mon, 12 Sep 2016 20:32:23 +0200 Message-Id: <1473705147-6588-5-git-send-email-tn@semihalf.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1473705147-6588-1-git-send-email-tn@semihalf.com> References: <1473705147-6588-1-git-send-email-tn@semihalf.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160912_113340_770328_B2BD2081 X-CRM114-Status: GOOD ( 13.96 ) 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, al.stone@linaro.org, linaro-acpi@lists.linaro.org, catalin.marinas@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, okaya@codeaurora.org, linux-acpi@vger.kernel.org, robert.richter@caviumnetworks.com, hanjun.guo@linaro.org, ddaney.cavm@gmail.com, linux-pci@vger.kernel.org, shijie.huang@arm.com, Tomasz Nowicki , mw@semihalf.com, andrea.gallo@linaro.org, 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-Virus-Scanned: ClamAV using ClamSMTP There is no point to initialize ITS without having msi-controller property in corresponding DT node. However, its_probe is checking msi-controller presence at the end, so we can save our time and do that check prior to its_probe call. Also, for the code clarity purpose, we put domain initialization to separate function. Signed-off-by: Tomasz Nowicki Acked-by: Marc Zyngier Reviewed-by: Hanjun Guo --- drivers/irqchip/irq-gic-v3-its.c | 57 ++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 36b9c28..943442d 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -1614,13 +1614,37 @@ static void its_enable_quirks(struct its_node *its) gic_enable_quirks(iidr, its_quirks, its); } +static int its_init_domain(struct device_node *node, struct its_node *its, + struct irq_domain *parent) +{ + struct irq_domain *inner_domain; + struct msi_domain_info *info; + + info = kzalloc(sizeof(*info), GFP_KERNEL); + if (!info) + return -ENOMEM; + + inner_domain = irq_domain_add_tree(node, &its_domain_ops, its); + if (!inner_domain) { + kfree(info); + return -ENOMEM; + } + + inner_domain->parent = parent; + inner_domain->bus_token = DOMAIN_BUS_NEXUS; + info->ops = &its_msi_domain_ops; + info->data = its; + inner_domain->host_data = info; + + return 0; +} + static int __init its_probe(struct device_node *node, struct irq_domain *parent) { struct resource res; struct its_node *its; void __iomem *its_base; - struct irq_domain *inner_domain; u32 val; u64 baser, tmp; int err; @@ -1712,28 +1736,9 @@ 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")) { - struct msi_domain_info *info; - - info = kzalloc(sizeof(*info), GFP_KERNEL); - if (!info) { - err = -ENOMEM; - goto out_free_tables; - } - - inner_domain = irq_domain_add_tree(node, &its_domain_ops, its); - if (!inner_domain) { - err = -ENOMEM; - kfree(info); - goto out_free_tables; - } - - inner_domain->parent = parent; - inner_domain->bus_token = DOMAIN_BUS_NEXUS; - info->ops = &its_msi_domain_ops; - info->data = its; - inner_domain->host_data = info; - } + err = its_init_domain(node, its, parent); + if (err) + goto out_free_tables; spin_lock(&its_lock); list_add(&its->entry, &its_nodes); @@ -1784,6 +1789,12 @@ int __init its_init(struct device_node *node, struct rdists *rdists, for (np = of_find_matching_node(node, its_device_id); np; np = of_find_matching_node(np, its_device_id)) { + if (!of_property_read_bool(np, "msi-controller")) { + pr_warn("%s: no msi-controller property, ITS ignored\n", + np->full_name); + continue; + } + its_probe(np, parent_domain); }