All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: Suresh Mangipudi <smangipudi@nvidia.com>,
	Laxman Dewangan <ldewangan@nvidia.com>,
	Jon Hunter <jonathanh@nvidia.com>,
	"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
	"linux-tegra@vger.kernel.org" <linux-tegra@vger.kernel.org>
Subject: Re: [PATCH v2] gpio: Add Tegra186 support
Date: Mon, 3 Apr 2017 07:28:09 +0200	[thread overview]
Message-ID: <20170403052809.GA4203@ulmo.ba.sec> (raw)
In-Reply-To: <CACRpkdZBp1Q=J9QgwegcfqxmnDSjzYnJQg1t2UpbRkemo9aCWg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3180 bytes --]

On Sat, Apr 01, 2017 at 07:46:24PM +0200, Linus Walleij wrote:
> On Fri, Mar 31, 2017 at 4:54 PM, Thierry Reding
> <thierry.reding@gmail.com> wrote:
> > On Fri, Mar 31, 2017 at 03:59:40PM +0200, Linus Walleij wrote:
> 
> > If I call this multiple times with different parent_irq parameters, then
> > only the last one will be stored in gpiochip->irq_chained_parent. Later
> > on, this is used to disconnect the chained handler and data upon GPIO
> > chip removal, which means that handler and data for all but the last one
> > end up dangling.
> 
> People are using this code already for chained handlers with several
> parents.
> 
> I guess it works so nicely because gpiochips are often just added
> and seldom removed.
> 
> Overall that means this is a bug and should be fixed, not that new
> drivers should avoid using this approach, or that we should discourage
> new drivers to use this API.
> 
> >>       /* Set the parent IRQ for all affected IRQs */
> >>       for (offset = 0; offset < gpiochip->ngpio; offset++) {
> >>               if (!gpiochip_irqchip_irq_valid(gpiochip, offset))
> >>                       continue;
> >>               irq_set_parent(irq_find_mapping(gpiochip->irqdomain, offset),
> >>                              parent_irq);
> >>       }
> >> }
> >
> > Similarly here, we'd be setting the parent IRQ of all associated GPIOs
> > to the first, second... last parent IRQ. This is completely unnecessary
> > work and it's also setting the wrong parent. Note that we don't actually
> > care about that in the driver right now, but it's still wrong.
> 
> Is that a way of saying there are bugs in the gpiolib?
> 
> I know there are, maintainers working on core code are always
> lacking. I wrote this code and I admit I make mistakes, please help
> me fix them instead of trying to make this into a reason not to
> use this code.

Fair enough. I'll see if I can turn this into something that I can use
for this particular driver. I suspect it'll be a bit cumbersome because
of the parent/child relationship, but I have a couple of ideas that I'd
like to try out.

> >> Why are you keeping the irqs around after requesting?
> >> Use devm_*
> >
> > First I prefer to keep resource request and driver initialization
> > separate because it makes error recovery more robust. So this is used to
> > first store the results from platform_get_irq() and later on to iterate
> > over when installing the chained handlers.
> 
> OK no big deal. But it could be in a local variable rather than
> in the driver state container, right?

Well, I also need the same array of interrupts to remove the handlers
again, so I don't think local would be enough. But...

> 
> > Also, devm_* doesn't exist for irq_set_chained_handler_and_data(). So I
> > need to keep these around in order to properly uninstall the handlers
> > again on removal.
> 
> OK is this something that should be fixed in the irqchip code?

... with this in place it wouldn't be necessary. Cross-subsystem series
are unlikely to make it for v4.12 at this point, so here go my hopes to
get this merged sometime soon...

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      reply	other threads:[~2017-04-03  5:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-10 16:26 [PATCH v2] gpio: Add Tegra186 support Thierry Reding
2017-03-13  7:06 ` Thierry Reding
     [not found]   ` <20170313070623.GA15513-EkSeR96xj6Pcmrwk2tT4+A@public.gmane.org>
2017-03-14 15:20     ` Linus Walleij
     [not found] ` <20170310162629.31455-1-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-03-13 16:22   ` Laxman Dewangan
     [not found]     ` <58C6C72C.4080408-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2017-03-13 17:44       ` Thierry Reding
2017-03-31 13:10   ` Thierry Reding
     [not found]     ` <20170331131006.GC29779-EkSeR96xj6Pcmrwk2tT4+A@public.gmane.org>
2017-03-31 13:36       ` Linus Walleij
     [not found]         ` <CACRpkdZwb37kSgKDo=6v-G102KGs0NVB1CZg+MEOKDaA8dKuLg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-04-01  7:45           ` Laxman Dewangan
2017-03-31 13:59   ` Linus Walleij
     [not found]     ` <CACRpkdZpev7op=4e7DwYfnRpNBPN6U_EXd6G3PqM-XQudLHqow-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-31 14:54       ` Thierry Reding
     [not found]         ` <20170331145437.GA16964-EkSeR96xj6Pcmrwk2tT4+A@public.gmane.org>
2017-04-01 17:46           ` Linus Walleij
2017-04-03  5:28             ` Thierry Reding [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170403052809.GA4203@ulmo.ba.sec \
    --to=thierry.reding@gmail.com \
    --cc=jonathanh@nvidia.com \
    --cc=ldewangan@nvidia.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=smangipudi@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.