Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1606655 > unrolled thread

[PATCH RT 1/1] remoteproc: Prevent schedule while atomic

Started byLionel Debieve <lionel.debieve@st.com>
First post2017-03-22 16:20 +0100
Last post2017-03-24 09:40 +0100
Articles 11 — 7 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH RT 1/1] remoteproc: Prevent schedule while atomic Lionel Debieve <lionel.debieve@st.com> - 2017-03-22 16:20 +0100
    Re: [PATCH RT 1/1] remoteproc: Prevent schedule while atomic Steven Rostedt <rostedt@goodmis.org> - 2017-03-22 17:10 +0100
      Re: [PATCH RT 1/1] remoteproc: Prevent schedule while atomic Lionel DEBIEVE <lionel.debieve@st.com> - 2017-03-22 18:20 +0100
    Re: [PATCH RT 1/1] remoteproc: Prevent schedule while atomic Julia Cartwright <julia@ni.com> - 2017-03-22 18:40 +0100
      Re: [PATCH RT 1/1] remoteproc: Prevent schedule while atomic Steven Rostedt <rostedt@goodmis.org> - 2017-03-22 19:10 +0100
        Re: [PATCH RT 1/1] remoteproc: Prevent schedule while atomic Grygorii Strashko <grygorii.strashko@ti.com> - 2017-03-22 19:40 +0100
          Re: [PATCH RT 1/1] remoteproc: Prevent schedule while atomic Julia Cartwright <julia@ni.com> - 2017-03-22 19:50 +0100
            Re: [PATCH RT 1/1] remoteproc: Prevent schedule while atomic Lionel DEBIEVE <lionel.debieve@st.com> - 2017-03-23 09:30 +0100
              Re: [PATCH RT 1/1] remoteproc: Prevent schedule while atomic Lee Jones <lee.jones@linaro.org> - 2017-03-23 11:30 +0100
                Re: [PATCH RT 1/1] remoteproc: Prevent schedule while atomic Julia Cartwright <julia@ni.com> - 2017-03-23 22:00 +0100
            Re: [PATCH RT 1/1] remoteproc: Prevent schedule while atomic Thomas Gleixner <tglx@linutronix.de> - 2017-03-24 09:40 +0100

#1606655 — [PATCH RT 1/1] remoteproc: Prevent schedule while atomic

FromLionel Debieve <lionel.debieve@st.com>
Date2017-03-22 16:20 +0100
Subject[PATCH RT 1/1] remoteproc: Prevent schedule while atomic
Message-ID<tnQdj-4rn-9@gated-at.bofh.it>
Use raw_spin_lock in enable/disable channel as it comes from
interrupt context.

BUG: sleeping function called from invalid context at
kernel/locking/rtmutex.c:995
in_atomic(): 1, irqs_disabled(): 128, pid: 307, name: pulseaudio
Preemption disabled at:
[<c01790fc>] __handle_domain_irq+0x4c/0xec
CPU: 0 PID: 307 Comm: pulseaudio
Hardware name: STi SoC with Flattened Device Tree
[<c011046c>] (unwind_backtrace)
[<c010c7f4>] (show_stack)
[<c03d1578>] (dump_stack)
[<c014e440>] (___might_sleep)
[<c08e7f24>] (rt_spin_lock)
[<c069bb04>] (sti_mbox_disable_channel)
[<c069befc>] (sti_mbox_irq_handler)
[<c0179900>] (__handle_irq_event_percpu)
[<c01799dc>] (handle_irq_event_percpu)
[<c0179a78>] (handle_irq_event)
[<c017d1c8>] (handle_fasteoi_irq)
[<c0178c08>] (generic_handle_irq)
[<c017912c>] (__handle_domain_irq)
[<c0101488>] (gic_handle_irq)

Signed-off-by: Lionel Debieve <lionel.debieve@st.com>
---
 drivers/mailbox/mailbox-sti.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/mailbox/mailbox-sti.c b/drivers/mailbox/mailbox-sti.c
index 41bcd33..f9674ca 100644
--- a/drivers/mailbox/mailbox-sti.c
+++ b/drivers/mailbox/mailbox-sti.c
@@ -60,7 +60,7 @@ struct sti_mbox_device {
 	void __iomem		*base;
 	const char		*name;
 	u32			enabled[STI_MBOX_INST_MAX];
-	spinlock_t		lock;
+	raw_spinlock_t		lock;
 };
 
 /**
@@ -129,10 +129,10 @@ static void sti_mbox_enable_channel(struct mbox_chan *chan)
 	unsigned long flags;
 	void __iomem *base = MBOX_BASE(mdev, instance);
 
-	spin_lock_irqsave(&mdev->lock, flags);
+	raw_spin_lock_irqsave(&mdev->lock, flags);
 	mdev->enabled[instance] |= BIT(channel);
 	writel_relaxed(BIT(channel), base + STI_ENA_SET_OFFSET);
-	spin_unlock_irqrestore(&mdev->lock, flags);
+	raw_spin_unlock_irqrestore(&mdev->lock, flags);
 }
 
 static void sti_mbox_disable_channel(struct mbox_chan *chan)
@@ -144,10 +144,10 @@ static void sti_mbox_disable_channel(struct mbox_chan *chan)
 	unsigned long flags;
 	void __iomem *base = MBOX_BASE(mdev, instance);
 
-	spin_lock_irqsave(&mdev->lock, flags);
+	raw_spin_lock_irqsave(&mdev->lock, flags);
 	mdev->enabled[instance] &= ~BIT(channel);
 	writel_relaxed(BIT(channel), base + STI_ENA_CLR_OFFSET);
-	spin_unlock_irqrestore(&mdev->lock, flags);
+	raw_spin_unlock_irqrestore(&mdev->lock, flags);
 }
 
 static void sti_mbox_clear_irq(struct mbox_chan *chan)
@@ -450,7 +450,7 @@ static int sti_mbox_probe(struct platform_device *pdev)
 	mdev->dev		= &pdev->dev;
 	mdev->mbox		= mbox;
 
-	spin_lock_init(&mdev->lock);
+	raw_spin_lock_init(&mdev->lock);
 
 	/* STi Mailbox does not have a Tx-Done or Tx-Ready IRQ */
 	mbox->txdone_irq	= false;
-- 
2.7.4

[toc] | [next] | [standalone]


#1606706

FromSteven Rostedt <rostedt@goodmis.org>
Date2017-03-22 17:10 +0100
Message-ID<tnQZI-586-29@gated-at.bofh.it>
In reply to#1606655
On Wed, 22 Mar 2017 16:18:43 +0100
Lionel Debieve <lionel.debieve@st.com> wrote:

> Use raw_spin_lock in enable/disable channel as it comes from
> interrupt context.
> 
> BUG: sleeping function called from invalid context at
> kernel/locking/rtmutex.c:995
> in_atomic(): 1, irqs_disabled(): 128, pid: 307, name: pulseaudio
> Preemption disabled at:
> [<c01790fc>] __handle_domain_irq+0x4c/0xec
> CPU: 0 PID: 307 Comm: pulseaudio
> Hardware name: STi SoC with Flattened Device Tree
> [<c011046c>] (unwind_backtrace)
> [<c010c7f4>] (show_stack)
> [<c03d1578>] (dump_stack)
> [<c014e440>] (___might_sleep)
> [<c08e7f24>] (rt_spin_lock)
> [<c069bb04>] (sti_mbox_disable_channel)
> [<c069befc>] (sti_mbox_irq_handler)
> [<c0179900>] (__handle_irq_event_percpu)
> [<c01799dc>] (handle_irq_event_percpu)
> [<c0179a78>] (handle_irq_event)
> [<c017d1c8>] (handle_fasteoi_irq)
> [<c0178c08>] (generic_handle_irq)
> [<c017912c>] (__handle_domain_irq)
> [<c0101488>] (gic_handle_irq)
> 
> Signed-off-by: Lionel Debieve <lionel.debieve@st.com>

Looks fine to me. Should this go to mainline?

Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

-- Steve

> ---
>  drivers/mailbox/mailbox-sti.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/mailbox/mailbox-sti.c
> b/drivers/mailbox/mailbox-sti.c index 41bcd33..f9674ca 100644
> --- a/drivers/mailbox/mailbox-sti.c
> +++ b/drivers/mailbox/mailbox-sti.c
> @@ -60,7 +60,7 @@ struct sti_mbox_device {
>  	void __iomem		*base;
>  	const char		*name;
>  	u32			enabled[STI_MBOX_INST_MAX];
> -	spinlock_t		lock;
> +	raw_spinlock_t		lock;
>  };
>  
>  /**
> @@ -129,10 +129,10 @@ static void sti_mbox_enable_channel(struct
> mbox_chan *chan) unsigned long flags;
>  	void __iomem *base = MBOX_BASE(mdev, instance);
>  
> -	spin_lock_irqsave(&mdev->lock, flags);
> +	raw_spin_lock_irqsave(&mdev->lock, flags);
>  	mdev->enabled[instance] |= BIT(channel);
>  	writel_relaxed(BIT(channel), base + STI_ENA_SET_OFFSET);
> -	spin_unlock_irqrestore(&mdev->lock, flags);
> +	raw_spin_unlock_irqrestore(&mdev->lock, flags);
>  }
>  
>  static void sti_mbox_disable_channel(struct mbox_chan *chan)
> @@ -144,10 +144,10 @@ static void sti_mbox_disable_channel(struct
> mbox_chan *chan) unsigned long flags;
>  	void __iomem *base = MBOX_BASE(mdev, instance);
>  
> -	spin_lock_irqsave(&mdev->lock, flags);
> +	raw_spin_lock_irqsave(&mdev->lock, flags);
>  	mdev->enabled[instance] &= ~BIT(channel);
>  	writel_relaxed(BIT(channel), base + STI_ENA_CLR_OFFSET);
> -	spin_unlock_irqrestore(&mdev->lock, flags);
> +	raw_spin_unlock_irqrestore(&mdev->lock, flags);
>  }
>  
>  static void sti_mbox_clear_irq(struct mbox_chan *chan)
> @@ -450,7 +450,7 @@ static int sti_mbox_probe(struct platform_device
> *pdev) mdev->dev		= &pdev->dev;
>  	mdev->mbox		= mbox;
>  
> -	spin_lock_init(&mdev->lock);
> +	raw_spin_lock_init(&mdev->lock);
>  
>  	/* STi Mailbox does not have a Tx-Done or Tx-Ready IRQ */
>  	mbox->txdone_irq	= false;

[toc] | [prev] | [next] | [standalone]


#1606788

FromLionel DEBIEVE <lionel.debieve@st.com>
Date2017-03-22 18:20 +0100
Message-ID<tnS5t-5Vz-57@gated-at.bofh.it>
In reply to#1606706
On 03/22/2017 05:05 PM, Steven Rostedt wrote:
> On Wed, 22 Mar 2017 16:18:43 +0100
> Lionel Debieve <lionel.debieve@st.com> wrote:
>
>> Use raw_spin_lock in enable/disable channel as it comes from
>> interrupt context.
>>
>> BUG: sleeping function called from invalid context at
>> kernel/locking/rtmutex.c:995
>> in_atomic(): 1, irqs_disabled(): 128, pid: 307, name: pulseaudio
>> Preemption disabled at:
>> [<c01790fc>] __handle_domain_irq+0x4c/0xec
>> CPU: 0 PID: 307 Comm: pulseaudio
>> Hardware name: STi SoC with Flattened Device Tree
>> [<c011046c>] (unwind_backtrace)
>> [<c010c7f4>] (show_stack)
>> [<c03d1578>] (dump_stack)
>> [<c014e440>] (___might_sleep)
>> [<c08e7f24>] (rt_spin_lock)
>> [<c069bb04>] (sti_mbox_disable_channel)
>> [<c069befc>] (sti_mbox_irq_handler)
>> [<c0179900>] (__handle_irq_event_percpu)
>> [<c01799dc>] (handle_irq_event_percpu)
>> [<c0179a78>] (handle_irq_event)
>> [<c017d1c8>] (handle_fasteoi_irq)
>> [<c0178c08>] (generic_handle_irq)
>> [<c017912c>] (__handle_domain_irq)
>> [<c0101488>] (gic_handle_irq)
>>
>> Signed-off-by: Lionel Debieve <lionel.debieve@st.com>
> Looks fine to me. Should this go to mainline?
>
> Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
>
> -- Steve

Will look deeper if it can be.

Lionel

>
>> ---
>>   drivers/mailbox/mailbox-sti.c | 12 ++++++------
>>   1 file changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/mailbox/mailbox-sti.c
>> b/drivers/mailbox/mailbox-sti.c index 41bcd33..f9674ca 100644
>> --- a/drivers/mailbox/mailbox-sti.c
>> +++ b/drivers/mailbox/mailbox-sti.c
>> @@ -60,7 +60,7 @@ struct sti_mbox_device {
>>   	void __iomem		*base;
>>   	const char		*name;
>>   	u32			enabled[STI_MBOX_INST_MAX];
>> -	spinlock_t		lock;
>> +	raw_spinlock_t		lock;
>>   };
>>   
>>   /**
>> @@ -129,10 +129,10 @@ static void sti_mbox_enable_channel(struct
>> mbox_chan *chan) unsigned long flags;
>>   	void __iomem *base = MBOX_BASE(mdev, instance);
>>   
>> -	spin_lock_irqsave(&mdev->lock, flags);
>> +	raw_spin_lock_irqsave(&mdev->lock, flags);
>>   	mdev->enabled[instance] |= BIT(channel);
>>   	writel_relaxed(BIT(channel), base + STI_ENA_SET_OFFSET);
>> -	spin_unlock_irqrestore(&mdev->lock, flags);
>> +	raw_spin_unlock_irqrestore(&mdev->lock, flags);
>>   }
>>   
>>   static void sti_mbox_disable_channel(struct mbox_chan *chan)
>> @@ -144,10 +144,10 @@ static void sti_mbox_disable_channel(struct
>> mbox_chan *chan) unsigned long flags;
>>   	void __iomem *base = MBOX_BASE(mdev, instance);
>>   
>> -	spin_lock_irqsave(&mdev->lock, flags);
>> +	raw_spin_lock_irqsave(&mdev->lock, flags);
>>   	mdev->enabled[instance] &= ~BIT(channel);
>>   	writel_relaxed(BIT(channel), base + STI_ENA_CLR_OFFSET);
>> -	spin_unlock_irqrestore(&mdev->lock, flags);
>> +	raw_spin_unlock_irqrestore(&mdev->lock, flags);
>>   }
>>   
>>   static void sti_mbox_clear_irq(struct mbox_chan *chan)
>> @@ -450,7 +450,7 @@ static int sti_mbox_probe(struct platform_device
>> *pdev) mdev->dev		= &pdev->dev;
>>   	mdev->mbox		= mbox;
>>   
>> -	spin_lock_init(&mdev->lock);
>> +	raw_spin_lock_init(&mdev->lock);
>>   
>>   	/* STi Mailbox does not have a Tx-Done or Tx-Ready IRQ */
>>   	mbox->txdone_irq	= false;
>

[toc] | [prev] | [next] | [standalone]


#1606805

FromJulia Cartwright <julia@ni.com>
Date2017-03-22 18:40 +0100
Message-ID<tnSoO-63J-25@gated-at.bofh.it>
In reply to#1606655
On Wed, Mar 22, 2017 at 04:18:43PM +0100, Lionel Debieve wrote:
> Use raw_spin_lock in enable/disable channel as it comes from
> interrupt context.
> 
> BUG: sleeping function called from invalid context at
> kernel/locking/rtmutex.c:995
> in_atomic(): 1, irqs_disabled(): 128, pid: 307, name: pulseaudio
> Preemption disabled at:
> [<c01790fc>] __handle_domain_irq+0x4c/0xec
> CPU: 0 PID: 307 Comm: pulseaudio
> Hardware name: STi SoC with Flattened Device Tree
> [<c011046c>] (unwind_backtrace)
> [<c010c7f4>] (show_stack)
> [<c03d1578>] (dump_stack)
> [<c014e440>] (___might_sleep)
> [<c08e7f24>] (rt_spin_lock)
> [<c069bb04>] (sti_mbox_disable_channel)
> [<c069befc>] (sti_mbox_irq_handler)
> [<c0179900>] (__handle_irq_event_percpu)
> [<c01799dc>] (handle_irq_event_percpu)
> [<c0179a78>] (handle_irq_event)
> [<c017d1c8>] (handle_fasteoi_irq)
> [<c0178c08>] (generic_handle_irq)
> [<c017912c>] (__handle_domain_irq)
> [<c0101488>] (gic_handle_irq)

Which kernel were you testing on, here?  From what I can tell, this
should have been fixed with Thomas's commit:

   2a1d3ab8986d ("genirq: Handle force threading of irqs with primary and thread handler")

Which landed in 4.4.  It forces the primary handler to be threaded as
well.

   Julia

[toc] | [prev] | [next] | [standalone]


#1606871

FromSteven Rostedt <rostedt@goodmis.org>
Date2017-03-22 19:10 +0100
Message-ID<tnSRP-6Ap-11@gated-at.bofh.it>
In reply to#1606805
On Wed, 22 Mar 2017 12:37:59 -0500
Julia Cartwright <julia@ni.com> wrote:

> Which kernel were you testing on, here?  From what I can tell, this
> should have been fixed with Thomas's commit:
> 
>    2a1d3ab8986d ("genirq: Handle force threading of irqs with primary
> and thread handler")

Thanks Julia for looking into this. I just looked at the code, and saw
that it does very little with the lock held, and was fine with the
conversion. But if that interrupt handler should be in a thread, we
should see if that's the issue first.

> 
> Which landed in 4.4.  It forces the primary handler to be threaded as
> well.
> 

Lionel,

Can you check if this is an issue with 4.4 too?

-- Steve

[toc] | [prev] | [next] | [standalone]


#1606897

FromGrygorii Strashko <grygorii.strashko@ti.com>
Date2017-03-22 19:40 +0100
Message-ID<tnTkS-6PF-21@gated-at.bofh.it>
In reply to#1606871
On 03/22/2017 01:01 PM, Steven Rostedt wrote:
> On Wed, 22 Mar 2017 12:37:59 -0500
> Julia Cartwright <julia@ni.com> wrote:
>
>> Which kernel were you testing on, here?  From what I can tell, this
>> should have been fixed with Thomas's commit:
>>
>>    2a1d3ab8986d ("genirq: Handle force threading of irqs with primary
>> and thread handler")
>
> Thanks Julia for looking into this. I just looked at the code, and saw
> that it does very little with the lock held, and was fine with the
> conversion. But if that interrupt handler should be in a thread, we
> should see if that's the issue first.


It will not be threaded because there are IRQF_ONESHOT used.

	ret = devm_request_threaded_irq(&pdev->dev, irq,
					sti_mbox_irq_handler,
					sti_mbox_thread_handler,
					IRQF_ONESHOT, mdev->name, mdev);

>
>>
>> Which landed in 4.4.  It forces the primary handler to be threaded as
>> well.
>>
>
> Lionel,
>
> Can you check if this is an issue with 4.4 too?
>


-- 
regards,
-grygorii

[toc] | [prev] | [next] | [standalone]


#1606908

FromJulia Cartwright <julia@ni.com>
Date2017-03-22 19:50 +0100
Message-ID<tnTuy-6TD-29@gated-at.bofh.it>
In reply to#1606897

[Multipart message — attachments visible in raw view] — view raw

On Wed, Mar 22, 2017 at 01:30:12PM -0500, Grygorii Strashko wrote:
> 
> On 03/22/2017 01:01 PM, Steven Rostedt wrote:
> > On Wed, 22 Mar 2017 12:37:59 -0500
> > Julia Cartwright <julia@ni.com> wrote:
> > 
> > > Which kernel were you testing on, here?  From what I can tell, this
> > > should have been fixed with Thomas's commit:
> > > 
> > >    2a1d3ab8986d ("genirq: Handle force threading of irqs with primary
> > > and thread handler")
> > 
> > Thanks Julia for looking into this. I just looked at the code, and saw
> > that it does very little with the lock held, and was fine with the
> > conversion. But if that interrupt handler should be in a thread, we
> > should see if that's the issue first.
> 
> 
> It will not be threaded because there are IRQF_ONESHOT used.
> 
> 	ret = devm_request_threaded_irq(&pdev->dev, irq,
> 					sti_mbox_irq_handler,
> 					sti_mbox_thread_handler,
> 					IRQF_ONESHOT, mdev->name, mdev);

Indeed.  I had skipped over this important detail when I was skimming
through the code.

Thanks for clarifying!

Is IRQF_ONESHOT really necessary for this device?  The primary handler
invokes sti_mbox_disable_channel() on the interrupting channel, which I
would hope would acquiesce the pending interrupt at the device-level?

Also, as written there are num_inst reads of STI_IRQ_VAL_OFFSET in the
primary handler, which seems inefficient...(unless of course reading
incurs side effects, here).

   Julia

[toc] | [prev] | [next] | [standalone]


#1607247

FromLionel DEBIEVE <lionel.debieve@st.com>
Date2017-03-23 09:30 +0100
Message-ID<to6i5-84h-11@gated-at.bofh.it>
In reply to#1606908
On 03/22/2017 07:47 PM, Julia Cartwright wrote:
> On Wed, Mar 22, 2017 at 01:30:12PM -0500, Grygorii Strashko wrote:
>> On 03/22/2017 01:01 PM, Steven Rostedt wrote:
>>> On Wed, 22 Mar 2017 12:37:59 -0500
>>> Julia Cartwright <julia@ni.com> wrote:
>>>
>>>> Which kernel were you testing on, here?  From what I can tell, this
>>>> should have been fixed with Thomas's commit:
>>>>
>>>>     2a1d3ab8986d ("genirq: Handle force threading of irqs with primary
>>>> and thread handler")
>>> Thanks Julia for looking into this. I just looked at the code, and saw
>>> that it does very little with the lock held, and was fine with the
>>> conversion. But if that interrupt handler should be in a thread, we
>>> should see if that's the issue first.
>>
>> It will not be threaded because there are IRQF_ONESHOT used.
>>
>> 	ret = devm_request_threaded_irq(&pdev->dev, irq,
>> 					sti_mbox_irq_handler,
>> 					sti_mbox_thread_handler,
>> 					IRQF_ONESHOT, mdev->name, mdev);
> Indeed.  I had skipped over this important detail when I was skimming
> through the code.
>
> Thanks for clarifying!
>
> Is IRQF_ONESHOT really necessary for this device?  The primary handler
> invokes sti_mbox_disable_channel() on the interrupting channel, which I
> would hope would acquiesce the pending interrupt at the device-level?
>
> Also, as written there are num_inst reads of STI_IRQ_VAL_OFFSET in the
> primary handler, which seems inefficient...(unless of course reading
> incurs side effects, here).
>
>     Julia

First to reply Julia, test was made using 4.9.y kernel branch.
For the IRQF_ONESHOT, I rely on Lee (adding in mail thread) that was at the device driver origin.

Steven, you're also right as the patch can be also pushed in mainline too.

Lionel

[toc] | [prev] | [next] | [standalone]


#1607322

FromLee Jones <lee.jones@linaro.org>
Date2017-03-23 11:30 +0100
Message-ID<to8ad-TC-7@gated-at.bofh.it>
In reply to#1607247
On Thu, 23 Mar 2017, Lionel DEBIEVE wrote:

> On 03/22/2017 07:47 PM, Julia Cartwright wrote:
> > On Wed, Mar 22, 2017 at 01:30:12PM -0500, Grygorii Strashko wrote:
> >> On 03/22/2017 01:01 PM, Steven Rostedt wrote:
> >>> On Wed, 22 Mar 2017 12:37:59 -0500
> >>> Julia Cartwright <julia@ni.com> wrote:
> >>>
> >>>> Which kernel were you testing on, here?  From what I can tell, this
> >>>> should have been fixed with Thomas's commit:
> >>>>
> >>>>     2a1d3ab8986d ("genirq: Handle force threading of irqs with primary
> >>>> and thread handler")
> >>> Thanks Julia for looking into this. I just looked at the code, and saw
> >>> that it does very little with the lock held, and was fine with the
> >>> conversion. But if that interrupt handler should be in a thread, we
> >>> should see if that's the issue first.
> >>
> >> It will not be threaded because there are IRQF_ONESHOT used.
> >>
> >> 	ret = devm_request_threaded_irq(&pdev->dev, irq,
> >> 					sti_mbox_irq_handler,
> >> 					sti_mbox_thread_handler,
> >> 					IRQF_ONESHOT, mdev->name, mdev);
> > Indeed.  I had skipped over this important detail when I was skimming
> > through the code.
> >
> > Thanks for clarifying!
> >
> > Is IRQF_ONESHOT really necessary for this device?  The primary handler
> > invokes sti_mbox_disable_channel() on the interrupting channel, which I
> > would hope would acquiesce the pending interrupt at the device-level?

Not sure.  This part of the code is remanent from when I re-wrote it.

What is the alternative?

NB: What does 'acquiesce' mean in this context?  Is that a typo?

> > Also, as written there are num_inst reads of STI_IRQ_VAL_OFFSET in the
> > primary handler, which seems inefficient...(unless of course reading
> > incurs side effects, here).

Inefficient in what respect?

> First to reply Julia, test was made using 4.9.y kernel branch.
> For the IRQF_ONESHOT, I rely on Lee (adding in mail thread) that was at the device driver origin.
> 
> Steven, you're also right as the patch can be also pushed in mainline too.
> 
> Lionel
> 

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

[toc] | [prev] | [next] | [standalone]


#1607902

FromJulia Cartwright <julia@ni.com>
Date2017-03-23 22:00 +0100
Message-ID<tohZT-7Mb-1@gated-at.bofh.it>
In reply to#1607322

[Multipart message — attachments visible in raw view] — view raw

On Thu, Mar 23, 2017 at 10:26:49AM +0000, Lee Jones wrote:
> On Thu, 23 Mar 2017, Lionel DEBIEVE wrote:
> 
> > On 03/22/2017 07:47 PM, Julia Cartwright wrote:
> > > On Wed, Mar 22, 2017 at 01:30:12PM -0500, Grygorii Strashko wrote:
> > >> On 03/22/2017 01:01 PM, Steven Rostedt wrote:
> > >>> On Wed, 22 Mar 2017 12:37:59 -0500
> > >>> Julia Cartwright <julia@ni.com> wrote:
> > >>>
> > >>>> Which kernel were you testing on, here?  From what I can tell, this
> > >>>> should have been fixed with Thomas's commit:
> > >>>>
> > >>>>     2a1d3ab8986d ("genirq: Handle force threading of irqs with primary
> > >>>> and thread handler")
> > >>> Thanks Julia for looking into this. I just looked at the code, and saw
> > >>> that it does very little with the lock held, and was fine with the
> > >>> conversion. But if that interrupt handler should be in a thread, we
> > >>> should see if that's the issue first.
> > >>
> > >> It will not be threaded because there are IRQF_ONESHOT used.
> > >>
> > >> 	ret = devm_request_threaded_irq(&pdev->dev, irq,
> > >> 					sti_mbox_irq_handler,
> > >> 					sti_mbox_thread_handler,
> > >> 					IRQF_ONESHOT, mdev->name, mdev);
> > > Indeed.  I had skipped over this important detail when I was skimming
> > > through the code.
> > >
> > > Thanks for clarifying!
> > >
> > > Is IRQF_ONESHOT really necessary for this device?  The primary handler
> > > invokes sti_mbox_disable_channel() on the interrupting channel, which I
> > > would hope would acquiesce the pending interrupt at the device-level?
> 
> Not sure.  This part of the code is remanent from when I re-wrote it.
> 
> What is the alternative?

If, on the completed execution of the registered primary handler, you
can ensure that the device is no longer asserting an interrupt to the
connected irq chip, then the IRQF_ONESHOT isn't necessary, because it's
safe for the irq core to unmask the interrupt after the primary handler
runs.

It appears that it might be able to make this guarantee, if that's what
sti_mbox_disable_channel() is doing.

> NB: What does 'acquiesce' mean in this context?  Is that a typo?

I mean 'acquiesce' to mean what I mention before: prevent the device
from asserting the interrupt.  Perhaps it's a uncommon use of the word.

> > > Also, as written there are num_inst reads of STI_IRQ_VAL_OFFSET in the
> > > primary handler, which seems inefficient...(unless of course reading
> > > incurs side effects, here).
>
> Inefficient in what respect?

I've since looked again and realized that the register base is
recalculated based on 'instance', so disregard this comment.

   Julia

[toc] | [prev] | [next] | [standalone]


#1608212

FromThomas Gleixner <tglx@linutronix.de>
Date2017-03-24 09:40 +0100
Message-ID<tosVj-7gO-11@gated-at.bofh.it>
In reply to#1606908
On Wed, 22 Mar 2017, Julia Cartwright wrote:
> On Wed, Mar 22, 2017 at 01:30:12PM -0500, Grygorii Strashko wrote:
> > It will not be threaded because there are IRQF_ONESHOT used.
> > 
> > 	ret = devm_request_threaded_irq(&pdev->dev, irq,
> > 					sti_mbox_irq_handler,
> > 					sti_mbox_thread_handler,
> > 					IRQF_ONESHOT, mdev->name, mdev);
> 
> Indeed.  I had skipped over this important detail when I was skimming
> through the code.
> 
> Thanks for clarifying!
> 
> Is IRQF_ONESHOT really necessary for this device?  The primary handler
> invokes sti_mbox_disable_channel() on the interrupting channel, which I
> would hope would acquiesce the pending interrupt at the device-level?

Well, this is a typical case of well done split into primary and threaded
handler. There is no advantage on RT to force this into double threaded
handling. Making the lock raw is definitely the proper solution here.

Thanks,

	tglx

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web