linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Jason Wang <jason77.wang@gmail.com>
Cc: notasas@gmail.com, vapier@gentoo.org, linux-input@vger.kernel.org
Subject: Re: [PATCH v2] Input: ads7846 - Replace spinlock by mutex to wrap disable()/enable()
Date: Tue, 7 Sep 2010 21:43:26 -0700	[thread overview]
Message-ID: <20100908044326.GA10338@core.coreip.homeip.net> (raw)
In-Reply-To: <4C86FE0D.2060905@gmail.com>

On Wed, Sep 08, 2010 at 11:07:57AM +0800, Jason Wang wrote:
> Dmitry Torokhov wrote:
> >On Wed, Sep 01, 2010 at 09:48:18AM -0700, Dmitry Torokhov wrote:
> >>On Wed, Sep 01, 2010 at 06:07:30PM +0800, Jason Wang wrote:
> >>>Dmitry Torokhov wrote:
> >>>>Hi Jason,
> >>>>
> >>>>On Wed, Aug 25, 2010 at 11:45:27AM +0800, Jason Wang wrote:
> >>>>>Hi dmitry and others,
> >>>>>
> >>>>>could you please to help me review this patch?
> >>>>>
> >>>>>Thanks,
> >>>>>Jason.
> >>>>>
> >>>>>Jason Wang wrote:
> >>>>>>The commit 9114337 introduces regulator operations in the ads7846
> >>>>>>touchscreen driver. Among these operations, some are called in the
> >>>>>>spinlock protected context.
> >>>>>>On most platforms, the regulator operation is achieved through
> >>>>>>i2c/spi bus transfer operations, some bus transfer operations will
> >>>>>>call wait_for_completion function. It isn't allowable  to call
> >>>>>>sleepable function in the atomic context. So replace the spinlock with
> >>>>>>mutex to protect ads7846_disable()/ads7846_enable().
> >>>>>>
> >>>>I am afraid the patch is not correct. ads7846_disable() and
> >>>>ads7846_enable() check and modify flags (such as irq_disabled and
> >>>>pending) that are also accessed form timer/interrupt context. Moving to
> >>>>mutex removes the serialization that used to be there.
> >>>Thanks for your comments. you are right it is dangerous and
> >>>unreasonable to use different locks to protect a critical resource.
> >>>>I wonder if we should start by converting the driver to used threaded
> >>>>IRQ model with "long playing" interrupt handler so all access happens in
> >>>>process context and shutdown sequence is simplified.
> >>>It can solve most issues, but it can't solve this situation. Because
> >>>here the atomic region in which conflicts happened is from spin_lock
> >>>instead of irq handler.
> >>>
> >>Right, but switching to threaded IRQ will allow to use mutex in place
> >>of the spinlock everywhere.
> >>
> >
> >I wonder if the following patch works (or can be made to work)...
> >
> Hi Dmitry,
> 
> I have made a quick test of this patch, currently two issues found:
> 1) missing #include <linux/sched.h> , it will produce a building error.
> 2) touch panel can't work, it seems that the input dev doesn't
> report pen up events.
> 

Yeah, it is kinda hard to get stuff working first time around without
the hardware :)

> Your patch is a good frame work, i will continue working basing off
> your patch.
> Maybe several dates later, i will send out an extra patch to
> strengthen your patch.
> 

Great, let me know how it goes.

Thanks.

-- 
Dmitry

      reply	other threads:[~2010-09-08  4:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-21  5:59 [PATCH v2] Input: ads7846 - Replace spinlock by mutex to wrap disable()/enable() Jason Wang
2010-08-25  3:45 ` Jason Wang
2010-09-01  6:48   ` Dmitry Torokhov
2010-09-01 10:07     ` Jason Wang
2010-09-01 16:48       ` Dmitry Torokhov
2010-09-02 16:01         ` Dmitry Torokhov
2010-09-03  2:47           ` Jason Wang
2010-09-08  3:07           ` Jason Wang
2010-09-08  4:43             ` Dmitry Torokhov [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=20100908044326.GA10338@core.coreip.homeip.net \
    --to=dmitry.torokhov@gmail.com \
    --cc=jason77.wang@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=notasas@gmail.com \
    --cc=vapier@gentoo.org \
    /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).