All of lore.kernel.org
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely@secretlab.ca>
To: Rob Herring <robherring2@gmail.com>,
	Ben Herrenschmidt <benh@kernel.crashing.org>
Cc: linux-arm-kernel@lists.infradead.org,
	devicetree-discuss@lists.ozlabs.org,
	linux-kernel@vger.kernel.org, marc.zyngier@arm.com,
	thomas.abraham@linaro.org, jamie@jamieiles.com, b-cousson@ti.com,
	shawn.guo@linaro.org, dave.martin@linaro.org,
	linux@arm.linux.org.uk, Rob Herring <rob.herring@calxeda.com>
Subject: Re: [PATCH 1/3] of/irq: of_irq_find_parent: check for parent equal to child
Date: Tue, 20 Sep 2011 15:01:01 -0600	[thread overview]
Message-ID: <20110920210101.GP7781@ponder.secretlab.ca> (raw)
In-Reply-To: <1316550244-3655-2-git-send-email-robherring2@gmail.com>

On Tue, Sep 20, 2011 at 03:24:02PM -0500, Rob Herring wrote:
> From: Rob Herring <rob.herring@calxeda.com>
> 
> 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 <rob.herring@calxeda.com>
> Cc: Grant Likely <grant.likely@secretlab.ca>

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.

> ---
>  drivers/of/irq.c |   14 +++++++-------
>  1 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/of/irq.c b/drivers/of/irq.c
> index 9f689f1..6a5b5e7 100644
> --- a/drivers/of/irq.c
> +++ b/drivers/of/irq.c
> @@ -58,27 +58,27 @@ EXPORT_SYMBOL_GPL(irq_of_parse_and_map);
>   */
>  struct device_node *of_irq_find_parent(struct device_node *child)
>  {
> -	struct device_node *p;
> +	struct device_node *p, *c = child;
>  	const __be32 *parp;
>  
> -	if (!of_node_get(child))
> +	if (!of_node_get(c))
>  		return NULL;
>  
>  	do {
> -		parp = of_get_property(child, "interrupt-parent", NULL);
> +		parp = of_get_property(c, "interrupt-parent", NULL);
>  		if (parp == NULL)
> -			p = of_get_parent(child);
> +			p = of_get_parent(c);
>  		else {
>  			if (of_irq_workarounds & OF_IMAP_NO_PHANDLE)
>  				p = of_node_get(of_irq_dflt_pic);
>  			else
>  				p = of_find_node_by_phandle(be32_to_cpup(parp));
>  		}
> -		of_node_put(child);
> -		child = p;
> +		of_node_put(c);
> +		c = p;
>  	} while (p && of_get_property(p, "#interrupt-cells", NULL) == NULL);
>  
> -	return p;
> +	return (p == child) ? NULL : p;
>  }
>  
>  /**
> -- 
> 1.7.5.4
> 

WARNING: multiple messages have this Message-ID (diff)
From: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
To: Rob Herring <robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Ben Herrenschmidt
	<benh-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org>
Cc: dave.martin-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
	linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: Re: [PATCH 1/3] of/irq: of_irq_find_parent: check for parent equal to child
Date: Tue, 20 Sep 2011 15:01:01 -0600	[thread overview]
Message-ID: <20110920210101.GP7781@ponder.secretlab.ca> (raw)
In-Reply-To: <1316550244-3655-2-git-send-email-robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

On Tue, Sep 20, 2011 at 03:24:02PM -0500, Rob Herring wrote:
> From: Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>
> 
> 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 <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>
> Cc: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>

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.

> ---
>  drivers/of/irq.c |   14 +++++++-------
>  1 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/of/irq.c b/drivers/of/irq.c
> index 9f689f1..6a5b5e7 100644
> --- a/drivers/of/irq.c
> +++ b/drivers/of/irq.c
> @@ -58,27 +58,27 @@ EXPORT_SYMBOL_GPL(irq_of_parse_and_map);
>   */
>  struct device_node *of_irq_find_parent(struct device_node *child)
>  {
> -	struct device_node *p;
> +	struct device_node *p, *c = child;
>  	const __be32 *parp;
>  
> -	if (!of_node_get(child))
> +	if (!of_node_get(c))
>  		return NULL;
>  
>  	do {
> -		parp = of_get_property(child, "interrupt-parent", NULL);
> +		parp = of_get_property(c, "interrupt-parent", NULL);
>  		if (parp == NULL)
> -			p = of_get_parent(child);
> +			p = of_get_parent(c);
>  		else {
>  			if (of_irq_workarounds & OF_IMAP_NO_PHANDLE)
>  				p = of_node_get(of_irq_dflt_pic);
>  			else
>  				p = of_find_node_by_phandle(be32_to_cpup(parp));
>  		}
> -		of_node_put(child);
> -		child = p;
> +		of_node_put(c);
> +		c = p;
>  	} while (p && of_get_property(p, "#interrupt-cells", NULL) == NULL);
>  
> -	return p;
> +	return (p == child) ? NULL : p;
>  }
>  
>  /**
> -- 
> 1.7.5.4
> 

WARNING: multiple messages have this Message-ID (diff)
From: grant.likely@secretlab.ca (Grant Likely)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/3] of/irq: of_irq_find_parent: check for parent equal to child
Date: Tue, 20 Sep 2011 15:01:01 -0600	[thread overview]
Message-ID: <20110920210101.GP7781@ponder.secretlab.ca> (raw)
In-Reply-To: <1316550244-3655-2-git-send-email-robherring2@gmail.com>

On Tue, Sep 20, 2011 at 03:24:02PM -0500, Rob Herring wrote:
> From: Rob Herring <rob.herring@calxeda.com>
> 
> 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 <rob.herring@calxeda.com>
> Cc: Grant Likely <grant.likely@secretlab.ca>

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.

> ---
>  drivers/of/irq.c |   14 +++++++-------
>  1 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/of/irq.c b/drivers/of/irq.c
> index 9f689f1..6a5b5e7 100644
> --- a/drivers/of/irq.c
> +++ b/drivers/of/irq.c
> @@ -58,27 +58,27 @@ EXPORT_SYMBOL_GPL(irq_of_parse_and_map);
>   */
>  struct device_node *of_irq_find_parent(struct device_node *child)
>  {
> -	struct device_node *p;
> +	struct device_node *p, *c = child;
>  	const __be32 *parp;
>  
> -	if (!of_node_get(child))
> +	if (!of_node_get(c))
>  		return NULL;
>  
>  	do {
> -		parp = of_get_property(child, "interrupt-parent", NULL);
> +		parp = of_get_property(c, "interrupt-parent", NULL);
>  		if (parp == NULL)
> -			p = of_get_parent(child);
> +			p = of_get_parent(c);
>  		else {
>  			if (of_irq_workarounds & OF_IMAP_NO_PHANDLE)
>  				p = of_node_get(of_irq_dflt_pic);
>  			else
>  				p = of_find_node_by_phandle(be32_to_cpup(parp));
>  		}
> -		of_node_put(child);
> -		child = p;
> +		of_node_put(c);
> +		c = p;
>  	} while (p && of_get_property(p, "#interrupt-cells", NULL) == NULL);
>  
> -	return p;
> +	return (p == child) ? NULL : p;
>  }
>  
>  /**
> -- 
> 1.7.5.4
> 

  reply	other threads:[~2011-09-20 21:01 UTC|newest]

Thread overview: 92+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-20 20:24 [PATCH 0/3] GIC OF bindings Rob Herring
2011-09-20 20:24 ` Rob Herring
2011-09-20 20:24 ` Rob Herring
2011-09-20 20:24 ` [PATCH 1/3] of/irq: of_irq_find_parent: check for parent equal to child Rob Herring
2011-09-20 20:24   ` Rob Herring
2011-09-20 20:24   ` Rob Herring
2011-09-20 21:01   ` Grant Likely [this message]
2011-09-20 21:01     ` Grant Likely
2011-09-20 21:01     ` Grant Likely
2011-09-20 20:24 ` [PATCH 2/3] of/irq: introduce of_irq_init Rob Herring
2011-09-20 20:24   ` Rob Herring
2011-09-20 20:24   ` Rob Herring
2011-09-20 23:00   ` Grant Likely
2011-09-20 23:00     ` Grant Likely
2011-09-21 10:01   ` Jamie Iles
2011-09-21 10:01     ` Jamie Iles
2011-09-21 10:01     ` Jamie Iles
2011-09-23  2:21   ` [PATCH v3] " Rob Herring
2011-09-23  2:21     ` Rob Herring
2011-09-23  2:21     ` Rob Herring
2011-09-23  5:14     ` Grant Likely
2011-09-23  5:14       ` Grant Likely
2011-09-23  5:14       ` Grant Likely
2011-09-26 19:24     ` [PATCH v4] " Rob Herring
2011-09-26 19:24       ` Rob Herring
2011-09-26 19:24       ` Rob Herring
2011-09-27  1:53       ` Grant Likely
2011-09-27  1:53         ` Grant Likely
2011-09-27  1:53         ` Grant Likely
2011-09-27 13:03         ` Rob Herring
2011-09-27 13:03           ` Rob Herring
2011-09-27 13:03           ` Rob Herring
2011-09-27 21:24           ` Grant Likely
2011-09-27 21:24             ` Grant Likely
2011-09-20 20:24 ` [PATCH 3/3] ARM: gic: add OF based initialization Rob Herring
2011-09-20 20:24   ` Rob Herring
2011-09-20 20:24   ` Rob Herring
2011-09-20 23:08   ` Grant Likely
2011-09-20 23:08     ` Grant Likely
2011-09-20 23:08     ` Grant Likely
2011-09-21  1:54     ` Rob Herring
2011-09-21  1:54       ` Rob Herring
2011-09-21  1:54       ` Rob Herring
2011-09-21 17:15   ` Cousson, Benoit
2011-09-21 17:15     ` Cousson, Benoit
2011-09-21 17:15     ` Cousson, Benoit
2011-09-21 17:55     ` Rob Herring
2011-09-21 17:55       ` Rob Herring
2011-09-21 17:55       ` Rob Herring
2011-09-21 19:28       ` Cousson, Benoit
2011-09-21 19:28         ` Cousson, Benoit
2011-09-21 19:28         ` Cousson, Benoit
2011-09-21 20:27         ` Cousson, Benoit
2011-09-21 20:27           ` Cousson, Benoit
2011-09-21 20:27           ` Cousson, Benoit
2011-09-26 19:57   ` Jamie Iles
2011-09-26 19:57     ` Jamie Iles
2011-09-26 19:57     ` Jamie Iles
2011-09-26 20:49     ` Rob Herring
2011-09-26 20:49       ` Rob Herring
2011-09-26 20:49       ` Rob Herring
2011-09-26 21:11       ` Jamie Iles
2011-09-26 21:11         ` Jamie Iles
2011-09-26 21:11         ` Jamie Iles
2011-09-26 21:32         ` Rob Herring
2011-09-26 21:32           ` Rob Herring
2011-09-26 21:32           ` Rob Herring
2011-09-26 22:00           ` Jamie Iles
2011-09-26 22:00             ` Jamie Iles
2011-09-26 22:29   ` Jamie Iles
2011-09-26 22:29     ` Jamie Iles
2011-09-26 22:29     ` Jamie Iles
2011-09-21  2:49 ` [PATCH 0/3] GIC OF bindings David Miller
2011-09-21  2:49   ` David Miller
2011-09-21  2:49   ` David Miller
2011-09-21  4:14   ` Grant Likely
2011-09-21  4:14     ` Grant Likely
2011-09-21  4:58     ` Mitch Bradley
2011-09-21  4:58       ` Mitch Bradley
2011-09-21  4:58       ` Mitch Bradley
2011-09-21  5:21       ` David Miller
2011-09-21  5:21         ` David Miller
2011-09-21  5:21         ` David Miller
2011-09-21  7:11         ` Mitch Bradley
2011-09-21  7:11           ` Mitch Bradley
2011-09-21  7:11           ` Mitch Bradley
2011-09-21  5:16   ` Segher Boessenkool
2011-09-21  5:16     ` Segher Boessenkool
2011-09-21  5:16     ` Segher Boessenkool
2011-09-21  9:43 ` Shawn Guo
2011-09-21  9:43   ` Shawn Guo
2011-09-21  9:43   ` Shawn Guo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110920210101.GP7781@ponder.secretlab.ca \
    --to=grant.likely@secretlab.ca \
    --cc=b-cousson@ti.com \
    --cc=benh@kernel.crashing.org \
    --cc=dave.martin@linaro.org \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=jamie@jamieiles.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=marc.zyngier@arm.com \
    --cc=rob.herring@calxeda.com \
    --cc=robherring2@gmail.com \
    --cc=shawn.guo@linaro.org \
    --cc=thomas.abraham@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.