linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Nokia N900: v4.16-rc4: oops in iio when grepping sysfs
@ 2018-03-09 22:12 Pavel Machek
  2018-03-09 22:28 ` Greg KH
  0 siblings, 1 reply; 7+ messages in thread
From: Pavel Machek @ 2018-03-09 22:12 UTC (permalink / raw)
  To: pali.rohar, sre, kernel list, linux-arm-kernel, linux-omap, tony,
	khilman, aaro.koskinen, ivo.g.dimitrov.75, patrikbachan, serge,
	abcloriens, clayton, martijn, sakari.ailus, Filip Matijević,
	security, jic23, knaack.h, lars, pmeerw, linux-iio

[-- Attachment #1: Type: text/plain, Size: 2546 bytes --]

Hi!

Hmm. Looks like there's a lot of fun to be had with sysfs.

								Pavel


pavel@n900:~$ uname -a
Linux n900 4.16.0-rc4-59690-g7f84626-dirty #543 Thu Mar 8 19:53:30 CET
2018 armv7l GNU/Linux

[  306.402496] bq2415x: command Timer reset
[  312.761322] adp1653 2-0030: Read Addr:03 Val:00 ok
[  313.264129] Unable to handle kernel NULL pointer dereference at
virtual address 00000
000
[  313.272308] pgd = 01336620
[  313.275146] [00000000] *pgd=800af831, *pte=00000000, *ppte=00000000
[  313.281463] Internal error: Oops: 80000007 [#1] ARM
[  313.286376] Modules linked in:
[  313.289459] CPU: 0 PID: 3584 Comm: grep Tainted: G        W
4.16.0-rc4-59690-g
7f84626-dirty #543
[  313.298919] Hardware name: Nokia RX-51 board
[  313.303222] PC is at   (null)
[  313.306213] LR is at iio_ev_state_show+0x38/0x54
[  313.310852] pc : [<00000000>]    lr : [<c05d69c0>]    psr: a0000013
[  313.317169] sp : c7b47e70  ip : c087bb24  fp : 00000001
[  313.322418] r10: cb19e000  r9 : c0857220  r8 : 00001000
[  313.327667] r7 : 00000fff  r6 : cb711c80  r5 : cb19e000  r4 :
00000000
[  313.334228] r3 : 00000001  r2 : 00000000  r1 : c087b4dc  r0 :
ce584800
[  313.340789] Flags: NzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM
Segment none
[  313.347991] Control: 10c5387d  Table: 87bec019  DAC: 00000051
[  313.353759] Process grep (pid: 3584, stack limit = 0xc4e45eab)
[  313.359619] Stack: (0xc7b47e70 to 0xc7b48000)
[  313.364013] 7e60:                                     c05d6988
cb711b00 ce585c00 c0450d68
[  313.471038] [<c05d69c0>] (iio_ev_state_show) from [<c0450d68>]
(dev_attr_show+0x1c/0x4c)
[  313.479187] [<c0450d68>] (dev_attr_show) from [<c023f934>]
(sysfs_kf_seq_show+0x90/0x108)
[  313.487426] [<c023f934>] (sysfs_kf_seq_show) from [<c023e2f8>]
(kernfs_seq_show+0x24/0x28)
[  313.495758] [<c023e2f8>] (kernfs_seq_show) from [<c01fc954>]
(seq_read+0x1dc/0x500)
[  313.503479] [<c01fc954>] (seq_read) from [<c01d9f80>]
(__vfs_read+0x2c/0x120)
[  313.510681] [<c01d9f80>] (__vfs_read) from [<c01da0fc>]
(vfs_read+0x88/0x114)
[  313.517852] [<c01da0fc>] (vfs_read) from [<c01da584>]
(SyS_read+0x40/0x8c)
[  313.524780] [<c01da584>] (SyS_read) from [<c0101000>]
(ret_fast_syscall+0x0/0x54)
[  313.532318] Exception stack(0xc7b47fa8 to 0xc7b47ff0)
[  313.537414] 7fa0:                   00035330 00042000 00000003
00042000 00008000 00008000


-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Nokia N900: v4.16-rc4: oops in iio when grepping sysfs
  2018-03-09 22:12 Nokia N900: v4.16-rc4: oops in iio when grepping sysfs Pavel Machek
@ 2018-03-09 22:28 ` Greg KH
  2018-03-09 23:01   ` Pavel Machek
  0 siblings, 1 reply; 7+ messages in thread
From: Greg KH @ 2018-03-09 22:28 UTC (permalink / raw)
  To: Pavel Machek
  Cc: pali.rohar, sre, kernel list, linux-arm-kernel, linux-omap, tony,
	khilman, aaro.koskinen, ivo.g.dimitrov.75, patrikbachan, serge,
	abcloriens, clayton, martijn, sakari.ailus, Filip Matijević,
	security, jic23, knaack.h, lars, pmeerw, linux-iio

On Fri, Mar 09, 2018 at 11:12:21PM +0100, Pavel Machek wrote:
> Hi!
> 
> Hmm. Looks like there's a lot of fun to be had with sysfs.
> 
> 								Pavel
> 
> 
> pavel@n900:~$ uname -a
> Linux n900 4.16.0-rc4-59690-g7f84626-dirty #543 Thu Mar 8 19:53:30 CET
> 2018 armv7l GNU/Linux
> 
> [  306.402496] bq2415x: command Timer reset
> [  312.761322] adp1653 2-0030: Read Addr:03 Val:00 ok
> [  313.264129] Unable to handle kernel NULL pointer dereference at
> virtual address 00000
> 000
> [  313.272308] pgd = 01336620
> [  313.275146] [00000000] *pgd=800af831, *pte=00000000, *ppte=00000000
> [  313.281463] Internal error: Oops: 80000007 [#1] ARM
> [  313.286376] Modules linked in:
> [  313.289459] CPU: 0 PID: 3584 Comm: grep Tainted: G        W
> 4.16.0-rc4-59690-g
> 7f84626-dirty #543
> [  313.298919] Hardware name: Nokia RX-51 board
> [  313.303222] PC is at   (null)
> [  313.306213] LR is at iio_ev_state_show+0x38/0x54
> [  313.310852] pc : [<00000000>]    lr : [<c05d69c0>]    psr: a0000013
> [  313.317169] sp : c7b47e70  ip : c087bb24  fp : 00000001
> [  313.322418] r10: cb19e000  r9 : c0857220  r8 : 00001000
> [  313.327667] r7 : 00000fff  r6 : cb711c80  r5 : cb19e000  r4 :
> 00000000
> [  313.334228] r3 : 00000001  r2 : 00000000  r1 : c087b4dc  r0 :
> ce584800
> [  313.340789] Flags: NzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM
> Segment none
> [  313.347991] Control: 10c5387d  Table: 87bec019  DAC: 00000051
> [  313.353759] Process grep (pid: 3584, stack limit = 0xc4e45eab)
> [  313.359619] Stack: (0xc7b47e70 to 0xc7b48000)
> [  313.364013] 7e60:                                     c05d6988
> cb711b00 ce585c00 c0450d68
> [  313.471038] [<c05d69c0>] (iio_ev_state_show) from [<c0450d68>]
> (dev_attr_show+0x1c/0x4c)
> [  313.479187] [<c0450d68>] (dev_attr_show) from [<c023f934>]
> (sysfs_kf_seq_show+0x90/0x108)
> [  313.487426] [<c023f934>] (sysfs_kf_seq_show) from [<c023e2f8>]
> (kernfs_seq_show+0x24/0x28)
> [  313.495758] [<c023e2f8>] (kernfs_seq_show) from [<c01fc954>]
> (seq_read+0x1dc/0x500)
> [  313.503479] [<c01fc954>] (seq_read) from [<c01d9f80>]
> (__vfs_read+0x2c/0x120)
> [  313.510681] [<c01d9f80>] (__vfs_read) from [<c01da0fc>]
> (vfs_read+0x88/0x114)
> [  313.517852] [<c01da0fc>] (vfs_read) from [<c01da584>]
> (SyS_read+0x40/0x8c)
> [  313.524780] [<c01da584>] (SyS_read) from [<c0101000>]
> (ret_fast_syscall+0x0/0x54)
> [  313.532318] Exception stack(0xc7b47fa8 to 0xc7b47ff0)
> [  313.537414] 7fa0:                   00035330 00042000 00000003
> 00042000 00008000 00008000
> 

What file are you opening to cause this?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Nokia N900: v4.16-rc4: oops in iio when grepping sysfs
  2018-03-09 22:28 ` Greg KH
@ 2018-03-09 23:01   ` Pavel Machek
  2018-03-10 11:19     ` Akinobu Mita
  2018-03-10 11:19     ` Lars-Peter Clausen
  0 siblings, 2 replies; 7+ messages in thread
From: Pavel Machek @ 2018-03-09 23:01 UTC (permalink / raw)
  To: Greg KH, jic23, akinobu.mita, javier, gregor.boirie
  Cc: pali.rohar, sre, kernel list, linux-arm-kernel, linux-omap, tony,
	khilman, aaro.koskinen, ivo.g.dimitrov.75, patrikbachan, serge,
	abcloriens, clayton, martijn, sakari.ailus, Filip Matijević,
	security, jic23, knaack.h, lars, pmeerw, linux-iio

[-- Attachment #1: Type: text/plain, Size: 3662 bytes --]

Hi!

> > Hmm. Looks like there's a lot of fun to be had with sysfs.
> > 
> > 
> > pavel@n900:~$ uname -a
> > Linux n900 4.16.0-rc4-59690-g7f84626-dirty #543 Thu Mar 8 19:53:30 CET
> > 2018 armv7l GNU/Linux
> > 
> > [  306.402496] bq2415x: command Timer reset
> > [  312.761322] adp1653 2-0030: Read Addr:03 Val:00 ok
> > [  313.264129] Unable to handle kernel NULL pointer dereference at
> > virtual address 00000
> > 000
> > [  313.272308] pgd = 01336620
> > [  313.275146] [00000000] *pgd=800af831, *pte=00000000, *ppte=00000000
> > [  313.281463] Internal error: Oops: 80000007 [#1] ARM
> > [  313.286376] Modules linked in:
> > [  313.289459] CPU: 0 PID: 3584 Comm: grep Tainted: G        W
> > 4.16.0-rc4-59690-g
> > 7f84626-dirty #543
> > [  313.298919] Hardware name: Nokia RX-51 board
> > [  313.303222] PC is at   (null)
> > [  313.306213] LR is at iio_ev_state_show+0x38/0x54
> > [  313.310852] pc : [<00000000>]    lr : [<c05d69c0>]    psr: a0000013
> > [  313.317169] sp : c7b47e70  ip : c087bb24  fp : 00000001
> > [  313.322418] r10: cb19e000  r9 : c0857220  r8 : 00001000
> > [  313.327667] r7 : 00000fff  r6 : cb711c80  r5 : cb19e000  r4 :
> > 00000000
> > [  313.334228] r3 : 00000001  r2 : 00000000  r1 : c087b4dc  r0 :
> > ce584800
> > [  313.340789] Flags: NzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM
> > Segment none
> > [  313.347991] Control: 10c5387d  Table: 87bec019  DAC: 00000051
> > [  313.353759] Process grep (pid: 3584, stack limit = 0xc4e45eab)
> > [  313.359619] Stack: (0xc7b47e70 to 0xc7b48000)
> > [  313.364013] 7e60:                                     c05d6988
> > cb711b00 ce585c00 c0450d68
> > [  313.471038] [<c05d69c0>] (iio_ev_state_show) from [<c0450d68>]
> > (dev_attr_show+0x1c/0x4c)
> > [  313.479187] [<c0450d68>] (dev_attr_show) from [<c023f934>]
> > (sysfs_kf_seq_show+0x90/0x108)
> > [  313.487426] [<c023f934>] (sysfs_kf_seq_show) from [<c023e2f8>]
> > (kernfs_seq_show+0x24/0x28)
> > [  313.495758] [<c023e2f8>] (kernfs_seq_show) from [<c01fc954>]
> > (seq_read+0x1dc/0x500)
> > [  313.503479] [<c01fc954>] (seq_read) from [<c01d9f80>]
> > (__vfs_read+0x2c/0x120)
> > [  313.510681] [<c01d9f80>] (__vfs_read) from [<c01da0fc>]
> > (vfs_read+0x88/0x114)
> > [  313.517852] [<c01da0fc>] (vfs_read) from [<c01da584>]
> > (SyS_read+0x40/0x8c)
> > [  313.524780] [<c01da584>] (SyS_read) from [<c0101000>]
> > (ret_fast_syscall+0x0/0x54)
> > [  313.532318] Exception stack(0xc7b47fa8 to 0xc7b47ff0)
> > [  313.537414] 7fa0:                   00035330 00042000 00000003
> > 00042000 00008000 00008000
> > 
> 
> What file are you opening to cause this?

Strace says:

openat(7, "in_intensity_both_thresh_rising_en",
> > O_RDONLY|O_LARGEFILE|O_NOFOLLOW) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0
ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbe83b714) = -1 ENOTTY
> > (Inappropriate ioctl for device)
read(3,
Message from syslogd@localhost at Mar  9 23:54:39 ...
 kernel:[ 3097.357696] Internal error: Oops: 80000007 [#2] ARM

So that would be:

./devices/platform/68000000.ocp/48072000.i2c/i2c-2/2-0029/iio:device1/events/in_intensity_both_thresh_rising_en

And indeed, manually cat-ing that file reproduces the problem.

pavel@n900:/sys/devices/platform/68000000.ocp/48072000.i2c/i2c-2/2-0029/iio:device1$
cat name
tsl2563

I can not find tsl2563 in MAINTAINERS, file is
./drivers/iio/light/tsl2563.c . I added few people pointed by git log.

Best regards,
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Nokia N900: v4.16-rc4: oops in iio when grepping sysfs
  2018-03-09 23:01   ` Pavel Machek
@ 2018-03-10 11:19     ` Akinobu Mita
  2018-03-10 11:19     ` Lars-Peter Clausen
  1 sibling, 0 replies; 7+ messages in thread
From: Akinobu Mita @ 2018-03-10 11:19 UTC (permalink / raw)
  To: Pavel Machek
  Cc: Greg KH, Jonathan Cameron, javier, gregor.boirie, pali.rohar,
	sre, kernel list, linux-arm-kernel, linux-omap, tony, khilman,
	aaro.koskinen, ivo.g.dimitrov.75, patrikbachan, serge,
	abcloriens, clayton, martijn, Sakari Ailus, Filip Matijević,
	security, Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald,
	linux-iio

2018-03-10 8:01 GMT+09:00 Pavel Machek <pavel@ucw.cz>:
> Hi!
>
>> > Hmm. Looks like there's a lot of fun to be had with sysfs.
>> >
>> >
>> > pavel@n900:~$ uname -a
>> > Linux n900 4.16.0-rc4-59690-g7f84626-dirty #543 Thu Mar 8 19:53:30 CET
>> > 2018 armv7l GNU/Linux
>> >
>> > [  306.402496] bq2415x: command Timer reset
>> > [  312.761322] adp1653 2-0030: Read Addr:03 Val:00 ok
>> > [  313.264129] Unable to handle kernel NULL pointer dereference at
>> > virtual address 00000
>> > 000
>> > [  313.272308] pgd = 01336620
>> > [  313.275146] [00000000] *pgd=800af831, *pte=00000000, *ppte=00000000
>> > [  313.281463] Internal error: Oops: 80000007 [#1] ARM
>> > [  313.286376] Modules linked in:
>> > [  313.289459] CPU: 0 PID: 3584 Comm: grep Tainted: G        W
>> > 4.16.0-rc4-59690-g
>> > 7f84626-dirty #543
>> > [  313.298919] Hardware name: Nokia RX-51 board
>> > [  313.303222] PC is at   (null)
>> > [  313.306213] LR is at iio_ev_state_show+0x38/0x54
>> > [  313.310852] pc : [<00000000>]    lr : [<c05d69c0>]    psr: a0000013
>> > [  313.317169] sp : c7b47e70  ip : c087bb24  fp : 00000001
>> > [  313.322418] r10: cb19e000  r9 : c0857220  r8 : 00001000
>> > [  313.327667] r7 : 00000fff  r6 : cb711c80  r5 : cb19e000  r4 :
>> > 00000000
>> > [  313.334228] r3 : 00000001  r2 : 00000000  r1 : c087b4dc  r0 :
>> > ce584800
>> > [  313.340789] Flags: NzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM
>> > Segment none
>> > [  313.347991] Control: 10c5387d  Table: 87bec019  DAC: 00000051
>> > [  313.353759] Process grep (pid: 3584, stack limit = 0xc4e45eab)
>> > [  313.359619] Stack: (0xc7b47e70 to 0xc7b48000)
>> > [  313.364013] 7e60:                                     c05d6988
>> > cb711b00 ce585c00 c0450d68
>> > [  313.471038] [<c05d69c0>] (iio_ev_state_show) from [<c0450d68>]
>> > (dev_attr_show+0x1c/0x4c)
>> > [  313.479187] [<c0450d68>] (dev_attr_show) from [<c023f934>]
>> > (sysfs_kf_seq_show+0x90/0x108)
>> > [  313.487426] [<c023f934>] (sysfs_kf_seq_show) from [<c023e2f8>]
>> > (kernfs_seq_show+0x24/0x28)
>> > [  313.495758] [<c023e2f8>] (kernfs_seq_show) from [<c01fc954>]
>> > (seq_read+0x1dc/0x500)
>> > [  313.503479] [<c01fc954>] (seq_read) from [<c01d9f80>]
>> > (__vfs_read+0x2c/0x120)
>> > [  313.510681] [<c01d9f80>] (__vfs_read) from [<c01da0fc>]
>> > (vfs_read+0x88/0x114)
>> > [  313.517852] [<c01da0fc>] (vfs_read) from [<c01da584>]
>> > (SyS_read+0x40/0x8c)
>> > [  313.524780] [<c01da584>] (SyS_read) from [<c0101000>]
>> > (ret_fast_syscall+0x0/0x54)
>> > [  313.532318] Exception stack(0xc7b47fa8 to 0xc7b47ff0)
>> > [  313.537414] 7fa0:                   00035330 00042000 00000003
>> > 00042000 00008000 00008000
>> >
>>
>> What file are you opening to cause this?
>
> Strace says:
>
> openat(7, "in_intensity_both_thresh_rising_en",
>> > O_RDONLY|O_LARGEFILE|O_NOFOLLOW) = 3
> fstat64(3, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0
> ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbe83b714) = -1 ENOTTY
>> > (Inappropriate ioctl for device)
> read(3,
> Message from syslogd@localhost at Mar  9 23:54:39 ...
>  kernel:[ 3097.357696] Internal error: Oops: 80000007 [#2] ARM
>
> So that would be:
>
> ./devices/platform/68000000.ocp/48072000.i2c/i2c-2/2-0029/iio:device1/events/in_intensity_both_thresh_rising_en
>
> And indeed, manually cat-ing that file reproduces the problem.

This problem happens when no irq is defined for this device.

In this case, tsl2563_info_no_irq whose read_event_config field is NULL
is selected as iio_info.  On the other hand, iio_chan_spec for this
driver always registers event_spec.

So sysfs files related to the channel events are always created even if
no irq is defined.

I think we can fix this issue by defining another iio_chan_spec with
no event_spec for no irq case.

Jonathan, do you have any other idea how to fix this issue?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Nokia N900: v4.16-rc4: oops in iio when grepping sysfs
  2018-03-09 23:01   ` Pavel Machek
  2018-03-10 11:19     ` Akinobu Mita
@ 2018-03-10 11:19     ` Lars-Peter Clausen
  2018-03-10 12:00       ` Pavel Machek
  1 sibling, 1 reply; 7+ messages in thread
From: Lars-Peter Clausen @ 2018-03-10 11:19 UTC (permalink / raw)
  To: Pavel Machek, Greg KH, jic23, akinobu.mita, javier, gregor.boirie
  Cc: pali.rohar, sre, kernel list, linux-arm-kernel, linux-omap, tony,
	khilman, aaro.koskinen, ivo.g.dimitrov.75, patrikbachan, serge,
	abcloriens, clayton, martijn, sakari.ailus, Filip Matijević,
	security, knaack.h, pmeerw, linux-iio

On 03/10/2018 12:01 AM, Pavel Machek wrote:
[...]
>> What file are you opening to cause this?
> 
> Strace says:
> 
> openat(7, "in_intensity_both_thresh_rising_en",
>>> O_RDONLY|O_LARGEFILE|O_NOFOLLOW) = 3
> fstat64(3, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0
> ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbe83b714) = -1 ENOTTY
>>> (Inappropriate ioctl for device)
> read(3,
> Message from syslogd@localhost at Mar  9 23:54:39 ...
>  kernel:[ 3097.357696] Internal error: Oops: 80000007 [#2] ARM
> 
> So that would be:
> 
> ./devices/platform/68000000.ocp/48072000.i2c/i2c-2/2-0029/iio:device1/events/in_intensity_both_thresh_rising_en
> 
> And indeed, manually cat-ing that file reproduces the problem.
> 
> pavel@n900:/sys/devices/platform/68000000.ocp/48072000.i2c/i2c-2/2-0029/iio:device1$
> cat name
> tsl2563
> 
> I can not find tsl2563 in MAINTAINERS, file is
> ./drivers/iio/light/tsl2563.c . I added few people pointed by git log.

The driver registers event attributes, but does not provide a handle to
access those attributes.

Now the question is how to best handle this case.

1) Return an error when the device is registered and abort registration
2) Skip registering the event attributes
3) Skip registering the event attributes, but print a warning
4) Register the attributes, but return an error when they are accessed

I'd prefer 2 since it offers a nice method of disabling all events for a
device (e.g. if not interrupt is provided).

On the other hand it could cause some confusion during development,
potentially causing the developer to wonder why he doesn't get any event
attributes even though he setup his channel description to have event
attributes.

Patch for 2.

--- a/drivers/iio/industrialio-event.c
+++ b/drivers/iio/industrialio-event.c
@@ -477,7 +477,8 @@ int iio_device_register_eventset(struct iio_dev
 	struct attribute **attr;

 	if (!(indio_dev->info->event_attrs ||
-	      iio_check_for_dynamic_events(indio_dev)))
+	      iio_check_for_dynamic_events(indio_dev)) ||
+	    !indio_dev->info->read_event_config)
 		return 0;

 	indio_dev->event_interface =

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Nokia N900: v4.16-rc4: oops in iio when grepping sysfs
  2018-03-10 11:19     ` Lars-Peter Clausen
@ 2018-03-10 12:00       ` Pavel Machek
  2018-03-10 17:59         ` Jonathan Cameron
  0 siblings, 1 reply; 7+ messages in thread
From: Pavel Machek @ 2018-03-10 12:00 UTC (permalink / raw)
  To: Lars-Peter Clausen
  Cc: Greg KH, jic23, akinobu.mita, javier, gregor.boirie, pali.rohar,
	sre, kernel list, linux-arm-kernel, linux-omap, tony, khilman,
	aaro.koskinen, ivo.g.dimitrov.75, patrikbachan, serge,
	abcloriens, clayton, martijn, sakari.ailus, Filip Matijević,
	security, knaack.h, pmeerw, linux-iio

[-- Attachment #1: Type: text/plain, Size: 2392 bytes --]

Hi!

On Sat 2018-03-10 12:19:29, Lars-Peter Clausen wrote:
> On 03/10/2018 12:01 AM, Pavel Machek wrote:
> [...]
> >> What file are you opening to cause this?
> > 
> > Strace says:
> > 
> > openat(7, "in_intensity_both_thresh_rising_en",
> >>> O_RDONLY|O_LARGEFILE|O_NOFOLLOW) = 3
> > fstat64(3, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0
> > ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbe83b714) = -1 ENOTTY
> >>> (Inappropriate ioctl for device)
> > read(3,
> > Message from syslogd@localhost at Mar  9 23:54:39 ...
> >  kernel:[ 3097.357696] Internal error: Oops: 80000007 [#2] ARM
> > 
> > So that would be:
> > 
> > ./devices/platform/68000000.ocp/48072000.i2c/i2c-2/2-0029/iio:device1/events/in_intensity_both_thresh_rising_en
> > 
> > And indeed, manually cat-ing that file reproduces the problem.
> > 
> > pavel@n900:/sys/devices/platform/68000000.ocp/48072000.i2c/i2c-2/2-0029/iio:device1$
> > cat name
> > tsl2563
> > 
> > I can not find tsl2563 in MAINTAINERS, file is
> > ./drivers/iio/light/tsl2563.c . I added few people pointed by git log.
> 
> The driver registers event attributes, but does not provide a handle to
> access those attributes.
> 
> Now the question is how to best handle this case.
> 
> 1) Return an error when the device is registered and abort registration
> 2) Skip registering the event attributes
> 3) Skip registering the event attributes, but print a warning
> 4) Register the attributes, but return an error when they are accessed
> 
> I'd prefer 2 since it offers a nice method of disabling all events for a
> device (e.g. if not interrupt is provided).

2 works for me.

Tested-by: Pavel Machek <pavel@ucw.cz>
Reported-by: Pavel Machek <pavel@ucw.cz>

Now grep -ri asdfasdf /sys finishes.

Thanks,
								Pavel

> --- a/drivers/iio/industrialio-event.c
> +++ b/drivers/iio/industrialio-event.c
> @@ -477,7 +477,8 @@ int iio_device_register_eventset(struct iio_dev
>  	struct attribute **attr;
> 
>  	if (!(indio_dev->info->event_attrs ||
> -	      iio_check_for_dynamic_events(indio_dev)))
> +	      iio_check_for_dynamic_events(indio_dev)) ||
> +	    !indio_dev->info->read_event_config)
>  		return 0;
> 
>  	indio_dev->event_interface =

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Nokia N900: v4.16-rc4: oops in iio when grepping sysfs
  2018-03-10 12:00       ` Pavel Machek
@ 2018-03-10 17:59         ` Jonathan Cameron
  0 siblings, 0 replies; 7+ messages in thread
From: Jonathan Cameron @ 2018-03-10 17:59 UTC (permalink / raw)
  To: Pavel Machek
  Cc: Lars-Peter Clausen, Greg KH, akinobu.mita, javier, gregor.boirie,
	pali.rohar, sre, kernel list, linux-arm-kernel, linux-omap, tony,
	khilman, aaro.koskinen, ivo.g.dimitrov.75, patrikbachan, serge,
	abcloriens, clayton, martijn, sakari.ailus, Filip Matijević,
	security, knaack.h, pmeerw, linux-iio

On Sat, 10 Mar 2018 13:00:53 +0100
Pavel Machek <pavel@ucw.cz> wrote:

> Hi!
> 
> On Sat 2018-03-10 12:19:29, Lars-Peter Clausen wrote:
> > On 03/10/2018 12:01 AM, Pavel Machek wrote:
> > [...]  
> > >> What file are you opening to cause this?  
> > > 
> > > Strace says:
> > > 
> > > openat(7, "in_intensity_both_thresh_rising_en",  
> > >>> O_RDONLY|O_LARGEFILE|O_NOFOLLOW) = 3  
> > > fstat64(3, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0
> > > ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbe83b714) = -1 ENOTTY  
> > >>> (Inappropriate ioctl for device)  
> > > read(3,
> > > Message from syslogd@localhost at Mar  9 23:54:39 ...
> > >  kernel:[ 3097.357696] Internal error: Oops: 80000007 [#2] ARM
> > > 
> > > So that would be:
> > > 
> > > ./devices/platform/68000000.ocp/48072000.i2c/i2c-2/2-0029/iio:device1/events/in_intensity_both_thresh_rising_en
> > > 
> > > And indeed, manually cat-ing that file reproduces the problem.
> > > 
> > > pavel@n900:/sys/devices/platform/68000000.ocp/48072000.i2c/i2c-2/2-0029/iio:device1$
> > > cat name
> > > tsl2563
> > > 
> > > I can not find tsl2563 in MAINTAINERS, file is
> > > ./drivers/iio/light/tsl2563.c . I added few people pointed by git log.  
> > 
> > The driver registers event attributes, but does not provide a handle to
> > access those attributes.
> > 
> > Now the question is how to best handle this case.
> > 
> > 1) Return an error when the device is registered and abort registration
> > 2) Skip registering the event attributes
> > 3) Skip registering the event attributes, but print a warning
> > 4) Register the attributes, but return an error when they are accessed
> > 
> > I'd prefer 2 since it offers a nice method of disabling all events for a
> > device (e.g. if not interrupt is provided).  
> 
> 2 works for me.
> 
> Tested-by: Pavel Machek <pavel@ucw.cz>
> Reported-by: Pavel Machek <pavel@ucw.cz>
> 
> Now grep -ri asdfasdf /sys finishes.

Hmm. I'd count this as a good general prevention of what is actually
a driver bug.  The driver should either have failed or as has been suggested
should have come up without the event sysfs attributes by registering different
abilities.

So I'm favour of this change, but from a semantic point of view I'd
like the addition of a warning for this case and ideally for the driver
to be fixed to not attempt to add them (two iio_info structures which
is what a lot of other drivers do to allow them to work with and
without the interrupt being available.).

Anyhow, Lars, please send a formal patch for the below and we'll
get that headed for mainline asap.

> 
> Thanks,
> 								Pavel
> 
> > --- a/drivers/iio/industrialio-event.c
> > +++ b/drivers/iio/industrialio-event.c
> > @@ -477,7 +477,8 @@ int iio_device_register_eventset(struct iio_dev
> >  	struct attribute **attr;
> > 
> >  	if (!(indio_dev->info->event_attrs ||
> > -	      iio_check_for_dynamic_events(indio_dev)))
> > +	      iio_check_for_dynamic_events(indio_dev)) ||
> > +	    !indio_dev->info->read_event_config)
> >  		return 0;
> > 
> >  	indio_dev->event_interface =  
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-03-10 17:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-09 22:12 Nokia N900: v4.16-rc4: oops in iio when grepping sysfs Pavel Machek
2018-03-09 22:28 ` Greg KH
2018-03-09 23:01   ` Pavel Machek
2018-03-10 11:19     ` Akinobu Mita
2018-03-10 11:19     ` Lars-Peter Clausen
2018-03-10 12:00       ` Pavel Machek
2018-03-10 17:59         ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).