platform/kernel/linux-starfive.git
7 years agousb: musb: Add a quirk to preserve the session during suspend
Alexandre Bailon [Thu, 2 Feb 2017 03:30:19 +0000 (21:30 -0600)]
usb: musb: Add a quirk to preserve the session during suspend

On da8xx, VBUS is not maintained during suspend when musb is in host mode.
On resume, all the connected devices will be disconnected and then will
be enumerated again.
This happens because MUSB_DEVCTL is cleared during suspend.
Add a quirk to not clear MUSB_DEVCTL and then preserve the  session during
a suspend.

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Signed-off-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: musb: da8xx: Add support of suspend / resume
Alexandre Bailon [Thu, 2 Feb 2017 03:30:18 +0000 (21:30 -0600)]
usb: musb: da8xx: Add support of suspend / resume

Implement PM methods specifics for da8xx glue.
The only thing to do is to power off the phy.
As the registers are in retention during suspend,
there is no need to save them.

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Signed-off-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: musb: davinci: remove redundant code
Bin Liu [Thu, 2 Feb 2017 03:30:17 +0000 (21:30 -0600)]
usb: musb: davinci: remove redundant code

The session is cleared in the core whenever musb_platform_disable() is
called, so clearing it in the glue driver *_musb_disable() is redundant.

Signed-off-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: musb: am35x: remove redundant code
Bin Liu [Thu, 2 Feb 2017 03:30:16 +0000 (21:30 -0600)]
usb: musb: am35x: remove redundant code

The session is cleared in the core whenever musb_platform_disable() is
called, so clearing it in the glue driver *_musb_disable() is redundant.

Signed-off-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: musb: da8xx: remove redundant code
Bin Liu [Thu, 2 Feb 2017 03:30:15 +0000 (21:30 -0600)]
usb: musb: da8xx: remove redundant code

The session is cleared in the core whenever musb_platform_disable() is
called, so clearing it in the glue driver *_musb_disable() is redundant.

Signed-off-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: musb: dsps: remove redundant code
Bin Liu [Thu, 2 Feb 2017 03:30:14 +0000 (21:30 -0600)]
usb: musb: dsps: remove redundant code

The session is cleared in the core whenever musb_platform_disable() is
called, so clearing it in the glue driver *_musb_disable() is redundant.

Signed-off-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: musb: remove musb_generic_disable function
Bin Liu [Thu, 2 Feb 2017 03:30:13 +0000 (21:30 -0600)]
usb: musb: remove musb_generic_disable function

musb_generic_disable() only has two lines of code. So remove it and let
the callers directly call those two lines.

Signed-off-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: musb: da8xx: Remove CPPI 3.0 quirk and methods
Alexandre Bailon [Thu, 2 Feb 2017 03:30:12 +0000 (21:30 -0600)]
usb: musb: da8xx: Remove CPPI 3.0 quirk and methods

DA8xx driver is registering and using the CPPI 3.0 DMA controller but
actually, the DA8xx has a CPPI 4.1 DMA controller.
Remove the CPPI 3.0 quirk and methods.

Fixes: f8e9f34f80a2 ("usb: musb: Fix up DMA related macros")
Fixes: 7f6283ed6fe8 ("usb: musb: Set up function pointers for DMA")
Cc: <stable@vger.kernel.org>
Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Acked-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: misc: adutux: remove redundant error check on copy_to_user return code
Colin Ian King [Thu, 2 Feb 2017 11:51:48 +0000 (11:51 +0000)]
usb: misc: adutux: remove redundant error check on copy_to_user return code

The 2nd check for a non-zero return from copy_to_user is redundant as
it is has already been made a few lines earlier.  This check was made
redundant because of previous fix to the copy_to_user error return
check.

Detected by CoverityScan, CID#114347 ("Logically Dead Code")

Fixes: 1865a9c382ede ("USB: adutux: fix misuse of return value of copy_to_user()")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoMerge tag 'phy-for-4.11' of git://git.kernel.org/pub/scm/linux/kernel/git/kishon...
Greg Kroah-Hartman [Tue, 31 Jan 2017 09:51:45 +0000 (10:51 +0100)]
Merge tag 'phy-for-4.11' of git://git./linux/kernel/git/kishon/linux-phy into usb-next

Kishon writes:

phy: for 4.11

 *) Add USB HSIC and HS phy driver for Qualcomm's SoC
 *) Add USB3 PHY driver for Broadcom NSP SoC
 *) Make sun4i-usb-phy driver to be used for V3s USB PHY
 *) Misc fixes and cleanups

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agophy: qcom-ufs: Fix misplaced jump label
Vivek Gautam [Fri, 27 Jan 2017 08:10:19 +0000 (13:40 +0530)]
phy: qcom-ufs: Fix misplaced jump label

We want to skip only tx/rx_iface clocks and not ref_clk_src
as well. Fix the jump label accordingly.

Fixes: 300f96771d78 ("phy: qcom-ufs: Skip obtaining rx/tx_iface_clk for msm8996 based phy")

Cc: Subhash Jadavani <subhashj@codeaurora.org>
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Cc: Kishon Vijay Abraham I <kishon@ti.com>
Cc: stable@vger.kernel.org
Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agophy: fix rockchip-inno-usb2 build errors
Randy Dunlap [Thu, 26 Jan 2017 17:42:41 +0000 (09:42 -0800)]
phy: fix rockchip-inno-usb2 build errors

Fix build errors in phy-rockchip-inno-usb2.c. The driver uses
extcon interfaces so it should depend on EXTCON.

Fixes these build errors:

drivers/built-in.o: In function `rockchip_usb2phy_otg_sm_work':
phy-rockchip-inno-usb2.c:(.text+0x2bcb): undefined reference to `extcon_get_state'
phy-rockchip-inno-usb2.c:(.text+0x2cd4): undefined reference to `extcon_set_state_sync'
phy-rockchip-inno-usb2.c:(.text+0x2cec): undefined reference to `extcon_set_state_sync'
phy-rockchip-inno-usb2.c:(.text+0x2d2d): undefined reference to `extcon_get_state'
drivers/built-in.o: In function `rockchip_usb2phy_probe':
phy-rockchip-inno-usb2.c:(.text+0x31d7): undefined reference to `extcon_get_edev_by_phandle'
phy-rockchip-inno-usb2.c:(.text+0x321a): undefined reference to `devm_extcon_dev_allocate'
phy-rockchip-inno-usb2.c:(.text+0x3230): undefined reference to `devm_extcon_dev_register'
phy-rockchip-inno-usb2.c:(.text+0x375a): undefined reference to `extcon_register_notifier'

Found in linux-next but is also needed in mainline.

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: MyungJoo Ham <myungjoo.ham@samsung.com>
Cc: Chanwoo Choi <cw00.choi@samsung.com>
Cc: Heiko Stuebner <heiko@sntech.de>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agophy: Add USB3 PHY support for Broadcom NSP SoC
Yendapally Reddy Dhananjaya Reddy [Tue, 17 Jan 2017 16:14:29 +0000 (11:14 -0500)]
phy: Add USB3 PHY support for Broadcom NSP SoC

This patch adds support for Broadcom NSP USB3 PHY

Signed-off-by: Yendapally Reddy Dhananjaya Reddy <yendapally.reddy@broadcom.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agodt-bindings: phy: Add documentation for NSP USB3 PHY
Yendapally Reddy Dhananjaya Reddy [Tue, 17 Jan 2017 16:14:27 +0000 (11:14 -0500)]
dt-bindings: phy: Add documentation for NSP USB3 PHY

Add documentation for USB3 PHY available in Northstar plus SoC

Signed-off-by: Yendapally Reddy Dhananjaya Reddy <yendapally.reddy@broadcom.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agophy: qcom-ufs: Suppress extraneous logging
Bjorn Andersson [Sun, 22 Jan 2017 21:17:49 +0000 (13:17 -0800)]
phy: qcom-ufs: Suppress extraneous logging

The error paths of the common qcom-ufs functions for registering the
phy, acquiring clocks and acquiring regulators all print specific error
messages before returning an error, so there is no value in printing yet
another - more generic - message when this occur.

Reviewed-by: Vivek Gautam <vivek.gautam@codeaurora.org>
Reviewed-by: Subhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agophy: qcom-ufs: Remove -always-on property
Bjorn Andersson [Sun, 22 Jan 2017 21:17:48 +0000 (13:17 -0800)]
phy: qcom-ufs: Remove -always-on property

The fact that a regulator is always-on is a property of the regulator,
not a specific consumer. Implementing this in the driver leads to a
system behaviour that is dependent on if the Qualcomm UFS PHY was ever
(partially) probed.

If the specific regulator should be always on in a particular device,
mark it so by specifying "regulator-always-on" in the regulator node.

Reviewed-by: Vivek Gautam <vivek.gautam@codeaurora.org>
Reviewed-by: Subhash Jadavani <subhashj@codeaurora.org>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agophy: qcom-ufs: Correct usage of regulator_get()
Bjorn Andersson [Sun, 22 Jan 2017 21:17:47 +0000 (13:17 -0800)]
phy: qcom-ufs: Correct usage of regulator_get()

When regulator_get() tries to resolve a regulator supply but fail to
find a matching property in DeviceTree it returns a dummy regulator, if
a matching supply is specified but unavailable the regulator core will
return an error.

Based on this we should not ignore errors upon failing to acquire the
optional "vddp-ref-clk" supply.

Reviewed-by: Vivek Gautam <vivek.gautam@codeaurora.org>
Reviewed-by: Subhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agophy: qcom-ufs: Don't kfree devres resource
Bjorn Andersson [Sun, 22 Jan 2017 21:17:46 +0000 (13:17 -0800)]
phy: qcom-ufs: Don't kfree devres resource

Upon failing to acquire regulator supplies the qcom-ufs driver calls
kfree() on the devm allocated memory used to store the name of the
regulator, leading to devres corruption.

Rather than switching to using the appropriate free function the patch
acknowledge the fact that "name" is always a constant string and we
don't actually need to create a local copy of it, but rather just
reference the constant string.

Fixes: add78fc05702 ("phy: qcom-ufs: Use devm sibling of kstrdup for regulator names")
Cc: stable@vger.kernel.org
Reviewed-by: Subhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agophy: Add support for Qualcomm's USB HS phy
Stephen Boyd [Wed, 25 Jan 2017 22:32:45 +0000 (14:32 -0800)]
phy: Add support for Qualcomm's USB HS phy

The high-speed phy on qcom SoCs is controlled via the ULPI
viewport.

Cc: Kishon Vijay Abraham I <kishon@ti.com>
Cc: <devicetree@vger.kernel.org>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agophy: Add support for Qualcomm's USB HSIC phy
Stephen Boyd [Wed, 25 Jan 2017 22:32:44 +0000 (14:32 -0800)]
phy: Add support for Qualcomm's USB HSIC phy

The HSIC USB controller on qcom SoCs has an integrated all
digital phy controlled via the ULPI viewport.

Cc: Kishon Vijay Abraham I <kishon@ti.com>
Acked-by: Rob Herring <robh@kernel.org>
Cc: <devicetree@vger.kernel.org>
Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agoUSB: cdc-acm: fix TIOCGSERIAL flags
Johan Hovold [Wed, 25 Jan 2017 17:02:49 +0000 (18:02 +0100)]
USB: cdc-acm: fix TIOCGSERIAL flags

The driver reports that it always uses a low-latency mode by returning
the ASYNC_LOW_LATENCY flag through TIOCGSERIAL.

Even if this behaviour could not be changed, this may have made some
sense prior to 7a9a65ced11e ("cdc-acm: Fix long standing abuse of
tty->low_latency") which removed the unconditional setting of the
corresponding tty low_latency flag (something which had always been
broken in itself).

Since the driver does not have a low-latency mode, let's drop the flag.

Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoMerge tag 'usb-for-v4.11' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi...
Greg Kroah-Hartman [Thu, 26 Jan 2017 14:36:28 +0000 (15:36 +0100)]
Merge tag 'usb-for-v4.11' of git://git./linux/kernel/git/balbi/usb into usb-next

Felipe writes:

USB: changes for v4.11

Here's the big pull request for the Gadget
API. Again the majority of changes sit in dwc2
driver. Most important changes contain a workaround
for GOTGCTL being wrong, a sleep-inside-spinlock fix
and the big series of cleanups on dwc2.

One important thing on dwc3 is that we don't anymore
need gadget drivers to cope with unaligned OUT
transfers for us. We have support for appending one
extra chained TRB to align transfer ourselves.

Apart from these, the usual set of typos,
non-critical fixes, etc.

7 years agousb: dwc3: host: pass quirk-broken-port-ped property for known broken revisions
Felipe Balbi [Thu, 26 Jan 2017 09:17:37 +0000 (11:17 +0200)]
usb: dwc3: host: pass quirk-broken-port-ped property for known broken revisions

dwc3 revisions <=3.00a have a limitation where Port Disable command
doesn't work. Set the quirk-broken-port-ped property for such
controllers so XHCI core can do the necessary workaround.

[rogerq@ti.com] Updated code from platform data to device property.

Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc2: eliminate irq parameter from dwc2_hcd_init
Heiner Kallweit [Wed, 25 Jan 2017 22:13:37 +0000 (23:13 +0100)]
usb: dwc2: eliminate irq parameter from dwc2_hcd_init

The irq is available in hsotg already, so there's no need to
pass it as separate function parameter.

Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc2: fix "iomem 0x00000000" message
Heiner Kallweit [Wed, 25 Jan 2017 22:10:51 +0000 (23:10 +0100)]
usb: dwc2: fix "iomem 0x00000000" message

Set the iomem parameters in the usb_hcd to fix this misleading
message during driver load:
dwc2 c9100000.usb: irq 22, io mem 0x00000000

Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: phy: ab8500: remove unused ab8500_eyediagram_workaroud()
Arnd Bergmann [Wed, 25 Jan 2017 22:30:31 +0000 (23:30 +0100)]
usb: phy: ab8500: remove unused ab8500_eyediagram_workaroud()

The only caller of this function is gone, so now we get a warning:

drivers/usb/phy/phy-ab8500-usb.c:1026:17: error: 'ab8500_eyediagram_workaroud' defined but not used [-Werror=unused-function]

It is possible that we should in fact still call the function from
somewhere else, but I don't see from where.

Fixes: 635f997a499b ("usb: phy: ab8500: Remove the set_power callback")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: gadget: udc: fsl: Add missing complete function.
Magnus Lilja [Wed, 25 Jan 2017 21:07:59 +0000 (22:07 +0100)]
usb: gadget: udc: fsl: Add missing complete function.

Commit 304f7e5e1d08 ("usb: gadget: Refactor request completion")
removed check if req->req.complete is non-NULL, resulting in a NULL
pointer derefence and a kernel panic.
This patch adds an empty complete function instead of re-introducing
the req->req.complete check.

Fixes: 304f7e5e1d08 ("usb: gadget: Refactor request completion")

Signed-off-by: Magnus Lilja <lilja.magnus@gmail.com>
Cc: <stable@vger.kernel.org> # 3.18+
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc3: gadget: read IN ep FIFO size from HW
Felipe Balbi [Mon, 23 Jan 2017 16:01:59 +0000 (18:01 +0200)]
usb: dwc3: gadget: read IN ep FIFO size from HW

Instead of assuming all IN endpoints support 1024
bytes, let's read the actual value from HW and pass
that to gadget API.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agoxhci: refactor xhci_urb_enqueue
Mathias Nyman [Mon, 23 Jan 2017 12:20:27 +0000 (14:20 +0200)]
xhci: refactor xhci_urb_enqueue

Use switch instead of several if statements

Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoxhci: simplify how we store TDs in urb private data
Mathias Nyman [Mon, 23 Jan 2017 12:20:26 +0000 (14:20 +0200)]
xhci: simplify how we store TDs in urb private data

Instead of storing a zero length array of td pointers, and then
allocate memory both for the td pointer array and the td's, just
use a zero length array of actual td's in urb private data.

old:

struct urb_priv {
       struct xhci_td *td[0]
}

new:

struct urb_priv {
        struct xhci_td td[0]
}

Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoxhci: Rename variables related to transfer descritpors
Mathias Nyman [Mon, 23 Jan 2017 12:20:25 +0000 (14:20 +0200)]
xhci: Rename variables related to transfer descritpors

urb_priv structure has a count on how many TDs the
URB contains, and how many of those TD's we have handled.

rename:
length -> num_tds
td_cnt -> num_tds_done

No functional changes

Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoxhci: rename size variable to num_tds
Mathias Nyman [Mon, 23 Jan 2017 12:20:24 +0000 (14:20 +0200)]
xhci: rename size variable to num_tds

No functinal changes.
num_tds describes the number of transfer descriptor better than "size"

Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: host: xhci: add xhci_virt_device tracer
Felipe Balbi [Mon, 23 Jan 2017 12:20:23 +0000 (14:20 +0200)]
usb: host: xhci: add xhci_virt_device tracer

Let's start tracing at least part of an xhci_virt_device lifetime. We
might want to extend this tracepoint class later, but for now it already
exposes quite a bit of valuable information.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: host: xhci: remove newline from tracer
Felipe Balbi [Mon, 23 Jan 2017 12:20:22 +0000 (14:20 +0200)]
usb: host: xhci: remove newline from tracer

If we add that newline, the output will look like the following:

     kworker/2:1-42    [002] ....   169.811435: xhci_address_ctx:
ctx_64=0, ctx_type=2, ctx_dma=@153fbd000, ctx_va=@ffff880153fbd000

We would rather have that in a single line.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: host: xhci: convert several if() to a single switch statement
Felipe Balbi [Mon, 23 Jan 2017 12:20:21 +0000 (14:20 +0200)]
usb: host: xhci: convert several if() to a single switch statement

when getting endpoint type, a switch statement looks
better than a series of if () branches. There are no
functional changes with this patch, cleanup only.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: host: xhci: add urb_enqueue/dequeue/giveback tracers
Felipe Balbi [Mon, 23 Jan 2017 12:20:20 +0000 (14:20 +0200)]
usb: host: xhci: add urb_enqueue/dequeue/giveback tracers

These three new tracers will help us tie TRBs into URBs by *also*
looking into URB lifetime.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: host: xhci: make a generic TRB tracer
Felipe Balbi [Mon, 23 Jan 2017 12:20:19 +0000 (14:20 +0200)]
usb: host: xhci: make a generic TRB tracer

instead of having a tracer that can only trace command completions,
let's promote this tracer so it can trace and decode any TRB.

With that, it will be easier to extrapolate the lifetime of any TRB
which might help debugging certain issues.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: host: xhci: combine event TRB completion debugging messages
Felipe Balbi [Mon, 23 Jan 2017 12:20:18 +0000 (14:20 +0200)]
usb: host: xhci: combine event TRB completion debugging messages

If we just provide a helper to convert completion code to string, we can
combine all debugging messages into a single print.

[keep the old debug messages, for warn and grep -Mathias]
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: host: xhci: convert to list_for_each_entry_safe()
Felipe Balbi [Mon, 23 Jan 2017 12:20:17 +0000 (14:20 +0200)]
usb: host: xhci: convert to list_for_each_entry_safe()

instead of using while(!list_empty()) followed by list_first_entry(), we
can actually use list_for_each_entry_safe().

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoxhci: use the trb_to_noop() helper for command trbs
Mathias Nyman [Mon, 23 Jan 2017 12:20:16 +0000 (14:20 +0200)]
xhci: use the trb_to_noop() helper for command trbs

Remove duplicate code by using trb_to_noop() when
handling Aborted commads

Based on earlier code by Felipe Balbi <felipe.balbi@linux.intel.com>

Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoxhci: Introduce helper to turn one TRB into a no-op
Mathias Nyman [Mon, 23 Jan 2017 12:20:15 +0000 (14:20 +0200)]
xhci: Introduce helper to turn one TRB into a no-op

Useful for turning both transfer and command trbs
into no-ops.

Based on earlier code by Felipe Balbi <felipe.balbi@linux.intel.com>

Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: host: xhci: unconditionally call xhci_unmap_td_bounce_buffer()
Felipe Balbi [Mon, 23 Jan 2017 12:20:14 +0000 (14:20 +0200)]
usb: host: xhci: unconditionally call xhci_unmap_td_bounce_buffer()

xhci_unmap_td_bounce_buffer() already checks for a valid td->bounce_seg
and bails out early if that's invalid. There's no need to check for this
twice.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: host: xhci: check for a valid ring when unmapping bounce buffer
Felipe Balbi [Mon, 23 Jan 2017 12:20:13 +0000 (14:20 +0200)]
usb: host: xhci: check for a valid ring when unmapping bounce buffer

This way we can remove checks for valid ring from call sites of
xhci_unmap_td_bounce_buffer()

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: host: xhci: remove bogus __releases()/__acquires() annotation
Felipe Balbi [Mon, 23 Jan 2017 12:20:12 +0000 (14:20 +0200)]
usb: host: xhci: remove bogus __releases()/__acquires() annotation

handle_tx_event() is not releasing xhci->lock nor reacquiring it, remove
the bogus annotation.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: host: xhci: introduce xhci_td_cleanup()
Felipe Balbi [Mon, 23 Jan 2017 12:20:11 +0000 (14:20 +0200)]
usb: host: xhci: introduce xhci_td_cleanup()

By extracting xhci_td_cleanup() from finish_td(), code before clearer
and easier to follow.

There are no functional changes with this patch. It's merely a cleanup.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: host: xhci: reorder variable definitions
Felipe Balbi [Mon, 23 Jan 2017 12:20:10 +0000 (14:20 +0200)]
usb: host: xhci: reorder variable definitions

no functional changes. Simple cleanup to make sure variables are ordered
in a 'reverse christmas tree' fashion. While at that, also remove an
obsolete comment which doesn't apply anymore.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: host: xhci: use slightly better list helpers
Felipe Balbi [Mon, 23 Jan 2017 12:20:09 +0000 (14:20 +0200)]
usb: host: xhci: use slightly better list helpers

Replace list_entry() with list_first_entry() and list_for_each() with
list_for_each_entry(). This makes the code slightly more readable.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: host: xhci: remove unneded semicolon
Felipe Balbi [Mon, 23 Jan 2017 12:20:08 +0000 (14:20 +0200)]
usb: host: xhci: remove unneded semicolon

it does no good, let's remove it.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: host: xhci: simplify irq handler return
Felipe Balbi [Mon, 23 Jan 2017 12:20:07 +0000 (14:20 +0200)]
usb: host: xhci: simplify irq handler return

Instead of having several return points, let's use a local variable and
a single place to return. This makes the code slightly easier to read.

[set ret = IRQ_HANDLED in default working case  -Mathias]
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: host: xhci: rename completion codes to match spec
Felipe Balbi [Mon, 23 Jan 2017 12:20:06 +0000 (14:20 +0200)]
usb: host: xhci: rename completion codes to match spec

Cleanup only. This patch is a mechaninal rename to make sure our macros
for TRB completion codes match what the specification uses to refer to
such errors. The idea behind this is that it makes it far easier to grep
the specification and match it with implementation.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: host: xhci: print HCIVERSION on debug
Felipe Balbi [Mon, 23 Jan 2017 12:20:05 +0000 (14:20 +0200)]
usb: host: xhci: print HCIVERSION on debug

When calling xhci_dbg_regs() we actually _do_ want to know XHCI's
version. This might help figure out why certain problems only happen
in some cases.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: host: xhci: change pre-increments to post-increments
Felipe Balbi [Mon, 23 Jan 2017 12:20:04 +0000 (14:20 +0200)]
usb: host: xhci: change pre-increments to post-increments

This is a cleanup patch only, no functional changes. The idea is just to
make sure for loops look the same all over the driver.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: xhci: remove unnecessary return in xhci_pci_setup()
Lu Baolu [Mon, 23 Jan 2017 12:20:03 +0000 (14:20 +0200)]
usb: xhci: remove unnecessary return in xhci_pci_setup()

Remove the unnecessary return line in xhci_pci_setup().

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: xhci: use list_is_singular for cmd_list
Lu Baolu [Mon, 23 Jan 2017 12:20:02 +0000 (14:20 +0200)]
usb: xhci: use list_is_singular for cmd_list

Use list_is_singular() to check if cmd_list has only one entry.

[use list_empty() in queue command instead -Mathias]
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: xhci: avoid unnecessary calculation
Lu Baolu [Mon, 23 Jan 2017 12:20:01 +0000 (14:20 +0200)]
usb: xhci: avoid unnecessary calculation

No need to calculate remainder and length_field, if there is
no data phase of a control transfer.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: xhci: remove unnecessary assignment
Lu Baolu [Mon, 23 Jan 2017 12:20:00 +0000 (14:20 +0200)]
usb: xhci: remove unnecessary assignment

Drop an unnecessary assignment in prepare_transfer().

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: host: xhci-plat: enable BROKEN_PED quirk if platform requested
Felipe Balbi [Mon, 23 Jan 2017 12:19:59 +0000 (14:19 +0200)]
usb: host: xhci-plat: enable BROKEN_PED quirk if platform requested

In case 'quirk-broken-port-ped' property is passed in via device property,
we should enable the corresponding BROKEN_PED quirk flag for XHCI core.

[rogerq@ti.com] Updated code from platform data to device property
and added DT binding.

Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: xhci: add quirk flag for broken PED bits
Felipe Balbi [Mon, 23 Jan 2017 12:19:58 +0000 (14:19 +0200)]
usb: xhci: add quirk flag for broken PED bits

Some devices from Texas Instruments [1] suffer from
a silicon bug where Port Enabled/Disabled bit
should not be used to silence an erroneous device.

The bug is so that if port is disabled with PED
bit, an IRQ for device removal (or attachment)
will never fire.

Just for the sake of completeness, the actual
problem lies with SNPS USB IP and this affects
all known versions up to 3.00a. A separate
patch will be added to dwc3 to enabled this
quirk flag if version is <= 3.00a.

[1] - AM572x Silicon Errata http://www.ti.com/lit/er/sprz429j/sprz429j.pdf
Section i896— USB xHCI Port Disable Feature Does Not Work

Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoxhci: Put warning message on a single line
Alexander Stein [Mon, 23 Jan 2017 12:19:57 +0000 (14:19 +0200)]
xhci: Put warning message on a single line

This allows someone to grep for the complete warning message as in;
xhci-hcd xhci-hcd.0.auto: USB core suspending device not in U0/U1/U2.

Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: host: xhci: Remove unused 'addr_64' variable in xhci_hcd structure
Baolin Wang [Mon, 23 Jan 2017 12:19:56 +0000 (14:19 +0200)]
usb: host: xhci: Remove unused 'addr_64' variable in xhci_hcd structure

Since the 'addr_64' variable as legacy is unused now, then remove it from
xhci_hcd structure.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: xhci: remove unnecessary second abort try
Lu Baolu [Mon, 23 Jan 2017 12:19:55 +0000 (14:19 +0200)]
usb: xhci: remove unnecessary second abort try

The second try was a workaround for (what we thought was) command
ring failing to stop in the first place. But this turns out to be
due to the race that we have fixed(see "xhci: Fix race related to
abort operation"). With that fix, it is time to remove the second
try.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoxhci: remove unnecessary check for pending timer
Mathias Nyman [Mon, 23 Jan 2017 12:19:54 +0000 (14:19 +0200)]
xhci: remove unnecessary check for pending timer

Checking if the command timeout timer is pending when queueing the
first command to the command ring is not really useful, remove it.

Suggested-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoxhci: detect stop endpoint race using pending timer instead of counter.
Mathias Nyman [Mon, 23 Jan 2017 12:19:53 +0000 (14:19 +0200)]
xhci: detect stop endpoint race using pending timer instead of counter.

A counter was used to find out if the stop endpoint completion raced with
the stop endpoint timeout timer. This was needed in case the stop ep
completion failed to delete the timer as it was running on anoter cpu.

The EP_STOP_CMD_PENDING flag was not enough as a new stop endpoint command
may be queued between the command completion and timeout function, which
would set the flag back.

Instead of the separate counter that was used we can detect the race by
checking both the STOP_EP_PENDING flag and timer_pending in the timeout
function.

Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoxhci: rename EP_HALT_PENDING to EP_STOP_CMD_PENDING
Mathias Nyman [Mon, 23 Jan 2017 12:19:52 +0000 (14:19 +0200)]
xhci: rename EP_HALT_PENDING to EP_STOP_CMD_PENDING

We don't want to confuse halted and stalled endpoint states with
a flag indicating we are waiting for a stop endpoint command to
finish or timeout

Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoxhci: simplify if statement to make it more readable
Mathias Nyman [Mon, 23 Jan 2017 12:19:51 +0000 (14:19 +0200)]
xhci: simplify if statement to make it more readable

No functional change, De Morgan !(A && B) = (!A || !B)

Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: storage: sddr09: Remove a set-but-not-used variable
Augusto Mecking Caringi [Tue, 24 Jan 2017 18:11:23 +0000 (18:11 +0000)]
usb: storage: sddr09: Remove a set-but-not-used variable

The 'isnew' variable in 'sddr09_write_lba' function is set but never
used.

This has been detected by building the driver with W=1:

drivers/usb/storage/sddr09.c: In function â€˜sddr09_write_lba’:
drivers/usb/storage/sddr09.c:873:17: warning: variable â€˜isnew’ set but
not used [-Wunused-but-set-variable]
int i, result, isnew;
                 ^

Signed-off-by: Augusto Mecking Caringi <augustocaringi@gmail.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: musb: constify musb_hdrc_config structures
Bhumika Goyal [Tue, 24 Jan 2017 19:22:22 +0000 (00:52 +0530)]
usb: musb: constify musb_hdrc_config structures

Declare musb_hdrc_config structures as const as they are only stored in
the config field of a musb_hdrc_platform_data structure. This field is of
type const, so musb_hdrc_config structures having this property can be
made const too.
Done using Coccinelle:

@r disable optional_qualifier@
identifier x;
position p;
@@
static struct musb_hdrc_config x@p={...};

@ok@
struct musb_hdrc_platform_data pdata;
identifier r.x;
position p;
@@
pdata.config=&x@p;

@bad@
position p != {r.p,ok.p};
identifier r.x;
@@
x@p

@depends on !bad disable optional_qualifier@
identifier r.x;
@@
+const
struct musb_hdrc_config x;

File size before:
   text    data     bss     dec     hex filename
   1212     338       0    1550     60e drivers/usb/musb/jz4740.o

File size after:
   text    data     bss     dec     hex filename
   1268     290       0    1558     616 drivers/usb/musb/jz4740.o

File size before:
   text    data     bss     dec     hex filename
   6151     333      16    6500    1964 drivers/usb/musb/sunxi.o

File size after:
   text    data     bss     dec     hex filename
   6215     269      16    6500    1964 drivers/usb/musb/sunxi.o

File size before:
   text    data     bss     dec     hex filename
   3668     864       0    4532    11b4 drivers/usb/musb/ux500.o

File size after:
   text    data     bss     dec     hex filename
   3724     808       0    4532    11b4 drivers/usb/musb/ux500.o

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoMerge 4.10-rc5 into usb-next
Greg Kroah-Hartman [Wed, 25 Jan 2017 08:20:49 +0000 (09:20 +0100)]
Merge 4.10-rc5 into usb-next

We need the USB fixes in here as well to handle future merge issues and
dependancies.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: dwc2: gadget: Add checking for g-tx-fifo-size parameter
Sevak Arakelyan [Mon, 23 Jan 2017 23:01:45 +0000 (15:01 -0800)]
usb: dwc2: gadget: Add checking for g-tx-fifo-size parameter

Add dwc2_check_param_tx_fifo_sizes function which validates
the members of g_tx_fifo_size array and sets to average or
default values if it is needed.

Cc: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Sevak Arakelyan <sevaka@synopsys.com>
Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc2: gadget: Set TX FIFO depths to calculated defaults
Sevak Arakelyan [Mon, 23 Jan 2017 23:01:23 +0000 (15:01 -0800)]
usb: dwc2: gadget: Set TX FIFO depths to calculated defaults

Remove legacy DWC2_G_P_LEGACY_TX_FIFO_SIZE array for TX FIFOs.
Update dwc2_set_param_tx_fifo_sizes function to calculate
and assign default average FIFO depth to each member of
g_tx_fifo_size array. Total FIFO size, EP Info block's size,
FIFO operation mode and device operation mode are taken into
consideration during the calculation.

Cc: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Sevak Arakelyan <sevaka@synopsys.com>
Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc2: host: Correct snpsid checking for GDFIFOCFG
Sevak Arakelyan [Mon, 23 Jan 2017 23:01:01 +0000 (15:01 -0800)]
usb: dwc2: host: Correct snpsid checking for GDFIFOCFG

GDFIFOCFG is available from IP version 2.91a. Fix the code to reflect
this.

Signed-off-by: Sevak Arakelyan <sevaka@synopsys.com>
Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc2: host: use msleep() for long delay
Nicholas Mc Guire [Mon, 23 Jan 2017 23:00:40 +0000 (15:00 -0800)]
usb: dwc2: host: use msleep() for long delay

ulseep_range() uses hrtimers and provides no advantage over msleep()
for larger delays. Fix up the 100ms delays here passing the adjusted "min"
value to msleep(). This helps reduce the load on the hrtimer subsystem.

Link: http://lkml.org/lkml/2017/1/11/377
Fixes: commit 2938fc63e0c2 ("usb: dwc2: Properly account for the force mode delays")
Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc2: Add a quirk to allow speed negotiation for Hisilicon Hi6220
Chen Yu [Mon, 23 Jan 2017 23:00:18 +0000 (15:00 -0800)]
usb: dwc2: Add a quirk to allow speed negotiation for Hisilicon Hi6220

The Hi6220's usb controller is limited in that it does not
support "Split Transactions", so it does not support communicating
with low-speed and full-speed devices behind a high-speed hub.

Thus it requires a quirk so that we can manually drop the usb
speed when low/full-speed are attached, and bump back to high
speed when they are removed.

Cc: Wei Xu <xuwei5@hisilicon.com>
Cc: Guodong Xu <guodong.xu@linaro.org>
Cc: Amit Pundir <amit.pundir@linaro.org>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: John Youn <johnyoun@synopsys.com>
Cc: Douglas Anderson <dianders@chromium.org>
Cc: Chen Yu <chenyu56@huawei.com>
Cc: Vardan Mikayelyan <mvardan@synopsys.com>
Cc: Kishon Vijay Abraham I <kishon@ti.com>
Cc: Felipe Balbi <felipe.balbi@linux.intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org
Signed-off-by: Chen Yu <chenyu56@huawei.com>
[jstultz: Reworked to simplify the patch, and made
 commit log to be more specific about the issue]
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc2: Force port resume on switching to device mode
Chen Yu [Mon, 23 Jan 2017 22:59:57 +0000 (14:59 -0800)]
usb: dwc2: Force port resume on switching to device mode

We've seen failures when switching between host and gadget mode,
which was diagnosed as being caused due to the bus being
auto-suspended when we switched.

So this patch forces a port resume when switching to device
mode if the bus is suspended.

Cc: Wei Xu <xuwei5@hisilicon.com>
Cc: Guodong Xu <guodong.xu@linaro.org>
Cc: Amit Pundir <amit.pundir@linaro.org>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: John Youn <johnyoun@synopsys.com>
Cc: Douglas Anderson <dianders@chromium.org>
Cc: Chen Yu <chenyu56@huawei.com>
Cc: Vardan Mikayelyan <mvardan@synopsys.com>
Cc: Kishon Vijay Abraham I <kishon@ti.com>
Cc: Felipe Balbi <felipe.balbi@linux.intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org
Signed-off-by: Chen Yu <chenyu56@huawei.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc2: Workaround case where GOTGCTL state is wrong
John Stultz [Mon, 23 Jan 2017 22:59:35 +0000 (14:59 -0800)]
usb: dwc2: Workaround case where GOTGCTL state is wrong

When removing a USB-A to USB-otg adapter cable, we get a change status
irq, and then in dwc2_conn_id_status_change, we erroneously see the
GOTGCTL_CONID_B flag set. This causes us to get stuck in the
"while (!dwc2_is_device_mode(hsotg))" loop, spitting out "Waiting for
Peripheral Mode, Mode=Host" warnings until it fails out many seconds
later.

This patch works around the issue by re-reading the GOTGCTL state to
check if the GOTGCTL_CONID_B is still set and if not restarting the
change status logic.

Cc: Wei Xu <xuwei5@hisilicon.com>
Cc: Guodong Xu <guodong.xu@linaro.org>
Cc: Amit Pundir <amit.pundir@linaro.org>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: John Youn <johnyoun@synopsys.com>
Cc: Douglas Anderson <dianders@chromium.org>
Cc: Chen Yu <chenyu56@huawei.com>
Cc: Vardan Mikayelyan <mvardan@synopsys.com>
Cc: Kishon Vijay Abraham I <kishon@ti.com>
Cc: Felipe Balbi <felipe.balbi@linux.intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org
Reviewed-by: Vardan Mikayelyan <mvardan@synopsys.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc2: Avoid sleeping while holding hsotg->lock
John Stultz [Mon, 23 Jan 2017 22:59:14 +0000 (14:59 -0800)]
usb: dwc2: Avoid sleeping while holding hsotg->lock

Basically when plugging in various cables in different orders, I'm
occasionally seeing the following BUG splat:

[   86.215403] BUG: scheduling while atomic: kworker/u16:2/53/0x00000002
[   86.219164] usb 1-1: USB disconnect, device number 9
[   86.226845] Preemption disabled at:[   86.230218]
[<ffffff8008673558>] dwc2_conn_id_status_change+0x120/0x250
[   86.236894] CPU: 0 PID: 53 Comm: kworker/u16:2 Tainted: G        W
     4.9.0-rc8-00051-gd5a7979-dirty #1702
[   86.246836] Hardware name: HiKey Development Board (DT)
[   86.252100] Workqueue: dwc2 dwc2_conn_id_status_change
[   86.257279] Call trace:
[   86.259771] [<ffffff8008087c28>] dump_backtrace+0x0/0x1a0
[   86.265210] [<ffffff8008087ddc>] show_stack+0x14/0x20
[   86.270308] [<ffffff80084343f0>] dump_stack+0x90/0xb0
[   86.275401] [<ffffff80080d8d94>] __schedule_bug+0x6c/0xb8
[   86.280841] [<ffffff8008a07220>] __schedule+0x4f8/0x5b0
[   86.286099] [<ffffff8008a073e8>] schedule+0x38/0xa0
[   86.291017] [<ffffff8008a0a6cc>] schedule_hrtimeout_range_clock+0x8c/0xf0
[   86.297846] [<ffffff8008a0a740>] schedule_hrtimeout_range+0x10/0x18
[   86.304150] [<ffffff8008a0a4a0>] usleep_range+0x50/0x58
[   86.309418] [<ffffff800866d8dc>] dwc2_wait_for_mode.isra.4+0x54/0xd0
[   86.315815] [<ffffff800866f058>] dwc2_core_reset+0xe0/0x168
[   86.321431] [<ffffff800867e364>] dwc2_hsotg_core_init_disconnected+0x2c/0x310
[   86.328602] [<ffffff8008673568>] dwc2_conn_id_status_change+0x130/0x250
[   86.335254] [<ffffff80080ccd48>] process_one_work+0x118/0x370
[   86.341035] [<ffffff80080ccfe8>] worker_thread+0x48/0x498
[   86.346473] [<ffffff80080d2eb0>] kthread+0xd0/0xe8
[   86.351299] [<ffffff8008082e80>] ret_from_fork+0x10/0x50

This seems to be caused by the dwc2_wait_for_mode() calling
usleep_range() while the hstog->lock spinlock is held, since
we take that before calling dwc2_hsotg_core_init_disconnected().

This patch avoids the issue by adding an extra argument to
dwc2_core_reset(), as suggested by John Youn, which allows us to
skip the waiting, which should be unnecessary when calling from
dwc2_hsotg_core_init_disconnected().

Cc: Wei Xu <xuwei5@hisilicon.com>
Cc: Guodong Xu <guodong.xu@linaro.org>
Cc: Amit Pundir <amit.pundir@linaro.org>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: John Youn <johnyoun@synopsys.com>
Cc: Douglas Anderson <dianders@chromium.org>
Cc: Chen Yu <chenyu56@huawei.com>
Cc: Vardan Mikayelyan <mvardan@synopsys.com>
Cc: Kishon Vijay Abraham I <kishon@ti.com>
Cc: Felipe Balbi <felipe.balbi@linux.intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc2: Show dr_mode via debugfs
John Youn [Mon, 23 Jan 2017 22:58:52 +0000 (14:58 -0800)]
usb: dwc2: Show dr_mode via debugfs

Show the value of dr_mode via a debufs file.

Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc2: Remove debug prints in params.c
John Youn [Mon, 23 Jan 2017 22:58:31 +0000 (14:58 -0800)]
usb: dwc2: Remove debug prints in params.c

Remove debugging prints to show params.

Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc2: Add debugfs file to show params
John Youn [Mon, 23 Jan 2017 22:58:09 +0000 (14:58 -0800)]
usb: dwc2: Add debugfs file to show params

Show the core params and hardware params.

Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc2: Remove unnecessary parameters
John Youn [Mon, 23 Jan 2017 22:57:48 +0000 (14:57 -0800)]
usb: dwc2: Remove unnecessary parameters

Further reduce the set of parameters set by platforms. Many of them are
unnecessary as they should be reported by hardware. They should only
need to be overridden if there is a problem.

Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc2: Fix usage of bool params
John Youn [Mon, 23 Jan 2017 22:57:26 +0000 (14:57 -0800)]
usb: dwc2: Fix usage of bool params

Check these parameters only for true or false. There is no need to check
for greater or less than 0.

Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc2: Remove platform static params
John Youn [Mon, 23 Jan 2017 22:57:04 +0000 (14:57 -0800)]
usb: dwc2: Remove platform static params

Remove the platform-specific static param structs and set only those
params that are necessary for each platform.

Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc2: Check core parameters
John Youn [Mon, 23 Jan 2017 22:56:43 +0000 (14:56 -0800)]
usb: dwc2: Check core parameters

Check that core parameters have valid values and adjust them if they
aren't.

Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc2: Rearrange param structure members
John Youn [Mon, 23 Jan 2017 22:56:20 +0000 (14:56 -0800)]
usb: dwc2: Rearrange param structure members

Group the members by global, host, and gadget params. Formatting and
organizational change only.

Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc2: Update parameter types
John Youn [Mon, 23 Jan 2017 22:55:58 +0000 (14:55 -0800)]
usb: dwc2: Update parameter types

Update the param types to appropriately sized ints and bools.

Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc2: Get device properties
John Youn [Mon, 23 Jan 2017 22:55:35 +0000 (14:55 -0800)]
usb: dwc2: Get device properties

After setting the default core parameter values, read in the device
properties and modify core parameter values if needed.

Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc2: Set core parameters to default values
John Youn [Mon, 23 Jan 2017 22:55:14 +0000 (14:55 -0800)]
usb: dwc2: Set core parameters to default values

Initialize the core parameters to their default, auto-detected values.

Remove all the previous dwc2_set_param* methods. Most of what this code
is doing is handling defaults for "not set" values and other trivial
checks. The checking can be simplified and will be done in a later
commit.

This allows us to change only those parameters that won't work with
default settings. It also allows us to use non-int parameters.

Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc2: Remove unused otg_ver parameter
John Youn [Mon, 23 Jan 2017 22:54:52 +0000 (14:54 -0800)]
usb: dwc2: Remove unused otg_ver parameter

The otg_ver parameter only controls the SRP pulsing method and defaults
to the 1.3 behavior. It is unused and can be removed.

Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: gadget: f_hid: fix: Move IN request allocation to set_alt()
Krzysztof Opasiak [Tue, 24 Jan 2017 02:27:24 +0000 (03:27 +0100)]
usb: gadget: f_hid: fix: Move IN request allocation to set_alt()

Since commit: ba1582f22231 ("usb: gadget: f_hid: use alloc_ep_req()")
we cannot allocate any requests in bind() as we check if we should
align request buffer based on endpoint descriptor which is assigned
in set_alt().

Allocating request in bind() function causes a NULL pointer
dereference.

This commit moves allocation of IN request from bind() to set_alt()
to prevent this issue.

Fixes: ba1582f22231 ("usb: gadget: f_hid: use alloc_ep_req()")
Cc: stable@vger.kernel.org
Tested-by: David Lechner <david@lechnology.com>
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: gadget: udc: constify usb_ep_ops structures
Bhumika Goyal [Mon, 23 Jan 2017 17:26:04 +0000 (22:56 +0530)]
usb: gadget: udc: constify usb_ep_ops structures

Declare usb_ep_ops structures as const as they are only stored in the
ops field of an usb_ep structure. This field is of type const, so
usb_ep_ops structures having this property can be made const too.
Done using Coccinelle( A smaller version of the script)

@r disable optional_qualifier@
identifier i;
position p;
@@
static struct usb_ep_ops i@p={...};

@ok@
identifier r.i;
position p;
struct mv_ep a;
struct mv_u3d_ep b;
struct omap_ep c;

@@
(
a.ep.ops=&i@p;
|
b.ep.ops=&i@p;
|
c.ep.ops=&i@p;

)

@bad@
position p!={r.p,ok.p};
identifier r.i;
@@
i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
+const
struct usb_ep_ops i;

File size details before and after applying  the patch.
First line of every .o file shows the file size before patching and
second line shows the file size after patching.

  text    data     bss     dec     hex filename

   7782     384       8    8174    1fee usb/gadget/udc/fotg210-udc.o
   7878     296       8    8182    1ff6 usb/gadget/udc/fotg210-udc.o

  17866     992      40   18898    49d2 usb/gadget/udc/fsl_udc_core.o
  17954     896      40   18890    49ca usb/gadget/udc/fsl_udc_core.o

   9646     288       8    9942    26d6 usb/gadget/udc/fusb300_udc.o
   9742     192       8    9942    26d6 usb/gadget/udc/fusb300_udc.o

  12752     416       8   13176    3378 drivers/usb/gadget/udc/goku_udc.o
  12832     328       8   13168    3370 drivers/usb/gadget/udc/goku_udc.o

  16541    1696       8   18245    4745 drivers/usb/gadget/udc/gr_udc.o
  16637    1600       8   18245    4745 drivers/usb/gadget/udc/gr_udc.o

  15798     288      16   16102    3ee6 drivers/usb/gadget/udc/m66592-udc.o
  15894     192      16   16102    3ee6 drivers/usb/gadget/udc/m66592-udc.o

  17751    3808      16   21575    5447 usb/gadget/udc/mv_u3d_core.o
  17839    3712      16   21567    543f usb/gadget/udc/mv_u3d_core.o

  17348    1112      24   18484    4834 usb/gadget/udc/mv_udc_core.o
  17436    1016      24   18476    482c usb/gadget/udc/mv_udc_core.o

  25990    2620      13   28623    6fcf drivers/usb/gadget/udc/net2272.o
  26086    2524      13   28623    6fcf drivers/usb/gadget/udc/net2272.o

  18409    7312       8   25729    6481 drivers/usb/gadget/udc/pxa27x_udc.o
  18505    7208       8   25721    6479 drivers/usb/gadget/udc/pxa27x_udc.o

  18644     288      16   18948    4a04 usb/gadget/udc/r8a66597-udc.o
  18740     192      16   18948    4a04 usb/gadget/udc/r8a66597-udc.o

Files: drivers/usb/gadget/udc/{s3c-hsudc.o/omap_udc.o/fsl_qe_udc.o} did
not complie.

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: gadget: udc: atmel: Update endpoint allocation scheme
Cristian Birsan [Mon, 23 Jan 2017 14:45:59 +0000 (16:45 +0200)]
usb: gadget: udc: atmel: Update endpoint allocation scheme

This patch updates the usb endpoint allocation scheme for atmel usba
driver to make sure all endpoints are allocated in order. This
requirement comes from the datasheet of the controller.

The allocation scheme is decided by fifo_mode parameter. For fifo_mode =
0 the driver tries to autoconfigure the endpoints fifo size. All other
modes contain fixed configurations optimized for different purposes. The
idea is somehow similar with the approach used on musb driver.

Signed-off-by: Cristian Birsan <cristian.birsan@microchip.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: gadget: f_fs: Accept up to 30 endpoints.
Vincent Pelletier [Mon, 23 Jan 2017 14:41:04 +0000 (14:41 +0000)]
usb: gadget: f_fs: Accept up to 30 endpoints.

It is allowed by the USB specification to enabled same-address, opposite-
direction endpoints simultaneously, which means 30 non-zero endpoints
are allowed. So double eps_addrmap length to 30.
The original code only accepted 14 descriptors out of a likely intended 15
(as there are 15 endpoint addresses, ignoring direction), because the first
eps_addrmap entry is unused (it is a placeholder for endpoint zero). So
increase eps_addrmap length by one to 31.

Signed-off-by: Vincent Pelletier <plr.vincent@gmail.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: gadger: f_fs: Do not copy past descriptor end.
Vincent Pelletier [Tue, 17 Jan 2017 13:20:11 +0000 (13:20 +0000)]
usb: gadger: f_fs: Do not copy past descriptor end.

Endpoint descriptors come in 2 sizes, struct usb_endpoint_descriptor being
the largest. Use bLength to stop on endpoint descriptor boundary, and not
2 bytes too far.

Signed-off-by: Vincent Pelletier <plr.vincent@gmail.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: phy: fsl: Remove the set_power callback
Baolin Wang [Wed, 18 Jan 2017 12:19:49 +0000 (20:19 +0800)]
usb: phy: fsl: Remove the set_power callback

Since the set_power callback did not do anything for power setting,
then remove it.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: phy: msm: Remove the set_power callback
Baolin Wang [Wed, 18 Jan 2017 12:19:48 +0000 (20:19 +0800)]
usb: phy: msm: Remove the set_power callback

Since it will not set the PMIC current drawn from USB configuration by
set_power callback, then remove it.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: phy: ab8500: Remove the set_power callback
Baolin Wang [Wed, 18 Jan 2017 12:19:47 +0000 (20:19 +0800)]
usb: phy: ab8500: Remove the set_power callback

There are no users will use the vbus_draw variable set by set_power()
callback to set the vbus current. Thus we can remove it.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc2: gadget: Set GDFIFOCFG
Sevak Arakelyan [Thu, 19 Jan 2017 02:34:19 +0000 (18:34 -0800)]
usb: dwc2: gadget: Set GDFIFOCFG

Add programming of GDFIFOCFG register in device mode.
It must contain start address for EP Info block and
total FIFO depth.

Signed-off-by: Sevak Arakelyan <sevaka@synopsys.com>
Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: gadget: uac2: add req_number as parameter
Peter Chen [Wed, 4 Jan 2017 02:19:23 +0000 (10:19 +0800)]
usb: gadget: uac2: add req_number as parameter

There are only two requests for uac2, it may not be enough at high
loading system which usb interrupt handler can't be serviced on
time, then the data will be lost since it is isoc transfer for audio.

In this patch, we introduce a parameter for the number for usb request,
and the user can override it if current number for request is not enough
for his/her use case.

Besides, update this parameter for legacy audio gadget and documentation.

Signed-off-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc2: Fix sizeof in kzalloc
John Youn [Wed, 18 Jan 2017 04:32:41 +0000 (20:32 -0800)]
usb: dwc2: Fix sizeof in kzalloc

Take the sizeof '*req' instead of 'struct dwc2_hsotg_req'.

Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc2: Remove 'return' from void function
John Youn [Wed, 18 Jan 2017 04:32:27 +0000 (20:32 -0800)]
usb: dwc2: Remove 'return' from void function

The function returns void so a return is unnecessary.

Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>