Commit Graph

17 Commits

Author SHA1 Message Date
Ben Fennema 03e7d8c864 nanohub: fix out of bounds write in nanohub_spi_read
SPI_MIN_DMA can cause a request for greater than the number
of bytes needed to complete a packet. Limit the number of bytes
copied into the rx buffer by the rx buffer length.

Bug: 35804737
Change-Id: Ibb02272fa549879f716519f541bff656104f8a1c
Signed-off-by: Ben Fennema <fennema@google.com>
Signed-off-by: Siqi Lin <siqilin@google.com>
2017-03-01 15:40:37 -08:00
Ben Fennema e67b13b892 nanohub: increase wakeup sensor sample wakelock from 10ms to 250ms
Bug: 28470911
Bug: 28759940

Change-Id: Ia64eb3a2ca8edfd0b214c3f107aed2a25cbed450
Signed-off-by: Ben Fennema <fennema@google.com>
(cherry picked from commit 3a8f2ce01574ce1dc510a7b3a5c8e5c534531c3d)
2016-05-13 14:14:56 -07:00
Ben Fennema a85e42348d nanohub: fix build on non arm64 targets
Bug: 28397847

Change-Id: I72111095321d0f39dd33f427f15aeea79e6813e7
Signed-off-by: Ben Fennema <fennema@google.com>
2016-04-26 10:50:25 -07:00
Alexey Polyudov 58488b617d ANDROID: nanohub: force correct state of wakeup signal
wakeup signal management was not correct for IRQ2-enabled
systems. Unwanted transitions on wakeup line were causing
IRQ1 in response, and blocking suspend operation.

wakeup signal management is reworked, so that it is
controlled by pair of counters:
lock counter keeps track of all wakeup requests, and
wakeup counter keeps track of only those requests who
need to wakeup MCU by driving wakeup low.

Signed-off-by: Alexey Polyudov <apolyudov@google.com>
Change-Id: Ie7c2cd3b8927976fbd20177a76d77fea7205293d
Bug: 28271752
2016-04-22 12:13:45 -07:00
Ben Fennema e38670a882 nanohub: fix non-wakeup sensors when using irq2
Bug: 28316655

Change-Id: Ia1601d1cb2d26a8960325ffd743f2ef64dd4486c
Signed-off-by: Ben Fennema <fennema@google.com>
2016-04-21 18:18:30 -07:00
Ben Fennema d66828f8a9 nanohub: send one large spi transaction for cmd + response
Don't issue a read request when no pending interrupts.
Bump up the read kthread priority

Bug: 27815143

Change-Id: I810865aaaf5d08e858d66c4ede1e6a703b4e8d38
Signed-off-by: Ben Fennema <fennema@google.com>
2016-04-20 21:58:56 +00:00
Alexey Polyudov a4f5ac0fb9 ANDROID: nanohub: fix suspend interaction with IRQ2
platforms with IRQ2 available are not able to suspend,
if non-wakeup events are flowing quite often.

To fix it, we acquire lock on wakeup signal, before
attempting to check for IO activity.

We no longer need to check the activity of worker thread,
because if we have the lock, thread has nothing to do but wait
for us, however it may not yet reach the IDLE state, and
we don't want to lose time waiting for this to happen.

Signed-off-by: Alexey Polyudov <apolyudov@google.com>
Change-Id: Id9c661ec022b8a6b1b53ebdcd7392006d74e40d5
Bug: 28271752
2016-04-20 14:32:31 -07:00
Alexey Polyudov 7b57553944 ANDROID: nanohub: fix error in IRQ management
Fixes IRQ2 handling in nanohub_reset();
issue introduced in

commit 3eaf0d1025d2 ("ANDROID: nanohub: fix error handling on probe path")

Bug: 28250645
Original Author: Alexey Polyudov <apolyudov@google.com>
Change-Id: I5b889b4127bdc5bdca2964e6b6ab0021c19093d4
Signed-off-by: Alexey Polyudov <apolyudov@google.com>
2016-04-19 00:05:53 +00:00
Trevor Bunker b1b1acfd25 nanohub: fix nanohub_request_gpios return value
Change-Id: I29e5a477341ed7df1e658f40c3e0981fa8433365
2016-04-14 15:00:02 -07:00
Alexey Polyudov ef288ac602 ANDROID: nanohub: fix FW upload on older versions
Older versions of sensorhub hang while triyng to
communicate with FW, because FW upload did not
succeed.

This behavior was introduced by
commit 3eaf0d1025d2 ("ANDROID: nanohub: fix error handling on probe path")
This change is removing requirement for
interrupt handshake as precondition for FW upload,
hence resolves the issue. It also adds timeout on
write as extra precausion.

Signed-off-by: Alexey Polyudov <apolyudov@google.com>
Change-Id: I1e6a39f7c43c0a083b89fb6e48ea30006ce96f4a
Bug: 27421260
2016-04-14 16:20:26 +00:00
Alexey Polyudov 3e44b8a241 ANDROID: nanohub: fix error handling on probe path
this fixes resource leaks in case of failures at probe
time. fixes leaks on module unload as well.

removes some code duplication. minor logic cleanup.

Signed-off-by: Alexey Polyudov <apolyudov@google.com>
Bug: 27810219
Change-Id: I1f3ebdf78fe44b3ac97a64717819d75a485b6470
2016-04-14 16:17:02 +00:00
Ben Fennema 24bee51912 nanohub: add missing spin_lock_init
Change-Id: Ibbd96594bc8b92f08e975899fbecb6ad7e54be0c
Signed-off-by: Ben Fennema <fennema@google.com>
2016-03-22 07:47:00 -07:00
Ben Fennema 00fe3f7859 nanohub: add context_hub hal support
add /dev/nanohub_comms for context hub hal to communicate through

Change-Id: Idc02b3a0be7c85bc86ce95671c031f0ed56c0e37
Signed-off-by: Ben Fennema <fennema@google.com>
2016-03-21 14:22:16 -07:00
Ben Fennema 60edac8724 nanohub: time out messages via elapsed time and not transactions
The spacing between spi transactions can vary greatly, so time
out based on elapsed time instead of number of transactions.

Change-Id: I21ef1f5f0e7a1946871c0614d438ec9b7c91275f
Signed-off-by: Ben Fennema <fennema@google.com>
2016-03-09 13:20:48 -08:00
Ben Fennema 9db57a3f30 nanohub: add timeout to suspend
Timeout and log an error instead of waiting forever for the sensorhub to
wake up.

Bug: 27373474

Change-Id: If4a200490846ee303a4177ebca8c31824ce34199
Signed-off-by: Ben Fennema <fennema@google.com>
2016-03-08 12:03:46 -08:00
Ben Fennema 0d54f9be56 nanohub: add spinlock around wakeup gpio changes in request and release wakeup
error path:
thread1:
release_wakeup:
    dec wakeup_cnt, new value is 0:
        <schedule occurs> (prior to setting wakeup gpio to inactive)

thread2:
request_wakeup:
    inc wakeup_cnt, new value is 1:
        set wakeup gpio to active
    ...

thread1:
        set wakeup gpio to inactive

Bug: 27336006

Change-Id: I72b5e408207c7cef18153c93f041eb734c17adec
Signed-off-by: Ben Fennema <fennema@google.com>
2016-03-07 09:44:29 -08:00
Ben Fennema dd4b8a08e5 nanohub: add nanohub kernel driver
Adds nanohub kernel driver files as well as device tree configuration to
use nanohub instead of contexthub (spich)

Change-Id: I089dd5c3a08968a002e965e8d1ed260b93e32ce3
Signed-off-by: Ben Fennema <fennema@google.com>
2016-02-05 12:51:01 -08:00