From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755114AbcJZPuP (ORCPT ); Wed, 26 Oct 2016 11:50:15 -0400 Received: from mail-pf0-f182.google.com ([209.85.192.182]:36571 "EHLO mail-pf0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754568AbcJZPuI (ORCPT ); Wed, 26 Oct 2016 11:50:08 -0400 From: Kevin Hilman To: Linus Walleij Cc: Jerome Brunet , Marc Zyngier , Carlo Caione , "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 Subject: Re: [PATCH 4/9] pinctrl: meson: allow gpio to request irq Organization: BayLibre 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> <1477491766.2482.159.camel@baylibre.com> Date: Wed, 26 Oct 2016 08:50:06 -0700 In-Reply-To: (Linus Walleij's message of "Wed, 26 Oct 2016 16:32:29 +0200") Message-ID: <7hk2cvrtxt.fsf@baylibre.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Linus, Linus Walleij writes: > On Wed, Oct 26, 2016 at 4:22 PM, Jerome Brunet wrote: >> On Tue, 2016-10-25 at 20:20 +0200, Linus Walleij wrote: > >>> 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. > > OK good, sorry if I'm stating the obvious. > >> 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 ? > > Yes, but you want to call irq_create_mapping() in slowpath (irq setup) > and irq_find_mapping() in fastpath (irq handler). Else the first IRQ > may result in unwelcomed surprises. > >> There is really a *lot* of gpio drivers which use irq_create_mapping in >> the to_irq callback, are these all wrong ? > > Yes they are all wrong. They should all be using irq_find_mapping(). So, dumb question from someone trying (but having a hard time) to follow and understand the rationale... If it's wrong enough to completely reject, why are changes still being merged that are doing it so wrong? (e.g. like this one[1], just merged for v4.9) Kevin [1] 0eb9f683336d pinctrl: Add IRQ support to STM32 gpios https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/drivers/pinctrl/stm32/pinctrl-stm32.c?id=0eb9f683336d7eb99a3b75987620417c574ffb57