diff mbox

i2c-powermac fails

Message ID 20091014230252.0d0cba8d@hyperion.delvare (mailing list archive)
State Not Applicable
Headers show

Commit Message

Jean Delvare Oct. 14, 2009, 9:02 p.m. UTC
Hi all,

On Tue, 13 Oct 2009 11:49:48 +0200, Jean Delvare wrote:
> I2C bus being setup too fast sounds more likely. It might be worth
> adding an arbitrary delay after initialization, just to see if it
> helps. Not sure where though, as I'm not familiar with the Powermac
> initialization steps. Maybe right before i2c_add_adapter() in
> i2c_powermac_probe?

Tim, can you please give a try to this patch? Obviously your machine
will take 5 additional seconds to boot, and this isn't meant as a real
fix, but if it helps, this will be an interesting hint for further
debugging attempts.

Comments

Benjamin Herrenschmidt Oct. 14, 2009, 9:26 p.m. UTC | #1
On Wed, 2009-10-14 at 23:02 +0200, Jean Delvare wrote:
> Hi all,
> 
> On Tue, 13 Oct 2009 11:49:48 +0200, Jean Delvare wrote:
> > I2C bus being setup too fast sounds more likely. It might be worth
> > adding an arbitrary delay after initialization, just to see if it
> > helps. Not sure where though, as I'm not familiar with the Powermac
> > initialization steps. Maybe right before i2c_add_adapter() in
> > i2c_powermac_probe?
> 
> Tim, can you please give a try to this patch? Obviously your machine
> will take 5 additional seconds to boot, and this isn't meant as a real
> fix, but if it helps, this will be an interesting hint for further
> debugging attempts.

Oh, I was actually thinking about the frequency of the I2C clock :-)

Cheers,
Ben.

> --- kernel32.orig/drivers/macintosh/therm_adt746x.c
> +++ kernel32/drivers/macintosh/therm_adt746x.c
> @@ -380,6 +380,7 @@ static int probe_thermostat(struct i2c_c
>  	if (thermostat)
>  		return 0;
>  
> +	msleep(5000);
>  	th = kzalloc(sizeof(struct thermostat), GFP_KERNEL);
>  	if (!th)
>  		return -ENOMEM;
> 
>
Jean Delvare Oct. 15, 2009, 10:49 a.m. UTC | #2
On Thu, 15 Oct 2009 08:26:15 +1100, Benjamin Herrenschmidt wrote:
> On Wed, 2009-10-14 at 23:02 +0200, Jean Delvare wrote:
> > Hi all,
> > 
> > On Tue, 13 Oct 2009 11:49:48 +0200, Jean Delvare wrote:
> > > I2C bus being setup too fast sounds more likely. It might be worth
> > > adding an arbitrary delay after initialization, just to see if it
> > > helps. Not sure where though, as I'm not familiar with the Powermac
> > > initialization steps. Maybe right before i2c_add_adapter() in
> > > i2c_powermac_probe?
> > 
> > Tim, can you please give a try to this patch? Obviously your machine
> > will take 5 additional seconds to boot, and this isn't meant as a real
> > fix, but if it helps, this will be an interesting hint for further
> > debugging attempts.
> 
> Oh, I was actually thinking about the frequency of the I2C clock :-)

Oh. Well, if that was the case, we would see errors all the time, not
just during initialization, right? Or does the I2C clock frequency
change over time somehow?
Benjamin Herrenschmidt Oct. 15, 2009, 11:19 a.m. UTC | #3
On Thu, 2009-10-15 at 12:49 +0200, Jean Delvare wrote:
> Oh. Well, if that was the case, we would see errors all the time, not
> just during initialization, right? Or does the I2C clock frequency
> change over time somehow?

No but maybe we are a bit on the "limit" of the device and some
registers take long to respond than others ?

Cheers,
Ben.
Jean Delvare Oct. 15, 2009, 2:05 p.m. UTC | #4
On Thu, 15 Oct 2009 22:19:19 +1100, Benjamin Herrenschmidt wrote:
> On Thu, 2009-10-15 at 12:49 +0200, Jean Delvare wrote:
> > Oh. Well, if that was the case, we would see errors all the time, not
> > just during initialization, right? Or does the I2C clock frequency
> > change over time somehow?
> 
> No but maybe we are a bit on the "limit" of the device and some
> registers take long to respond than others ?

Unlikely. The ADT7460 can run at I2C clock rates up to 400 kHz while
the Keywest I2C runs at 25, 50 or 100 kHz if I read the code properly.
I don't know what exact speed is used on Tim's system, apparently it is
read from the hardware in the device tree directly?

We could have low_i2c.c log the I2C clock frequency and/or try to force
the lowest speed (25 kHz) and see if it helps, but I very much doubt
it. And I'd rather wait for Tim to report the result with my last patch
first.
Jean Delvare Oct. 16, 2009, 7:44 a.m. UTC | #5
On Thu, 15 Oct 2009 16:05:13 +0200, Jean Delvare wrote:
> On Thu, 15 Oct 2009 22:19:19 +1100, Benjamin Herrenschmidt wrote:
> > On Thu, 2009-10-15 at 12:49 +0200, Jean Delvare wrote:
> > > Oh. Well, if that was the case, we would see errors all the time, not
> > > just during initialization, right? Or does the I2C clock frequency
> > > change over time somehow?
> > 
> > No but maybe we are a bit on the "limit" of the device and some
> > registers take long to respond than others ?
> 
> Unlikely. The ADT7460 can run at I2C clock rates up to 400 kHz while
> the Keywest I2C runs at 25, 50 or 100 kHz if I read the code properly.
> I don't know what exact speed is used on Tim's system, apparently it is
> read from the hardware in the device tree directly?
> 
> We could have low_i2c.c log the I2C clock frequency and/or try to force
> the lowest speed (25 kHz) and see if it helps, but I very much doubt
> it. And I'd rather wait for Tim to report the result with my last patch
> first.

Ben, wouldn't this recent patch of yours be worth testing too?

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=11a50873ef2b3c1c3fe99a661c22c08f35d93553

If it solves problems at resume time, I guess it might also solve
problems at boot time?
Benjamin Herrenschmidt Oct. 16, 2009, 8:42 a.m. UTC | #6
On Fri, 2009-10-16 at 09:44 +0200, Jean Delvare wrote:
> On Thu, 15 Oct 2009 16:05:13 +0200, Jean Delvare wrote:
> > On Thu, 15 Oct 2009 22:19:19 +1100, Benjamin Herrenschmidt wrote:
> > > On Thu, 2009-10-15 at 12:49 +0200, Jean Delvare wrote:
> > > > Oh. Well, if that was the case, we would see errors all the time, not
> > > > just during initialization, right? Or does the I2C clock frequency
> > > > change over time somehow?
> > > 
> > > No but maybe we are a bit on the "limit" of the device and some
> > > registers take long to respond than others ?
> > 
> > Unlikely. The ADT7460 can run at I2C clock rates up to 400 kHz while
> > the Keywest I2C runs at 25, 50 or 100 kHz if I read the code properly.
> > I don't know what exact speed is used on Tim's system, apparently it is
> > read from the hardware in the device tree directly?
> > 
> > We could have low_i2c.c log the I2C clock frequency and/or try to force
> > the lowest speed (25 kHz) and see if it helps, but I very much doubt
> > it. And I'd rather wait for Tim to report the result with my last patch
> > first.
> 
> Ben, wouldn't this recent patch of yours be worth testing too?
> 
> http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=11a50873ef2b3c1c3fe99a661c22c08f35d93553
> 
> If it solves problems at resume time, I guess it might also solve
> problems at boot time?

I doubt it. The problem was related to the way interrupts get turned off
at suspend time by the generic code, which is unrelated to what happens
at boot.

Cheers,
Ben.
diff mbox

Patch

--- kernel32.orig/drivers/macintosh/therm_adt746x.c
+++ kernel32/drivers/macintosh/therm_adt746x.c
@@ -380,6 +380,7 @@  static int probe_thermostat(struct i2c_c
 	if (thermostat)
 		return 0;
 
+	msleep(5000);
 	th = kzalloc(sizeof(struct thermostat), GFP_KERNEL);
 	if (!th)
 		return -ENOMEM;