From: Nishanth Menon <nm@ti.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: lee.jones@linaro.org, LKML <linux-kernel@vger.kernel.org>,
devicetree@vger.kernel.org, Keerthy <j-keerthy@ti.com>,
Mark Brown <broonie@linaro.org>,
Samuel Ortiz <sameo@linux.intel.com>,
linux-omap@vger.kernel.org, Tony Lindgren <tony@atomide.com>,
LAK <linux-arm-kernel@lists.infradead.org>,
Kevin Hilman <khilman@linaro.org>
Subject: Re: [PATCH V3 3/3] mfd: palmas: Add support for optional wakeup
Date: Fri, 19 Sep 2014 11:19:27 -0500 [thread overview]
Message-ID: <20140919161927.GA28613@kahuna> (raw)
In-Reply-To: <alpine.DEB.2.10.1409190710320.5612@nanos>
On 08:37-20140919, Thomas Gleixner wrote:
> On Thu, 18 Sep 2014, Nishanth Menon wrote:
> > On 17:57-20140918, Thomas Gleixner wrote:
> >
> > I suppose I can improve the commit message to elaborate this better?
> > Will that help?
>
> You also want to improve the comment in the empty handler.
OK. will do the same. Thanks for suggesting.
>
> > >
> > > > + */
> > > > + return IRQ_NONE;
>
> And it still does not explain WHY you think that returning IRQ_NONE is
> the right thing to do here. You actually handle the interrupt, right?
> Just because the handler is an NOP does not mean you did not handle
> it.
Hmm.. My motivation for IRQ_NONE was because this specific handler does
not handle the interrupt. Now, from this discussion, I understand that I
should rather use IRQ_HANDLED since the event is indeed handled (just
not here).
Thank you for correcting my understanding. Will update in my next rev
(once we solve the following discussion)..
>
> > > > +static int palmas_i2c_suspend(struct i2c_client *i2c, pm_message_t mesg)
> > > > +{
> > > > + struct palmas *palmas = i2c_get_clientdata(i2c);
> > > > + struct device *dev = &i2c->dev;
> > > > +
> > > > + if (!palmas->wakeirq)
> > > > + return 0;
> > > > +
> > > > + if (device_may_wakeup(dev))
> > > > + enable_irq(palmas->wakeirq);
> > > > +
> > > > + return 0;
> > > > +}
> > > > +
> > > > +static int palmas_i2c_resume(struct i2c_client *i2c)
> > > > +{
> > > > + struct palmas *palmas = i2c_get_clientdata(i2c);
> > > > + struct device *dev = &i2c->dev;
> > > > +
> > > > + if (!palmas->wakeirq)
> > > > + return 0;
> > > > +
> > > > + if (device_may_wakeup(dev))
> > > > + disable_irq_nosync(palmas->wakeirq);
> > >
> > > Again, why nosync?
> > true - nosync is not necessary at here. disable_irq is however necessary
> > as we are not interested in wakeup events for level changes.
> >
> > We just use the enable/disable to control when we'd want to arm the pin
> > for waking up from suspend state.
>
> And what is issuing the call to enable/disable_irq_wake()?
>
> So if that interrupt is not marked proper then you can bring your
> device into a wont resume state easily
>
> start suspend
> enable wakeirq
> disable_device_irqs()
> if (!iswakeup_irq())
> disable_irq() // does not mask due to lazy masking
>
> ....
> wakeirq fires
> if (irq_is_disabled())
> mask_irq();
>
> transition into suspend
>
> Now your pinctrl irq is masked at the HW level and wont wake the
> machine up ever again.
True.
>
> So now looking at that pinctrl irq chip thing, which seems to be
> designed to handle these kind of wakeups. That thing looks massivly
> wrong as well, simply because it enforces to use
> enable_irq/disable_irq().
>
> So because the sole purpose of this chip is to handle the separate
> wakeup style interrupt, it should actually NOT enable the interrupt in
> the irq_unmask callback.
>
> Simply because during normal operation nothing is interested in the
> interrupt and any operation which might enable it (including request
> irq) is just making the system handle completely pointless interrupts
> and hoops and loops juggling with enable/disable irq.
>
> So the right thing here is to have an empty unmask function and do the
> actual unmask only in the irq_set_wake() callback. mask of course
> needs to do what it says. The point is, that the following sequence of
> code will just work w/o generating an interrupt on the wakeirq line
> outside of the wake enabled context.
>
> dev_init()
> request_wakeirq();
>
> suspend()
> if (may_wake())
> enable_irq_wake();
>
> resume()
> if (may_wake())
> disable_irq_wake();
>
> The other omap drivers using this have the same issue ... And of
> course they are subtly different.
>
> The uart one handles the actual device interrupt, which is violating
> the general rule of possible interrupt reentrancy in the pm-runtime
> case if the two interrupts are affine to two different cores. Yes,
> it's protected by a lock and works by chance ....
>
> The mmc one issues a disable_irq_nosync() in the wakeup irq handler
> itself.
>
> WHY does one driver need that and the other does not? You are not even
> able to come up with a common scheme for OMAP. I don't want to see the
> mess others are going to create when this stuff becomes more used.
>
> Thanks,
>
> tglx
I think I understand your concern - I request Tony to comment about
this. I mean, I can try and hook things like uart in other drivers
(like https://patchwork.kernel.org/patch/4759171/ ), but w.r.t overall
generic usage guideline wise, I would prefer Tony to comment.
--
Regards,
Nishanth Menon
WARNING: multiple messages have this Message-ID (diff)
From: nm@ti.com (Nishanth Menon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH V3 3/3] mfd: palmas: Add support for optional wakeup
Date: Fri, 19 Sep 2014 11:19:27 -0500 [thread overview]
Message-ID: <20140919161927.GA28613@kahuna> (raw)
In-Reply-To: <alpine.DEB.2.10.1409190710320.5612@nanos>
On 08:37-20140919, Thomas Gleixner wrote:
> On Thu, 18 Sep 2014, Nishanth Menon wrote:
> > On 17:57-20140918, Thomas Gleixner wrote:
> >
> > I suppose I can improve the commit message to elaborate this better?
> > Will that help?
>
> You also want to improve the comment in the empty handler.
OK. will do the same. Thanks for suggesting.
>
> > >
> > > > + */
> > > > + return IRQ_NONE;
>
> And it still does not explain WHY you think that returning IRQ_NONE is
> the right thing to do here. You actually handle the interrupt, right?
> Just because the handler is an NOP does not mean you did not handle
> it.
Hmm.. My motivation for IRQ_NONE was because this specific handler does
not handle the interrupt. Now, from this discussion, I understand that I
should rather use IRQ_HANDLED since the event is indeed handled (just
not here).
Thank you for correcting my understanding. Will update in my next rev
(once we solve the following discussion)..
>
> > > > +static int palmas_i2c_suspend(struct i2c_client *i2c, pm_message_t mesg)
> > > > +{
> > > > + struct palmas *palmas = i2c_get_clientdata(i2c);
> > > > + struct device *dev = &i2c->dev;
> > > > +
> > > > + if (!palmas->wakeirq)
> > > > + return 0;
> > > > +
> > > > + if (device_may_wakeup(dev))
> > > > + enable_irq(palmas->wakeirq);
> > > > +
> > > > + return 0;
> > > > +}
> > > > +
> > > > +static int palmas_i2c_resume(struct i2c_client *i2c)
> > > > +{
> > > > + struct palmas *palmas = i2c_get_clientdata(i2c);
> > > > + struct device *dev = &i2c->dev;
> > > > +
> > > > + if (!palmas->wakeirq)
> > > > + return 0;
> > > > +
> > > > + if (device_may_wakeup(dev))
> > > > + disable_irq_nosync(palmas->wakeirq);
> > >
> > > Again, why nosync?
> > true - nosync is not necessary at here. disable_irq is however necessary
> > as we are not interested in wakeup events for level changes.
> >
> > We just use the enable/disable to control when we'd want to arm the pin
> > for waking up from suspend state.
>
> And what is issuing the call to enable/disable_irq_wake()?
>
> So if that interrupt is not marked proper then you can bring your
> device into a wont resume state easily
>
> start suspend
> enable wakeirq
> disable_device_irqs()
> if (!iswakeup_irq())
> disable_irq() // does not mask due to lazy masking
>
> ....
> wakeirq fires
> if (irq_is_disabled())
> mask_irq();
>
> transition into suspend
>
> Now your pinctrl irq is masked at the HW level and wont wake the
> machine up ever again.
True.
>
> So now looking at that pinctrl irq chip thing, which seems to be
> designed to handle these kind of wakeups. That thing looks massivly
> wrong as well, simply because it enforces to use
> enable_irq/disable_irq().
>
> So because the sole purpose of this chip is to handle the separate
> wakeup style interrupt, it should actually NOT enable the interrupt in
> the irq_unmask callback.
>
> Simply because during normal operation nothing is interested in the
> interrupt and any operation which might enable it (including request
> irq) is just making the system handle completely pointless interrupts
> and hoops and loops juggling with enable/disable irq.
>
> So the right thing here is to have an empty unmask function and do the
> actual unmask only in the irq_set_wake() callback. mask of course
> needs to do what it says. The point is, that the following sequence of
> code will just work w/o generating an interrupt on the wakeirq line
> outside of the wake enabled context.
>
> dev_init()
> request_wakeirq();
>
> suspend()
> if (may_wake())
> enable_irq_wake();
>
> resume()
> if (may_wake())
> disable_irq_wake();
>
> The other omap drivers using this have the same issue ... And of
> course they are subtly different.
>
> The uart one handles the actual device interrupt, which is violating
> the general rule of possible interrupt reentrancy in the pm-runtime
> case if the two interrupts are affine to two different cores. Yes,
> it's protected by a lock and works by chance ....
>
> The mmc one issues a disable_irq_nosync() in the wakeup irq handler
> itself.
>
> WHY does one driver need that and the other does not? You are not even
> able to come up with a common scheme for OMAP. I don't want to see the
> mess others are going to create when this stuff becomes more used.
>
> Thanks,
>
> tglx
I think I understand your concern - I request Tony to comment about
this. I mean, I can try and hook things like uart in other drivers
(like https://patchwork.kernel.org/patch/4759171/ ), but w.r.t overall
generic usage guideline wise, I would prefer Tony to comment.
--
Regards,
Nishanth Menon
WARNING: multiple messages have this Message-ID (diff)
From: Nishanth Menon <nm@ti.com>
To: Thomas Gleixner <tglx@linutronix.de>, Tony Lindgren <tony@atomide.com>
Cc: <lee.jones@linaro.org>, LKML <linux-kernel@vger.kernel.org>,
<devicetree@vger.kernel.org>, Keerthy <j-keerthy@ti.com>,
Mark Brown <broonie@linaro.org>,
Samuel Ortiz <sameo@linux.intel.com>,
<linux-omap@vger.kernel.org>, Tony Lindgren <tony@atomide.com>,
LAK <linux-arm-kernel@lists.infradead.org>,
Kevin Hilman <khilman@linaro.org>
Subject: Re: [PATCH V3 3/3] mfd: palmas: Add support for optional wakeup
Date: Fri, 19 Sep 2014 11:19:27 -0500 [thread overview]
Message-ID: <20140919161927.GA28613@kahuna> (raw)
In-Reply-To: <alpine.DEB.2.10.1409190710320.5612@nanos>
On 08:37-20140919, Thomas Gleixner wrote:
> On Thu, 18 Sep 2014, Nishanth Menon wrote:
> > On 17:57-20140918, Thomas Gleixner wrote:
> >
> > I suppose I can improve the commit message to elaborate this better?
> > Will that help?
>
> You also want to improve the comment in the empty handler.
OK. will do the same. Thanks for suggesting.
>
> > >
> > > > + */
> > > > + return IRQ_NONE;
>
> And it still does not explain WHY you think that returning IRQ_NONE is
> the right thing to do here. You actually handle the interrupt, right?
> Just because the handler is an NOP does not mean you did not handle
> it.
Hmm.. My motivation for IRQ_NONE was because this specific handler does
not handle the interrupt. Now, from this discussion, I understand that I
should rather use IRQ_HANDLED since the event is indeed handled (just
not here).
Thank you for correcting my understanding. Will update in my next rev
(once we solve the following discussion)..
>
> > > > +static int palmas_i2c_suspend(struct i2c_client *i2c, pm_message_t mesg)
> > > > +{
> > > > + struct palmas *palmas = i2c_get_clientdata(i2c);
> > > > + struct device *dev = &i2c->dev;
> > > > +
> > > > + if (!palmas->wakeirq)
> > > > + return 0;
> > > > +
> > > > + if (device_may_wakeup(dev))
> > > > + enable_irq(palmas->wakeirq);
> > > > +
> > > > + return 0;
> > > > +}
> > > > +
> > > > +static int palmas_i2c_resume(struct i2c_client *i2c)
> > > > +{
> > > > + struct palmas *palmas = i2c_get_clientdata(i2c);
> > > > + struct device *dev = &i2c->dev;
> > > > +
> > > > + if (!palmas->wakeirq)
> > > > + return 0;
> > > > +
> > > > + if (device_may_wakeup(dev))
> > > > + disable_irq_nosync(palmas->wakeirq);
> > >
> > > Again, why nosync?
> > true - nosync is not necessary at here. disable_irq is however necessary
> > as we are not interested in wakeup events for level changes.
> >
> > We just use the enable/disable to control when we'd want to arm the pin
> > for waking up from suspend state.
>
> And what is issuing the call to enable/disable_irq_wake()?
>
> So if that interrupt is not marked proper then you can bring your
> device into a wont resume state easily
>
> start suspend
> enable wakeirq
> disable_device_irqs()
> if (!iswakeup_irq())
> disable_irq() // does not mask due to lazy masking
>
> ....
> wakeirq fires
> if (irq_is_disabled())
> mask_irq();
>
> transition into suspend
>
> Now your pinctrl irq is masked at the HW level and wont wake the
> machine up ever again.
True.
>
> So now looking at that pinctrl irq chip thing, which seems to be
> designed to handle these kind of wakeups. That thing looks massivly
> wrong as well, simply because it enforces to use
> enable_irq/disable_irq().
>
> So because the sole purpose of this chip is to handle the separate
> wakeup style interrupt, it should actually NOT enable the interrupt in
> the irq_unmask callback.
>
> Simply because during normal operation nothing is interested in the
> interrupt and any operation which might enable it (including request
> irq) is just making the system handle completely pointless interrupts
> and hoops and loops juggling with enable/disable irq.
>
> So the right thing here is to have an empty unmask function and do the
> actual unmask only in the irq_set_wake() callback. mask of course
> needs to do what it says. The point is, that the following sequence of
> code will just work w/o generating an interrupt on the wakeirq line
> outside of the wake enabled context.
>
> dev_init()
> request_wakeirq();
>
> suspend()
> if (may_wake())
> enable_irq_wake();
>
> resume()
> if (may_wake())
> disable_irq_wake();
>
> The other omap drivers using this have the same issue ... And of
> course they are subtly different.
>
> The uart one handles the actual device interrupt, which is violating
> the general rule of possible interrupt reentrancy in the pm-runtime
> case if the two interrupts are affine to two different cores. Yes,
> it's protected by a lock and works by chance ....
>
> The mmc one issues a disable_irq_nosync() in the wakeup irq handler
> itself.
>
> WHY does one driver need that and the other does not? You are not even
> able to come up with a common scheme for OMAP. I don't want to see the
> mess others are going to create when this stuff becomes more used.
>
> Thanks,
>
> tglx
I think I understand your concern - I request Tony to comment about
this. I mean, I can try and hook things like uart in other drivers
(like https://patchwork.kernel.org/patch/4759171/ ), but w.r.t overall
generic usage guideline wise, I would prefer Tony to comment.
--
Regards,
Nishanth Menon
next prev parent reply other threads:[~2014-09-19 16:19 UTC|newest]
Thread overview: 66+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-18 19:04 [PATCH V3 0/3] mfd: palmas: add optional wakeup irq Nishanth Menon
2014-09-18 19:04 ` Nishanth Menon
2014-09-18 19:04 ` Nishanth Menon
2014-09-18 19:04 ` [PATCH V3 1/3] Documentation: dt-bindings: mfd: palmas: Fix example style of i2c peripheral Nishanth Menon
2014-09-18 19:04 ` Nishanth Menon
2014-09-18 19:04 ` Nishanth Menon
2014-09-18 19:04 ` [PATCH V3 2/3] Documentation: dt-bindings: mfd: palmas: document optional wakeup IRQ Nishanth Menon
2014-09-18 19:04 ` Nishanth Menon
2014-09-18 19:04 ` Nishanth Menon
[not found] ` <1411067086-16613-1-git-send-email-nm-l0cyMroinI0@public.gmane.org>
2014-09-18 19:04 ` [PATCH V3 3/3] mfd: palmas: Add support for optional wakeup Nishanth Menon
2014-09-18 19:04 ` Nishanth Menon
2014-09-18 19:04 ` Nishanth Menon
2014-09-19 0:57 ` Thomas Gleixner
2014-09-19 0:57 ` Thomas Gleixner
2014-09-19 3:03 ` Nishanth Menon
2014-09-19 3:03 ` Nishanth Menon
2014-09-19 3:03 ` Nishanth Menon
2014-09-19 15:37 ` Thomas Gleixner
2014-09-19 15:37 ` Thomas Gleixner
2014-09-19 15:37 ` Thomas Gleixner
2014-09-19 16:19 ` Nishanth Menon [this message]
2014-09-19 16:19 ` Nishanth Menon
2014-09-19 16:19 ` Nishanth Menon
2014-09-19 17:36 ` Thomas Gleixner
2014-09-19 17:36 ` Thomas Gleixner
2014-09-19 17:36 ` Thomas Gleixner
2014-09-19 19:16 ` Tony Lindgren
2014-09-19 19:16 ` Tony Lindgren
2014-09-19 19:16 ` Tony Lindgren
[not found] ` <20140919191649.GQ14505-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2014-09-19 19:46 ` Thomas Gleixner
2014-09-19 19:46 ` Thomas Gleixner
2014-09-19 19:46 ` Thomas Gleixner
2014-09-19 19:57 ` Tony Lindgren
2014-09-19 19:57 ` Tony Lindgren
2014-09-19 19:57 ` Tony Lindgren
[not found] ` <20140919195738.GR14505-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2014-09-20 2:07 ` Thomas Gleixner
2014-09-20 2:07 ` Thomas Gleixner
2014-09-20 2:07 ` Thomas Gleixner
2014-09-20 14:07 ` Tony Lindgren
2014-09-20 14:07 ` Tony Lindgren
2014-09-20 14:07 ` Tony Lindgren
2014-10-02 3:43 ` Tony Lindgren
2014-10-02 3:43 ` Tony Lindgren
[not found] ` <20141002034345.GH3122-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2014-11-06 20:46 ` Tony Lindgren
2014-11-06 20:46 ` Tony Lindgren
2014-11-06 20:46 ` Tony Lindgren
[not found] ` <20141106204629.GF31454-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2014-11-13 10:03 ` Thomas Gleixner
2014-11-13 10:03 ` Thomas Gleixner
2014-11-13 10:03 ` Thomas Gleixner
2014-11-13 17:40 ` Tony Lindgren
2014-11-13 17:40 ` Tony Lindgren
[not found] ` <20141113174030.GM26481-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2014-11-13 22:25 ` Thomas Gleixner
2014-11-13 22:25 ` Thomas Gleixner
2014-11-13 22:25 ` Thomas Gleixner
2014-11-13 23:45 ` Tony Lindgren
2014-11-13 23:45 ` Tony Lindgren
2014-11-13 23:45 ` Tony Lindgren
2014-11-14 16:19 ` Felipe Balbi
2014-11-14 16:19 ` Felipe Balbi
2014-11-14 16:19 ` Felipe Balbi
2014-11-14 17:08 ` Tony Lindgren
2014-11-14 17:08 ` Tony Lindgren
2014-11-14 17:08 ` Tony Lindgren
[not found] ` <20141114170816.GW26481-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2014-11-14 17:21 ` Felipe Balbi
2014-11-14 17:21 ` Felipe Balbi
2014-11-14 17:21 ` Felipe Balbi
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=20140919161927.GA28613@kahuna \
--to=nm@ti.com \
--cc=broonie@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=j-keerthy@ti.com \
--cc=khilman@linaro.org \
--cc=lee.jones@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=sameo@linux.intel.com \
--cc=tglx@linutronix.de \
--cc=tony@atomide.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.