diff mbox

[U-Boot] RFC: tegra: Avoid using I2C prior to relocation

Message ID 1375854747-3621-1-git-send-email-sjg@chromium.org
State Accepted
Delegated to: Tom Rini
Headers show

Commit Message

Simon Glass Aug. 7, 2013, 5:52 a.m. UTC
Tegra recently moved to the new I2C framework, which sets up I2C prior to
relocation, and prior to calling i2c_init_board(). This causes a crash on
Tegra boards.

note:

There are many ways to fix this. I believe this is one. It disables i2c_init()
until relocation is complete. I have been unable to test it so far due to
problems getting my Seaboard to work. I will try another Tegra board, but
send this for comment in the meantime.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
 drivers/i2c/tegra_i2c.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Stephen Warren Aug. 7, 2013, 4:20 p.m. UTC | #1
On 08/06/2013 11:52 PM, Simon Glass wrote:
> Tegra recently moved to the new I2C framework, which sets up I2C prior to
> relocation, and prior to calling i2c_init_board(). This causes a crash on
> Tegra boards.
> 
> note:
> 
> There are many ways to fix this. I believe this is one. It disables i2c_init()
> until relocation is complete. I have been unable to test it so far due to
> problems getting my Seaboard to work. I will try another Tegra board, but
> send this for comment in the meantime.

Tested-by: Stephen Warren <swarren@nvidia.com>

(On Beaver and Dalmore, tested booting to U-Boot command prompt followed
by "i2c dev 0; i2c probe")

Note: I believe this is an enormous hack that hacks around the problem
of dynamic device initialization just not being well thought out
relative to the restrictions of U-Boot's various boot stages. I'd still
prefer an outright revert of the broken code.

In other words, tegra_i2c_init() simply shouldn't be called at the wrong
time; it shouldn't have to handle being called at the wrong time and
null itself out when that happens.

However, if this is what it takes to get U-Boot working again, then
let's apply it ASAP.
Simon Glass Aug. 7, 2013, 9:03 p.m. UTC | #2
Hi Stephen,

On Wed, Aug 7, 2013 at 10:20 AM, Stephen Warren <swarren@wwwdotorg.org>wrote:

> On 08/06/2013 11:52 PM, Simon Glass wrote:
> > Tegra recently moved to the new I2C framework, which sets up I2C prior to
> > relocation, and prior to calling i2c_init_board(). This causes a crash on
> > Tegra boards.
> >
> > note:
> >
> > There are many ways to fix this. I believe this is one. It disables
> i2c_init()
> > until relocation is complete. I have been unable to test it so far due to
> > problems getting my Seaboard to work. I will try another Tegra board, but
> > send this for comment in the meantime.
>
> Tested-by: Stephen Warren <swarren@nvidia.com>
>
> (On Beaver and Dalmore, tested booting to U-Boot command prompt followed
> by "i2c dev 0; i2c probe")
>
> Note: I believe this is an enormous hack that hacks around the problem
> of dynamic device initialization just not being well thought out
> relative to the restrictions of U-Boot's various boot stages. I'd still
> prefer an outright revert of the broken code.
>
> In other words, tegra_i2c_init() simply shouldn't be called at the wrong
> time; it shouldn't have to handle being called at the wrong time and
> null itself out when that happens.
>
> However, if this is what it takes to get U-Boot working again, then
> let's apply it ASAP.
>

Fair enough.

Restricting my comments to I2C only, I think that we could have (at least
until driver model happens) an I2C init for each driver (in this case it is
i2c_init_board() that is called by the I2C subsystem twice during init
(once from board_init_f() and once from board_init_r()). The i2c_init()
call is odd because it does an init of a single I2C bus, which isn't really
necessary for most hardware. But I'm not sure it is worth worrying about
this until we have driver model.

Regards,
Simon
Stephen Warren Aug. 9, 2013, 11:17 p.m. UTC | #3
On 08/07/2013 10:20 AM, Stephen Warren wrote:
> On 08/06/2013 11:52 PM, Simon Glass wrote:
>> Tegra recently moved to the new I2C framework, which sets up I2C prior to
>> relocation, and prior to calling i2c_init_board(). This causes a crash on
>> Tegra boards.
>>
>> note:
>>
>> There are many ways to fix this. I believe this is one. It disables i2c_init()
>> until relocation is complete. I have been unable to test it so far due to
>> problems getting my Seaboard to work. I will try another Tegra board, but
>> send this for comment in the meantime.
> 
> Tested-by: Stephen Warren <swarren@nvidia.com>
> 
> (On Beaver and Dalmore, tested booting to U-Boot command prompt followed
> by "i2c dev 0; i2c probe")
> 
> Note: I believe this is an enormous hack that hacks around the problem
> of dynamic device initialization just not being well thought out
> relative to the restrictions of U-Boot's various boot stages. I'd still
> prefer an outright revert of the broken code.
> 
> In other words, tegra_i2c_init() simply shouldn't be called at the wrong
> time; it shouldn't have to handle being called at the wrong time and
> null itself out when that happens.
> 
> However, if this is what it takes to get U-Boot working again, then
> let's apply it ASAP.

This doesn't seem to have been applied yet. Are you expecting this to go
through the main U-boot Tree, I2C tree, or Tegra tree? I just noticed
that you only CC'd the Tegra maintainer...
Simon Glass Aug. 10, 2013, 4:03 a.m. UTC | #4
+Tom Rini

Hi Stephen,

On Fri, Aug 9, 2013 at 5:17 PM, Stephen Warren <swarren@wwwdotorg.org>wrote:

> On 08/07/2013 10:20 AM, Stephen Warren wrote:
> > On 08/06/2013 11:52 PM, Simon Glass wrote:
> >> Tegra recently moved to the new I2C framework, which sets up I2C prior
> to
> >> relocation, and prior to calling i2c_init_board(). This causes a crash
> on
> >> Tegra boards.
> >>
> >> note:
> >>
> >> There are many ways to fix this. I believe this is one. It disables
> i2c_init()
> >> until relocation is complete. I have been unable to test it so far due
> to
> >> problems getting my Seaboard to work. I will try another Tegra board,
> but
> >> send this for comment in the meantime.
> >
> > Tested-by: Stephen Warren <swarren@nvidia.com>
> >
> > (On Beaver and Dalmore, tested booting to U-Boot command prompt followed
> > by "i2c dev 0; i2c probe")
> >
> > Note: I believe this is an enormous hack that hacks around the problem
> > of dynamic device initialization just not being well thought out
> > relative to the restrictions of U-Boot's various boot stages. I'd still
> > prefer an outright revert of the broken code.
> >
> > In other words, tegra_i2c_init() simply shouldn't be called at the wrong
> > time; it shouldn't have to handle being called at the wrong time and
> > null itself out when that happens.
> >
> > However, if this is what it takes to get U-Boot working again, then
> > let's apply it ASAP.
>
> This doesn't seem to have been applied yet. Are you expecting this to go
> through the main U-boot Tree, I2C tree, or Tegra tree? I just noticed
> that you only CC'd the Tegra maintainer...
>
>
I put tegra: on the front expecting it to go that way, but it doesn't
matter. Also your comments did not exactly represent a glowing
recommendation.

Tom (Rini) are you willing to pick this up as a bug fix please?

Regards,
Simon
Simon Glass Aug. 13, 2013, 7:34 p.m. UTC | #5
Hi Tom,

On Sat, Aug 10, 2013 at 7:21 PM, Tom Warren <TWarren@nvidia.com> wrote:
>
> Simon,
>
>
>
> From: sjg@google.com [mailto:sjg@google.com] On Behalf Of Simon Glass
> Sent: Friday, August 09, 2013 9:04 PM
> To: Stephen Warren
> Cc: U-Boot Mailing List; Tom Warren; Stephen Warren; trini@ti.com
> Subject: Re: [PATCH] RFC: tegra: Avoid using I2C prior to relocation
>
>
>
> +Tom Rini
>
>
>
> Hi Stephen,
>
>
>
> On Fri, Aug 9, 2013 at 5:17 PM, Stephen Warren <swarren@wwwdotorg.org> wrote:
>
> On 08/07/2013 10:20 AM, Stephen Warren wrote:
> > On 08/06/2013 11:52 PM, Simon Glass wrote:
> >> Tegra recently moved to the new I2C framework, which sets up I2C prior to
> >> relocation, and prior to calling i2c_init_board(). This causes a crash on
> >> Tegra boards.
> >>
> >> note:
> >>
> >> There are many ways to fix this. I believe this is one. It disables i2c_init()
> >> until relocation is complete. I have been unable to test it so far due to
> >> problems getting my Seaboard to work. I will try another Tegra board, but
> >> send this for comment in the meantime.
> >
> > Tested-by: Stephen Warren <swarren@nvidia.com>
> >
> > (On Beaver and Dalmore, tested booting to U-Boot command prompt followed
> > by "i2c dev 0; i2c probe")
> >
> > Note: I believe this is an enormous hack that hacks around the problem
> > of dynamic device initialization just not being well thought out
> > relative to the restrictions of U-Boot's various boot stages. I'd still
> > prefer an outright revert of the broken code.
> >
> > In other words, tegra_i2c_init() simply shouldn't be called at the wrong
> > time; it shouldn't have to handle being called at the wrong time and
> > null itself out when that happens.
> >
> > However, if this is what it takes to get U-Boot working again, then
> > let's apply it ASAP.
>
> This doesn't seem to have been applied yet. Are you expecting this to go
> through the main U-boot Tree, I2C tree, or Tegra tree? I just noticed
> that you only CC'd the Tegra maintainer...
>
>
>
> I put tegra: on the front expecting it to go that way, but it doesn't matter. Also your comments did not exactly represent a glowing recommendation.
>
> [Tom] It’s still marked RFC – doesn’t that have to go away before anyone can pick it up / apply it?

Sorry, I missed this in first reading due to the quoting. I will
re-issue without RFC.

Regards,
Simon
Stephen Warren Aug. 13, 2013, 7:42 p.m. UTC | #6
On 08/13/2013 01:34 PM, Simon Glass wrote:
> Hi Tom,
> 
> On Sat, Aug 10, 2013 at 7:21 PM, Tom Warren <TWarren@nvidia.com> wrote:
>>
>> Simon,
>>
>> From: sjg@google.com [mailto:sjg@google.com] On Behalf Of Simon Glass
...
>> I put tegra: on the front expecting it to go that way, but it doesn't matter. Also your comments did not exactly represent a glowing recommendation.
>>
>> [Tom] It’s still marked RFC – doesn’t that have to go away before anyone can pick it up / apply it?
> 
> Sorry, I missed this in first reading due to the quoting. I will
> re-issue without RFC.

If that's the only change, you hardly need to repost it to edit the
patch subject; there are many ways of fixing that when applying the patch...
Tom Rini Aug. 13, 2013, 9:12 p.m. UTC | #7
On Wed, Aug 07, 2013 at 10:20:01AM -0600, Stephen Warren wrote:
> On 08/06/2013 11:52 PM, Simon Glass wrote:
> > Tegra recently moved to the new I2C framework, which sets up I2C prior to
> > relocation, and prior to calling i2c_init_board(). This causes a crash on
> > Tegra boards.
> > 
> > note:
> > 
> > There are many ways to fix this. I believe this is one. It disables i2c_init()
> > until relocation is complete. I have been unable to test it so far due to
> > problems getting my Seaboard to work. I will try another Tegra board, but
> > send this for comment in the meantime.
> 
> Tested-by: Stephen Warren <swarren@nvidia.com>

With a hand-tweaked commit message, applied to u-boot/master, thanks!
Stephen Warren Aug. 14, 2013, 3:59 p.m. UTC | #8
On 08/13/2013 03:12 PM, Tom Rini wrote:
> On Wed, Aug 07, 2013 at 10:20:01AM -0600, Stephen Warren wrote:
>> On 08/06/2013 11:52 PM, Simon Glass wrote:
>>> Tegra recently moved to the new I2C framework, which sets up
>>> I2C prior to relocation, and prior to calling i2c_init_board().
>>> This causes a crash on Tegra boards.
>>> 
>>> note:
>>> 
>>> There are many ways to fix this. I believe this is one. It
>>> disables i2c_init() until relocation is complete. I have been
>>> unable to test it so far due to problems getting my Seaboard to
>>> work. I will try another Tegra board, but send this for comment
>>> in the meantime.
>> 
>> Tested-by: Stephen Warren <swarren@nvidia.com>
> 
> With a hand-tweaked commit message, applied to u-boot/master,
> thanks!

Thanks!

For the record, I tested u-boot.git/master commit:

cdce889 tegra: Avoid using I2C prior to relocation

on Beaver, and booted a kernel both from SD card and over USB
Ethernet, and both cases worked fine. So, we have a known-good commit
for any future bisects:-)
Simon Glass Aug. 14, 2013, 4:02 p.m. UTC | #9
Hi Stephen,

On Wed, Aug 14, 2013 at 9:59 AM, Stephen Warren <swarren@wwwdotorg.org> wrote:
> On 08/13/2013 03:12 PM, Tom Rini wrote:
>> On Wed, Aug 07, 2013 at 10:20:01AM -0600, Stephen Warren wrote:
>>> On 08/06/2013 11:52 PM, Simon Glass wrote:
>>>> Tegra recently moved to the new I2C framework, which sets up
>>>> I2C prior to relocation, and prior to calling i2c_init_board().
>>>> This causes a crash on Tegra boards.
>>>>
>>>> note:
>>>>
>>>> There are many ways to fix this. I believe this is one. It
>>>> disables i2c_init() until relocation is complete. I have been
>>>> unable to test it so far due to problems getting my Seaboard to
>>>> work. I will try another Tegra board, but send this for comment
>>>> in the meantime.
>>>
>>> Tested-by: Stephen Warren <swarren@nvidia.com>
>>
>> With a hand-tweaked commit message, applied to u-boot/master,
>> thanks!
>
> Thanks!
>
> For the record, I tested u-boot.git/master commit:
>
> cdce889 tegra: Avoid using I2C prior to relocation
>
> on Beaver, and booted a kernel both from SD card and over USB
> Ethernet, and both cases worked fine. So, we have a known-good commit
> for any future bisects:-)

OK that's good, thanks.

Regards,
Simon
diff mbox

Patch

diff --git a/drivers/i2c/tegra_i2c.c b/drivers/i2c/tegra_i2c.c
index 9ac3969..9847cf1 100644
--- a/drivers/i2c/tegra_i2c.c
+++ b/drivers/i2c/tegra_i2c.c
@@ -453,6 +453,10 @@  void i2c_init_board(void)
 
 static void tegra_i2c_init(struct i2c_adapter *adap, int speed, int slaveaddr)
 {
+	/* No i2c support prior to relocation */
+	if (!(gd->flags & GD_FLG_RELOC))
+		return;
+
 	/* This will override the speed selected in the fdt for that port */
 	debug("i2c_init(speed=%u, slaveaddr=0x%x)\n", speed, slaveaddr);
 	i2c_set_bus_speed(speed);