[PATCH] USB: core: Fix bug caused by duplicate interface PM usage counter

2019-04-19 Thread Alan Stern
The syzkaller fuzzer reported a bug in the USB hub driver which turned out to be caused by a negative runtime-PM usage counter. This allowed a hub to be runtime suspended at a time when the driver did not expect it. The symptom is a WARNING issued because the hub's status URB is submitted while i

Re: [PATCH] USB: serial: pl2303: fix xon/xoff flow control

2019-04-19 Thread Greg Kroah-Hartman
On Thu, Apr 18, 2019 at 06:03:52PM +0200, Johan Hovold wrote: > Fix the XON/XOFF flow-control implementation by reporting back the > attributes actually supported while ignoring the rest. > > Note that only outgoing XON/XOFF flow control (IXON) is currently > supported for PL2303HX, and only using

Re: [PATCH 2/2] USB: serial: digi_acceleport: clean up set_termios

2019-04-19 Thread Greg KH
On Thu, Apr 18, 2019 at 06:20:20PM +0200, Johan Hovold wrote: > Clean up set_termios() by adding missing white space around operators > and making a couple of continuation lines more readable. > > Also drop a couple of redundant braces. > > Signed-off-by: Johan Hovold Reviewed-by: Greg Kroah-Ha

Re: [PATCH] usb: dwc3: Allow building USB_DWC3_QCOM without EXTCON

2019-04-19 Thread Greg Kroah-Hartman
On Fri, Apr 19, 2019 at 11:59:08AM +0200, Marc Gonzalez wrote: > Keep EXTCON support optional, since some platforms do not need it. > > Fixes: 3def4031b3e3 ("usb: dwc3: add EXTCON dependency for qcom") > Signed-off-by: Marc Gonzalez > --- > drivers/usb/dwc3/Kconfig | 3 ++- > 1 file changed, 2 i

Re: USB fuzzing with syzbot

2019-04-19 Thread Greg Kroah-Hartman
On Wed, Apr 17, 2019 at 06:33:39PM +0200, Andrey Konovalov wrote: > Hi, > > As you might have noticed, syzbot has started reporting bugs in the > USB subsystem that can be triggered externally by a malicious USB > device. Right now the fuzzing is done via a GadgetFS-like interface to > emulate USB

Re: [PATCH 1/2] USB: serial: digi_acceleport: clean up modem-control handling

2019-04-19 Thread Greg KH
On Thu, Apr 18, 2019 at 06:20:19PM +0200, Johan Hovold wrote: > Clean up modem-control handling somewhat by adding missing whitespace > around operators and splitting a long statement in two. > > Signed-off-by: Johan Hovold > --- > drivers/usb/serial/digi_acceleport.c | 8 > 1 file chan

Re: [PATCH] usb: dwc3: Allow building USB_DWC3_QCOM without EXTCON

2019-04-19 Thread Greg Kroah-Hartman
On Fri, Apr 19, 2019 at 01:24:23PM +0200, Greg Kroah-Hartman wrote: > On Fri, Apr 19, 2019 at 11:59:08AM +0200, Marc Gonzalez wrote: > > Keep EXTCON support optional, since some platforms do not need it. > > > > Fixes: 3def4031b3e3 ("usb: dwc3: add EXTCON dependency for qcom") > > Signed-off-by: M

Re: USB fuzzing with syzbot

2019-04-19 Thread Alan Stern
On Fri, 19 Apr 2019, Greg Kroah-Hartman wrote: > > 3. Regarding that GadgetFS-like interface. > > > > Initially I was using GadgetFS (together with the Dummy HCD/UDC > > module) to perform emulation of USB devices for fuzzing, but later > > switched to a custom written interface. This interface i

[PATCH v1 11/14] usb: dwc2: Allow exiting hibernation from gpwrdn rst detect

2019-04-19 Thread Artur Petrosyan
When device cable is disconnected core receives suspend interrupt and enters hibernation. After entering into hibernation GPWRDN_RST_DET and GPWRDN_STS_CHGINT interrupts are asserted. From cable disconnection we need to exit from hibernation either by GPWRDN_RST_DET or GPWRDN_STS_CHGINT. If we exi

[PATCH v1 00/14] usb: dwc2: Fix and improve power saving modes.

2019-04-19 Thread Artur Petrosyan
This patch set, fixes and improves partial power down and hibernation power saving modes. Also, adds support for entering/exiting hibernation by system issued suspend/resume. This series contains patches which were submitted to LKML. However, a part of those patches didn't reach to LKML because of

[PATCH v1 05/14] usb: dwc2: Add port conn. sts. checking in _dwc2_hcd_resume() function.

2019-04-19 Thread Artur Petrosyan
Added port connection status checking which prevents exiting from Partial Power Down mode from _dwc2_hcd_resume() when no entering to Partial Power Down mode happened. Signed-off-by: Artur Petrosyan --- drivers/usb/dwc2/hcd.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git

[PATCH v1 08/14] usb: dwc2: Add default param to control power optimization.

2019-04-19 Thread Artur Petrosyan
- Added a default param "power_saving" to enable or disable hibernation or partial power down features. - Printed hibernation param in hw_params_show and power_saving param in params_show. Signed-off-by: Artur Petrosyan Signed-off-by: Minas Harutyunyan --- drivers/usb/dwc2/core.h| 3 +

[PATCH v1 13/14] usb: dwc2: Clear GINTSTS_RESTOREDONE bit after restore is generated.

2019-04-19 Thread Artur Petrosyan
When hibernation exit is performed the dwc2_hib_restore_common() function is called. In that function we wait until GINTSTS_RESTOREDONE bit is set. However, after the setting of that bit we get a lot of (dwc2_hsotg_irq:) interrupts which indicates that (GINTSTS.RstrDoneInt) restore done interrupt i

[PATCH v1 09/14] usb: dwc2: Update dwc2_handle_usb_suspend_intr function.

2019-04-19 Thread Artur Petrosyan
To avoid working in two modes (partial power down and hibernation) changed conditions for entering partial power down or hibernation. Instead of checking hw_params.power_optimized and hw_params.hibernation now checking power_down param which already set to one of the options (Hibernation or Partia

[PATCH v1 06/14] usb: dwc2: Add part. power down exit from dwc2_conn_id_status_change().

2019-04-19 Thread Artur Petrosyan
Before changing to connector B exiting from Partial Power Down is required. - Added exiting from Partial Power Down mode when connector ID status changes to "connId B". Because if connector ID status changed to B connector while core was in partial power down mode, HANG would accrue from a

Re: [PATCH] USB: core: Fix bug caused by duplicate interface PM usage counter

2019-04-19 Thread Greg KH
On Fri, Apr 19, 2019 at 01:52:38PM -0400, Alan Stern wrote: > The syzkaller fuzzer reported a bug in the USB hub driver which turned > out to be caused by a negative runtime-PM usage counter. This allowed > a hub to be runtime suspended at a time when the driver did not expect > it. The symptom i

Re: [PATCH] usb: dwc3: Allow building USB_DWC3_QCOM without EXTCON

2019-04-19 Thread Marc Gonzalez
On 19/04/2019 13:24, Greg Kroah-Hartman wrote: > On Fri, Apr 19, 2019 at 11:59:08AM +0200, Marc Gonzalez wrote: > >> Keep EXTCON support optional, since some platforms do not need it. >> >> Fixes: 3def4031b3e3 ("usb: dwc3: add EXTCON dependency for qcom") >> Signed-off-by: Marc Gonzalez >> --- >>

[PATCH] usb: dwc3: Allow building USB_DWC3_QCOM without EXTCON

2019-04-19 Thread Marc Gonzalez
Keep EXTCON support optional, since some platforms do not need it. Fixes: 3def4031b3e3 ("usb: dwc3: add EXTCON dependency for qcom") Signed-off-by: Marc Gonzalez --- drivers/usb/dwc3/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/Kconfig b/drivers/

usb: dwc2: Usb wifi dongle fails to initialize with Frame Overrun errors

2019-04-19 Thread Hal Emmerich
Hello all, I have a ar9271 wireless dongle which is known to not work well with dwc2. When inserted, it may initialize properly if the system was just rebooted but after that will error out. With dwc2 verbose debug enabled, I see a bulk transfer followed by a frame overrun interrupt. The l

[PATCH v1 01/14] usb: dwc2: Fix dwc2_restore_device_registers() function.

2019-04-19 Thread Artur Petrosyan
- Added backup of DCFG register. - Added Set the Power-On Programming done bit. Signed-off-by: Artur Petrosyan --- drivers/usb/dwc2/gadget.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 6812a8a3a98b..dcb0fbb8bc42 1006

[PATCH v1 04/14] usb: dwc2: Fix suspend state in host mode for partial power down.

2019-04-19 Thread Artur Petrosyan
- In dwc2_port_suspend() function added waiting for the HPRT0.PrtSusp register field to be set. - In _dwc2_hcd_suspend() function added checking of "hsotg->flags.b.port_connect_status" port connection status if port connection status is 0 then skipping power saving (entering partial power

[PATCH v1 02/14] usb: dwc2: Add descriptive debug messages for Partial Power Down mode.

2019-04-19 Thread Artur Petrosyan
Added dev_dbg() messages when entering and exiting from partial power down. It is now more visible when core enters partial power down and when exits form it. Debug messages are added in the following functions. - dwc2_exit_partial_power_down() - dwc2_enter_partial_power_down() Signed-off-by: Art

Re: [PATCH v2 0/5] USB: dwc2: Allow wakeup from suspend; enable for rk3288-veyron

2019-04-19 Thread Artur Petrosyan
Hi, On 4/18/2019 19:55, Doug Anderson wrote: > Hi, > > On Thu, Apr 18, 2019 at 5:41 AM Minas Harutyunyan > wrote: >> Did you consider/reviewed patch series from Artur Petrosyan "[PATCH >> 00/14] usb: dwc2: Fix and improve power saving modes" (submitted on >> April 12) which fixing partial power

[PATCH v1 07/14] usb: dwc2: Reset DEVADDR after exiting gadget hibernation.

2019-04-19 Thread Artur Petrosyan
Initially resetting device address was done in dwc2_hsotg_irq() interrupt handler. However, when core is hibernated USB RESET is not handled in dwc2_hsotg_irq() handler, instead USB RESET interrupt is handled in dwc2_handle_gpwrdn_intr() handler. - Added reset device address to zero when core exit

[PATCH v1 10/14] usb: dwc2: Fix hibernation between host and device modes.

2019-04-19 Thread Artur Petrosyan
When core is in hibernation in host mode and a device cable was connected than driver exited from device hibernation. However, registers saved for host mode and when exited from device hibernation register restore would be done for device register which was wrong because there was no device registe

[PATCH v1 03/14] usb: dwc2: Fix wakeup detected and session request interrupt handlers.

2019-04-19 Thread Artur Petrosyan
In host mode port power must be turned on when wakeup detected or session request interrupt is detected. Because, otherwise core wouldn't exit form partial power down. - Turned on the port power by setting HPRT0_PWR bit. - Called dwc2_hcd_connect() function after enabling the power of the port.

[PATCH v1 12/14] usb: dwc2: Clear fifo_map when resetting core.

2019-04-19 Thread Artur Petrosyan
If core enters host hibernation when switching from device mode to host mode disconnection of host cable asserts a WARNING in dwc2_hsotg_init_fifo() that fifo_map is not cleared. To avoid the WARNING, fifo_map should be cleared in dwc2_core_reset() function. - Cleared fifo_map when resetting the

[PATCH v1 14/14] usb: dwc2: Add enter/exit hibernation from system issued suspend/resume

2019-04-19 Thread Artur Petrosyan
Added a new flow of entering and exiting hibernation when PC is hibernated or suspended. Signed-off-by: Artur Petrosyan --- drivers/usb/dwc2/hcd.c | 128 +++-- 1 file changed, 81 insertions(+), 47 deletions(-) diff --git a/drivers/usb/dwc2/hcd.c b/dri