Skip to contentSkip to conversation

irqchip/sg2042-msi: Set irq type according to DT configuration

PATCH Superseded Chen Wang 4 participants 9 messages Aug 26, 2025 – Sep 3, 2025

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Chen Wang

author
#0 lore raw

v2 cover irqchip/sg2042-msi: Set irq type according to DT configuration

From: Chen Wang <[email protected]>

The original MSI interrupt type was hard-coded, which was not a good idea. Now it is changed to read the device tree configuration and then set the interrupt type.

This patchset is based on irq/drivers branch of tip.

---

Changes in v2:
The patch series is based on irq/drivers branch of tip.

Reverted the change to obtain params of "msi-ranges"; it's better not to assume the value of "#interrupt-cells" is 2, even though it's known to be the case. Thanks to Inochi for the comments.

Changes in v1:
The patch series is based on irq/drivers branch of tip. You can simply review or test the patches at the link [1].

---

Chen Wang (3):
irqchip/sg2042-msi: Set irq type according to DT configuration
riscv: sophgo: dts: sg2042: change msi irq type to
IRQ_TYPE_EDGE_RISING
riscv: sophgo: dts: sg2044: change msi irq type to
IRQ_TYPE_EDGE_RISING

 arch/riscv/boot/dts/sophgo/sg2042.dtsi | 2 +-
 arch/riscv/boot/dts/sophgo/sg2044.dtsi | 2 +-
 drivers/irqchip/irq-sg2042-msi.c       | 7 +++++--
 3 files changed, 7 insertions(+), 4 deletions(-)

base-commit: 8ff1c16c753e293c3ba20583cb64f81ea7b9a451

Signature · 1 line
2.34.1
author
#1 lore raw

PATCH v2 1/3 irqchip/sg2042-msi: Set irq type according to DT configuration

From: Chen Wang <[email protected]>

The original MSI interrupt type was hard-coded, which was not a good idea. Now it is changed to read the device tree configuration and then set the interrupt type.

---
 drivers/irqchip/irq-sg2042-msi.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/irqchip/irq-sg2042-msi.c +5 -2
index 3b13dbbfdb51..f7cf0dc72eab 100644
@@ -30,6 +30,7 @@ struct sg204x_msi_chip_info {
  * @doorbell_addr:	see TRM, 10.1.32, GP_INTR0_SET
  * @irq_first:		First vectors number that MSIs starts
  * @num_irqs:		Number of vectors for MSIs
+ * @irq_type:		IRQ type for MSIs
  * @msi_map:		mapping for allocated MSI vectors.
  * @msi_map_lock:	Lock for msi_map
  * @chip_info:		chip specific infomations
@@ -41,6 +42,7 @@ struct sg204x_msi_chipdata {
 
 	u32					irq_first;
 	u32					num_irqs;
+	unsigned int				irq_type;
 
 	unsigned long				*msi_map;
 	struct mutex				msi_map_lock;
@@ -137,14 +139,14 @@ static int sg204x_msi_parent_domain_alloc(struct irq_domain *domain, unsigned in
 	fwspec.fwnode = domain->parent->fwnode;
 	fwspec.param_count = 2;
 	fwspec.param[0] = data->irq_first + hwirq;
-	fwspec.param[1] = IRQ_TYPE_EDGE_RISING;
+	fwspec.param[1] = data->irq_type;
 
 	ret = irq_domain_alloc_irqs_parent(domain, virq, 1, &fwspec);
 	if (ret)
 		return ret;
 
 	d = irq_domain_get_irq_data(domain->parent, virq);
-	return d->chip->irq_set_type(d, IRQ_TYPE_EDGE_RISING);
+	return d->chip->irq_set_type(d, data->irq_type);
 }
 
 static int sg204x_msi_middle_domain_alloc(struct irq_domain *domain, unsigned int virq,
@@ -298,6 +300,7 @@ static int sg2042_msi_probe(struct platform_device *pdev)
 	}
 
 	data->irq_first = (u32)args.args[0];
+	data->irq_type = (unsigned int)args.args[1];
 	data->num_irqs = (u32)args.args[args.nargs - 1];
 
 	mutex_init(&data->msi_map_lock);
Signature · 1 line
2.34.1
#2 lore raw
Quoted 3 lines · Chen Wang

From: Chen Wang <[email protected]>

The original MSI interrupt type was hard-coded, which was not a good idea.

That's not really helpful, unless you explain WHY it's not a good idea...

Also for correctness sake, you want to change the DTs first and not after you changed the driver to read it from the stale device tree with the wrong type.

Thanks,

tglx

author
#3 lore raw

PATCH v2 2/3 riscv: sophgo: dts: sg2042: change msi irq type to IRQ_TYPE_EDGE_RISING

In reply to Chen Wang

From: Chen Wang <[email protected]>

The latest MSI driver will read the DTS configuration to set the IRQ type, so correct the IRQ type in the DTS to the correct value.

This field in the DTS was not used before.

---
 arch/riscv/boot/dts/sophgo/sg2042.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/boot/dts/sophgo/sg2042.dtsi +1 -1
index b3e4d3c18fdc..6430c6e25c00 100644
@@ -190,7 +190,7 @@ msi: msi-controller@7030010304 {
 			reg-names = "clr", "doorbell";
 			msi-controller;
 			#msi-cells = <0>;
-			msi-ranges = <&intc 64 IRQ_TYPE_LEVEL_HIGH 32>;
+			msi-ranges = <&intc 64 IRQ_TYPE_EDGE_RISING 32>;
 		};
 
 		rpgate: clock-controller@7030010368 {
Signature · 1 line
2.34.1
author
#4 lore raw

PATCH v2 3/3 riscv: sophgo: dts: sg2044: change msi irq type to IRQ_TYPE_EDGE_RISING

In reply to Chen Wang

From: Chen Wang <[email protected]>

The latest MSI driver will read the DTS configuration to set the IRQ type, so correct the IRQ type in the DTS to the correct value.

This field in the DTS was not used before.

---
 arch/riscv/boot/dts/sophgo/sg2044.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/boot/dts/sophgo/sg2044.dtsi +1 -1
index 6ec955744b0c..320c4d1d08e6 100644
@@ -214,7 +214,7 @@ msi: msi-controller@6d50000000 {
 			reg-names = "clr", "doorbell";
 			#msi-cells = <0>;
 			msi-controller;
-			msi-ranges = <&intc 352 IRQ_TYPE_LEVEL_HIGH 512>;
+			msi-ranges = <&intc 352 IRQ_TYPE_EDGE_RISING 512>;
 			status = "disabled";
 		};
 
Signature · 1 line
2.34.1
maintainer Tested-by on the v2 series
#5 lore raw
In reply to Chen Wang
Quoted 31 lines · Chen Wang

From: Chen Wang <[email protected]>

The original MSI interrupt type was hard-coded, which was not a good idea. Now it is changed to read the device tree configuration and then set the interrupt type.

This patchset is based on irq/drivers branch of tip.

---

Changes in v2:
The patch series is based on irq/drivers branch of tip.

Reverted the change to obtain params of "msi-ranges"; it's better not to assume the value of "#interrupt-cells" is 2, even though it's known to be the case. Thanks to Inochi for the comments.

Changes in v1:
The patch series is based on irq/drivers branch of tip. You can simply review or test the patches at the link [1].

---

Chen Wang (3):
irqchip/sg2042-msi: Set irq type according to DT configuration
riscv: sophgo: dts: sg2042: change msi irq type to
IRQ_TYPE_EDGE_RISING
riscv: sophgo: dts: sg2044: change msi irq type to
IRQ_TYPE_EDGE_RISING

Quoted 10 lines
 arch/riscv/boot/dts/sophgo/sg2042.dtsi | 2 +-
 arch/riscv/boot/dts/sophgo/sg2044.dtsi | 2 +-
 drivers/irqchip/irq-sg2042-msi.c       | 7 +++++--
 3 files changed, 7 insertions(+), 4 deletions(-)

base-commit: 8ff1c16c753e293c3ba20583cb64f81ea7b9a451

Signature · 1 line
2.34.1
#6 lore raw
In reply to Chen Wang

Hi, Thomas,

Would you please pick this patchset?

P.S. Since the modification of the DTS part is closely dependent on the modification of the driver part, I am not sure whether you are willing to pick these three patches together, or just pick the driver part and leave the DTS part to me?

Thanks,

Chen

Quoted 38 lines · Chen Wang

From: Chen Wang <[email protected]>

The original MSI interrupt type was hard-coded, which was not a good idea. Now it is changed to read the device tree configuration and then set the interrupt type.

This patchset is based on irq/drivers branch of tip.

---

Changes in v2:
The patch series is based on irq/drivers branch of tip.

Reverted the change to obtain params of "msi-ranges"; it's better not to assume the value of "#interrupt-cells" is 2, even though it's known to be the case. Thanks to Inochi for the comments.

Changes in v1:
The patch series is based on irq/drivers branch of tip. You can simply review or test the patches at the link [1].

---

Chen Wang (3):
irqchip/sg2042-msi: Set irq type according to DT configuration
riscv: sophgo: dts: sg2042: change msi irq type to
IRQ_TYPE_EDGE_RISING
riscv: sophgo: dts: sg2044: change msi irq type to
IRQ_TYPE_EDGE_RISING

  arch/riscv/boot/dts/sophgo/sg2042.dtsi | 2 +-
  arch/riscv/boot/dts/sophgo/sg2044.dtsi | 2 +-
  drivers/irqchip/irq-sg2042-msi.c       | 7 +++++--
  3 files changed, 7 insertions(+), 4 deletions(-)

base-commit: 8ff1c16c753e293c3ba20583cb64f81ea7b9a451

#7 lore raw

On Tue, Sep 02 2025 at 07:59, Chen Wang wrote:

Please don't top-post and trim your replies.

Quoted 4 lines

P.S. Since the modification of the DTS part is closely dependent on the modification of the driver part, I am not sure whether you are willing to pick these three patches together, or just pick the driver part and leave the DTS part to me?

They need to go together in the right order obviously.

#8 lore raw
Quoted 9 lines · Thomas Gleixner

On Tue, Sep 02 2025 at 07:59, Chen Wang wrote:

Please don't top-post and trim your replies.

Quoted 4 lines

P.S. Since the modification of the DTS part is closely dependent on the modification of the driver part, I am not sure whether you are willing to pick these three patches together, or just pick the driver part and leave the DTS part to me?

They need to go together in the right order obviously.

OK, I'll adjust the order of the patches and repost a new version.

Thanks,

Chen