linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ferenc Wagner <wferi@niif.hu>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: "Dmitry Eremin-Solenikov" <dbaryshkov@gmail.com>,
	linux-input@vger.kernel.org,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Subject: Re: [PATCH] input: make gpio-keys use IRQF_SHARED
Date: Thu, 01 Oct 2009 16:02:15 +0200	[thread overview]
Message-ID: <87fxa3xleg.fsf@tac.ki.iif.hu> (raw)
In-Reply-To: <20090928170301.GG21455@core.coreip.homeip.net> (Dmitry Torokhov's message of "Mon, 28 Sep 2009 10:03:01 -0700")

Dmitry Torokhov <dmitry.torokhov@gmail.com> writes:

> On Tue, Sep 22, 2009 at 09:06:05PM +0200, Ferenc Wagner wrote:
>
>> Dmitry Torokhov <dmitry.torokhov@gmail.com> writes:
>> 
>>> On Tue, Sep 22, 2009 at 05:14:22PM +0200, Ferenc Wagner wrote:
>>>
>>>>     The gpio_get_value function may sleep, so it should not be
>>>>     called in a timer function.
>>>> 
>>>> But I don't see why it could sleep, is that really the case?
>>>
>>> There are things like i2c gpio extenders that require access to
>>> slow buses and can sleep.
>>
>> Please read my other reply in this thread before the following.
>> All this seems to mean that using level triggered interrupts on
>> such devices is impossible, unless we find a way to acknowledge the
>> interrupt without GPIO access.
>
> You probably want to look into threaded interrupt handlers and
> IRQF_ONESHOT. These can't be shared though, so it looks like you
> need nested IRQ handlers infrastructure.

This sounds like a job for the irqchip setup code, if I understand
http://lkml.org/lkml/2009/8/15/133 correctly, that is, no driver
business.  Doesn't that apply only when the irqchip itself is on a
slow bus?  I find IRQF_ONESHOT more relevant, and sharing such a beast
would be possible in principle, although a little complicated, as
http://lkml.org/lkml/2009/8/15/131 asserts.  But still, how would the
somewhat more latency-sensitive serial port on the same interrupt line
tolerate its interrupt staying masked for a considerable period?  Even
if there was no hardware which shared interrupts between slow and fast
devices (which I hope), a driver blindly using oneshot interrupts
would unnecessarily add the scheduling delay to the masked period
instead of acknowledging and unmasking the line from hardirq context.
Please correct me if I got these wrong.

On the other hand, querying gpio_cansleep could be used to avoid this,
and I can't conceive how the IRQ core could find out and do what's
best for the driver in such cases.

>> But level triggering is needed for sharing.
>
> I believe that both level and edge-triggered interrupts can be shared.

Sure, but all parties must agree on the trigger type, and level
triggering seems to be the norm (I've read
http://lkml.org/lkml/1998/8/7/30 on the unreliability of shared edge
triggered interrupts, but I don't buy Linus' argument, because the
system should keep asking the devices until none of them needs
servicing -- ineffective, but reliable).  Anyway, in my (and therefore
the most important) case the serial console grabs the interrupt first,
and although it's willing to share it, it uses level triggering, so
I've got no choice.

>>>> Also, commit 57ffe9d539e0eb741bb9ca8f2834d210e70ee2e3 removed the
>>>> possibility of telling apart different keys, so that should be
>>>> reverted during the process.  I already asked Uwe Kleine-König
>>>> about the whys, but didn't get a reply.
>>>
>>> I don't see why you say that... You request IRQ per button and you get
>>> that button structure as argument in the interrupt handler.
>> 
>> In practice, several buttons often share a single IRQ line, possibly
>> even with other hardware, like the serial port in my case (as
>> described in my other reply).  So generally you need the full platform
>> data for all GPIO buttons in the handler, to find out which generated
>> the interrupt.
>
> Your interrupt handler will get called for every button on that IRQ line
> and you can query button state I think.

Well, yes, if I register the handler once for each button.  Is that
really preferable?  It didn't occur to me as the current code does not
use shared interrupts, so it's out of question.  Sigh, the generic
GPIO interface is already rather inefficient, accessing only a single
bit per call (cf. the first block comment in tosakbd.c)...
Or did I get you wrong again?
-- 
Thanks,
Feri.
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2009-10-01 14:02 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-16 15:03 [PATCH] input: make gpio-keys use IRQF_SHARED Dmitry Eremin-Solenikov
2009-09-16 16:28 ` Dmitry Torokhov
2009-09-16 18:41   ` Dmitry Eremin-Solenikov
2009-09-18 11:44     ` Dmitry Eremin-Solenikov
2009-09-22 16:42       ` Dmitry Torokhov
2009-09-22 18:50         ` Ferenc Wagner
2009-09-22 15:14   ` Ferenc Wagner
2009-09-22 16:41     ` Dmitry Torokhov
2009-09-22 19:06       ` Ferenc Wagner
2009-09-28 17:03         ` Dmitry Torokhov
2009-10-01 14:02           ` Ferenc Wagner [this message]
2009-10-12 17:09             ` Ferenc Wagner
2009-10-14  8:04               ` Dmitry Torokhov
2009-10-14 11:03                 ` gpio_get_value in atomic context (was: make gpio-keys use IRQF_SHARED) Ferenc Wagner
2009-10-14 11:40                   ` Arve Hjønnevåg
2009-11-28  1:08                     ` David Brownell
2009-11-30 15:35                       ` gpio_get_value in atomic context Ferenc Wagner
2009-12-09 13:33                       ` Ferenc Wagner
2009-10-14 11:25                 ` [PATCH] input: make gpio-keys use IRQF_SHARED Ferenc Wagner

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=87fxa3xleg.fsf@tac.ki.iif.hu \
    --to=wferi@niif.hu \
    --cc=dbaryshkov@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=u.kleine-koenig@pengutronix.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).