All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
To: Ezequiel Garcia
	<ezequiel-30ULvvUtt6G51wMPkGsGjgyUoB5FGQPZ@public.gmane.org>
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>,
	Thierry Reding
	<thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Subject: Re: I2C OF IRQ parsing issue due to probe ordering
Date: Thu, 30 Oct 2014 14:15:43 +0200	[thread overview]
Message-ID: <15051800.BQpGCgk7GR@avalon> (raw)
In-Reply-To: <545227E4.5070507-30ULvvUtt6G51wMPkGsGjgyUoB5FGQPZ@public.gmane.org>

Hi Ezequiel,

On Thursday 30 October 2014 08:58:28 Ezequiel Garcia wrote:
> On 10/25/2014 07:13 PM, Laurent Pinchart wrote:
> > Hello,
> > 
> > I recently ran into an issue with the OF IRQ parsing code in the I2C core
> > (of_i2c_register_devices in drivers/i2c/i2c-core.c).
> > 
> > My DT contains the following nodes.
> > 
> >         gpio1: gpio@e6051000 {
> >                 ...
> >                 #interrupt-cells = <2>;
> >                 interrupt-controller;
> >                 clocks = <&mstp9_clks R8A7790_CLK_GPIO1>;
> >         };
> >         
> >         iic2: i2c@e6520000 {
> >                 #address-cells = <1>;
> >                 #size-cells = <0>;
> >                 ...
> >                 hdmi@39 {
> >                         compatible = "adi,adv7511w";
> >                         reg = <0x39>;
> >                         interrupt-parent = <&gpio1>;
> >                         interrupts = <15 IRQ_TYPE_EDGE_FALLING>;
> >                         ...
> >                 };
> >         };
> >         
> >         mstp9_clks: mstp9_clks@e6150994 {
> >                 ...
> >         };
> > 
> > The i2c@e6520000 node is probed before the gpio@e6051000 node. The
> > of_i2c_register_devices() function tries to register all children,
> > including hdmi@39. It tries to parse and map the I2C client IRQ by
> > calling irq_of_parse_and_map(), which returns 0 as the interrupt
> > controller isn't probed yet. The adv7511 driver later probes the hdmi@39
> > device and gets client->irq set to 0.
> > 
> > We can't control the probe order.
> 
> Maybe I'm missing something, but I think your i2c adapter is probed with
> a subsys_initcall (as many other adapters). Otherwise, I can't see why
> it would be probed before the the gpio controller.
> 
> I think this initcall is your problem. Have you tried just using
> platform_driver's probe?

My I2C controller driver uses module_platform_driver(). The reason why the 
GPIO controller is probed later is because the GPIO requires a clock, and the 
clock device is probed after the I2C controller, resulting in a deferred 
probing the first time the GPIO controller is probed.

In the general case probe ordering can't be controlled, especially with DT. I 
believe we thus need a generic solution.

-- 
Regards,

Laurent Pinchart

WARNING: multiple messages have this Message-ID (diff)
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-gpio@vger.kernel.org, Wolfram Sang <wsa@the-dreams.de>,
	Thierry Reding <thierry.reding@gmail.com>
Subject: Re: I2C OF IRQ parsing issue due to probe ordering
Date: Thu, 30 Oct 2014 14:15:43 +0200	[thread overview]
Message-ID: <15051800.BQpGCgk7GR@avalon> (raw)
In-Reply-To: <545227E4.5070507@vanguardiasur.com.ar>

Hi Ezequiel,

On Thursday 30 October 2014 08:58:28 Ezequiel Garcia wrote:
> On 10/25/2014 07:13 PM, Laurent Pinchart wrote:
> > Hello,
> > 
> > I recently ran into an issue with the OF IRQ parsing code in the I2C core
> > (of_i2c_register_devices in drivers/i2c/i2c-core.c).
> > 
> > My DT contains the following nodes.
> > 
> >         gpio1: gpio@e6051000 {
> >                 ...
> >                 #interrupt-cells = <2>;
> >                 interrupt-controller;
> >                 clocks = <&mstp9_clks R8A7790_CLK_GPIO1>;
> >         };
> >         
> >         iic2: i2c@e6520000 {
> >                 #address-cells = <1>;
> >                 #size-cells = <0>;
> >                 ...
> >                 hdmi@39 {
> >                         compatible = "adi,adv7511w";
> >                         reg = <0x39>;
> >                         interrupt-parent = <&gpio1>;
> >                         interrupts = <15 IRQ_TYPE_EDGE_FALLING>;
> >                         ...
> >                 };
> >         };
> >         
> >         mstp9_clks: mstp9_clks@e6150994 {
> >                 ...
> >         };
> > 
> > The i2c@e6520000 node is probed before the gpio@e6051000 node. The
> > of_i2c_register_devices() function tries to register all children,
> > including hdmi@39. It tries to parse and map the I2C client IRQ by
> > calling irq_of_parse_and_map(), which returns 0 as the interrupt
> > controller isn't probed yet. The adv7511 driver later probes the hdmi@39
> > device and gets client->irq set to 0.
> > 
> > We can't control the probe order.
> 
> Maybe I'm missing something, but I think your i2c adapter is probed with
> a subsys_initcall (as many other adapters). Otherwise, I can't see why
> it would be probed before the the gpio controller.
> 
> I think this initcall is your problem. Have you tried just using
> platform_driver's probe?

My I2C controller driver uses module_platform_driver(). The reason why the 
GPIO controller is probed later is because the GPIO requires a clock, and the 
clock device is probed after the I2C controller, resulting in a deferred 
probing the first time the GPIO controller is probed.

In the general case probe ordering can't be controlled, especially with DT. I 
believe we thus need a generic solution.

-- 
Regards,

Laurent Pinchart


  parent reply	other threads:[~2014-10-30 12:15 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-25 22:13 I2C OF IRQ parsing issue due to probe ordering Laurent Pinchart
2014-10-27 12:58 ` Wolfram Sang
2014-10-27 12:58   ` Wolfram Sang
2014-10-30 12:53   ` Laurent Pinchart
2014-10-30 13:02     ` Thierry Reding
2014-10-30 13:12       ` Laurent Pinchart
2014-10-30 12:56   ` Thierry Reding
2014-10-30 13:05     ` Laurent Pinchart
2014-10-30 13:21       ` Wolfram Sang
2014-10-30 13:22         ` Laurent Pinchart
2014-10-30 13:43           ` Thierry Reding
2014-10-30 11:58 ` Ezequiel Garcia
2014-10-30 11:58   ` Ezequiel Garcia
     [not found]   ` <545227E4.5070507-30ULvvUtt6G51wMPkGsGjgyUoB5FGQPZ@public.gmane.org>
2014-10-30 12:15     ` Laurent Pinchart [this message]
2014-10-30 12:15       ` Laurent Pinchart

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=15051800.BQpGCgk7GR@avalon \
    --to=laurent.pinchart-rylnwiuwjnjg/c1bvhzhaw@public.gmane.org \
    --cc=ezequiel-30ULvvUtt6G51wMPkGsGjgyUoB5FGQPZ@public.gmane.org \
    --cc=linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.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.