From patchwork Wed Jul 19 19:07:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 9853037 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 F3054602BD for ; Wed, 19 Jul 2017 19:09:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB20C20856 for ; Wed, 19 Jul 2017 19:09:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CEAA2285CD; Wed, 19 Jul 2017 19:09:57 +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=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4DC4220856 for ; Wed, 19 Jul 2017 19:09:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=wx+rPMapvHmQUbdrqCvYV/w9AKYtP03Xeyu2AF9bM/k=; b=p/Kqswnt0wi5ccK2PoBr+uO2NK aJhfadycwp+6vp/JVQmzfpQWsmcdMlDwgEGm1jxUryKM5BIJj6VPXKLxHO1RIySIKR4O7GFeetq+V Vm1Q8VXpo2RSAWOPJpwxX5ATI1lmw6EXS/ZLrzsp+S3NunfqEkJIxCBuAkOWOj6GJ3/C5gc7pRWqJ RxxQ95kty2+liiS3cyybs73RktR040NRhZqVM1nyQZ+AFfylGEoE5/QkVuMQd/Xu1zUScGv0u86us Vh/pt495pXrXFS3NiCFsEsUJG0CYg7qvdozo6H34i7avTh1hLefjJ1xKEUnhj1CDnwVYj0ClXKEXi wigESbGw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dXuM5-0001fp-UQ; Wed, 19 Jul 2017 19:09:53 +0000 Received: from mail-qt0-x244.google.com ([2607:f8b0:400d:c0d::244]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dXuLK-0000hS-OV for linux-arm-kernel@lists.infradead.org; Wed, 19 Jul 2017 19:09:15 +0000 Received: by mail-qt0-x244.google.com with SMTP id 19so1283681qty.1 for ; Wed, 19 Jul 2017 12:08:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7J3dLdLGmvqhz8T6cmDYylZDjGWK15I37BvyxY6ONBY=; b=HfmBocFfs4TPpwLkPKAKMoaoOVUExncGEiG/j5Uk8I1+WrNO1Yfew/Mk64x+oWaelV Sub7LlBj/4QLNwutELtNZzFFAVg7VPiMm1C3BvH/Cyd0CWQu9K8JDRwc+7MtbsFFHDA/ YNgWUBdDcEOAxYoT87SnbeoPFwUmivWBn2jHmjLw6EOWFypuQC9oifdFm9vJ8kEY+QUx DSss96/1xVmYLxgtYiHATPtJLWeGT24VDl0nUS5wK7hhZ9mDLBPnBTec0zT5rlNZfmUQ yLc38WjQPM3TVgwUtYX1jTFjQtjFdgWXJfSTfdj8DKMd4xehozWt1h8DPiw7z3emloB6 HDeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7J3dLdLGmvqhz8T6cmDYylZDjGWK15I37BvyxY6ONBY=; b=q07RziJs/bCgba/BfknYgvfp1O+4ffpATG9zUql68JnVQsSlcvq1yp3HUKU5kkjPsB 9RvA6cx+2A0wfCrM6IrrxCSbuOwkg+8gR07wo9rkgOUJom6QRthT0J+hyDhBqcIx5LrC +XGs99ePL2RX5cNiiea0ACK5lfJVOcks4MD4bM9Q62fVwX5hPlDLmsdHH3Hr3PTV2eew YVjWSNLGZfJLyk+q4y6wjqgihPAdx3UxZCpCUfoZe2jLDSUJwKm4pK6x8TwiPWnXRter nLK4nQvoIx+CesT+RssiWah2UBDmuRg865FjvqN0Eeh/e2cDZxJkx0y3qKXhGPhzLlJO HhOg== X-Gm-Message-State: AIVw112d+68XmsvRK22vIz28JHVOcQsD/PNV7ldzQtfKkojpThrFGZER oyrf4SqhXO4x2Q== X-Received: by 10.200.34.15 with SMTP id o15mr1615341qto.290.1500491327931; Wed, 19 Jul 2017 12:08:47 -0700 (PDT) Received: from stb-bld-02.irv.broadcom.com ([192.19.255.250]) by smtp.gmail.com with ESMTPSA id 73sm518082qkx.30.2017.07.19.12.08.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Jul 2017 12:08:47 -0700 (PDT) From: Doug Berger To: Thomas Gleixner Subject: [PATCH v2 4/6] irqchip: brcmstb-l2: Remove some processing from the handler Date: Wed, 19 Jul 2017 12:07:32 -0700 Message-Id: <20170719190734.18566-5-opendmb@gmail.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170719190734.18566-1-opendmb@gmail.com> References: <20170719190734.18566-1-opendmb@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170719_120907_451432_D84BC5C5 X-CRM114-Status: GOOD ( 18.99 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Sebastian Frias , Doug Berger , Jason Cooper , linux-mips@linux-mips.org, Boris Brezillon , Marc Zyngier , Bartosz Golaszewski , Kevin Cernekee , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Rob Herring , bcm-kernel-feedback-list@broadcom.com, Gregory Fong , Florian Fainelli , Brian Norris , linux-arm-kernel@lists.infradead.org, Marc Gonzalez 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 Saving the generic chip pointer in the brcmstb_l2_intc_data prevents the need to call irq_get_domain_generic_chip(). Also don't need to save parent_irq and base there since local variables in the brcmstb_l2_intc_of_init() function are just as good. The handle_edge_irq flow or chained_irq_enter takes care of the acknowledgement of the interrupt so it is redundant to clear it in brcmstb_l2_intc_irq_handle(). irq_linear_revmap() is a fast path equivalent of irq_find_mapping() that is appropriate to use for domain controllers of this type. Defining irq_mask_ack is slightly more efficient than just implementing irq_mask and irq_ack seperately. Reviewed-by: Florian Fainelli Signed-off-by: Doug Berger --- drivers/irqchip/irq-brcmstb-l2.c | 46 +++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/drivers/irqchip/irq-brcmstb-l2.c b/drivers/irqchip/irq-brcmstb-l2.c index bddf169c4b37..977ae55d47d4 100644 --- a/drivers/irqchip/irq-brcmstb-l2.c +++ b/drivers/irqchip/irq-brcmstb-l2.c @@ -1,7 +1,7 @@ /* * Generic Broadcom Set Top Box Level 2 Interrupt controller driver * - * Copyright (C) 2014 Broadcom Corporation + * Copyright (C) 2014-2017 Broadcom * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -41,9 +41,8 @@ /* L2 intc private data structure */ struct brcmstb_l2_intc_data { - int parent_irq; - void __iomem *base; struct irq_domain *domain; + struct irq_chip_generic *gc; bool can_wake; u32 saved_mask; /* for suspend/resume */ }; @@ -51,15 +50,14 @@ struct brcmstb_l2_intc_data { static void brcmstb_l2_intc_irq_handle(struct irq_desc *desc) { struct brcmstb_l2_intc_data *b = irq_desc_get_handler_data(desc); - struct irq_chip_generic *gc = irq_get_domain_generic_chip(b->domain, 0); struct irq_chip *chip = irq_desc_get_chip(desc); unsigned int irq; u32 status; chained_irq_enter(chip, desc); - status = irq_reg_readl(gc, CPU_STATUS) & - ~(irq_reg_readl(gc, CPU_MASK_STATUS)); + status = irq_reg_readl(b->gc, CPU_STATUS) & + ~(irq_reg_readl(b->gc, CPU_MASK_STATUS)); if (status == 0) { raw_spin_lock(&desc->lock); @@ -70,10 +68,8 @@ static void brcmstb_l2_intc_irq_handle(struct irq_desc *desc) do { irq = ffs(status) - 1; - /* ack at our level */ - irq_reg_writel(gc, 1 << irq, CPU_CLEAR); status &= ~(1 << irq); - generic_handle_irq(irq_find_mapping(b->domain, irq)); + generic_handle_irq(irq_linear_revmap(b->domain, irq)); } while (status); out: chained_irq_exit(chip, desc); @@ -116,32 +112,33 @@ static int __init brcmstb_l2_intc_of_init(struct device_node *np, { unsigned int clr = IRQ_NOREQUEST | IRQ_NOPROBE | IRQ_NOAUTOEN; struct brcmstb_l2_intc_data *data; - struct irq_chip_generic *gc; struct irq_chip_type *ct; int ret; unsigned int flags; + int parent_irq; + void __iomem *base; data = kzalloc(sizeof(*data), GFP_KERNEL); if (!data) return -ENOMEM; - data->base = of_iomap(np, 0); - if (!data->base) { + base = of_iomap(np, 0); + if (!base) { pr_err("failed to remap intc L2 registers\n"); ret = -ENOMEM; goto out_free; } /* Disable all interrupts by default */ - writel(0xffffffff, data->base + CPU_MASK_SET); + writel(0xffffffff, base + CPU_MASK_SET); /* Wakeup interrupts may be retained from S5 (cold boot) */ data->can_wake = of_property_read_bool(np, "brcm,irq-can-wake"); if (!data->can_wake) - writel(0xffffffff, data->base + CPU_CLEAR); + writel(0xffffffff, base + CPU_CLEAR); - data->parent_irq = irq_of_parse_and_map(np, 0); - if (!data->parent_irq) { + parent_irq = irq_of_parse_and_map(np, 0); + if (!parent_irq) { pr_err("failed to find parent interrupt\n"); ret = -EINVAL; goto out_unmap; @@ -170,18 +167,19 @@ static int __init brcmstb_l2_intc_of_init(struct device_node *np, } /* Set the IRQ chaining logic */ - irq_set_chained_handler_and_data(data->parent_irq, + irq_set_chained_handler_and_data(parent_irq, brcmstb_l2_intc_irq_handle, data); - gc = irq_get_domain_generic_chip(data->domain, 0); - gc->reg_base = data->base; - gc->private = data; - ct = gc->chip_types; + data->gc = irq_get_domain_generic_chip(data->domain, 0); + data->gc->reg_base = base; + data->gc->private = data; + ct = data->gc->chip_types; ct->chip.irq_ack = irq_gc_ack_set_bit; ct->regs.ack = CPU_CLEAR; ct->chip.irq_mask = irq_gc_mask_disable_reg; + ct->chip.irq_mask_ack = irq_gc_mask_disable_and_ack_set; ct->regs.disable = CPU_MASK_SET; ct->chip.irq_unmask = irq_gc_unmask_enable_reg; @@ -194,19 +192,19 @@ static int __init brcmstb_l2_intc_of_init(struct device_node *np, /* This IRQ chip can wake the system, set all child interrupts * in wake_enabled mask */ - gc->wake_enabled = 0xffffffff; + data->gc->wake_enabled = 0xffffffff; ct->chip.irq_set_wake = irq_gc_set_wake; } pr_info("registered L2 intc (mem: 0x%p, parent irq: %d)\n", - data->base, data->parent_irq); + base, parent_irq); return 0; out_free_domain: irq_domain_remove(data->domain); out_unmap: - iounmap(data->base); + iounmap(base); out_free: kfree(data); return ret;