linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mfd: speedup twl4030 irq response time and decrease irq disable time
@ 2010-09-22  1:49 tom.leiming
  2010-09-27 14:31 ` Ming Lei
  2010-09-27 15:48 ` Samuel Ortiz
  0 siblings, 2 replies; 7+ messages in thread
From: tom.leiming @ 2010-09-22  1:49 UTC (permalink / raw)
  To: sameo
  Cc: linux-omap, Ming Lei, Santosh Shilimkar, Balaji T K,
	Rajendra Nayak, Kevin Hilman, linux-kernel

From: Ming Lei <tom.leiming@gmail.com>

This patch sets scheduler policy of twl4030 irq thread
(twl4030_irq_thread) as SCHED_FIFO to speedup irq response
time, just like taken by kernel threaded irq in irq_thread
(kernel/irq/manage.c). Also higher priority than that of
threaded irq is taken to avoid preemption from twl4030
subchips's threaded irq handler, so pih irq disable time may
be decreased.

The pih irq is disabled in handle_twl4030_pih which may
wakeup twl4030 irq thread, and the pih irq will be enabled
again until complete of all sih irqs' handling in twl4030
irq thread.

Also for each one interrupt line of twl4030 subchip, only
two irq events can be buffered by twl4030(4.4.2.3 of TPS65950 TRM).

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Cc: Samuel Ortiz <sameo@linux.intel.com>
Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
Cc: Balaji T K <balajitk@ti.com>
Cc: Rajendra Nayak <rnayak@ti.com>
Cc: Kevin Hilman <khilman@deeprootsystems.com>
Cc: linux-kernel@vger.kernel.org
---
 drivers/mfd/twl4030-irq.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
index 097f24d..d1e0d80 100644
--- a/drivers/mfd/twl4030-irq.c
+++ b/drivers/mfd/twl4030-irq.c
@@ -286,8 +286,16 @@ static int twl4030_irq_thread(void *data)
 	long irq = (long)data;
 	static unsigned i2c_errors;
 	static const unsigned max_i2c_errors = 100;
-
-
+	struct sched_param param = {
+		.sched_priority = MAX_USER_RT_PRIO/2 + 10,
+	};
+
+	/* Take higher priority than threaded irq to make us immune of
+ 	 * preemption from twl4030 subchips's threaded irq handler, then
+ 	 * we can complete all SIH irqs' handling and enable PIH irq
+ 	 * again asap.
+ 	 * */
+	sched_setscheduler(current, SCHED_FIFO, &param);
 	current->flags |= PF_NOFREEZE;
 
 	while (!kthread_should_stop()) {
-- 
1.6.2.5


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] mfd: speedup twl4030 irq response time and decrease irq disable time
  2010-09-22  1:49 [PATCH] mfd: speedup twl4030 irq response time and decrease irq disable time tom.leiming
@ 2010-09-27 14:31 ` Ming Lei
  2010-09-27 15:48 ` Samuel Ortiz
  1 sibling, 0 replies; 7+ messages in thread
From: Ming Lei @ 2010-09-27 14:31 UTC (permalink / raw)
  To: sameo
  Cc: linux-omap, Ming Lei, Santosh Shilimkar, Balaji T K,
	Rajendra Nayak, Kevin Hilman, linux-kernel

2010/9/22  <tom.leiming@gmail.com>:
> From: Ming Lei <tom.leiming@gmail.com>
>
> This patch sets scheduler policy of twl4030 irq thread
> (twl4030_irq_thread) as SCHED_FIFO to speedup irq response
> time, just like taken by kernel threaded irq in irq_thread
> (kernel/irq/manage.c). Also higher priority than that of
> threaded irq is taken to avoid preemption from twl4030
> subchips's threaded irq handler, so pih irq disable time may
> be decreased.
>
> The pih irq is disabled in handle_twl4030_pih which may
> wakeup twl4030 irq thread, and the pih irq will be enabled
> again until complete of all sih irqs' handling in twl4030
> irq thread.
>
> Also for each one interrupt line of twl4030 subchip, only
> two irq events can be buffered by twl4030(4.4.2.3 of TPS65950 TRM).

Ping...

> Signed-off-by: Ming Lei <tom.leiming@gmail.com>
> Cc: Samuel Ortiz <sameo@linux.intel.com>
> Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
> Cc: Balaji T K <balajitk@ti.com>
> Cc: Rajendra Nayak <rnayak@ti.com>
> Cc: Kevin Hilman <khilman@deeprootsystems.com>
> Cc: linux-kernel@vger.kernel.org
> ---
>  drivers/mfd/twl4030-irq.c |   10 +++++++++-
>  1 files changed, 9 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
> index 097f24d..d1e0d80 100644
> --- a/drivers/mfd/twl4030-irq.c
> +++ b/drivers/mfd/twl4030-irq.c
> @@ -286,8 +286,16 @@ static int twl4030_irq_thread(void *data)
>        long irq = (long)data;
>        static unsigned i2c_errors;
>        static const unsigned max_i2c_errors = 100;
> -
> -
> +       struct sched_param param = {
> +               .sched_priority = MAX_USER_RT_PRIO/2 + 10,
> +       };
> +
> +       /* Take higher priority than threaded irq to make us immune of
> +        * preemption from twl4030 subchips's threaded irq handler, then
> +        * we can complete all SIH irqs' handling and enable PIH irq
> +        * again asap.
> +        * */
> +       sched_setscheduler(current, SCHED_FIFO, &param);
>        current->flags |= PF_NOFREEZE;
>
>        while (!kthread_should_stop()) {
> --
> 1.6.2.5
>
>


thanks,

-- 
Lei Ming

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mfd: speedup twl4030 irq response time and decrease irq disable time
  2010-09-22  1:49 [PATCH] mfd: speedup twl4030 irq response time and decrease irq disable time tom.leiming
  2010-09-27 14:31 ` Ming Lei
@ 2010-09-27 15:48 ` Samuel Ortiz
  2010-09-28  0:25   ` Ming Lei
  1 sibling, 1 reply; 7+ messages in thread
From: Samuel Ortiz @ 2010-09-27 15:48 UTC (permalink / raw)
  To: tom.leiming
  Cc: linux-omap, Santosh Shilimkar, Balaji T K, Rajendra Nayak,
	Kevin Hilman, linux-kernel

Hi Tom,

On Wed, Sep 22, 2010 at 09:49:31AM +0800, tom.leiming@gmail.com wrote:
> From: Ming Lei <tom.leiming@gmail.com>
> 
> This patch sets scheduler policy of twl4030 irq thread
> (twl4030_irq_thread) as SCHED_FIFO to speedup irq response
> time, just like taken by kernel threaded irq in irq_thread
> (kernel/irq/manage.c). Also higher priority than that of
> threaded irq is taken to avoid preemption from twl4030
> subchips's threaded irq handler, so pih irq disable time may
> be decreased.
Wouldn't converting your twl4030_irq_thread() to the threaded IRQ framework
fix that problem ?


> The pih irq is disabled in handle_twl4030_pih which may
> wakeup twl4030 irq thread, and the pih irq will be enabled
> again until complete of all sih irqs' handling in twl4030
> irq thread.
> 
> Also for each one interrupt line of twl4030 subchip, only
> two irq events can be buffered by twl4030(4.4.2.3 of TPS65950 TRM).
Could you explain how is that related to the patch below ?

Cheers,
Samuel.



> Signed-off-by: Ming Lei <tom.leiming@gmail.com>
> Cc: Samuel Ortiz <sameo@linux.intel.com>
> Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
> Cc: Balaji T K <balajitk@ti.com>
> Cc: Rajendra Nayak <rnayak@ti.com>
> Cc: Kevin Hilman <khilman@deeprootsystems.com>
> Cc: linux-kernel@vger.kernel.org
> ---
>  drivers/mfd/twl4030-irq.c |   10 +++++++++-
>  1 files changed, 9 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
> index 097f24d..d1e0d80 100644
> --- a/drivers/mfd/twl4030-irq.c
> +++ b/drivers/mfd/twl4030-irq.c
> @@ -286,8 +286,16 @@ static int twl4030_irq_thread(void *data)
>  	long irq = (long)data;
>  	static unsigned i2c_errors;
>  	static const unsigned max_i2c_errors = 100;
> -
> -
> +	struct sched_param param = {
> +		.sched_priority = MAX_USER_RT_PRIO/2 + 10,
> +	};
> +
> +	/* Take higher priority than threaded irq to make us immune of
> + 	 * preemption from twl4030 subchips's threaded irq handler, then
> + 	 * we can complete all SIH irqs' handling and enable PIH irq
> + 	 * again asap.
> + 	 * */
> +	sched_setscheduler(current, SCHED_FIFO, &param);
>  	current->flags |= PF_NOFREEZE;
>  
>  	while (!kthread_should_stop()) {
> -- 
> 1.6.2.5
> 

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mfd: speedup twl4030 irq response time and decrease irq disable time
  2010-09-27 15:48 ` Samuel Ortiz
@ 2010-09-28  0:25   ` Ming Lei
  2010-09-28  4:24     ` Mark Brown
  0 siblings, 1 reply; 7+ messages in thread
From: Ming Lei @ 2010-09-28  0:25 UTC (permalink / raw)
  To: Samuel Ortiz
  Cc: linux-omap, Santosh Shilimkar, Balaji T K, Rajendra Nayak,
	Kevin Hilman, linux-kernel

Hi Samuel,

     Thanks for your comment.

2010/9/27 Samuel Ortiz <sameo@linux.intel.com>:
> Hi Tom,
>
> On Wed, Sep 22, 2010 at 09:49:31AM +0800, tom.leiming@gmail.com wrote:
>> From: Ming Lei <tom.leiming@gmail.com>
>>
>> This patch sets scheduler policy of twl4030 irq thread
>> (twl4030_irq_thread) as SCHED_FIFO to speedup irq response
>> time, just like taken by kernel threaded irq in irq_thread
>> (kernel/irq/manage.c). Also higher priority than that of
>> threaded irq is taken to avoid preemption from twl4030
>> subchips's threaded irq handler, so pih irq disable time may
>> be decreased.
> Wouldn't converting your twl4030_irq_thread() to the threaded IRQ framework
> fix that problem ?

IRQ_DISABLED flag is set by disable_irq_nosync called from PIH handler,
then thread function can't be executed in irq thread function, so we can't
convert this to threaded IRQ framework simply.

>
>> The pih irq is disabled in handle_twl4030_pih which may
>> wakeup twl4030 irq thread, and the pih irq will be enabled
>> again until complete of all sih irqs' handling in twl4030
>> irq thread.
>>
>> Also for each one interrupt line of twl4030 subchip, only
>> two irq events can be buffered by twl4030(4.4.2.3 of TPS65950 TRM).
> Could you explain how is that related to the patch below ?

We need to decrease PIH irq disable time as far as possible to
make twl4030 subchip happy, or else some irqs may be lost, right?

This patch will decrease PIH irq disable time:

        - set schedule policy of twl4030_irq_thread as SCHED_FIFO, so
it will get running timeslice quicker than before

       - set priority of  twl4030_irq_thread higher than irq_thread of
subchips to prevent it from being preempted by subchips' irq thread.


-- 
Lei Ming

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mfd: speedup twl4030 irq response time and decrease irq disable time
  2010-09-28  0:25   ` Ming Lei
@ 2010-09-28  4:24     ` Mark Brown
  2010-09-28  5:01       ` Ming Lei
  0 siblings, 1 reply; 7+ messages in thread
From: Mark Brown @ 2010-09-28  4:24 UTC (permalink / raw)
  To: Ming Lei
  Cc: Samuel Ortiz, linux-omap, Santosh Shilimkar, Balaji T K,
	Rajendra Nayak, Kevin Hilman, linux-kernel

On Tue, Sep 28, 2010 at 08:25:24AM +0800, Ming Lei wrote:
> 2010/9/27 Samuel Ortiz <sameo@linux.intel.com>:

> > Wouldn't converting your twl4030_irq_thread() to the threaded IRQ framework
> > fix that problem ?

> IRQ_DISABLED flag is set by disable_irq_nosync called from PIH handler,
> then thread function can't be executed in irq thread function, so we can't
> convert this to threaded IRQ framework simply.

Have you raised this issue with the genirq guys?  This sounds like
something that the core infrastructure should be able to cope with.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mfd: speedup twl4030 irq response time and decrease irq disable time
  2010-09-28  4:24     ` Mark Brown
@ 2010-09-28  5:01       ` Ming Lei
  2010-09-28  5:12         ` Mark Brown
  0 siblings, 1 reply; 7+ messages in thread
From: Ming Lei @ 2010-09-28  5:01 UTC (permalink / raw)
  To: Mark Brown
  Cc: Samuel Ortiz, linux-omap, Santosh Shilimkar, Balaji T K,
	Rajendra Nayak, Kevin Hilman, linux-kernel, Thomas Gleixner,
	Ingo Molnar, Peter Zijlstra, linux-arch

CC genirq guys

2010/9/28 Mark Brown <broonie@opensource.wolfsonmicro.com>:
> On Tue, Sep 28, 2010 at 08:25:24AM +0800, Ming Lei wrote:
>> 2010/9/27 Samuel Ortiz <sameo@linux.intel.com>:
>
>> > Wouldn't converting your twl4030_irq_thread() to the threaded IRQ framework
>> > fix that problem ?
>
>> IRQ_DISABLED flag is set by disable_irq_nosync called from PIH handler,
>> then thread function can't be executed in irq thread function, so we can't
>> convert this to threaded IRQ framework simply.
>
> Have you raised this issue with the genirq guys?  This sounds like
> something that the core infrastructure should be able to cope with.
>

Even genirq guys can help us to convert to irq thread framework, I
don't think there is good way to set priority for one irq thread.

For twl4030, if we can make twl4030_irq_thread to run at higher
priority than that of other irq thread, the PIH irq disable time can be
decreased further since other irq thread waken up by twl4030_irq_thread
can preempt the running of twl4030_irq_thread, and the PIH irq will be
enabled until complete of twl4030_irq_thread.

thanks,
-- 
Lei Ming

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mfd: speedup twl4030 irq response time and decrease irq disable time
  2010-09-28  5:01       ` Ming Lei
@ 2010-09-28  5:12         ` Mark Brown
  0 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2010-09-28  5:12 UTC (permalink / raw)
  To: Ming Lei
  Cc: Samuel Ortiz, linux-omap, Santosh Shilimkar, Balaji T K,
	Rajendra Nayak, Kevin Hilman, linux-kernel, Thomas Gleixner,
	Ingo Molnar, Peter Zijlstra, linux-arch

On Tue, Sep 28, 2010 at 01:01:32PM +0800, Ming Lei wrote:
> 2010/9/28 Mark Brown <broonie@opensource.wolfsonmicro.com>:

> > Have you raised this issue with the genirq guys?  This sounds like
> > something that the core infrastructure should be able to cope with.

> Even genirq guys can help us to convert to irq thread framework, I
> don't think there is good way to set priority for one irq thread.

What I'm saying is that this sounds like something it's reasonable to
want to do so if there's no way currently to get high priority handling
of timing sensitive interrupt controllers it'd be good if there could
be.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-09-28  5:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-22  1:49 [PATCH] mfd: speedup twl4030 irq response time and decrease irq disable time tom.leiming
2010-09-27 14:31 ` Ming Lei
2010-09-27 15:48 ` Samuel Ortiz
2010-09-28  0:25   ` Ming Lei
2010-09-28  4:24     ` Mark Brown
2010-09-28  5:01       ` Ming Lei
2010-09-28  5:12         ` Mark Brown

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).