Skip to contentSkip to conversation

mfd: speedup twl4030 irq response time and decrease irq disable time

PATCH In review [email protected] 3 participants 7 messages Sep 22, 2010 – Sep 28, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mfd: speedup twl4030 irq response time and decrease irq disable time

From: Ming Lei <[email protected]>

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

Cc Samuel Ortiz <[email protected]>
Cc Santosh Shilimkar <[email protected]>
Cc Balaji T K <[email protected]>
Cc Rajendra Nayak <[email protected]>
Cc Kevin Hilman <[email protected]>
---
 drivers/mfd/twl4030-irq.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
drivers/mfd/twl4030-irq.c +10 -2
index 097f24d..d1e0d80 100644
@@ -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()) {
Signature · 1 line
1.6.2.5
author
#1 lore raw

2010/9/22 <[email protected]>:

Quoted 10 lines

From: Ming Lei <[email protected]>

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.

Quoted 7 lines

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

Quoted 35 lines
Cc Samuel Ortiz <[email protected]>
Cc Santosh Shilimkar <[email protected]>
Cc Balaji T K <[email protected]>
Cc Rajendra Nayak <[email protected]>
Cc Kevin Hilman <[email protected]>

---
 drivers/mfd/twl4030-irq.c |   10 +++++++++-

 1 files changed, 9 insertions(+), 1 deletions(-)
drivers/mfd/twl4030-irq.c +10 -3
index 097f24d..d1e0d80 100644
@@ -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()) {
--
Quoted 3 lines

1.6.2.5

thanks,

Signature · 1 line
Lei Ming
#2 lore raw
In reply to [email protected]

Hi Tom,

Quoted 9 lines · On Wed, Sep 22, 2010 at 09:49:31AM +0800, [email protected] wrote:

From: Ming Lei <[email protected]>

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 ?

Quoted 7 lines

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.

Quoted 37 lines
Cc Samuel Ortiz <[email protected]>
Cc Santosh Shilimkar <[email protected]>
Cc Balaji T K <[email protected]>
Cc Rajendra Nayak <[email protected]>
Cc Kevin Hilman <[email protected]>
---
 drivers/mfd/twl4030-irq.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
drivers/mfd/twl4030-irq.c +10 -2
index 097f24d..d1e0d80 100644
@@ -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()) {
Signature · 1 line
1.6.2.5
Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/
author
#3 lore raw

Hi Samuel,

Thanks for your comment.

2010/9/27 Samuel Ortiz <[email protected]>:

Quoted 12 lines

Hi Tom,

Quoted 9 lines · On Wed, Sep 22, 2010 at 09:49:31AM +0800, [email protected] wrote:

From: Ming Lei <[email protected]>

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.

Quoted 2 lines

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.

Quoted 9 lines
Quoted 8 lines

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.

Signature · 1 line
Lei Ming
#4 lore raw
Quoted 8 lines · Ming Lei

2010/9/27 Samuel Ortiz <[email protected]>:

Quoted 2 lines

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.

author
#5 lore raw

CC genirq guys

2010/9/28 Mark Brown <[email protected]>:

Quoted 6 lines · Ming Lei
Quoted 4 lines

2010/9/27 Samuel Ortiz <[email protected]>:

Quoted 2 lines

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

Quoted 7 lines
Quoted 3 lines

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,

Signature · 1 line
Lei Ming
#6 lore raw
Quoted 7 lines · Ming Lei

2010/9/28 Mark Brown <[email protected]>:

Quoted 2 lines

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.