All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
To: Thomas Gleixner <tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
Cc: Nishanth Menon <nm-l0cyMroinI0@public.gmane.org>,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
	LKML <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Keerthy <j-keerthy-l0cyMroinI0@public.gmane.org>,
	Mark Brown <broonie-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	Samuel Ortiz <sameo-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
	linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	LAK
	<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>,
	Kevin Hilman <khilman-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Subject: Re: [PATCH V3 3/3] mfd: palmas: Add support for optional wakeup
Date: Fri, 19 Sep 2014 12:16:49 -0700	[thread overview]
Message-ID: <20140919191649.GQ14505@atomide.com> (raw)
In-Reply-To: <alpine.DEB.2.10.1409191027330.5612@nanos>

* Thomas Gleixner <tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org> [140919 10:37]:
> On Fri, 19 Sep 2014, Nishanth Menon wrote:
> > On 08:37-20140919, Thomas Gleixner wrote:
> > > 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.
> 
> No, the uart and that i2c thing are just wrong. Assume the following
> 
> device irq affine to cpu0
> wakeup irq affine to cpu1
> 
> CPU 0				CPU 1
> 
> runtime suspend
> 
>  enable_wake(wakeup irq);
> 
> wakeup interrupt is raised	device interrupt is raised
> 
>   dev_handler(device)		dev_handler(device)
> 
> It might work due to locking, but it is nevertheless wrong. Interrupt
> handlers for devices are guaranteed not to be reentrant. And this
> brilliant stuff simply violates that guarantee. So, no. It's wrong
> even if it happens to work by chance.

Hmm yeah that's a good point indeed.

>From hardware point of view the wake-up events behave like interrupts
and could also be used as the only interrupt in some messed up cases.
That avoids all kinds of custom APIs from driver point.

The re-entrancy problem we've most likely had ever since we enabled
the PRCM interrupts, and maybe that's why I did not even consider
that part. I think before that we were calling the driver interrupt
after waking up from the PM code..

Anyways, how about the following to deal with the re-entrancy problem:

1. The wake-up interrupt handler must have a separate interrupt
   handler that just calls tasklet_schedule()

2. The device interrupt handler also just calls tasklet_schedule()

3. The tasklet then does pm_runtime_get, handles the registers, and
   so on.

Or would we still have a re-entrancy problem somewhere else with
that?

Regards,

Tony
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: tony@atomide.com (Tony Lindgren)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH V3 3/3] mfd: palmas: Add support for optional wakeup
Date: Fri, 19 Sep 2014 12:16:49 -0700	[thread overview]
Message-ID: <20140919191649.GQ14505@atomide.com> (raw)
In-Reply-To: <alpine.DEB.2.10.1409191027330.5612@nanos>

* Thomas Gleixner <tglx@linutronix.de> [140919 10:37]:
> On Fri, 19 Sep 2014, Nishanth Menon wrote:
> > On 08:37-20140919, Thomas Gleixner wrote:
> > > 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.
> 
> No, the uart and that i2c thing are just wrong. Assume the following
> 
> device irq affine to cpu0
> wakeup irq affine to cpu1
> 
> CPU 0				CPU 1
> 
> runtime suspend
> 
>  enable_wake(wakeup irq);
> 
> wakeup interrupt is raised	device interrupt is raised
> 
>   dev_handler(device)		dev_handler(device)
> 
> It might work due to locking, but it is nevertheless wrong. Interrupt
> handlers for devices are guaranteed not to be reentrant. And this
> brilliant stuff simply violates that guarantee. So, no. It's wrong
> even if it happens to work by chance.

Hmm yeah that's a good point indeed.

>From hardware point of view the wake-up events behave like interrupts
and could also be used as the only interrupt in some messed up cases.
That avoids all kinds of custom APIs from driver point.

The re-entrancy problem we've most likely had ever since we enabled
the PRCM interrupts, and maybe that's why I did not even consider
that part. I think before that we were calling the driver interrupt
after waking up from the PM code..

Anyways, how about the following to deal with the re-entrancy problem:

1. The wake-up interrupt handler must have a separate interrupt
   handler that just calls tasklet_schedule()

2. The device interrupt handler also just calls tasklet_schedule()

3. The tasklet then does pm_runtime_get, handles the registers, and
   so on.

Or would we still have a re-entrancy problem somewhere else with
that?

Regards,

Tony

WARNING: multiple messages have this Message-ID (diff)
From: Tony Lindgren <tony@atomide.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Nishanth Menon <nm@ti.com>,
	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,
	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 12:16:49 -0700	[thread overview]
Message-ID: <20140919191649.GQ14505@atomide.com> (raw)
In-Reply-To: <alpine.DEB.2.10.1409191027330.5612@nanos>

* Thomas Gleixner <tglx@linutronix.de> [140919 10:37]:
> On Fri, 19 Sep 2014, Nishanth Menon wrote:
> > On 08:37-20140919, Thomas Gleixner wrote:
> > > 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.
> 
> No, the uart and that i2c thing are just wrong. Assume the following
> 
> device irq affine to cpu0
> wakeup irq affine to cpu1
> 
> CPU 0				CPU 1
> 
> runtime suspend
> 
>  enable_wake(wakeup irq);
> 
> wakeup interrupt is raised	device interrupt is raised
> 
>   dev_handler(device)		dev_handler(device)
> 
> It might work due to locking, but it is nevertheless wrong. Interrupt
> handlers for devices are guaranteed not to be reentrant. And this
> brilliant stuff simply violates that guarantee. So, no. It's wrong
> even if it happens to work by chance.

Hmm yeah that's a good point indeed.

>From hardware point of view the wake-up events behave like interrupts
and could also be used as the only interrupt in some messed up cases.
That avoids all kinds of custom APIs from driver point.

The re-entrancy problem we've most likely had ever since we enabled
the PRCM interrupts, and maybe that's why I did not even consider
that part. I think before that we were calling the driver interrupt
after waking up from the PM code..

Anyways, how about the following to deal with the re-entrancy problem:

1. The wake-up interrupt handler must have a separate interrupt
   handler that just calls tasklet_schedule()

2. The device interrupt handler also just calls tasklet_schedule()

3. The tasklet then does pm_runtime_get, handles the registers, and
   so on.

Or would we still have a re-entrancy problem somewhere else with
that?

Regards,

Tony

  reply	other threads:[~2014-09-19 19:16 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
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 [this message]
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=20140919191649.GQ14505@atomide.com \
    --to=tony-4v6ys6ai5vpbdgjk7y7tuq@public.gmane.org \
    --cc=broonie-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=j-keerthy-l0cyMroinI0@public.gmane.org \
    --cc=khilman-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=nm-l0cyMroinI0@public.gmane.org \
    --cc=sameo-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
    --cc=tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.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 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.