2016-03-14 06:45:43

by majun (Euler7)

[permalink] [raw]
Subject: [PATCH v2 0/2] Irq/Mbigen: fix the IO remap problem in mbigen driver.

From: Ma Jun <[email protected]>

This patch set is used to fix the problem of remap a set of registers
repeatedly.

Changes in v2:
--- Change the mbigen device node definition
--- Change the mbigen driver based on the new mbigen dts structure.

Ma Jun (2):
Irq/mbigen:Change the mbigen node definition in dt binding file
Irq/mbigen:Change the mbigen driver based on the new mbigen node definition

.../interrupt-controller/hisilicon,mbigen-v2.txt | 22 +++++++++++---
drivers/irqchip/irq-mbigen.c | 30 ++++++++++++++------
2 files changed, 38 insertions(+), 14 deletions(-)



2016-03-14 06:45:54

by majun (Euler7)

[permalink] [raw]
Subject: [PATCH v2 2/2] Irq/mbigen:Change the mbigen driver based on the new mbigen node definition.

From: Ma Jun <[email protected]>

To fix the IO remap problem, change the mbigen driver based on the
new mbigen node definition.

Signed-off-by: Ma Jun <[email protected]>
---
drivers/irqchip/irq-mbigen.c | 30 +++++++++++++++++++++---------
1 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/drivers/irqchip/irq-mbigen.c b/drivers/irqchip/irq-mbigen.c
index 4dd3eb8..4d413bc 100644
--- a/drivers/irqchip/irq-mbigen.c
+++ b/drivers/irqchip/irq-mbigen.c
@@ -242,6 +242,8 @@ static int mbigen_device_probe(struct platform_device *pdev)
struct resource *res;
struct irq_domain *domain;
u32 num_pins;
+ struct platform_device *child_pdev;
+ struct device_node *np;

mgn_chip = devm_kzalloc(&pdev->dev, sizeof(*mgn_chip), GFP_KERNEL);
if (!mgn_chip)
@@ -251,25 +253,35 @@ static int mbigen_device_probe(struct platform_device *pdev)

res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
mgn_chip->base = devm_ioremap_resource(&pdev->dev, res);
+
if (IS_ERR(mgn_chip->base))
return PTR_ERR(mgn_chip->base);

- if (of_property_read_u32(pdev->dev.of_node, "num-pins", &num_pins) < 0) {
- dev_err(&pdev->dev, "No num-pins property\n");
- return -EINVAL;
- }
+ for_each_child_of_node(pdev->dev.of_node, np) {
+ if (!of_property_read_bool(np, "interrupt-controller"))
+ continue;
+
+ child_pdev = of_platform_device_create(np, NULL, platform_bus_type.dev_root);
+ if (IS_ERR(child_pdev))
+ return PTR_ERR(child_pdev);
+
+ if (of_property_read_u32(child_pdev->dev.of_node, "num-pins", &num_pins) < 0) {
+ dev_err(&pdev->dev, "No num-pins property\n");
+ return -EINVAL;
+ }

- domain = platform_msi_create_device_domain(&pdev->dev, num_pins,
+ domain = platform_msi_create_device_domain(&child_pdev->dev, num_pins,
mbigen_write_msg,
&mbigen_domain_ops,
mgn_chip);

- if (!domain)
- return -ENOMEM;
+ if (!domain)
+ return -ENOMEM;

- platform_set_drvdata(pdev, mgn_chip);
+ dev_info(&child_pdev->dev, "Allocated %d MSIs\n", num_pins);
+ }

- dev_info(&pdev->dev, "Allocated %d MSIs\n", num_pins);
+ platform_set_drvdata(pdev, mgn_chip);

return 0;
}
--
1.7.1


2016-03-14 06:46:01

by majun (Euler7)

[permalink] [raw]
Subject: [PATCH v2 1/2] Irq/mbigen:Change the mbigen node definition in dt binding file

From: Ma Jun <[email protected]>

For mbigen module, there is a special case that more than one mbigen
device nodes use the same reg definition in DTS when these devices
exist in the same mbigen hardware module.

To fix the mbigen IO remap problem, the mbigen node definition and
structure are changed based on Mark Rutland's suggestion.

Signed-off-by: Ma Jun <[email protected]>
---
.../interrupt-controller/hisilicon,mbigen-v2.txt | 22 +++++++++++++++----
1 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/Documentation/devicetree/bindings/interrupt-controller/hisilicon,mbigen-v2.txt b/Documentation/devicetree/bindings/interrupt-controller/hisilicon,mbigen-v2.txt
index 720f7c9..3b2f4c4 100644
--- a/Documentation/devicetree/bindings/interrupt-controller/hisilicon,mbigen-v2.txt
+++ b/Documentation/devicetree/bindings/interrupt-controller/hisilicon,mbigen-v2.txt
@@ -21,6 +21,8 @@ Mbigen main node required properties:
- reg: Specifies the base physical address and size of the Mbigen
registers.

+Mbigen sub node required properties:
+------------------------------------------
- interrupt controller: Identifies the node as an interrupt controller

- msi-parent: Specifies the MSI controller this mbigen use.
@@ -45,13 +47,23 @@ Mbigen main node required properties:

Examples:

- mbigen_device_gmac:intc {
+ mbigen_chip_dsa {
compatible = "hisilicon,mbigen-v2";
reg = <0x0 0xc0080000 0x0 0x10000>;
- interrupt-controller;
- msi-parent = <&its_dsa 0x40b1c>;
- num-pins = <9>;
- #interrupt-cells = <2>;
+
+ mbigen_gmac:intc_gmac {
+ interrupt-controller;
+ msi-parent = <&its_dsa 0x40b1c>;
+ num-pins = <9>;
+ #interrupt-cells = <2>;
+ };
+
+ mbigen_i2c:intc_i2c {
+ interrupt-controller;
+ msi-parent = <&its_dsa 0x40b0e>;
+ num-pins = <2>;
+ #interrupt-cells = <2>;
+ };
};

Devices connect to mbigen required properties:
--
1.7.1


2016-03-14 07:45:46

by Thomas Gleixner

[permalink] [raw]
Subject: Re: [PATCH v2 2/2] Irq/mbigen:Change the mbigen driver based on the new mbigen node definition.

On Mon, 14 Mar 2016, MaJun wrote:

> From: Ma Jun <[email protected]>
>
> To fix the IO remap problem, change the mbigen driver based on the
> new mbigen node definition.

Please describe what the problem is. There is no way that anyone can figure
out why that patch is required, what it fixes and how the fix is done. The
'how' should be a high level description as we can see the actual changes in
the diff.

Thanks,

tglx



2016-03-14 07:51:35

by Thomas Gleixner

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] Irq/mbigen:Change the mbigen node definition in dt binding file

Majun,

On Mon, 14 Mar 2016, MaJun wrote:

First of all the prefix for irq chip drivers is not "Irq/".

Hint: git log drivers/irqchip

> From: Ma Jun <[email protected]>
>
> For mbigen module, there is a special case that more than one mbigen
> device nodes use the same reg definition in DTS when these devices
> exist in the same mbigen hardware module.

There is a special case, so what?

> To fix the mbigen IO remap problem, the mbigen node definition and

Which problem?

> structure are changed based on Mark Rutland's suggestion.

That's really uselss. Nobody has any idea what Mark suggested and in which way
it fixes that unspecified problem you are talking about.

Thanks,

tglx

2016-03-15 07:38:00

by majun (Euler7)

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] Irq/mbigen:Change the mbigen node definition in dt binding file

Hi Thomas:
Thanks for pointing out the problems.
I'll make detail description about this problem and resend this patch set.


在 2016/3/14 15:49, Thomas Gleixner 写道:
> Majun,
>
> On Mon, 14 Mar 2016, MaJun wrote:
>
> First of all the prefix for irq chip drivers is not "Irq/".
>
> Hint: git log drivers/irqchip
>
>> From: Ma Jun <[email protected]>
>>
>> For mbigen module, there is a special case that more than one mbigen
>> device nodes use the same reg definition in DTS when these devices
>> exist in the same mbigen hardware module.
>
> There is a special case, so what?
>

In current driver, the registers would be remapped repeatedly
and caused error when use the function "devm_ioremap_resource".

That's the problem I tried to fix.

>> To fix the mbigen IO remap problem, the mbigen node definition and
>
> Which problem?
>
>> structure are changed based on Mark Rutland's suggestion.
>
> That's really uselss. Nobody has any idea what Mark suggested and in which way
> it fixes that unspecified problem you are talking about.
>

Actually, I discussed this problem with Mark in v1.
He raised some questions and suggestions
http://lists.infradead.org/pipermail/linux-arm-kernel/2016-February/403691.html

Thanks!
MaJun

> Thanks,
>
> tglx
>
> .
>