From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758443AbcK3RIc (ORCPT ); Wed, 30 Nov 2016 12:08:32 -0500 Received: from fllnx209.ext.ti.com ([198.47.19.16]:16153 "EHLO fllnx209.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758074AbcK3RIX (ORCPT ); Wed, 30 Nov 2016 12:08:23 -0500 Subject: Re: question about irq_enter()/irq_exit() calling policy To: Russell King - ARM Linux References: <22d0d991-bbe2-ce10-5202-3cdf97a9ecf2@ti.com> <20161130102134.GB14217@n2100.armlinux.org.uk> CC: , , From: Grygorii Strashko Message-ID: <9c334b42-6b22-397f-93f6-e19e9163a17c@ti.com> Date: Wed, 30 Nov 2016 11:07:49 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20161130102134.GB14217@n2100.armlinux.org.uk> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [128.247.83.173] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Russell, On 11/30/2016 04:21 AM, Russell King - ARM Linux wrote: > On Tue, Nov 29, 2016 at 05:47:12PM -0600, Grygorii Strashko wrote: >> 2) Should these function be called for each processed irq? >> >> >> HW IRQ: >> switch (IRQ mode) >> ... >> while (irq = get_pending_irq()) { >> ... >> irq_enter() >> handle(irq) - execute hw_irq_hadler >> irq_exit() >> } >> ... >> switch > > We tend to do (2) as a general rule, which isn't much different from what > other architectures do - even if they have a method to directly enter > through vectors (eg, x86) the effect of two pending interrupts is that one > will run after each other, and there will be an intervening exit -> entry. > > In the case of ARM CPUs, if the interrupt signal is active, you vector > back to the interrupt handler as soon as you exit back to the parent > context without executing any parent context instructions. > > So, we have the choice of going through all the IRQ entry code, processing > one interrupt, and returning only to then re-vector back through the IRQ > entry code, or we can process all the pending IRQs that we can see at that > time. > > The former method wastes all the CPU cycles getting from the parent context > to the IRQ context for each and every interrupt. > Thanks a lot for your detailed explanation. When I've asked this question my intention was to understand possibility of calling irq_enter()/irq_exit() only once for the case (2), like: HW IRQ: switch (IRQ mode) ... irq_enter() while (irq = get_pending_irq()) { ... handle(irq) - execute hw_irq_hadler } irq_exit() ... switch -- regards, -grygorii