linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] irqchip/sg2042-msi: Set irq type according to DT configuration
@ 2025-08-25  6:54 Chen Wang
  2025-08-25  6:55 ` [PATCH 1/4] irqchip/sg2042-msi: Improve the logic of obtaining msi-ranges parameters Chen Wang
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Chen Wang @ 2025-08-25  6:54 UTC (permalink / raw)
  To: u.kleine-koenig, aou, unicorn_wang, conor+dt, inochiama, krzk+dt,
	looong.bin, palmer, paul.walmsley, robh, tglx, sycamoremoon376,
	devicetree, linux-kernel, linux-riscv, sophgo

From: Chen Wang <unicorn_wang@outlook.com>

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.

Also improve the code to obtain msi-ranges parameters in this patchset.

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

Chen Wang (4):
  irqchip/sg2042-msi: Improve the logic of obtaining msi-ranges
    parameters
  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       | 21 ++++++++-------------
 3 files changed, 10 insertions(+), 15 deletions(-)


base-commit: 8ff1c16c753e293c3ba20583cb64f81ea7b9a451
-- 
2.34.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* [PATCH 1/4] irqchip/sg2042-msi: Improve the logic of obtaining msi-ranges parameters
  2025-08-25  6:54 [PATCH 0/4] irqchip/sg2042-msi: Set irq type according to DT configuration Chen Wang
@ 2025-08-25  6:55 ` Chen Wang
  2025-08-25  7:33   ` Inochi Amaoto
  2025-08-25  6:55 ` [PATCH 2/4] irqchip/sg2042-msi: Set irq type according to DT configuration Chen Wang
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Chen Wang @ 2025-08-25  6:55 UTC (permalink / raw)
  To: u.kleine-koenig, aou, unicorn_wang, conor+dt, inochiama, krzk+dt,
	looong.bin, palmer, paul.walmsley, robh, tglx, sycamoremoon376,
	devicetree, linux-kernel, linux-riscv, sophgo

From: Chen Wang <unicorn_wang@outlook.com>

Get the arguments of msi-ranges by specifying nargs directly instead of
using nargs_prop. This only takes one step, unlike the previous two
steps to get the values of all the arguments.

Signed-off-by: Chen Wang <unicorn_wang@outlook.com>
---
 drivers/irqchip/irq-sg2042-msi.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/irqchip/irq-sg2042-msi.c b/drivers/irqchip/irq-sg2042-msi.c
index 3b13dbbfdb51..5249afd93b4a 100644
--- a/drivers/irqchip/irq-sg2042-msi.c
+++ b/drivers/irqchip/irq-sg2042-msi.c
@@ -276,17 +276,9 @@ static int sg2042_msi_probe(struct platform_device *pdev)
 	data->doorbell_addr = res->start;
 
 	ret = fwnode_property_get_reference_args(dev_fwnode(dev), "msi-ranges",
-						 "#interrupt-cells", 0, 0, &args);
+						 NULL, 3, 0, &args);
 	if (ret) {
-		dev_err(dev, "Unable to parse MSI vec base\n");
-		return ret;
-	}
-	fwnode_handle_put(args.fwnode);
-
-	ret = fwnode_property_get_reference_args(dev_fwnode(dev), "msi-ranges", NULL,
-						 args.nargs + 1, 0, &args);
-	if (ret) {
-		dev_err(dev, "Unable to parse MSI vec number\n");
+		dev_err(dev, "Unable to parse MSI Ranges\n");
 		return ret;
 	}
 
@@ -298,7 +290,7 @@ static int sg2042_msi_probe(struct platform_device *pdev)
 	}
 
 	data->irq_first = (u32)args.args[0];
-	data->num_irqs = (u32)args.args[args.nargs - 1];
+	data->num_irqs = (u32)args.args[2];
 
 	mutex_init(&data->msi_map_lock);
 
-- 
2.34.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* [PATCH 2/4] irqchip/sg2042-msi: Set irq type according to DT configuration
  2025-08-25  6:54 [PATCH 0/4] irqchip/sg2042-msi: Set irq type according to DT configuration Chen Wang
  2025-08-25  6:55 ` [PATCH 1/4] irqchip/sg2042-msi: Improve the logic of obtaining msi-ranges parameters Chen Wang
@ 2025-08-25  6:55 ` Chen Wang
  2025-08-25  6:56 ` [PATCH 3/4] riscv: sophgo: dts: sg2042: change msi irq type to IRQ_TYPE_EDGE_RISING Chen Wang
  2025-08-25  6:56 ` [PATCH 4/4] riscv: sophgo: dts: sg2044: " Chen Wang
  3 siblings, 0 replies; 8+ messages in thread
From: Chen Wang @ 2025-08-25  6:55 UTC (permalink / raw)
  To: u.kleine-koenig, aou, unicorn_wang, conor+dt, inochiama, krzk+dt,
	looong.bin, palmer, paul.walmsley, robh, tglx, sycamoremoon376,
	devicetree, linux-kernel, linux-riscv, sophgo

From: Chen Wang <unicorn_wang@outlook.com>

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.

Signed-off-by: Chen Wang <unicorn_wang@outlook.com>
---
 drivers/irqchip/irq-sg2042-msi.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/irqchip/irq-sg2042-msi.c b/drivers/irqchip/irq-sg2042-msi.c
index 5249afd93b4a..be47c038386c 100644
--- a/drivers/irqchip/irq-sg2042-msi.c
+++ b/drivers/irqchip/irq-sg2042-msi.c
@@ -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,
@@ -290,6 +292,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[2];
 
 	mutex_init(&data->msi_map_lock);
-- 
2.34.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* [PATCH 3/4] riscv: sophgo: dts: sg2042: change msi irq type to IRQ_TYPE_EDGE_RISING
  2025-08-25  6:54 [PATCH 0/4] irqchip/sg2042-msi: Set irq type according to DT configuration Chen Wang
  2025-08-25  6:55 ` [PATCH 1/4] irqchip/sg2042-msi: Improve the logic of obtaining msi-ranges parameters Chen Wang
  2025-08-25  6:55 ` [PATCH 2/4] irqchip/sg2042-msi: Set irq type according to DT configuration Chen Wang
@ 2025-08-25  6:56 ` Chen Wang
  2025-08-25  6:56 ` [PATCH 4/4] riscv: sophgo: dts: sg2044: " Chen Wang
  3 siblings, 0 replies; 8+ messages in thread
From: Chen Wang @ 2025-08-25  6:56 UTC (permalink / raw)
  To: u.kleine-koenig, aou, unicorn_wang, conor+dt, inochiama, krzk+dt,
	looong.bin, palmer, paul.walmsley, robh, tglx, sycamoremoon376,
	devicetree, linux-kernel, linux-riscv, sophgo

From: Chen Wang <unicorn_wang@outlook.com>

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.

Signed-off-by: Chen Wang <unicorn_wang@outlook.com>
---
 arch/riscv/boot/dts/sophgo/sg2042.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/boot/dts/sophgo/sg2042.dtsi b/arch/riscv/boot/dts/sophgo/sg2042.dtsi
index b3e4d3c18fdc..6430c6e25c00 100644
--- a/arch/riscv/boot/dts/sophgo/sg2042.dtsi
+++ b/arch/riscv/boot/dts/sophgo/sg2042.dtsi
@@ -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 {
-- 
2.34.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* [PATCH 4/4] riscv: sophgo: dts: sg2044: change msi irq type to IRQ_TYPE_EDGE_RISING
  2025-08-25  6:54 [PATCH 0/4] irqchip/sg2042-msi: Set irq type according to DT configuration Chen Wang
                   ` (2 preceding siblings ...)
  2025-08-25  6:56 ` [PATCH 3/4] riscv: sophgo: dts: sg2042: change msi irq type to IRQ_TYPE_EDGE_RISING Chen Wang
@ 2025-08-25  6:56 ` Chen Wang
  2025-08-25  7:00   ` Chen Wang
  3 siblings, 1 reply; 8+ messages in thread
From: Chen Wang @ 2025-08-25  6:56 UTC (permalink / raw)
  To: u.kleine-koenig, aou, unicorn_wang, conor+dt, inochiama, krzk+dt,
	looong.bin, palmer, paul.walmsley, robh, tglx, sycamoremoon376,
	devicetree, linux-kernel, linux-riscv, sophgo

From: Chen Wang <unicorn_wang@outlook.com>

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.

Signed-off-by: Chen Wang <unicorn_wang@outlook.com>
---
 arch/riscv/boot/dts/sophgo/sg2044.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/boot/dts/sophgo/sg2044.dtsi b/arch/riscv/boot/dts/sophgo/sg2044.dtsi
index 6ec955744b0c..320c4d1d08e6 100644
--- a/arch/riscv/boot/dts/sophgo/sg2044.dtsi
+++ b/arch/riscv/boot/dts/sophgo/sg2044.dtsi
@@ -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";
 		};
 
-- 
2.34.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH 4/4] riscv: sophgo: dts: sg2044: change msi irq type to IRQ_TYPE_EDGE_RISING
  2025-08-25  6:56 ` [PATCH 4/4] riscv: sophgo: dts: sg2044: " Chen Wang
@ 2025-08-25  7:00   ` Chen Wang
  0 siblings, 0 replies; 8+ messages in thread
From: Chen Wang @ 2025-08-25  7:00 UTC (permalink / raw)
  To: Inochi Amaoto
  Cc: Chen Wang, u.kleine-koenig, aou, conor+dt, inochiama, krzk+dt,
	looong.bin, palmer, paul.walmsley, robh, tglx, sycamoremoon376,
	devicetree, linux-kernel, linux-riscv, sophgo

Hi, Inochi,

Please help review and test this with SG2044 board, I only have 
pioneerbox/SG2042 and it's tested and works.

Thanks,

Chen

On 8/25/2025 2:56 PM, Chen Wang wrote:
> From: Chen Wang <unicorn_wang@outlook.com>
>
> 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.
>
> Signed-off-by: Chen Wang <unicorn_wang@outlook.com>
> ---
>   arch/riscv/boot/dts/sophgo/sg2044.dtsi | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/riscv/boot/dts/sophgo/sg2044.dtsi b/arch/riscv/boot/dts/sophgo/sg2044.dtsi
> index 6ec955744b0c..320c4d1d08e6 100644
> --- a/arch/riscv/boot/dts/sophgo/sg2044.dtsi
> +++ b/arch/riscv/boot/dts/sophgo/sg2044.dtsi
> @@ -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";
>   		};
>   

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH 1/4] irqchip/sg2042-msi: Improve the logic of obtaining msi-ranges parameters
  2025-08-25  6:55 ` [PATCH 1/4] irqchip/sg2042-msi: Improve the logic of obtaining msi-ranges parameters Chen Wang
@ 2025-08-25  7:33   ` Inochi Amaoto
  2025-08-25  8:22     ` Chen Wang
  0 siblings, 1 reply; 8+ messages in thread
From: Inochi Amaoto @ 2025-08-25  7:33 UTC (permalink / raw)
  To: Chen Wang, u.kleine-koenig, aou, unicorn_wang, conor+dt,
	inochiama, krzk+dt, looong.bin, palmer, paul.walmsley, robh, tglx,
	sycamoremoon376, devicetree, linux-kernel, linux-riscv, sophgo

On Mon, Aug 25, 2025 at 02:55:03PM +0800, Chen Wang wrote:
> From: Chen Wang <unicorn_wang@outlook.com>
> 
> Get the arguments of msi-ranges by specifying nargs directly instead of
> using nargs_prop. This only takes one step, unlike the previous two
> steps to get the values of all the arguments.
> 
> Signed-off-by: Chen Wang <unicorn_wang@outlook.com>
> ---
>  drivers/irqchip/irq-sg2042-msi.c | 14 +++-----------
>  1 file changed, 3 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/irqchip/irq-sg2042-msi.c b/drivers/irqchip/irq-sg2042-msi.c
> index 3b13dbbfdb51..5249afd93b4a 100644
> --- a/drivers/irqchip/irq-sg2042-msi.c
> +++ b/drivers/irqchip/irq-sg2042-msi.c
> @@ -276,17 +276,9 @@ static int sg2042_msi_probe(struct platform_device *pdev)
>  	data->doorbell_addr = res->start;
>  

>  	ret = fwnode_property_get_reference_args(dev_fwnode(dev), "msi-ranges",
> -						 "#interrupt-cells", 0, 0, &args);
> +						 NULL, 3, 0, &args);

Why using a fixed range here? I see no improvement. I think using #interrupt-cells
is just OK.

Regards,
Inochi

>  	if (ret) {
> -		dev_err(dev, "Unable to parse MSI vec base\n");
> -		return ret;
> -	}
> -	fwnode_handle_put(args.fwnode);
> -
> -	ret = fwnode_property_get_reference_args(dev_fwnode(dev), "msi-ranges", NULL,
> -						 args.nargs + 1, 0, &args);
> -	if (ret) {
> -		dev_err(dev, "Unable to parse MSI vec number\n");
> +		dev_err(dev, "Unable to parse MSI Ranges\n");
>  		return ret;
>  	}
>  
> @@ -298,7 +290,7 @@ static int sg2042_msi_probe(struct platform_device *pdev)
>  	}
>  
>  	data->irq_first = (u32)args.args[0];
> -	data->num_irqs = (u32)args.args[args.nargs - 1];
> +	data->num_irqs = (u32)args.args[2];
>  
>  	mutex_init(&data->msi_map_lock);
>  
> -- 
> 2.34.1
> 

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH 1/4] irqchip/sg2042-msi: Improve the logic of obtaining msi-ranges parameters
  2025-08-25  7:33   ` Inochi Amaoto
@ 2025-08-25  8:22     ` Chen Wang
  0 siblings, 0 replies; 8+ messages in thread
From: Chen Wang @ 2025-08-25  8:22 UTC (permalink / raw)
  To: Inochi Amaoto, Chen Wang, u.kleine-koenig, aou, conor+dt, krzk+dt,
	looong.bin, palmer, paul.walmsley, robh, tglx, sycamoremoon376,
	devicetree, linux-kernel, linux-riscv, sophgo


On 8/25/2025 3:33 PM, Inochi Amaoto wrote:
> On Mon, Aug 25, 2025 at 02:55:03PM +0800, Chen Wang wrote:
>> From: Chen Wang <unicorn_wang@outlook.com>
>>
>> Get the arguments of msi-ranges by specifying nargs directly instead of
>> using nargs_prop. This only takes one step, unlike the previous two
>> steps to get the values of all the arguments.
>>
>> Signed-off-by: Chen Wang <unicorn_wang@outlook.com>
>> ---
>>   drivers/irqchip/irq-sg2042-msi.c | 14 +++-----------
>>   1 file changed, 3 insertions(+), 11 deletions(-)
>>
>> diff --git a/drivers/irqchip/irq-sg2042-msi.c b/drivers/irqchip/irq-sg2042-msi.c
>> index 3b13dbbfdb51..5249afd93b4a 100644
>> --- a/drivers/irqchip/irq-sg2042-msi.c
>> +++ b/drivers/irqchip/irq-sg2042-msi.c
>> @@ -276,17 +276,9 @@ static int sg2042_msi_probe(struct platform_device *pdev)
>>   	data->doorbell_addr = res->start;
>>   
>>   	ret = fwnode_property_get_reference_args(dev_fwnode(dev), "msi-ranges",
>> -						 "#interrupt-cells", 0, 0, &args);
>> +						 NULL, 3, 0, &args);
> Why using a fixed range here? I see no improvement. I think using #interrupt-cells
> is just OK.
Ok, I will revert this change.
> Regards,
> Inochi
>
>>   	if (ret) {
>> -		dev_err(dev, "Unable to parse MSI vec base\n");
>> -		return ret;
>> -	}
>> -	fwnode_handle_put(args.fwnode);
>> -
>> -	ret = fwnode_property_get_reference_args(dev_fwnode(dev), "msi-ranges", NULL,
>> -						 args.nargs + 1, 0, &args);
>> -	if (ret) {
>> -		dev_err(dev, "Unable to parse MSI vec number\n");
>> +		dev_err(dev, "Unable to parse MSI Ranges\n");
>>   		return ret;
>>   	}
>>   
>> @@ -298,7 +290,7 @@ static int sg2042_msi_probe(struct platform_device *pdev)
>>   	}
>>   
>>   	data->irq_first = (u32)args.args[0];
>> -	data->num_irqs = (u32)args.args[args.nargs - 1];
>> +	data->num_irqs = (u32)args.args[2];
>>   
>>   	mutex_init(&data->msi_map_lock);
>>   
>> -- 
>> 2.34.1
>>

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

end of thread, other threads:[~2025-08-25  8:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-25  6:54 [PATCH 0/4] irqchip/sg2042-msi: Set irq type according to DT configuration Chen Wang
2025-08-25  6:55 ` [PATCH 1/4] irqchip/sg2042-msi: Improve the logic of obtaining msi-ranges parameters Chen Wang
2025-08-25  7:33   ` Inochi Amaoto
2025-08-25  8:22     ` Chen Wang
2025-08-25  6:55 ` [PATCH 2/4] irqchip/sg2042-msi: Set irq type according to DT configuration Chen Wang
2025-08-25  6:56 ` [PATCH 3/4] riscv: sophgo: dts: sg2042: change msi irq type to IRQ_TYPE_EDGE_RISING Chen Wang
2025-08-25  6:56 ` [PATCH 4/4] riscv: sophgo: dts: sg2044: " Chen Wang
2025-08-25  7:00   ` Chen Wang

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