RobertCNelson / ti-linux-kernel-dev

vendor bsp...
MIT License
87 stars 76 forks source link

tieqep: add patch to fix unhandled fault on 4.9 kernel #10

Closed pdp7 closed 7 years ago

pdp7 commented 7 years ago

This patch adds a fix for the tieqep driver to avoid unhandled fault when reading or writing to memory mapped eQEP registers.

The fix is to call pm_runtime_get_sync() at the beginning of any functions that will read from or write to eQEP registers. This should ensure that the eQEP peripheral is running and its clock is enabled.

Before this patch, an attempt to read the position file via sysfs would results in a segmentation fault. The kernel log would contain this error:

[ 2591.653471] Unhandled fault: external abort on non-linefetch (0x1028) at 0xfa304180
[ 2591.915165] [<bf005310>] (eqep_get_position [tieqep]) from [<c08930d0>] (dev_attr_show+0x2c/0x58)

Details: https://gist.github.com/pdp7/fe07082d23f2bfbc362c733a7b0aea72

BeagleBoard mailing list thread: https://groups.google.com/d/msg/beagleboard/_TdTH7oPEXE/MNvU-mY6DgAJ

pdp7 commented 7 years ago

4.9.6-ti-r18

Tests OK to read rotary encoder position with this patch applied:

root@beaglebone:~# uname -a
Linux beaglebone 4.9.6-ti-r18 #1 SMP PREEMPT Thu Feb 2 06:21:39 CST 2017 armv7l GNU/Linux
root@beaglebone:~# config-pin p8.11 qep && config-pin p8.12 qep
root@beaglebone:~# cat /sys/devices/platform/ocp/48304000.epwmss/48304180.eqep/position 
0
root@beaglebone:~# cat /sys/devices/platform/ocp/48304000.epwmss/48304180.eqep/position 
178
RobertCNelson commented 7 years ago

Thanks! @pdp7 merged!

pdp7 commented 7 years ago

@RobertCNelson Thanks, I've just built and tested 4.9.7-ti-r19 OK:

root@beaglebone:~# uname -r
4.9.7-ti-r19
root@beaglebone:~# config-pin p8.11 qep && config-pin p8.12 qep
root@beaglebone:~# cat /sys/devices/platform/ocp/48304000.epwmss/48304180.eqep/position 
1
root@beaglebone:~# cat /sys/devices/platform/ocp/48304000.epwmss/48304180.eqep/position 
97