Re: [i2c] [crash, bisected] I2C, kobject (ffff81003e8c4160): tried to init an initialized object

2008-07-17 Thread Ingo Molnar

* Ingo Molnar [EMAIL PROTECTED] wrote:

 Jean,
 
 -tip testing found another (similar) i2c crash with latest -git, on a 
 Core2Duo laptop:
 
 calling  nforce2_init+0x0/0x1b
 initcall nforce2_init+0x0/0x1b returned 0 after 0 msecs
 calling  nforce2_s4985_init+0x0/0x275
 BUG: unable to handle kernel NULL pointer dereference at 000c
 IP: [c04af2cf] i2c_smbus_xfer+0x27/0x3f0
 *pdpt = 009cb001 *pde =  
 Oops:  [#1] SMP 

turning off I2C_NFORCE2_S4985 makes the system boot up fine. Workaround 
patch below.

Ingo

---
commit 15e524060d13e8fac3fe2fb6c6519be6de9ab8a8
Author: Ingo Molnar [EMAIL PROTECTED]
Date:   Thu Jul 17 11:29:44 2008 +0200

i2c workaround: turn off I2C_NFORCE2_S4985 for now

I2C_NFORCE2_S4985 causes this crash:

calling  nforce2_init+0x0/0x1b
initcall nforce2_init+0x0/0x1b returned 0 after 0 msecs
calling  nforce2_s4985_init+0x0/0x275
BUG: unable to handle kernel NULL pointer dereference at 000c
IP: [c04af2cf] i2c_smbus_xfer+0x27/0x3f0
*pdpt = 009cb001 *pde = 
Oops:  [#1] SMP

Pid: 1, comm: swapper Not tainted (2.6.26-tip #3033)
EIP: 0060:[c04af2cf] EFLAGS: 00010246 CPU: 0
EIP is at i2c_smbus_xfer+0x27/0x3f0
EAX: 0003 EBX:  ECX:  EDX: 0018
ESI: 0003 EDI: 0018 EBP: f7c6ff24 ESP: f7c6fea8
 DS: 007b ES: 007b FS: 00d8 GS:  SS: 0068
Process swapper (pid: 1, ti=f7c6e000 task=f7c7 task.ti=f7c6e000)
Stack: 0035 0003  c0104237  0046 0046 

    f7c6ff50 c09debf0 0001007b fffe007b 00d8 ffef 
c01213cb
   0060 0286 f7c6ff1c 0004 0286 0246 f7c6ff24 
c014673a
Call Trace:
 [c0104237] ? common_interrupt+0x23/0x28
 [c01213cb] ? vprintk+0x290/0x29b
 [c014673a] ? ftrace_record_ip+0x19f/0x1e6
 [c01a1385] ? sysfs_add_file_mode+0x57/0x76
 [c099632f] ? nforce2_s4985_init+0x2d/0x275
 [c013319c] ? ktime_get_ts+0x51/0x55
 [c01331b8] ? ktime_get+0x18/0x34
 [c0971887] ? kernel_init+0x11f/0x24a
 [c0996302] ? nforce2_s4985_init+0x0/0x275
 [c011cbe8] ? schedule_tail+0x1e/0x4d
 [c01037aa] ? ret_from_fork+0x6/0x1c
 [c0971768] ? kernel_init+0x0/0x24a
 [c0971768] ? kernel_init+0x0/0x24a
 [c0104477] ? kernel_thread_helper+0x7/0x10
 ===
Code: 5e 5f 5d c3 55 89 e5 57 56 53 83 ec 70 e8 ca 51 c5 ff 89 45 8c 8b 75 
0c 83 e1 14 8a 45 08 89 d7 8b 5d 8c 88 45 8b 89 f0 88 45 8a 8b 43 0c 83 78 04 
00 0f b7 c1 89 45 84 74 3a 83 c3 20 89 d8 e8
EIP: [c04af2cf] i2c_smbus_xfer+0x27/0x3f0 SS:ESP 0068:f7c6fea8
Kernel panic - not syncing: Fatal exception
Pid: 1, comm: swapper Tainted: G  D   2.6.26-tip #3033
 [c01208ee] panic+0x44/0xeb
 [c0104c8d] die+0x123/0x13a
 [c0110f38] do_page_fault+0x632/0x6f2
 [c0110906] ? do_page_fault+0x0/0x6f2
 [c06585ca] error_code+0x72/0x78
 [c04af2cf] ? i2c_smbus_xfer+0x27/0x3f0
 [c0104237] ? common_interrupt+0x23/0x28
 [c01213cb] ? vprintk+0x290/0x29b
 [c014673a] ? ftrace_record_ip+0x19f/0x1e6
 [c01a1385] ? sysfs_add_file_mode+0x57/0x76
 [c099632f] nforce2_s4985_init+0x2d/0x275
 [c013319c] ? ktime_get_ts+0x51/0x55
 [c01331b8] ? ktime_get+0x18/0x34
 [c0971887] kernel_init+0x11f/0x24a
 [c0996302] ? nforce2_s4985_init+0x0/0x275
 [c011cbe8] ? schedule_tail+0x1e/0x4d
 [c01037aa] ? ret_from_fork+0x6/0x1c
 [c0971768] ? kernel_init+0x0/0x24a
 [c0971768] ? kernel_init+0x0/0x24a
 [c0104477] kernel_thread_helper+0x7/0x10
 ===

with this config:

  http://redhat.com/~mingo/misc/config-Thu_Jul_17_10_47_42_CEST_2008.bad

Signed-off-by: Ingo Molnar [EMAIL PROTECTED]
---
 drivers/i2c/busses/Kconfig |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 6ee997b..2213fab 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -149,6 +149,9 @@ config I2C_NFORCE2
 config I2C_NFORCE2_S4985
tristate SMBus multiplexing on the Tyan S4985
depends on I2C_NFORCE2  EXPERIMENTAL
+   # broke a T60 Core2Duo with:
+   # http://redhat.com/~mingo/misc/config-Thu_Jul_17_10_47_42_CEST_2008.bad
+   depends on 0
help
  Enabling this option will add specific SMBus support for the Tyan
  S4985 motherboard.  On this 4-CPU board, the SMBus is multiplexed

___
i2c mailing list
i2c@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/i2c


Re: [i2c] [crash, bisected] I2C, kobject (ffff81003e8c4160): tried to init an initialized object

2008-07-17 Thread Ingo Molnar

* Ingo Molnar [EMAIL PROTECTED] wrote:

 -tip testing found another (similar) i2c crash with latest -git, on a 
 Core2Duo laptop:

found another bootup crash on an Athlon 64 X2 testsystem:

[   19.61] bus: 'pci': add driver amd756_smbus
[   19.615204] initcall amd756_init+0x0/0x20 returned 0 after 9 msecs
[   19.62] calling  amd756_s4882_init+0x0/0x2d7
[   19.624242] [ cut here ]
[   19.628415] WARNING: at kernel/mutex.c:134 mutex_lock_nested+0xc0/0x267()
[   19.63] Pid: 1, comm: swapper Not tainted 2.6.26-tip #20066
[   19.63] 
[   19.63] Call Trace:
[   19.63]  [802358f5] warn_on_slowpath+0x58/0x7f
[   19.63]  [80263ac6] ? ftrace_record_ip+0x20c/0x263
[   19.63]  [80514faa] ? _raw_spin_unlock+0x8e/0x93
[   19.63]  [80507c44] ? debug_locks_off+0x4/0x3c
[   19.63]  [80263ac6] ? ftrace_record_ip+0x20c/0x263
[   19.63]  [8020b3a4] ? mcount_call+0x5/0x31
[   19.63]  [80861c19] mutex_lock_nested+0xc0/0x267
[   19.63]  [806e8ffd] ? i2c_smbus_xfer+0x59/0x49c
[   19.63]  [80cc8575] ? amd756_s4882_init+0x0/0x2d7
[   19.63]  [8020b3a4] ? mcount_call+0x5/0x31
[   19.63]  [806e8ffd] i2c_smbus_xfer+0x59/0x49c
[   19.63]  [80263ac6] ? ftrace_record_ip+0x20c/0x263
[   19.63]  [80514faa] ? _raw_spin_unlock+0x8e/0x93
[   19.63]  [80cc8584] ? amd756_s4882_init+0xf/0x2d7
[   19.63]  [80263ac6] ? ftrace_record_ip+0x20c/0x263
[   19.63]  [80cc8575] ? amd756_s4882_init+0x0/0x2d7
[   19.63]  [8020b3a4] ? mcount_call+0x5/0x31
[   19.63]  [80cc8575] ? amd756_s4882_init+0x0/0x2d7
[   19.63]  [80cc85b6] amd756_s4882_init+0x41/0x2d7
[   19.63]  [8024e325] ? getnstimeofday+0x3f/0xa1
[   19.63]  [8024bf25] ? ktime_get_ts+0x4e/0x53
[   19.63]  [80cc8575] ? amd756_s4882_init+0x0/0x2d7
[   19.63]  [80ca49a0] kernel_init+0x143/0x2a4
[   19.63]  [80863721] ? _spin_unlock_irq+0x2b/0x37
[   19.63]  [8020c9f9] child_rip+0xa/0x11
[   19.63]  [80ca485d] ? kernel_init+0x0/0x2a4
[   19.63]  [8020c9ef] ? child_rip+0x0/0x11
[   19.63] 
[   19.63] ---[ end trace 0e79313125261797 ]---
[   19.63] BUG: unable to handle kernel NULL pointer dereference at 

[   19.63] IP: [80861c66] mutex_lock_nested+0x10d/0x267

with this config:

  http://redhat.com/~mingo/misc/config-Thu_Jul_17_11_34_08_CEST_2008.bad

i already had I2C_NFORCE2_S4985 off here, so it's a different one.

Ingo

___
i2c mailing list
i2c@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/i2c


Re: [i2c] [crash, bisected] I2C, kobject (ffff81003e8c4160): tried to init an initialized object

2008-07-17 Thread Ingo Molnar

* Alexey Dobriyan [EMAIL PROTECTED] wrote:

 On Thu, Jul 17, 2008 at 11:33:30AM +0200, Ingo Molnar wrote:
  
  * Ingo Molnar [EMAIL PROTECTED] wrote:
  
   Jean,
   
   -tip testing found another (similar) i2c crash with latest -git, on a 
   Core2Duo laptop:
   
   calling  nforce2_init+0x0/0x1b
   initcall nforce2_init+0x0/0x1b returned 0 after 0 msecs
   calling  nforce2_s4985_init+0x0/0x275
   BUG: unable to handle kernel NULL pointer dereference at 000c
   IP: [c04af2cf] i2c_smbus_xfer+0x27/0x3f0
   *pdpt = 009cb001 *pde =  
   Oops:  [#1] SMP 
  
  turning off I2C_NFORCE2_S4985 makes the system boot up fine. Workaround 
  patch below.
 
 Well, it's pretty easy oops unless I misread something.
 It happened on not nforce2 motherboard, right?

yeah.

 nforce2_init will just register PCI driver,
 no matching PCI ids = nforce2_set_reference() isn't called =
 nforce2_smbus stays NULL.
 
 Second module loads and tries to i2c_smbus_xfer(NULL, ) in module_init()
 hook which oopses.

can try patches, but got other 5 fresh upstream oopses/hangs/crashes to 
investigate now. (so i went for the minimal-effort 
turn-off-the-failing-part approach)

Ingo

___
i2c mailing list
i2c@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/i2c


Re: [i2c] Access 16bits address register in a device through I2C

2008-07-17 Thread Ben Dooks
On Fri, Jul 18, 2008 at 12:13:30AM +0800, Wen Wang wrote:
 Hi all,
 I have a problem writing an I2C device driver and would greatly appreciate
 if someone could provide some enlightenment.
 
 I'm working on a project needs to access registers with 16bits address
 through I2C. But unfortunately I can not find a way to achieve this, cause
 it seems that current kernel I2C framework only supports 8bits address
 register.

The easiest way is to create a function that uses a pair of i2c messages,
the first message sends the 16bits of address pointer to the device, the
second one either reads or writes data.
 
 So I'm wondering do I miss something or what can I do? Any ideas?
 
 Thanks
 Wen

 ___
 i2c mailing list
 i2c@lm-sensors.org
 http://lists.lm-sensors.org/mailman/listinfo/i2c

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'

___
i2c mailing list
i2c@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/i2c


Re: [i2c] Access 16bits address register in a device through I2C

2008-07-17 Thread Wolfram Sang
Hi Wen,

On Fri, Jul 18, 2008 at 12:13:30AM +0800, Wen Wang wrote:

 So I'm wondering do I miss something or what can I do? Any ideas?

For an example what Ben suggested (2 messages), have a look at the
at24-driver, which just went through the merge-window.

http://article.gmane.org/gmane.linux.drivers.i2c/1661

Check functions 'at24_eeprom_[read|write]' for details.

All the best,

   Wolfram

-- 
  Dipl.-Ing. Wolfram Sang | http://www.pengutronix.de
 Pengutronix - Linux Solutions for Science and Industry


signature.asc
Description: Digital signature
___
i2c mailing list
i2c@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/i2c

Re: [i2c] [crash, bisected] I2C, kobject (ffff81003e8c4160): tried to init an initialized object (was: Re: [GIT PULL] i2c updates for 2.6.27, round 1)

2008-07-17 Thread Greg KH
On Wed, Jul 16, 2008 at 11:07:02AM +0200, Jean Delvare wrote:
  btw., Greg, the kobject debugging check and output is really nice, 
  informative and useful! It likely pinpoints the real bug here.
 
 Is this something new in 2.6.26-gitX? I want to know if the bug is
 something new or if it could be already present in 2.6.26 and earlier
 kernels and went unnoticed so far.

It is in 2.6.26 as I haven't merged any patches with Linus yet, portions
of it might be in older kernels, but not in the same type of format.

thanks,

greg k-h

___
i2c mailing list
i2c@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/i2c


Re: [i2c] [PATCH] hwmon: (adm9240) Convert to a new-style i2c driver

2008-07-17 Thread Grant Coady
On Wed, 16 Jul 2008 16:32:57 +0200, Jean Delvare [EMAIL PROTECTED] wrote:

The new-style adm9240 driver implements the optional detect() callback
to cover the use cases of the legacy driver.

Signed-off-by: Jean Delvare [EMAIL PROTECTED]
Cc: Grant Coady [EMAIL PROTECTED]

Tested both as compiled in, and as modules, with 2.6.26-git6, no problems 
found, userspace:
~$ sensors --version
sensors version 3.0.2 with libsensors version 3.0.2

sensors-detect, sensors and 'sensors -s' behaved as expected.

Acked-by: Grant Coady [EMAIL PROTECTED]

---
 drivers/hwmon/adm9240.c |   93 +++
 1 file changed, 46 insertions(+), 47 deletions(-)

--- linux-2.6.26-rc9.orig/drivers/hwmon/adm9240.c  2008-07-12 
09:20:31.0 +0200
+++ linux-2.6.26-rc9/drivers/hwmon/adm9240.c   2008-07-12 10:27:31.0 
+0200
@@ -130,25 +130,37 @@ static inline unsigned int AOUT_FROM_REG
   return SCALE(reg, 1250, 255);
 }
 
-static int adm9240_attach_adapter(struct i2c_adapter *adapter);
-static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind);
+static int adm9240_probe(struct i2c_client *client,
+   const struct i2c_device_id *id);
+static int adm9240_detect(struct i2c_client *client, int kind,
+struct i2c_board_info *info);
 static void adm9240_init_client(struct i2c_client *client);
-static int adm9240_detach_client(struct i2c_client *client);
+static int adm9240_remove(struct i2c_client *client);
 static struct adm9240_data *adm9240_update_device(struct device *dev);
 
 /* driver data */
+static const struct i2c_device_id adm9240_id[] = {
+  { adm9240, adm9240 },
+  { ds1780, ds1780 },
+  { lm81, lm81 },
+  { }
+};
+MODULE_DEVICE_TABLE(i2c, adm9240_id);
+
 static struct i2c_driver adm9240_driver = {
+  .class  = I2C_CLASS_HWMON,
   .driver = {
   .name   = adm9240,
   },
-  .attach_adapter = adm9240_attach_adapter,
-  .detach_client  = adm9240_detach_client,
+  .probe  = adm9240_probe,
+  .remove = adm9240_remove,
+  .id_table   = adm9240_id,
+  .detect = adm9240_detect,
+  .address_data   = addr_data,
 };
 
 /* per client data */
 struct adm9240_data {
-  enum chips type;
-  struct i2c_client client;
   struct device *hwmon_dev;
   struct mutex update_lock;
   char valid;
@@ -532,28 +544,17 @@ static const struct attribute_group adm9
 
 /*** sensor chip detect and driver install ***/
 
-static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind)
+/* Return 0 if detection is successful, -ENODEV otherwise */
+static int adm9240_detect(struct i2c_client *new_client, int kind,
+struct i2c_board_info *info)
 {
-  struct i2c_client *new_client;
-  struct adm9240_data *data;
-  int err = 0;
+  struct i2c_adapter *adapter = new_client-adapter;
   const char *name = ;
+  int address = new_client-addr;
   u8 man_id, die_rev;
 
   if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
-  goto exit;
-
-  if (!(data = kzalloc(sizeof(*data), GFP_KERNEL))) {
-  err = -ENOMEM;
-  goto exit;
-  }
-
-  new_client = data-client;
-  i2c_set_clientdata(new_client, data);
-  new_client-addr = address;
-  new_client-adapter = adapter;
-  new_client-driver = adm9240_driver;
-  new_client-flags = 0;
+  return -ENODEV;
 
   if (kind == 0) {
   kind = adm9240;
@@ -566,7 +567,7 @@ static int adm9240_detect(struct i2c_ada
   != address) {
   dev_err(adapter-dev, detect fail: address match, 
   0x%02x\n, address);
-  goto exit_free;
+  return -ENODEV;
   }
 
   /* check known chip manufacturer */
@@ -581,7 +582,7 @@ static int adm9240_detect(struct i2c_ada
   } else {
   dev_err(adapter-dev, detect fail: unknown manuf, 
   0x%02x\n, man_id);
-  goto exit_free;
+  return -ENODEV;
   }
 
   /* successful detect, print chip info */
@@ -600,20 +601,31 @@ static int adm9240_detect(struct i2c_ada
   } else if (kind == lm81) {
   name = lm81;
   }
+  strlcpy(info-type, name, I2C_NAME_SIZE);
 
-  /* fill in the remaining client fields and attach */
-  strlcpy(new_client-name, name, I2C_NAME_SIZE);
-  data-type = kind;
-  mutex_init(data-update_lock);
+  return 0;
+}
 
-  if ((err = i2c_attach_client(new_client)))
-  goto exit_free;
+static int adm9240_probe(struct i2c_client *new_client,
+   const struct i2c_device_id *id)
+{
+  struct adm9240_data *data;
+  int err;
+
+  data = 

Re: [i2c] Access 16bits address register in a device through I2C

2008-07-17 Thread Wen Wang
Hi Guys,

Thank you for your kindly heads up, that really helps me a lot :)

BRs
Wen

On Fri, Jul 18, 2008 at 1:06 AM, Wolfram Sang [EMAIL PROTECTED] wrote:

 Hi Wen,

 On Fri, Jul 18, 2008 at 12:13:30AM +0800, Wen Wang wrote:

  So I'm wondering do I miss something or what can I do? Any ideas?

 For an example what Ben suggested (2 messages), have a look at the
 at24-driver, which just went through the merge-window.

 http://article.gmane.org/gmane.linux.drivers.i2c/1661

 Check functions 'at24_eeprom_[read|write]' for details.

 All the best,

   Wolfram

 --
  Dipl.-Ing. Wolfram Sang | http://www.pengutronix.de
  Pengutronix - Linux Solutions for Science and Industry

 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.6 (GNU/Linux)

 iD8DBQFIf3wpD27XaX1/VRsRAjXBAKCx28nzPbkyMx3aN6KNN03jNFIRLwCgiyAL
 +zHcrnvXfuzWngEpflY5KZg=
 =sUwl
 -END PGP SIGNATURE-


___
i2c mailing list
i2c@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/i2c