Commit graph

562786 commits

Author SHA1 Message Date
Colin Cross
4dedd9f124 cpuidle: governor: menu: don't use loadavg
get_loadavg doesn't work as intended.  According to the comments, it
should be returning an average over a few seconds, but it is actually
reading the instantaneous load.  It is almost always returning 0, but
can sometimes, depending on workload, spike very high into the hundreds
even when the average cpu load is under 10%.  Disable it for now.

Change-Id: I63ed100af1cf9463549939b8113ed83676db5f86
Signed-off-by: Colin Cross <ccross@android.com>
2016-02-16 13:52:31 -08:00
Riley Andrews
7abc800d04 sched: add sched blocked tracepoint which dumps out context of sleep.
Decare war on uninterruptible sleep. Add a tracepoint which
walks the kernel stack and dumps the first non-scheduler function
called before the scheduler is invoked.

Change-Id: I19e965d5206329360a92cbfe2afcc8c30f65c229
Signed-off-by: Riley Andrews <riandrews@google.com>
2016-02-16 13:52:31 -08:00
Arve Hjønnevåg
b3bb0e5bbf sched: Enable might_sleep before initializing drivers.
This allows detection of init bugs in built-in drivers.

Signed-off-by: Arve Hjønnevåg <arve@android.com>
2016-02-16 13:52:30 -08:00
John Stultz
e4123d4ac6 fiq_debugger: Build fixes for 4.1
Small build updates for 4.1

Signed-off-by: John Stultz <john.stultz@linaro.org>
2016-02-16 13:52:30 -08:00
Arve Hjønnevåg
8591e0429e fiq_debugger: Add fiq_watchdog_triggered api
Dumps registers and stacktrace into console-ramoops when called
from a watchdog fiq.

Change-Id: Ib6fab5a52f670db18e64214d5e4890e8292a749c
Signed-off-by: Arve Hjønnevåg <arve@android.com>
2016-02-16 13:52:29 -08:00
Arve Hjønnevåg
592a91a756 fiq_debugger: Call fiq_debugger_printf through a function pointer from cpu specific code
This allows the output from the register and stack trace code to be
sent elsewhere.

Change-Id: I41bb0d5a25e1b9ca55feef5dbd675818b2f832d5
Signed-off-by: Arve Hjønnevåg <arve@android.com>
2016-02-16 13:52:29 -08:00
Colin Cross
0fe3a992c3 fiq_debugger: add ARM64 support
Add fiq_debugger_arm64.c that implements the platform-specific
functions.

Change-Id: I4d8b96777bb8503a93d4eb47bbde8e018740a5bf
Signed-off-by: Colin Cross <ccross@android.com>
2016-02-16 13:52:28 -08:00
Colin Cross
6f7487e127 fiq_debugger: split arm support into fiq_debugger_arm.c
Split arm support into a separate .c file that is only built for
CONFIG_ARM.

Change-Id: Iba16f4d51608bf9c3e5c8acefefcd38fead9797c
Signed-off-by: Colin Cross <ccross@android.com>
2016-02-16 13:52:28 -08:00
Colin Cross
a5c052a3e4 fiq_debugger: use pt_regs for registers
IRQ mode already passes in a struct pt_regs from get_irq_regs().
FIQ mode passes in something similar but not identical to a
struct pt_regs - FIQ mode stores the spsr of the interrupted mode
in slot 17, while pt_regs expects orig_r0.

Replace the existing mixture of void *regs, unsigned *regs, and
struct pt_regs * const with const struct pt_regs *.  Modify
dump_regs not to print the spsr since it won't be there in a
struct pt_regs anyways.  Modify dump_allregs to highlight the
mode that was interrupted, making spsr easy to find there.

Change-Id: Ibfe1723d702306c7605fd071737d7be9ee9d8c12
Signed-off-by: Colin Cross <ccross@android.com>
2016-02-16 13:52:28 -08:00
Colin Cross
10ea8c38eb fiq_debugger: allow compiling without CONFIG_FIQ_GLUE
Allow compiling fiq_debugger.c without CONFIG_FIQ_GLUE for
platforms that don't support FIQs.

Change-Id: Iabdfd790d24fa9d47b29d2f850c567af2dcad78f
Signed-off-by: Colin Cross <ccross@android.com>
2016-02-16 13:52:27 -08:00
Colin Cross
cfbb5d4264 fiq_debugger: rename debug->fiq_debugger
Rename variables and functions in the global namespace to avoid
future collisions.

Change-Id: Ic23a304b0f794efc94cc6d086fddd63231d99c98
Signed-off-by: Colin Cross <ccross@android.com>
2016-02-16 13:52:27 -08:00
Colin Cross
4ef006294a fiq_debugger: move into drivers/staging/android/fiq_debugger/
Move fiq_debugger into drivers/staging/android/fiq_debugger/ to
allow for sharing between ARM and ARM64.

Change-Id: I6ca5e8b7e3d000f57da3234260261c5592cef2a8
Signed-off-by: Colin Cross <ccross@android.com>
2016-02-16 13:52:26 -08:00
Arve Hjønnevåg
35ccfaff94 ARM: fiq_glue: Add custom fiq return handler api.
Change-Id: I5ff2764e85151ca0a88576542fda07c2d33dd065
Signed-off-by: Arve Hjønnevåg <arve@android.com>
2016-02-16 13:52:26 -08:00
Todd Poynor
699df5adbb ARM: kgdb: ignore breakpoint instructions from user mode
Avoid conflicts with user mode usage of the same instructions, as with
Clang -ftrapv.

Change-Id: I12d1c6d8f94376bfd2503cb0be843d7e478fb6ea
Signed-off-by: Todd Poynor <toddpoynor@google.com>
2016-02-16 13:52:25 -08:00
Arve Hjønnevåg
f8b0ad9d7b ARM: fiq_debugger: Update tty code for 3.9
Signed-off-by: Arve Hjønnevåg <arve@android.com>
2016-02-16 13:52:25 -08:00
Arve Hjønnevåg
a38d2154c8 ARM: fiq_debugger: Use kmsg_dumper to dump kernel logs
Signed-off-by: Arve Hjønnevåg <arve@android.com>
2016-02-16 13:52:24 -08:00
Arve Hjønnevåg
9b6224b1f5 ARM: fiq_debugger: Fix to compile on 3.7
Use for_each_irq_desc in arch/arm/common/fiq_debugger.c

Signed-off-by: Arve Hjønnevåg <arve@android.com>
2016-02-16 13:52:24 -08:00
Mars
cdad2cdca2 ARM: fiq_debugger: fix uninitialised spin_lock.
Backtrace:
[<c0045ea0>] (dump_backtrace+0x0/0x10c) from [<c0575c60>] (dump_stack+0x1)
 r6:c07a489c r5:c0c9b9dc r4:00000002 r3:271aed3b
[<c0575c48>] (dump_stack+0x0/0x1c) from [<c00b1b00>] (__lock_acquire+0x93)
[<c00b11c8>] (__lock_acquire+0x0/0xad4) from [<c00b219c>] (lock_acquire+0)
[<c00b210c>] (lock_acquire+0x0/0xa4) from [<c057e544>] (_raw_spin_lock_ir)
[<c057e4f8>] (_raw_spin_lock_irq+0x0/0x5c) from [<c005297c>] (fiq_tty_wri)
 r5:e30f0000 r4:e36f0c00
[<c005293c>] (fiq_tty_write+0x0/0x80) from [<c023168c>] (n_tty_write+0x18)
 r8:e370fc40 r7:e378a000 r6:e3572d1c r5:e36f0c00 r4:00000002
r3:c005293c
[<c0231500>] (n_tty_write+0x0/0x440) from [<c022d4a4>] (tty_write+0x100/0)
[<c022d3a4>] (tty_write+0x0/0x2a8) from [<c0100b80>] (vfs_write+0xa4/0x14)
[<c0100adc>] (vfs_write+0x0/0x148) from [<c0100cdc>] (sys_write+0x40/0x78)
 r8:00000002 r7:4076d2c4 r6:e370fc40 r5:00000000 r4:00000000
[<c0100c9c>] (sys_write+0x0/0x78) from [<c0041740>] (ret_fast_syscall+0x0)
 r8:c0041908 r7:00000004 r6:00000002 r5:00000000 r4:4007cbe0

[ccross: moved spin_lock_init into existing #ifdef]
Change-Id: If400d084eb20433c126ea1dd027a6be7f2ebb1f6
Signed-off-by: Mars <caoziqiang@meizu.com>
Signed-off-by: Colin Cross <ccross@android.com>
2016-02-16 13:52:23 -08:00
Colin Cross
394668b452 ARM: fiq_debugger: lock between tty and console writes
debug_console_write calls debug_uart_flush, which will usually wait
until the serial port fifo empties.  If another thread is continuously
calling fiq_tty_write, the fifo will constantly be refilled and
debug_uart_flush might never return.

Add a spinlock that is locked in debug_console_write and fiq_tty_write
to ensure they can't run at the same time.  This has an extra advantage
of preventing lines from the console and tty from being mixed together.

Also reduce the size returned by fiq_tty_write_room to keep the time
spent with the spinlock held to a reasonable value.

In addition, make sure fiq context can't loop forever by never calling
debug_uart_flush when the console is enabled.

Change-Id: I5712b01f740ca0c84f680d2032c9fa16b7656939
Signed-off-by: Colin Cross <ccross@android.com>
2016-02-16 13:52:23 -08:00
Colin Cross
05c369015c ARM: fiq_debugger: add process context reboot command
kernel_restart cannot be called from interrupt context.  Add support for
commands called from a work function, and implement the "reboot" command
there.  Also rename the existing irq-mode command to "reset" and change
it to use machine_restart instead of kernel_restart.

Change-Id: I3c423147c01db03d89e95a5b99096ca89462079f
Signed-off-by: Colin Cross <ccross@android.com>
2016-02-16 13:52:22 -08:00
Colin Cross
30f1c58cc5 ARM: fiq_debugger: fix multiple consoles and make it a preferred console
Fix setting up consoles on multiple fiq debugger devices by
splitting the tty driver init into the initcall, and initializing
the single tty device during probe.  Has the side effect of moving
the tty device node to /dev/ttyFIQx, where x is the platform device
id, which should normally match the serial port.

To avoid having to pass a different console=/dev/ttyFIQx for every
device, make the fiq debugger a preferred console that will be used
by default if no console was passed on the command line.

Change-Id: I6cc2670628a41e84615859bc96adba189966d647
Signed-off-by: Colin Cross <ccross@android.com>
2016-02-16 13:52:22 -08:00
Colin Cross
c70fe44edf kdb: support new lines without carriage returns
kdb expects carriage returns through the serial port to terminate
commands.  Modify it to accept the first seen carriage return or
new line as a terminator, but not treat \r\n as two terminators.

Change-Id: I06166017e7703d24310eefcb71c3a7d427088db7
Signed-off-by: Colin Cross <ccross@android.com>
2016-02-16 13:52:21 -08:00
Colin Cross
35d99e5646 ARM: fiq_debugger: add support for kgdb
Adds polling tty ops to the fiq debugger console tty, which allows
kgdb to run against an fiq debugger console.

Add a check in do_sysrq to prevent enabling kgdb from the fiq
debugger unless a flag (writable only by root) has been set. This
should make it safe to enable KGDB on a production device.

Also add a shortcut to enable the console and kgdb together, to
allow kgdb to be enabled when the shell on the console is not
responding.

Change-Id: Ifc65239ca96c9887431a6a36b9b44a539002f544
Signed-off-by: Colin Cross <ccross@android.com>
2016-02-16 13:52:21 -08:00
Colin Cross
7c4ff13273 ARM: fiq_debugger: add debug_putc
Convert all the calls to state->pdata->uart_putc to a debug_putc
helper.

Change-Id: Idc007bd170ff1b51d0325e238105ae0c86d23777
Signed-off-by: Colin Cross <ccross@android.com>
2016-02-16 13:52:20 -08:00
Colin Cross
61b0d5a3c1 ARM: fiq_debugger: add support for reboot commands
Pass the rest of the reboot command to kernel_restart to allow
reboot bootloader to work from FIQ debugger.

Change-Id: I4e7b366a69268dda17ffcf4c84f2373d15cb1271
Signed-off-by: Colin Cross <ccross@android.com>
2016-02-16 13:52:20 -08:00
Colin Cross
dcccb8f21c ARM: fiq_debugger: fix compiling for v3.3
Call kernel_restart instead of arch_reset, the ARM reset handling
has changed.

Remove localtimer irq printing, they now show up in the regular
irq stats.

Change-Id: I523da343b292c5711f3e1cbfd766d32eea2da84e
Signed-off-by: Colin Cross <ccross@android.com>
2016-02-16 13:52:19 -08:00
Iliyan Malchev
e7b792f79f ARM: Add generic fiq serial debugger
Change-Id: Ibb536c88f0dbaf4766d0599296907e35e42cbfd6
Signed-off-by: Iliyan Malchev <malchev@google.com>
Signed-off-by: Arve Hjønnevåg <arve@android.com>
2016-02-16 13:52:19 -08:00
Arve Hjønnevåg
e9c1a826c0 ARM: Add fiq_glue
Change-Id: I27d2554e07d9de204e0a06696d38db51608d9f6b
Signed-off-by: Arve Hjønnevåg <arve@android.com>
Signed-off-by: Colin Cross <ccross@android.com>
2016-02-16 13:52:19 -08:00
keunyoung
daafe226f7 fix false disconnect due to a signal sent to the reading process
- In the current implementation, when a signal is sent to the reading process,
  read is cancelled by calling usb_ep_dequeue, which lead into calling
  acc_complete_out with ECONNRESET, but the current logic treats it as
  disconnection, which makes the device inaccessible until cable is actually
  disconnected.
- The fix calls disconnect only when ESHUTDOWN error is passed.
- If data has already arrived while trying cancelling, the data is marked
  as available, and it will be read out on the next read. This is necessary
  as USB bulk is assumed to guarantee no data loss.

Signed-off-by: keunyoung <keunyoung@google.com>
2016-02-16 13:52:18 -08:00
Amit Pundir
a6a18dc18a usb: gadget: u_ether: use %z format specifier for size_t
Use '%zd' format specifier for size_t type instead
of '%d' to fix build warnings like:

drivers/usb/gadget/function/u_ether.c: In function ‘rx_submit’:
drivers/usb/gadget/function/u_ether.c:244:2: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘size_t’ [-Wformat=]
  DBG(dev, "%s: size: %d\n", __func__, size);
  ^

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2016-02-16 13:52:18 -08:00
Amit Pundir
78263aa46b usb: gadget: rndis: fix broken build for 4.4
Use rndis_params instead of configNr to align with
changes from mainline commit 83210e59ee
"usb: gadget: rndis: use rndis_params instead of configNr".

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2016-02-16 13:52:17 -08:00
Amit Pundir
bbc2ad37fd usb: gadget: rndis: fix broken data aggregation build
Declare "cdev" to fix broken AOSP commit
"RNDIS: Add Data aggregation (multi packet) support",
otherwise we run into following build failure:

  CC      drivers/usb/gadget/function/f_rndis.o
drivers/usb/gadget/function/f_rndis.c: In function ‘rndis_command_complete’:
drivers/usb/gadget/function/f_rndis.c:479:3: error: ‘cdev’ undeclared (first use in this function)
drivers/usb/gadget/function/f_rndis.c:479:3: note: each undeclared identifier is reported only once for each function it appears in
make[4]: *** [drivers/usb/gadget/function/f_rndis.o] Error 1

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2016-02-16 13:52:17 -08:00
Amit Pundir
561085a191 usb: gadget: rndis: use %z format specifier for size_t
Use '%z' format specifier for sizeof operator instead
of '%u' to fix build warnings like:

    warning: format '%u' expects type 'unsigned int', but argument 3 has type 'long unsigned int'

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2016-02-16 13:52:16 -08:00
Amit Pundir
33975a41d9 usb: gadget: cleanup: fix unused variable and function warnings
Remove unused variables and functions to fix following
build warnings:

  CC      drivers/usb/gadget/configfs.o
drivers/usb/gadget/configfs.c: In function ‘gadgets_make’:
drivers/usb/gadget/configfs.c:1710:6: warning: unused variable ‘err’ [-Wunused-variable]
  int err;
      ^
drivers/usb/gadget/configfs.c:1709:27: warning: unused variable ‘attr’ [-Wunused-variable]
  struct device_attribute *attr;
                           ^
drivers/usb/gadget/configfs.c:1708:28: warning: unused variable ‘attrs’ [-Wunused-variable]
  struct device_attribute **attrs;
                            ^
drivers/usb/gadget/configfs.c: In function ‘gadgets_drop’:
drivers/usb/gadget/configfs.c:1774:27: warning: unused variable ‘attr’ [-Wunused-variable]
  struct device_attribute *attr;
                           ^
drivers/usb/gadget/configfs.c:1773:28: warning: unused variable ‘attrs’ [-Wunused-variable]
  struct device_attribute **attrs;
                            ^
<snip>...
  CC      drivers/usb/gadget/function/f_mtp.o
drivers/usb/gadget/function/f_mtp.c:1219:12: warning: ‘mtp_bind_config’ defined but not used [-Wunused-function]
 static int mtp_bind_config(struct usb_configuration *c, bool ptp_config)
            ^
drivers/usb/gadget/function/f_mtp.c:1300:12: warning: ‘mtp_setup’ defined but not used [-Wunused-function]
 static int mtp_setup(void)
            ^
<snip>...
  CC      drivers/usb/gadget/function/f_accessory.o
drivers/usb/gadget/function/f_accessory.c:969:1: warning: ‘acc_function_bind’ defined but not used [-Wunused-function]
 acc_function_bind(struct usb_configuration *c, struct usb_function *f) {
 ^
drivers/usb/gadget/function/f_accessory.c:1172:12: warning: ‘acc_bind_config’ defined but not used [-Wunused-function]
 static int acc_bind_config(struct usb_configuration *c)
            ^

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2016-02-16 13:52:16 -08:00
Amit Pundir
c886eb3e71 usb: gadget: build audio_source function only if SND is enabled
Also select SND_PCM while building f_audio_source
otherwise we run into following build error:

  LD      init/built-in.o
drivers/built-in.o: In function `audio_data_complete':
/linaro/android/kernel/linaro-android/drivers/usb/gadget/function/f_audio_source.c:458: undefined reference to `snd_pcm_period_elapsed'
drivers/built-in.o: In function `audio_pcm_hw_free':
/linaro/android/kernel/linaro-android/drivers/usb/gadget/function/f_audio_source.c:770: undefined reference to `snd_pcm_lib_free_vmalloc_buffer'
drivers/built-in.o: In function `snd_pcm_lib_alloc_vmalloc_buffer':
/linaro/android/kernel/linaro-android/include/sound/pcm.h:1179: undefined reference to `_snd_pcm_lib_alloc_vmalloc_buffer'
drivers/built-in.o: In function `audio_pcm_open':
/linaro/android/kernel/linaro-android/drivers/usb/gadget/function/f_audio_source.c:734: undefined reference to `snd_pcm_limit_hw_rates'
drivers/built-in.o: In function `snd_card_setup':
/linaro/android/kernel/linaro-android/drivers/usb/gadget/function/f_audio_source.c:888: undefined reference to `snd_pcm_new'
/linaro/android/kernel/linaro-android/drivers/usb/gadget/function/f_audio_source.c:898: undefined reference to `snd_pcm_set_ops'
/linaro/android/kernel/linaro-android/drivers/usb/gadget/function/f_audio_source.c:899: undefined reference to `snd_pcm_lib_preallocate_pages_for_all'
drivers/built-in.o:(.data+0x1fd28): undefined reference to `snd_pcm_lib_ioctl'
make: *** [vmlinux] Error 1

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2016-02-16 13:52:15 -08:00
Amit Pundir
fcabd00b41 usb: gadget: configfs: handle gadget reset request for android
There is this new mandatory UDC->reset API in v3.18+ kernels,
commit ef979a26 "usb: gadget: add reset API at usb_gadget_driver".

Let android_disconnect handle that for Android, similar to
how composite_disconnect is handling the generic ConfigFS
gadget reset request.

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2016-02-16 13:52:15 -08:00
Badhri Jagan Sridharan
06047350fc ANDROID: usb: gadget: create F_midi device
Android frameworks relies on the alsa
config reported by the f_midi device.

Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com>
Change-Id: I0695e00b166fd953f50acea93802245b0d5a5240
2016-02-16 13:52:14 -08:00
Badhri Jagan Sridharan
de9e90c21e usb: gadget: Add device attribute to determine gadget state
Android frameworks (UsbDeviceManager) relies on gadget state exported
through device attributes.  This CL adds the device attribute to export
USB gadget state.

Change-Id: Id0391810d75b58c579610fbec6e37ab22f28886d
Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com>
2016-02-16 13:52:14 -08:00
Amit Pundir
b9efd37bc8 usb: phy: fix dual role sysfs build if kernel modules are supported
Add a missing ";" after EXPORT_SYMBOL() otherwise we run
into following build error if Kernel Modules are supported:
----------
  CC      drivers/usb/phy/class-dual-role.o
drivers/usb/phy/class-dual-role.c:91:1: error: expected ',' or ';' before 'int'
 int dual_role_get_property(struct dual_role_phy_instance *dual_role,
 ^
make[3]: *** [drivers/usb/phy/class-dual-role.o] Error 1
----------

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2016-02-16 13:52:13 -08:00
Badhri Jagan Sridharan
ce31762e99 usb: phy: Dual role sysfs class definition
This CL adds a new class to monitor and change
dual role usb ports from userspace. The usb
phy drivers can register to the dual_role_usb
class and expose the capabilities of the ports.
The phy drivers can decide on whether a specific
attribute can be changed from userspace by
choosing to implement the appropriate callback.

Cherry-picked from
https://android-review.googlesource.com/#/c/167310/

Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
Bug: 21615151
Change-Id: Id1c4aaa97e898264d7006381a7badd029b5d9789
2016-02-16 13:52:13 -08:00
Amit Pundir
a89affddff usb: gadget: fix NULL ptr derefer while symlinking PTP func
Fix NULL pointer dereference while trying to link PTP
function to a gadget configuration without creating
MTP function.

PTP piggyback on MTP function so make sure we have
MTP function created beforehand. Otherwise we run
into following kernel panic:
-----------------------
[   70.329957] Unable to handle kernel NULL pointer dereference at virtual address 00000000
[   70.330738] pgd = dd8ec000
[   70.330916] [00000000] *pgd=00000000
[   70.331663] Internal error: Oops: 805 [#1] SMP THUMB2
[   70.332155] CPU: 0 PID: 2067 Comm: ln Not tainted 3.18.0-00587-gdfa582e #1
[   70.332511] task: dd9c92c0 ti: dd822000 task.ti: dd822000
[   70.333094] PC is at function_alloc_mtp_ptp+0xe/0x68
[   70.333311] LR is at usb_get_function+0x11/0x1c
[   70.333489] pc : [<c034ec12>]    lr : [<c033cce9>]    psr: 60070033
<..snip..>
[   70.384111] 3fc0: bec14ae4 00000004 bec14c0a 00000053 00000004 b6f0422d 00000000 bec14adc
[   70.384369] 3fe0: bec14af8 bec14a98 b6f071f3 b6e8977c 20070010 bec14c0d 00000000 00000000
[   70.384832] [<c034ec12>] (function_alloc_mtp_ptp) from [<c033cce9>] (usb_get_function+0x11/0x1c)
[   70.385146] [<c033cce9>] (usb_get_function) from [<c033da9b>] (config_usb_cfg_link+0x87/0xa8)
[   70.385421] [<c033da9b>] (config_usb_cfg_link) from [<c011f417>] (configfs_symlink+0xb7/0x1c8)
[   70.385696] [<c011f417>] (configfs_symlink) from [<c00dcd8d>] (vfs_symlink+0x85/0xc0)
[   70.386010] [<c00dcd8d>] (vfs_symlink) from [<c00dce0b>] (SyS_symlinkat+0x43/0x70)
[   70.386261] [<c00dce0b>] (SyS_symlinkat) from [<c000ce41>] (ret_fast_syscall+0x1/0x5c)
[   70.386610] Code: eb04 4a0f 6e03 480f (e883) 0005
[   70.387346] ---[ end trace 8dba7c552e02f8fa ]---
[   70.387647] Kernel panic - not syncing: Fatal exception
[   70.387980] ---[ end Kernel panic - not syncing: Fatal exception
-----------------------

Steps to reproduce the kernel panic:

mount -t configfs none /config
mkdir /config/usb_gadget/g1
cd /config/usb_gadget/g1
echo 0x18d1 > idVendor
echo 0x4e26 > idProduct
mkdir strings/0x409
echo 0123459876 > strings/0x409/serialnumber
echo Asus > strings/0x409/manufacturer
echo Nexus7 > strings/0x409/product
mkdir configs/c.1
mkdir configs/c.1/strings/0x409
echo "Conf 1" > configs/c.1/strings/0x409/configuration
echo 120 > configs/c.1/MaxPower
mkdir functions/ptp.ptp
ln -s functions/ptp.ptp configs/c.1/ptp.ptp

Also MTP and PTP are mutually exclusive functions
so make sure we have only one of it linked to a
configuration at a time. Otherwise it opens up
another set of bug(s?).

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2016-02-16 13:52:12 -08:00
Badhri Jagan Sridharan
e931d151a9 usb:gadget:Add "state" attribute to android_device
Added a device attribute to android_device to
determine USB_GADGET's state

Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com>
Change-Id: I17f8903120df96bf2f4bf441940b53a87b818230
2016-02-16 13:52:12 -08:00
Badhri Jagan Sridharan
1c9137c8c5 usb: gadget: Do not disconnect unregistered dev
configfs_composite_unbind sets the gadget data
to null. Therefore, add check in disconnect
function to make sure that cdev is not NULL.
Prints a WARN message if the driver tries to
redundantly disconnect a gadget.

Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
Change-Id: I248cb7175d0dd9a51c18053dd39475d8b3284f6d
2016-02-16 13:52:11 -08:00
Badhri Jagan Sridharan
e1cc1e2a37 usb: gadget: Relocate f_accessory
3.18 kernel has reorganized drivers/usb/gadget
directory. Moving accessory gadget driver from
drivers/usb/gadget to drivers/usb/gadget/function

Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com>
Change-Id: If73c6df0537c4b1f51338ed3b0db817e51f06b4a
2016-02-16 13:52:11 -08:00
Badhri Jagan Sridharan
8cc9024964 usb: gadget: Accessory:Migrate to USB_FUNCTION API
This patch adds support to use Android accessory
gadget function through the
DECLARE_USB_FUNCTION_INIT interface.

Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
Change-Id: Ib352752d5bc905fa1df9049b53eabf1294930db7
2016-02-16 13:52:10 -08:00
Badhri Jagan Sridharan
9c5cdf4ddd usb: gadget: Move gadget functions code
3.18 kernel has reorganized drivers/usb/gadget
directory. Moving gadget functions drivers from
drivers/usb/gadget to drivers/usb/gadget/function

Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com>
Change-Id: I1eab0190f8d42e3be1b4e91ad3bc3a2dc853b0ef
2016-02-16 13:52:10 -08:00
Badhri Jagan Sridharan
3541608288 usb:gadget:audio_source: Move to USB_FUNCTION API
This patch adds support to use audio_source
gadget function through DECLARE_USB_FUNCTION_INIT
interface.

Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
Change-Id: I1fc6c9ea07105ae4eb785eebd3bb925bfdd8bc6b
2016-02-16 13:52:09 -08:00
Badhri Jagan Sridharan
dbaad39b68 usb: gadget: Add function devices to the parent
Added create_function_device to create child
function devices for USB gadget functions.
Android UsbDeviceManager relies on communicating
to the devices created by the gadget functions
to implement functions such as audio_source.

Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com>
Change-Id: I0df9ad86ac32d8cdacdea164e9fed49891b45fc2
2016-02-16 13:52:09 -08:00
Badhri Jagan Sridharan
795b676102 usb: gadget: f_audio_source:replace deprecated API
Replace snd_card_create with snd_card_new.
snd_card_create depcrecated starting form v3.15

Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com>
Change-Id: I76f7d753812963d595055bce7d3e6518163482f5
2016-02-16 13:52:08 -08:00
Amit Pundir
e087ef4d0d usb: gadget: check for accessory device before disconnecting HIDs
While disabling ConfigFS Android gadget, android_disconnect() calls
kill_all_hid_devices(), if CONFIG_USB_CONFIGFS_F_ACC is enabled, to free
the registered HIDs without checking whether the USB accessory device
really exist or not. If USB accessory device doesn't exist then we run into
following kernel panic:
----8<----
[  136.724761] Unable to handle kernel NULL pointer dereference at virtual address 00000064
[  136.724809] pgd = c0204000
[  136.731924] [00000064] *pgd=00000000
[  136.737830] Internal error: Oops: 5 [#1] SMP ARM
[  136.738108] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 3.18.0-rc4-00400-gf75300e-dirty #76
[  136.742788] task: c0fb19d8 ti: c0fa4000 task.ti: c0fa4000
[  136.750890] PC is at _raw_spin_lock_irqsave+0x24/0x60
[  136.756246] LR is at kill_all_hid_devices+0x24/0x114
---->8----

This patch adds a test to check if USB Accessory device exists before freeing HIDs.

Change-Id: Ie229feaf0de3f4f7a151fcaa9a994e34e15ff73b
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2016-02-16 13:52:08 -08:00