mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] irqchip/loongarch-cpu: Fix return value of lpic_gsi_to_irq()
@ 2024-07-23  6:45 Huacai Chen
  2024-07-23  6:46 ` Jiaxun Yang
  2024-07-26 19:17 ` [tip: irq/urgent] " tip-bot2 for Huacai Chen
  0 siblings, 2 replies; 3+ messages in thread
From: Huacai Chen @ 2024-07-23  6:45 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: loongarch, linux-kernel, Xuefeng Li, Huacai Chen, Jiaxun Yang,
	Huacai Chen, Miao Wang

lpic_gsi_to_irq() should return a valid irq if acpi_register_gsi()
succeed, and return 0 otherwise. But now lpic_gsi_to_irq() converts
a negative return value of acpi_register_gsi() to a positive value
silently, so fix it.

Reported-by: Miao Wang <shankerwangmiao@gmail.com>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
---
 drivers/irqchip/irq-loongarch-cpu.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/irqchip/irq-loongarch-cpu.c b/drivers/irqchip/irq-loongarch-cpu.c
index 9d8f2c406043..b35903a06902 100644
--- a/drivers/irqchip/irq-loongarch-cpu.c
+++ b/drivers/irqchip/irq-loongarch-cpu.c
@@ -18,11 +18,13 @@ struct fwnode_handle *cpuintc_handle;
 
 static u32 lpic_gsi_to_irq(u32 gsi)
 {
+	int irq = 0;
+
 	/* Only pch irqdomain transferring is required for LoongArch. */
 	if (gsi >= GSI_MIN_PCH_IRQ && gsi <= GSI_MAX_PCH_IRQ)
-		return acpi_register_gsi(NULL, gsi, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_HIGH);
+		irq = acpi_register_gsi(NULL, gsi, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_HIGH);
 
-	return 0;
+	return (irq > 0) ? irq : 0;
 }
 
 static struct fwnode_handle *lpic_get_gsi_domain_id(u32 gsi)
-- 
2.43.5


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

* Re: [PATCH] irqchip/loongarch-cpu: Fix return value of lpic_gsi_to_irq()
  2024-07-23  6:45 [PATCH] irqchip/loongarch-cpu: Fix return value of lpic_gsi_to_irq() Huacai Chen
@ 2024-07-23  6:46 ` Jiaxun Yang
  2024-07-26 19:17 ` [tip: irq/urgent] " tip-bot2 for Huacai Chen
  1 sibling, 0 replies; 3+ messages in thread
From: Jiaxun Yang @ 2024-07-23  6:46 UTC (permalink / raw)
  To: Huacai Chen, Thomas Gleixner
  Cc: loongarch, linux-kernel, Xuefeng Li, Huacai Chen, Miao Wang



在2024年7月23日七月 下午2:45,Huacai Chen写道:
> lpic_gsi_to_irq() should return a valid irq if acpi_register_gsi()
> succeed, and return 0 otherwise. But now lpic_gsi_to_irq() converts
> a negative return value of acpi_register_gsi() to a positive value
> silently, so fix it.
>
> Reported-by: Miao Wang <shankerwangmiao@gmail.com>
> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>

Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com>

> ---
>  drivers/irqchip/irq-loongarch-cpu.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/irqchip/irq-loongarch-cpu.c 
> b/drivers/irqchip/irq-loongarch-cpu.c
> index 9d8f2c406043..b35903a06902 100644
> --- a/drivers/irqchip/irq-loongarch-cpu.c
> +++ b/drivers/irqchip/irq-loongarch-cpu.c
> @@ -18,11 +18,13 @@ struct fwnode_handle *cpuintc_handle;
> 
>  static u32 lpic_gsi_to_irq(u32 gsi)
>  {
> +	int irq = 0;
> +
>  	/* Only pch irqdomain transferring is required for LoongArch. */
>  	if (gsi >= GSI_MIN_PCH_IRQ && gsi <= GSI_MAX_PCH_IRQ)
> -		return acpi_register_gsi(NULL, gsi, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_HIGH);
> +		irq = acpi_register_gsi(NULL, gsi, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_HIGH);
> 
> -	return 0;
> +	return (irq > 0) ? irq : 0;
>  }
> 
>  static struct fwnode_handle *lpic_get_gsi_domain_id(u32 gsi)
> -- 
> 2.43.5

-- 
- Jiaxun

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

* [tip: irq/urgent] irqchip/loongarch-cpu: Fix return value of lpic_gsi_to_irq()
  2024-07-23  6:45 [PATCH] irqchip/loongarch-cpu: Fix return value of lpic_gsi_to_irq() Huacai Chen
  2024-07-23  6:46 ` Jiaxun Yang
@ 2024-07-26 19:17 ` tip-bot2 for Huacai Chen
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Huacai Chen @ 2024-07-26 19:17 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Miao Wang, Huacai Chen, Thomas Gleixner, Jiaxun Yang, stable,
	x86, linux-kernel, maz

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

Commit-ID:     81a91abab1307d7725fa4620952c0767beae7753
Gitweb:        https://git.kernel.org/tip/81a91abab1307d7725fa4620952c0767beae7753
Author:        Huacai Chen <chenhuacai@loongson.cn>
AuthorDate:    Tue, 23 Jul 2024 14:45:08 +08:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Fri, 26 Jul 2024 21:08:42 +02:00

irqchip/loongarch-cpu: Fix return value of lpic_gsi_to_irq()

lpic_gsi_to_irq() should return a valid Linux interrupt number if
acpi_register_gsi() succeeds, and return 0 otherwise. But lpic_gsi_to_irq()
converts a negative return value of acpi_register_gsi() to a positive value
silently.

Convert the return value explicitly.

Fixes: e8bba72b396c ("irqchip / ACPI: Introduce ACPI_IRQ_MODEL_LPIC for LoongArch")
Reported-by: Miao Wang <shankerwangmiao@gmail.com>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20240723064508.35560-1-chenhuacai@loongson.cn
---
 drivers/irqchip/irq-loongarch-cpu.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/irqchip/irq-loongarch-cpu.c b/drivers/irqchip/irq-loongarch-cpu.c
index 9d8f2c4..b35903a 100644
--- a/drivers/irqchip/irq-loongarch-cpu.c
+++ b/drivers/irqchip/irq-loongarch-cpu.c
@@ -18,11 +18,13 @@ struct fwnode_handle *cpuintc_handle;
 
 static u32 lpic_gsi_to_irq(u32 gsi)
 {
+	int irq = 0;
+
 	/* Only pch irqdomain transferring is required for LoongArch. */
 	if (gsi >= GSI_MIN_PCH_IRQ && gsi <= GSI_MAX_PCH_IRQ)
-		return acpi_register_gsi(NULL, gsi, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_HIGH);
+		irq = acpi_register_gsi(NULL, gsi, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_HIGH);
 
-	return 0;
+	return (irq > 0) ? irq : 0;
 }
 
 static struct fwnode_handle *lpic_get_gsi_domain_id(u32 gsi)

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

end of thread, other threads:[~2024-07-26 19:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-23  6:45 [PATCH] irqchip/loongarch-cpu: Fix return value of lpic_gsi_to_irq() Huacai Chen
2024-07-23  6:46 ` Jiaxun Yang
2024-07-26 19:17 ` [tip: irq/urgent] " tip-bot2 for Huacai Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®