From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Feng Tang <feng.tang@intel.com>
Cc: "linux-input@vger.kernel.org" <linux-input@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"kwlee@mtekvision.com" <kwlee@mtekvision.com>,
"Clark, Joel" <joel.clark@intel.com>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH 1/2] Input: tsc2007 - Disable irq when the irq thread is handling data
Date: Wed, 30 Nov 2011 22:10:15 -0800 [thread overview]
Message-ID: <20111201061015.GD16816@core.coreip.homeip.net> (raw)
In-Reply-To: <20111130100824.535c7e16@feng-i7>
On Wed, Nov 30, 2011 at 10:08:24AM +0800, Feng Tang wrote:
> Hi Dmitry,
>
> Thanks for the review.
>
> On Tue, 29 Nov 2011 17:22:08 +0800
> Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote:
>
> > Hi Feng,
> >
> > On Tue, Nov 29, 2011 at 04:12:57PM +0800, Feng Tang wrote:
> > > The TSC2007 data sheet say in some case the HW may fire some false
> > > interrrupt, which I also met during integrating one TSC2007 device.
> > > So add the disable_irq/enable_irq protection around data handling.
> >
> > IRQF_ONESHOT should prevent IRQ from firing again while thread is
> > servicing it. Did you actually observe it not working?
>
> You are right, the tsc's threaded IRQ function is not re-entered, and
> the driver is working actually. My bad not stating the problem clearly.
> The real problem I want solve is, many platforms including ours use a
> GPIO line as the tsc2007's IRQ line, and when these extra tsc2007 IRQ
> is triggered on the gpio line, that GPIO controller will fire up extra
> noise IRQ accordingly, causing its ISR to be called. And my patch is
> trying to let the GPIO controller driver disable that specific IRQ pin
> from tsc2007. As disable_irq will call GPIO irq_chip's irq_disable() or
> mask() hook.
But ONESHOT interrupt handler will not unmask interrupt until thead
finishes servicing it so we should not be seeing these extra IRQs.
I'm adding Thomas in case I misunderstand how it threaded IRQ supposed to
work.
Also, there is clear_penirq() platform method that is called to clean
penirq state, if needed.
>
> By grep the tsc2007_platform_data in kernel, I see most of the most of
> the tsc2007 platforms are using GPIO line as tsc2007 IRQ ine. So this
> should be a general problem.
>
> Following is patch with updated log and comments.
>
> Thanks,
> Feng
>
> -----------------
>
> From 16585020d27a066d2908959e370ea4f8905a0d34 Mon Sep 17 00:00:00 2001
> From: Feng Tang <feng.tang@intel.com>
> Date: Tue, 29 Nov 2011 15:48:42 +0800
> Subject: [PATCH 1/2] Input: tsc2007 - Disable irq when the irq thread is handling data
>
> The TSC2007 data sheet say in some case the HW may fire some false
> interrrupt, which I also met during integrating one TSC2007 device.
> Most of the tsc2007 platforms including ours are using a gpio line as
> tsc2007's irq line, so calling disable_irq_nosync() to actually
> prevent the gpio controller from firing IRQ for tsc2007 in such case.
>
> Signed-off-by: Feng Tang <feng.tang@intel.com>
> ---
> drivers/input/touchscreen/tsc2007.c | 13 +++++++++++++
> 1 files changed, 13 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/input/touchscreen/tsc2007.c b/drivers/input/touchscreen/tsc2007.c
> index 1f674cb..03c1961 100644
> --- a/drivers/input/touchscreen/tsc2007.c
> +++ b/drivers/input/touchscreen/tsc2007.c
> @@ -171,6 +171,18 @@ static irqreturn_t tsc2007_soft_irq(int irq, void *handle)
> struct ts_event tc;
> u32 rt;
>
> + /*
> + * Disable the irq, as it may fire several other IRQs during
> + * this thread is handling data, as suggested by the TSC2007
> + * datasheet, p19, "Touch Detect" chapter.
> + *
> + * Most of the tsc2007 platforms are using a gpio line as
> + * tsc2007's irq line, so calling disable_irq_nosync() will
> + * actually prevent the gpio controller from firing IRQ for
> + * this tsc2007 line in such case.
> + */
> + disable_irq_nosync(irq);
> +
> while (!ts->stopped && tsc2007_is_pen_down(ts)) {
>
> /* pen is down, continue with the measurement */
> @@ -221,6 +233,7 @@ static irqreturn_t tsc2007_soft_irq(int irq, void *handle)
> if (ts->clear_penirq)
> ts->clear_penirq();
>
> + enable_irq(irq);
> return IRQ_HANDLED;
> }
>
> --
> 1.7.1
> >
> > Thanks.
> >
> > >
> > > Signed-off-by: Feng Tang <feng.tang@intel.com>
> > > ---
> > > drivers/input/touchscreen/tsc2007.c | 8 ++++++++
> > > 1 files changed, 8 insertions(+), 0 deletions(-)
> > >
> > > diff --git a/drivers/input/touchscreen/tsc2007.c
> > > b/drivers/input/touchscreen/tsc2007.c index 1f674cb..789f216 100644
> > > --- a/drivers/input/touchscreen/tsc2007.c
> > > +++ b/drivers/input/touchscreen/tsc2007.c
> > > @@ -171,6 +171,13 @@ static irqreturn_t tsc2007_soft_irq(int irq,
> > > void *handle) struct ts_event tc;
> > > u32 rt;
> > >
> > > + /*
> > > + * Disable the irq, as it may fire several other IRQs
> > > during
> > > + * this thread is handling data, as suggested by the
> > > TSC2007
> > > + * datasheet, p19, "Touch Detect" chapter
> > > + */
> > > + disable_irq_nosync(irq);
> > > +
> > > while (!ts->stopped && tsc2007_is_pen_down(ts)) {
> > >
> > > /* pen is down, continue with the measurement */
> > > @@ -221,6 +228,7 @@ static irqreturn_t tsc2007_soft_irq(int irq,
> > > void *handle) if (ts->clear_penirq)
> > > ts->clear_penirq();
> > >
> > > + enable_irq(irq);
> > > return IRQ_HANDLED;
> > > }
> > >
> > > --
> > > 1.7.1
> > >
> > >
> >
--
Dmitry
next prev parent reply other threads:[~2011-12-01 6:10 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-29 8:12 [PATCH 1/2] Input: tsc2007 - Disable irq when the irq thread is handling data Feng Tang
2011-11-29 8:12 ` [PATCH 2/2] Input: tsc2007 - Add a z1_low_threshhold platform data parameter Feng Tang
2011-11-29 9:23 ` Dmitry Torokhov
2011-11-30 2:34 ` Feng Tang
2011-12-01 5:47 ` Dmitry Torokhov
2011-12-01 6:19 ` Feng Tang
2011-12-01 8:45 ` Dmitry Torokhov
2011-12-01 9:04 ` Feng Tang
2011-12-04 8:54 ` Dmitry Torokhov
2011-12-05 5:35 ` Feng Tang
2011-12-26 3:16 ` Feng Tang
2011-11-29 9:22 ` [PATCH 1/2] Input: tsc2007 - Disable irq when the irq thread is handling data Dmitry Torokhov
2011-11-30 2:08 ` Feng Tang
2011-12-01 6:10 ` Dmitry Torokhov [this message]
2011-12-01 6:30 ` Feng Tang
2011-12-01 8:48 ` Dmitry Torokhov
2011-12-01 9:00 ` Feng Tang
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=20111201061015.GD16816@core.coreip.homeip.net \
--to=dmitry.torokhov@gmail.com \
--cc=feng.tang@intel.com \
--cc=joel.clark@intel.com \
--cc=kwlee@mtekvision.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.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).