From: Rob Herring <hidden> Date: 2011-09-20 20:24:15
From: Rob Herring <redacted>
Hopefully, this is the final or near final version of GIC binding support.
Changes from the previous version:
- SPIs and PPIs are numbered starting at 0. Now the gic has it's own irq
domain translate function instead of the simple domain one.
- interrupt cell format has changed based on Grant's proposal.
- Dropped "ARM: gic: allow irq_start to be 0". Instead, the first 16 irqs
are skipped and the domain irq_base adjusted accordingly.
- Added a fix to of_irq_find_parent when the parent == child.
- Renamed intc_desc.parent to intc_desc.interrupt_parent.
- Implemented Grant's algorithm for walking the list of interrupt
controllers. Added a return value to interrupt init functions, so they
don't get added to the parent list on a init failure.
The changes are significant enough that I did not include previous
acked/reviewed/tested-by's.
Rob
Rob Herring (3):
of/irq: of_irq_find_parent: check for parent equal to child
of/irq: introduce of_irq_init
ARM: gic: add OF based initialization
Documentation/devicetree/bindings/arm/gic.txt | 55 +++++++++++
arch/arm/common/gic.c | 89 ++++++++++++++++-
arch/arm/include/asm/hardware/gic.h | 12 +++
drivers/of/irq.c | 128 +++++++++++++++++++++++--
include/linux/of_irq.h | 1 +
5 files changed, 274 insertions(+), 11 deletions(-)
create mode 100644 Documentation/devicetree/bindings/arm/gic.txt
--
1.7.5.4
From: Rob Herring <hidden> Date: 2011-09-20 20:24:18
From: Rob Herring <redacted>
An interrupt controller may often implicitly inherit itself from a parent
node when in fact the controller is the interrupt root controller. Guard
against the case of child == parent and return NULL in this case.
This can also be fixed by adding an explicit "interrupt-parent;" to a root
interrupt controller node.
Based on code from Grant Likely.
Signed-off-by: Rob Herring <redacted>
Cc: Grant Likely <redacted>
---
drivers/of/irq.c | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
From: Grant Likely <hidden> Date: 2011-09-20 21:01:07
On Tue, Sep 20, 2011 at 03:24:02PM -0500, Rob Herring wrote:
From: Rob Herring <redacted>
An interrupt controller may often implicitly inherit itself from a parent
node when in fact the controller is the interrupt root controller. Guard
against the case of child == parent and return NULL in this case.
This can also be fixed by adding an explicit "interrupt-parent;" to a root
interrupt controller node.
Based on code from Grant Likely.
Signed-off-by: Rob Herring <redacted>
Cc: Grant Likely <redacted>
Looks great.
Ben, can you look at this please? Make sure I've not missed something
about how powerpc expects of_irq_find_parent() to behave.
g.
From: Rob Herring <hidden> Date: 2011-09-20 20:24:21
From: Rob Herring <redacted>
of_irq_init will scan the devicetree for matching interrupt controller
nodes. Then it calls an initialization function for each found controller
in the proper order with parent nodes initialized before child nodes.
Based on initial pseudo code from Grant Likely.
Signed-off-by: Rob Herring <redacted>
Cc: Grant Likely <redacted>
---
drivers/of/irq.c | 114 ++++++++++++++++++++++++++++++++++++++++++++++++
include/linux/of_irq.h | 1 +
2 files changed, 115 insertions(+), 0 deletions(-)
@@ -19,10 +19,12 @@*/#include<linux/errno.h>+#include<linux/list.h>#include<linux/module.h>#include<linux/of.h>#include<linux/of_irq.h>#include<linux/string.h>+#include<linux/slab.h>/* For archs that don't support NO_IRQ (such as x86), provide a dummy value */#ifndef NO_IRQ
@@ -386,3 +388,115 @@ int of_irq_to_resource_table(struct device_node *dev, struct resource *res,returni;}++structintc_desc{+structlist_headlist;+structdevice_node*dev;+structdevice_node*interrupt_parent;+};++typedefint(*irq_init_cb_t)(structdevice_node*,structdevice_node*);++/**+*of_irq_init-Scanthedevicetreeformatchinginterruptcontrollersand+*calltheirinitializationfunctionsinorderwithparentsfirst.+*@matches:0terminatedarrayofnodestomatchandinitializationfunction+*tocallonmatch+*/+void__initof_irq_init(conststructof_device_id*matches)+{+structdevice_node*np;+structintc_desc*desc;+structintc_desc*temp_desc;+structintc_desc*parent_desc=NULL;+structlist_headintc_desc_list;+structlist_headintc_parent_list;++INIT_LIST_HEAD(&intc_desc_list);+INIT_LIST_HEAD(&intc_parent_list);++for_each_matching_node(np,matches){+if(!of_find_property(np,"interrupt-controller",NULL))+continue;+/* Here, we allocate and populate an intc_desc with the node+*pointer,interrupt-parentdevice_nodeetc.*/+desc=kzalloc(sizeof(*desc),GFP_KERNEL);+if(!desc){+WARN_ON(1);+gotoerr;+}+desc->dev=np;+desc->interrupt_parent=of_irq_find_parent(np);+list_add(&desc->list,&intc_desc_list);+}+if(list_empty(&intc_desc_list))+return;++/*+*Therootirqcontrolleristheonewithoutaninterrupt-parent.+*Thatonegoesfirst,followedbythecontrollersthatreferenceit,+*followedbytheonesthatreferencethe2ndlevelcontrollers,etc+*/+while(!list_empty(&intc_desc_list)){+/*+*Processallcontrollerswiththecurrent'parent'.+*FirstpasswillbelookingforNULLastheparent.+*TheassumptionisthatNULLparentmeansarootcontroller.+*/+list_for_each_entry_safe(desc,temp_desc,&intc_desc_list,list){+conststructof_device_id*match;+intret;+irq_init_cb_tirq_init_cb;++if(parent_desc&&+(desc->interrupt_parent!=parent_desc->dev))+continue;++list_del(&desc->list);+match=of_match_node(matches,desc->dev);+if(!match||!match->data)+continue;++pr_debug("of_irq_init: init %s @ %p, parent %p\n",+match->compatible,+desc->dev,desc->interrupt_parent);+irq_init_cb=match->data;+ret=irq_init_cb(desc->dev,desc->interrupt_parent);+if(ret)+continue;++/*+*Thisoneisnowsetup;addittotheparentlistso+*itschildrencangetprocessedinasubsequentpass.+*/+list_add_tail(&desc->list,&intc_parent_list);+}+/*+*Allthedirectchildrenforthecurrentparentare+*processed,sofreetheparentnow.+*/+if(parent_desc)+kfree(parent_desc);++/* Get the next pending parent that might have children */+parent_desc=list_first_entry(&intc_parent_list,+typeof(*parent_desc),list);+if(list_empty(&intc_parent_list)||!parent_desc){+pr_debug("of_irq_init: children remain, but no parents\n");+gotoerr;+}++list_del(&parent_desc->list);+}+return;++err:+list_for_each_entry_safe(desc,temp_desc,&intc_parent_list,list){+list_del(&desc->list);+kfree(desc);+}+list_for_each_entry_safe(desc,temp_desc,&intc_desc_list,list){+list_del(&desc->list);+kfree(desc);+}+}
From: Grant Likely <hidden> Date: 2011-09-20 23:01:01
On Tue, Sep 20, 2011 at 03:24:03PM -0500, Rob Herring wrote:
From: Rob Herring <redacted>
of_irq_init will scan the devicetree for matching interrupt controller
nodes. Then it calls an initialization function for each found controller
in the proper order with parent nodes initialized before child nodes.
Based on initial pseudo code from Grant Likely.
Signed-off-by: Rob Herring <redacted>
Cc: Grant Likely <redacted>
@@ -19,10 +19,12 @@*/#include<linux/errno.h>+#include<linux/list.h>#include<linux/module.h>#include<linux/of.h>#include<linux/of_irq.h>#include<linux/string.h>+#include<linux/slab.h>/* For archs that don't support NO_IRQ (such as x86), provide a dummy value */#ifndef NO_IRQ
This typedef should be in a header file. I'd like to try and find a
way to typecheck the .data parameter in the matches table (maybe with
a macro), but I've not dug into the problem.
+
+/**
+ * of_irq_init - Scan the device tree for matching interrupt controllers and
kerneldoc format is:
* of_irq_init() - ...
And the short description should fit on the one line. Further
description can appear after the argument list documentation.
+ * call their initialization functions in order with parents first.
+ * @matches: 0 terminated array of nodes to match and initialization function
+ * to call on match
+ */
+void __init of_irq_init(const struct of_device_id *matches)
+{
+ struct device_node *np;
+ struct intc_desc *desc;
+ struct intc_desc *temp_desc;
+ struct intc_desc *parent_desc = NULL;
+ struct list_head intc_desc_list;
+ struct list_head intc_parent_list;
Nit: these lines can be collapsed a bit.
struct intc_desc *desc, *temp_desc, *parent_desc = NULL;
struct list_head intc_desc_list, intc_parent_list;
+ INIT_LIST_HEAD(&intc_desc_list);
+ INIT_LIST_HEAD(&intc_parent_list);
+
+ for_each_matching_node(np, matches) {
+ if (!of_find_property(np, "interrupt-controller", NULL))
+ continue;
+ /* Here, we allocate and populate an intc_desc with the node
+ * pointer, interrupt-parent device_node etc. */
+ desc = kzalloc(sizeof(*desc), GFP_KERNEL);
+ if (!desc) {
+ WARN_ON(1);
+ goto err;
+ }
+ desc->dev = np;
+ desc->interrupt_parent = of_irq_find_parent(np);
+ list_add(&desc->list, &intc_desc_list);
list_add_tail() would keep things ordered.
+ }
+ if (list_empty(&intc_desc_list))
+ return;
This test can be dropped because the while loop performs the exact
same test.
+
+ /*
+ * The root irq controller is the one without an interrupt-parent.
+ * That one goes first, followed by the controllers that reference it,
+ * followed by the ones that reference the 2nd level controllers, etc
+ */
+ while (!list_empty(&intc_desc_list)) {
+ /*
+ * Process all controllers with the current 'parent'.
+ * First pass will be looking for NULL as the parent.
+ * The assumption is that NULL parent means a root controller.
+ */
+ list_for_each_entry_safe(desc, temp_desc, &intc_desc_list, list) {
+ const struct of_device_id *match;
+ int ret;
+ irq_init_cb_t irq_init_cb;
+
+ if (parent_desc &&
+ (desc->interrupt_parent != parent_desc->dev))
+ continue;
If you changed
struct intc_desc *parent_desc = NULL;
to
struct device_node *parent_np = NULL;
Then this test could be simplified to:
if (desc->interupt_parent != parent_np)
continue;
And the kfree could be done immediately after the next parent is
pulled off the intc_desc_list since the only thing actually needed
from the parent_desc is the parent node pointer.
+
+ list_del(&desc->list);
+ match = of_match_node(matches, desc->dev);
+ if (!match || !match->data)
+ continue;
+
+ pr_debug("of_irq_init: init %s @ %p, parent %p\n",
+ match->compatible,
+ desc->dev, desc->interrupt_parent);
+ irq_init_cb = match->data;
+ ret = irq_init_cb(desc->dev, desc->interrupt_parent);
+ if (ret)
+ continue;
+
+ /*
+ * This one is now set up; add it to the parent list so
+ * its children can get processed in a subsequent pass.
+ */
+ list_add_tail(&desc->list, &intc_parent_list);
+ }
+ /*
+ * All the direct children for the current parent are
+ * processed, so free the parent now.
+ */
+ if (parent_desc)
+ kfree(parent_desc);
+
+ /* Get the next pending parent that might have children */
+ parent_desc = list_first_entry(&intc_parent_list,
+ typeof(*parent_desc), list);
+ if (list_empty(&intc_parent_list) || !parent_desc) {
+ pr_debug("of_irq_init: children remain, but no parents\n");
+ goto err;
+ }
+
+ list_del(&parent_desc->list);
+ }
Need a loop here to clear and free any remaining entries in the
intc_parent_list. Actually, everything would work fine by simply
removing the below 'return' statement and letting the code fall
through to the free loops unconditionally. And the "goto err" above
can be simplified to "break".
Hi Rob,
On Tue, Sep 20, 2011 at 03:24:03PM -0500, Rob Herring wrote:
quoted hunk
From: Rob Herring <redacted>
of_irq_init will scan the devicetree for matching interrupt controller
nodes. Then it calls an initialization function for each found controller
in the proper order with parent nodes initialized before child nodes.
Based on initial pseudo code from Grant Likely.
Signed-off-by: Rob Herring <redacted>
Cc: Grant Likely <redacted>
---
drivers/of/irq.c | 114 ++++++++++++++++++++++++++++++++++++++++++++++++
include/linux/of_irq.h | 1 +
2 files changed, 115 insertions(+), 0 deletions(-)
@@ -19,10 +19,12 @@*/#include<linux/errno.h>+#include<linux/list.h>#include<linux/module.h>#include<linux/of.h>#include<linux/of_irq.h>#include<linux/string.h>+#include<linux/slab.h>/* For archs that don't support NO_IRQ (such as x86), provide a dummy value */#ifndef NO_IRQ
@@ -386,3 +388,115 @@ int of_irq_to_resource_table(struct device_node *dev, struct resource *res,returni;}++structintc_desc{+structlist_headlist;+structdevice_node*dev;+structdevice_node*interrupt_parent;+};++typedefint(*irq_init_cb_t)(structdevice_node*,structdevice_node*);++/**+*of_irq_init-Scanthedevicetreeformatchinginterruptcontrollersand+*calltheirinitializationfunctionsinorderwithparentsfirst.+*@matches:0terminatedarrayofnodestomatchandinitializationfunction+*tocallonmatch+*/+void__initof_irq_init(conststructof_device_id*matches)+{+structdevice_node*np;+structintc_desc*desc;+structintc_desc*temp_desc;+structintc_desc*parent_desc=NULL;+structlist_headintc_desc_list;+structlist_headintc_parent_list;++INIT_LIST_HEAD(&intc_desc_list);+INIT_LIST_HEAD(&intc_parent_list);++for_each_matching_node(np,matches){+if(!of_find_property(np,"interrupt-controller",NULL))+continue;+/* Here, we allocate and populate an intc_desc with the node+*pointer,interrupt-parentdevice_nodeetc.*/+desc=kzalloc(sizeof(*desc),GFP_KERNEL);+if(!desc){+WARN_ON(1);+gotoerr;+}+desc->dev=np;+desc->interrupt_parent=of_irq_find_parent(np);+list_add(&desc->list,&intc_desc_list);+}+if(list_empty(&intc_desc_list))+return;++/*+*Therootirqcontrolleristheonewithoutaninterrupt-parent.+*Thatonegoesfirst,followedbythecontrollersthatreferenceit,+*followedbytheonesthatreferencethe2ndlevelcontrollers,etc+*/+while(!list_empty(&intc_desc_list)){+/*+*Processallcontrollerswiththecurrent'parent'.+*FirstpasswillbelookingforNULLastheparent.+*TheassumptionisthatNULLparentmeansarootcontroller.+*/+list_for_each_entry_safe(desc,temp_desc,&intc_desc_list,list){+conststructof_device_id*match;+intret;+irq_init_cb_tirq_init_cb;++if(parent_desc&&+(desc->interrupt_parent!=parent_desc->dev))+continue;++list_del(&desc->list);+match=of_match_node(matches,desc->dev);+if(!match||!match->data)+continue;
+
+ /*
+ * This one is now set up; add it to the parent list so
+ * its children can get processed in a subsequent pass.
+ */
+ list_add_tail(&desc->list, &intc_parent_list);
+ }
+ /*
+ * All the direct children for the current parent are
+ * processed, so free the parent now.
+ */
+ if (parent_desc)
+ kfree(parent_desc);
+
+ /* Get the next pending parent that might have children */
+ parent_desc = list_first_entry(&intc_parent_list,
+ typeof(*parent_desc), list);
+ if (list_empty(&intc_parent_list) || !parent_desc) {
+ pr_debug("of_irq_init: children remain, but no parents\n");
+ goto err;
+ }
+
+ list_del(&parent_desc->list);
+ }
+ return;
+
+err:
+ list_for_each_entry_safe(desc, temp_desc, &intc_parent_list, list) {
+ list_del(&desc->list);
+ kfree(desc);
+ }
+ list_for_each_entry_safe(desc, temp_desc, &intc_desc_list, list) {
+ list_del(&desc->list);
+ kfree(desc);
+ }
+}
From: Rob Herring <hidden> Date: 2011-09-23 02:21:24
From: Rob Herring <redacted>
of_irq_init will scan the devicetree for matching interrupt controller
nodes. Then it calls an initialization function for each found controller
in the proper order with parent nodes initialized before child nodes.
Based on initial pseudo code from Grant Likely.
Signed-off-by: Rob Herring <redacted>
Cc: Grant Likely <redacted>
---
Changes from v2:
- add missing kfree's found by Jamie
- Implement Grant's comments to simplify the init loop
- fix function comments
drivers/of/irq.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++++
include/linux/of_irq.h | 3 +
2 files changed, 109 insertions(+), 0 deletions(-)
@@ -19,10 +19,12 @@*/#include<linux/errno.h>+#include<linux/list.h>#include<linux/module.h>#include<linux/of.h>#include<linux/of_irq.h>#include<linux/string.h>+#include<linux/slab.h>/* For archs that don't support NO_IRQ (such as x86), provide a dummy value */#ifndef NO_IRQ
@@ -386,3 +388,107 @@ int of_irq_to_resource_table(struct device_node *dev, struct resource *res,returni;}++structintc_desc{+structlist_headlist;+structdevice_node*dev;+structdevice_node*interrupt_parent;+};++/**+*of_irq_init-ScanandinitmatchinginterruptcontrollersinDT+*@matches:0terminatedarrayofnodestomatchandinitfunctiontocall+*+*Thisfunctionscansthedevicetreeformatchinginterruptcontrollernodes,+*andcallstheirinitializationfunctionsinorderwithparentsfirst.+*/+void__initof_irq_init(conststructof_device_id*matches)+{+structdevice_node*np,*parent=NULL;+structintc_desc*desc,*temp_desc;+structlist_headintc_desc_list,intc_parent_list;++INIT_LIST_HEAD(&intc_desc_list);+INIT_LIST_HEAD(&intc_parent_list);++for_each_matching_node(np,matches){+if(!of_find_property(np,"interrupt-controller",NULL))+continue;+/* Here, we allocate and populate an intc_desc with the node+*pointer,interrupt-parentdevice_nodeetc.*/+desc=kzalloc(sizeof(*desc),GFP_KERNEL);+if(!desc){+WARN_ON(1);+gotoerr;+}+desc->dev=np;+desc->interrupt_parent=of_irq_find_parent(np);+list_add_tail(&desc->list,&intc_desc_list);+}+if(list_empty(&intc_desc_list))+return;++/*+*Therootirqcontrolleristheonewithoutaninterrupt-parent.+*Thatonegoesfirst,followedbythecontrollersthatreferenceit,+*followedbytheonesthatreferencethe2ndlevelcontrollers,etc+*/+while(!list_empty(&intc_desc_list)){+/*+*Processallcontrollerswiththecurrent'parent'.+*FirstpasswillbelookingforNULLastheparent.+*TheassumptionisthatNULLparentmeansarootcontroller.+*/+list_for_each_entry_safe(desc,temp_desc,&intc_desc_list,list){+conststructof_device_id*match;+intret;+of_irq_init_cb_tirq_init_cb;++if(desc->interrupt_parent!=parent)+continue;++list_del(&desc->list);+match=of_match_node(matches,desc->dev);+if(!match||!match->data){+kfree(desc);+continue;+}++pr_debug("of_irq_init: init %s @ %p, parent %p\n",+match->compatible,+desc->dev,desc->interrupt_parent);+irq_init_cb=match->data;+ret=irq_init_cb(desc->dev,desc->interrupt_parent);+if(ret){+kfree(desc);+continue;+}++/*+*Thisoneisnowsetup;addittotheparentlistso+*itschildrencangetprocessedinasubsequentpass.+*/+list_add_tail(&desc->list,&intc_parent_list);+}++/* Get the next pending parent that might have children */+desc=list_first_entry(&intc_parent_list,typeof(*desc),list);+if(list_empty(&intc_parent_list)||!desc){+pr_debug("of_irq_init: children remain, but no parents\n");+break;+}+list_del(&desc->list);+parent=desc->dev;+kfree(desc);+}++list_for_each_entry_safe(desc,temp_desc,&intc_parent_list,list){+list_del(&desc->list);+kfree(desc);+}+err:+list_for_each_entry_safe(desc,temp_desc,&intc_desc_list,list){+list_del(&desc->list);+kfree(desc);+}+}
From: Grant Likely <hidden> Date: 2011-09-23 23:04:30
On Thu, Sep 22, 2011 at 09:21:13PM -0500, Rob Herring wrote:
From: Rob Herring <redacted>
of_irq_init will scan the devicetree for matching interrupt controller
nodes. Then it calls an initialization function for each found controller
in the proper order with parent nodes initialized before child nodes.
Based on initial pseudo code from Grant Likely.
Signed-off-by: Rob Herring <redacted>
Cc: Grant Likely <redacted>
Looking really good, comments below...
---
Changes from v2:
- add missing kfree's found by Jamie
- Implement Grant's comments to simplify the init loop
- fix function comments
Nit: put changelog above the s-o-b lines so that it appears in the git
commit text.
@@ -19,10 +19,12 @@*/#include<linux/errno.h>+#include<linux/list.h>#include<linux/module.h>#include<linux/of.h>#include<linux/of_irq.h>#include<linux/string.h>+#include<linux/slab.h>/* For archs that don't support NO_IRQ (such as x86), provide a dummy value */#ifndef NO_IRQ
@@ -386,3 +388,107 @@ int of_irq_to_resource_table(struct device_node *dev, struct resource *res,returni;}++structintc_desc{+structlist_headlist;+structdevice_node*dev;+structdevice_node*interrupt_parent;+};++/**+*of_irq_init-ScanandinitmatchinginterruptcontrollersinDT+*@matches:0terminatedarrayofnodestomatchandinitfunctiontocall+*+*Thisfunctionscansthedevicetreeformatchinginterruptcontrollernodes,+*andcallstheirinitializationfunctionsinorderwithparentsfirst.+*/+void__initof_irq_init(conststructof_device_id*matches)+{+structdevice_node*np,*parent=NULL;+structintc_desc*desc,*temp_desc;+structlist_headintc_desc_list,intc_parent_list;++INIT_LIST_HEAD(&intc_desc_list);+INIT_LIST_HEAD(&intc_parent_list);++for_each_matching_node(np,matches){+if(!of_find_property(np,"interrupt-controller",NULL))+continue;+/* Here, we allocate and populate an intc_desc with the node+*pointer,interrupt-parentdevice_nodeetc.*/
+
+ /*
+ * The root irq controller is the one without an interrupt-parent.
+ * That one goes first, followed by the controllers that reference it,
+ * followed by the ones that reference the 2nd level controllers, etc
+ */
+ while (!list_empty(&intc_desc_list)) {
+ /*
+ * Process all controllers with the current 'parent'.
+ * First pass will be looking for NULL as the parent.
+ * The assumption is that NULL parent means a root controller.
+ */
+ list_for_each_entry_safe(desc, temp_desc, &intc_desc_list, list) {
+ const struct of_device_id *match;
+ int ret;
+ of_irq_init_cb_t irq_init_cb;
+
+ if (desc->interrupt_parent != parent)
+ continue;
+
+ list_del(&desc->list);
+ match = of_match_node(matches, desc->dev);
+ if (!match || !match->data) {
match will always be !NULL. If match_data is NULL; something is
seriously wrong and the code should WARN().
+ kfree(desc);
+ continue;
+ }
+
+ pr_debug("of_irq_init: init %s @ %p, parent %p\n",
+ match->compatible,
+ desc->dev, desc->interrupt_parent);
+ irq_init_cb = match->data;
+ ret = irq_init_cb(desc->dev, desc->interrupt_parent);
+ if (ret) {
+ kfree(desc);
+ continue;
+ }
+
+ /*
+ * This one is now set up; add it to the parent list so
+ * its children can get processed in a subsequent pass.
+ */
+ list_add_tail(&desc->list, &intc_parent_list);
+ }
+
+ /* Get the next pending parent that might have children */
+ desc = list_first_entry(&intc_parent_list, typeof(*desc), list);
+ if (list_empty(&intc_parent_list) || !desc) {
+ pr_debug("of_irq_init: children remain, but no parents\n");
From: Rob Herring <hidden> Date: 2011-09-26 19:24:57
From: Rob Herring <redacted>
of_irq_init will scan the devicetree for matching interrupt controller
nodes. Then it calls an initialization function for each found controller
in the proper order with parent nodes initialized before child nodes.
Based on initial pseudo code from Grant Likely.
Changes in v4:
- Drop unnecessary empty list check
- Be more verbose on errors
- Simplify "if (!desc) WARN_ON(1)" to "if (WARN_ON(!desc))"
Changes in v3:
- add missing kfree's found by Jamie
- Implement Grant's comments to simplify the init loop
- fix function comments
Changes in v2:
- Complete re-write of list searching code from Grant Likely
Signed-off-by: Rob Herring <redacted>
Cc: Grant Likely <redacted>
---
drivers/of/irq.c | 107 ++++++++++++++++++++++++++++++++++++++++++++++++
include/linux/of_irq.h | 3 +
2 files changed, 110 insertions(+), 0 deletions(-)
@@ -19,10 +19,12 @@*/#include<linux/errno.h>+#include<linux/list.h>#include<linux/module.h>#include<linux/of.h>#include<linux/of_irq.h>#include<linux/string.h>+#include<linux/slab.h>/* For archs that don't support NO_IRQ (such as x86), provide a dummy value */#ifndef NO_IRQ
@@ -386,3 +388,108 @@ int of_irq_to_resource_table(struct device_node *dev, struct resource *res,returni;}++structintc_desc{+structlist_headlist;+structdevice_node*dev;+structdevice_node*interrupt_parent;+};++/**+*of_irq_init-ScanandinitmatchinginterruptcontrollersinDT+*@matches:0terminatedarrayofnodestomatchandinitfunctiontocall+*+*Thisfunctionscansthedevicetreeformatchinginterruptcontrollernodes,+*andcallstheirinitializationfunctionsinorderwithparentsfirst.+*/+void__initof_irq_init(conststructof_device_id*matches)+{+structdevice_node*np,*parent=NULL;+structintc_desc*desc,*temp_desc;+structlist_headintc_desc_list,intc_parent_list;++INIT_LIST_HEAD(&intc_desc_list);+INIT_LIST_HEAD(&intc_parent_list);++for_each_matching_node(np,matches){+if(!of_find_property(np,"interrupt-controller",NULL))+continue;+/*+*Here,weallocateandpopulateanintc_descwiththenode+*pointer,interrupt-parentdevice_nodeetc.+*/+desc=kzalloc(sizeof(*desc),GFP_KERNEL);+if(WARN_ON(!desc))+gotoerr;++desc->dev=np;+desc->interrupt_parent=of_irq_find_parent(np);+list_add_tail(&desc->list,&intc_desc_list);+}++/*+*Therootirqcontrolleristheonewithoutaninterrupt-parent.+*Thatonegoesfirst,followedbythecontrollersthatreferenceit,+*followedbytheonesthatreferencethe2ndlevelcontrollers,etc.+*/+while(!list_empty(&intc_desc_list)){+/*+*Processallcontrollerswiththecurrent'parent'.+*FirstpasswillbelookingforNULLastheparent.+*TheassumptionisthatNULLparentmeansarootcontroller.+*/+list_for_each_entry_safe(desc,temp_desc,&intc_desc_list,list){+conststructof_device_id*match;+intret;+of_irq_init_cb_tirq_init_cb;++if(desc->interrupt_parent!=parent)+continue;++list_del(&desc->list);+match=of_match_node(matches,desc->dev);+if(WARN(!match->data,+"of_irq_init: no init function for %s\n",+match->compatible)){+kfree(desc);+continue;+}++pr_debug("of_irq_init: init %s @ %p, parent %p\n",+match->compatible,+desc->dev,desc->interrupt_parent);+irq_init_cb=match->data;+ret=irq_init_cb(desc->dev,desc->interrupt_parent);+if(ret){+kfree(desc);+continue;+}++/*+*Thisoneisnowsetup;addittotheparentlistso+*itschildrencangetprocessedinasubsequentpass.+*/+list_add_tail(&desc->list,&intc_parent_list);+}++/* Get the next pending parent that might have children */+desc=list_first_entry(&intc_parent_list,typeof(*desc),list);+if(list_empty(&intc_parent_list)||!desc){+pr_err("of_irq_init: children remain, but no parents\n");+break;+}+list_del(&desc->list);+parent=desc->dev;+kfree(desc);+}++list_for_each_entry_safe(desc,temp_desc,&intc_parent_list,list){+list_del(&desc->list);+kfree(desc);+}+err:+list_for_each_entry_safe(desc,temp_desc,&intc_desc_list,list){+list_del(&desc->list);+kfree(desc);+}+}
From: Grant Likely <hidden> Date: 2011-09-27 01:53:10
On Mon, Sep 26, 2011 at 02:24:43PM -0500, Rob Herring wrote:
From: Rob Herring <redacted>
of_irq_init will scan the devicetree for matching interrupt controller
nodes. Then it calls an initialization function for each found controller
in the proper order with parent nodes initialized before child nodes.
Based on initial pseudo code from Grant Likely.
Changes in v4:
- Drop unnecessary empty list check
- Be more verbose on errors
- Simplify "if (!desc) WARN_ON(1)" to "if (WARN_ON(!desc))"
Changes in v3:
- add missing kfree's found by Jamie
- Implement Grant's comments to simplify the init loop
- fix function comments
Changes in v2:
- Complete re-write of list searching code from Grant Likely
Signed-off-by: Rob Herring <redacted>
Cc: Grant Likely <redacted>
@@ -19,10 +19,12 @@*/#include<linux/errno.h>+#include<linux/list.h>#include<linux/module.h>#include<linux/of.h>#include<linux/of_irq.h>#include<linux/string.h>+#include<linux/slab.h>/* For archs that don't support NO_IRQ (such as x86), provide a dummy value */#ifndef NO_IRQ
@@ -386,3 +388,108 @@ int of_irq_to_resource_table(struct device_node *dev, struct resource *res,returni;}++structintc_desc{+structlist_headlist;+structdevice_node*dev;+structdevice_node*interrupt_parent;+};++/**+*of_irq_init-ScanandinitmatchinginterruptcontrollersinDT+*@matches:0terminatedarrayofnodestomatchandinitfunctiontocall+*+*Thisfunctionscansthedevicetreeformatchinginterruptcontrollernodes,+*andcallstheirinitializationfunctionsinorderwithparentsfirst.+*/+void__initof_irq_init(conststructof_device_id*matches)+{+structdevice_node*np,*parent=NULL;+structintc_desc*desc,*temp_desc;+structlist_headintc_desc_list,intc_parent_list;++INIT_LIST_HEAD(&intc_desc_list);+INIT_LIST_HEAD(&intc_parent_list);++for_each_matching_node(np,matches){+if(!of_find_property(np,"interrupt-controller",NULL))+continue;+/*+*Here,weallocateandpopulateanintc_descwiththenode+*pointer,interrupt-parentdevice_nodeetc.+*/+desc=kzalloc(sizeof(*desc),GFP_KERNEL);+if(WARN_ON(!desc))+gotoerr;++desc->dev=np;+desc->interrupt_parent=of_irq_find_parent(np);+list_add_tail(&desc->list,&intc_desc_list);+}++/*+*Therootirqcontrolleristheonewithoutaninterrupt-parent.+*Thatonegoesfirst,followedbythecontrollersthatreferenceit,+*followedbytheonesthatreferencethe2ndlevelcontrollers,etc.+*/+while(!list_empty(&intc_desc_list)){+/*+*Processallcontrollerswiththecurrent'parent'.+*FirstpasswillbelookingforNULLastheparent.+*TheassumptionisthatNULLparentmeansarootcontroller.+*/+list_for_each_entry_safe(desc,temp_desc,&intc_desc_list,list){+conststructof_device_id*match;+intret;+of_irq_init_cb_tirq_init_cb;++if(desc->interrupt_parent!=parent)+continue;++list_del(&desc->list);+match=of_match_node(matches,desc->dev);+if(WARN(!match->data,+"of_irq_init: no init function for %s\n",+match->compatible)){+kfree(desc);+continue;+}++pr_debug("of_irq_init: init %s @ %p, parent %p\n",+match->compatible,+desc->dev,desc->interrupt_parent);+irq_init_cb=match->data;+ret=irq_init_cb(desc->dev,desc->interrupt_parent);+if(ret){+kfree(desc);+continue;+}++/*+*Thisoneisnowsetup;addittotheparentlistso+*itschildrencangetprocessedinasubsequentpass.+*/+list_add_tail(&desc->list,&intc_parent_list);+}++/* Get the next pending parent that might have children */+desc=list_first_entry(&intc_parent_list,typeof(*desc),list);+if(list_empty(&intc_parent_list)||!desc){+pr_err("of_irq_init: children remain, but no parents\n");+break;+}+list_del(&desc->list);+parent=desc->dev;+kfree(desc);+}++list_for_each_entry_safe(desc,temp_desc,&intc_parent_list,list){+list_del(&desc->list);+kfree(desc);+}+err:+list_for_each_entry_safe(desc,temp_desc,&intc_desc_list,list){+list_del(&desc->list);+kfree(desc);+}+}
From: Rob Herring <hidden> Date: 2011-09-27 13:03:58
Grant,
On 09/26/2011 08:53 PM, Grant Likely wrote:
On Mon, Sep 26, 2011 at 02:24:43PM -0500, Rob Herring wrote:
quoted
From: Rob Herring <redacted>
of_irq_init will scan the devicetree for matching interrupt controller
nodes. Then it calls an initialization function for each found controller
in the proper order with parent nodes initialized before child nodes.
Based on initial pseudo code from Grant Likely.
Changes in v4:
- Drop unnecessary empty list check
- Be more verbose on errors
- Simplify "if (!desc) WARN_ON(1)" to "if (WARN_ON(!desc))"
Changes in v3:
- add missing kfree's found by Jamie
- Implement Grant's comments to simplify the init loop
- fix function comments
Changes in v2:
- Complete re-write of list searching code from Grant Likely
Signed-off-by: Rob Herring <redacted>
Cc: Grant Likely <redacted>
Looks good to me. Merged.
I'm dependent on this and things in rmk's tree for initial highbank
support, so should this series go in thru arm-soc tree? Several others
are dependent on this as well.
Rob
@@ -19,10 +19,12 @@*/#include<linux/errno.h>+#include<linux/list.h>#include<linux/module.h>#include<linux/of.h>#include<linux/of_irq.h>#include<linux/string.h>+#include<linux/slab.h>/* For archs that don't support NO_IRQ (such as x86), provide a dummy value */#ifndef NO_IRQ
@@ -386,3 +388,108 @@ int of_irq_to_resource_table(struct device_node *dev, struct resource *res,returni;}++structintc_desc{+structlist_headlist;+structdevice_node*dev;+structdevice_node*interrupt_parent;+};++/**+*of_irq_init-ScanandinitmatchinginterruptcontrollersinDT+*@matches:0terminatedarrayofnodestomatchandinitfunctiontocall+*+*Thisfunctionscansthedevicetreeformatchinginterruptcontrollernodes,+*andcallstheirinitializationfunctionsinorderwithparentsfirst.+*/+void__initof_irq_init(conststructof_device_id*matches)+{+structdevice_node*np,*parent=NULL;+structintc_desc*desc,*temp_desc;+structlist_headintc_desc_list,intc_parent_list;++INIT_LIST_HEAD(&intc_desc_list);+INIT_LIST_HEAD(&intc_parent_list);++for_each_matching_node(np,matches){+if(!of_find_property(np,"interrupt-controller",NULL))+continue;+/*+*Here,weallocateandpopulateanintc_descwiththenode+*pointer,interrupt-parentdevice_nodeetc.+*/+desc=kzalloc(sizeof(*desc),GFP_KERNEL);+if(WARN_ON(!desc))+gotoerr;++desc->dev=np;+desc->interrupt_parent=of_irq_find_parent(np);+list_add_tail(&desc->list,&intc_desc_list);+}++/*+*Therootirqcontrolleristheonewithoutaninterrupt-parent.+*Thatonegoesfirst,followedbythecontrollersthatreferenceit,+*followedbytheonesthatreferencethe2ndlevelcontrollers,etc.+*/+while(!list_empty(&intc_desc_list)){+/*+*Processallcontrollerswiththecurrent'parent'.+*FirstpasswillbelookingforNULLastheparent.+*TheassumptionisthatNULLparentmeansarootcontroller.+*/+list_for_each_entry_safe(desc,temp_desc,&intc_desc_list,list){+conststructof_device_id*match;+intret;+of_irq_init_cb_tirq_init_cb;++if(desc->interrupt_parent!=parent)+continue;++list_del(&desc->list);+match=of_match_node(matches,desc->dev);+if(WARN(!match->data,+"of_irq_init: no init function for %s\n",+match->compatible)){+kfree(desc);+continue;+}++pr_debug("of_irq_init: init %s @ %p, parent %p\n",+match->compatible,+desc->dev,desc->interrupt_parent);+irq_init_cb=match->data;+ret=irq_init_cb(desc->dev,desc->interrupt_parent);+if(ret){+kfree(desc);+continue;+}++/*+*Thisoneisnowsetup;addittotheparentlistso+*itschildrencangetprocessedinasubsequentpass.+*/+list_add_tail(&desc->list,&intc_parent_list);+}++/* Get the next pending parent that might have children */+desc=list_first_entry(&intc_parent_list,typeof(*desc),list);+if(list_empty(&intc_parent_list)||!desc){+pr_err("of_irq_init: children remain, but no parents\n");+break;+}+list_del(&desc->list);+parent=desc->dev;+kfree(desc);+}++list_for_each_entry_safe(desc,temp_desc,&intc_parent_list,list){+list_del(&desc->list);+kfree(desc);+}+err:+list_for_each_entry_safe(desc,temp_desc,&intc_desc_list,list){+list_del(&desc->list);+kfree(desc);+}+}
From: Grant Likely <hidden> Date: 2011-09-27 21:25:05
On Tue, Sep 27, 2011 at 7:03 AM, Rob Herring [off-list ref] wrote:
Grant,
On 09/26/2011 08:53 PM, Grant Likely wrote:
quoted
On Mon, Sep 26, 2011 at 02:24:43PM -0500, Rob Herring wrote:
quoted
From: Rob Herring <redacted>
of_irq_init will scan the devicetree for matching interrupt controller
nodes. Then it calls an initialization function for each found controller
in the proper order with parent nodes initialized before child nodes.
Based on initial pseudo code from Grant Likely.
Changes in v4:
- Drop unnecessary empty list check
- Be more verbose on errors
- Simplify "if (!desc) WARN_ON(1)" to "if (WARN_ON(!desc))"
Changes in v3:
- add missing kfree's found by Jamie
- Implement Grant's comments to simplify the init loop
- fix function comments
Changes in v2:
- Complete re-write of list searching code from Grant Likely
Signed-off-by: Rob Herring <redacted>
Cc: Grant Likely <redacted>
Looks good to me. ?Merged.
I'm dependent on this and things in rmk's tree for initial highbank
support, so should this series go in thru arm-soc tree? Several others
are dependent on this as well.
Sure, it can go in via arm-soc. I don't have anything depending on it
in mine. Add my acked-by.
g.
@@ -0,0 +1,55 @@+* ARM Generic Interrupt Controller++ARM SMP cores are often associated with a GIC, providing per processor+interrupts (PPI), shared processor interrupts (SPI) and software+generated interrupts (SGI).++Primary GIC is attached directly to the CPU and typically has PPIs and SGIs.+Secondary GICs are cascaded into the upward interrupt controller and do not+have PPIs or SGIs.++Main node required properties:++- compatible : should be one of:+ "arm,cortex-a9-gic"+ "arm,arm11mp-gic"+- interrupt-controller : Identifies the node as an interrupt controller+- #interrupt-cells : Specifies the number of cells needed to encode an+ interrupt source. The type shall be a <u32> and the value shall be 3.++ The 1st cell is the interrupt type; 0 for SPI interrupts, 1 for PPI+ interrupts.++ The 2nd cell contains the interrupt number for the interrupt type.+ SPI interrupts are in the range [0-987]. PPI interrupts are in the+ range [0-15].++ The 3rd cell is the flags, encoded as follows:+ bits[3:0] trigger type and level flags.+ 1 = low-to-high edge triggered+ 2 = high-to-low edge triggered+ 4 = active high level-sensitive+ 8 = active low level-sensitive+ bits[15:8] PPI interrupt cpu mask. Each bit corresponds to each of+ the 8 possible cpus attached to the GIC. A bit set to '1' indicated+ the interrupt is wired to that CPU. Only valid for PPI interrupts.++- reg : Specifies base physical address(s) and size of the GIC registers. The+ first region is the GIC distributor register base and size. The 2nd region is+ the GIC cpu interface register base and size.++Optional+- interrupts : Interrupt source of the parent interrupt controller. Only+ present on secondary GICs.++Example:++ intc: interrupt-controller at fff11000 {+ compatible = "arm,cortex-a9-gic";+ #interrupt-cells = <3>;+ #address-cells = <1>;+ interrupt-controller;+ reg = <0xfff11000 0x1000>,+ <0xfff10100 0x100>;+ };+
@@ -405,3 +415,74 @@ void gic_raise_softirq(const struct cpumask *mask, unsigned int irq)writel_relaxed(map<<16|irq,gic_data[0].dist_base+GIC_DIST_SOFTINT);}#endif++#ifdef CONFIG_OF+staticintgic_cnt__initdata=0;++intgic_irq_domain_dt_translate(structirq_domain*d,+structdevice_node*controller,+constu32*intspec,unsignedintintsize,+unsignedlong*out_hwirq,unsignedint*out_type)+{+structgic_chip_data*gic_data=d->priv;++if(d->of_node!=controller)+return-EINVAL;+if(intsize<3)+return-EINVAL;++*out_hwirq=intspec[1];+/*+*We'vealreadyskippedoverSGIs,soPPIsneednotranslation.+*ForSPIs,weneedtoskipover16PPIsonprimaryGICs.+*/+if(!intspec[0]&&!gic_data->irq_offset)+*out_hwirq+=16;++*out_type=intspec[2]&IRQ_TYPE_SENSE_MASK;+return0;+}++structirq_domain_opsgic_irq_domain_ops={+.dt_translate=gic_irq_domain_dt_translate,+};++int__initgic_of_init(structdevice_node*node,structdevice_node*parent)+{+void__iomem*cpu_base;+void__iomem*dist_base;+intirq;+structirq_domain*domain=&gic_data[gic_cnt].domain;++if(WARN_ON(!node))+return-ENODEV;++dist_base=of_iomap(node,0);+WARN(!dist_base,"unable to map gic dist registers\n");++cpu_base=of_iomap(node,1);+WARN(!cpu_base,"unable to map gic cpu registers\n");++domain->nr_irq=gic_irq_count(dist_base);+/* subtract off SGIs. Also subtract off PPIs for secondary GICs */+if(parent)+domain->nr_irq-=32;+else+domain->nr_irq-=16;++domain->irq_base=irq_alloc_descs(-1,16,domain->nr_irq,numa_node_id());+domain->of_node=of_node_get(node);+domain->ops=&gic_irq_domain_ops;+domain->priv=&gic_data[gic_cnt];+irq_domain_add(domain);++gic_init(gic_cnt,domain->irq_base,dist_base,cpu_base);++if(parent){+irq=irq_of_parse_and_map(node,0);+gic_cascade_irq(gic_cnt,irq);+}+gic_cnt++;+return0;+}+#endif
@@ -0,0 +1,55 @@+* ARM Generic Interrupt Controller++ARM SMP cores are often associated with a GIC, providing per processor+interrupts (PPI), shared processor interrupts (SPI) and software+generated interrupts (SGI).++Primary GIC is attached directly to the CPU and typically has PPIs and SGIs.+Secondary GICs are cascaded into the upward interrupt controller and do not+have PPIs or SGIs.++Main node required properties:++- compatible : should be one of:+ "arm,cortex-a9-gic"+ "arm,arm11mp-gic"+- interrupt-controller : Identifies the node as an interrupt controller+- #interrupt-cells : Specifies the number of cells needed to encode an+ interrupt source. The type shall be a <u32> and the value shall be 3.++ The 1st cell is the interrupt type; 0 for SPI interrupts, 1 for PPI+ interrupts.++ The 2nd cell contains the interrupt number for the interrupt type.+ SPI interrupts are in the range [0-987]. PPI interrupts are in the+ range [0-15].++ The 3rd cell is the flags, encoded as follows:+ bits[3:0] trigger type and level flags.+ 1 = low-to-high edge triggered+ 2 = high-to-low edge triggered+ 4 = active high level-sensitive+ 8 = active low level-sensitive+ bits[15:8] PPI interrupt cpu mask. Each bit corresponds to each of+ the 8 possible cpus attached to the GIC. A bit set to '1' indicated+ the interrupt is wired to that CPU. Only valid for PPI interrupts.++- reg : Specifies base physical address(s) and size of the GIC registers. The+ first region is the GIC distributor register base and size. The 2nd region is+ the GIC cpu interface register base and size.++Optional+- interrupts : Interrupt source of the parent interrupt controller. Only+ present on secondary GICs.++Example:++ intc: interrupt-controller at fff11000 {+ compatible = "arm,cortex-a9-gic";+ #interrupt-cells = <3>;+ #address-cells = <1>;+ interrupt-controller;+ reg = <0xfff11000 0x1000>,+ <0xfff10100 0x100>;+ };+
I though that the offset was 32 to get from SPI number to Interrrupt
ID? And that PPI interrupts start at Interrupt ID 16? Or am I
mistaken about the hwirq number that this driver uses internally?
Otherwise, the change looks about right to me.
g.
@@ -0,0 +1,55 @@+* ARM Generic Interrupt Controller++ARM SMP cores are often associated with a GIC, providing per processor+interrupts (PPI), shared processor interrupts (SPI) and software+generated interrupts (SGI).++Primary GIC is attached directly to the CPU and typically has PPIs and SGIs.+Secondary GICs are cascaded into the upward interrupt controller and do not+have PPIs or SGIs.++Main node required properties:++- compatible : should be one of:+ "arm,cortex-a9-gic"+ "arm,arm11mp-gic"+- interrupt-controller : Identifies the node as an interrupt controller+- #interrupt-cells : Specifies the number of cells needed to encode an+ interrupt source. The type shall be a <u32> and the value shall be 3.++ The 1st cell is the interrupt type; 0 for SPI interrupts, 1 for PPI+ interrupts.++ The 2nd cell contains the interrupt number for the interrupt type.+ SPI interrupts are in the range [0-987]. PPI interrupts are in the+ range [0-15].++ The 3rd cell is the flags, encoded as follows:+ bits[3:0] trigger type and level flags.+ 1 = low-to-high edge triggered+ 2 = high-to-low edge triggered+ 4 = active high level-sensitive+ 8 = active low level-sensitive+ bits[15:8] PPI interrupt cpu mask. Each bit corresponds to each of+ the 8 possible cpus attached to the GIC. A bit set to '1' indicated+ the interrupt is wired to that CPU. Only valid for PPI interrupts.++- reg : Specifies base physical address(s) and size of the GIC registers. The+ first region is the GIC distributor register base and size. The 2nd region is+ the GIC cpu interface register base and size.++Optional+- interrupts : Interrupt source of the parent interrupt controller. Only+ present on secondary GICs.++Example:++ intc: interrupt-controller at fff11000 {+ compatible = "arm,cortex-a9-gic";+ #interrupt-cells = <3>;+ #address-cells = <1>;+ interrupt-controller;+ reg = <0xfff11000 0x1000>,+ <0xfff10100 0x100>;+ };+
I though that the offset was 32 to get from SPI number to Interrrupt
ID? And that PPI interrupts start at Interrupt ID 16? Or am I
mistaken about the hwirq number that this driver uses internally?
There's basically 2 cases to handle: primary and secondary controllers.
For primary ctrlrs, the domain irq_base is already 16 to skip over SGIs
and legacy ISA interrupts. So PPIs don't need any conversion and SPIs
only need 16 more added. I misspoke previously as it's not quite
independent of virq numbering because entry-macro-gic.S is still fixed
GIC ID = Linux virq (or offset of 32 in Exynos case).
For secondary ctrlrs, the gic code already accounts for 32 offset in ID
to Linux virq with the irq_offset field which is set to Linux virq base
- 32. So in this case, no conversion is needed.
I don't really see a better way without breaking non-DT use of the gic.
Rob
Hi Rob,
I'm testing that series with OMAP4 but have some issues for the moment :-(
[ 0.000000] WARNING: at kernel/irq/irqdomain.c:34 gic_of_init+0x10c/0x180()
[ 0.000000] error: irq_desc already assigned to a domain
[ 0.000000] Modules linked in:
[ 0.000000] [<c001b284>] (unwind_backtrace+0x0/0xf0) from [<c0051c34>] (warn_slowpath_common+0x4c/0x64)
[ 0.000000] [<c0051c34>] (warn_slowpath_common+0x4c/0x64) from [<c0051ce0>] (warn_slowpath_fmt+0x30/0x40)
[ 0.000000] [<c0051ce0>] (warn_slowpath_fmt+0x30/0x40) from [<c05f6874>] (gic_of_init+0x10c/0x180)
[ 0.000000] [<c05f6874>] (gic_of_init+0x10c/0x180) from [<c05fa2e0>] (omap_gic_of_init+0x8/0x28)
[ 0.000000] [<c05fa2e0>] (omap_gic_of_init+0x8/0x28) from [<c0616b44>] (of_irq_init+0x148/0x28c)
[ 0.000000] [<c0616b44>] (of_irq_init+0x148/0x28c) from [<c05f3074>] (init_IRQ+0x14/0x1c)
[ 0.000000] [<c05f3074>] (init_IRQ+0x14/0x1c) from [<c05f0650>] (start_kernel+0x184/0x2fc)
[ 0.000000] [<c05f0650>] (start_kernel+0x184/0x2fc) from [<80008040>] (0x80008040)
I'm not super familiar with all the irq stuff but I'm wondering if there is not something wrong with the test that print that message:
void irq_domain_add(struct irq_domain *domain)
{
struct irq_data *d;
int hwirq;
/*
* This assumes that the irq_domain owner has already allocated
* the irq_descs. This block will be removed when support for dynamic
* allocation of irq_descs is added to irq_domain.
*/
for (hwirq = 0; hwirq < domain->nr_irq; hwirq++) {
d = irq_get_irq_data(irq_domain_to_irq(domain, hwirq));
if (d || d->domain) {
/* things are broken; just report, don't clean up */
WARN(1, "error: irq_desc already assigned to a domain");
return;
}
[...]
Is the (d || d->domain) correct? Shouldn't it be (d && d->domain)?
But since that used to work properly, I have some doubt. Moreover the driver will not even get the proper interrupt later...
Do you have any clue?
Thanks,
Benoit
On 9/20/2011 10:24 PM, Rob Herring wrote:
quoted hunk
From: Rob Herring<redacted>
This adds ARM gic interrupt controller initialization using device tree
data.
The initialization function is intended to be called by of_irq_init
function like this:
const static struct of_device_id irq_match[] = {
{ .compatible = "arm,cortex-a9-gic", .data = gic_of_init, },
{}
};
static void __init init_irqs(void)
{
of_irq_init(irq_match);
}
Signed-off-by: Rob Herring<redacted>
---
Documentation/devicetree/bindings/arm/gic.txt | 55 +++++++++++++++
arch/arm/common/gic.c | 89 +++++++++++++++++++++++-
arch/arm/include/asm/hardware/gic.h | 12 ++++
3 files changed, 152 insertions(+), 4 deletions(-)
create mode 100644 Documentation/devicetree/bindings/arm/gic.txt
@@ -0,0 +1,55 @@+* ARM Generic Interrupt Controller++ARM SMP cores are often associated with a GIC, providing per processor+interrupts (PPI), shared processor interrupts (SPI) and software+generated interrupts (SGI).++Primary GIC is attached directly to the CPU and typically has PPIs and SGIs.+Secondary GICs are cascaded into the upward interrupt controller and do not+have PPIs or SGIs.++Main node required properties:++- compatible : should be one of:+ "arm,cortex-a9-gic"+ "arm,arm11mp-gic"+- interrupt-controller : Identifies the node as an interrupt controller+- #interrupt-cells : Specifies the number of cells needed to encode an+ interrupt source. The type shall be a<u32> and the value shall be 3.++ The 1st cell is the interrupt type; 0 for SPI interrupts, 1 for PPI+ interrupts.++ The 2nd cell contains the interrupt number for the interrupt type.+ SPI interrupts are in the range [0-987]. PPI interrupts are in the+ range [0-15].++ The 3rd cell is the flags, encoded as follows:+ bits[3:0] trigger type and level flags.+ 1 = low-to-high edge triggered+ 2 = high-to-low edge triggered+ 4 = active high level-sensitive+ 8 = active low level-sensitive+ bits[15:8] PPI interrupt cpu mask. Each bit corresponds to each of+ the 8 possible cpus attached to the GIC. A bit set to '1' indicated+ the interrupt is wired to that CPU. Only valid for PPI interrupts.++- reg : Specifies base physical address(s) and size of the GIC registers. The+ first region is the GIC distributor register base and size. The 2nd region is+ the GIC cpu interface register base and size.++Optional+- interrupts : Interrupt source of the parent interrupt controller. Only+ present on secondary GICs.++Example:++ intc: interrupt-controller at fff11000 {+ compatible = "arm,cortex-a9-gic";+ #interrupt-cells =<3>;+ #address-cells =<1>;+ interrupt-controller;+ reg =<0xfff11000 0x1000>,+ <0xfff10100 0x100>;+ };+
@@ -405,3 +415,74 @@ void gic_raise_softirq(const struct cpumask *mask, unsigned int irq)writel_relaxed(map<<16|irq,gic_data[0].dist_base+GIC_DIST_SOFTINT);}#endif++#ifdef CONFIG_OF+staticintgic_cnt__initdata=0;++intgic_irq_domain_dt_translate(structirq_domain*d,+structdevice_node*controller,+constu32*intspec,unsignedintintsize,+unsignedlong*out_hwirq,unsignedint*out_type)+{+structgic_chip_data*gic_data=d->priv;++if(d->of_node!=controller)+return-EINVAL;+if(intsize<3)+return-EINVAL;++*out_hwirq=intspec[1];+/*+*We'vealreadyskippedoverSGIs,soPPIsneednotranslation.+*ForSPIs,weneedtoskipover16PPIsonprimaryGICs.+*/+if(!intspec[0]&&!gic_data->irq_offset)+*out_hwirq+=16;++*out_type=intspec[2]&IRQ_TYPE_SENSE_MASK;+return0;+}++structirq_domain_opsgic_irq_domain_ops={+.dt_translate=gic_irq_domain_dt_translate,+};++int__initgic_of_init(structdevice_node*node,structdevice_node*parent)+{+void__iomem*cpu_base;+void__iomem*dist_base;+intirq;+structirq_domain*domain=&gic_data[gic_cnt].domain;++if(WARN_ON(!node))+return-ENODEV;++dist_base=of_iomap(node,0);+WARN(!dist_base,"unable to map gic dist registers\n");++cpu_base=of_iomap(node,1);+WARN(!cpu_base,"unable to map gic cpu registers\n");++domain->nr_irq=gic_irq_count(dist_base);+/* subtract off SGIs. Also subtract off PPIs for secondary GICs */+if(parent)+domain->nr_irq-=32;+else+domain->nr_irq-=16;++domain->irq_base=irq_alloc_descs(-1,16,domain->nr_irq,numa_node_id());+domain->of_node=of_node_get(node);+domain->ops=&gic_irq_domain_ops;+domain->priv=&gic_data[gic_cnt];+irq_domain_add(domain);++gic_init(gic_cnt,domain->irq_base,dist_base,cpu_base);++if(parent){+irq=irq_of_parse_and_map(node,0);+gic_cascade_irq(gic_cnt,irq);+}+gic_cnt++;+return0;+}+#endif
From: Rob Herring <hidden> Date: 2011-09-21 17:56:07
Benoit,
On 09/21/2011 12:15 PM, Cousson, Benoit wrote:
Hi Rob,
I'm testing that series with OMAP4 but have some issues for the moment :-(
[ 0.000000] WARNING: at kernel/irq/irqdomain.c:34 gic_of_init+0x10c/0x180()
[ 0.000000] error: irq_desc already assigned to a domain
[ 0.000000] Modules linked in:
[ 0.000000] [<c001b284>] (unwind_backtrace+0x0/0xf0) from [<c0051c34>] (warn_slowpath_common+0x4c/0x64)
[ 0.000000] [<c0051c34>] (warn_slowpath_common+0x4c/0x64) from [<c0051ce0>] (warn_slowpath_fmt+0x30/0x40)
[ 0.000000] [<c0051ce0>] (warn_slowpath_fmt+0x30/0x40) from [<c05f6874>] (gic_of_init+0x10c/0x180)
[ 0.000000] [<c05f6874>] (gic_of_init+0x10c/0x180) from [<c05fa2e0>] (omap_gic_of_init+0x8/0x28)
[ 0.000000] [<c05fa2e0>] (omap_gic_of_init+0x8/0x28) from [<c0616b44>] (of_irq_init+0x148/0x28c)
[ 0.000000] [<c0616b44>] (of_irq_init+0x148/0x28c) from [<c05f3074>] (init_IRQ+0x14/0x1c)
[ 0.000000] [<c05f3074>] (init_IRQ+0x14/0x1c) from [<c05f0650>] (start_kernel+0x184/0x2fc)
[ 0.000000] [<c05f0650>] (start_kernel+0x184/0x2fc) from [<80008040>] (0x80008040)
I'm not super familiar with all the irq stuff but I'm wondering if there is not something wrong with the test that print that message:
void irq_domain_add(struct irq_domain *domain)
{
struct irq_data *d;
int hwirq;
/*
* This assumes that the irq_domain owner has already allocated
* the irq_descs. This block will be removed when support for dynamic
* allocation of irq_descs is added to irq_domain.
*/
for (hwirq = 0; hwirq < domain->nr_irq; hwirq++) {
d = irq_get_irq_data(irq_domain_to_irq(domain, hwirq));
if (d || d->domain) {
/* things are broken; just report, don't clean up */
WARN(1, "error: irq_desc already assigned to a domain");
return;
}
[...]
Is the (d || d->domain) correct? Shouldn't it be (d && d->domain)?
But since that used to work properly, I have some doubt. Moreover the driver will not even get the proper interrupt later...
Do you have any clue?
I fixed that in the prior series and tglx picked it up, so I did not
repost. It should hit mainline for 3.1, but I haven't verified if it is
in yet. Sorry for the confusion, I should have mentioned that.
Rob
I fixed that in the prior series and tglx picked it up, so I did not
repost. It should hit mainline for 3.1, but I haven't verified if it is
in yet. Sorry for the confusion, I should have mentioned that.
OK, I remember now as well that Thomas took patched 2 patches from your
previous one. And I found it:
https://lkml.org/lkml/2011/9/14/190
Now, I have to find why the twl interrupt-controller is not working
anymore even with that fix.
Almost-Tested-by: Benoit Cousson [off-list ref]
Thanks,
Benoit
I fixed that in the prior series and tglx picked it up, so I did not
repost. It should hit mainline for 3.1, but I haven't verified if it is
in yet. Sorry for the confusion, I should have mentioned that.
OK, I remember now as well that Thomas took patched 2 patches from your
previous one. And I found it:
https://lkml.org/lkml/2011/9/14/190
Now, I have to find why the twl interrupt-controller is not working
anymore even with that fix.
This is much better with the proper #interrupt-cells size:-)
Almost-Tested-by: Benoit Cousson[off-list ref]
Tested-by: Benoit Cousson<redacted>
With a still very limited number of OMAP4 peripherals for the moment.
Regards,
Benoit
Hi Rob,
On Tue, Sep 20, 2011 at 03:24:04PM -0500, Rob Herring wrote:
[...]
+int __init gic_of_init(struct device_node *node, struct device_node *parent)
+{
+ void __iomem *cpu_base;
+ void __iomem *dist_base;
+ int irq;
+ struct irq_domain *domain = &gic_data[gic_cnt].domain;
+
+ if (WARN_ON(!node))
+ return -ENODEV;
+
+ dist_base = of_iomap(node, 0);
+ WARN(!dist_base, "unable to map gic dist registers\n");
+
+ cpu_base = of_iomap(node, 1);
+ WARN(!cpu_base, "unable to map gic cpu registers\n");
+
+ domain->nr_irq = gic_irq_count(dist_base);
+ /* subtract off SGIs. Also subtract off PPIs for secondary GICs */
+ if (parent)
+ domain->nr_irq -= 32;
+ else
+ domain->nr_irq -= 16;
+
+ domain->irq_base = irq_alloc_descs(-1, 16, domain->nr_irq, numa_node_id());
The way I understand irq_alloc_descs() (probably not very well) is that
having the irq parameter < 0 and the from parameter 16 means that it
needs to find domain->nr_irq descs starting from at least 16. But if
the base is greater than 16, does this still work with the gic entry
macros as they are?
Jamie
From: Rob Herring <hidden> Date: 2011-09-26 20:49:17
On 09/26/2011 02:57 PM, Jamie Iles wrote:
Hi Rob,
On Tue, Sep 20, 2011 at 03:24:04PM -0500, Rob Herring wrote:
[...]
quoted
+int __init gic_of_init(struct device_node *node, struct device_node *parent)
+{
+ void __iomem *cpu_base;
+ void __iomem *dist_base;
+ int irq;
+ struct irq_domain *domain = &gic_data[gic_cnt].domain;
+
+ if (WARN_ON(!node))
+ return -ENODEV;
+
+ dist_base = of_iomap(node, 0);
+ WARN(!dist_base, "unable to map gic dist registers\n");
+
+ cpu_base = of_iomap(node, 1);
+ WARN(!cpu_base, "unable to map gic cpu registers\n");
+
+ domain->nr_irq = gic_irq_count(dist_base);
+ /* subtract off SGIs. Also subtract off PPIs for secondary GICs */
+ if (parent)
+ domain->nr_irq -= 32;
+ else
+ domain->nr_irq -= 16;
+
+ domain->irq_base = irq_alloc_descs(-1, 16, domain->nr_irq, numa_node_id());
The way I understand irq_alloc_descs() (probably not very well) is that
having the irq parameter < 0 and the from parameter 16 means that it
needs to find domain->nr_irq descs starting from at least 16. But if
the base is greater than 16, does this still work with the gic entry
macros as they are?
No, but that would only happen if a platform calls irq_alloc_descs prior
to this code. The root controller must be initialized first (for other
reasons as well). There are no calls to irq_alloc_descs in arch/arm.
With the MULTI_IRQ GIC support Marc Z is working on, we could make the
GIC irq mapping be completely dynamic. Although, there's probably not
much reason to do so for the root controller.
Rob
On Mon, Sep 26, 2011 at 03:49:11PM -0500, Rob Herring wrote:
On 09/26/2011 02:57 PM, Jamie Iles wrote:
quoted
Hi Rob,
On Tue, Sep 20, 2011 at 03:24:04PM -0500, Rob Herring wrote:
[...]
quoted
+int __init gic_of_init(struct device_node *node, struct device_node *parent)
+{
+ void __iomem *cpu_base;
+ void __iomem *dist_base;
+ int irq;
+ struct irq_domain *domain = &gic_data[gic_cnt].domain;
+
+ if (WARN_ON(!node))
+ return -ENODEV;
+
+ dist_base = of_iomap(node, 0);
+ WARN(!dist_base, "unable to map gic dist registers\n");
+
+ cpu_base = of_iomap(node, 1);
+ WARN(!cpu_base, "unable to map gic cpu registers\n");
+
+ domain->nr_irq = gic_irq_count(dist_base);
+ /* subtract off SGIs. Also subtract off PPIs for secondary GICs */
+ if (parent)
+ domain->nr_irq -= 32;
+ else
+ domain->nr_irq -= 16;
+
+ domain->irq_base = irq_alloc_descs(-1, 16, domain->nr_irq, numa_node_id());
The way I understand irq_alloc_descs() (probably not very well) is that
having the irq parameter < 0 and the from parameter 16 means that it
needs to find domain->nr_irq descs starting from at least 16. But if
the base is greater than 16, does this still work with the gic entry
macros as they are?
No, but that would only happen if a platform calls irq_alloc_descs prior
to this code. The root controller must be initialized first (for other
reasons as well). There are no calls to irq_alloc_descs in arch/arm.
With the MULTI_IRQ GIC support Marc Z is working on, we could make the
GIC irq mapping be completely dynamic. Although, there's probably not
much reason to do so for the root controller.
OK, that makes sense. I think that if you were to do
irq_alloc_descs(16, 16, domain->nr_irqs, num_node_id()) then that will
guarantee the descriptors start from 16 (if they are available) which is
probably nicer.
Jamie
From: Rob Herring <hidden> Date: 2011-09-26 21:32:23
On 09/26/2011 04:11 PM, Jamie Iles wrote:
On Mon, Sep 26, 2011 at 03:49:11PM -0500, Rob Herring wrote:
quoted
On 09/26/2011 02:57 PM, Jamie Iles wrote:
quoted
Hi Rob,
On Tue, Sep 20, 2011 at 03:24:04PM -0500, Rob Herring wrote:
[...]
quoted
+int __init gic_of_init(struct device_node *node, struct device_node *parent)
+{
+ void __iomem *cpu_base;
+ void __iomem *dist_base;
+ int irq;
+ struct irq_domain *domain = &gic_data[gic_cnt].domain;
+
+ if (WARN_ON(!node))
+ return -ENODEV;
+
+ dist_base = of_iomap(node, 0);
+ WARN(!dist_base, "unable to map gic dist registers\n");
+
+ cpu_base = of_iomap(node, 1);
+ WARN(!cpu_base, "unable to map gic cpu registers\n");
+
+ domain->nr_irq = gic_irq_count(dist_base);
+ /* subtract off SGIs. Also subtract off PPIs for secondary GICs */
+ if (parent)
+ domain->nr_irq -= 32;
+ else
+ domain->nr_irq -= 16;
+
+ domain->irq_base = irq_alloc_descs(-1, 16, domain->nr_irq, numa_node_id());
The way I understand irq_alloc_descs() (probably not very well) is that
having the irq parameter < 0 and the from parameter 16 means that it
needs to find domain->nr_irq descs starting from at least 16. But if
the base is greater than 16, does this still work with the gic entry
macros as they are?
No, but that would only happen if a platform calls irq_alloc_descs prior
to this code. The root controller must be initialized first (for other
reasons as well). There are no calls to irq_alloc_descs in arch/arm.
With the MULTI_IRQ GIC support Marc Z is working on, we could make the
GIC irq mapping be completely dynamic. Although, there's probably not
much reason to do so for the root controller.
OK, that makes sense. I think that if you were to do
irq_alloc_descs(16, 16, domain->nr_irqs, num_node_id()) then that will
guarantee the descriptors start from 16 (if they are available) which is
probably nicer.
That would break secondary GICs though as it would always fail. For
secondary GIC, we skip SGIs and PPIs and allocate the first available
block of irq_desc's.
Rob
On Mon, Sep 26, 2011 at 04:32:17PM -0500, Rob Herring wrote:
On 09/26/2011 04:11 PM, Jamie Iles wrote:
quoted
On Mon, Sep 26, 2011 at 03:49:11PM -0500, Rob Herring wrote:
quoted
On 09/26/2011 02:57 PM, Jamie Iles wrote:
quoted
Hi Rob,
On Tue, Sep 20, 2011 at 03:24:04PM -0500, Rob Herring wrote:
[...]
quoted
+int __init gic_of_init(struct device_node *node, struct device_node *parent)
+{
+ void __iomem *cpu_base;
+ void __iomem *dist_base;
+ int irq;
+ struct irq_domain *domain = &gic_data[gic_cnt].domain;
+
+ if (WARN_ON(!node))
+ return -ENODEV;
+
+ dist_base = of_iomap(node, 0);
+ WARN(!dist_base, "unable to map gic dist registers\n");
+
+ cpu_base = of_iomap(node, 1);
+ WARN(!cpu_base, "unable to map gic cpu registers\n");
+
+ domain->nr_irq = gic_irq_count(dist_base);
+ /* subtract off SGIs. Also subtract off PPIs for secondary GICs */
+ if (parent)
+ domain->nr_irq -= 32;
+ else
+ domain->nr_irq -= 16;
+
+ domain->irq_base = irq_alloc_descs(-1, 16, domain->nr_irq, numa_node_id());
The way I understand irq_alloc_descs() (probably not very well) is that
having the irq parameter < 0 and the from parameter 16 means that it
needs to find domain->nr_irq descs starting from at least 16. But if
the base is greater than 16, does this still work with the gic entry
macros as they are?
No, but that would only happen if a platform calls irq_alloc_descs prior
to this code. The root controller must be initialized first (for other
reasons as well). There are no calls to irq_alloc_descs in arch/arm.
With the MULTI_IRQ GIC support Marc Z is working on, we could make the
GIC irq mapping be completely dynamic. Although, there's probably not
much reason to do so for the root controller.
OK, that makes sense. I think that if you were to do
irq_alloc_descs(16, 16, domain->nr_irqs, num_node_id()) then that will
guarantee the descriptors start from 16 (if they are available) which is
probably nicer.
That would break secondary GICs though as it would always fail. For
secondary GIC, we skip SGIs and PPIs and allocate the first available
block of irq_desc's.
Ahh, OK that makes sense. Thanks for the explanation Rob! That'll
hopefully help me with a common VIC binding.
Jamie
Hi Rob,
Apologies for the noise! One minor comment below.
Jamie
On Tue, Sep 20, 2011 at 03:24:04PM -0500, Rob Herring wrote:
From: Rob Herring <redacted>
This adds ARM gic interrupt controller initialization using device tree
data.
The initialization function is intended to be called by of_irq_init
function like this:
const static struct of_device_id irq_match[] = {
{ .compatible = "arm,cortex-a9-gic", .data = gic_of_init, },
{}
};
static void __init init_irqs(void)
{
of_irq_init(irq_match);
}
Signed-off-by: Rob Herring <redacted>
---
Hopefully, this is the final or near final version of GIC binding support.
Changes from the previous version:
- SPIs and PPIs are numbered starting at 0. Now the gic has it's own irq
domain translate function instead of the simple domain one.
- interrupt cell format has changed based on Grant's proposal.
- Dropped "ARM: gic: allow irq_start to be 0". Instead, the first 16 irqs
are skipped and the domain irq_base adjusted accordingly.
- Added a fix to of_irq_find_parent when the parent == child.
- Renamed intc_desc.parent to intc_desc.interrupt_parent.
- Implemented Grant's algorithm for walking the list of interrupt
controllers. Added a return value to interrupt init functions, so they
don't get added to the parent list on a init failure.
The changes are significant enough that I did not include previous
acked/reviewed/tested-by's.
Just out of curiosity where does this "interrupt-parent" property
come from?
On platforms I am familiar with, the parent path is walked to the root
and we stop at device nodes that have "interrupt-map" and
"interrupt-map-mask" properties.
The map and mask are applied to the "reg" property of the device in
question to see which map entry matches, if a match is found the map
entry contains the translated interrupt.
And this process continues over and over all the way to the root to get
the system interrupt that processor actually deals with.
The mechanism shown here seems overly simplistic and not able to handle
the cases handled by existing OF property schemes in use for several
years on real systems.
Hopefully, this is the final or near final version of GIC binding support.
Changes from the previous version:
- SPIs and PPIs are numbered starting at 0. Now the gic has it's own irq
? domain translate function instead of the simple domain one.
- interrupt cell format has changed based on Grant's proposal.
- Dropped "ARM: gic: allow irq_start to be 0". Instead, the first 16 irqs
? are skipped and the domain irq_base adjusted accordingly.
- Added a fix to of_irq_find_parent when the parent == child.
- Renamed intc_desc.parent to intc_desc.interrupt_parent.
- Implemented Grant's algorithm for walking the list of interrupt
? controllers. Added a return value to interrupt init functions, so they
? don't get added to the parent list on a init failure.
The changes are significant enough that I did not include previous
acked/reviewed/tested-by's.
Just out of curiosity where does this "interrupt-parent" property
come from?
On platforms I am familiar with, the parent path is walked to the root
and we stop at device nodes that have "interrupt-map" and
"interrupt-map-mask" properties.
The map and mask are applied to the "reg" property of the device in
question to see which map entry matches, if a match is found the map
entry contains the translated interrupt.
And this process continues over and over all the way to the root to get
the system interrupt that processor actually deals with.
The mechanism shown here seems overly simplistic and not able to handle
the cases handled by existing OF property schemes in use for several
years on real systems.
interrupt-parent has been implemented for years on powerpc. I don't
know if it was ever an Open Firmware thing, but it is in ePAPR [1],
and ARM isn't doing anything novel in that regard.
[1] section 2.4, page 30,
https://www.power.org/resources/downloads/Power_ePAPR_APPROVED_v1.1.pdf
It is true that is cannot handle all situations, but for those
interrupt-map is still available.
g.
On Tue, Sep 20, 2011 at 8:49 PM, David Miller[off-list ref] wrote:
quoted
From: Rob Herring<redacted>
Date: Tue, 20 Sep 2011 15:24:01 -0500
quoted
Hopefully, this is the final or near final version of GIC binding support.
Changes from the previous version:
- SPIs and PPIs are numbered starting at 0. Now the gic has it's own irq
domain translate function instead of the simple domain one.
- interrupt cell format has changed based on Grant's proposal.
- Dropped "ARM: gic: allow irq_start to be 0". Instead, the first 16 irqs
are skipped and the domain irq_base adjusted accordingly.
- Added a fix to of_irq_find_parent when the parent == child.
- Renamed intc_desc.parent to intc_desc.interrupt_parent.
- Implemented Grant's algorithm for walking the list of interrupt
controllers. Added a return value to interrupt init functions, so they
don't get added to the parent list on a init failure.
The changes are significant enough that I did not include previous
acked/reviewed/tested-by's.
Just out of curiosity where does this "interrupt-parent" property
come from?
On platforms I am familiar with, the parent path is walked to the root
and we stop at device nodes that have "interrupt-map" and
"interrupt-map-mask" properties.
The map and mask are applied to the "reg" property of the device in
question to see which map entry matches, if a match is found the map
entry contains the translated interrupt.
And this process continues over and over all the way to the root to get
the system interrupt that processor actually deals with.
The mechanism shown here seems overly simplistic and not able to handle
the cases handled by existing OF property schemes in use for several
years on real systems.
interrupt-parent has been implemented for years on powerpc. I don't
know if it was ever an Open Firmware thing, but it is in ePAPR [1],
and ARM isn't doing anything novel in that regard.
Thanks for the link.
In my vast collection of Sun OF dumps, I cannot find a single instance
where they've made use of this property, which is why I've never seen
it before.
Thanks for the link.
In my vast collection of Sun OF dumps, I cannot find a single instance
where they've made use of this property, which is why I've never seen
it before.
I can't say I'm surprised at that. Sun hardware tends to be rather more
hierarchical than is the norm in, for example, the PC space. This
particular document came into being during the CHRP era, when IBM and
Apple were trying to glue a Macintosh legacy I/O system onto the side of
a PC legacy I/O system. The result was not pretty.
Sun had at least the semblance of a coherent architectural design and
review process.
Just out of curiosity where does this "interrupt-parent" property
come from?
On platforms I am familiar with, the parent path is walked to the root
and we stop at device nodes that have "interrupt-map" and
"interrupt-map-mask" properties.
"interrupt-parent" is defined in the Open Firmware "interrupt mapping"
recommended practice, the same place as "interrupt-map" etc. are.
The mechanism shown here seems overly simplistic and not able to
handle
the cases handled by existing OF property schemes in use for several
years on real systems.
"interrupt-parent" is only meant to be used for the simple cases. It's
quite handy there. It is also required in all "interrupt-controller"
nodes that aren't the root of the interrupt tree.
Segher
On Tue, Sep 20, 2011 at 03:24:01PM -0500, Rob Herring wrote:
From: Rob Herring <redacted>
Hopefully, this is the final or near final version of GIC binding support.
Changes from the previous version:
- SPIs and PPIs are numbered starting at 0. Now the gic has it's own irq
domain translate function instead of the simple domain one.
- interrupt cell format has changed based on Grant's proposal.
- Dropped "ARM: gic: allow irq_start to be 0". Instead, the first 16 irqs
are skipped and the domain irq_base adjusted accordingly.
- Added a fix to of_irq_find_parent when the parent == child.
- Renamed intc_desc.parent to intc_desc.interrupt_parent.
- Implemented Grant's algorithm for walking the list of interrupt
controllers. Added a return value to interrupt init functions, so they
don't get added to the parent list on a init failure.
The changes are significant enough that I did not include previous
acked/reviewed/tested-by's.
You can add mine back. On imx6q:
Tested-by: Shawn Guo <redacted>
Hopefully, this is the last round of binding scheme change. There are
63 nodes in imx6q dts with 'interrupts' property. I have changed them
3 times :)
--
Regards,
Shawn