linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v11 0/7] Loongarch-avec support
@ 2024-08-23 10:33 Tianyang Zhang
  2024-08-23 10:33 ` [PATCH v11 1/7] Docs/LoongArch: Add advanced extended IRQ model description Tianyang Zhang
  2024-08-23 10:33 ` [PATCH v11 2/7] LoongArch: Define ARCH_IRQ_INIT_FLAGS as IRQ_NOPROBE Tianyang Zhang
  0 siblings, 2 replies; 5+ messages in thread
From: Tianyang Zhang @ 2024-08-23 10:33 UTC (permalink / raw)
  To: corbet, alexs, chenhuacai, kernel, tglx, jiaxun.yang, gaoliang,
	wangliupu, lvjianmin, zhangtianyang, yijun, mhocko, akpm,
	dianders, maobibo, xry111, zhaotianrui, nathan, yangtiezhu,
	zhoubinbin
  Cc: loongarch, linux-doc, linux-kernel

This series of patches introduces support for advanced extended 
interrupt controllers (AVECINTC), and this hardware feature will 
be supported on 3C6000 for the first time

Changes log:
 V0->V1:
         1.Modified some formats and declarations
         2.Removed kmalloc/kfree when adding affinity related data to pending_list,
           and used moving tag to replace the original behavior
         3.Adjusted the process that enables AVEC interrupts, now it is at the end of all processes
         4.Removed CPUHP related callbacks, now irq_matrix_online/irq_matrix_offline is completed in start_secondary/loongson_cpu_disable
         5.Adjusted compatibility issues for CONFIG_ACPI
         6.About question:
         > irr = csr_read64(LOONGARCH_CSR_IRR0 + vector / 64);
         > should be good enough, no?
         csr_read64 was built-in as __csrrd_d, it doesn't seem to support variables as parameters
         >>>>
         drivers/irqchip/irq-loongarch-avec.c: In function ‘complete_irq_moving’:
         ./arch/loongarch/include/asm/loongarch.h:164:25: error: invalid argument to built-in function
           164 | #define csr_read64(reg) __csrrd_d(reg)
               |                         ^~~~~~~~~
         drivers/irqchip/irq-loongarch-avec.c:170:23: note: in expansion of macro ‘csr_read64’
           170 |                 irr = csr_read64(LOONGARCH_CSR_IRR_BASE + vector / VECTORS_PER_REG);
               |                       ^~~~~~~~~~
         >>>>
         So we have temporarily retained the previous implementation.
 
 V1->V2:
         Fixed up coding style. Made on/offline functions void
         Added compatibility when CONFIG_SMP is turned off
 
 V2->V3:
 	Squash two patches into one
 
 V3->V4:
 	Update NR_IRQS
 	Update Register's name
 	Fixed up coding style
 V4->V5:
	Retain feature CPUCFG1_MSGINT	
 	Fixed up coding style
	Delete the test code introduced by V4, and now msi msg address still uses the 32-bit address
 V5->V6:
	Fix definition of NR_IRQS
	Define arch_probe_nr_irqs()
	Handle all avecintc interrupts in one dispatch
	Use cpuhotplug callbacks instead of direct call to avec_online_cpu()/avec_offline_cpu()
	Rename {SMP,ACTION}_CLEAR_VECT to {SMP,ACTION}_CLEAR_VECTOR
	Use avecintc_ prefix instead of loongarch_avec_ to keep consistancy
 V6->V7:
	Fixed compatibility issue with cpuhp_setup_state_nocalls when CONFIG_SMP is turned off
	Rename avecintc_online/offline_cpu as avecintc_cpu_online/offline
	Use pch_msi_handle[0] as default value of get_pch_msi_handle
	Rework commit-message
 V7->V8:
	Fixed up coding style
	Support per-device-MSI domain
	Replaced spin_lock ops with guard/scope_guard
	Always execute irq_metrix_offline while the CPU is offline
 V8->V9:
	Fixed up coding style and potential bugs 
 V9->V10:
	Add a cover of series patch
 V10->V11:
	Separate the original patch into 7 small patches
	Correcting memory operations in critical areas
	Fixed up other coding style problem

Huacai Chen (5):
  Docs/LoongArch: Add advanced extended IRQ model description
  LoongArch: Define ARCH_IRQ_INIT_FLAGS as IRQ_NOPROBE
  LoongArch: Move irqchip function prototypes to irq-loongson.h
  LoongArch: Architectural preparation for AVEC irqchip
  irqchip/loongson-eiointc: Rename CPUHP_AP_IRQ_LOONGARCH_STARTING

Tianyang Zhang (2):
  irqchip/loongson-pch-msi: Prepare get_pch_msi_handle() for AVECINTC
  irqchip/loongarch-avec: Add AVEC irqchip support

 .../arch/loongarch/irq-chip-model.rst         |  32 ++
 .../zh_CN/arch/loongarch/irq-chip-model.rst   |  32 ++
 arch/loongarch/Kconfig                        |   1 +
 arch/loongarch/include/asm/cpu-features.h     |   1 +
 arch/loongarch/include/asm/cpu.h              |   2 +
 arch/loongarch/include/asm/hardirq.h          |   3 +-
 arch/loongarch/include/asm/hw_irq.h           |   2 +
 arch/loongarch/include/asm/irq.h              |  31 +-
 arch/loongarch/include/asm/loongarch.h        |  18 +-
 arch/loongarch/include/asm/smp.h              |   2 +
 arch/loongarch/kernel/cpu-probe.c             |   3 +-
 arch/loongarch/kernel/irq.c                   |  15 +-
 arch/loongarch/kernel/paravirt.c              |   5 +
 arch/loongarch/kernel/smp.c                   |   6 +
 drivers/irqchip/Makefile                      |   2 +-
 drivers/irqchip/irq-loongarch-avec.c          | 425 ++++++++++++++++++
 drivers/irqchip/irq-loongarch-cpu.c           |   7 +-
 drivers/irqchip/irq-loongson-eiointc.c        |   9 +-
 drivers/irqchip/irq-loongson-htvec.c          |   2 +
 drivers/irqchip/irq-loongson-liointc.c        |   2 +
 drivers/irqchip/irq-loongson-pch-lpc.c        |   2 +
 drivers/irqchip/irq-loongson-pch-msi.c        |  25 +-
 drivers/irqchip/irq-loongson-pch-pic.c        |   2 +
 drivers/irqchip/irq-loongson.h                |  27 ++
 include/linux/cpuhotplug.h                    |   3 +-
 25 files changed, 624 insertions(+), 35 deletions(-)
 create mode 100644 drivers/irqchip/irq-loongarch-avec.c
 create mode 100644 drivers/irqchip/irq-loongson.h

-- 
2.20.1


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

* [PATCH v11 1/7] Docs/LoongArch: Add advanced extended IRQ model description
  2024-08-23 10:33 [PATCH v11 0/7] Loongarch-avec support Tianyang Zhang
@ 2024-08-23 10:33 ` Tianyang Zhang
  2024-08-23 10:33 ` [PATCH v11 2/7] LoongArch: Define ARCH_IRQ_INIT_FLAGS as IRQ_NOPROBE Tianyang Zhang
  1 sibling, 0 replies; 5+ messages in thread
From: Tianyang Zhang @ 2024-08-23 10:33 UTC (permalink / raw)
  To: corbet, alexs, chenhuacai, kernel, tglx, jiaxun.yang, gaoliang,
	wangliupu, lvjianmin, zhangtianyang, yijun, mhocko, akpm,
	dianders, maobibo, xry111, zhaotianrui, nathan, yangtiezhu,
	zhoubinbin
  Cc: loongarch, linux-doc, linux-kernel, Huacai Chen

From: Huacai Chen <chenhuacai@loongson.cn>

Introduce the advanced extended interrupt controllers (AVECINTC). This
feature will allow each core to have 256 independent interrupt vectors
and MSI interrupts can be independently routed to any vector on any CPU.

The whole topology of irqchips in LoongArch machines looks like this if
AVECINTC is supported:

  +-----+     +-----------------------+     +-------+
  | IPI | --> |        CPUINTC        | <-- | Timer |
  +-----+     +-----------------------+     +-------+
               ^          ^          ^
               |          |          |
        +---------+ +----------+ +---------+     +-------+
        | EIOINTC | | AVECINTC | | LIOINTC | <-- | UARTs |
        +---------+ +----------+ +---------+     +-------+
             ^            ^
             |            |
        +---------+  +---------+
        | PCH-PIC |  | PCH-MSI |
        +---------+  +---------+
          ^     ^           ^
          |     |           |
  +---------+ +---------+ +---------+
  | Devices | | PCH-LPC | | Devices |
  +---------+ +---------+ +---------+
                   ^
                   |
              +---------+
              | Devices |
              +---------+

Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Tianyang Zhang <zhangtianyang@loongson.cn>
---
 .../arch/loongarch/irq-chip-model.rst         | 32 +++++++++++++++++++
 .../zh_CN/arch/loongarch/irq-chip-model.rst   | 32 +++++++++++++++++++
 2 files changed, 64 insertions(+)

diff --git a/Documentation/arch/loongarch/irq-chip-model.rst b/Documentation/arch/loongarch/irq-chip-model.rst
index 7988f4192363..6dd48256e39f 100644
--- a/Documentation/arch/loongarch/irq-chip-model.rst
+++ b/Documentation/arch/loongarch/irq-chip-model.rst
@@ -85,6 +85,38 @@ to CPUINTC directly::
     | Devices |
     +---------+
 
+Advanced Extended IRQ model
+===========================
+
+In this model, IPI (Inter-Processor Interrupt) and CPU Local Timer interrupt go
+to CPUINTC directly, CPU UARTS interrupts go to LIOINTC, PCH-MSI interrupts go
+to AVECINTC, and then go to CPUINTC directly, while all other devices interrupts
+go to PCH-PIC/PCH-LPC and gathered by EIOINTC, and then go to CPUINTC directly::
+
+ +-----+     +-----------------------+     +-------+
+ | IPI | --> |        CPUINTC        | <-- | Timer |
+ +-----+     +-----------------------+     +-------+
+              ^          ^          ^
+              |          |          |
+       +---------+ +----------+ +---------+     +-------+
+       | EIOINTC | | AVECINTC | | LIOINTC | <-- | UARTs |
+       +---------+ +----------+ +---------+     +-------+
+            ^            ^
+            |            |
+       +---------+  +---------+
+       | PCH-PIC |  | PCH-MSI |
+       +---------+  +---------+
+         ^     ^           ^
+         |     |           |
+ +---------+ +---------+ +---------+
+ | Devices | | PCH-LPC | | Devices |
+ +---------+ +---------+ +---------+
+                  ^
+                  |
+             +---------+
+             | Devices |
+             +---------+
+
 ACPI-related definitions
 ========================
 
diff --git a/Documentation/translations/zh_CN/arch/loongarch/irq-chip-model.rst b/Documentation/translations/zh_CN/arch/loongarch/irq-chip-model.rst
index f1e9ab18206c..472761938682 100644
--- a/Documentation/translations/zh_CN/arch/loongarch/irq-chip-model.rst
+++ b/Documentation/translations/zh_CN/arch/loongarch/irq-chip-model.rst
@@ -87,6 +87,38 @@ PCH-LPC/PCH-MSI,然后被EIOINTC统一收集,再直接到达CPUINTC::
     | Devices |
     +---------+
 
+高级扩展IRQ模型
+===============
+
+在这种模型里面,IPI(Inter-Processor Interrupt)和CPU本地时钟中断直接发送到CPUINTC,
+CPU串口(UARTs)中断发送到LIOINTC,PCH-MSI中断发送到AVECINTC,而后通过AVECINTC直接
+送达CPUINTC,而其他所有设备的中断则分别发送到所连接的PCH-PIC/PCH-LPC,然后由EIOINTC
+统一收集,再直接到达CPUINTC::
+
+ +-----+     +-----------------------+     +-------+
+ | IPI | --> |        CPUINTC        | <-- | Timer |
+ +-----+     +-----------------------+     +-------+
+              ^          ^          ^
+              |          |          |
+       +---------+ +----------+ +---------+     +-------+
+       | EIOINTC | | AVECINTC | | LIOINTC | <-- | UARTs |
+       +---------+ +----------+ +---------+     +-------+
+            ^            ^
+            |            |
+       +---------+  +---------+
+       | PCH-PIC |  | PCH-MSI |
+       +---------+  +---------+
+         ^     ^           ^
+         |     |           |
+ +---------+ +---------+ +---------+
+ | Devices | | PCH-LPC | | Devices |
+ +---------+ +---------+ +---------+
+                  ^
+                  |
+             +---------+
+             | Devices |
+             +---------+
+
 ACPI相关的定义
 ==============
 
-- 
2.20.1


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

* [PATCH v11 2/7] LoongArch: Define ARCH_IRQ_INIT_FLAGS as IRQ_NOPROBE
  2024-08-23 10:33 [PATCH v11 0/7] Loongarch-avec support Tianyang Zhang
  2024-08-23 10:33 ` [PATCH v11 1/7] Docs/LoongArch: Add advanced extended IRQ model description Tianyang Zhang
@ 2024-08-23 10:33 ` Tianyang Zhang
  2024-08-23 17:34   ` Thomas Gleixner
  1 sibling, 1 reply; 5+ messages in thread
From: Tianyang Zhang @ 2024-08-23 10:33 UTC (permalink / raw)
  To: corbet, alexs, chenhuacai, kernel, tglx, jiaxun.yang, gaoliang,
	wangliupu, lvjianmin, zhangtianyang, yijun, mhocko, akpm,
	dianders, maobibo, xry111, zhaotianrui, nathan, yangtiezhu,
	zhoubinbin
  Cc: loongarch, linux-doc, linux-kernel, Huacai Chen

From: Huacai Chen <chenhuacai@loongson.cn>

Currently we call irq_set_noprobe() in a loop for all IRQs, but indeed
it only works for IRQs below NR_IRQS_LEGACY because at init_IRQ() only
legacy interrupts have been allocated.

Instead, we can define ARCH_IRQ_INIT_FLAGS as IRQ_NOPROBE in asm/hwirq.h
and the core will automatically set the flag for all interrupts.

Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Tianyang Zhang <zhangtianyang@loongson.cn>
---
 arch/loongarch/include/asm/hw_irq.h | 2 ++
 arch/loongarch/kernel/irq.c         | 3 ---
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/loongarch/include/asm/hw_irq.h b/arch/loongarch/include/asm/hw_irq.h
index af4f4e8fbd85..8156ffb67415 100644
--- a/arch/loongarch/include/asm/hw_irq.h
+++ b/arch/loongarch/include/asm/hw_irq.h
@@ -9,6 +9,8 @@
 
 extern atomic_t irq_err_count;
 
+#define ARCH_IRQ_INIT_FLAGS	IRQ_NOPROBE
+
 /*
  * interrupt-retrigger: NOP for now. This may not be appropriate for all
  * machines, we'll see ...
diff --git a/arch/loongarch/kernel/irq.c b/arch/loongarch/kernel/irq.c
index f4991c03514f..adac8fcbb2ac 100644
--- a/arch/loongarch/kernel/irq.c
+++ b/arch/loongarch/kernel/irq.c
@@ -102,9 +102,6 @@ void __init init_IRQ(void)
 	mp_ops.init_ipi();
 #endif
 
-	for (i = 0; i < NR_IRQS; i++)
-		irq_set_noprobe(i);
-
 	for_each_possible_cpu(i) {
 		page = alloc_pages_node(cpu_to_node(i), GFP_KERNEL, order);
 
-- 
2.20.1


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

* [PATCH v11 2/7] LoongArch: Define ARCH_IRQ_INIT_FLAGS as IRQ_NOPROBE
  2024-08-23 10:35 [PATCH v11 0/7] Loongarch-avec support Tianyang Zhang
@ 2024-08-23 10:35 ` Tianyang Zhang
  0 siblings, 0 replies; 5+ messages in thread
From: Tianyang Zhang @ 2024-08-23 10:35 UTC (permalink / raw)
  To: corbet, alexs, chenhuacai, kernel, tglx, jiaxun.yang, gaoliang,
	wangliupu, lvjianmin, zhangtianyang, yijun, mhocko, akpm,
	dianders, maobibo, xry111, zhaotianrui, nathan, yangtiezhu,
	zhoubinbin
  Cc: loongarch, linux-doc, linux-kernel, Huacai Chen

From: Huacai Chen <chenhuacai@loongson.cn>

Currently we call irq_set_noprobe() in a loop for all IRQs, but indeed
it only works for IRQs below NR_IRQS_LEGACY because at init_IRQ() only
legacy interrupts have been allocated.

Instead, we can define ARCH_IRQ_INIT_FLAGS as IRQ_NOPROBE in asm/hwirq.h
and the core will automatically set the flag for all interrupts.

Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Tianyang Zhang <zhangtianyang@loongson.cn>
---
 arch/loongarch/include/asm/hw_irq.h | 2 ++
 arch/loongarch/kernel/irq.c         | 3 ---
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/loongarch/include/asm/hw_irq.h b/arch/loongarch/include/asm/hw_irq.h
index af4f4e8fbd85..8156ffb67415 100644
--- a/arch/loongarch/include/asm/hw_irq.h
+++ b/arch/loongarch/include/asm/hw_irq.h
@@ -9,6 +9,8 @@
 
 extern atomic_t irq_err_count;
 
+#define ARCH_IRQ_INIT_FLAGS	IRQ_NOPROBE
+
 /*
  * interrupt-retrigger: NOP for now. This may not be appropriate for all
  * machines, we'll see ...
diff --git a/arch/loongarch/kernel/irq.c b/arch/loongarch/kernel/irq.c
index f4991c03514f..adac8fcbb2ac 100644
--- a/arch/loongarch/kernel/irq.c
+++ b/arch/loongarch/kernel/irq.c
@@ -102,9 +102,6 @@ void __init init_IRQ(void)
 	mp_ops.init_ipi();
 #endif
 
-	for (i = 0; i < NR_IRQS; i++)
-		irq_set_noprobe(i);
-
 	for_each_possible_cpu(i) {
 		page = alloc_pages_node(cpu_to_node(i), GFP_KERNEL, order);
 
-- 
2.20.1


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

* Re: [PATCH v11 2/7] LoongArch: Define ARCH_IRQ_INIT_FLAGS as IRQ_NOPROBE
  2024-08-23 10:33 ` [PATCH v11 2/7] LoongArch: Define ARCH_IRQ_INIT_FLAGS as IRQ_NOPROBE Tianyang Zhang
@ 2024-08-23 17:34   ` Thomas Gleixner
  0 siblings, 0 replies; 5+ messages in thread
From: Thomas Gleixner @ 2024-08-23 17:34 UTC (permalink / raw)
  To: Tianyang Zhang, corbet, alexs, chenhuacai, kernel, jiaxun.yang,
	gaoliang, wangliupu, lvjianmin, zhangtianyang, yijun, mhocko,
	akpm, dianders, maobibo, xry111, zhaotianrui, nathan, yangtiezhu,
	zhoubinbin
  Cc: loongarch, linux-doc, linux-kernel, Huacai Chen

On Fri, Aug 23 2024 at 18:33, Tianyang Zhang wrote:
> From: Huacai Chen <chenhuacai@loongson.cn>
>
> Currently we call irq_set_noprobe() in a loop for all IRQs, but indeed
> it only works for IRQs below NR_IRQS_LEGACY because at init_IRQ() only
> legacy interrupts have been allocated.
>
> Instead, we can define ARCH_IRQ_INIT_FLAGS as IRQ_NOPROBE in asm/hwirq.h
> and the core will automatically set the flag for all interrupts.
>
> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
> Signed-off-by: Tianyang Zhang <zhangtianyang@loongson.cn>

Reviewed-by: Thomas Gleixner <tglx@linutronix.de>

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

end of thread, other threads:[~2024-08-23 17:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-23 10:33 [PATCH v11 0/7] Loongarch-avec support Tianyang Zhang
2024-08-23 10:33 ` [PATCH v11 1/7] Docs/LoongArch: Add advanced extended IRQ model description Tianyang Zhang
2024-08-23 10:33 ` [PATCH v11 2/7] LoongArch: Define ARCH_IRQ_INIT_FLAGS as IRQ_NOPROBE Tianyang Zhang
2024-08-23 17:34   ` Thomas Gleixner
  -- strict thread matches above, loose matches on Subject: below --
2024-08-23 10:35 [PATCH v11 0/7] Loongarch-avec support Tianyang Zhang
2024-08-23 10:35 ` [PATCH v11 2/7] LoongArch: Define ARCH_IRQ_INIT_FLAGS as IRQ_NOPROBE Tianyang Zhang

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