Commit graph

562573 commits

Author SHA1 Message Date
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
Praneeth Bajjuri
260bcfb18b usb: u_ether: Fix compile errors
commit f1a1823ff2
usb: gadget: u_ether: convert into module

changes qlen function definition. and this has to be fixed
accordingly in current u_ether driver.

This patch fixes following compile error in u_ether caused by commit.

drivers/usb/gadget/u_ether.c: In function 'rx_fill':
drivers/usb/gadget/u_ether.c:416:3: error: too few arguments to function 'qlen'
   if (++req_cnt > qlen(dev->gadget))
   ^

drivers/usb/gadget/u_ether.c: In function 'eth_start_xmit':
drivers/usb/gadget/u_ether.c:738:24: error: 'qmult' undeclared (first use in this function)
   if (dev->tx_qlen == (qmult/2)) {

which was caused by commits
commit 79467317949e1621240f632acfb7453783bec2e7
USB: gadget: u_ether: Fix data stall issue in RNDIS tethering mode

commit 68b91e8c54f5c091986c5719631893b10eab760a
usb: u_ether: Add workqueue as bottom half handler for rx data path

Change-Id: Ic4e5a1e08cb688e5a606c7c1895f869d8f887b9f
Signed-off-by: Praneeth Bajjuri <praneeth@ti.com>
2016-02-16 13:52:07 -08:00
Badhri Jagan Sridharan
4b2db1ab6c usb: gadget: Add Uevent to notify userspace
Android userspace UsbDeviceManager relies on the
uevents generated by the composition driver to
generate user notifications. This CL adds uevents
to be generated whenever USB changes its state
i.e. connected, disconnected, configured.

This CL also intercepts the setup requests from
the usb_core anb routes it to the specific
usb function if required.

Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com>
Change-Id: Ib3d3a78255a532f7449dac286f776c2966caf8c1
2016-02-16 13:52:07 -08:00
Badhri Jagan Sridharan
6ccbd233ae usb: gadget: configfs: Add usb_function ptr to fi struct
Add a pointer to the usb_function inside the
usb_function_instance structure to service
functions specific setup requests even before
the function gets added to the usb_gadget

Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com>
Change-Id: I6f457006f6c5516cc6986ec2acdf5b1ecf259d0c
2016-02-16 13:52:06 -08:00
Badhri Jagan Sridharan
7e3ab4a469 usb: gadget: mtp/ptp: Migrate functions to the USB_FUNCTION interface
This patch adds support to use mtp/ptp gadget functions
through the DECLARE_USB_FUNCTION_INIT interface.

enabling USB_CONFIGFS_F_MTP config compiles f_mtp.c
thereby providing support for MTP gadget

enabling USB_CONFIGFS_F_PTP config compiles f_ptp.c
thereby providing support for PTP gadget

Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
Change-Id: I38d7b570e8886d155ef10cd2c839b2232dcb3158
2016-02-16 13:52:06 -08:00
xerox_lin
24134b26ba USB: gadget: rndis: Add module parameter for DL max packets per xfer
Currently DL aggregation is supported in RNDIS driver and is set to
3 by default. And there is no support to change downlink maximum
packets per transfer at runtime through module parameter. Hence add
module parameter for DL maximum packets per transfer to change it at
runtime.

echo 6 > /sys/module/g_android/parameters/rndis_dl_max_pkt_per_xfer

To disable DL aggregation during runtime,

echo 1 > /sys/module/g_android/parameters/rndis_dl_max_pkt_per_xfer

Change-Id: I3a1d0bc97358e2b6f233df7ae8725fb507de50db
Signed-off-by: Xerox Lin <xerox_lin@htc.com>
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
2016-02-16 13:52:05 -08:00
Badhri Jagan Sridharan
c3d7f0cdd2 ndis: Add debug support to disable RNDIS Multipacket Feature
This change adds module param which allows to disable RNDIS
Multi-packet Feature (Aggregation support in Downlink path)
as this feature is enabled by default.

To disable use this param before moving to RNDIS Composition:
echo 1 > /sys/module/g_android/parameters/rndis_multipacket_dl_disable

Also counts errors as Rx errors if received RNDIS packets are
not following RNDIS message format as those packets are being
discarded.

Change-Id: I764430da78f2204af92e14bb279c11b24c7e4c67
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
2016-02-16 13:52:05 -08:00
Badhri Jagan Sridharan
debf5d6eac RNDIS: Add Data aggregation (multi packet) support
Add data aggregation support using RNDIS Multi Packet feature
to achieve better UDP Downlink throughput. Max 3 RNDIS Packets
aggregated into one RNDIS Packet with this implementation.

With this change, seeing UDP Downlink throughput increase
from 90 Mbps to above 100 Mbps when using Iperf and sending
data more than 100 Mbps.

Change-Id: I21c39482718944bb1b1068bdd02f626531e58f08
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
Signed-off-by: Rajkumar Raghupathy <raghup@codeaurora.org>
2016-02-16 13:52:04 -08:00
Badhri Jagan Sridharan
78281f6ed7 USB: gadget: u_ether: Fix data stall issue in RNDIS tethering mode
For dual speed gadget, with current no. of request(10), there is
possibility of corner case occurence where all 10 reuqests are queued
to HW without setting IOC bit, which could lead to data stall in
RNDIS tethering and RNDIS local networking.

With this patch, counter will be incremented before queueing request to
HW and sets IOC bit for every nth request due to which the corner case
of all requests queued to HW without IOC bit set will be avoided.

Change-Id: I26515bfd9bbc8f7af38be7835692143f7093118a
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
2016-02-16 13:52:04 -08:00
taeju.park
265801537d usb: gadget: prevent change of Host MAC address of 'usb0' interface
On windows 7 platform, previously allocated ip address is maintained.
However, Host MAC address of 'usb0' interface is changed when the
tethering driver re-enumerated. Thus, the tethering network driver
can't be allocated ip address from dhcp. It causes connection delay
between host and phone for usb tethering.

This patch prevents from changing Host MAC address of 'usb0' interface.
In other words, this patch maintains the Host MAC address allocated when
first tethering driver although the driver is re-enumerated. However,
after reboot, the Host MAC address can be changed.

Change-Id: I43add9925e9d6d90c56cffbd3ed999104448f818
Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com>
2016-02-16 13:52:03 -08:00
Badhri Jagan Sridharan
398a708ed5 usb: u_ether: Add workqueue as bottom half handler for rx data path
u_ether driver passes rx data to network layer and resubmits the
request back to usb hardware in interrupt context. Network layer
processes rx data by scheduling tasklet. For high throughput
scenarios on rx data path driver is spending lot of time in interrupt
context due to rx data processing by tasklet and continuous completion
and re-submission of the usb requests which results in watchdog bark.
Hence move the rx data processing and usb request submission to a
workqueue bottom half handler.

Change-Id: I316de8e267997137ac189a8b7b2846fa325f4a5a
Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com>
2016-02-16 13:52:03 -08:00
xerox_lin
70d6557c59 usb: Add support for rndis uplink aggregation
RNDIS protocol supports data aggregation on uplink and can help
reduce mips by reducing number of interrupts on device. Throughput
also improved by 20-30%. Aggregation is disabled by setting
aggregation packet size to 1. To help better UL throughput, set
as ul aggregation support to 3 rndis packets by default. It can be
configured via module parameter: rndis_ul_max_pkt_per_xfer.

Change-Id: I0b62a21a5c3ceb6b04933d0d6da33301dbafe493
Signed-off-by: Vamsi Krishna <vskrishn@codeaurora.org>
Signed-off-by: Xerox Lin <xerox_lin@htc.com>
2016-02-16 13:52:02 -08:00
xerox_lin
c996cdd384 USB: rndis: Free the rndis response queue during REMOTE_NDIS_RESET_MSG
When rndis data transfer is in progress, some Windows7 Host PC is not
sending the GET_ENCAPSULATED_RESPONSE command for receiving the response
for the previous SEND_ENCAPSULATED_COMMAND processed.

The rndis function driver appends each response for the
SEND_ENCAPSULATED_COMMAND in a queue. As the above process got corrupted,
the Host sends a REMOTE_NDIS_RESET_MSG command to do a soft-reset.
As the rndis response queue is not freed, the previous response is sent
as a part of this REMOTE_NDIS_RESET_MSG's reset response and the Host
blocks any more Rndis transfers.

Hence free the rndis response queue as a part of this soft-reset so that
the current response for REMOTE_NDIS_RESET_MSG is sent properly during the
response command.

Change-Id: I8eff3849db452fe01b7d1fe4140ef1f1ad3f4fd4
Signed-off-by: Rajkumar Raghupathy <raghup@codeaurora.org>
Signed-off-by: Xerox Lin <xerox_lin@htc.com>
2016-02-16 13:52:02 -08:00
Anson Jacob
62ed32043a usb: gadget: f_audio_source: Fixed USB Audio Class Interface Descriptor
Fixed Android Issue #56549.

When both Vendor Class and Audio Class are activated for AOA 2.0,
the baInterfaceNr of the AudioControl Interface Descriptor points
to wrong interface numbers. They should be pointing to
Audio Control Device and Audio Streaming interfaces.

Replaced baInterfaceNr with the correct value.

Change-Id: Iaa083f3d97c1f0fc9481bf87852b2b51278a6351
Signed-off-by: Anson Jacob <ansonkuzhumbil@gmail.com>
2016-02-16 13:52:01 -08:00