linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] irqchip/gic-v4.1: Use readx_poll_timeout_atomic() to fix sleep in atomic
@ 2020-06-05  5:23 Zenghui Yu
  2020-06-10 13:59 ` Zenghui Yu
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Zenghui Yu @ 2020-06-05  5:23 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, kvmarm
  Cc: tglx, jason, maz, wanghaibin.wang, wangjingyi11, Zenghui Yu

readx_poll_timeout() can sleep if @sleep_us is specified by the caller,
and is therefore unsafe to be used inside the atomic context, which is
this case when we use it to poll the GICR_VPENDBASER.Dirty bit in
irq_set_vcpu_affinity() callback.

Let's convert to its atomic version instead which helps to get the v4.1
board back to life!

Fixes: 96806229ca03 ("irqchip/gic-v4.1: Add support for VPENDBASER's Dirty+Valid signaling")
Signed-off-by: Zenghui Yu <yuzenghui@huawei.com>
---
 drivers/irqchip/irq-gic-v3-its.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index cd685f521c77..6a5a87fc4601 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -3797,10 +3797,10 @@ static void its_wait_vpt_parse_complete(void)
 	if (!gic_rdists->has_vpend_valid_dirty)
 		return;
 
-	WARN_ON_ONCE(readq_relaxed_poll_timeout(vlpi_base + GICR_VPENDBASER,
-						val,
-						!(val & GICR_VPENDBASER_Dirty),
-						10, 500));
+	WARN_ON_ONCE(readq_relaxed_poll_timeout_atomic(vlpi_base + GICR_VPENDBASER,
+						       val,
+						       !(val & GICR_VPENDBASER_Dirty),
+						       10, 500));
 }
 
 static void its_vpe_schedule(struct its_vpe *vpe)
-- 
2.19.1


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

* Re: [PATCH] irqchip/gic-v4.1: Use readx_poll_timeout_atomic() to fix sleep in atomic
  2020-06-05  5:23 [PATCH] irqchip/gic-v4.1: Use readx_poll_timeout_atomic() to fix sleep in atomic Zenghui Yu
@ 2020-06-10 13:59 ` Zenghui Yu
  2020-06-10 15:02   ` Marc Zyngier
  2020-06-10 18:43 ` Marc Zyngier
  2020-06-30 10:11 ` [tip: irq/urgent] " tip-bot2 for Zenghui Yu
  2 siblings, 1 reply; 5+ messages in thread
From: Zenghui Yu @ 2020-06-10 13:59 UTC (permalink / raw)
  To: maz
  Cc: linux-kernel, linux-arm-kernel, kvmarm, tglx, jason,
	wanghaibin.wang, wangjingyi11

Hi Marc,

Sorry to ping you in the merge window, but ...

On 2020/6/5 13:23, Zenghui Yu wrote:
> readx_poll_timeout() can sleep if @sleep_us is specified by the caller,
> and is therefore unsafe to be used inside the atomic context, which is
> this case when we use it to poll the GICR_VPENDBASER.Dirty bit in
> irq_set_vcpu_affinity() callback.

this seems like an urgent thing to me. Without this patch, CPUs are
easily to get stuck on my board with GICv4.1 enabled. So it'd be good if
you can have a look and take this as a fix (if it is correct).


Thanks,
Zenghui

> 
> Let's convert to its atomic version instead which helps to get the v4.1
> board back to life!
> 
> Fixes: 96806229ca03 ("irqchip/gic-v4.1: Add support for VPENDBASER's Dirty+Valid signaling")
> Signed-off-by: Zenghui Yu <yuzenghui@huawei.com>
> ---
>   drivers/irqchip/irq-gic-v3-its.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
> index cd685f521c77..6a5a87fc4601 100644
> --- a/drivers/irqchip/irq-gic-v3-its.c
> +++ b/drivers/irqchip/irq-gic-v3-its.c
> @@ -3797,10 +3797,10 @@ static void its_wait_vpt_parse_complete(void)
>   	if (!gic_rdists->has_vpend_valid_dirty)
>   		return;
>   
> -	WARN_ON_ONCE(readq_relaxed_poll_timeout(vlpi_base + GICR_VPENDBASER,
> -						val,
> -						!(val & GICR_VPENDBASER_Dirty),
> -						10, 500));
> +	WARN_ON_ONCE(readq_relaxed_poll_timeout_atomic(vlpi_base + GICR_VPENDBASER,
> +						       val,
> +						       !(val & GICR_VPENDBASER_Dirty),
> +						       10, 500));
>   }
>   
>   static void its_vpe_schedule(struct its_vpe *vpe)
> 

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

* Re: [PATCH] irqchip/gic-v4.1: Use readx_poll_timeout_atomic() to fix sleep in atomic
  2020-06-10 13:59 ` Zenghui Yu
@ 2020-06-10 15:02   ` Marc Zyngier
  0 siblings, 0 replies; 5+ messages in thread
From: Marc Zyngier @ 2020-06-10 15:02 UTC (permalink / raw)
  To: Zenghui Yu
  Cc: linux-kernel, linux-arm-kernel, kvmarm, tglx, jason,
	wanghaibin.wang, wangjingyi11

Hi Zenghui,

On 2020-06-10 14:59, Zenghui Yu wrote:
> Hi Marc,
> 
> Sorry to ping you in the merge window, but ...
> 
> On 2020/6/5 13:23, Zenghui Yu wrote:
>> readx_poll_timeout() can sleep if @sleep_us is specified by the 
>> caller,
>> and is therefore unsafe to be used inside the atomic context, which is
>> this case when we use it to poll the GICR_VPENDBASER.Dirty bit in
>> irq_set_vcpu_affinity() callback.
> 
> this seems like an urgent thing to me. Without this patch, CPUs are
> easily to get stuck on my board with GICv4.1 enabled. So it'd be good 
> if
> you can have a look and take this as a fix (if it is correct).

No worries. I've earmarked the patch for -rc1 already, just haven't got
a chance to build the branch yet (a bit busy on the KVM side).

I'll probably update the branch tonight or tomorrow.

Thanks,

         M.
-- 
Jazz is not dead. It just smells funny...

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

* Re: [PATCH] irqchip/gic-v4.1: Use readx_poll_timeout_atomic() to fix sleep in atomic
  2020-06-05  5:23 [PATCH] irqchip/gic-v4.1: Use readx_poll_timeout_atomic() to fix sleep in atomic Zenghui Yu
  2020-06-10 13:59 ` Zenghui Yu
@ 2020-06-10 18:43 ` Marc Zyngier
  2020-06-30 10:11 ` [tip: irq/urgent] " tip-bot2 for Zenghui Yu
  2 siblings, 0 replies; 5+ messages in thread
From: Marc Zyngier @ 2020-06-10 18:43 UTC (permalink / raw)
  To: Zenghui Yu, linux-arm-kernel, linux-kernel, kvmarm; +Cc: tglx, jason

On Fri, 5 Jun 2020 13:23:45 +0800, Zenghui Yu wrote:
> readx_poll_timeout() can sleep if @sleep_us is specified by the caller,
> and is therefore unsafe to be used inside the atomic context, which is
> this case when we use it to poll the GICR_VPENDBASER.Dirty bit in
> irq_set_vcpu_affinity() callback.
> 
> Let's convert to its atomic version instead which helps to get the v4.1
> board back to life!
> 
> [...]

Applied to irq/irqchip-next, thanks!

[1/1] irqchip/gic-v4.1: Use readx_poll_timeout_atomic() to fix sleep in atomic
      commit: a87d4e00eacbc95b44466e3470529f4de49b450a

Cheers,

	M.
-- 
Without deviation from the norm, progress is not possible.



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

* [tip: irq/urgent] irqchip/gic-v4.1: Use readx_poll_timeout_atomic() to fix sleep in atomic
  2020-06-05  5:23 [PATCH] irqchip/gic-v4.1: Use readx_poll_timeout_atomic() to fix sleep in atomic Zenghui Yu
  2020-06-10 13:59 ` Zenghui Yu
  2020-06-10 18:43 ` Marc Zyngier
@ 2020-06-30 10:11 ` tip-bot2 for Zenghui Yu
  2 siblings, 0 replies; 5+ messages in thread
From: tip-bot2 for Zenghui Yu @ 2020-06-30 10:11 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: Zenghui Yu, Marc Zyngier, x86, LKML

The following commit has been merged into the irq/urgent branch of tip:

Commit-ID:     31dbb6b1d025506b3b8b8b74e9b697df47b9f696
Gitweb:        https://git.kernel.org/tip/31dbb6b1d025506b3b8b8b74e9b697df47b9f696
Author:        Zenghui Yu <yuzenghui@huawei.com>
AuthorDate:    Fri, 05 Jun 2020 13:23:45 +08:00
Committer:     Marc Zyngier <maz@kernel.org>
CommitterDate: Sun, 21 Jun 2020 15:13:11 +01:00

irqchip/gic-v4.1: Use readx_poll_timeout_atomic() to fix sleep in atomic

readx_poll_timeout() can sleep if @sleep_us is specified by the caller,
and is therefore unsafe to be used inside the atomic context, which is
this case when we use it to poll the GICR_VPENDBASER.Dirty bit in
irq_set_vcpu_affinity() callback.

Let's convert to its atomic version instead which helps to get the v4.1
board back to life!

Fixes: 96806229ca03 ("irqchip/gic-v4.1: Add support for VPENDBASER's Dirty+Valid signaling")
Signed-off-by: Zenghui Yu <yuzenghui@huawei.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20200605052345.1494-1-yuzenghui@huawei.com
---
 drivers/irqchip/irq-gic-v3-its.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index cd685f5..6a5a87f 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -3797,10 +3797,10 @@ static void its_wait_vpt_parse_complete(void)
 	if (!gic_rdists->has_vpend_valid_dirty)
 		return;
 
-	WARN_ON_ONCE(readq_relaxed_poll_timeout(vlpi_base + GICR_VPENDBASER,
-						val,
-						!(val & GICR_VPENDBASER_Dirty),
-						10, 500));
+	WARN_ON_ONCE(readq_relaxed_poll_timeout_atomic(vlpi_base + GICR_VPENDBASER,
+						       val,
+						       !(val & GICR_VPENDBASER_Dirty),
+						       10, 500));
 }
 
 static void its_vpe_schedule(struct its_vpe *vpe)

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

end of thread, other threads:[~2020-06-30 10:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-05  5:23 [PATCH] irqchip/gic-v4.1: Use readx_poll_timeout_atomic() to fix sleep in atomic Zenghui Yu
2020-06-10 13:59 ` Zenghui Yu
2020-06-10 15:02   ` Marc Zyngier
2020-06-10 18:43 ` Marc Zyngier
2020-06-30 10:11 ` [tip: irq/urgent] " tip-bot2 for Zenghui Yu

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