linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] genirq: Fix [devm_]irq_alloc_desc returning irq 0
@ 2020-12-21 18:56 Hans de Goede
  2021-01-13 11:47 ` Hans de Goede
  2021-02-05 19:55 ` [tip: irq/urgent] genirq: Prevent [devm_]irq_alloc_desc from " tip-bot2 for Hans de Goede
  0 siblings, 2 replies; 3+ messages in thread
From: Hans de Goede @ 2020-12-21 18:56 UTC (permalink / raw)
  To: Thomas Gleixner, Marc Zyngier; +Cc: Hans de Goede, linux-kernel, Bjorn Helgaas

Since commit a85a6c86c25b ("driver core: platform: Clarify that IRQ 0
is invalid"), having a linux-irq with number 0 will trigger a WARN
when calling platform_get_irq*() to retrieve that linux-irq.

Since [devm_]irq_alloc_desc allocs 1 single irq and since irq 0 is
normally not used, it would return 0 before this commit, triggering
that WARN. This happens e.g. on Intel Bay Trail and Cherry Trail
devices using the LPE audio engine for HDMI audio:

[   22.761392] ------------[ cut here ]------------
[   22.761405] 0 is an invalid IRQ number
[   22.761462] WARNING: CPU: 3 PID: 472 at drivers/base/platform.c:238 platform_get_irq_optional+0x108/0x180
[   22.761470] Modules linked in: snd_hdmi_lpe_audio(+) ...
...
[   22.762133] Call Trace:
[   22.762158]  platform_get_irq+0x17/0x30
[   22.762182]  hdmi_lpe_audio_probe+0x4a/0x6c0 [snd_hdmi_lpe_audio]
...
[   22.762726] ---[ end trace ceece38854223a0b ]---

Change the 'from' parameter passed to __[devm_]irq_alloc_descs() by the
[devm_]irq_alloc_desc macros from 0 to 1, so that these macros
will no longer return 0.

Cc: Bjorn Helgaas <bhelgaas@google.com>
Fixes: a85a6c86c25b ("driver core: platform: Clarify that IRQ 0 is invalid")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
A quick grep for 'irq_alloc_desc\(' shows only 2 users of irq_alloc_desc():
1. drivers/gpu/drm/i915/display/intel_lpe_audio.c
2. drivers/sh/intc/virq.c
But that might very well be an incomplete list.
---
 include/linux/irq.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/irq.h b/include/linux/irq.h
index c54365309e97..a36d35c25996 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -922,7 +922,7 @@ int __devm_irq_alloc_descs(struct device *dev, int irq, unsigned int from,
 	__irq_alloc_descs(irq, from, cnt, node, THIS_MODULE, NULL)
 
 #define irq_alloc_desc(node)			\
-	irq_alloc_descs(-1, 0, 1, node)
+	irq_alloc_descs(-1, 1, 1, node)
 
 #define irq_alloc_desc_at(at, node)		\
 	irq_alloc_descs(at, at, 1, node)
@@ -937,7 +937,7 @@ int __devm_irq_alloc_descs(struct device *dev, int irq, unsigned int from,
 	__devm_irq_alloc_descs(dev, irq, from, cnt, node, THIS_MODULE, NULL)
 
 #define devm_irq_alloc_desc(dev, node)				\
-	devm_irq_alloc_descs(dev, -1, 0, 1, node)
+	devm_irq_alloc_descs(dev, -1, 1, 1, node)
 
 #define devm_irq_alloc_desc_at(dev, at, node)			\
 	devm_irq_alloc_descs(dev, at, at, 1, node)
-- 
2.28.0


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

* Re: [PATCH] genirq: Fix [devm_]irq_alloc_desc returning irq 0
  2020-12-21 18:56 [PATCH] genirq: Fix [devm_]irq_alloc_desc returning irq 0 Hans de Goede
@ 2021-01-13 11:47 ` Hans de Goede
  2021-02-05 19:55 ` [tip: irq/urgent] genirq: Prevent [devm_]irq_alloc_desc from " tip-bot2 for Hans de Goede
  1 sibling, 0 replies; 3+ messages in thread
From: Hans de Goede @ 2021-01-13 11:47 UTC (permalink / raw)
  To: Thomas Gleixner, Marc Zyngier; +Cc: linux-kernel, Bjorn Helgaas

Hi,

On 12/21/20 7:56 PM, Hans de Goede wrote:
> Since commit a85a6c86c25b ("driver core: platform: Clarify that IRQ 0
> is invalid"), having a linux-irq with number 0 will trigger a WARN
> when calling platform_get_irq*() to retrieve that linux-irq.
> 
> Since [devm_]irq_alloc_desc allocs 1 single irq and since irq 0 is
> normally not used, it would return 0 before this commit, triggering
> that WARN. This happens e.g. on Intel Bay Trail and Cherry Trail
> devices using the LPE audio engine for HDMI audio:
> 
> [   22.761392] ------------[ cut here ]------------
> [   22.761405] 0 is an invalid IRQ number
> [   22.761462] WARNING: CPU: 3 PID: 472 at drivers/base/platform.c:238 platform_get_irq_optional+0x108/0x180
> [   22.761470] Modules linked in: snd_hdmi_lpe_audio(+) ...
> ...
> [   22.762133] Call Trace:
> [   22.762158]  platform_get_irq+0x17/0x30
> [   22.762182]  hdmi_lpe_audio_probe+0x4a/0x6c0 [snd_hdmi_lpe_audio]
> ...
> [   22.762726] ---[ end trace ceece38854223a0b ]---
> 
> Change the 'from' parameter passed to __[devm_]irq_alloc_descs() by the
> [devm_]irq_alloc_desc macros from 0 to 1, so that these macros
> will no longer return 0.


Can someone please take a look at this patch?

(I guess sending this out during the hollidays may not have been the
best of ideas.)

Regards,

Hans




> 
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Fixes: a85a6c86c25b ("driver core: platform: Clarify that IRQ 0 is invalid")
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
> A quick grep for 'irq_alloc_desc\(' shows only 2 users of irq_alloc_desc():
> 1. drivers/gpu/drm/i915/display/intel_lpe_audio.c
> 2. drivers/sh/intc/virq.c
> But that might very well be an incomplete list.
> ---
>  include/linux/irq.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/irq.h b/include/linux/irq.h
> index c54365309e97..a36d35c25996 100644
> --- a/include/linux/irq.h
> +++ b/include/linux/irq.h
> @@ -922,7 +922,7 @@ int __devm_irq_alloc_descs(struct device *dev, int irq, unsigned int from,
>  	__irq_alloc_descs(irq, from, cnt, node, THIS_MODULE, NULL)
>  
>  #define irq_alloc_desc(node)			\
> -	irq_alloc_descs(-1, 0, 1, node)
> +	irq_alloc_descs(-1, 1, 1, node)
>  
>  #define irq_alloc_desc_at(at, node)		\
>  	irq_alloc_descs(at, at, 1, node)
> @@ -937,7 +937,7 @@ int __devm_irq_alloc_descs(struct device *dev, int irq, unsigned int from,
>  	__devm_irq_alloc_descs(dev, irq, from, cnt, node, THIS_MODULE, NULL)
>  
>  #define devm_irq_alloc_desc(dev, node)				\
> -	devm_irq_alloc_descs(dev, -1, 0, 1, node)
> +	devm_irq_alloc_descs(dev, -1, 1, 1, node)
>  
>  #define devm_irq_alloc_desc_at(dev, at, node)			\
>  	devm_irq_alloc_descs(dev, at, at, 1, node)
> 


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

* [tip: irq/urgent] genirq: Prevent [devm_]irq_alloc_desc from returning irq 0
  2020-12-21 18:56 [PATCH] genirq: Fix [devm_]irq_alloc_desc returning irq 0 Hans de Goede
  2021-01-13 11:47 ` Hans de Goede
@ 2021-02-05 19:55 ` tip-bot2 for Hans de Goede
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Hans de Goede @ 2021-02-05 19:55 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Hans de Goede, Thomas Gleixner, stable, x86, linux-kernel, maz

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

Commit-ID:     4c7bcb51ae25f79e3733982e5d0cd8ce8640ddfc
Gitweb:        https://git.kernel.org/tip/4c7bcb51ae25f79e3733982e5d0cd8ce8640ddfc
Author:        Hans de Goede <hdegoede@redhat.com>
AuthorDate:    Mon, 21 Dec 2020 19:56:47 +01:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Fri, 05 Feb 2021 20:48:28 +01:00

genirq: Prevent [devm_]irq_alloc_desc from returning irq 0

Since commit a85a6c86c25b ("driver core: platform: Clarify that IRQ 0
is invalid"), having a linux-irq with number 0 will trigger a WARN()
when calling platform_get_irq*() to retrieve that linux-irq.

Since [devm_]irq_alloc_desc allocs a single irq and since irq 0 is not used
on some systems, it can return 0, triggering that WARN(). This happens
e.g. on Intel Bay Trail and Cherry Trail devices using the LPE audio engine
for HDMI audio:

 0 is an invalid IRQ number
 WARNING: CPU: 3 PID: 472 at drivers/base/platform.c:238 platform_get_irq_optional+0x108/0x180
 Modules linked in: snd_hdmi_lpe_audio(+) ...

 Call Trace:
  platform_get_irq+0x17/0x30
  hdmi_lpe_audio_probe+0x4a/0x6c0 [snd_hdmi_lpe_audio]

 ---[ end trace ceece38854223a0b ]---

Change the 'from' parameter passed to __[devm_]irq_alloc_descs() by the
[devm_]irq_alloc_desc macros from 0 to 1, so that these macros will no
longer return 0.

Fixes: a85a6c86c25b ("driver core: platform: Clarify that IRQ 0 is invalid")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20201221185647.226146-1-hdegoede@redhat.com
---
 include/linux/irq.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/irq.h b/include/linux/irq.h
index 4aeb1c4..2efde6a 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -928,7 +928,7 @@ int __devm_irq_alloc_descs(struct device *dev, int irq, unsigned int from,
 	__irq_alloc_descs(irq, from, cnt, node, THIS_MODULE, NULL)
 
 #define irq_alloc_desc(node)			\
-	irq_alloc_descs(-1, 0, 1, node)
+	irq_alloc_descs(-1, 1, 1, node)
 
 #define irq_alloc_desc_at(at, node)		\
 	irq_alloc_descs(at, at, 1, node)
@@ -943,7 +943,7 @@ int __devm_irq_alloc_descs(struct device *dev, int irq, unsigned int from,
 	__devm_irq_alloc_descs(dev, irq, from, cnt, node, THIS_MODULE, NULL)
 
 #define devm_irq_alloc_desc(dev, node)				\
-	devm_irq_alloc_descs(dev, -1, 0, 1, node)
+	devm_irq_alloc_descs(dev, -1, 1, 1, node)
 
 #define devm_irq_alloc_desc_at(dev, at, node)			\
 	devm_irq_alloc_descs(dev, at, at, 1, node)

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

end of thread, other threads:[~2021-02-05 19:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-21 18:56 [PATCH] genirq: Fix [devm_]irq_alloc_desc returning irq 0 Hans de Goede
2021-01-13 11:47 ` Hans de Goede
2021-02-05 19:55 ` [tip: irq/urgent] genirq: Prevent [devm_]irq_alloc_desc from " tip-bot2 for Hans de Goede

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