All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH for-5.19 v2 1/2] irqchip/loongson-liointc: Use architecture register to get coreid
@ 2022-06-09 17:52 Jiaxun Yang
  2022-06-09 17:52 ` [PATCH for-5.19 v2 2/2] loongarch: Mask out higher bits for cpuid and rename the function Jiaxun Yang
  2022-06-10  8:04 ` [irqchip: irq/irqchip-fixes] irqchip/loongson-liointc: Use architecture register to get coreid irqchip-bot for Jiaxun Yang
  0 siblings, 2 replies; 4+ messages in thread
From: Jiaxun Yang @ 2022-06-09 17:52 UTC (permalink / raw)
  To: chenhuacai; +Cc: kernel, maz, linux-kernel, Jiaxun Yang

fa84f89395e0 ("irqchip/loongson-liointc: Fix build error for
LoongArch") replaced get_ebase_cpunum with physical processor
id from SMP facilities. However that breaks MIPS non-SMP build
and makes booting from other cores inpossible on non-SMP kernel.

Thus we revert get_ebase_cpunum back and use get_csr_cpuid for
LoongArch.

Fixes: fa84f89395e0 ("irqchip/loongson-liointc: Fix build error for LoongArch")
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
 drivers/irqchip/irq-loongson-liointc.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/irqchip/irq-loongson-liointc.c b/drivers/irqchip/irq-loongson-liointc.c
index aed88857d90f..8d05d8bcf56f 100644
--- a/drivers/irqchip/irq-loongson-liointc.c
+++ b/drivers/irqchip/irq-loongson-liointc.c
@@ -39,6 +39,12 @@
 
 #define LIOINTC_ERRATA_IRQ	10
 
+#if defined(CONFIG_MIPS)
+#define liointc_core_id get_ebase_cpunum()
+#else
+#define liointc_core_id get_csr_cpuid()
+#endif
+
 struct liointc_handler_data {
 	struct liointc_priv	*priv;
 	u32			parent_int_map;
@@ -57,7 +63,7 @@ static void liointc_chained_handle_irq(struct irq_desc *desc)
 	struct liointc_handler_data *handler = irq_desc_get_handler_data(desc);
 	struct irq_chip *chip = irq_desc_get_chip(desc);
 	struct irq_chip_generic *gc = handler->priv->gc;
-	int core = cpu_logical_map(smp_processor_id()) % LIOINTC_NUM_CORES;
+	int core = liointc_core_id % LIOINTC_NUM_CORES;
 	u32 pending;
 
 	chained_irq_enter(chip, desc);
-- 
2.25.1


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

* [PATCH for-5.19 v2 2/2] loongarch: Mask out higher bits for cpuid and rename the function
  2022-06-09 17:52 [PATCH for-5.19 v2 1/2] irqchip/loongson-liointc: Use architecture register to get coreid Jiaxun Yang
@ 2022-06-09 17:52 ` Jiaxun Yang
  2022-06-10  8:02   ` Marc Zyngier
  2022-06-10  8:04 ` [irqchip: irq/irqchip-fixes] irqchip/loongson-liointc: Use architecture register to get coreid irqchip-bot for Jiaxun Yang
  1 sibling, 1 reply; 4+ messages in thread
From: Jiaxun Yang @ 2022-06-09 17:52 UTC (permalink / raw)
  To: chenhuacai; +Cc: kernel, maz, linux-kernel, Jiaxun Yang

Only low 9 bits of CPUID CSR represents coreid, higher bits
are marked as reserved. In case Loongson may define higher
bits in future, just mask them out for get_csr_cpuid.

Also, as we already have read_csr_cpuid, rename get_csr_cpuid
to get_csr_coreid to reflect the actual bit domain name.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
 arch/loongarch/include/asm/loongarch.h | 4 ++--
 drivers/irqchip/irq-loongson-liointc.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/loongarch/include/asm/loongarch.h b/arch/loongarch/include/asm/loongarch.h
index 3ba4f7e87cd2..fe2408144fa3 100644
--- a/arch/loongarch/include/asm/loongarch.h
+++ b/arch/loongarch/include/asm/loongarch.h
@@ -1198,9 +1198,9 @@ static inline u64 drdtime(void)
 	return val;
 }
 
-static inline unsigned int get_csr_cpuid(void)
+static inline unsigned int get_csr_coreid(void)
 {
-	return csr_read32(LOONGARCH_CSR_CPUID);
+	return csr_read32(LOONGARCH_CSR_CPUID) & CSR_CPUID_COREID;
 }
 
 static inline void csr_any_send(unsigned int addr, unsigned int data,
diff --git a/drivers/irqchip/irq-loongson-liointc.c b/drivers/irqchip/irq-loongson-liointc.c
index 8d05d8bcf56f..2ee636b2d827 100644
--- a/drivers/irqchip/irq-loongson-liointc.c
+++ b/drivers/irqchip/irq-loongson-liointc.c
@@ -42,7 +42,7 @@
 #if defined(CONFIG_MIPS)
 #define liointc_core_id get_ebase_cpunum()
 #else
-#define liointc_core_id get_csr_cpuid()
+#define liointc_core_id read_csr_cpuid()
 #endif
 
 struct liointc_handler_data {
-- 
2.25.1


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

* Re: [PATCH for-5.19 v2 2/2] loongarch: Mask out higher bits for cpuid and rename the function
  2022-06-09 17:52 ` [PATCH for-5.19 v2 2/2] loongarch: Mask out higher bits for cpuid and rename the function Jiaxun Yang
@ 2022-06-10  8:02   ` Marc Zyngier
  0 siblings, 0 replies; 4+ messages in thread
From: Marc Zyngier @ 2022-06-10  8:02 UTC (permalink / raw)
  To: Jiaxun Yang; +Cc: chenhuacai, kernel, linux-kernel

On Thu, 09 Jun 2022 18:52:42 +0100,
Jiaxun Yang <jiaxun.yang@flygoat.com> wrote:
> 
> Only low 9 bits of CPUID CSR represents coreid, higher bits
> are marked as reserved. In case Loongson may define higher
> bits in future, just mask them out for get_csr_cpuid.
> 
> Also, as we already have read_csr_cpuid, rename get_csr_cpuid
> to get_csr_coreid to reflect the actual bit domain name.

I assume you meant read_csr_cpuid here?

> 
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> ---
>  arch/loongarch/include/asm/loongarch.h | 4 ++--
>  drivers/irqchip/irq-loongson-liointc.c | 2 +-
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/loongarch/include/asm/loongarch.h b/arch/loongarch/include/asm/loongarch.h
> index 3ba4f7e87cd2..fe2408144fa3 100644
> --- a/arch/loongarch/include/asm/loongarch.h
> +++ b/arch/loongarch/include/asm/loongarch.h
> @@ -1198,9 +1198,9 @@ static inline u64 drdtime(void)
>  	return val;
>  }
>  
> -static inline unsigned int get_csr_cpuid(void)
> +static inline unsigned int get_csr_coreid(void)
>  {
> -	return csr_read32(LOONGARCH_CSR_CPUID);
> +	return csr_read32(LOONGARCH_CSR_CPUID) & CSR_CPUID_COREID;
>  }
>  
>  static inline void csr_any_send(unsigned int addr, unsigned int data,
> diff --git a/drivers/irqchip/irq-loongson-liointc.c b/drivers/irqchip/irq-loongson-liointc.c
> index 8d05d8bcf56f..2ee636b2d827 100644
> --- a/drivers/irqchip/irq-loongson-liointc.c
> +++ b/drivers/irqchip/irq-loongson-liointc.c
> @@ -42,7 +42,7 @@
>  #if defined(CONFIG_MIPS)
>  #define liointc_core_id get_ebase_cpunum()
>  #else
> -#define liointc_core_id get_csr_cpuid()
> +#define liointc_core_id read_csr_cpuid()
>  #endif
>  
>  struct liointc_handler_data {

I'm not going to take this patch as part of 5.19, as loongarch doesn't
have any irqchip support yet, and this can be made part of the IRQ
enabling series if really necessary.

	M.

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

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

* [irqchip: irq/irqchip-fixes] irqchip/loongson-liointc: Use architecture register to get coreid
  2022-06-09 17:52 [PATCH for-5.19 v2 1/2] irqchip/loongson-liointc: Use architecture register to get coreid Jiaxun Yang
  2022-06-09 17:52 ` [PATCH for-5.19 v2 2/2] loongarch: Mask out higher bits for cpuid and rename the function Jiaxun Yang
@ 2022-06-10  8:04 ` irqchip-bot for Jiaxun Yang
  1 sibling, 0 replies; 4+ messages in thread
From: irqchip-bot for Jiaxun Yang @ 2022-06-10  8:04 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jiaxun Yang, Marc Zyngier, tglx

The following commit has been merged into the irq/irqchip-fixes branch of irqchip:

Commit-ID:     6fac824f40987a54a08dfbcc36145869d02e45b1
Gitweb:        https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms/6fac824f40987a54a08dfbcc36145869d02e45b1
Author:        Jiaxun Yang <jiaxun.yang@flygoat.com>
AuthorDate:    Thu, 09 Jun 2022 18:52:41 +01:00
Committer:     Marc Zyngier <maz@kernel.org>
CommitterDate: Fri, 10 Jun 2022 08:57:19 +01:00

irqchip/loongson-liointc: Use architecture register to get coreid

fa84f89395e0 ("irqchip/loongson-liointc: Fix build error for
LoongArch") replaced get_ebase_cpunum with physical processor
id from SMP facilities. However that breaks MIPS non-SMP build
and makes booting from other cores inpossible on non-SMP kernel.

Thus we revert get_ebase_cpunum back and use get_csr_cpuid for
LoongArch.

Fixes: fa84f89395e0 ("irqchip/loongson-liointc: Fix build error for LoongArch")
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20220609175242.977-1-jiaxun.yang@flygoat.com
---
 drivers/irqchip/irq-loongson-liointc.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/irqchip/irq-loongson-liointc.c b/drivers/irqchip/irq-loongson-liointc.c
index aed8885..8d05d8b 100644
--- a/drivers/irqchip/irq-loongson-liointc.c
+++ b/drivers/irqchip/irq-loongson-liointc.c
@@ -39,6 +39,12 @@
 
 #define LIOINTC_ERRATA_IRQ	10
 
+#if defined(CONFIG_MIPS)
+#define liointc_core_id get_ebase_cpunum()
+#else
+#define liointc_core_id get_csr_cpuid()
+#endif
+
 struct liointc_handler_data {
 	struct liointc_priv	*priv;
 	u32			parent_int_map;
@@ -57,7 +63,7 @@ static void liointc_chained_handle_irq(struct irq_desc *desc)
 	struct liointc_handler_data *handler = irq_desc_get_handler_data(desc);
 	struct irq_chip *chip = irq_desc_get_chip(desc);
 	struct irq_chip_generic *gc = handler->priv->gc;
-	int core = cpu_logical_map(smp_processor_id()) % LIOINTC_NUM_CORES;
+	int core = liointc_core_id % LIOINTC_NUM_CORES;
 	u32 pending;
 
 	chained_irq_enter(chip, desc);

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

end of thread, other threads:[~2022-06-10  8:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-09 17:52 [PATCH for-5.19 v2 1/2] irqchip/loongson-liointc: Use architecture register to get coreid Jiaxun Yang
2022-06-09 17:52 ` [PATCH for-5.19 v2 2/2] loongarch: Mask out higher bits for cpuid and rename the function Jiaxun Yang
2022-06-10  8:02   ` Marc Zyngier
2022-06-10  8:04 ` [irqchip: irq/irqchip-fixes] irqchip/loongson-liointc: Use architecture register to get coreid irqchip-bot for Jiaxun Yang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.