Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1904390imj; Sun, 17 Feb 2019 18:06:46 -0800 (PST) X-Google-Smtp-Source: AHgI3Iax+FcjlAGSS3bLp7J7R3xaOPxTEhIUjsCobVXYb44NblhCUcWfRP64ZJqIZp0HKQEWOk9b X-Received: by 2002:a62:3888:: with SMTP id f130mr21417303pfa.132.1550455606636; Sun, 17 Feb 2019 18:06:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550455606; cv=none; d=google.com; s=arc-20160816; b=hEBo9SBAVE0aV9BaRRLuztL7GLlxA/ZrKbuo4LP1KhxwhO1tku2LGWUGeyI59iOt4K lNex74IogYuvK0wTUaYP+o3pFI+iVTNXsu5W1REh9gRG1g25dKUFZU9u0YtjwibceHD0 87aX8fK4q6Q1qH6SFF5B6+n3DcFjFUGTicQc3n6D48dfZEcPAdwx1DrDjkcf/ny2s00G eFYA8VUcyKvdPDwxuZa9mPy8/D1yRhs8E4KDg20jW0w0CmjvmoLqtawuGURkNEBPQrDq VPwroH24W2b1YX3mXRupc3BnByjhk4uDNIBSHVgsUz9PKh1aLXPcEQSWlB9WTLuoLnlT d+qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=LL2wPhl7YEkfNNyQlMzrYCpd/Kh9aNj7Ea9/oKB5QBQ=; b=N8qeyJhgEdokKy7nS4D6r8yWz7i78Bomxm81ggXRt6QpP2qK5vW4zPV/t0xth4Ggsa fpvbSUZIpnd6nRfLnTDtW6cyyzsAIPMcGCnzb7HdVQqLQfJsDNW4k6MksJJM1WF5LQ7U 53eqCJQUry9WUd1zmBWEgng51lvENB/CWRxFyswAoO8Bqlo7KPxs30Cbx5+Cw6DlqDRN XFEFGKRu2cq/ezBhyVvvOyopGt7+nOqdimsFd7ROntsDR2exz9xn2otimXlke5hX4f/U VuvPWAkOhjwaaHhwae+TI8TCBHZz1gt8I9bz93eh5BxvAvCSVCnTRX3zbEdhpOT9qDcW 6a9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="hHF89bj/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a90si12513140plc.314.2019.02.17.18.06.31; Sun, 17 Feb 2019 18:06:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="hHF89bj/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728286AbfBRCFA (ORCPT + 99 others); Sun, 17 Feb 2019 21:05:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:52906 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728238AbfBRCE6 (ORCPT ); Sun, 17 Feb 2019 21:04:58 -0500 Received: from localhost.localdomain (unknown [122.234.57.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4BAAA218DE; Mon, 18 Feb 2019 02:04:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550455497; bh=ed1VjmqKzMydv/xvnLDn+jcuERcIg8YPmwr8UPds0LQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hHF89bj/r+8/cUAlPQNmLjcCblhL6j3E/jDJSZWKIonKl+Zx388XrgqK7BMcKPQ6B h5No+U2BGKGmMrb5EoegPj7OMNQgryP923cTHwWVDHP0PmWkuQvt5CfmYTjc6mxixO +P7nA2/elu+ZyFOOuS2xS8XBmI6CzUHo6rVJY9aU= From: guoren@kernel.org To: marc.zyngier@arm.com, tglx@linutronix.de, robh+dt@kernel.org Cc: linux-kernel@vger.kernel.org, guoren@kernel.org, Guo Ren Subject: [PATCH V2 3/7] irqchip/csky: Optimize remove unnecessary loop irq handle Date: Mon, 18 Feb 2019 10:04:39 +0800 Message-Id: <1550455483-11710-3-git-send-email-guoren@kernel.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1550455483-11710-1-git-send-email-guoren@kernel.org> References: <1550455483-11710-1-git-send-email-guoren@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Guo Ren Here is the previous interrupt processing flow: while (pending) { ^^^^^^^^^^^^^^^ It's unnecessary! get irq handle_level/fasteoi_irq { mask irq driver irq handler unmask irq } irq_exit { preempt_count_sub(HARDIRQ_OFFSET); if (!in_interrupt() && local_softirq_pending()) invoke_softirq(); Because: ^^^^^^^^^^^^^^^^ linux enable irq Here! } } Because linux enable the irq in irq_exit() before ret, we needn't loop read pending register again for next irq which is done during irq_exit(). Signed-off-by: Guo Ren Cc: Thomas Gleixner Cc: Marc Zyngier --- drivers/irqchip/irq-csky-apb-intc.c | 36 ++++++++++++++++++------------------ drivers/irqchip/irq-csky-mpintc.c | 8 ++------ 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/drivers/irqchip/irq-csky-apb-intc.c b/drivers/irqchip/irq-csky-apb-intc.c index fcc5444..ae4c59b 100644 --- a/drivers/irqchip/irq-csky-apb-intc.c +++ b/drivers/irqchip/irq-csky-apb-intc.c @@ -150,7 +150,7 @@ ck_intc_init_comm(struct device_node *node, struct device_node *parent) return 0; } -static inline bool handle_irq_perbit(struct pt_regs *regs, u32 hwirq, +static inline bool handle_irq_onebit(struct pt_regs *regs, u32 hwirq, u32 irq_base) { if (hwirq == 0) @@ -166,16 +166,15 @@ static void gx_irq_handler(struct pt_regs *regs) { bool ret; -retry: - ret = handle_irq_perbit(regs, + ret = handle_irq_onebit(regs, readl(reg_base + GX_INTC_PEN63_32), 32); if (ret) - goto retry; + return; - ret = handle_irq_perbit(regs, + ret = handle_irq_onebit(regs, readl(reg_base + GX_INTC_PEN31_00), 0); - if (ret) - goto retry; + if (!ret) + pr_err("%s: none irq pending!\n", __func__); } static int __init @@ -277,29 +276,30 @@ static void ck_irq_handler(struct pt_regs *regs) void __iomem *reg_pen_lo = reg_base + CK_INTC_PEN31_00; void __iomem *reg_pen_hi = reg_base + CK_INTC_PEN63_32; -retry: /* handle 0 - 63 irqs */ - ret = handle_irq_perbit(regs, readl(reg_pen_hi), 32); + ret = handle_irq_onebit(regs, readl(reg_pen_hi), 32); if (ret) - goto retry; + return; - ret = handle_irq_perbit(regs, readl(reg_pen_lo), 0); + ret = handle_irq_onebit(regs, readl(reg_pen_lo), 0); if (ret) - goto retry; + return; - if (nr_irq == INTC_IRQS) + if (nr_irq == INTC_IRQS) { + pr_err("%s: none irq pending!\n", __func__); return; + } /* handle 64 - 127 irqs */ - ret = handle_irq_perbit(regs, + ret = handle_irq_onebit(regs, readl(reg_pen_hi + CK_INTC_DUAL_BASE), 96); if (ret) - goto retry; + return; - ret = handle_irq_perbit(regs, + ret = handle_irq_onebit(regs, readl(reg_pen_lo + CK_INTC_DUAL_BASE), 64); - if (ret) - goto retry; + if (!ret) + pr_err("%s: none irq pending!\n", __func__); } static int __init diff --git a/drivers/irqchip/irq-csky-mpintc.c b/drivers/irqchip/irq-csky-mpintc.c index c67c961..99d3f3f 100644 --- a/drivers/irqchip/irq-csky-mpintc.c +++ b/drivers/irqchip/irq-csky-mpintc.c @@ -33,7 +33,6 @@ static void __iomem *INTCL_base; #define INTCL_PICTLR 0x0 #define INTCL_SIGR 0x60 -#define INTCL_HPPIR 0x68 #define INTCL_RDYIR 0x6c #define INTCL_SENR 0xa0 #define INTCL_CENR 0xa4 @@ -45,11 +44,8 @@ static void csky_mpintc_handler(struct pt_regs *regs) { void __iomem *reg_base = this_cpu_read(intcl_reg); - do { - handle_domain_irq(root_domain, - readl_relaxed(reg_base + INTCL_RDYIR), - regs); - } while (readl_relaxed(reg_base + INTCL_HPPIR) & BIT(31)); + handle_domain_irq(root_domain, + readl_relaxed(reg_base + INTCL_RDYIR), regs); } static void csky_mpintc_enable(struct irq_data *d) -- 2.7.4