From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932702AbcJZOWz (ORCPT ); Wed, 26 Oct 2016 10:22:55 -0400 Received: from mail-wm0-f51.google.com ([74.125.82.51]:37384 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932124AbcJZOWx (ORCPT ); Wed, 26 Oct 2016 10:22:53 -0400 Message-ID: <1477491766.2482.159.camel@baylibre.com> Subject: Re: [PATCH 4/9] pinctrl: meson: allow gpio to request irq From: Jerome Brunet To: Linus Walleij Cc: Marc Zyngier , Carlo Caione , Kevin Hilman , "open list:ARM/Amlogic Meson..." , "linux-arm-kernel@lists.infradead.org" , "linux-gpio@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "devicetree@vger.kernel.org" , Thomas Gleixner , Jason Cooper , Rob Herring , Catalin Marinas , Will Deacon , Russell King Date: Wed, 26 Oct 2016 16:22:46 +0200 In-Reply-To: References: <1476871709-8359-1-git-send-email-jbrunet@baylibre.com> <1476871709-8359-5-git-send-email-jbrunet@baylibre.com> <1477040798.15560.96.camel@baylibre.com> <1477400900.2482.51.camel@baylibre.com> <1477405332.2482.87.camel@baylibre.com> <1477409478.2482.113.camel@baylibre.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.20.5 (3.20.5-1.fc24) Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2016-10-25 at 20:20 +0200, Linus Walleij wrote: > On Tue, Oct 25, 2016 at 5:31 PM, Jerome Brunet > wrote: > > > > On Tue, 2016-10-25 at 15:47 +0100, Marc Zyngier wrote: > > > > > > > > > Is gpio_to_irq() supposed to allocate an interrupt? Or merely to > > > report the existence of a mapping? > > It should provide an IRQ corresponding to the gpio line, if possible. > > However the semantic is such, that it is not necessary to call > to_irq() > before using an IRQ: the irqchip and gpiochip abstractions should be > orthogonal. Linus, They are orthogonal. You can request an irq from the irqchip controller without the gpiochip, like any other irq controller. > > This goes especially when using device tree or ACPI, where you > may reference an IRQ from something modeled as irqchip, which > is simultaneously a gpiochip. > > > > > Linus, please correct me if I'm wrong, > > .to_irq gets the linux gpio number and returns the linux virtual > > irq > > numbers, 0 if there is no interrupt. > > Yes. But it may *or may not* be called before using the IRQ. > > So it should look up or try to create a mapping on request, but not > assume to have been called before using some line as IRQ. > > The only thing you should assume to be called before an interrupt > is put to use is the stuff in irqchip. So you have to do your > dynamic irqdomain mapping elsewhere than .to_irq(). irq_create_mapping (and irq_create_fwspec_mapping) internally calls irq_find_mapping. So if the mapping already exist (the irq is already used before calling to_irq), the existing mapping will be returned. The mapping will be actually created only if needed. It seems to be in line with your explanation, no ? There is really a *lot* of gpio drivers which use irq_create_mapping in the to_irq callback, are these all wrong ? If this should not be used, what should we all do instead ?  > > Yours, > Linus Walleij