[Letux-kernel] two accelerometers + iio_bridge considered harmful
H. Nikolaus Schaller
hns at goldelico.com
Wed Aug 1 09:14:58 CEST 2018
Hi,
> Am 01.08.2018 um 08:22 schrieb H. Nikolaus Schaller <hns at goldelico.com>:
>
>>
>>
>> So first question is it really worth to make it thread-safe
>
> Well, a simple mutex would help.
>
> But where could we initialize it before the first channel is registered?
> And make sure that it is initialized only once (without another mutex)?
Ah, it is easy. DEFINE_MUTEX is a static initializer :)
Attached is a new patch which does not break my devices (except rmmod, see
below - this might be if channels[0].data is no longer valid) and may help
in your setup. Please let me know your results.
BTW: we might improve the scheme to register iio channels from a single
chip only and ignore others so that they are never mixed up.
Something like:
if (indio_dev != channels[0].indio_dev)
return 0;
There is still a problem that it is not deterministic which one is taken.
This would need a device tree property... But someone might argue that
this does not belong into a hardware description.
So a different scheme would be to collect all different indio_dev and
create a unique input device for each of them. So for two chips we get
two input devices.
Then, udev might be able to give them unique file names in /dev/input
(e.g. accel, accel2, ...) as we have it for keyboard, modem, etc.
BR,
Nikolaus
root at letux:~# modprobe -r bno055
root at letux:~# modprobe bno055
[ 396.624755] bno055 1-0029: software revision id 0311
root at letux:~# modprobe -r bmc150_accel_i2c
[ 405.711547] Unable to handle kernel paging request at virtual address fffffff0
[ 405.719116] pgd = dbc63e24
[ 405.721954] [fffffff0] *pgd=afffd861, *pte=00000000, *ppte=00000000
[ 405.728546] Internal error: Oops: 837 [#1] PREEMPT SMP ARM
[ 405.734252] Modules linked in: bno055 usb_f_ecm g_ether usb_f_rndis u_ether libcomposite configfs ipv6 arc4 wl18xx wlcore mac80211 hso cfg80211 omapdrm drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops drm drm_panel_orientation_quirks pps_gpio panel_tpo_td028ttec1 snd_soc_simple_card snd_soc_omap_twl4030 snd_soc_simple_card_utils pps_core wwan_on_off encoder_opa362 snd_soc_w2cbw003_bt snd_soc_gtm601 pwm_omap_dmtimer connector_analog_tv generic_adc_battery pwm_bl omap3_isp videobuf2_dma_contig wlcore_sdio videobuf2_memops videobuf2_v4l2 bmp280_spi ov9655 bq27xxx_battery_hdq videobuf2_common bq27xxx_battery v4l2_fwnode v4l2_common omap_hdq omap2430 bmp280_i2c bmp280 videodev at24 tsc2007 leds_tca6507 media bmc150_accel_i2c(-) bmc150_magn_i2c bmc150_accel_core bmc150_magn industrialio_triggered_buffer
[ 405.809478] phy_twl4030_usb kfifo_buf snd_soc_si47xx snd_soc_omap_mcbsp snd_soc_sdma musb_hdrc gpio_twl4030 snd_soc_twl4030 twl4030_pwrbutton gnss_w2sg0004 twl4030_charger twl4030_madc twl4030_vibra industrialio gnss w2cbw003_bluetooth ehci_omap omapdss omapdss_base cec [last unloaded: bno055]
[ 405.836822] CPU: 0 PID: 2781 Comm: modprobe Not tainted 4.18.0-rc7-letux+ #2577
[ 405.844451] Hardware name: Generic OMAP36xx (Flattened Device Tree)
[ 405.851043] PC is at __input_unregister_device+0x50/0x12c
[ 405.856689] LR is at __input_unregister_device+0x3c/0x12c
[ 405.862335] pc : [<c05f2158>] lr : [<c05f2144>] psr: a0000093
[ 405.868865] sp : ed5bbed0 ip : ee437800 fp : becbae04
[ 405.874328] r10: 00000081 r9 : ed5ba000 r8 : ee23c4cc
[ 405.879791] r7 : ee319a54 r6 : ed02b96c r5 : ed02bb30 r4 : ed02b800
[ 405.886627] r3 : ffffffec r2 : 00000000 r1 : 00000000 r0 : ed02b800
[ 405.893432] Flags: NzCv IRQs off FIQs on Mode SVC_32 ISA ARM Segment none
[ 405.901000] Control: 10c5387d Table: ad578019 DAC: 00000051
[ 405.907012] Process modprobe (pid: 2781, stack limit = 0x31d308ea)
[ 405.913452] Stack: (0xed5bbed0 to 0xed5bc000)
[ 405.918029] bec0: ed02b800 ed03062c ed0306c0 c05f2288
[ 405.926574] bee0: bf0793dc bf076994 ed030400 bf0713b0 bf152000 ee319a20 ed030400 bf1421c4
[ 405.935119] bf00: ee319a20 ee319a00 bf154020 c0607018 c0606fe4 ee319a20 ee23c498 c04fd21c
[ 405.943695] bf20: ee319a20 bf154020 00000800 0044a6ec c0101204 c04fd348 6805fc82 bf154020
[ 405.952239] bf40: c0b03d48 c04fc45c bf154080 c01abf68 31636d62 615f3035 6c656363 6332695f
[ 405.960815] bf60: 00000000 ed02c9c0 ee437800 ee437c78 ed02c9c0 ee437800 ee437c78 00000000
[ 405.969360] bf80: ed02c9c0 c014eb1c 00101204 6805fc82 ed5bbfb0 0044a6b8 0044a6b8 00000001
[ 405.977905] bfa0: 00000081 c0101000 0044a6b8 0044a6b8 0044a6ec 00000800 31265700 00000000
[ 405.986450] bfc0: 0044a6b8 0044a6b8 00000001 00000081 00000000 00000001 0044a6b8 becbae04
[ 405.995025] bfe0: b6f36521 becb9a2c 0042c613 b6f36526 80000030 0044a6ec 00000000 00000000
[ 406.003601] [<c05f2158>] (__input_unregister_device) from [<c05f2288>] (input_unregister_device+0x4c/0x6c)
[ 406.013763] [<c05f2288>] (input_unregister_device) from [<bf076994>] (iio_device_unregister_inputbridge+0x1c/0x38 [industrialio])
[ 406.026000] [<bf076994>] (iio_device_unregister_inputbridge [industrialio]) from [<bf0713b0>] (iio_device_unregister+0x1c/0x64 [industrialio])
[ 406.039428] [<bf0713b0>] (iio_device_unregister [industrialio]) from [<bf1421c4>] (bmc150_accel_core_remove+0x18/0xa8 [bmc150_accel_core])
[ 406.052459] [<bf1421c4>] (bmc150_accel_core_remove [bmc150_accel_core]) from [<c0607018>] (i2c_device_remove+0x34/0x74)
[ 406.063720] [<c0607018>] (i2c_device_remove) from [<c04fd21c>] (device_release_driver_internal+0x138/0x1f8)
[ 406.073913] [<c04fd21c>] (device_release_driver_internal) from [<c04fd348>] (driver_detach+0x60/0x6c)
[ 406.083587] [<c04fd348>] (driver_detach) from [<c04fc45c>] (bus_remove_driver+0x64/0x8c)
[ 406.092041] [<c04fc45c>] (bus_remove_driver) from [<c01abf68>] (sys_delete_module+0x198/0x22c)
[ 406.101074] [<c01abf68>] (sys_delete_module) from [<c0101000>] (ret_fast_syscall+0x0/0x54)
[ 406.109710] Exception stack(0xed5bbfa8 to 0xed5bbff0)
[ 406.114990] bfa0: 0044a6b8 0044a6b8 0044a6ec 00000800 31265700 00000000
[ 406.123535] bfc0: 0044a6b8 0044a6b8 00000001 00000081 00000000 00000001 0044a6b8 becbae04
[ 406.132080] bfe0: b6f36521 becb9a2c 0042c613 b6f36526
[ 406.137390] Code: e3a01000 e2433014 e2832014 e1550002 (15831004)
[ 406.143768] ---[ end trace ca382565bec93816 ]---
[ 406.148834] note: modprobe[2781] exited with preempt_count 1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-iio-input-bridge-improve-iio_device_unregister_input.patch
Type: application/octet-stream
Size: 1349 bytes
Desc: not available
URL: <http://lists.goldelico.com/pipermail/letux-kernel/attachments/20180801/2c1fe551/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-iio-input-bridge-add-mutex-locking-to-prevent-agains.patch
Type: application/octet-stream
Size: 3130 bytes
Desc: not available
URL: <http://lists.goldelico.com/pipermail/letux-kernel/attachments/20180801/2c1fe551/attachment-0003.obj>
-------------- next part --------------
More information about the Letux-kernel
mailing list