Skip to contentSkip to conversation

Issue with imx_get_temp()

DISCUSSION Igor Plyatov 4 participants 8 messages Dec 2, 2019 – Jan 9, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Dear all,

please  look at back-trace below. It happens on Freescale i.MX6 Quad.

Found a few of those during power on/off stress test in the climate chamber:

[    0.657596] ------------[ cut here ]------------
[    0.657626] WARNING: CPU: 3 PID: 150 at /home/geosig/development/oe-core-toradex-cr7/build/tmp-glibc/work-shared/cr7/kernel-source/kernel/irq/chip.c:242 __irq_startup+0x94/0xa8
[    0.657630] Modules linked in:
[    0.657643] CPU: 3 PID: 150 Comm: kworker/3:1 Not tainted 5.1.1 #1
[    0.657648] Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
[    0.657660] Workqueue: events deferred_probe_work_func
[    0.657691] [<8011005c>] (unwind_backtrace) from [<8010b8c8>] (show_stack+0x10/0x14)
[    0.657709] [<8010b8c8>] (show_stack) from [<80857b04>] (dump_stack+0x88/0x9c)
[    0.657727] [<80857b04>] (dump_stack) from [<8011f308>] (__warn+0xdc/0xf4)
[    0.657741] [<8011f308>] (__warn) from [<8011f438>] (warn_slowpath_null+0x40/0x48)
[    0.657752] [<8011f438>] (warn_slowpath_null) from [<8016d1a8>] (__irq_startup+0x94/0xa8)
[    0.657762] [<8016d1a8>] (__irq_startup) from [<8016d208>] (irq_startup+0x4c/0x130)
[    0.657772] [<8016d208>] (irq_startup) from [<8016a6dc>] (enable_irq+0x44/0x90)
[    0.657790] [<8016a6dc>] (enable_irq) from [<8066f05c>] (imx_get_temp+0x1bc/0x1fc)
[    0.657804] [<8066f05c>] (imx_get_temp) from [<8066cd78>] (thermal_zone_get_temp+0x48/0x68)
[    0.657816] [<8066cd78>] (thermal_zone_get_temp) from [<8066a3e4>] (thermal_zone_device_update.part.3+0x28/0xcc)
[    0.657827] [<8066a3e4>] (thermal_zone_device_update.part.3) from [<8066afc4>] (thermal_zone_device_register+0x4ac/0x5ec)
[    0.657837] [<8066afc4>] (thermal_zone_device_register) from [<8066f580>] (imx_thermal_probe+0x3a8/0x61c)
[    0.657853] [<8066f580>] (imx_thermal_probe) from [<8054ae90>] (platform_drv_probe+0x48/0x98)
[    0.657864] [<8054ae90>] (platform_drv_probe) from [<805492a4>] (really_probe+0x228/0x2d0)
[    0.657875] [<805492a4>] (really_probe) from [<805494ac>] (driver_probe_device+0x60/0x174)
[    0.657892] [<805494ac>] (driver_probe_device) from [<805476f4>] (bus_for_each_drv+0x58/0xb8)
[    0.657903] [<805476f4>] (bus_for_each_drv) from [<80549008>] (__device_attach+0xd0/0x13c)
[    0.657914] [<80549008>] (__device_attach) from [<80548404>] (bus_probe_device+0x84/0x8c)
[    0.657923] [<80548404>] (bus_probe_device) from [<8054889c>] (deferred_probe_work_func+0x64/0x90)
[    0.657938] [<8054889c>] (deferred_probe_work_func) from [<80136fd0>] (process_one_work+0x204/0x420)
[    0.657952] [<80136fd0>] (process_one_work) from [<80137ddc>] (worker_thread+0x44/0x5bc)
[    0.657966] [<80137ddc>] (worker_thread) from [<8013cab0>] (kthread+0x144/0x14c)
[    0.657978] [<8013cab0>] (kthread) from [<801010e8>] (ret_from_fork+0x14/0x2c)
[    0.657984] Exception stack(0xd0ae1fb0 to 0xd0ae1ff8)
[    0.657992] 1fa0:                                     00000000 00000000 00000000 00000000
[    0.658002] 1fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[    0.658010] 1fe0: 00000000 00000000 00000000 00000000 00000013 00000000
[    0.658016] ---[ end trace 6bb553a60c0886bd ]---

Can somebody recommend, how to debug/resolve this issue?

Best wishes.
--
Igor Plyatov

#1 lore raw

Hi,

From: linux-arm-kernel [mailto:[email protected]] On Behalf Of Igor Plyatov
Sent: Monday, December 2, 2019 2:45 PM

Quoted 10 lines

Dear all,

please  look at back-trace below. It happens on Freescale i.MX6 Quad.

Found a few of those during power on/off stress test in the climate chamber:

[    0.657596] ------------[ cut here ]------------
[    0.657626] WARNING: CPU: 3 PID: 150 at /home/geosig/development/oe-core-toradex-cr7/build/tmp-glibc/work-shared/cr7/kernel-source/kernel/irq/chip.c:242 __irq_startup+0x94/0xa8
[    0.657630] Modules linked in:

Having the following issue on kernel 4.19.87 on a imx6ull SoC.
This sometimes happens during kernel boot, but when the system comes up, it works normally.

Unable to handle kernel NULL pointer dereference at virtual address 00000c00
pgd = (ptrval)
[00000c00] *pgd=00000000
Internal error: Oops: 80000005 [#1] PREEMPT SMP ARM
Modules linked in:
CPU: 0 PID: 5 Comm: kworker/0:0 Not tainted 4.19.87-dhsom-g8bbbef713fb0 #2
Hardware name: Freescale i.MX6 Ultralite (Device Tree)
Workqueue: events deferred_probe_work_func
PC is at 0xc00
LR is at _raw_spin_lock_irqsave+0x4c/0x58
pc : [<00000c00>]    lr : [<c0a7bc68>]    psr: 60000193

sp : c1643cc8 ip : c1643cc8 fp : c1643cf4
r10: 00000000 r9 : c1010548 r8 : c16f2010
r7 : c1705600 r6 : c0567518 r5 : 60000113 r4 : c1705600 r3 : c162b200 r2 : 00000000 r1 : 00000000 r0 : c1705600
Flags: nZCv IRQs off FIQs on Mode SVC_32 ISA ARM Segment none
Control: 10c5387d Table: 8000406a DAC: 00000051 Process kworker/0:0 (pid: 5, stack limit = 0x(ptrval))

Stack: (0xc1643cc8 to 0xc1644000)

3cc0: 00000001 00000000 c0567518 40000113 c1643cfc c1705600
3ce0: 00000184 00000001 c1643d0c c1643cf8 c0567518 c0a7bc28 c1705600 00000184 3d00: c1643d2c c1643d10 c056a240 c0567510 c1c1af40 00000012 c16f2000 c1705600 3d20: c1643d7c c1643d30 c0726500 c056a218 00000000 00000000 00000000 7a7daaf8 3d40: c16f2010 c16f2010 00000080 7a7daaf8 c0564e7c 00000000 c16f2010 c10629d4 3d60: c15ccc1c c10629d4 00000001 00000000 c1643d9c c1643d80 c0551e5c c0726304 3d80: c15ccc18 c16f2010 00000000 c15ccc1c c1643dcc c1643da0 c054ff04 c0551df4 3da0: 00000000 c16f2010 c10629d4 c16f2010 c05503a0 00000001 00000001 c1010548 3dc0: c1643e04 c1643dd0 c0550148 c054fce4 c0795754 c0793a10 c1643e04 c1643de8 3de0: c10629d4 c1643e5c c16f2010 c05503a0 00000001 00000001 c1643e24 c1643e08 3e00: c0550430 c05500f0 00000000 c1643e5c c1010548 c05503a0 c1643e54 c1643e28 3e20: c054df24 c05503ac c1643e54 c15ebed4 c1bcd0d4 7a7daaf8 c16f2010 c16f2044 3e40: c1010548 cbdbc600 c1643e8c c1643e58 c054fc50 c054deb4 00000002 c16f2010 3e60: 00000001 7a7daaf8 00000000 c16f2010 c16f2010 c103f800 cbdbc600 c1643f04 3e80: c1643e9c c1643e90 c0550454 c054fb88 c1643ebc c1643ea0 c054eff0 c055044c 3ea0: c16f2010 c103f43c c103f488 cbdbc600 c1643edc c1643ec0 c054f4bc c054ef6c 3ec0: c15f8700 c103f494 cbdb92c0 cbdbc600 c1643f44 c1643ee0 c013bcac c054f464 3ee0: 00000001 00000000 c013bc3c 00000080 00000000 00000000 00000000 00000000 3f00: cbdb92c0 c103f494 c11cf940 00000000 c0dc23f0 7a7daaf8 c0a7bcbc cbdb92c0 3f20: c15f8714 00000008 cbdb92f4 c1005900 cbdb92c0 c15f8700 c1643f7c c1643f48 3f40: c013bf60 c013baf8 c15f8780 00000000 c1643f7c c15f8780 00000000 c1608ec0 3f60: c15f8700 c013bf34 c15f87b8 c161de48 c1643fac c1643f80 c014203c c013bf40 3f80: 00000000 c1608ec0 c0141f24 00000000 00000000 00000000 00000000 00000000 3fa0: 00000000 c1643fb0 c01010e8 c0141f30 00000000 00000000 00000000 00000000 3fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 3fe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000000 00000000

Backtrace: 
[<c0a7bc1c>] (_raw_spin_lock_irqsave) from [<c0567518>] (regmap_lock_spinlock+0x14/0x1c)
 r6:00000001 r5:00000184 r4:c1705600
[<c0567504>] (regmap_lock_spinlock) from [<c056a240>] (regmap_write+0x34/0x64)
 r5:00000184 r4:c1705600
[<c056a20c>] (regmap_write) from [<c0726500>] (imx_thermal_probe+0x208/0x654)
 r7:c1705600 r6:c16f2000 r5:00000012 r4:c1c1af40
[<c07262f8>] (imx_thermal_probe) from [<c0551e5c>] (platform_drv_probe+0x74/0xac)
 r10:00000000 r9:00000001 r8:c10629d4 r7:c15ccc1c r6:c10629d4 r5:c16f2010
 r4:00000000
[<c0551de8>] (platform_drv_probe) from [<c054ff04>] (really_probe+0x22c/0x2d0)
 r7:c15ccc1c r6:00000000 r5:c16f2010 r4:c15ccc18
[<c054fcd8>] (really_probe) from [<c0550148>] (driver_probe_device+0x64/0x188)
 r10:c1010548 r9:00000001 r8:00000001 r7:c05503a0 r6:c16f2010 r5:c10629d4
 r4:c16f2010 r3:00000000
[<c05500e4>] (driver_probe_device) from [<c0550430>] (__device_attach_driver+0x90/0xa0)
 r9:00000001 r8:00000001 r7:c05503a0 r6:c16f2010 r5:c1643e5c r4:c10629d4
[<c05503a0>] (__device_attach_driver) from [<c054df24>] (bus_for_each_drv+0x7c/0xc4)
 r7:c05503a0 r6:c1010548 r5:c1643e5c r4:00000000
[<c054dea8>] (bus_for_each_drv) from [<c054fc50>] (__device_attach+0xd4/0x144)
 r7:cbdbc600 r6:c1010548 r5:c16f2044 r4:c16f2010
[<c054fb7c>] (__device_attach) from [<c0550454>] (device_initial_probe+0x14/0x18)
 r8:c1643f04 r7:cbdbc600 r6:c103f800 r5:c16f2010 r4:c16f2010
[<c0550440>] (device_initial_probe) from [<c054eff0>] (bus_probe_device+0x90/0x98)
[<c054ef60>] (bus_probe_device) from [<c054f4bc>] (deferred_probe_work_func+0x64/0x94)
 r7:cbdbc600 r6:c103f488 r5:c103f43c r4:c16f2010
[<c054f458>] (deferred_probe_work_func) from [<c013bcac>] (process_one_work+0x1c0/0x448)
 r7:cbdbc600 r6:cbdb92c0 r5:c103f494 r4:c15f8700
[<c013baec>] (process_one_work) from [<c013bf60>] (worker_thread+0x2c/0x520)
 r10:c15f8700 r9:cbdb92c0 r8:c1005900 r7:cbdb92f4 r6:00000008 r5:c15f8714
 r4:cbdb92c0
[<c013bf34>] (worker_thread) from [<c014203c>] (kthread+0x118/0x154)
 r10:c161de48 r9:c15f87b8 r8:c013bf34 r7:c15f8700 r6:c1608ec0 r5:00000000
 r4:c15f8780
[<c0141f24>] (kthread) from [<c01010e8>] (ret_from_fork+0x14/0x2c)
Exception stack(0xc1643fb0 to 0xc1643ff8)

3fa0: 00000000 00000000 00000000 00000000
3fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 3fe0: 00000000 00000000 00000000 00000000 00000013 00000000
r10:00000000 r9:00000000 r8:00000000 r7:00000000 r6:00000000 r5:c0141f24 r4:c1608ec0 r3:00000000

Code: bad PC value
---[ end trace 12a07887f3c97eb0 ]---

Could my issue and Igor Plyatov issue have the same cause or are the two different problems of the "imx_thermal" driver?

Thanks and best regards,
Christoph
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#2 lore raw
In reply to Igor Plyatov

Hi Igor,

Quoted 41 lines · Igor Plyatov

Dear all,

please  look at back-trace below. It happens on Freescale i.MX6 Quad.

Found a few of those during power on/off stress test in the climate chamber:

[    0.657596] ------------[ cut here ]------------
[    0.657626] WARNING: CPU: 3 PID: 150 at /home/geosig/development/oe-core-toradex-cr7/build/tmp-glibc/work-shared/cr7/kernel-source/kernel/irq/chip.c:242 __irq_startup+0x94/0xa8
[    0.657630] Modules linked in:
[    0.657643] CPU: 3 PID: 150 Comm: kworker/3:1 Not tainted 5.1.1 #1
[    0.657648] Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
[    0.657660] Workqueue: events deferred_probe_work_func
[    0.657691] [<8011005c>] (unwind_backtrace) from [<8010b8c8>] (show_stack+0x10/0x14)
[    0.657709] [<8010b8c8>] (show_stack) from [<80857b04>] (dump_stack+0x88/0x9c)
[    0.657727] [<80857b04>] (dump_stack) from [<8011f308>] (__warn+0xdc/0xf4)
[    0.657741] [<8011f308>] (__warn) from [<8011f438>] (warn_slowpath_null+0x40/0x48)
[    0.657752] [<8011f438>] (warn_slowpath_null) from [<8016d1a8>] (__irq_startup+0x94/0xa8)
[    0.657762] [<8016d1a8>] (__irq_startup) from [<8016d208>] (irq_startup+0x4c/0x130)
[    0.657772] [<8016d208>] (irq_startup) from [<8016a6dc>] (enable_irq+0x44/0x90)
[    0.657790] [<8016a6dc>] (enable_irq) from [<8066f05c>] (imx_get_temp+0x1bc/0x1fc)
[    0.657804] [<8066f05c>] (imx_get_temp) from [<8066cd78>] (thermal_zone_get_temp+0x48/0x68)
[    0.657816] [<8066cd78>] (thermal_zone_get_temp) from [<8066a3e4>] (thermal_zone_device_update.part.3+0x28/0xcc)
[    0.657827] [<8066a3e4>] (thermal_zone_device_update.part.3) from [<8066afc4>] (thermal_zone_device_register+0x4ac/0x5ec)
[    0.657837] [<8066afc4>] (thermal_zone_device_register) from [<8066f580>] (imx_thermal_probe+0x3a8/0x61c)
[    0.657853] [<8066f580>] (imx_thermal_probe) from [<8054ae90>] (platform_drv_probe+0x48/0x98)
[    0.657864] [<8054ae90>] (platform_drv_probe) from [<805492a4>] (really_probe+0x228/0x2d0)
[    0.657875] [<805492a4>] (really_probe) from [<805494ac>] (driver_probe_device+0x60/0x174)
[    0.657892] [<805494ac>] (driver_probe_device) from [<805476f4>] (bus_for_each_drv+0x58/0xb8)
[    0.657903] [<805476f4>] (bus_for_each_drv) from [<80549008>] (__device_attach+0xd0/0x13c)
[    0.657914] [<80549008>] (__device_attach) from [<80548404>] (bus_probe_device+0x84/0x8c)
[    0.657923] [<80548404>] (bus_probe_device) from [<8054889c>] (deferred_probe_work_func+0x64/0x90)
[    0.657938] [<8054889c>] (deferred_probe_work_func) from [<80136fd0>] (process_one_work+0x204/0x420)
[    0.657952] [<80136fd0>] (process_one_work) from [<80137ddc>] (worker_thread+0x44/0x5bc)
[    0.657966] [<80137ddc>] (worker_thread) from [<8013cab0>] (kthread+0x144/0x14c)
[    0.657978] [<8013cab0>] (kthread) from [<801010e8>] (ret_from_fork+0x14/0x2c)
[    0.657984] Exception stack(0xd0ae1fb0 to 0xd0ae1ff8)
[    0.657992] 1fa0:                                     00000000 00000000 00000000 00000000
[    0.658002] 1fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[    0.658010] 1fe0: 00000000 00000000 00000000 00000000 00000013 00000000
[    0.658016] ---[ end trace 6bb553a60c0886bd ]---
Quoted 1 line

Can somebody recommend, how to debug/resolve this issue?

Mh.. it seems that the irq gets enabled before a irq-handler is registered. As your backlog shows the thermal_zone_device_register() triggers a imx_get_temp() and during boot the irq_enabled is false and it seems that your temperature is below the alarm_temp. So in such a case the enable_irq() is executed. I don't know what happens if we enable a irq without a irq-handler.

Regards,
Marco

Quoted 6 lines

Best wishes.
--
Igor Plyatov

Signature · 9 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
reviewer
#3 lore raw

Hi Marco,

Quoted 6 lines · Marco Felsch

Mh.. it seems that the irq gets enabled before a irq-handler is registered. As your backlog shows the thermal_zone_device_register() triggers a imx_get_temp() and during boot the irq_enabled is false and it seems that your temperature is below the alarm_temp. So in such a case the enable_irq() is executed. I don't know what happens if we enable a irq without a irq-handler.

I think your analysis makes sense.

Should we move the ' data->irq_enabled = true' just prior to calling thermal_zone_device_register()?

drivers/thermal/imx_thermal.c +1 -1
@@ -803,6 +803,7 @@ static int imx_thermal_probe(struct platform_device *pdev)
                goto legacy_cleanup;
        }
 
+       data->irq_enabled = true;
        data->tz = thermal_zone_device_register("imx_thermal_zone",
                                                IMX_TRIP_NUM,
                                                BIT(IMX_TRIP_PASSIVE), data,
@@ -837,7 +838,6 @@ static int imx_thermal_probe(struct platform_device *pdev)
        regmap_write(map, data->socdata->sensor_ctrl + REG_SET,
                     data->socdata->measure_temp_mask);
 
-       data->irq_enabled = true;
        data->mode = THERMAL_DEVICE_ENABLED;
 
        ret = devm_request_threaded_irq(&pdev->dev, data->irq,
reviewer
#4 lore raw
Quoted 12 lines · Fabio Estevam

Hi Marco,

Quoted 6 lines · Marco Felsch

Mh.. it seems that the irq gets enabled before a irq-handler is registered. As your backlog shows the thermal_zone_device_register() triggers a imx_get_temp() and during boot the irq_enabled is false and it seems that your temperature is below the alarm_temp. So in such a case the enable_irq() is executed. I don't know what happens if we enable a irq without a irq-handler.

Quoted 4 lines

I think your analysis makes sense.

Should we move the ' data->irq_enabled = true' just prior to calling thermal_zone_device_register()?

Or maybe we could call thermal_zone_device_register() later?

Igor,

Does the following patch help?
http://code.bulix.org/l3rz2e-982595

reviewer
#6 lore raw

Hi Igor,

Quoted 11 lines · Igor Plyatov

Dear Fabio,

Quoted 2 lines

Does the following patch help?
http://code.bulix.org/l3rz2e-982595

Thank you!

Patch applied and will be tested.

I will inform you about results.

How did your tests go?