The bFrameIndex of video streaming interface descriptor
is initialized to 1 in uvcg_frame_make(), but never be
setted for different frame resolutions, this cause host
to fail to select the correct frame resolution. This patch
increases the bFrameIndex in order.
Change-Id: Ic0609976e09d9e3d6f82595c00e2ac7b356e4f5f
Signed-off-by: William Wu <william.wu@rock-chips.com>
When prepare setup packet, don't clear nak before call
ep0_out_start(), because clear nak will make the usb
core to handle OUT transaction immediately without
NAK response, this may cause OUT transaction fail.
We can reproduce this issue in the following two case:
- Configure usb device as rndis, connect to Windows PC;
- Configure usb device as uvc, connect to Windows PC,
and take still image;
Use the usb analyzer to capture data in case2,we can
easily to find the problem.
Without this patch, the Class request OUT transfer is:
- SETUP transaction
- OUT transaction
- OUT packet
- DATA1 packet
- ACK pakcet
- IN transactions
- IN packet
- NAK packet (response NAK forever)
With this patch, the Class request OUT transfer is:
- SETUP transaction
- OUT transaction
- OUT packet
- DATA1 packet
- NAK packet
- PING transactions
- OUT transaction
- OUT packet
- DATA1 packet
- ACK pakcet
- IN transaction
- IN packet
- DATA1 packet
- ACK pakcet
Change-Id: I5ea915bc425ffa2f2a06a1a830f6f88725c94b03
Signed-off-by: William Wu <william.wu@rock-chips.com>
When dequeue req which already queued on the endpoint,
don't stop the transfer and also don't flush the Tx FIFO
for isoc endpoint, otherwise, it may fail when set NAK
bit and disable ep in dwc_otg_pcd_ep_stop_transfer().
Change-Id: Ib3c1215f9c9507c08cc12c966456209384811b6d
Signed-off-by: William Wu <william.wu@rock-chips.com>
In some error case, it may fail to set the NAK bit
or Disable bit for endpoint when do ep deactivate
operation. We need to use wait-till-ready timeout
loop for ep deactivate instead of while loop.
Change-Id: I0e5ed61b2528f89910333c5eb907677e492fe3a0
Signed-off-by: William Wu <william.wu@rock-chips.com>
The frame num of isoc ep is initialized to 0xFFFFFFFF in
ep_enable and start_next_request(), and then in the NAK
interrupt handler, it will check if the ep frame num is
0xFFFFFFFF, then reset the frame num to 0 and start next
request.
But if we dequeue the isoc ep request if it's already
enqueued, if may fail to call complete_ep() -> start_
next_request(), so the isoc ep frame num can't be reinit
to 0xFFFFFFFF, this cause NAK interrupt handler check
the frame num incorrectly, and fail to start next request.
Change-Id: Iab8526f6e3979347bdbe6c49525ec0ba8130d4bc
Signed-off-by: William Wu <william.wu@rock-chips.com>
The dwc_otg_ep_start_zl_transfer() can be called from irq
handler in the top half, so don't print additional log to
avoid wasting too much time in interrupt handling.
If someone needs to dump verbose log, just set the debug
level to appropriate value.
Change-Id: If6fb8a22e0c42fb2b629c3a82d8e632254434784
Signed-off-by: William Wu <william.wu@rock-chips.com>
Sometimes we found the usb device could not connect to the HUBs when
the cable plug in and out constantly, the root cause is "USB RESET"
was missed from these HUBs, and we only try 2 times to reconnect.
This patch as one workaround to increase reconnect times to 6, and
add the delay time (3.5ms-4ms) after DCTL.SftDiscon bit was clear.
Change-Id: I57cfe5dc68e6d3d67c20771423dae29542ed047d
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
Signed-off-by: William Wu <william.wu@rock-chips.com>
According to DWC2 databook V3.10a, 5.3.5.14 Device Threshold
Control Register (DTHRCTL), it recommends that the Transmit
Threshold Length (TxThrLen) is to be the same as the programmed
AHB Burst Length (GAHBCFG.HBstLen), on Rockchip platform the
value is 16.
Change-Id: I6427e3a3fc7b57e85229cdf4b9c5fff878b919b6
Signed-off-by: William Wu <william.wu@rock-chips.com>
Move last_id property from static to struct dwc_otg_device as a static
global variable to support PM suspend process.
Change-Id: I7729095339aed3dcca6481005f249c855ebbdb3c
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
Signed-off-by: William Wu <william.wu@rock-chips.com>
According to 'DesignWare Cores USB 2.0 Hi-Speed On-The-Go (OTG)
Programmer's Guide' 2.1.3.3 Dedicated FIFO Mode with Thresholding,
We can use threshold to support the following case:
1. To have a smaller FIFO size;
2. To have faster DMA response;
The threshold is useful for rockchip platforms which has a smaller
FIFO size and try to support three isochronous back-to-back packets
(high bandwidth).
And we also need to set GAHBCFG.HBstLen to INCR16 for high bandwidth
endpoints. If you want to support high bandwidth endpoints, it needs
to add a new property 'rockchip,high-bandwidth' in dts usb node.
Change-Id: I0c1d373cdaa51f22c15484912b752fb0b6ad4b9c
Signed-off-by: William Wu <wulf@rock-chips.com>
The frame_overrun flag is used to indicates
SOF number (current_frame) overrun in DSTS
and the target_frame over DSTS_SOFFN_LIMIT.
Clear the frame_overrun flag only if target_frame
below DSTS_SOFFN_LIMIT and current_frame less
than target_frame.
Change-Id: I91cf9001324a9bbbcc4bc28b335695d607fb69d4
Signed-off-by: William Wu <william.wu@rock-chips.com>
The default period size is only 64 frames, this
will cause usb audio playback with noise via
internal audio codec. This patch sets the period
size to (snd->rate / 10), and also sets the buffer
size to snd->rate.
Change-Id: I4a4eb1b4dd79aec65f5c44eacd8a2fa101dfbd1b
Signed-off-by: William Wu <william.wu@rock-chips.com>
The f_audio_disable() doesn't disable usb ep, and
this cause usb enumeration fail. So add usb ep
disable operation.
This patch also reinitializes the opts->bound flag
to false in f_audio_free(), and then it can setup
ALSA audio device again in f_audio_bind().
Change-Id: I7b10630f5085b1a03792bc4b9e7eabb02d2bd5a2
Signed-off-by: William Wu <william.wu@rock-chips.com>
Adds pm_runtime support for dwc2, so that power domain is
enabled only when there is a transaction going on to help
save power.
Change-Id: I318552774d20eeaed521ff179f99b2551ee24183
Signed-off-by: William Wu <william.wu@rock-chips.com>
Some EHCI controllers use usic phy (e.g rk3399/rk3288),
in order to enable these controllers, we need to set
some additional EHCI vendor-specific registers.
Support this feature in device tree when using the ehci
platform driver by adding a new property for it.
Change-Id: I279ccfdb5866df49828825bfd41b39fcd58a2832
Signed-off-by: William Wu <william.wu@rock-chips.com>
During dwc3 resume, it shoudn't reset otg controller logic
if device is connecting with the otg port, because it will
cause device to be reenumerated. More seriously, it may
cause the otg_work to enter disconnect process and power
down usb3 controller power domain, at the same time, if
the xHCI driver is accessing the controller asynchronously,
it will cause system hang.
Change-Id: Id546277bd4082b7baeff830788643a800330ae8e
Signed-off-by: William Wu <william.wu@rock-chips.com>
When do core init, only reset the core for device mode.
Becasue in host mode, xHCI driver will reset the core
and its host block via usbcmd.hcrst. If we do core reset
in dwc3_core_init() for host mode, it will reset both
the dwc3 core registers and xHCI registers, and cause
device to be reenumerated when usb suspend/resume.
Change-Id: If723ce8a771975e9757d28cb2c114d6269581677
Signed-off-by: William Wu <william.wu@rock-chips.com>
commit 313db3d648 upstream.
The > should be >= here so that we don't read one element beyond the end
of the ep->stream_info->stream_rings[] array.
Fixes: e9df17eb14 ("USB: xhci: Correct assumptions about number of rings per endpoint.")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
commit bba57eddad upstream.
Corsair Strafe appears to suffer from the same issues
as the Corsair Strafe RGB.
Apply the same quirks (control message delay and init delay)
that the RGB version has to 1b1c:1b15.
With these quirks in place the keyboard works correctly upon
booting the system, and no longer requires reattaching the device.
Signed-off-by: Nico Sneck <snecknico@gmail.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
commit f1e255d60a upstream.
In general, accessing userspace memory beyond the length of the supplied
buffer in VFS read/write handlers can lead to both kernel memory corruption
(via kernel_read()/kernel_write(), which can e.g. be triggered via
sys_splice()) and privilege escalation inside userspace.
Fix it by using simple_read_from_buffer() instead of custom logic.
Fixes: 6bc235a2e2 ("USB: add driver for Meywa-Denki & Kayac YUREX")
Signed-off-by: Jann Horn <jannh@google.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
commit 01b3cdfca2 upstream.
Fix broken modem-status error handling which could lead to bits of slab
data leaking to user space.
Fixes: 3b36a8fd67 ("usb: fix uninitialized variable warning in keyspan_pda")
Cc: stable <stable@vger.kernel.org> # 2.6.27
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
commit 367b160fe4 upstream.
There are two versions of the Qivicon Zigbee stick in circulation. This
adds the second USB ID to the cp210x driver.
Signed-off-by: Olli Salonen <olli.salonen@iki.fi>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
commit e33eab9ded upstream.
The "r" variable is an int and "bufsize" is an unsigned int so the
comparison is type promoted to unsigned. If usb_control_msg() returns a
negative that is treated as a high positive value and the error handling
doesn't work.
Fixes: 2d5a9c72d0 ("USB: serial: ch341: fix control-message error handling")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
After commit 7e4da3fcf7 ("usb: gadget: composite:
Test get_alt() presence instead of set_alt()") f_uac1
function became broken because it doesn't have
get_alt() callback implementation and composite
framework never set altsetting 1 for audiostreaming
interface. On host site it looks like:
[424339.017711] 21:1:1: usb_set_interface failed (-32)
Since host can't set altsetting 1, it can't start
playing audio.
In order to fix it implemented get_alt along with
minor improvements (error conditions checking)
similar to what existing f_uac2 has.
Change-Id: I41d59c69e3b300b164e6267c48c1367e8d38b098
Cc: Krzysztof Opasiak <k.opasiak@samsung.com>
Signed-off-by: Ruslan Bilovol <ruslan.bilovol@gmail.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: William Wu <william.wu@rock-chips.com>
(cherry picked from commit 1fc4926d92)
The commit c64eaccc619f ("usb: dwc_otg_310: map ep to
corresponding TxFIFO number") use a fixed mapping between
the endpint addresses and the TxFIFO number. The TxFIFO
number 1 is assigned to ep1-in, and the TxFIFO number 2
is assigned to ep3-in. For uvc function, the ep1-in is
used for uvc control ep (interrupt), and the ep3-in is
used for uvc stream ep. So resize the depth of TxFIFO
number 1 to 512 Bytes, and resize the depth of TxFIFO
number 2 to 1024 Bytes.
Change-Id: I07a89aab01206f6b6f853886d564130abffc1586
Signed-off-by: William Wu <william.wu@rock-chips.com>
In Dedicated FIFO mode, it uses a simple logic to assign
TxFIFO number for each active endpoint. But it doesn't
guarantee that the FIFO depth is suitable for the maxpacket
of the endpoint. We may meet ep TxFIFO problem if we use
a composite device with more than three functions.
In my test case, I configure an usb composite device with
four functions on rv108: Mass storage + ADB + Rndis + HID.
when the functions are enabled:
echo "mass_storage,ffs,rndis,hidg0" > /sys/class/android_usb/android0/functions
The mass_storage works abnormally because that the mass
storage gadget driver calls ep_enable operation at last,
and the ep1-in of mass_storage is assigned with TxFIFO
number 5. The FIFO mapping between the endpint addresses
and the TxFIFO number is:
Ep1-IN msc bulk => TxFIFO number 5, FIFO depth 64 Bytes
Ep3-IN adb bulk => TxFIFO number 1, FIFO depth 1024 Bytes
Ep5-IN rndis bulk => TxFIFO number 3, FIFO depth 512 Bytes
Ep7-IN rndis interrupt => TxFIFO number 2, FIFO depth 512 Bytes
Ep8-IN hid interrupt => TxFIFO number 4, FIFO depth 384 Bytes
This patch use a fixed mapping between the endpint addresses
and the TxFIFO number like this:
EP1-IN => TxFIFO number 1
EP3-IN => TxFIFO number 2
EP5-IN => TxFIFO number 3
EP7-IN => TxFIFO number 4
EP8-IN => TxFIFO number 5
EP9-IN => TxFIFO number 6
With this patch, in my test case (Mass storage+ ADB + Rndis + HID)
the FIFO mapping is:
Ep1-IN msc bulk => TxFIFO number 1, FIFO depth 1024 Bytes
Ep3-IN adb bulk => TxFIFO number 2, FIFO depth 512 Bytes
Ep5-IN rndis bulk => TxFIFO number 3, FIFO depth 512 Bytes
Ep7-IN rndis interrupt => TxFIFO number 4, FIFO depth 384 Bytes
Ep8-IN hid interrupt => TxFIFO number 5, FIFO depth 64 Bytes
Change-Id: Id00ed7e78d26d87b6c473ea84d1b1901ef25171e
Signed-off-by: William Wu <william.wu@rock-chips.com>
commit 2f83982338 upstream.
Silicon Labs defines alternative VID/PID pairs for some chips that when
used will automatically install drivers for Windows users without manual
intervention. Unfortunately, these IDs are not recognized by the Linux
module, so using these IDs improves user experience on one platform but
degrades it on Linux. This patch addresses this problem.
Signed-off-by: Karoly Pados <pados@pados.hu>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
commit 6e01827ed9 upstream.
Some low-speed and full-speed devices (for example, bluetooth)
do not have time to initialize. For them, ETIMEDOUT is a valid error.
We need to give them another try. Otherwise, they will
never be initialized correctly and in dmesg will be messages
"Bluetooth: hci0 command 0x1002 tx timeout" or similars.
Fixes: 264904ccc3 ("usb: retry reset if a device times out")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Maxim Moseychuk <franchesko.salias.hudro.pedros@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[ Upstream commit ebc3dd688c ]
It has been observed that writing 0xF2 to the power register while it
reads as 0xF4 results in the register having the value 0xF0, i.e. clearing
RESUME and setting SUSPENDM in one go does not work. It might also violate
the USB spec to transition directly from resume to suspend, especially
when not taking T_DRSMDN into account. But this is what happens when a
remote wakeup occurs between SetPortFeature USB_PORT_FEAT_SUSPEND on the
root hub and musb_bus_suspend being called.
This commit returns -EBUSY when musb_bus_suspend is called while remote
wakeup is signalled and thus avoids to reset the RESUME bit. Ignoring
this error when musb_port_suspend is called from musb_hub_control is ok.
Signed-off-by: Daniel Glöckner <dg@emlix.com>
Signed-off-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
If XferNotReady comes before usb_ep_queue() we will
set our PENDING request flag and wait for a
request. However, originally, we were assuming
usb_ep_queue() would always happen before our first
XferNotReady and that causes a corner case where we
could try to issue ENDTRANSFER command before
STARTTRANSFER.
Let's fix that by tracking endpoints which have been
started.
Change-Id: I8432a70fff0da1b4bc1ea7d86e13d491e89a05bb
Reported-by: Janusz Dziedzic <januszx.dziedzic@intel.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Meng Dongyang <daniel.meng@rock-chips.com>
(cherry picked from commit 6cb2e4e3de)
The cmd argument we pass to
dwc3_send_gadget_ep_cmd() could contain extra
arguments embedded. When checking for StartTransfer
command, we need to make sure to match only lower 4
bits which contain the actual command and ignore the
rest.
Change-Id: I08056bf689f8a4ea1bcec242ffab296407d41bc8
Reported-by: Janusz Dziedzic <januszx.dziedzic@intel.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Meng Dongyang <daniel.meng@rock-chips.com>
(cherry picked from commit 5999914f22)
* linux-linaro-lsk-v4.4: (361 commits)
Linux 4.4.135
Revert "vti4: Don't override MTU passed on link creation via IFLA_MTU"
Linux 4.4.134
s390/ftrace: use expoline for indirect branches
kdb: make "mdr" command repeat
Bluetooth: btusb: Add device ID for RTL8822BE
ASoC: samsung: i2s: Ensure the RCLK rate is properly determined
regulator: of: Add a missing 'of_node_put()' in an error handling path of 'of_regulator_match()'
scsi: lpfc: Fix frequency of Release WQE CQEs
scsi: lpfc: Fix soft lockup in lpfc worker thread during LIP testing
scsi: lpfc: Fix issue_lip if link is disabled
netlabel: If PF_INET6, check sk_buff ip header version
selftests/net: fixes psock_fanout eBPF test case
perf report: Fix memory corruption in --branch-history mode --branch-history
perf tests: Use arch__compare_symbol_names to compare symbols
x86/apic: Set up through-local-APIC mode on the boot CPU if 'noapic' specified
drm/rockchip: Respect page offset for PRIME mmap calls
MIPS: Octeon: Fix logging messages with spurious periods after newlines
audit: return on memory error to avoid null pointer dereference
crypto: sunxi-ss - Add MODULE_ALIAS to sun4i-ss
...
Conflicts:
arch/arm64/include/asm/assembler.h
Rebase LTS commit 348f043ab6
("arm64: Add work around for Arm Cortex-A55 Erratum 1024718").
fs/f2fs/namei.c
Rebase LTS commit 03bb758894
("do d_instantiate/unlock_new_inode combinations safely")
fs/proc/base.c
Trivial typo.
kernel/auditsc.c
Rebase LTS commit 9bb698bede
("audit: move calcs after alloc and check when logging set loginuid").
kernel/time/timekeeping.c
Rebase changes from AOSP commit 28850c79d071
("BACKPORT: time: Fix CLOCK_MONOTONIC_RAW sub-nanosecond accounting"), and
1d35c0438678 ("BACKPORT: time: Clean up CLOCK_MONOTONIC_RAW time handling").
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
If the CONFIG_USB_CONFIGFS is not define, the 'audio_source_bind_config'
may be unused. Corrcet warning of no previous prototype for
'audio_source_bind_config' by adding judgment of CONFIG_USB_CONFIGFS
macro definition.
Change-Id: I174ae996c1d53e78b76f72cf463bc1efb189675b
Signed-off-by: Meng Dongyang <daniel.meng@rock-chips.com>
The sending process may still work if disconnect from
PC, for the sending function is called in the complete
call back function. So set alt to 0 when disconnect or
reset, and stop follow-up sending in complete function
if alt is 0.
Change-Id: I073f122fe2ce2faf8cf6fb036fb983f9f3325f34
Signed-off-by: Meng Dongyang <daniel.meng@rock-chips.com>
This patch add support of 2 channel of uac, set min
channel number and max channel number to 2.
Change-Id: Ia3b45d3329ba6819339079b31ff42398464942b5
Signed-off-by: Meng Dongyang <daniel.meng@rock-chips.com>
Add sample rate to attribute of uevent when receive the command
of set interface.
Change-Id: I9cea17ebe57441209a99dec0b1dc279e274accc3
Signed-off-by: Meng Dongyang <daniel.meng@rock-chips.com>
Accordding to the "Universal Serial Bus Device Class Definition
for Audio Devices", there are some error in the f_audio_source
driver. The audio source can't be recognize by the Windows PC
if control unit is not support. In order to support Windows PC,
this patch fix error in f_audio_source driver and add support of
control unit.
Change-Id: Ie508141f032adecfbe2e951ad36d9b8c271b28ba
Signed-off-by: Meng Dongyang <daniel.meng@rock-chips.com>
The sample rate is force to 44100 in current code. This
code add numbers of sample rate up to 15 and support
set or get by PC.
Change-Id: I543d84f3081f82a4c96071c2b2442d37a9a835fb
Signed-off-by: Meng Dongyang <daniel.meng@rock-chips.com>
Add uevent of setting interface to notify the application.
In some cases that the application want to get the change event
and state of alt immediately when to select the next operation,
but current code doesn't have the interface for it. So this patch
sent a uevent when setting interface and report the state of alt
throw attribute of uevent.
Change-Id: I47084f99bc046dede86d6b5777677f3799056c03
Signed-off-by: Meng Dongyang <daniel.meng@rock-chips.com>
commit 009615ab7f upstream.
On sparc32, tcflag_t is unsigned long, unlike all other architectures:
drivers/usb/serial/cp210x.c: In function 'cp210x_get_termios':
drivers/usb/serial/cp210x.c:717:3: warning: passing argument 2 of 'cp210x_get_termios_port' from incompatible pointer type
cp210x_get_termios_port(tty->driver_data,
^
drivers/usb/serial/cp210x.c:35:13: note: expected 'unsigned int *' but argument is of type 'tcflag_t *'
static void cp210x_get_termios_port(struct usb_serial_port *port,
^
Consistently use tcflag_t to fix this.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Cc: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>