diff mbox series

[V1,2/2] xen/device-tree: Add ability to handle nodes with interrupts-extended prop

Message ID 1558460254-7127-3-git-send-email-olekstysh@gmail.com (mailing list archive)
State New, archived
Headers show
Series Add ability to handle nodes with interrupts-extended property | expand

Commit Message

Oleksandr Tyshchenko May 21, 2019, 5:37 p.m. UTC
From: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>

The "interrupts-extended" property is a special form for use when
a node needs to reference multiple interrupt parents.

According to the:
Linux/Documentation/devicetree/bindings/interrupt-controller/interrupts.txt

But, there are cases when "interrupts-extended" property is used for
"outside /soc node" with a single interrupt parent as an equivalent of
pairs ("interrupt-parent" + "interrupts").

The good example here is ARCH timer node for R-Car Gen3/Gen2 family,
which is mandatory device for Xen usage on ARM. And without ability
to handle such nodes, Xen fails to operate.

So, this patch adds required support for Xen to be able to handle
nodes with that property.

Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>

---
    Changes RFC -> V1:
        - Explain in the commit message regarding property usage, add a link
          to the bindings.
        - Don't try to look for "interrupts" property if "interrupts-extended"
          property is present, but doesn't contain any interrupts
          (dt_count_phandle_with_args returns 0).
        - Add messages to tell which property is used.
---
 xen/common/device_tree.c | 36 +++++++++++++++++++++++++++++++++---
 1 file changed, 33 insertions(+), 3 deletions(-)

Comments

Julien Grall May 29, 2019, 5:44 p.m. UTC | #1
Hi Oleksandr,

On 21/05/2019 18:37, Oleksandr Tyshchenko wrote:
> From: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
> 
> The "interrupts-extended" property is a special form for use when
> a node needs to reference multiple interrupt parents. >
> According to the:

NIT: s/the//

> Linux/Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
> 
> But, there are cases when "interrupts-extended" property is used for
> "outside /soc node" with a single interrupt parent as an equivalent of
> pairs ("interrupt-parent" + "interrupts").
> 
> The good example here is ARCH timer node for R-Car Gen3/Gen2 family,

NIT: s/The/A/ I think

> which is mandatory device for Xen usage on ARM. And without ability
> to handle such nodes, Xen fails to operate.
> 
> So, this patch adds required support for Xen to be able to handle
> nodes with that property.
> 
> Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>

I will give an opportunity to Stefano to review it. If I don't hear anything by 
Monday, I will merge it.

Thank you!

Cheers,
Oleksandr Tyshchenko May 29, 2019, 5:58 p.m. UTC | #2
On 29.05.19 20:44, Julien Grall wrote:
> Hi Oleksandr,

Hi, Julien


>
> On 21/05/2019 18:37, Oleksandr Tyshchenko wrote:
>> From: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
>>
>> The "interrupts-extended" property is a special form for use when
>> a node needs to reference multiple interrupt parents. >
>> According to the:
>
> NIT: s/the//
>
>> Linux/Documentation/devicetree/bindings/interrupt-controller/interrupts.txt 
>>
>>
>> But, there are cases when "interrupts-extended" property is used for
>> "outside /soc node" with a single interrupt parent as an equivalent of
>> pairs ("interrupt-parent" + "interrupts").
>>
>> The good example here is ARCH timer node for R-Car Gen3/Gen2 family,
>
> NIT: s/The/A/ I think
>
>> which is mandatory device for Xen usage on ARM. And without ability
>> to handle such nodes, Xen fails to operate.
>>
>> So, this patch adds required support for Xen to be able to handle
>> nodes with that property.
>>
>> Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
>
> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>

Thank you! I assume you meant Reviewed-by: Julien Grall 
<julien.grall@arm.com> )

Shall I send new version with proposed changes?


>
> I will give an opportunity to Stefano to review it. If I don't hear 
> anything by Monday, I will merge it.
>
> Thank you!
>
> Cheers,
>
Julien Grall May 29, 2019, 6:18 p.m. UTC | #3
On 29/05/2019 18:58, Oleksandr wrote:
> 
> On 29.05.19 20:44, Julien Grall wrote:
>> Hi Oleksandr,
> 
> Hi, Julien
> 
> 
>>
>> On 21/05/2019 18:37, Oleksandr Tyshchenko wrote:
>>> From: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
>>>
>>> The "interrupts-extended" property is a special form for use when
>>> a node needs to reference multiple interrupt parents. >
>>> According to the:
>>
>> NIT: s/the//
>>
>>> Linux/Documentation/devicetree/bindings/interrupt-controller/interrupts.txt 
>>>
>>>
>>> But, there are cases when "interrupts-extended" property is used for
>>> "outside /soc node" with a single interrupt parent as an equivalent of
>>> pairs ("interrupt-parent" + "interrupts").
>>>
>>> The good example here is ARCH timer node for R-Car Gen3/Gen2 family,
>>
>> NIT: s/The/A/ I think
>>
>>> which is mandatory device for Xen usage on ARM. And without ability
>>> to handle such nodes, Xen fails to operate.
>>>
>>> So, this patch adds required support for Xen to be able to handle
>>> nodes with that property.
>>>
>>> Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
>>
>> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
> 
> Thank you! I assume you meant Reviewed-by: Julien Grall 
> <julien.grall@arm.com> )

Yes sorry, I was adding is reviewed-by on some of my patches and 
mechanically copied here. Apologies for the inconvenience.

> 
> Shall I send new version with proposed changes?

No need, I can do the change while committing (assuming Stefano has no 
other comments).

Cheers,
Julien Grall June 10, 2019, 7:45 p.m. UTC | #4
Hi,

On 5/29/19 7:18 PM, Julien Grall wrote:
> 
> 
> On 29/05/2019 18:58, Oleksandr wrote:
>>
>> On 29.05.19 20:44, Julien Grall wrote:
>>> Hi Oleksandr,
>>
>> Hi, Julien
>>
>>
>>>
>>> On 21/05/2019 18:37, Oleksandr Tyshchenko wrote:
>>>> From: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
>>>>
>>>> The "interrupts-extended" property is a special form for use when
>>>> a node needs to reference multiple interrupt parents. >
>>>> According to the:
>>>
>>> NIT: s/the//
>>>
>>>> Linux/Documentation/devicetree/bindings/interrupt-controller/interrupts.txt 
>>>>
>>>>
>>>> But, there are cases when "interrupts-extended" property is used for
>>>> "outside /soc node" with a single interrupt parent as an equivalent of
>>>> pairs ("interrupt-parent" + "interrupts").
>>>>
>>>> The good example here is ARCH timer node for R-Car Gen3/Gen2 family,
>>>
>>> NIT: s/The/A/ I think
>>>
>>>> which is mandatory device for Xen usage on ARM. And without ability
>>>> to handle such nodes, Xen fails to operate.
>>>>
>>>> So, this patch adds required support for Xen to be able to handle
>>>> nodes with that property.
>>>>
>>>> Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
>>>
>>> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
>>
>> Thank you! I assume you meant Reviewed-by: Julien Grall 
>> <julien.grall@arm.com> )
> 
> Yes sorry, I was adding is reviewed-by on some of my patches and 
> mechanically copied here. Apologies for the inconvenience.
> 
>>
>> Shall I send new version with proposed changes?
> 
> No need, I can do the change while committing (assuming Stefano has no 
> other comments).

Now applied to my staging branch. It will be committed tonight.

Thank you for the patches.

Cheers,
Oleksandr Tyshchenko June 11, 2019, 4:15 p.m. UTC | #5
On 10.06.19 22:45, Julien Grall wrote:
> Hi,

Hi Julien


> Now applied to my staging branch. It will be committed tonight.
>
> Thank you for the patches.

Thank you for the review.


>
>
> Cheers,
>
diff mbox series

Patch

diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c
index 65862b5..e107c6f 100644
--- a/xen/common/device_tree.c
+++ b/xen/common/device_tree.c
@@ -987,15 +987,27 @@  unsigned int dt_number_of_irq(const struct dt_device_node *device)
     const struct dt_device_node *p;
     const __be32 *intspec, *tmp;
     u32 intsize, intlen;
+    int intnum;
 
     dt_dprintk("dt_irq_number: dev=%s\n", device->full_name);
 
+    /* Try the new-style interrupts-extended first */
+    intnum = dt_count_phandle_with_args(device, "interrupts-extended",
+                                        "#interrupt-cells");
+    if ( intnum >= 0 )
+    {
+        dt_dprintk(" using 'interrupts-extended' property\n");
+        dt_dprintk(" intnum=%d\n", intnum);
+        return intnum;
+    }
+
     /* Get the interrupts property */
     intspec = dt_get_property(device, "interrupts", &intlen);
     if ( intspec == NULL )
         return 0;
     intlen /= sizeof(*intspec);
 
+    dt_dprintk(" using 'interrupts' property\n");
     dt_dprintk(" intspec=%d intlen=%d\n", be32_to_cpup(intspec), intlen);
 
     /* Look for the interrupt parent. */
@@ -1420,21 +1432,39 @@  int dt_device_get_raw_irq(const struct dt_device_node *device,
     const __be32 *intspec, *tmp, *addr;
     u32 intsize, intlen;
     int res = -EINVAL;
+    struct dt_phandle_args args;
+    int i;
 
     dt_dprintk("dt_device_get_raw_irq: dev=%s, index=%u\n",
                device->full_name, index);
 
+    /* Get the reg property (if any) */
+    addr = dt_get_property(device, "reg", NULL);
+
+    /* Try the new-style interrupts-extended first */
+    res = dt_parse_phandle_with_args(device, "interrupts-extended",
+                                     "#interrupt-cells", index, &args);
+    if ( !res )
+    {
+        dt_dprintk(" using 'interrupts-extended' property\n");
+        dt_dprintk(" intspec=%d intsize=%d\n", args.args[0], args.args_count);
+
+        for ( i = 0; i < args.args_count; i++ )
+            args.args[i] = cpu_to_be32(args.args[i]);
+
+        return dt_irq_map_raw(args.np, args.args, args.args_count,
+                              addr, out_irq);
+    }
+
     /* Get the interrupts property */
     intspec = dt_get_property(device, "interrupts", &intlen);
     if ( intspec == NULL )
         return -EINVAL;
     intlen /= sizeof(*intspec);
 
+    dt_dprintk(" using 'interrupts' property\n");
     dt_dprintk(" intspec=%d intlen=%d\n", be32_to_cpup(intspec), intlen);
 
-    /* Get the reg property (if any) */
-    addr = dt_get_property(device, "reg", NULL);
-
     /* Look for the interrupt parent. */
     p = dt_irq_find_parent(device);
     if ( p == NULL )