Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932083AbdHRAzC (ORCPT ); Thu, 17 Aug 2017 20:55:02 -0400 Received: from mail-cys01nam02on0075.outbound.protection.outlook.com ([104.47.37.75]:46231 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753891AbdHRAxq (ORCPT ); Thu, 17 Aug 2017 20:53:46 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=David.Daney@cavium.com; From: David Daney To: Linus Walleij , Alexandre Courbot , Mark Rutland , Marc Zyngier , Thomas Gleixner , linux-gpio@vger.kernel.org Cc: linux-kernel@vger.kernel.org, David Daney Subject: [PATCH v8 2/7] genirq: Add handle_fasteoi_{level,edge}_irq flow handlers. Date: Thu, 17 Aug 2017 17:53:31 -0700 Message-Id: <1503017616-3252-3-git-send-email-david.daney@cavium.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1503017616-3252-1-git-send-email-david.daney@cavium.com> References: <1503017616-3252-1-git-send-email-david.daney@cavium.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [50.233.148.156] X-ClientProxiedBy: CO2PR07CA0061.namprd07.prod.outlook.com (10.174.192.29) To CY4PR07MB3493.namprd07.prod.outlook.com (10.171.252.150) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 19dc3800-6018-454d-d136-08d4e5d393de 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:CY4PR07MB3493; X-Microsoft-Exchange-Diagnostics: 1;CY4PR07MB3493;3:7PaZ/GxSoNfmiWlU/8dMgOucVDo9grtCIFsb2DK633dDH9f/Nr9ApNHiM/I0Wmubjte3KzgJuEDr73L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ak1Eng/QJB0ugyYEKjBwcPVpqz3QwkN9Y8g6MoXGjDG9qWS9KBSsN+9SDFJMo7SxBmaKOHw6lk79OCK0G9l7IvKTX8WaRBKk5upO2nCD5SFXHwBOps2K5pqC9ZjozrAxI2nXUczbRXGJg+x8Fcq/M3X8eY2g4gA7dn1T/tlRWdZSXSSpcs0X6aznaid+90HtFGucRPYhCxVFzwsewgSxs3Yhv/06bHskoBmwmwEo1qNrKCl5h0CPvLJbeTCOIwCS/O5aFvbVLQb3LOkXEk;4:tg36VV03EUva3v2SJg7Qao1cO56guxoTQuc6YQgT27D4wd2XnvsHp8VcU1E0fe9upgMj+EwxfQ2AcdlNr8Ennbg4gZoJA97X1Rr/uwfGCkjgCQQyzIOKzEpHdSh/UXndlkIWHHQkA+z/TReDW/dGP/mFjegN/a4BbVtLr6IsNwl2z7JnnQRp8MXT5i1coC4N5G3Ul3tIa5lGX046QrlXjAK7djSPiyVb/Wvc0L94ZxjpvMejPMux1tfWpEgpwqsK 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)(10201501046)(3002001)(100000703101)(100105400095)(93006095)(93001095)(6041248)(20161123562025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123560025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:CY4PR07MB3493;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:CY4PR07MB3493; X-Forefront-PRVS: 040359335D X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(7370300001)(979002)(6009001)(189002)(199003)(69596002)(72206003)(50226002)(6116002)(3846002)(4326008)(105586002)(42186005)(2950100002)(6666003)(5003940100001)(4720700003)(76176999)(50986999)(5660300001)(189998001)(7350300001)(53416004)(33646002)(101416001)(53936002)(478600001)(6512007)(50466002)(2906002)(48376002)(7736002)(68736007)(107886003)(66066001)(25786009)(86362001)(47776003)(97736004)(36756003)(106356001)(6486002)(6506006)(305945005)(81156014)(81166006)(8676002)(142933001)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR07MB3493;H:ubuntu.caveonetworks.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CY4PR07MB3493;23:MamD+79tmDDy6IrxPSJWMbu+lAZUcLFyCnJxuqvMN?= =?us-ascii?Q?0Wb+5tok+ZnRTnGmmxrGld671OqXVyWJFAtQJGfqApckJBb37Cs2GtpXJ+fp?= =?us-ascii?Q?eRaJX5hoqfvNH2456UgDzSJAUuphYPnP4YMbjepuGxWxD+R/kehlKh6RC9i0?= =?us-ascii?Q?nzYHuD4yusl0cvx75h7Crn4OKBwUhI6SJ2lhJwFLEyrgVFfL50U80uZTeoxN?= =?us-ascii?Q?mKvPNaX2aG4pGG7qNd7+0lRG06dDBHL8ALH+5kXJnFkr03p4oRXOxd4BCFEc?= =?us-ascii?Q?6ykNhh1TBO0touYKhSr3R2G5ulYzAYxvnlvHWuoIh252cLTqkTkjj9hKVAXU?= =?us-ascii?Q?hEbaJKWYtVC7Yg/v/Kd7cbqoiqAgP8OXXaNGoWYIDGCKZHJpyn0yjBY8uiGl?= =?us-ascii?Q?VHnQ/MIDVnr/a/s3GWadNcdFn5zmwBmNgf3PkeXIZU1eB5bL5Twq94e4xWgO?= =?us-ascii?Q?gaHBCd3yp/buFTbNYfxd/JA4XZtjgNAFiLkF1uHyVPb9oVCGP4piPRiD+etm?= =?us-ascii?Q?VcC1TLbftUoz3GlLfDdEC00JyRH4DOBlZX/yl2ZyxgRATRMl9wHNVuzMyDs5?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mD9GjtZkFUywPmnWOkHlqx3RYpIi3KOGySvLng3FGg+UErk/394blflX5NaRh7v8fG2oFwHnzhZSdeuO41oJMist5qT/Jg7kTcUoJNiwf2VcuWuxUNAH90ScpCoY2vU0SWAWe6afiqG1KjJ0E62f6fEcHtFPAR1DyUUXVPuroR4XrztQ==;5:c2NeRAKpaa88AzmWx2g6UKGw2d/NkJShaDkfy3/HjFxCL4pdO/cS5pvTYPK/Ny6e9iiSHFq3P30Ly3HENKecr2U7UmrXowQJ1U8P0NU+O0D/Ay/hzQq/DwEv1/w/s9ph/y4oPDw5mhKf8utaai+jYw==;24:u6oytMRDg2hd/Ftjg3iK13KfXbm4saWpYj8p4xYvd/wrNO0qbS9kGQSy4cKDstB3+oIziwcIE87CLEpRRWXFw6BlXaXMlF7G+NnTO0EuRcw=;7:FTMB2vsloXuOMNq7i+tjR0d+lHFAwLARUTKqZSk129CreuXrH77hk+KTj570Tj8BJUnHFKqUB6Qm8ACkgDyTaUXtc5lbnRv9Genm6G0Dv04an1K0DmbtKD1xWZl1WupaNw1ZBL8eAYvIk5AhNCsjl8zmPrJbysHSiUW7YAc4yoPo6m5/KajHDMuh9ENgv4Cx5CAAlLgobC9u6jWVHPv1sIF92l869Cbr7YCUVbQSB9s= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2017 00:53:44.3102 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR07MB3493 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4412 Lines: 159 Follow-on patch for gpio-thunderx uses a irqdomain hierarchy which requires slightly different flow handlers, add them to chip.c which contains most of the other flow handlers. Make these conditionally compiled based on CONFIG_IRQ_FASTEOI_HIERARCHY_HANDLERS. Signed-off-by: David Daney --- include/linux/irq.h | 2 + kernel/irq/Kconfig | 4 ++ kernel/irq/chip.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 112 insertions(+) diff --git a/include/linux/irq.h b/include/linux/irq.h index d2d54379..d4728bf 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -568,6 +568,8 @@ static inline int irq_set_parent(int irq, int parent_irq) extern int irq_chip_pm_get(struct irq_data *data); extern int irq_chip_pm_put(struct irq_data *data); #ifdef CONFIG_IRQ_DOMAIN_HIERARCHY +extern void handle_fasteoi_ack_irq(struct irq_desc *desc); +extern void handle_fasteoi_mask_irq(struct irq_desc *desc); extern void irq_chip_enable_parent(struct irq_data *data); extern void irq_chip_disable_parent(struct irq_data *data); extern void irq_chip_ack_parent(struct irq_data *data); diff --git a/kernel/irq/Kconfig b/kernel/irq/Kconfig index 27c4e77..aada687 100644 --- a/kernel/irq/Kconfig +++ b/kernel/irq/Kconfig @@ -68,6 +68,10 @@ config IRQ_DOMAIN_HIERARCHY bool select IRQ_DOMAIN +# Support for hierarchical fasteoi+edge and fasteoi+level handlers +config IRQ_FASTEOI_HIERARCHY_HANDLERS + bool + # Generic IRQ IPI support config GENERIC_IRQ_IPI bool diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c index 6514f07..2395898 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -1092,6 +1092,112 @@ void irq_cpu_offline(void) } #ifdef CONFIG_IRQ_DOMAIN_HIERARCHY + +#ifdef CONFIG_IRQ_FASTEOI_HIERARCHY_HANDLERS +/** + * handle_fasteoi_ack_irq - irq handler for edge hierarchy + * stacked on transparent controllers + * + * @desc: the interrupt description structure for this irq + * + * Like handle_fasteoi_irq(), but for use with hierarchy where + * the irq_chip also needs to have its ->irq_ack() function + * called. + */ +void handle_fasteoi_ack_irq(struct irq_desc *desc) +{ + struct irq_chip *chip = desc->irq_data.chip; + + raw_spin_lock(&desc->lock); + + if (!irq_may_run(desc)) + goto out; + + desc->istate &= ~(IRQS_REPLAY | IRQS_WAITING); + + /* + * If its disabled or no action available + * then mask it and get out of here: + */ + if (unlikely(!desc->action || irqd_irq_disabled(&desc->irq_data))) { + desc->istate |= IRQS_PENDING; + mask_irq(desc); + goto out; + } + + kstat_incr_irqs_this_cpu(desc); + if (desc->istate & IRQS_ONESHOT) + mask_irq(desc); + + /* Start handling the irq */ + desc->irq_data.chip->irq_ack(&desc->irq_data); + + preflow_handler(desc); + handle_irq_event(desc); + + cond_unmask_eoi_irq(desc, chip); + + raw_spin_unlock(&desc->lock); + return; +out: + if (!(chip->flags & IRQCHIP_EOI_IF_HANDLED)) + chip->irq_eoi(&desc->irq_data); + raw_spin_unlock(&desc->lock); +} +EXPORT_SYMBOL_GPL(handle_fasteoi_ack_irq); + +/** + * handle_fasteoi_mask_irq - irq handler for level hierarchy + * stacked on transparent controllers + * + * @desc: the interrupt description structure for this irq + * + * Like handle_fasteoi_irq(), but for use with hierarchy where + * the irq_chip also needs to have its ->irq_mask_ack() function + * called. + */ +void handle_fasteoi_mask_irq(struct irq_desc *desc) +{ + struct irq_chip *chip = desc->irq_data.chip; + + raw_spin_lock(&desc->lock); + mask_ack_irq(desc); + + if (!irq_may_run(desc)) + goto out; + + desc->istate &= ~(IRQS_REPLAY | IRQS_WAITING); + + /* + * If its disabled or no action available + * then mask it and get out of here: + */ + if (unlikely(!desc->action || irqd_irq_disabled(&desc->irq_data))) { + desc->istate |= IRQS_PENDING; + mask_irq(desc); + goto out; + } + + kstat_incr_irqs_this_cpu(desc); + if (desc->istate & IRQS_ONESHOT) + mask_irq(desc); + + preflow_handler(desc); + handle_irq_event(desc); + + cond_unmask_eoi_irq(desc, chip); + + raw_spin_unlock(&desc->lock); + return; +out: + if (!(chip->flags & IRQCHIP_EOI_IF_HANDLED)) + chip->irq_eoi(&desc->irq_data); + raw_spin_unlock(&desc->lock); +} +EXPORT_SYMBOL_GPL(handle_fasteoi_mask_irq); + +#endif /* CONFIG_IRQ_FASTEOI_HIERARCHY_HANDLERS */ + /** * irq_chip_enable_parent - Enable the parent interrupt (defaults to unmask if * NULL) -- 1.8.3.1