Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751548AbdFGRZ4 (ORCPT ); Wed, 7 Jun 2017 13:25:56 -0400 Received: from mout.web.de ([217.72.192.78]:51798 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751397AbdFGRZy (ORCPT ); Wed, 7 Jun 2017 13:25:54 -0400 From: Alexander Stein To: Phil Elwell Cc: linux-kernel@vger.kernel.org, Mark Rutland , Rob Herring , Stephen Boyd , Florian Fainelli , Eric Anholt , Stefan Wahren , devicetree@vger.kernel.org, linux-clk@vger.kernel.org, linux-rpi-kernel@lists.infradead.org Subject: Re: [PATCH 1/2] clk: bcm2835: Add AUX interrupt controller Date: Wed, 07 Jun 2017 19:25:07 +0200 Message-ID: <2599573.4PsWGx6B1X@localhost> In-Reply-To: <369bb235-77fb-60ad-61d8-3de039e0f838@raspberrypi.org> References: <79d4534c-49fe-3af4-13d8-2aaf22120d43@raspberrypi.org> <3148562.tSrsoIclEp@ws-stein> <369bb235-77fb-60ad-61d8-3de039e0f838@raspberrypi.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:upHvpO3gcFq1Ea8LvlzcTvMRqdzbSqbWerJtnONljOQRGlulsHE iDMFH89bMEym82kI2bB+6t+yE4vIoUi9q+4Eh3FhxLkyIhe/1q/Kj2tvlGokp4Da3aBxi96 R7nu4kOZahyXuZMGKqPItT2+bO8IxxNjhOtQ/qXQohpJREreIaRGhDXpq5CjJtIt2bmpWJg MI+gezocG/xSlsYu4aKUw== X-UI-Out-Filterresults: notjunk:1;V01:K0:wcA2wX5wbvk=:Iaa5Zzwx4pyXkjQHd+Dzio +sL2rZFRENKnEmMzbpYGZX3qGgtJhtq/zVedovmVu2OIyb52asistqXQIPt3OckT89SvTfbFe slsyGWM3C+1xK6lTzkHReW8xwhKS9qRvu3ezFCPw4LrSqNwLeZ3ua2ssKPQdFkVwgFHhinKb4 qIA9T9yRpu0LmBT2YwLv2rFHTugKbRWTJSLovQXq6LChLzFqTzJevb7Z2u9wra0sldaYKfV45 mi7iiPKxrTQHCO5xItC90Fz9nqbERSQA/kajVbm2MJ1nLj7utqBJp0nVGzaDrhM3EG+9VdXGG SqYLpA5pu4Dm0r+jrMC8WIkUjkCydDdsF4mSsoYGi+Ja/XlD67BFocjidlH5frrmHKQv/4z/e GdpcH2z10LMZYASqam90V0N1Vesdp6nlASbjT1lUlwcngqw9WfCjTvLyt00HpOKM4BEurxWKy zgSG5yVnnnZu3YnbRq5KNtJm8L6ELGXdR0FSWvA4hVWcbRjzkIo8fJ4m5y2hQwfmEi2H5uZvQ nFrefUe+qIAZyNEjLaRV+H5JkyCZ4zwU6qcWU1V9DUWDgF+qX/kzAD3FmxETXXE1kVhy+76Wi SWlQnwc6eQ7dYRUCnTSlZOFmUItc9xm0u9V8Nk6MrPy7McNZp2J3oOAHl6eLtoLycXLlFdrVr 4fc2nLEr1uqSDsNH6sQTWJVRDAOrkpfPRYiLz6UTWqBxuyznUUrOXxwjDQJSA26Xv6k8PYWme YXB3bZBdGW3hAT83/zBv1U9A86cPsmDsFbpdPJVvyICt3vIU1OyrWWcR4qA6rAxpe2NlEbw1F lof3jDgf8PBHbA8GWkfGrr7JtsMZQ== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3406 Lines: 84 On Wednesday, June 7, 2017, 2:37:41 PM CEST Phil Elwell wrote: > On 07/06/2017 13:07, Alexander Stein wrote: > > On Wednesday 07 June 2017 12:11:45, Phil Elwell wrote: > >> Devices in the AUX block share a common interrupt line, with a register > >> indicating which devices have active IRQs. Expose this as a nested > >> interrupt controller to avoid IRQ sharing problems (easily observed if > >> UART1 and SPI1/2 are enabled simultaneously). > >> > >> Signed-off-by: Phil Elwell > >> --- > >> > >> drivers/clk/bcm/clk-bcm2835-aux.c | 120 > >> > >> ++++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) > >> > >> diff --git a/drivers/clk/bcm/clk-bcm2835-aux.c > >> b/drivers/clk/bcm/clk-bcm2835-aux.c index bd750cf..41e0702 100644 > >> --- a/drivers/clk/bcm/clk-bcm2835-aux.c > >> +++ b/drivers/clk/bcm/clk-bcm2835-aux.c > >> [...] > >> +struct auxirq_state { > >> + void __iomem *status; > >> + u32 enables; > >> + struct irq_domain *domain; > >> + struct regmap *local_regmap; > >> +}; > >> + > >> +static struct auxirq_state auxirq __read_mostly; > >> + > >> +static irqreturn_t bcm2835_auxirq_handler(int irq, void *dev_id) > >> +{ > >> + u32 stat = readl_relaxed(auxirq.status); > >> + u32 masked = stat & auxirq.enables; > > > > Doesn't this hide any spurious interrupts? Is this acceptable? I mean > > getting informed about spurious interrupts seems nice to me, as it > > indicates a hardware/configuration problem. > > Thanks for the reply. This interrupt handler is capable of dispatching > multiple interrupts but must return a single value - IRQ_HANDLED or > IRQ_NONE. I've assumed that returning IRQ_NONE repeatedly will trigger the > spurious interrupt detection. > > This implementation returns IRQ_HANDLED if any unmasked interrupts are > raised, otherwise it returns IRQ_NONE. Therefore provided any spurious > interrupt isn't always coincident with a real interrupt then it ought > eventually to be identified as spurious. The alternative - returning > IRQ_NONE if there are any spurious interrupts - seems prone to causing > collateral damage. > > What did you have in mind? I was wondering about "stat & auxirq.enables". With that you wouldn't forward any spurious interrupts to e.g. SPI1. I don't know which way is better, returning IRQ_NONE is a masked interrupt happens, or pass it further down. I guess this also raises a warning if the SPI driver also returns IRQ_NONE. BTW: Is it even allowed to call generic_handle_irq on a masked irq? > >> + if (masked & BCM2835_AUXIRQ_UART_MASK) > >> + generic_handle_irq(irq_linear_revmap(auxirq.domain, > >> + BCM2835_AUXIRQ_UART_IRQ)); > >> + > >> + if (masked & BCM2835_AUXIRQ_SPI1_MASK) > >> + generic_handle_irq(irq_linear_revmap(auxirq.domain, > >> + BCM2835_AUXIRQ_SPI1_IRQ)); > >> + > >> + if (masked & BCM2835_AUXIRQ_SPI2_MASK) > >> + generic_handle_irq(irq_linear_revmap(auxirq.domain, > >> + BCM2835_AUXIRQ_SPI2_IRQ)); > >> + > >> + return (masked & BCM2835_AUXIRQ_ALL_MASK) ? IRQ_HANDLED : IRQ_NONE; > >> +} > > > > How does interrupt acknowledgement work in these 3 interrupts work? > > The interrupt "controller" is just combinatorial logic on the three > level-sensitive interrupt lines from the devices. Interrupts must be > acknowledged and cleared at source. Thanks for the info. Best regards, Alexander