Bug 34572

Summary: kobject (f4fd6410): tried to init an initialized object, something is seriously wrong.
Product: Memory Management Reporter: Witold Baryluk (witold.baryluk+kernel)
Component: OtherAssignee: Andrew Morton (akpm)
Status: RESOLVED CODE_FIX    
Severity: normal CC: florian, srajiv, stefanb, witold.baryluk+kernel
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 2.6.39-rc6-00528-g0ee5623f Subsystem:
Regression: No Bisected commit-id:
Attachments: dmesg output
linux kernel config

Description Witold Baryluk 2011-05-05 08:30:44 UTC
Created attachment 56712 [details]
dmesg output

i386 on Debian unstable with gcc 4.5.3

.....
[    1.932922] Non-volatile memory driver v1.3
[    1.932979] Hangcheck: starting hangcheck timer 0.9.1 (tick is 180 seconds, margin is 60 seconds).
[    1.933069] Hangcheck: Using getrawmonotonic().
[    1.933416] kobject (f4fd6410): tried to init an initialized object, something is seriously wrong.
[    1.933509] Pid: 1, comm: swapper Not tainted 2.6.39-rc6-00528-g0ee5623f #20
[    1.933568] Call Trace:
[    1.933625]  [<c177c06a>] ? printk+0x1d/0x23
[    1.933682]  [<c132d6cc>] kobject_init+0x7c/0x90
[    1.933741]  [<c1405253>] device_initialize+0x23/0xa0
[    1.933800]  [<c140a0d9>] ? platform_device_alloc+0x59/0x70
[    1.933858]  [<c1409fa3>] platform_device_register+0x13/0x20
[    1.933918]  [<c1ab2532>] init_nsc+0xc6/0x1b9
[    1.933976]  [<c13c423c>] ? pnp_register_driver+0x1c/0x20
[    1.934034]  [<c1ab23d1>] ? init_tis+0x1a/0xb5
[    1.934091]  [<c1003135>] do_one_initcall+0x35/0x170
[    1.934149]  [<c133035a>] ? radix_tree_lookup+0xa/0x10
[    1.934207]  [<c10c4844>] ? irq_to_desc+0x14/0x20
[    1.934263]  [<c1ab246c>] ? init_tis+0xb5/0xb5
[    1.934321]  [<c1a85839>] kernel_init+0xc2/0x158
[    1.934378]  [<c1a85777>] ? start_kernel+0x31f/0x31f
[    1.934435]  [<c1786d3a>] kernel_thread_helper+0x6/0x10
[    1.935285] tpm_nsc tpm_nscl0: NSC TPM revision 2
....

Full dmesg and .config in attachments.
Comment 1 Witold Baryluk 2011-05-05 08:31:25 UTC
Created attachment 56722 [details]
linux kernel config
Comment 2 Andrew Morton 2011-05-06 21:22:57 UTC
(switched to email.  Please respond via emailed reply-to-all, not via the
bugzilla web interface).

On Thu, 5 May 2011 08:30:47 GMT
bugzilla-daemon@bugzilla.kernel.org wrote:

> https://bugzilla.kernel.org/show_bug.cgi?id=34572
> 
>            Summary: kobject (f4fd6410): tried to init an initialized
>                     object, something is seriously wrong.
>            Product: Memory Management
>            Version: 2.5
>     Kernel Version: 2.6.39-rc6-00528-g0ee5623f
>           Platform: All
>         OS/Version: Linux
>               Tree: Mainline
>             Status: NEW
>           Severity: normal
>           Priority: P1
>          Component: Other
>         AssignedTo: akpm@linux-foundation.org
>         ReportedBy: baryluk@smp.if.uj.edu.pl
>         Regression: No
> 
> 
> Created an attachment (id=56712)
>  --> (https://bugzilla.kernel.org/attachment.cgi?id=56712)
> dmesg output
> 
> i386 on Debian unstable with gcc 4.5.3
> 
> .....
> [    1.932922] Non-volatile memory driver v1.3
> [    1.932979] Hangcheck: starting hangcheck timer 0.9.1 (tick is 180
> seconds,
> margin is 60 seconds).
> [    1.933069] Hangcheck: Using getrawmonotonic().
> [    1.933416] kobject (f4fd6410): tried to init an initialized object,
> something is seriously wrong.
> [    1.933509] Pid: 1, comm: swapper Not tainted 2.6.39-rc6-00528-g0ee5623f
> #20
> [    1.933568] Call Trace:
> [    1.933625]  [<c177c06a>] ? printk+0x1d/0x23
> [    1.933682]  [<c132d6cc>] kobject_init+0x7c/0x90
> [    1.933741]  [<c1405253>] device_initialize+0x23/0xa0
> [    1.933800]  [<c140a0d9>] ? platform_device_alloc+0x59/0x70
> [    1.933858]  [<c1409fa3>] platform_device_register+0x13/0x20
> [    1.933918]  [<c1ab2532>] init_nsc+0xc6/0x1b9
> [    1.933976]  [<c13c423c>] ? pnp_register_driver+0x1c/0x20
> [    1.934034]  [<c1ab23d1>] ? init_tis+0x1a/0xb5
> [    1.934091]  [<c1003135>] do_one_initcall+0x35/0x170
> [    1.934149]  [<c133035a>] ? radix_tree_lookup+0xa/0x10
> [    1.934207]  [<c10c4844>] ? irq_to_desc+0x14/0x20
> [    1.934263]  [<c1ab246c>] ? init_tis+0xb5/0xb5
> [    1.934321]  [<c1a85839>] kernel_init+0xc2/0x158
> [    1.934378]  [<c1a85777>] ? start_kernel+0x31f/0x31f
> [    1.934435]  [<c1786d3a>] kernel_thread_helper+0x6/0x10
> [    1.935285] tpm_nsc tpm_nscl0: NSC TPM revision 2
> ....
> 
> Full dmesg and .config in attachments.
> 

Seems to be due to a problem in tpm_tis initialisation.
Comment 3 Witold Baryluk 2011-05-09 23:15:29 UTC
Under 2.6.39-rc6-00585-gc2bf807-dirty same behaviour

[    1.986556] ERST: Table is not found!
[    1.986640] GHES: HEST is not enabled!
[    1.986693] XENFS: not registering filesystem on non-xen platform
[    1.987176] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
[    2.000666] ACPI: Battery Slot [BAT0] (battery present)
[    2.053372] serial 00:09: activated
[    2.055978] 00:09: ttyS0 at I/O 0x3f8 (irq = 4) is a NS16550A
[    2.072940] Non-volatile memory driver v1.3
[    2.072996] Hangcheck: starting hangcheck timer 0.9.1 (tick is 180 seconds, margin is 60 seconds).
[    2.073086] Hangcheck: Using getrawmonotonic().
[    2.073535] Pid: 1, comm: swapper Not tainted 2.6.39-rc6-00585-gc2bf807-dirty #24
[    2.073623] Call Trace:
[    2.073681]  [<c17746b6>] ? printk+0x1d/0x1f
[    2.073740]  [<c132361c>] kobject_init+0x7c/0x90
[    2.073800]  [<c13f7a53>] device_initialize+0x23/0xa0
[    2.073859]  [<c13fcc84>] ? platform_device_alloc+0x54/0x70
[    2.073917]  [<c13fcb73>] platform_device_register+0x13/0x20
[    2.073977]  [<c1ac4232>] init_nsc+0xc5/0x1b8
[    2.074034]  [<c13b804c>] ? pnp_register_driver+0x1c/0x20
[    2.074092]  [<c1ac40d2>] ? init_tis+0x1a/0xb5
[    2.074149]  [<c1003034>] do_one_initcall+0x34/0x170
[    2.074207]  [<c132700a>] ? radix_tree_lookup+0xa/0x10
[    2.074266]  [<c10c0574>] ? irq_to_desc+0x14/0x20
[    2.074322]  [<c1ac416d>] ? init_tis+0xb5/0xb5
[    2.074379]  [<c1a97837>] kernel_init+0xc2/0x14e
[    2.074436]  [<c1a97775>] ? start_kernel+0x323/0x323
[    2.074494]  [<c17927ba>] kernel_thread_helper+0x6/0x10
[    2.075342] tpm_nsc tpm_nscl0: NSC TPM revision 2
[    2.079314] loop: module loaded
[    2.079973] Loading iSCSI transport class v2.0-870.
[    2.081006] iscsi: registered transport (tcp)
[    2.081802] ahci: probe of 0000:00:1f.2 failed with error -22
[    2.082076] ata_piix 0000:00:1f.2: MAP [ P0 P2 IDE IDE ]
[    2.238593] scsi0 : ata_piix
[    2.239342] scsi1 : ata_piix
....


Note: NO "kobject (0xdeadbeaf) tried to init an initialized object, something is seriously wrong."

> Seems to be due to a problem in tpm_tis initialisation.

Very possible. I had other similar (or maybe even the same) error (with call trace) in older kernels when initializing tpm_nsc. In current config I have tpm_nsc built-in, so cannot rmmod/modprobe to check, but will rebuild kernel and see effect.

But then why kobject reinitialization bug disapeared? It was just few commits.
Comment 4 Witold Baryluk 2011-05-12 01:06:56 UTC
Was testing again in 2.6.39-rc7-00708-g9f381a6-dirty, and kobject message is still present. I think it is long standing bug in tpm_tis module.
Comment 5 Rajiv Andrade 2011-05-13 22:21:39 UTC
Is the reporter somehow loading both tpm_tis and tpm_nsc?

Rajiv

On 05/06/2011 06:22 PM, Andrew Morton wrote:
> 
> (switched to email.  Please respond via emailed reply-to-all, not via the
> bugzilla web interface).
> 
> On Thu, 5 May 2011 08:30:47 GMT
> bugzilla-daemon@bugzilla.kernel.org wrote:
> 
>> https://bugzilla.kernel.org/show_bug.cgi?id=34572
>>
>>            Summary: kobject (f4fd6410): tried to init an initialized
>>                     object, something is seriously wrong.
>>            Product: Memory Management
>>            Version: 2.5
>>     Kernel Version: 2.6.39-rc6-00528-g0ee5623f
>>           Platform: All
>>         OS/Version: Linux
>>               Tree: Mainline
>>             Status: NEW
>>           Severity: normal
>>           Priority: P1
>>          Component: Other
>>         AssignedTo: akpm@linux-foundation.org
>>         ReportedBy: baryluk@smp.if.uj.edu.pl
>>         Regression: No
>>
>>
>> Created an attachment (id=56712)
>>  --> (https://bugzilla.kernel.org/attachment.cgi?id=56712)
>> dmesg output
>>
>> i386 on Debian unstable with gcc 4.5.3
>>
>> .....
>> [    1.932922] Non-volatile memory driver v1.3
>> [    1.932979] Hangcheck: starting hangcheck timer 0.9.1 (tick is 180
>> seconds,
>> margin is 60 seconds).
>> [    1.933069] Hangcheck: Using getrawmonotonic().
>> [    1.933416] kobject (f4fd6410): tried to init an initialized object,
>> something is seriously wrong.
>> [    1.933509] Pid: 1, comm: swapper Not tainted 2.6.39-rc6-00528-g0ee5623f
>> #20
>> [    1.933568] Call Trace:
>> [    1.933625]  [<c177c06a>] ? printk+0x1d/0x23
>> [    1.933682]  [<c132d6cc>] kobject_init+0x7c/0x90
>> [    1.933741]  [<c1405253>] device_initialize+0x23/0xa0
>> [    1.933800]  [<c140a0d9>] ? platform_device_alloc+0x59/0x70
>> [    1.933858]  [<c1409fa3>] platform_device_register+0x13/0x20
>> [    1.933918]  [<c1ab2532>] init_nsc+0xc6/0x1b9
>> [    1.933976]  [<c13c423c>] ? pnp_register_driver+0x1c/0x20
>> [    1.934034]  [<c1ab23d1>] ? init_tis+0x1a/0xb5
>> [    1.934091]  [<c1003135>] do_one_initcall+0x35/0x170
>> [    1.934149]  [<c133035a>] ? radix_tree_lookup+0xa/0x10
>> [    1.934207]  [<c10c4844>] ? irq_to_desc+0x14/0x20
>> [    1.934263]  [<c1ab246c>] ? init_tis+0xb5/0xb5
>> [    1.934321]  [<c1a85839>] kernel_init+0xc2/0x158
>> [    1.934378]  [<c1a85777>] ? start_kernel+0x31f/0x31f
>> [    1.934435]  [<c1786d3a>] kernel_thread_helper+0x6/0x10
>> [    1.935285] tpm_nsc tpm_nscl0: NSC TPM revision 2
>> ....
>>
>> Full dmesg and .config in attachments.
>>
> 
> Seems to be due to a problem in tpm_tis initialisation.
Comment 6 Anonymous Emailer 2011-05-14 23:45:52 UTC
Reply-To: stefanb@linux.vnet.ibm.com

On 05/13/2011 06:20 PM, Rajiv Andrade wrote:
> Is the reporter somehow loading both tpm_tis and tpm_nsc?
>
It looks like the problem is related to platform_device_alloc() calling 
device_initialize(&pa->pdev.dev)

http://lxr.linux.no/#linux+v2.6.38/drivers/base/platform.c#L164

and then platform_device_register() calling it again with &pdev->dev.

http://lxr.linux.no/#linux+v2.6.38/drivers/base/platform.c#L333

The solution may be to simply call platform_device_add() in the nsc driver.

Regards,
    Stefan

> Rajiv
>
> On 05/06/2011 06:22 PM, Andrew Morton wrote:
>> (switched to email.  Please respond via emailed reply-to-all, not via the
>> bugzilla web interface).
>>
>> On Thu, 5 May 2011 08:30:47 GMT
>> bugzilla-daemon@bugzilla.kernel.org wrote:
>>
>>> https://bugzilla.kernel.org/show_bug.cgi?id=34572
>>>
>>>             Summary: kobject (f4fd6410): tried to init an initialized
>>>                      object, something is seriously wrong.
>>>             Product: Memory Management
>>>             Version: 2.5
>>>      Kernel Version: 2.6.39-rc6-00528-g0ee5623f
>>>            Platform: All
>>>          OS/Version: Linux
>>>                Tree: Mainline
>>>              Status: NEW
>>>            Severity: normal
>>>            Priority: P1
>>>           Component: Other
>>>          AssignedTo: akpm@linux-foundation.org
>>>          ReportedBy: baryluk@smp.if.uj.edu.pl
>>>          Regression: No
>>>
>>>
>>> Created an attachment (id=56712)
>>>   -->  (https://bugzilla.kernel.org/attachment.cgi?id=56712)
>>> dmesg output
>>>
>>> i386 on Debian unstable with gcc 4.5.3
>>>
>>> .....
>>> [    1.932922] Non-volatile memory driver v1.3
>>> [    1.932979] Hangcheck: starting hangcheck timer 0.9.1 (tick is 180
>>> seconds,
>>> margin is 60 seconds).
>>> [    1.933069] Hangcheck: Using getrawmonotonic().
>>> [    1.933416] kobject (f4fd6410): tried to init an initialized object,
>>> something is seriously wrong.
>>> [    1.933509] Pid: 1, comm: swapper Not tainted 2.6.39-rc6-00528-g0ee5623f
>>> #20
>>> [    1.933568] Call Trace:
>>> [    1.933625]  [<c177c06a>] ? printk+0x1d/0x23
>>> [    1.933682]  [<c132d6cc>] kobject_init+0x7c/0x90
>>> [    1.933741]  [<c1405253>] device_initialize+0x23/0xa0
>>> [    1.933800]  [<c140a0d9>] ? platform_device_alloc+0x59/0x70
>>> [    1.933858]  [<c1409fa3>] platform_device_register+0x13/0x20
>>> [    1.933918]  [<c1ab2532>] init_nsc+0xc6/0x1b9
>>> [    1.933976]  [<c13c423c>] ? pnp_register_driver+0x1c/0x20
>>> [    1.934034]  [<c1ab23d1>] ? init_tis+0x1a/0xb5
>>> [    1.934091]  [<c1003135>] do_one_initcall+0x35/0x170
>>> [    1.934149]  [<c133035a>] ? radix_tree_lookup+0xa/0x10
>>> [    1.934207]  [<c10c4844>] ? irq_to_desc+0x14/0x20
>>> [    1.934263]  [<c1ab246c>] ? init_tis+0xb5/0xb5
>>> [    1.934321]  [<c1a85839>] kernel_init+0xc2/0x158
>>> [    1.934378]  [<c1a85777>] ? start_kernel+0x31f/0x31f
>>> [    1.934435]  [<c1786d3a>] kernel_thread_helper+0x6/0x10
>>> [    1.935285] tpm_nsc tpm_nscl0: NSC TPM revision 2
>>> ....
>>>
>>> Full dmesg and .config in attachments.
>>>
>> Seems to be due to a problem in tpm_tis initialisation.
>
> ------------------------------------------------------------------------------
> Achieve unprecedented app performance and reliability
> What every C/C++ and Fortran developer should know.
> Learn how Intel has extended the reach of its next-generation tools
> to help boost performance applications - inlcuding clusters.
> http://p.sf.net/sfu/intel-dev2devmay
> _______________________________________________
> tpmdd-devel mailing list
> tpmdd-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/tpmdd-devel
Comment 7 Witold Baryluk 2011-05-16 20:16:08 UTC
I'm not sure about this diagnosis (it isn't clear from source code), but you might be right.

Here is again dmesg, with kobject debuging enabled

[    0.294083] kobject: 'tpm' (f5d012c0): kobject_add_internal: parent: 'module', set: 'module'
[    0.294095] kobject: 'tpm' (f5d012c0): kobject_uevent_env
[    0.294101] kobject: 'tpm' (f5d012c0): fill_kobj_path: path = '/module/tpm'
[    0.294373] kobject: 'tpm_tis' (f5d013c0): kobject_add_internal: parent: 'module', set: 'module'
[    0.294386] kobject: 'tpm_tis' (f5d013c0): kobject_uevent_env
[    0.294391] kobject: 'tpm_tis' (f5d013c0): fill_kobj_path: path = '/module/tpm_tis'
[    0.294672] kobject: 'tpm_nsc' (f5d014c0): kobject_add_internal: parent: 'module', set: 'module'
[    0.294684] kobject: 'tpm_nsc' (f5d014c0): kobject_uevent_env
[    0.294690] kobject: 'tpm_nsc' (f5d014c0): fill_kobj_path: path = '/module/tpm_nsc'
...
[    0.338934] kobject: 'tpm' (f5d012c0): kobject_uevent_env
[    0.338940] kobject: 'tpm' (f5d012c0): fill_kobj_path: path = '/module/tpm'
[    0.339218] kobject: 'tpm_tis' (f5d013c0): kobject_uevent_env
[    0.339224] kobject: 'tpm_tis' (f5d013c0): fill_kobj_path: path = '/module/tpm_tis'
[    0.339525] kobject: 'tpm_tis' (f5d013c0): kobject_uevent_env
[    0.339531] kobject: 'tpm_tis' (f5d013c0): fill_kobj_path: path = '/module/tpm_tis'
[    0.339839] kobject: 'tpm_tis' (f5d013c0): kobject_uevent_env
[    0.339845] kobject: 'tpm_tis' (f5d013c0): fill_kobj_path: path = '/module/tpm_tis'
[    0.340528] kobject: 'tpm_tis' (f5d013c0): kobject_uevent_env
[    0.340534] kobject: 'tpm_tis' (f5d013c0): fill_kobj_path: path = '/module/tpm_tis'
...
[    3.032548] Non-volatile memory driver v1.3
[    3.032603] Hangcheck: starting hangcheck timer 0.9.1 (tick is 180 seconds, margin is 60 seconds).
[    3.032694] Hangcheck: Using getrawmonotonic().
[    3.032766] kobject: 'tpm_tis' (f5d81880): kobject_add_internal: parent: 'drivers', set: 'drivers'
[    3.032815] kobject: 'tpm_tis' (f5d81880): kobject_uevent_env
[    3.032821] kobject: 'tpm_tis' (f5d81880): fill_kobj_path: path = '/bus/pnp/drivers/tpm_tis'
[    3.033122] kobject: 'tpm_nsc' (f5dde700): kobject_add_internal: parent: 'drivers', set: 'drivers'
[    3.033155] kobject: 'tpm_nsc' (f5dde700): kobject_uevent_env
[    3.033160] kobject: 'tpm_nsc' (f5dde700): fill_kobj_path: path = '/bus/platform/drivers/tpm_nsc'
[    3.033461] kobject (f535bc10): tried to init an initialized object, something is seriously wrong.
[    3.033555] Pid: 1, comm: swapper Not tainted 2.6.39-rc7-thinkpad-t43-00829-geed631e-dirty #47
[    3.033645] Call Trace:
[    3.033704]  [<81782520>] ? printk+0x1d/0x1f
[    3.033763]  [<8132d6ec>] kobject_init+0x7c/0x90
[    3.033822]  [<8140c923>] device_initialize+0x23/0xa0
[    3.033881]  [<81411c04>] ? platform_device_alloc+0x54/0x70
[    3.033940]  [<81411af3>] platform_device_register+0x13/0x20
[    3.034002]  [<81ad96bf>] init_nsc+0xc5/0x1b8
[    3.034060]  [<813cc57c>] ? pnp_register_driver+0x1c/0x20
[    3.034119]  [<81ad955f>] ? init_tis+0x1a/0xb5
[    3.034176]  [<81003034>] do_one_initcall+0x34/0x170
[    3.034235]  [<8133111a>] ? radix_tree_lookup+0xa/0x10
[    3.034294]  [<810c41c4>] ? irq_to_desc+0x14/0x20
[    3.034350]  [<81ad95fa>] ? init_tis+0xb5/0xb5
[    3.034409]  [<81aaa86d>] kernel_init+0xc2/0x14e
[    3.034465]  [<81aaa7ab>] ? start_kernel+0x358/0x358
[    3.034525]  [<817a163a>] kernel_thread_helper+0x6/0x10
[    3.034592] kobject: 'tpm_nscl0' (f535bc10): kobject_add_internal: parent: 'platform', set: 'devices'
[    3.034651] kobject: 'tpm_nscl0' (f535bc10): kobject_uevent_env
[    3.034657] kobject: 'tpm_nscl0' (f535bc10): fill_kobj_path: path = '/devices/platform/tpm_nscl0'
[    3.034992] kobject: 'misc' (f536fb80): kobject_add_internal: parent: 'tpm_nscl0', set: '(null)'
[    3.035004] kobject: 'tpm0' (f5f6c408): kobject_add_internal: parent: 'misc', set: 'devices'
[    3.035105] kobject: 'tpm0' (f5f6c408): kobject_uevent_env
[    3.035112] kobject: 'tpm0' (f5f6c408): fill_kobj_path: path = '/devices/platform/tpm_nscl0/misc/tpm0'
[    3.035890] tpm_nsc tpm_nscl0: NSC TPM revision 2

// ... is mainly scsi initialization.

on 2.6.39-rc7-thinkpad-t43-00829-geed631e-dirty
Comment 8 Witold Baryluk 2011-05-16 22:59:52 UTC
> Is the reporter somehow loading both tpm_tis and tpm_nsc?
> 
> Rajiv

I have both built-in into kernel AFAIK.

$ grep -A 5 -B 5 TPM /boot/config-2.6.39-rc7-thinkpad-t43-00829-geed631e-dirty 
# CONFIG_NSC_GPIO is not set
# CONFIG_RAW_DRIVER is not set
CONFIG_HPET=y
# CONFIG_HPET_MMAP is not set
CONFIG_HANGCHECK_TIMER=y
CONFIG_TCG_TPM=y
CONFIG_TCG_TIS=y
CONFIG_TCG_NSC=y
# CONFIG_TCG_ATMEL is not set
# CONFIG_TCG_INFINEON is not set
# CONFIG_TELCLOCK is not set

Is this wrong? Even if so, it should not lead to my error, only one device driver should initialize. I have ThinkPad T43 with NSC chip. It is not TIS 1.2 compilant (Thinkpads T60 and newer are), but this position in kernel config is selected for example by IMA (Integrity Measurement Architecture). So TIS should obviously fail to load, and probably should not even try to load, as there is no hardware for it.

But I remember I had same (or similar) problem when everything was in modules, and i was just doing 'modprobe tpm_nsc'.
Comment 9 Stefan Berger 2011-05-25 13:58:30 UTC
It looks like the problem is related to platform_device_alloc() calling 
device_initialize(&pa->pdev.dev)

http://lxr.linux.no/#linux+v2.6.38/drivers/base/platform.c#L164

and then platform_device_register() calling it again with &pdev->dev.

http://lxr.linux.no/#linux+v2.6.38/drivers/base/platform.c#L333

The solution may be to simply call platform_device_add() in the nsc driver.

Would it be possible to try out the following patch?

diff --git a/drivers/char/tpm/tpm_nsc.c b/drivers/char/tpm/tpm_nsc.c
index a605cb7..82facc9 100644
--- a/drivers/char/tpm/tpm_nsc.c
+++ b/drivers/char/tpm/tpm_nsc.c
@@ -330,12 +330,12 @@ static int __init init_nsc(void)
 	pdev->dev.driver = &nsc_drv.driver;
 	pdev->dev.release = tpm_nsc_remove;
 
-	if ((rc = platform_device_register(pdev)) < 0)
-		goto err_free_dev;
+	if ((rc = platform_device_add(pdev)) < 0)
+		goto err_put_dev;
 
 	if (request_region(base, 2, "tpm_nsc0") == NULL ) {
 		rc = -EBUSY;
-		goto err_unreg_dev;
+		goto err_del_dev;
 	}
 
 	if (!(chip = tpm_register_hardware(&pdev->dev, &tpm_nsc))) {
@@ -382,10 +382,10 @@ static int __init init_nsc(void)
 
 err_rel_reg:
 	release_region(base, 2);
-err_unreg_dev:
-	platform_device_unregister(pdev);
-err_free_dev:
-	kfree(pdev);
+err_del_dev:
+	platform_device_del(pdev);
+err_put_dev:
+	platform_device_put(pdev);
 err_unreg_drv:
 	platform_driver_unregister(&nsc_drv);
 	return rc;


Regards,
    Stefan
Comment 10 Witold Baryluk 2011-05-31 00:26:17 UTC
Trying (after small adjustments to apply cleanly),
but recent kernel have some other bugs, which prevents me
from fully testing it now. I will report when this other
problems will be resolved.

Thanks for patch.

Regards,
Witek
Comment 11 Witold Baryluk 2011-07-21 21:44:03 UTC
It looks patch works, at least I do not get any warning, however I was testing production kernel without any debugging.


[    2.233363] Non-volatile memory driver v1.3
[    2.233411] Hangcheck: starting hangcheck timer 0.9.1 (tick is 180 seconds, margin is 60
 seconds).
[    2.233490] Hangcheck: Using getrawmonotonic().
[    2.233834] tpm_nsc tpm_nscl0: NSC TPM revision 2
[    2.235640] loop: module loaded
[    2.235957] Loading iSCSI transport class v2.0-870.
[    2.236392] iscsi: registered transport (tcp)

No all trace, so it looks good.

Will re-enable kobject debugging and check again.
Comment 12 Stefan Berger 2011-07-22 03:46:35 UTC
Let me know if you find anything. I'd otherwise post the patch on lkml and cc you on it so you can write a Tested-by: line into it.

   Stefan
Comment 13 Witold Baryluk 2011-07-22 20:25:58 UTC
Ok, it looks that kobject initialization is now OK. Thanks.


...
[    0.081182] kobject: 'tpm' (f5c620c4): kobject_add_internal: parent: 'module', set: 'module'
[    0.081187] kobject: 'tpm' (f5c620c4): kobject_uevent_env
[    0.081190] kobject: 'tpm' (f5c620c4): fill_kobj_path: path = '/module/tpm'
[    0.081217] kobject: 'tpm_tis' (f5c8a184): kobject_add_internal: parent: 'module', set: 'module'
[    0.081221] kobject: 'tpm_tis' (f5c8a184): kobject_uevent_env
[    0.081225] kobject: 'tpm_tis' (f5c8a184): fill_kobj_path: path = '/module/tpm_tis'
[    0.081251] kobject: 'tpm_nsc' (f5c8a5c4): kobject_add_internal: parent: 'module', set: 'module'
[    0.081256] kobject: 'tpm_nsc' (f5c8a5c4): kobject_uevent_env
[    0.081259] kobject: 'tpm_nsc' (f5c8a5c4): fill_kobj_path: path = '/module/tpm_nsc'
...
[    0.084579] kobject: 'tpm' (f5c620c4): kobject_uevent_env
[    0.084583] kobject: 'tpm' (f5c620c4): fill_kobj_path: path = '/module/tpm'
[    0.084609] kobject: 'tpm_tis' (f5c8a184): kobject_uevent_env
[    0.084613] kobject: 'tpm_tis' (f5c8a184): fill_kobj_path: path = '/module/tpm_tis'
[    0.084640] kobject: 'tpm_tis' (f5c8a184): kobject_uevent_env
[    0.084644] kobject: 'tpm_tis' (f5c8a184): fill_kobj_path: path = '/module/tpm_tis'
[    0.084673] kobject: 'tpm_tis' (f5c8a184): kobject_uevent_env
[    0.084677] kobject: 'tpm_tis' (f5c8a184): fill_kobj_path: path = '/module/tpm_tis'
[    0.084705] kobject: 'tpm_tis' (f5c8a184): kobject_uevent_env
[    0.084708] kobject: 'tpm_tis' (f5c8a184): fill_kobj_path: path = '/module/tpm_tis'
...
[    1.138124] kobject: 'nvram' (f5f5ce24): kobject_add_internal: parent: 'misc', set: 'devices'
[    1.138143] kobject: 'nvram' (f5f5ce24): kobject_uevent_env
[    1.138147] kobject: 'nvram' (f5f5ce24): fill_kobj_path: path = '/devices/virtual/misc/nvram'
[    1.138147] kobject: 'nvram' (f5f5ce24): fill_kobj_path: path = '/devices/virtual/misc/nvram'
[    1.138181] Non-volatile memory driver v1.3
[    1.138229] Hangcheck: starting hangcheck timer 0.9.1 (tick is 180 seconds, margin is 60 seconds).
[    1.138307] Hangcheck: Using getrawmonotonic().
[    1.138358] kobject: 'tpm_tis' (f5f5f9c8): kobject_add_internal: parent: 'drivers', set: 'drivers'
[    1.138376] kobject: 'tpm_tis' (f5f5f9c8): kobject_uevent_env
[    1.138381] kobject: 'tpm_tis' (f5f5f9c8): fill_kobj_path: path = '/bus/pnp/drivers/tpm_tis'
[    1.138469] kobject: 'tpm_nsc' (f5f611b0): kobject_add_internal: parent: 'drivers', set: 'drivers'
[    1.138476] kobject: 'tpm_nsc' (f5f611b0): kobject_uevent_env
[    1.138480] kobject: 'tpm_nsc' (f5f611b0): fill_kobj_path: path = '/bus/platform/drivers/tpm_nsc'
[    1.138521] kobject: 'tpm_nscl0' (f5f6272c): kobject_add_internal: parent: 'platform', set: 'devices'
[    1.138534] kobject: 'tpm_nscl0' (f5f6272c): kobject_uevent_env
[    1.138538] kobject: 'tpm_nscl0' (f5f6272c): fill_kobj_path: path = '/devices/platform/tpm_nscl0'
[    1.138611] kobject: 'misc' (f5f64164): kobject_add_internal: parent: 'tpm_nscl0', set: '(null)'
[    1.138616] kobject: 'tpm0' (f5f60e24): kobject_add_internal: parent: 'misc', set: 'devices'
[    1.138634] kobject: 'tpm0' (f5f60e24): kobject_uevent_env
[    1.138639] kobject: 'tpm0' (f5f60e24): fill_kobj_path: path = '/devices/platform/tpm_nscl0/misc/tpm0'
[    1.138692] tpm_nsc tpm_nscl0: NSC TPM revision 2
[    1.138743] kobject: 'isa' (f5f64c98): kobject_add_internal: parent: 'bus', set: 'bus'
...
Comment 14 Witold Baryluk 2011-07-22 20:36:41 UTC
Everything works without problem. Thanks.

Tested-by: Witold Baryluk <baryluk@smp.if.uj.edu.pl>
Comment 15 Witold Baryluk 2011-07-27 15:57:01 UTC
I found interesting message in log when suspending, or rather fail to suspend computer to RAM.

Orginally thought it is just bug #34932 And first call trace looks to be the case. However second call trace looks to be something with initialization of tpm_tis.

[188056.511692] PM: Syncing filesystems ... done.
[188057.344873] Freezing user space processes ... 
[188077.360091] Freezing of tasks failed after 20.01 seconds (2 tasks refusing to freeze, wq_busy=0):
[188077.360819] collectd        D f524f900     0  3453   3443 0x00800004
[188077.361356]  f37c1e88 00000082 c1027ef6 f524f900 00000092 00000000 f37c1e38 00000092
[188077.362089]  00000000 f56ccfa0 f37c1e38 f37c1e60 c1026e67 00000000 00000001 00000003
[188077.362821]  f56ccfa0 f37c1e78 c10380be f56ccfa0 c1038a6f 00000000 00000000 f56ccfa0
[188077.363553] Call Trace:
[188077.363763]  [<c1027ef6>] ? check_preempt_curr+0x76/0x90
[188077.364188]  [<c1026e67>] ? __wake_up_common+0x47/0x70
[188077.364601]  [<c10380be>] ? recalc_sigpending+0xe/0x30
[188077.365013]  [<c1038a6f>] ? __set_task_blocked+0x2f/0x80
[188077.365438]  [<c103a5ad>] ? set_current_blocked+0xd/0x10
[188077.365863]  [<c103a60b>] ? sigprocmask+0x5b/0xd0
[188077.366243]  [<c11a7a7d>] ? fuse_request_send+0xbd/0x250
[188077.366669]  [<c1043b80>] ? finish_wait+0x50/0x50
[188077.367047]  [<c11b0a7c>] ? fuse_statfs+0xdc/0x160
[188077.367434]  [<c10cc6d5>] ? statfs_by_dentry+0xb5/0x110
[188077.367853]  [<c10cc74a>] ? vfs_statfs+0x1a/0xa0
[188077.368223]  [<c10cc808>] ? user_statfs+0x38/0x60
[188077.368601]  [<c10cc8ca>] ? sys_statfs64+0x1a/0x40
[188077.368987]  [<c15838d0>] ? sysenter_do_call+0x12/0x26
[188077.369427] transmission    D c10b8e8a     0 29447  29287 0x00800004
[188077.369963]  f41bdd08 00000086 f41bdce0 c10b8e8a 00000000 00000000 f562d900 c1028250
[188077.370707]  00000000 f01c0fa0 f41bdcb8 f54ddc64 c1026e67 00000000 00000001 00000003
[188077.371438]  f01c0fa0 f41bdcf8 c10380be f01c0fa0 c1038a6f 00000000 00000000 f01c0fa0
[188077.372170] Call Trace:
[188077.372373]  [<c10b8e8a>] ? pollwake+0x5a/0x60
[188077.372731]  [<c1028250>] ? try_to_wake_up+0x80/0x80
[188077.373129]  [<c1026e67>] ? __wake_up_common+0x47/0x70
[188077.373540]  [<c10380be>] ? recalc_sigpending+0xe/0x30
[188077.373952]  [<c1038a6f>] ? __set_task_blocked+0x2f/0x80
[188077.374377]  [<c103a5ad>] ? set_current_blocked+0xd/0x10
[188077.374802]  [<c103a60b>] ? sigprocmask+0x5b/0xd0
[188077.375180]  [<c11a7a7d>] ? fuse_request_send+0xbd/0x250
[188077.375605]  [<c1043b80>] ? finish_wait+0x50/0x50
[188077.375983]  [<c11aa109>] ? fuse_dentry_revalidate+0x189/0x2b0
[188077.376450]  [<c10b2f02>] ? do_lookup+0x212/0x370
[188077.376828]  [<c10b4b42>] ? link_path_walk+0x122/0x750
[188077.377240]  [<c10b3555>] ? path_init+0x275/0x340
[188077.377619]  [<c1455da5>] ? inet_recvmsg+0x45/0x60
[188077.378003]  [<c10b5268>] ? path_lookupat+0x48/0x640
[188077.378404]  [<c13de202>] ? sock_aio_read+0x112/0x140
[188077.378809]  [<c109ff85>] ? kmem_cache_alloc+0xc5/0x170
[188077.379228]  [<c10b5888>] ? do_path_lookup+0x28/0x80
[188077.379626]  [<c10b5bc6>] ? user_path_at+0x36/0x70
[188077.380022]  [<c10ad5f9>] ? vfs_fstatat+0x59/0x90
[188077.380399]  [<c10ad668>] ? vfs_stat+0x18/0x20
[188077.380756]  [<c10ada8e>] ? sys_stat64+0xe/0x30
[188077.381122]  [<c10aa1cd>] ? vfs_read+0x11d/0x130
[188077.381494]  [<c104b78f>] ? getnstimeofday+0x3f/0xe0
[188077.381894]  [<c120e1e3>] ? copy_to_user+0x33/0x70
[188077.382280]  [<c1030f0c>] ? sys_gettimeofday+0x2c/0x70
[188077.382691]  [<c15838d0>] ? sysenter_do_call+0x12/0x26
[188077.383105]  [<c1580000>] ? tpm_tis_init+0x1b9/0x372
[188077.383519] 
[188077.383643] Restarting tasks ... done.
Comment 16 Stefan Berger 2011-07-27 17:10:21 UTC
So the problem we previously solved was related to the NSC TPM's driver. So presumably this is the driver you are using? 

When I provoke the refusal to suspend, by for example creating a key, which on my TPM can take up to 6 minutes, it shows me the name of the tool that causes this, below creatkey:

[ 3777.641279] createkey       D 0000000000000000     0  6633   6632 0x00800084
[ 3777.641448]  ffff880131f9fdc8 0000000000000086 000000010035108a 0000000000000000
[ 3777.641722]  ffff8800a66d0000 ffff880131f9ffd8 0000000000012d40 ffff880131f9ffd8
[ 3777.641996]  ffff880135740000 ffff8800a66d0000 ffff880131f9fde0 0000000100000286
[ 3777.642305] Call Trace:
[ 3777.642368]  [<ffffffff81464172>] schedule_timeout+0xa7/0xde
[ 3777.642430]  [<ffffffff8105a643>] ? del_timer+0x7a/0x7a
[ 3777.642490]  [<ffffffff814641c7>] schedule_timeout_uninterruptible+0x1e/0x20
[ 3777.642552]  [<ffffffff8105b096>] msleep+0x1b/0x22
[ 3777.642616]  [<ffffffffa0142265>] tpm_transmit+0x103/0x17b [tpm]
[ 3777.642677]  [<ffffffffa014261d>] tpm_write+0x8f/0xc0 [tpm]
[ 3777.642738]  [<ffffffffa014258e>] ? tpm_chip_find_get+0x13b/0x13b [tpm]
[ 3777.642801]  [<ffffffff8111c1a6>] vfs_write+0xac/0xf3
[ 3777.642861]  [<ffffffff8111d395>] ? fget_light+0x38/0x98
[ 3777.642921]  [<ffffffff8111c395>] sys_write+0x4a/0x6e
[ 3777.642981]  [<ffffffff8146be02>] system_call_fastpath+0x16/0x1b

Now in your case the programs are collectd and transmission. What is 'transmission'? I see the tpm_tis_init in the path. Did you insmod he tpm_tis driver? If you did an insmod / modprobe tpm_tis, does it block?
What version of Linux are you using?

   Stefan
Comment 17 Stefan Berger 2011-07-27 18:27:02 UTC
One more thing. I have posted patches to the Linux mailing list that are on their way to upstream (I hope) and may solve problems related to the TPM TIS driver's probing for interrupts taking ages -- if that's what's happening here.
Comment 18 Stefan Berger 2011-07-28 12:55:12 UTC
(In reply to comment #17)
> One more thing. I have posted patches to the Linux mailing list that are on
> their way to upstream (I hope) and may solve problems related to the TPM TIS
> driver's probing for interrupts taking ages -- if that's what's happening
> here.

As of today the tip of Linus's tree has the patches for the TPM. It should solve above problem - assuming it was related to modprobing the tpm_tis kernel module.

  Stefan
Comment 19 Witold Baryluk 2011-07-29 10:11:55 UTC
OK.

I have both tpm_nsc and tpm_tis built-into kernel. On my hardware I use
tpm_nsc, and I do not use tpm_tis (as I do not have compatible tpm), so tpm_tis
should just say that there is nothing for it and return (I still had it
included in kernel just because I build kernel for few computer models, and one
of them actually have tis compatible hardware).

tpm_tis initialization probably blocks in separate kernel thread (most of
hardware initialization is now asynchronous, right?). collectd is just
collecting statistics (it blocks kernel due to the bug in fuse implementation).
transmission on the other hand also probably is using this fuse filesystem (it
is bittorent p2p client). It  should not use by itself TPM.

I think second problem is indeed problem with tpm_tis initialization (as I do not hardware for it). And is separate problem.
Comment 20 Stefan Berger 2011-07-29 11:05:19 UTC
(In reply to comment #19)

> transmission on the other hand also probably is using this fuse filesystem
> (it
> is bittorent p2p client). It  should not use by itself TPM.
> I think second problem is indeed problem with tpm_tis initialization (as I do
> not hardware for it). And is separate problem.

If possible, update your Linux sources to the latest tip of the tree and try again.
Comment 21 Florian Mickler 2011-08-08 08:23:00 UTC
A patch referencing this bug report has been merged in Linux v3.1-rc1:

commit 29412f0f6a19e34336368f13eab848091c343952
Author: Stefan Berger <stefanb@linux.vnet.ibm.com>
Date:   Fri Jul 22 17:39:20 2011 -0400

    tpm_nsc: Fix bug when loading multiple TPM drivers
Comment 22 Witold Baryluk 2012-02-08 00:49:11 UTC
Closing fixed bug.