Skip to contentSkip to conversation

riscv: Make IPI_MAX visible and use it consistently

PATCH Applied Guo Ren 6 participants 15 messages Sep 11 – Nov 1

Subsystems (8)
lore
Share & tools
lore

Guo Ren

author
#0 lore raw

v2 cover riscv: Make IPI_MAX visible and use it consistently

This series removes the implicit assumption that RISC-V supports exactly eight IPI message types.

Currently, the SBI, CLINT and ACLINT SSWI IPI providers use BITS_PER_BYTE when sizing the generic IPI mux, while IMSIC carries a separate IMSIC_NR_IPI definition set to 8. These values happen to match IPI_MAX today, but neither is the proper source of truth for the number of RISC-V IPI message types.

Move enum ipi_message_type to asm/smp.h so IPI providers can use IPI_MAX directly, then replace the BITS_PER_BYTE and IMSIC_NR_IPI uses with IPI_MAX.

This also makes adding future RISC-V IPI message types independent of the current eight-entry assumption.

A follow-up patch renames the MediaTek VPU mailbox terminator from IPI_MAX to IPI_VPU_MAX. That token belongs to the VPU firmware IPI id enum and should follow the same prefixed convention as IPI_VPU_INIT (and SCP_IPI_MAX on the SCP side), instead of reusing the generic IPI_MAX name.

---
GUO Ren (XuanTie) (4):
clocksource: clint: Use IPI_MAX for IPI muxing irqchip/aclint-sswi: Use IPI_MAX for IPI muxing irqchip/imsic: Use IPI_MAX instead of IMSIC_NR_IPI
media: mtk-vpu: rename IPI_MAX to IPI_VPU_MAX

tip-bot2 for GUO Ren (XuanTie) (2):
riscv: smp: Move enum ipi_message_type to asm/smp.h
riscv: sbi: Use IPI_MAX for SBI IPI muxing

 arch/riscv/include/asm/smp.h                  | 12 ++++++++++++
 arch/riscv/kernel/sbi-ipi.c                   |  4 ++--
 arch/riscv/kernel/smp.c                       | 12 ------------
 drivers/clocksource/timer-clint.c             |  4 ++--
 drivers/irqchip/irq-aclint-sswi.c             |  4 ++--
 drivers/irqchip/irq-riscv-imsic-early.c       |  4 ++--
 drivers/irqchip/irq-riscv-imsic-state.h       |  1 -
 drivers/media/platform/mediatek/vpu/mtk_vpu.c | 12 ++++++------
 drivers/media/platform/mediatek/vpu/mtk_vpu.h |  4 ++--
 9 files changed, 28 insertions(+), 29 deletions(-)

---
base-commit: 08df884136f1c1197bab2a27814404fd329d9aac
change-id: 20260911-ipi_max-ff71eeadf6fd

Best regards,

Signature · 1 line
GUO Ren (XuanTie) <[email protected]>
author Applied
#1 lore raw

PATCH v2 1/6 riscv: smp: Move enum ipi_message_type to asm/smp.h

From: "tip-bot2 for GUO Ren (XuanTie)" <[email protected]>

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

Commit-ID:     1ae91dc397eb1dbc0f4fc6b96f2481cbc02fe0f9
Gitweb:        https://git.kernel.org/tip/1ae91dc397eb1dbc0f4fc6b96f2481cbc02fe0f9
Author:        GUO Ren (XuanTie) <[email protected]>
AuthorDate:    Sun, 16 Aug 2026 07:00:45
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Fri, 04 Sep 2026 15:34:34 +02:00

riscv: smp: Move enum ipi_message_type to asm/smp.h

The IPI message type enumeration (and therefore IPI_MAX) is currently private to arch/riscv/kernel/smp.c. Several IPI providers need to know the exact number of IPIs that the architecture requires, so move the enum into the public header.

This is a pure code movement with no functional change.

---
 arch/riscv/include/asm/smp.h | 12 ++++++++++++
 arch/riscv/kernel/smp.c      | 12 ------------
 2 files changed, 12 insertions(+), 12 deletions(-)
arch/riscv/include/asm/smp.h +12 -0
index 0ecc67641b09..bed39fff1f8a 100644
@@ -15,6 +15,18 @@
 struct seq_file;
 extern unsigned long boot_cpu_hartid;
 
+enum ipi_message_type {
+	IPI_RESCHEDULE,
+	IPI_CALL_FUNC,
+	IPI_CPU_STOP,
+	IPI_CPU_CRASH_STOP,
+	IPI_IRQ_WORK,
+	IPI_TIMER,
+	IPI_CPU_BACKTRACE,
+	IPI_KGDB_ROUNDUP,
+	IPI_MAX
+};
+
 #ifdef CONFIG_SMP
 
 #include <linux/jump_label.h>
arch/riscv/kernel/smp.c +0 -12
index fa66f9c97d74..8930b62b15e7 100644
@@ -28,18 +28,6 @@
 #include <asm/cacheflush.h>
 #include <asm/cpu_ops.h>
 
-enum ipi_message_type {
-	IPI_RESCHEDULE,
-	IPI_CALL_FUNC,
-	IPI_CPU_STOP,
-	IPI_CPU_CRASH_STOP,
-	IPI_IRQ_WORK,
-	IPI_TIMER,
-	IPI_CPU_BACKTRACE,
-	IPI_KGDB_ROUNDUP,
-	IPI_MAX
-};
-
 static const char * const ipi_names[] = {
 	[IPI_RESCHEDULE]	= "Rescheduling interrupts",
 	[IPI_CALL_FUNC]		= "Function call interrupts",
Signature · 1 line
2.43.0
author Applied
#2 lore raw

PATCH v2 2/6 riscv: sbi: Use IPI_MAX for SBI IPI muxing

In reply to Guo Ren

From: "tip-bot2 for GUO Ren (XuanTie)" <[email protected]>

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

Commit-ID:     2a0d49514f297baee259b19fb5553b538aa67d10
Gitweb:        https://git.kernel.org/tip/2a0d49514f297baee259b19fb5553b538aa67d10
Author:        GUO Ren (XuanTie) <[email protected]>
AuthorDate:    Sun, 16 Aug 2026 07:00:46
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Fri, 04 Sep 2026 15:34:34 +02:00

riscv: sbi: Use IPI_MAX for SBI IPI muxing

Now that IPI_MAX is visible from <asm/smp.h>, replace the hard-coded BITS_PER_BYTE with the proper symbolic constant in the SBI IPI extension driver.

No functional change; IPI_MAX is still 8.

---
 arch/riscv/kernel/sbi-ipi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/riscv/kernel/sbi-ipi.c +2 -2
index 0cc5559c08d8..eeec178a9b95 100644
@@ -57,7 +57,7 @@ void __init sbi_ipi_init(void)
 		return;
 	}
 
-	virq = ipi_mux_create(BITS_PER_BYTE, sbi_send_ipi);
+	virq = ipi_mux_create(IPI_MAX, sbi_send_ipi);
 	if (virq <= 0) {
 		pr_err("unable to create muxed IPIs\n");
 		irq_dispose_mapping(sbi_ipi_virq);
@@ -75,7 +75,7 @@ void __init sbi_ipi_init(void)
 			  "irqchip/sbi-ipi:starting",
 			  sbi_ipi_starting_cpu, NULL);
 
-	riscv_ipi_set_virq_range(virq, BITS_PER_BYTE);
+	riscv_ipi_set_virq_range(virq, IPI_MAX);
 	pr_info("providing IPIs using SBI IPI extension\n");
 
 	/*
Signature · 1 line
2.43.0
#3 lore raw

PATCH v2 3/6 clocksource: clint: Use IPI_MAX for IPI muxing

In reply to Guo Ren

Replace the hard-coded BITS_PER_BYTE with IPI_MAX now that the constant is exported from riscv asm/smp.h.

---
 drivers/clocksource/timer-clint.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clocksource/timer-clint.c +2 -2
index 0bdd9d7ec545..e56eee7e3781 100644
@@ -243,7 +243,7 @@ static int __init clint_timer_init_dt(struct device_node *np)
 	}
 
 #ifdef CONFIG_SMP
-	rc = ipi_mux_create(BITS_PER_BYTE, clint_send_ipi);
+	rc = ipi_mux_create(IPI_MAX, clint_send_ipi);
 	if (rc <= 0) {
 		pr_err("unable to create muxed IPIs\n");
 		rc = (rc < 0) ? rc : -ENODEV;
@@ -251,7 +251,7 @@ static int __init clint_timer_init_dt(struct device_node *np)
 	}
 
 	irq_set_chained_handler(clint_ipi_irq, clint_ipi_interrupt);
-	riscv_ipi_set_virq_range(rc, BITS_PER_BYTE);
+	riscv_ipi_set_virq_range(rc, IPI_MAX);
 	clint_clear_ipi();
 #endif
 
Signature · 1 line
2.43.0
#5 lore raw

PATCH v2 4/6 irqchip/aclint-sswi: Use IPI_MAX for IPI muxing

In reply to Guo Ren

Replace the hard-coded BITS_PER_BYTE with IPI_MAX now that the constant is exported from riscv asm/smp.h.

---
 drivers/irqchip/irq-aclint-sswi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/irqchip/irq-aclint-sswi.c +2 -2
index ca06efd86fa1..5e010fc401f7 100644
@@ -138,7 +138,7 @@ static int __init aclint_sswi_probe(struct fwnode_handle *fwnode)
 	}
 
 	/* Register SSWI irq and handler */
-	virq = ipi_mux_create(BITS_PER_BYTE, aclint_sswi_ipi_send);
+	virq = ipi_mux_create(IPI_MAX, aclint_sswi_ipi_send);
 	if (virq <= 0) {
 		pr_err("unable to create muxed IPIs\n");
 		irq_dispose_mapping(sswi_ipi_virq);
@@ -152,7 +152,7 @@ static int __init aclint_sswi_probe(struct fwnode_handle *fwnode)
 			  aclint_sswi_starting_cpu,
 			  aclint_sswi_dying_cpu);
 
-	riscv_ipi_set_virq_range(virq, BITS_PER_BYTE);
+	riscv_ipi_set_virq_range(virq, IPI_MAX);
 
 	return 0;
 }
Signature · 1 line
2.43.0
#6 lore raw

PATCH v2 5/6 irqchip/imsic: Use IPI_MAX instead of IMSIC_NR_IPI

In reply to Guo Ren

IMSIC was defining its own IMSIC_NR_IPI (= 8) which happened to match the architecture's IPI_MAX. Now that IPI_MAX is exported from riscv asm/smp.h, use the architecture constant and drop the private define.

This keeps the number of multiplexed IPIs in sync with the rest of the RISC-V IPI infrastructure.

---
 drivers/irqchip/irq-riscv-imsic-early.c | 4 ++--
 drivers/irqchip/irq-riscv-imsic-state.h | 1 -
 2 files changed, 2 insertions(+), 3 deletions(-)
drivers/irqchip/irq-riscv-imsic-early.c +2 -2
index 12efd241ce88..823f5f2ecb3d 100644
@@ -67,12 +67,12 @@ static int __init imsic_ipi_domain_init(void)
 		return 0;
 
 	/* Create IMSIC IPI multiplexing */
-	virq = ipi_mux_create(IMSIC_NR_IPI, imsic_ipi_send);
+	virq = ipi_mux_create(IPI_MAX, imsic_ipi_send);
 	if (virq <= 0)
 		return virq < 0 ? virq : -ENOMEM;
 
 	/* Set vIRQ range */
-	riscv_ipi_set_virq_range(virq, IMSIC_NR_IPI);
+	riscv_ipi_set_virq_range(virq, IPI_MAX);
 
 	/* Announce that IMSIC is providing IPIs */
 	pr_info("%pfwP: providing IPIs using interrupt %d\n", imsic->fwnode, IMSIC_IPI_ID);
drivers/irqchip/irq-riscv-imsic-state.h +0 -1
index c42ee180b305..878cc192ccec 100644
@@ -13,7 +13,6 @@
 #include <linux/timer.h>
 
 #define IMSIC_IPI_ID				1
-#define IMSIC_NR_IPI				8
 
 struct imsic_vector {
 	/* Fixed details of the vector */
Signature · 1 line
2.43.0
#7 lore raw

PATCH v2 6/6 media: mtk-vpu: rename IPI_MAX to IPI_VPU_MAX

In reply to Guo Ren

The last enumerator of this driver's firmware IPI id list is a bound for the VPU mailbox protocol, not a generic host IPI limit. Follow the existing naming in this header: IPI_VPU_INIT already carries a VPU prefix, so the terminator should match.

The same convention is used by the SCP IPI enum, which ends with a prefixed SCP_IPI_MAX rather than a bare IPI_MAX.

Rename IPI_MAX to IPI_VPU_MAX and update the descriptor table bounds and range checks. No functional change.

---
 drivers/media/platform/mediatek/vpu/mtk_vpu.c | 12 ++++++------
 drivers/media/platform/mediatek/vpu/mtk_vpu.h |  4 ++--
 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/media/platform/mediatek/vpu/mtk_vpu.c +6 -6
index 8d8319f0cd22..b3e9f8c4ab7a 100644
@@ -211,7 +211,7 @@ struct mtk_vpu {
 	struct vpu_regs reg;
 	struct vpu_run run;
 	struct vpu_wdt wdt;
-	struct vpu_ipi_desc ipi_desc[IPI_MAX];
+	struct vpu_ipi_desc ipi_desc[IPI_VPU_MAX];
 	struct share_obj __iomem *recv_buf;
 	struct share_obj __iomem *send_buf;
 	struct device *dev;
@@ -221,7 +221,7 @@ struct mtk_vpu {
 	struct mutex vpu_mutex; /* for protecting vpu data data structure */
 	u32 wdt_refcnt;
 	wait_queue_head_t ack_wq;
-	bool ipi_id_ack[IPI_MAX];
+	bool ipi_id_ack[IPI_VPU_MAX];
 };
 
 static inline void vpu_cfg_writel(struct mtk_vpu *vpu, u32 val, u32 offset)
@@ -296,7 +296,7 @@ int vpu_ipi_register(struct platform_device *pdev,
 		return -EPROBE_DEFER;
 	}
 
-	if (id < IPI_MAX && handler) {
+	if (id < IPI_VPU_MAX && handler) {
 		ipi_desc = vpu->ipi_desc;
 		ipi_desc[id].name = name;
 		ipi_desc[id].handler = handler;
@@ -319,7 +319,7 @@ int vpu_ipi_send(struct platform_device *pdev,
 	unsigned long timeout;
 	int ret = 0;
 
-	if (id <= IPI_VPU_INIT || id >= IPI_MAX ||
+	if (id <= IPI_VPU_INIT || id >= IPI_VPU_MAX ||
 	    len > sizeof(send_obj->share_buf) || !buf) {
 		dev_err(vpu->dev, "failed to send ipi message\n");
 		return -EINVAL;
@@ -748,7 +748,7 @@ static void vpu_ipi_handler(struct mtk_vpu *vpu)
 	s32 id = readl(&rcv_obj->id);
 
 	memcpy_fromio(data, rcv_obj->share_buf, sizeof(data));
-	if (id < IPI_MAX && ipi_desc[id].handler) {
+	if (id < IPI_VPU_MAX && ipi_desc[id].handler) {
 		ipi_desc[id].handler(data, readl(&rcv_obj->len),
 				     ipi_desc[id].priv);
 		if (id > IPI_VPU_INIT) {
@@ -934,7 +934,7 @@ static int mtk_vpu_probe(struct platform_device *pdev)
 #ifdef CONFIG_DEBUG_FS
 	debugfs_remove(vpu_debugfs);
 #endif
-	memset(vpu->ipi_desc, 0, sizeof(struct vpu_ipi_desc) * IPI_MAX);
+	memset(vpu->ipi_desc, 0, sizeof(struct vpu_ipi_desc) * IPI_VPU_MAX);
 vpu_mutex_destroy:
 	mutex_destroy(&vpu->vpu_mutex);
 disable_vpu_clk:
drivers/media/platform/mediatek/vpu/mtk_vpu.h +2 -2
index 3951547e9ec5..44ab631ec904 100644
@@ -49,7 +49,7 @@ typedef void (*ipi_handler_t) (void *data,
  *			 handle VP8 video encoder job,, and vice versa.
  * @IPI_MDP:		 The interrupt from vpu is to notify kernel to
  *			 handle MDP (Media Data Path) job, and vice versa.
- * @IPI_MAX:		 The maximum IPI number
+ * @IPI_VPU_MAX:	 The maximum VPU IPI number
  */
 
 enum ipi_id {
@@ -60,7 +60,7 @@ enum ipi_id {
 	IPI_VENC_H264,
 	IPI_VENC_VP8,
 	IPI_MDP,
-	IPI_MAX,
+	IPI_VPU_MAX,
 };
 
 /**
Signature · 1 line
2.43.0
reviewer Reviewed-by on v2 6/6
#8 lore raw

Re: [PATCH v2 6/6] media: mtk-vpu: rename IPI_MAX to IPI_VPU_MAX

Quoted 97 lines · GUO Ren (XuanTie)

The last enumerator of this driver's firmware IPI id list is a bound for the VPU mailbox protocol, not a generic host IPI limit. Follow the existing naming in this header: IPI_VPU_INIT already carries a VPU prefix, so the terminator should match.

The same convention is used by the SCP IPI enum, which ends with a prefixed SCP_IPI_MAX rather than a bare IPI_MAX.

Rename IPI_MAX to IPI_VPU_MAX and update the descriptor table bounds and range checks. No functional change.

---
 drivers/media/platform/mediatek/vpu/mtk_vpu.c | 12 ++++++------ drivers/media/platform/mediatek/vpu/mtk_vpu.h |  4 ++--

 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/media/platform/mediatek/vpu/mtk_vpu.c +1 -1
index 8d8319f0cd22..b3e9f8c4ab7a 100644
@@ -211,7 +211,7 @@ struct mtk_vpu {
  	struct vpu_regs reg;
  	struct vpu_run run;
  	struct vpu_wdt wdt;
-	struct vpu_ipi_desc ipi_desc[IPI_MAX];
+	struct vpu_ipi_desc ipi_desc[IPI_VPU_MAX];
  	struct share_obj __iomem *recv_buf;
  	struct share_obj __iomem *send_buf;
  	struct device *dev;
@@ -221,7 +221,7 @@ struct mtk_vpu {

  struct mutex vpu_mutex; /* for protecting vpu data data structure */ u32 wdt_refcnt;
  wait_queue_head_t ack_wq;

drivers/media/platform/mediatek/vpu/mtk_vpu.c +1 -1
-	bool ipi_id_ack[IPI_MAX];
+	bool ipi_id_ack[IPI_VPU_MAX];

 };

 static inline void vpu_cfg_writel(struct mtk_vpu *vpu, u32 val, u32 offset)

drivers/media/platform/mediatek/vpu/mtk_vpu.c +0 -0
@@ -296,7 +296,7 @@ int vpu_ipi_register(struct platform_device *pdev,
  		return -EPROBE_DEFER;
  	}

drivers/media/platform/mediatek/vpu/mtk_vpu.c +1 -1
-	if (id < IPI_MAX && handler) {
+	if (id < IPI_VPU_MAX && handler) {

  ipi_desc = vpu->ipi_desc;
  ipi_desc[id].name = name;
  ipi_desc[id].handler = handler;

drivers/media/platform/mediatek/vpu/mtk_vpu.c +0 -0
@@ -319,7 +319,7 @@ int vpu_ipi_send(struct platform_device *pdev,
  	unsigned long timeout;
  	int ret = 0;

drivers/media/platform/mediatek/vpu/mtk_vpu.c +1 -1
-	if (id <= IPI_VPU_INIT || id >= IPI_MAX ||
+	if (id <= IPI_VPU_INIT || id >= IPI_VPU_MAX ||

      len > sizeof(send_obj->share_buf) || !buf) { dev_err(vpu->dev, "failed to send ipi message\n"); return -EINVAL;

drivers/media/platform/mediatek/vpu/mtk_vpu.c +0 -0
@@ -748,7 +748,7 @@ static void vpu_ipi_handler(struct mtk_vpu *vpu)
  	s32 id = readl(&rcv_obj->id);


  memcpy_fromio(data, rcv_obj->share_buf, sizeof(data));

drivers/media/platform/mediatek/vpu/mtk_vpu.c +1 -1
-	if (id < IPI_MAX && ipi_desc[id].handler) {
+	if (id < IPI_VPU_MAX && ipi_desc[id].handler) {

  ipi_desc[id].handler(data, readl(&rcv_obj->len), ipi_desc[id].priv); if (id > IPI_VPU_INIT) {

drivers/media/platform/mediatek/vpu/mtk_vpu.c +1 -1
@@ -934,7 +934,7 @@ static int mtk_vpu_probe(struct platform_device *pdev)
  #ifdef CONFIG_DEBUG_FS
  	debugfs_remove(vpu_debugfs);
  #endif
-	memset(vpu->ipi_desc, 0, sizeof(struct vpu_ipi_desc) * IPI_MAX);
+	memset(vpu->ipi_desc, 0, sizeof(struct vpu_ipi_desc) * IPI_VPU_MAX);

 vpu_mutex_destroy:
  mutex_destroy(&vpu->vpu_mutex);
 disable_vpu_clk:

drivers/media/platform/mediatek/vpu/mtk_vpu.h +1 -1
index 3951547e9ec5..44ab631ec904 100644
@@ -49,7 +49,7 @@ typedef void (*ipi_handler_t) (void *data,
   *			 handle VP8 video encoder job,, and vice versa.
   * @IPI_MDP:		 The interrupt from vpu is to notify kernel to
   *			 handle MDP (Media Data Path) job, and vice versa.
- * @IPI_MAX:		 The maximum IPI number
+ * @IPI_VPU_MAX:	 The maximum VPU IPI number
   */


 enum ipi_id {

drivers/media/platform/mediatek/vpu/mtk_vpu.h +1 -1
@@ -60,7 +60,7 @@ enum ipi_id {
  	IPI_VENC_H264,
  	IPI_VENC_VP8,
  	IPI_MDP,
-	IPI_MAX,
+	IPI_VPU_MAX,
  };
Quoted 2 lines


 /**

#9 lore raw

Re: [PATCH v2 6/6] media: mtk-vpu: rename IPI_MAX to IPI_VPU_MAX

Le jeudi 17 septembre 2026 à 21:21 -0400, Radu Rendec a écrit :

Quoted 9 lines · GUO Ren (XuanTie)
Quoted 8 lines

The last enumerator of this driver's firmware IPI id list is a bound for the VPU mailbox protocol, not a generic host IPI limit. Follow the existing naming in this header: IPI_VPU_INIT already carries a VPU prefix, so the terminator should match.

The same convention is used by the SCP IPI enum, which ends with a prefixed SCP_IPI_MAX rather than a bare IPI_MAX.

Quoted 6 lines
Quoted 6 lines

Rename IPI_MAX to IPI_VPU_MAX and update the descriptor table bounds and range checks. No functional change.

Applied, ty.

Quoted 87 lines
Quoted 83 lines

---
 drivers/media/platform/mediatek/vpu/mtk_vpu.c | 12 ++++++------ drivers/media/platform/mediatek/vpu/mtk_vpu.h |  4 ++--

 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/media/platform/mediatek/vpu/mtk_vpu.c +1 -1
index 8d8319f0cd22..b3e9f8c4ab7a 100644
@@ -211,7 +211,7 @@ struct mtk_vpu {
  	struct vpu_regs reg;
  	struct vpu_run run;
  	struct vpu_wdt wdt;
-	struct vpu_ipi_desc ipi_desc[IPI_MAX];
+	struct vpu_ipi_desc ipi_desc[IPI_VPU_MAX];
  	struct share_obj __iomem *recv_buf;
  	struct share_obj __iomem *send_buf;
  	struct device *dev;
@@ -221,7 +221,7 @@ struct mtk_vpu {

  struct mutex vpu_mutex; /* for protecting vpu data data structure */ u32 wdt_refcnt;
  wait_queue_head_t ack_wq;

drivers/media/platform/mediatek/vpu/mtk_vpu.c +1 -1
-	bool ipi_id_ack[IPI_MAX];
+	bool ipi_id_ack[IPI_VPU_MAX];

 };

 static inline void vpu_cfg_writel(struct mtk_vpu *vpu, u32 val, u32 offset)

drivers/media/platform/mediatek/vpu/mtk_vpu.c +0 -0
@@ -296,7 +296,7 @@ int vpu_ipi_register(struct platform_device *pdev,
  		return -EPROBE_DEFER;
  	}

drivers/media/platform/mediatek/vpu/mtk_vpu.c +1 -1
-	if (id < IPI_MAX && handler) {
+	if (id < IPI_VPU_MAX && handler) {

  ipi_desc = vpu->ipi_desc;
  ipi_desc[id].name = name;
  ipi_desc[id].handler = handler;

drivers/media/platform/mediatek/vpu/mtk_vpu.c +0 -0
@@ -319,7 +319,7 @@ int vpu_ipi_send(struct platform_device *pdev,
  	unsigned long timeout;
  	int ret = 0;

drivers/media/platform/mediatek/vpu/mtk_vpu.c +1 -1
-	if (id <= IPI_VPU_INIT || id >= IPI_MAX ||
+	if (id <= IPI_VPU_INIT || id >= IPI_VPU_MAX ||

      len > sizeof(send_obj->share_buf) || !buf) { dev_err(vpu->dev, "failed to send ipi message\n"); return -EINVAL;

drivers/media/platform/mediatek/vpu/mtk_vpu.c +0 -0
@@ -748,7 +748,7 @@ static void vpu_ipi_handler(struct mtk_vpu *vpu)
  	s32 id = readl(&rcv_obj->id);


  memcpy_fromio(data, rcv_obj->share_buf, sizeof(data));

drivers/media/platform/mediatek/vpu/mtk_vpu.c +1 -1
-	if (id < IPI_MAX && ipi_desc[id].handler) {
+	if (id < IPI_VPU_MAX && ipi_desc[id].handler) {

  ipi_desc[id].handler(data, readl(&rcv_obj->len), ipi_desc[id].priv); if (id > IPI_VPU_INIT) {

drivers/media/platform/mediatek/vpu/mtk_vpu.c +1 -1
@@ -934,7 +934,7 @@ static int mtk_vpu_probe(struct platform_device *pdev)
  #ifdef CONFIG_DEBUG_FS
  	debugfs_remove(vpu_debugfs);
  #endif
-	memset(vpu->ipi_desc, 0, sizeof(struct vpu_ipi_desc) * IPI_MAX);
+	memset(vpu->ipi_desc, 0, sizeof(struct vpu_ipi_desc) * IPI_VPU_MAX);

 vpu_mutex_destroy:
  mutex_destroy(&vpu->vpu_mutex);
 disable_vpu_clk:

drivers/media/platform/mediatek/vpu/mtk_vpu.h +1 -1
index 3951547e9ec5..44ab631ec904 100644
@@ -49,7 +49,7 @@ typedef void (*ipi_handler_t) (void *data,
   *			 handle VP8 video encoder job,, and vice versa.
   * @IPI_MDP:		 The interrupt from vpu is to notify kernel to
   *			 handle MDP (Media Data Path) job, and vice versa.
- * @IPI_MAX:		 The maximum IPI number
+ * @IPI_VPU_MAX:	 The maximum VPU IPI number
   */


 enum ipi_id {

drivers/media/platform/mediatek/vpu/mtk_vpu.h +1 -1
@@ -60,7 +60,7 @@ enum ipi_id {
  	IPI_VENC_H264,
  	IPI_VENC_VP8,
  	IPI_MDP,
-	IPI_MAX,
+	IPI_VPU_MAX,
  };
Quoted 2 lines


 /**

reviewer
#10 lore raw
In reply to Guo Ren
Quoted 29 lines · Guo Ren

This series removes the implicit assumption that RISC-V supports exactly eight IPI message types.

Currently, the SBI, CLINT and ACLINT SSWI IPI providers use BITS_PER_BYTE when sizing the generic IPI mux, while IMSIC carries a separate IMSIC_NR_IPI definition set to 8. These values happen to match IPI_MAX today, but neither is the proper source of truth for the number of RISC-V IPI message types.

Move enum ipi_message_type to asm/smp.h so IPI providers can use IPI_MAX directly, then replace the BITS_PER_BYTE and IMSIC_NR_IPI uses with IPI_MAX.

This also makes adding future RISC-V IPI message types independent of the current eight-entry assumption.

A follow-up patch renames the MediaTek VPU mailbox terminator from IPI_MAX to IPI_VPU_MAX. That token belongs to the VPU firmware IPI id enum and should follow the same prefixed convention as IPI_VPU_INIT (and SCP_IPI_MAX on the SCP side), instead of reusing the generic IPI_MAX name.

---
GUO Ren (XuanTie) (4):
      clocksource: clint: Use IPI_MAX for IPI muxing irqchip/aclint-sswi: Use IPI_MAX for IPI muxing irqchip/imsic: Use IPI_MAX instead of IMSIC_NR_IPI
      media: mtk-vpu: rename IPI_MAX to IPI_VPU_MAX

Quoted 3 lines

tip-bot2 for GUO Ren (XuanTie) (2):
      riscv: smp: Move enum ipi_message_type to asm/smp.h
      riscv: sbi: Use IPI_MAX for SBI IPI muxing

I am confused. Thomas merged your entire v1 series a week before (see the individual replies from [email protected]). Why are you sending v2?

Patch 6 was not included in v1 (but it's clearly related), so perhaps you meant to send only this one as a separate patch?

Also:
* The cover letter should include a changelog, indicating what changes were made in each version compared to the previous one.
* Patches 1 and 2 carry a "From:" tag that attributes authorship to tip-bot2, which is wrong (if these patches were to be applied).

Quoted 18 lines

 arch/riscv/include/asm/smp.h                  | 12 ++++++++++++ arch/riscv/kernel/sbi-ipi.c                   |  4 ++-- arch/riscv/kernel/smp.c                       | 12 ------------ drivers/clocksource/timer-clint.c             |  4 ++-- drivers/irqchip/irq-aclint-sswi.c             |  4 ++-- drivers/irqchip/irq-riscv-imsic-early.c       |  4 ++-- drivers/irqchip/irq-riscv-imsic-state.h       |  1 - drivers/media/platform/mediatek/vpu/mtk_vpu.c | 12 ++++++------ drivers/media/platform/mediatek/vpu/mtk_vpu.h |  4 ++--

 9 files changed, 28 insertions(+), 29 deletions(-)

---
base-commit: 08df884136f1c1197bab2a27814404fd329d9aac
change-id: 20260911-ipi_max-ff71eeadf6fd

Best regards,
--
GUO Ren (XuanTie) <[email protected]>

author
#11 lore raw
Quoted 39 lines · Radu Rendec
Quoted 29 lines · Guo Ren

This series removes the implicit assumption that RISC-V supports exactly eight IPI message types.

Currently, the SBI, CLINT and ACLINT SSWI IPI providers use BITS_PER_BYTE when sizing the generic IPI mux, while IMSIC carries a separate IMSIC_NR_IPI definition set to 8. These values happen to match IPI_MAX today, but neither is the proper source of truth for the number of RISC-V IPI message types.

Move enum ipi_message_type to asm/smp.h so IPI providers can use IPI_MAX directly, then replace the BITS_PER_BYTE and IMSIC_NR_IPI uses with IPI_MAX.

This also makes adding future RISC-V IPI message types independent of the current eight-entry assumption.

A follow-up patch renames the MediaTek VPU mailbox terminator from IPI_MAX to IPI_VPU_MAX. That token belongs to the VPU firmware IPI id enum and should follow the same prefixed convention as IPI_VPU_INIT (and SCP_IPI_MAX on the SCP side), instead of reusing the generic IPI_MAX name.

---
GUO Ren (XuanTie) (4):
clocksource: clint: Use IPI_MAX for IPI muxing irqchip/aclint-sswi: Use IPI_MAX for IPI muxing irqchip/imsic: Use IPI_MAX instead of IMSIC_NR_IPI
media: mtk-vpu: rename IPI_MAX to IPI_VPU_MAX

Quoted 3 lines

tip-bot2 for GUO Ren (XuanTie) (2):
riscv: smp: Move enum ipi_message_type to asm/smp.h
riscv: sbi: Use IPI_MAX for SBI IPI muxing

I am confused. Thomas merged your entire v1 series a week before (see the individual replies from [email protected]). Why are you sending v2?

Quoted 8 lines

Patch 6 was not included in v1 (but it's clearly related), so perhaps you meant to send only this one as a separate patch?

Also:
* The cover letter should include a changelog, indicating what changes were made in each version compared to the previous one.
* Patches 1 and 2 carry a "From:" tag that attributes authorship to tip-bot2, which is wrong (if these patches were to be applied).

Sorry for the noise, and thanks for catching these.

You are right on both points. I missed the cover-letter changelog, and I should not have resent the already-merged patches as v2. The "From: tip-bot2" tags were added by b4 because those two patches had already landed; that is useful as a reminder to me, but it should not have been left in the patches themselves.

I should have skipped the b4 v2 flow and just sent patch 6 on its own. The only remaining change is the mtk-vpu IPI_MAX rename, which is needed after IPI_MAX became visible from <asm/smp.h>.

If you are willing to pick patch 6 as-is, I would appreciate it. Otherwise I will resend it as a standalone patch.

Signature · 2 lines
Best Regards
 Guo Ren
reviewer
#12 lore raw
Quoted 43 lines · Guo Ren
Quoted 42 lines · Radu Rendec
Quoted 29 lines · Guo Ren

This series removes the implicit assumption that RISC-V supports exactly eight IPI message types.

Currently, the SBI, CLINT and ACLINT SSWI IPI providers use BITS_PER_BYTE when sizing the generic IPI mux, while IMSIC carries a separate IMSIC_NR_IPI definition set to 8. These values happen to match IPI_MAX today, but neither is the proper source of truth for the number of RISC-V IPI message types.

Move enum ipi_message_type to asm/smp.h so IPI providers can use IPI_MAX directly, then replace the BITS_PER_BYTE and IMSIC_NR_IPI uses with IPI_MAX.

This also makes adding future RISC-V IPI message types independent of the current eight-entry assumption.

A follow-up patch renames the MediaTek VPU mailbox terminator from IPI_MAX to IPI_VPU_MAX. That token belongs to the VPU firmware IPI id enum and should follow the same prefixed convention as IPI_VPU_INIT (and SCP_IPI_MAX on the SCP side), instead of reusing the generic IPI_MAX name.

---
GUO Ren (XuanTie) (4):
      clocksource: clint: Use IPI_MAX for IPI muxing irqchip/aclint-sswi: Use IPI_MAX for IPI muxing irqchip/imsic: Use IPI_MAX instead of IMSIC_NR_IPI
      media: mtk-vpu: rename IPI_MAX to IPI_VPU_MAX

Quoted 3 lines

tip-bot2 for GUO Ren (XuanTie) (2):
      riscv: smp: Move enum ipi_message_type to asm/smp.h
      riscv: sbi: Use IPI_MAX for SBI IPI muxing

I am confused. Thomas merged your entire v1 series a week before (see the individual replies from [email protected]). Why are you sending v2?

Patch 6 was not included in v1 (but it's clearly related), so perhaps you meant to send only this one as a separate patch?

Quoted 7 lines
Quoted 5 lines

Also:
 * The cover letter should include a changelog, indicating what changes were made in each version compared to the previous one.
 * Patches 1 and 2 carry a "From:" tag that attributes authorship to tip-bot2, which is wrong (if these patches were to be applied).

Sorry for the noise, and thanks for catching these.

No worries :)

Quoted 9 lines

You are right on both points. I missed the cover-letter changelog, and I should not have resent the already-merged patches as v2. The "From: tip-bot2" tags were added by b4 because those two patches had already landed; that is useful as a reminder to me, but it should not have been left in the patches themselves.

I should have skipped the b4 v2 flow and just sent patch 6 on its own. The only remaining change is the mtk-vpu IPI_MAX rename, which is needed after IPI_MAX became visible from <asm/smp.h>.

Ugh, I missed that part. Because the IPI_MAX rename was already picked up, it's going to break the mtk-vpu driver until patch 6 is picked up too.

Quoted 2 lines

If you are willing to pick patch 6 as-is, I would appreciate it. Otherwise I will resend it as a standalone patch.

I cannot pick up anything myself because I'm just a reviewer. But I don't see any reason why patch 6 couldn't be picked up as-is, as long as everyone is on the same page. The "[PATCH v2 6/6]" part of the subject is dropped anyway.

I now realize that patch 1 (which introduces the conflicting change) was picked up by Thomas via the irq/drivers tip branch, but patch 6 is strictly a media subsystem patch, so I guess normally it should be picked up by a different maintainer via a different tree.

Thomas, are you willing to pick this up too? I'm thinking it could avoid some pain if irq/drivers gets merged into mainline first, before patch 6 makes it there through the media subsystem. Also, it's a pretty "innocent" patch, it just renames an enum value, and it's contained within that driver.

Signature · 2 lines
Best regards,
Radu
maintainer
#13 lore raw
Quoted 10 lines · Radu Rendec

I now realize that patch 1 (which introduces the conflicting change) was picked up by Thomas via the irq/drivers tip branch, but patch 6 is strictly a media subsystem patch, so I guess normally it should be picked up by a different maintainer via a different tree.

Thomas, are you willing to pick this up too? I'm thinking it could avoid some pain if irq/drivers gets merged into mainline first, before patch 6 makes it there through the media subsystem. Also, it's a pretty "innocent" patch, it just renames an enum value, and it's contained within that driver.

The media folks picked it up already.

#14 lore raw
In reply to Guo Ren
This series was applied to riscv/linux.git (fixes) by Hans Verkuil <[email protected]>:

Hello:

This series was applied to riscv/linux.git (fixes) by Hans Verkuil <[email protected]>:

Quoted 10 lines · On Fri, 11 Sep 2026 03:27:08 +0000 you wrote:

This series removes the implicit assumption that RISC-V supports exactly eight IPI message types.

Currently, the SBI, CLINT and ACLINT SSWI IPI providers use BITS_PER_BYTE when sizing the generic IPI mux, while IMSIC carries a separate IMSIC_NR_IPI definition set to 8. These values happen to match IPI_MAX today, but neither is the proper source of truth for the number of RISC-V IPI message types.

[...]

Here is the summary with links:
- [v2,1/6] riscv: smp: Move enum ipi_message_type to asm/smp.h

    https://git.kernel.org/riscv/c/1ae91dc397eb
  - [v2,2/6] riscv: sbi: Use IPI_MAX for SBI IPI muxing
    https://git.kernel.org/riscv/c/2a0d49514f29
  - [v2,3/6] clocksource: clint: Use IPI_MAX for IPI muxing
    https://git.kernel.org/riscv/c/f6326e26f602
  - [v2,4/6] irqchip/aclint-sswi: Use IPI_MAX for IPI muxing
    https://git.kernel.org/riscv/c/a89546503a0e
  - [v2,5/6] irqchip/imsic: Use IPI_MAX instead of IMSIC_NR_IPI
    https://git.kernel.org/riscv/c/5b104000160d
  - [v2,6/6] media: mtk-vpu: rename IPI_MAX to IPI_VPU_MAX
    https://git.kernel.org/riscv/c/d1d2645e755b

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html