platform/kernel/linux-starfive.git
6 years agousb: gadget: udc: renesas_usb3: should call pm_runtime_enable() before add udc
Yoshihiro Shimoda [Tue, 10 Apr 2018 05:38:51 +0000 (14:38 +0900)]
usb: gadget: udc: renesas_usb3: should call pm_runtime_enable() before add udc

This patch fixes an issue that this driver causes panic if a gadget
driver is already loaded because usb_add_gadget_udc() might call
renesas_usb3_start() via .udc_start, and then pm_runtime_get_sync()
in renesas_usb3_start() doesn't work correctly.
Note that the usb3_to_dev() macro should not be called at this timing
because the macro uses the gadget structure.

Fixes: cf06df3fae28 ("usb: gadget: udc: renesas_usb3: move pm_runtime_{en,dis}able()")
Cc: <stable@vger.kernel.org> # v4.15+
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: gadget: udc: renesas_usb3: should remove debugfs
Yoshihiro Shimoda [Tue, 10 Apr 2018 05:38:50 +0000 (14:38 +0900)]
usb: gadget: udc: renesas_usb3: should remove debugfs

This patch fixes an issue that this driver doesn't remove its debugfs.

Fixes: 43ba968b00ea ("usb: gadget: udc: renesas_usb3: add debugfs to set the b-device mode")
Cc: <stable@vger.kernel.org> # v4.14+
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: gadget: composite Allow for larger configuration descriptors
Joel Pepper [Thu, 26 Apr 2018 18:26:08 +0000 (20:26 +0200)]
usb: gadget: composite Allow for larger configuration descriptors

The composite framework allows us to create gadgets composed from many
different functions, which need to fit into a single configuration
descriptor.

Some functions (like uvc) can produce configuration descriptors upwards
of 2500 bytes on their own.

This patch increases the limit from 1024 bytes to 4096.

Signed-off-by: Joel Pepper <joel.pepper@rwth-aachen.de>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: Fix list_del corruption in dwc3_ep_dequeue
Mayank Rana [Fri, 23 Mar 2018 17:05:33 +0000 (10:05 -0700)]
usb: dwc3: gadget: Fix list_del corruption in dwc3_ep_dequeue

dwc3_ep_dequeue() waits for completion of End Transfer command using
wait_event_lock_irq(), which will release the dwc3->lock while waiting
and reacquire after completion. This allows a potential race condition
with ep_disable() which also removes all requests from started_list
and pending_list.

The check for NULL r->trb should catch this but currently it exits to
the wrong 'out1' label which calls dwc3_gadget_giveback(). Since its
list entry was already removed, if CONFIG_DEBUG_LIST is enabled a
'list_del corruption' bug is thrown since its next/prev pointers are
already LIST_POISON1/2. If r->trb is NULL it should simply exit to
'out0'.

Fixes: cf3113d893d4 ("usb: dwc3: gadget: properly increment dequeue pointer on ep_dequeue")
Cc: stable@vger.kernel.org # v4.12+
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
Signed-off-by: Jack Pham <jackp@codeaurora.org>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: dwc3_gadget_del_and_unmap_request() can be static
Wei Yongjun [Thu, 29 Mar 2018 02:20:10 +0000 (02:20 +0000)]
usb: dwc3: gadget: dwc3_gadget_del_and_unmap_request() can be static

Fixes the following sparse warning:

drivers/usb/dwc3/gadget.c:169:6: warning:
 symbol 'dwc3_gadget_del_and_unmap_request' was not declared. Should it be static?

Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc2: pci: Fix error return code in dwc2_pci_probe()
Wei Yongjun [Wed, 28 Mar 2018 13:41:13 +0000 (13:41 +0000)]
usb: dwc2: pci: Fix error return code in dwc2_pci_probe()

Fix to return error code -ENOMEM from the alloc fail error handling
case instead of 0, as done elsewhere in this function.

Fixes: ecd29dabb2ba ("usb: dwc2: pci: Handle error cleanup in probe")
Reviewed-by: Grigor Tovmasyan <tovmasya@synopsys.com>
Acked-by: Minas Harutyunyan <hminas@synopsys.com>
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc2: WA for Full speed ISOC IN in DDMA mode.
Artur Petrosyan [Mon, 16 Apr 2018 12:45:31 +0000 (08:45 -0400)]
usb: dwc2: WA for Full speed ISOC IN in DDMA mode.

By clearing NAK status of EP, core will send ZLP
to IN token and assert NAK interrupt relying
on TxFIFO status only.

The WA applies only to core versions from 2.72a
to 4.00a (including both). Also for FS_IOT_1.00a
and HS_IOT_1.00a.

Signed-off-by: Artur Petrosyan <arturp@synopsys.com>
Signed-off-by: Minas Harutyunyan <hminas@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc2: dwc2_vbus_supply_init: fix error check
Tomeu Vizoso [Mon, 26 Mar 2018 09:00:01 +0000 (11:00 +0200)]
usb: dwc2: dwc2_vbus_supply_init: fix error check

devm_regulator_get_optional returns -ENODEV if the regulator isn't
there, so if that's the case we have to make sure not to leave -ENODEV
in the regulator pointer.

Also, make sure we return 0 in that case, but correctly propagate any
other errors. Also propagate the error from _dwc2_hcd_start.

Fixes: 531ef5ebea96 ("usb: dwc2: add support for host mode external vbus supply")
Cc: Amelie Delaunay <amelie.delaunay@st.com>
Reviewed-by: Amelie Delaunay <amelie.delaunay@st.com>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Reviewed-by: Grigor Tovmasyan <tovmasya@synopsys.com>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Acked-by: Minas Harutyunyan <hminas@synopsys.com>
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: gadget: f_phonet: fix pn_net_xmit()'s return type
Luc Van Oostenryck [Tue, 24 Apr 2018 13:18:41 +0000 (15:18 +0200)]
usb: gadget: f_phonet: fix pn_net_xmit()'s return type

The method ndo_start_xmit() is defined as returning an 'netdev_tx_t',
which is a typedef for an enum type, but the implementation in this
driver returns an 'int'.

Fix this by returning 'netdev_tx_t' in this driver too.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc2: Fix HiKey regression caused by power_down feature
John Stultz [Sat, 19 May 2018 00:49:03 +0000 (17:49 -0700)]
usb: dwc2: Fix HiKey regression caused by power_down feature

In 4.17-rc, commit 03ea6d6e9e1f ("usb: dwc2: Enable power down")
caused the HiKey board to not correctly handle switching between
usb-gadget and usb-host mode.

Unplugging the OTG port would result in:
[   42.240973] dwc2 f72c0000.usb: dwc2_restore_host_registers: no host registers to restore
[   42.249066] dwc2 f72c0000.usb: dwc2_host_exit_hibernation: failed to restore host registers

And the USB-host ports would not function.

And plugging in the OTG port, we would see:
[   46.046557] WARNING: CPU: 3 PID: 6 at drivers/usb/dwc2/gadget.c:260 dwc2_hsotg_init_fifo+0x194/0x1a0
[   46.055761] CPU: 3 PID: 6 Comm: kworker/u16:0 Not tainted 4.17.0-rc5-00030-ge67da8c #231
[   46.055767] Hardware name: HiKey Development Board (DT)
[   46.055784] Workqueue: dwc2 dwc2_conn_id_status_change
...

Thus, this patch sets the hisi params to disable the power_down
flag by default, and gets thing working again.

Cc: John Youn <johnyoun@synopsys.com>
Cc: Vardan Mikayelyan <mvardan@synopsys.com>
Cc: Artur Petrosyan <arturp@synopsys.com>
Cc: Grigor Tovmasyan <tovmasya@synopsys.com>
Cc: Felipe Balbi <felipe.balbi@linux.intel.com>
Cc: linux-usb@vger.kernel.org
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc2: Fix kernel doc's warnings.
Grigor Tovmasyan [Wed, 16 May 2018 08:04:24 +0000 (12:04 +0400)]
usb: dwc2: Fix kernel doc's warnings.

Added descriptions for all not described parameters.
Fix all kernel doc's warnings.

Acked-by: Minas Harutyunyan <hminas@synopsys.com>
Signed-off-by: Grigor Tovmasyan <tovmasya@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: gadget: fsl: Introduce FSL_USB2_PHY_UTMI_DUAL for usb gadget
Nikhil Badola [Thu, 17 May 2018 21:28:37 +0000 (18:28 -0300)]
usb: gadget: fsl: Introduce FSL_USB2_PHY_UTMI_DUAL for usb gadget

Introduce FSL_USB2_PHY_UTMI_DUAL in gadget driver for setting
phy in SOCs with utmi dual phy

Acked-by: Li Yang <leoyang.li@nxp.com>
Signed-off-by: Nikhil Badola <nikhil.badola@freescale.com>
Tested-by: Tiago Brusamarello <tbrusa@gmail.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: dwc3_get_extcon() can be static
kbuild test robot [Thu, 17 May 2018 16:06:41 +0000 (00:06 +0800)]
usb: dwc3: dwc3_get_extcon() can be static

Fix sparse warning

Fixes: 5f0b74e54890 ("USB: dwc3: get extcon device by OF graph bindings")
Reviewed-by: Andrzej Hajda <a.hajda@samsung.com>
Signed-off-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: init req->{direction,epnum} from alloc_request()
Felipe Balbi [Mon, 7 May 2018 12:19:31 +0000 (15:19 +0300)]
usb: dwc3: gadget: init req->{direction,epnum} from alloc_request()

We dont' need to touch req->direction or req->epnum from
ep_queue(). It's enough that we initialize both fields from
alloc_request() and just keep them for the entire lifetime of the
request.

No functional changes.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: initialize transfer index from send_gadget_ep_cmd()
Felipe Balbi [Wed, 11 Apr 2018 09:58:46 +0000 (12:58 +0300)]
usb: dwc3: gadget: initialize transfer index from send_gadget_ep_cmd()

Instead of *always* calling dwc3_gadget_ep_get_transfer_index() after
sending a Start Transfer command, we can call it once from
dwc3_send_gadget_ep_cmd() itself.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: assign resource_index inside get_transfer_index()
Felipe Balbi [Wed, 11 Apr 2018 09:56:24 +0000 (12:56 +0300)]
usb: dwc3: gadget: assign resource_index inside get_transfer_index()

Instead of returning resource index number just to assign it to a
field inside 'dep' which was passed as argument, we can assing
dep->resource_index from inside dwc3_gadget_ep_get_transfer_index()
itself.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: always start isochronous aligned to dep->interval
Felipe Balbi [Wed, 11 Apr 2018 07:34:34 +0000 (10:34 +0300)]
usb: dwc3: gadget: always start isochronous aligned to dep->interval

We will *always* start transfer to the next uFrame number aligned to
dep->interval.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: don't issue End Transfer if we have started reqs
Felipe Balbi [Wed, 11 Apr 2018 07:32:52 +0000 (10:32 +0300)]
usb: dwc3: gadget: don't issue End Transfer if we have started reqs

In case we have many started requests and one of them in the middle is
completed with Missed Isoc, let's not End Transfer as that would
result in us loosing (possibly) many more intervals.

Instead, let's allow the controller to go through its list of started
requests.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: debug: decode uFrame from event too
Felipe Balbi [Wed, 11 Apr 2018 07:31:53 +0000 (10:31 +0300)]
usb: dwc3: debug: decode uFrame from event too

XferNotReady and XferInProgress give us the uFrame number we're
currently in. Printing that out on tracepoints may help us find bugs
in transfer scheduling.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: move dwc3_calc_trbs_left() in place of prototype
Felipe Balbi [Mon, 9 Apr 2018 10:01:43 +0000 (13:01 +0300)]
usb: dwc3: gadget: move dwc3_calc_trbs_left() in place of prototype

Avoid a prototype when the function can be defined earlier. No
functional changes, cleanup only.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: move set_xfer_resource() in place of prototype
Felipe Balbi [Mon, 9 Apr 2018 09:49:02 +0000 (12:49 +0300)]
usb: dwc3: gadget: move set_xfer_resource() in place of prototype

Instead of having a prototype for a function that's defined a few
lines down, let's just move definition to the place where prototype
was.

No functional changes, cleanup only.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: remove a few more dwc arguments
Felipe Balbi [Mon, 9 Apr 2018 09:46:47 +0000 (12:46 +0300)]
usb: dwc3: gadget: remove a few more dwc arguments

In a few places, the argument is completely unnecessary. On places
where it's needed, we can get it from dep->dwc.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: combine modify & restore into single argument
Felipe Balbi [Mon, 9 Apr 2018 09:40:48 +0000 (12:40 +0300)]
usb: dwc3: gadget: combine modify & restore into single argument

Those two arguments refer to a single bitfield in the register. In
order to simplify the code, we can combine them into a single argument
and expect caller to pass the correct action argument at all times.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: refactor dwc3_gadget_init_endpoints()
Felipe Balbi [Mon, 9 Apr 2018 08:06:09 +0000 (11:06 +0300)]
usb: dwc3: gadget: refactor dwc3_gadget_init_endpoints()

This just makes it slightly easier to read. No functional changes.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: split dwc3_gadget_ep_cleanup_completed_requests()
Felipe Balbi [Fri, 6 Apr 2018 12:56:35 +0000 (15:56 +0300)]
usb: dwc3: gadget: split dwc3_gadget_ep_cleanup_completed_requests()

No functional changes, it just makes the code slightly easier to read.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: get rid of the length variable
Felipe Balbi [Fri, 6 Apr 2018 12:51:49 +0000 (15:51 +0300)]
usb: dwc3: gadget: get rid of the length variable

Code is just as readable without it.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: reduce scope of ret variable
Felipe Balbi [Fri, 6 Apr 2018 12:50:29 +0000 (15:50 +0300)]
usb: dwc3: gadget: reduce scope of ret variable

We can declare it inside list_for_each_entry_safe() loop and reduce
its scope.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: one declaration per line
Felipe Balbi [Fri, 6 Apr 2018 12:49:49 +0000 (15:49 +0300)]
usb: dwc3: gadget: one declaration per line

Misc cleanup. No functional changes.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: simplify IOC handling
Felipe Balbi [Fri, 6 Apr 2018 12:37:30 +0000 (15:37 +0300)]
usb: dwc3: gadget: simplify IOC handling

We will only have event status of IOC when IOC bit is set in
TRB. There's no need to check both bits.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: simplify short packet event
Felipe Balbi [Fri, 6 Apr 2018 08:04:21 +0000 (11:04 +0300)]
usb: dwc3: gadget: simplify short packet event

We know that only OUT endpoints can trigger SHORT. We also know that
count MUST be > 0 whenever SHORT triggers.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: trace: print out event status too
Felipe Balbi [Fri, 6 Apr 2018 08:03:19 +0000 (11:03 +0300)]
usb: dwc3: trace: print out event status too

This will make it easier to figure out the reason for the event. That
information really helps debugging certain problems.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: simplify unaligned and zlp handling
Felipe Balbi [Thu, 29 Mar 2018 12:30:44 +0000 (15:30 +0300)]
usb: dwc3: gadget: simplify unaligned and zlp handling

We can just call reclaim_trb_linear instead of reimplementing it.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: remove unnecessary 'chain' variable
Felipe Balbi [Thu, 29 Mar 2018 11:49:36 +0000 (14:49 +0300)]
usb: dwc3: gadget: remove unnecessary 'chain' variable

Minor cleanup, no functional changes.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: remove PENDING handling from cleanup_completed
Felipe Balbi [Thu, 29 Mar 2018 11:02:41 +0000 (14:02 +0300)]
usb: dwc3: gadget: remove PENDING handling from cleanup_completed

We are trying to kick transfers on Isochronous endpoints in a more
controlled manner now. And this ended up rendering this piece of code
unnecessary.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: split scatterlist and linear handlers
Felipe Balbi [Thu, 29 Mar 2018 10:32:10 +0000 (13:32 +0300)]
usb: dwc3: gadget: split scatterlist and linear handlers

instead of having one big loop, let's split it down into two smaller
handlers: one for linear buffers and one for scatterlist.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: simplify isoc case on cleanup_completed_requests
Felipe Balbi [Thu, 29 Mar 2018 10:25:40 +0000 (13:25 +0300)]
usb: dwc3: gadget: simplify isoc case on cleanup_completed_requests

Just a minor simplification, no functional changes.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: simplify queueing of isoc transfers
Felipe Balbi [Thu, 29 Mar 2018 10:23:53 +0000 (13:23 +0300)]
usb: dwc3: gadget: simplify queueing of isoc transfers

After all the previous changes, it's now a lot clearer how isoc
transfers should be managed. We don't need to try to End Transfers
from ep_queue since that's already done by cleanup_requests.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: remove duplicated missed isoc handling
Felipe Balbi [Thu, 29 Mar 2018 10:07:16 +0000 (13:07 +0300)]
usb: dwc3: gadget: remove duplicated missed isoc handling

Now, this part of the code is duplicated and brings no extra value to
the driver. Let's remove it.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: check for Missed Isoc from event status
Felipe Balbi [Thu, 29 Mar 2018 09:49:28 +0000 (12:49 +0300)]
usb: dwc3: gadget: check for Missed Isoc from event status

In case we get an event with status set to Missed Isoc, this means we
have missed an isochronous interval and should issue End Transfer
command and wait for the following XferNotReady.

Let's do that early, rather than late.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: remove unnecessary 'ioc' variable
Felipe Balbi [Thu, 29 Mar 2018 09:10:31 +0000 (12:10 +0300)]
usb: dwc3: gadget: remove unnecessary 'ioc' variable

It's only written to, never read. We can remove it now.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: make cleanup_completed_requests() return nothing
Felipe Balbi [Thu, 29 Mar 2018 08:53:40 +0000 (11:53 +0300)]
usb: dwc3: gadget: make cleanup_completed_requests() return nothing

We don't need to return a value anymore here. Let's remove it.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: remove DWC3_EP_BUSY flag
Felipe Balbi [Thu, 29 Mar 2018 08:10:45 +0000 (11:10 +0300)]
usb: dwc3: gadget: remove DWC3_EP_BUSY flag

It has no use anymore.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: start removing BUSY flag
Felipe Balbi [Thu, 29 Mar 2018 08:08:46 +0000 (11:08 +0300)]
usb: dwc3: gadget: start removing BUSY flag

By now, it has the same semantics as DWC3_EP_TRANSFER_STARTED, but
that has a much more descriptive name.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: update dep->frame_number from XferInprogress too
Felipe Balbi [Tue, 27 Mar 2018 08:26:53 +0000 (11:26 +0300)]
usb: dwc3: gadget: update dep->frame_number from XferInprogress too

We will need an up-to-date frame_number from XferInProgress too when
future patches improve our handling of Isoc endpoints.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: always use frame number from XferNotReady
Felipe Balbi [Tue, 27 Mar 2018 08:14:31 +0000 (11:14 +0300)]
usb: dwc3: gadget: always use frame number from XferNotReady

The core requires the extra two bits of information for properly
scheduling Isochronous transfers. This means that we can't rely on
__dwc3_gadget_get_frame(). Let's always cache uFrame number from
XferNotReady instead.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: remove unnecessary 'dwc' parameter
Felipe Balbi [Tue, 27 Mar 2018 07:53:29 +0000 (10:53 +0300)]
usb: dwc3: gadget: remove unnecessary 'dwc' parameter

Endpoint handlers need to know about endpoints, not dwc. If they
really need access to dwc (e.g. for printing error messages) we have a
reference to it tucked inside the endpoint.

This patch has no functional changes, it's simply moving things around.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: move handler closer to calling site
Felipe Balbi [Tue, 27 Mar 2018 07:47:48 +0000 (10:47 +0300)]
usb: dwc3: gadget: move handler closer to calling site

Cleanup only, no functional changes. Just making code easier to
follow.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: rename dwc3_gadget_start_isoc()
Felipe Balbi [Tue, 27 Mar 2018 07:42:59 +0000 (10:42 +0300)]
usb: dwc3: gadget: rename dwc3_gadget_start_isoc()

Cleanup only, no functional changes. This just matches the event name
with its handler.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: remove some pointless checks
Felipe Balbi [Tue, 27 Mar 2018 07:41:39 +0000 (10:41 +0300)]
usb: dwc3: gadget: remove some pointless checks

We *KNOW* which events we enable for which endpoint types and
we *KNOW* when they'll trigger. The endpoint type checks are
pointless.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: remove allocated/queued request tracking
Felipe Balbi [Mon, 26 Mar 2018 13:09:00 +0000 (16:09 +0300)]
usb: dwc3: gadget: remove allocated/queued request tracking

That has never proven useful in any way. Just remove it.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: rename done_trbs and done_reqs
Felipe Balbi [Mon, 26 Mar 2018 12:48:22 +0000 (15:48 +0300)]
usb: dwc3: gadget: rename done_trbs and done_reqs

This patch simply renames two functions to more descriptive names so
that it's easier to understand what they're doing.

Cleanup only, no functional changes.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: don't kick transfer all the time
Felipe Balbi [Mon, 26 Mar 2018 10:32:47 +0000 (13:32 +0300)]
usb: dwc3: gadget: don't kick transfer all the time

Instead of constantly calling kick transfer everything some event
shows up, let's just rely on the fact that we send Update Transfer
every time a new request is queued.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: rename dwc3_endpoint_transfer_complete()
Felipe Balbi [Mon, 26 Mar 2018 10:29:17 +0000 (13:29 +0300)]
usb: dwc3: gadget: rename dwc3_endpoint_transfer_complete()

Now that we're making sure we don't have XferComplete events, we can
rename this function to what it actually handles:
dwc3_gadget_endpoint_transfer_in_progress()

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: XferComplete only for EP0
Felipe Balbi [Mon, 26 Mar 2018 10:26:56 +0000 (13:26 +0300)]
usb: dwc3: gadget: XferComplete only for EP0

XferComplete is enabled only for the default control pipe, let's make
that clear in the code.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: XferNotReady is Isoc-only
Felipe Balbi [Mon, 26 Mar 2018 10:26:00 +0000 (13:26 +0300)]
usb: dwc3: gadget: XferNotReady is Isoc-only

We don't use XferNotReady for anything other than Default Control
Pipe, which is handled in ep0.c, and Isochronous endpoints. Let's make
that clear in the code.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: pre-issue Start Transfer for Interrupt EPs too
Felipe Balbi [Mon, 26 Mar 2018 10:19:43 +0000 (13:19 +0300)]
usb: dwc3: gadget: pre-issue Start Transfer for Interrupt EPs too

Interrupt endpoints behave much like Bulk endpoints with the exception
that they are periodic. We can pre-issue Start Transfer exactly as we
do for Bulk endpoints.

While at that, remove one trailing blank line which is unnecessary.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: Correct the logic for queuing sgs
Anurag Kumar Vulisha [Tue, 27 Mar 2018 11:05:21 +0000 (16:35 +0530)]
usb: dwc3: gadget: Correct the logic for queuing sgs

The present code correctly fetches the req which were previously not
queued from the started_list but fails to continue queuing from the sg
where it previously stopped queuing (because of the unavailable TRB's).
This patch correct's the code to continue queuing from the correct sg
present in the sglist.

For example, consider 5 sgs in req. Because of limited TRB's among the
5 sgs only 3 got queued. This patch corrects the code to start queuing
from correct sg i.e 4th sg when the TRBs are available.

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: gadget: Correct handling of scattergather lists
Anurag Kumar Vulisha [Tue, 27 Mar 2018 11:05:20 +0000 (16:35 +0530)]
usb: dwc3: gadget: Correct handling of scattergather lists

The code logic in dwc3_prepare_one_trb() incorrectly uses the address
and length fields present in req packet for mapping TRB's instead of
using the address and length fields of scattergather lists. This patch
correct's the code to use sg->address and sg->length when scattergather
lists are present.

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agoUSB: dwc3: get extcon device by OF graph bindings
Andrzej Hajda [Tue, 15 May 2018 12:12:38 +0000 (14:12 +0200)]
USB: dwc3: get extcon device by OF graph bindings

extcon device is used to detect host/device connection. Since extcon
OF property is deprecated, alternative method should be added.
This method uses OF graph bindings to locate extcon.

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: support clocks and resets for DWC3 core
Masahiro Yamada [Wed, 16 May 2018 02:41:07 +0000 (11:41 +0900)]
usb: dwc3: support clocks and resets for DWC3 core

Historically, the clocks and resets are handled on the glue layer
side instead of the DWC3 core.  For simple cases, dwc3-of-simple.c
takes care of arbitrary number of clocks and resets.  The DT node
structure typically looks like as follows:

  dwc3-glue {
          compatible = "foo,dwc3";
          clocks = ...;
          resets = ...;
          ...

          dwc3 {
                  compatible = "snps,dwc3";
                  ...
          };
  }

By supporting the clocks and the reset in the dwc3/core.c, it will
be turned into a single node:

  dwc3 {
          compatible = "foo,dwc3", "snps,dwc3";
          clocks = ...;
          resets = ...;
          ...
  }

This commit adds the binding of clocks and resets specific to this IP.
The number of clocks should generally be the same across SoCs, it is
just some SoCs either tie clocks together or do not provide software
control of some of the clocks.

I took the clock names from the Synopsys datasheet: "ref" (ref_clk),
"bus_early" (bus_clk_early), and "suspend" (suspend_clk).

I found only one reset line in the datasheet, hence the reset-names
property is omitted.

Those clocks are required for new platforms.  Enforcing the new
binding breaks existing platforms since they specify clocks (and
resets) in their glue layer node, but nothing in the core node.
I listed such exceptional cases in the DT binding.  The driver
code has been relaxed to accept no clock.  This change is based
on the discussion [1].

I inserted reset_control_deassert() and clk_bulk_enable() before the
first register access, i.e. dwc3_cache_hwparams().

[1] https://patchwork.kernel.org/patch/10284265/

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: gadget: udc: atmel: Fix indenting
Romain Izard [Fri, 11 May 2018 10:19:56 +0000 (12:19 +0200)]
usb: gadget: udc: atmel: Fix indenting

Fix the fallout of the conversion to GPIO descriptors in 3df034081021.

Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: Romain Izard <romain.izard.pro@gmail.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: gadget: udc: atmel: Remove obsolete include
Romain Izard [Fri, 11 May 2018 10:19:55 +0000 (12:19 +0200)]
usb: gadget: udc: atmel: Remove obsolete include

The include defines the private platform_data structure used with AVR
platforms. It has no user since 7c55984e191f. Remove it.

Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: Romain Izard <romain.izard.pro@gmail.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: gadget: udc: atmel: GPIO inversion is handled by gpiod
Romain Izard [Fri, 11 May 2018 10:19:54 +0000 (12:19 +0200)]
usb: gadget: udc: atmel: GPIO inversion is handled by gpiod

When converting to GPIO descriptors, gpiod_get_value automatically
handles the line inversion flags from the device tree.

Do not invert the line twice.

Fixes: 3df034081021 ("usb: gadget: udc: atmel: convert to use GPIO descriptors")
Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: Romain Izard <romain.izard.pro@gmail.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agoUSB: rndis: Fix for handling garbled messages
Michel Pollet [Thu, 10 May 2018 13:09:09 +0000 (14:09 +0100)]
USB: rndis: Fix for handling garbled messages

A message can be forged to crash the stack; here we make sure we don't
completely break the system if this occurs

Signed-off-by: Michel Pollet <michel.pollet@bp.renesas.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: use local copy of resource to fix-up register offset
Masahiro Yamada [Thu, 19 Apr 2018 11:03:37 +0000 (20:03 +0900)]
usb: dwc3: use local copy of resource to fix-up register offset

It is not a good idea to directly modify the resource of a platform
device.  Modify its local copy, and pass it to devm_ioremap_resource()
so that we do not need to restore it in the failure path and the remove
hook.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: gadget: composite: fill bcdUSB as 0x0320 for SuperSpeed or higher speeds
Chunfeng Yun [Wed, 9 May 2018 11:29:16 +0000 (19:29 +0800)]
usb: gadget: composite: fill bcdUSB as 0x0320 for SuperSpeed or higher speeds

The USB3CV version 2.1.80 (March 26, 2018) requires all devices
( gen1, gen2, single lane, dual lane) to return the value of 0x0320
in the bcdUSB field

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: core: Suspend PHYs on runtime suspend in host mode
Manu Gautam [Wed, 9 May 2018 17:39:21 +0000 (23:09 +0530)]
usb: dwc3: core: Suspend PHYs on runtime suspend in host mode

Some PHY drivers (e.g. for Qualcomm QUSB2 and QMP PHYs) support
runtime PM to reduce PHY power consumption during bus_suspend.
Add changes to let core auto-suspend PHYs on host bus-suspend
using GUSB2PHYCFG register if needed for a platform. Also perform
PHYs runtime suspend/resume and let platform glue drivers e.g.
dwc3-qcom handle remote wakeup during bus suspend by waking up
devices on receiving wakeup event from PHY.

Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: Add Qualcomm DWC3 glue driver
Manu Gautam [Wed, 9 May 2018 17:39:20 +0000 (23:09 +0530)]
usb: dwc3: Add Qualcomm DWC3 glue driver

DWC3 controller on Qualcomm SOCs has a Qscratch wrapper.
Some of its uses are described below resulting in need to
have a separate glue driver instead of using dwc3-of-simple:
 - It exposes register interface to override vbus-override
   and lane0-pwr-present signals going to hardware. These
   must be updated in peripheral mode for DWC3 if vbus lines
   are not connected to hardware block. Otherwise RX termination
   in SS mode or DP pull-up is not applied by device controller.
 - pwr_events_irq_stat support to check if USB2 PHY is in L2 state
   before glue driver proceeds with suspend.
 - Support for wakeup interrupts lines that are asserted whenever
   there is any wakeup event on USB3 or USB2 bus.
 - Support to replace pip3 clock going to DWC3 with utmi clock
   for hardware configuration where SSPHY is not used with DWC3.

Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agodt-bindings: usb: Update documentation for Qualcomm DWC3 driver
Manu Gautam [Wed, 9 May 2018 17:39:19 +0000 (23:09 +0530)]
dt-bindings: usb: Update documentation for Qualcomm DWC3 driver

Existing documentation has lot of incorrect information as it
was originally added for a driver that no longer exists.

Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc3: of-simple: Add compatible for Allwinner H6 platform
Icenowy Zheng [Mon, 7 May 2018 15:18:15 +0000 (23:18 +0800)]
usb: dwc3: of-simple: Add compatible for Allwinner H6 platform

Add compatible string to use this generic glue layer to support
Allwinner H6 platform's dwc3 controller.

Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: gadget: f_ecm: fix host mac address for multiple instances
Lukasz Nowak [Sun, 6 May 2018 23:36:45 +0000 (01:36 +0200)]
usb: gadget: f_ecm: fix host mac address for multiple instances

In case there are multiple ecm instances, either for multiple
otg controllers, or multiple virtual links using libcomposite,
each instance needs to have its own host mac address string
value for iMACAddress.

Update the source array (ecm_string_defs), every time before
usb_gstrings_attach(). Without that, all links wrongly were
getting the same, last allocated, host mac address, rather
than the correct one, as requested via configfs.

Signed-off-by: Lukasz Nowak <lukasz.nowak@exablue.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agoUSB: Gadget Ethernet: Re-enable Jumbo frames.
John Greb [Sun, 6 May 2018 20:01:57 +0000 (20:01 +0000)]
USB: Gadget Ethernet: Re-enable Jumbo frames.

Fixes: <b3e3893e1253> ("net: use core MTU range checking")
which patched only one of two functions used to setup the
USB Gadget Ethernet driver, causing a serious performance
regression in the ability to increase mtu size above 1500.

Signed-off-by: John Greb <h3x4m3r0n@gmail.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc2: Change reading of current frame number flow.
Artur Petrosyan [Sat, 5 May 2018 13:46:26 +0000 (09:46 -0400)]
usb: dwc2: Change reading of current frame number flow.

The current frame_number is read from core for both
device and host modes. Reading of the current frame
number needs to be performed ASAP due to IRQ latency's.
This is why, it is moved to common interrupt handler.

Accordingly updated dwc2_gadget_target_frame_elapsed()
function which uses stored frame_number instead of
reading frame number.

In cases when target frame value is incremented
the frame_number is required to read again.

Signed-off-by: Artur Petrosyan <arturp@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc2: debugfs: Don't touch RX FIFO during register dump
Stefan Wahren [Fri, 4 May 2018 18:09:05 +0000 (20:09 +0200)]
usb: dwc2: debugfs: Don't touch RX FIFO during register dump

Dumping the registers via debugfs makes USB on Raspberry Pi completely
unusable. The read of register GRXSTSP ("Receive Status Read and Pop
Register") is responsible for this behaviour, because it pops the RX FIFO.
So avoid this by omitting the relevant register.

CC: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Fixes: 563cf017c443 ("usb: dwc2: debugfs: add support for complete register dump")
Acked-by: Minas Harutyunyan <hminas@synopsys.com>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc2: Fix crash in incomplete isoc intr handlers.
Artur Petrosyan [Sat, 5 May 2018 08:30:16 +0000 (04:30 -0400)]
usb: dwc2: Fix crash in incomplete isoc intr handlers.

Crash caused by going out of "eps_out" array range.
Iteration on "eps_out" changed to less than "num_of_eps".

Signed-off-by: Artur Petrosyan <arturp@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc2: Add Interpacket Gap(IPG) feature support
Grigor Tovmasyan [Sat, 5 May 2018 08:17:58 +0000 (12:17 +0400)]
usb: dwc2: Add Interpacket Gap(IPG) feature support

Added GHWCFG4_IPG_ISOC_SUPPORTED and DCFG_IPG_ISOC_SUPPORDED
bits definitions to enable/disable IPG feature.

Added ipg_isoc_en core parameter which will indicate IPG support
enable/disable and initialize it.

Signed-off-by: Grigor Tovmasyan <tovmasya@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc2: Enable BNA interrupt for IN endpoints
Minas Harutyunyan [Thu, 3 May 2018 13:25:37 +0000 (17:25 +0400)]
usb: dwc2: Enable BNA interrupt for IN endpoints

In DDMA mode required to enable BNA interrupt for
both directions.

Signed-off-by: Minas Harutyunyan <hminas@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: dwc2: Change ISOC DDMA flow
Minas Harutyunyan [Thu, 3 May 2018 13:24:28 +0000 (17:24 +0400)]
usb: dwc2: Change ISOC DDMA flow

Changed existing two descriptor-chain flow to one chain.

In two-chain implementation BNA interrupt used for switching between
two chains. BNA interrupt asserted because of returning to
beginning of the chain based on L-bit of last descriptor.

Because of that we lose packets. This issue resolved by using one
desc-chain.

Removed all staff related to two desc-chain flow from
DDMA ISOC related functions.

Removed request length checking from dwc2_gadget_fill_isoc_desc()
function. Request length checking added to dwc2_hsotg_ep_queue()
function. If request length greater than descriptor limits then
request not added to queue. Additional checking done for High
Bandwidth ISOC OUT's which not supported by driver. In
dwc2_gadget_fill_isoc_desc() function also checked desc-chain
status (full or not) to avoid of reusing not yet processed
descriptors.

In dwc2_gadget_start_isoc_ddma() function creation of desc-chain
always started from descriptor 0. Before filling descriptors, they
were initialized by HOST BUSY status.

In dwc2_gadget_complete_isoc_request_ddma() added checking for
desc-chain rollover. Also added checking completion status.
Request completed successfully if DEV_DMA_STS is DEV_DMA_STS_SUCC,
otherwise complete with actual=0. For systems with high IRQ latency
added pointer compl_desc to next descriptor to be completed by
XferCompl interrupt. This pointer replace descriptor index calculation
based on DxEPDMA register. On descriptor completion interrupt
processing all descriptors starting from compl_desc till descriptor
which Buffer Status field not equal DMA_DONE status.

Actually removed dwc2_gadget_start_next_isoc_ddma() function because
now driver use only one desc-chain and instead that function added
dwc2_gadget_handle_isoc_bna() function for handling BNA interrupts.

Handling BNA interrupt done by flushing TxFIFOs for OUT EPs,
completing request with actual=0 and resetting desc-chain number and
target frame to initial values for restarting transfers.

On handling NAK request completed with actual=0. Incremented target
frame to allow fill desc chain and start transfers.
In DDMA mode avoided of frame number incrementing, because tracking
of frame number performed in dwc2_gadget_fill_isoc_desc() function.

When core assert XferCompl along with BNA, we should ignore XferCompl
in dwc2_hsotg_epint() function.

On BNA interrupt replaced dwc2_gadget_start_next_isoc_ddma() by above
mentioned BNA handler.

In dwc2_hsotg_ep_enable() function added sanity check of bInterval
for ISOC IN in DDMA mode, because HW doesn't supported EP's with
bInterval more than 10 and check for mc for ISOC OUT transfers,
because core doesn't support high bandwidth transfers.

Signed-off-by: Minas Harutyunyan <hminas@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: mtu3: make USB_MTU3_DUAL_ROLE depend on EXTCON but not USB_MTU3
Chunfeng Yun [Tue, 24 Apr 2018 02:52:50 +0000 (10:52 +0800)]
usb: mtu3: make USB_MTU3_DUAL_ROLE depend on EXTCON but not USB_MTU3

In fact the driver depends on EXTCON only when it's configed as
USB_MTU3_DUAL_ROLE, so make USB_MTU3_DUAL_ROLE depend on EXTCON but
not USB_MTU3.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: mtu3: fix operation failure when test TEST_J/K
Chunfeng Yun [Tue, 24 Apr 2018 02:52:49 +0000 (10:52 +0800)]
usb: mtu3: fix operation failure when test TEST_J/K

There is an error dialog popped up in PC when test TEST_J/K
by EHSETT tool, due to not waiting for the completion of
control transfer. Here fix it by entering test mode after
Status Stage finish.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: mtu3: fix an unrecognized issue when connected with PC
Chunfeng Yun [Tue, 24 Apr 2018 02:52:48 +0000 (10:52 +0800)]
usb: mtu3: fix an unrecognized issue when connected with PC

When boot on the platform with the USB cable connected to Win7,
the Win7 will pop up an error dialog: "USB Device not recognized",
but finally the Win7 can enumerate it successfully.
The root cause is as the following:
When the xHCI driver set PORT_POWER of the OTG port, and if both
IDPIN and VBUS_VALID are high at the same time, the MTU3 controller
will set SESSION and pull up DP, so the Win7 can detect existence
of USB device, but if the mtu3 driver can't switch to device mode
during the debounce time, the Win7 can not enumerate it.
Here to fix it by removing the 1s delayed EXTCON register to speed up
mode switch.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: mtu3: remove repeated setting of gadget state
Chunfeng Yun [Tue, 24 Apr 2018 02:52:47 +0000 (10:52 +0800)]
usb: mtu3: remove repeated setting of gadget state

The usb_add_gadget_udc() will set the gadget state as
USB_STATE_NOTATTACHED, so we needn't set it again.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: mtu3: avoid TX data length truncated in SS/SSP mode
Chunfeng Yun [Tue, 24 Apr 2018 02:52:46 +0000 (10:52 +0800)]
usb: mtu3: avoid TX data length truncated in SS/SSP mode

The variable of 'count' is declared as u8, this will cause an issue
due to value truncated when works in SS or SSP mode and data length
is greater than 255, so change it as u32.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: phy: simplify getting .drvdata
Wolfram Sang [Thu, 19 Apr 2018 14:06:26 +0000 (16:06 +0200)]
usb: phy: simplify getting .drvdata

We should get drvdata from struct device directly. Going via
platform_device is an unneeded step back and forth.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: mtu3: simplify getting .drvdata
Wolfram Sang [Thu, 19 Apr 2018 14:06:25 +0000 (16:06 +0200)]
usb: mtu3: simplify getting .drvdata

We should get drvdata from struct device directly. Going via
platform_device is an unneeded step back and forth.

Acked-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: phy: Add Kconfig entry for Tegra PHY driver
Dmitry Osipenko [Mon, 9 Apr 2018 22:02:59 +0000 (01:02 +0300)]
usb: phy: Add Kconfig entry for Tegra PHY driver

Tegra's EHCI driver has a build dependency on Tegra's PHY driver and
currently Tegra's PHY driver is built only when Tegra's EHCI driver is
built. Add own Kconfig entry for the Tegra's PHY driver so that drivers
other than ehci-tegra (like ChipIdea UDC) could work with ehci-tegra
driver being disabled in kernels config by allowing user to manually
select the PHY driver.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: tegra: Move utmi-pads reset from ehci-tegra to tegra-phy
Dmitry Osipenko [Mon, 9 Apr 2018 22:02:58 +0000 (01:02 +0300)]
usb: tegra: Move utmi-pads reset from ehci-tegra to tegra-phy

UTMI pads are shared by USB controllers and reset of UTMI pads is shared
with the reset of USB1 controller. Currently reset of UTMI pads is done by
the EHCI driver and ChipIdea UDC works because EHCI driver always happen
to be probed first. Move reset controls from ehci-tegra to tegra-phy in
order to resolve the problem.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: phy: tegra: Cleanup error messages
Dmitry Osipenko [Mon, 9 Apr 2018 22:02:57 +0000 (01:02 +0300)]
usb: phy: tegra: Cleanup error messages

Tegra's PHY driver has a mix of pr_err() and dev_err(), let's switch to
dev_err() and use common errors message formatting across the driver for
consistency.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: gadget: f_fs: Add compat_ioctl to epfiles
Jerry Zhang [Fri, 30 Mar 2018 22:32:19 +0000 (15:32 -0700)]
usb: gadget: f_fs: Add compat_ioctl to epfiles

This allows 32 bit owners of ffs endpoints to
make ioctls into a 64 bit kernel.

All of the current epfile ioctls can be handled
with the same struct definitions as regular
ioctl.

Acked-by: MichaƂ Nazarewicz <mina86@mina86.com>
Signed-off-by: Jerry Zhang <zhangjerry@google.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: gadget: f_midi: Use refcount when freeing f_midi_opts
Jerry Zhang [Sat, 31 Mar 2018 00:54:24 +0000 (17:54 -0700)]
usb: gadget: f_midi: Use refcount when freeing f_midi_opts

Currently, the midi function is not freed until it is
both removed from the config and released by the user.
Since the user could take a long time to release the
card, it's possible that the function could be unlinked
and thus f_midi_opts would be null when freeing f_midi.

Thus, refcount f_midi_opts and only free it when it is
unlinked and all f_midis have been freed.

Signed-off-by: Jerry Zhang <zhangjerry@google.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb/gadget: Add driver for Aspeed SoC virtual hub
Benjamin Herrenschmidt [Thu, 3 May 2018 20:59:43 +0000 (06:59 +1000)]
usb/gadget: Add driver for Aspeed SoC virtual hub

The Aspeed BMC SoCs support a "virtual hub" function. It provides some
HW support for a top-level USB2 hub behind which sit 5 gadget "ports".

This driver adds support for the full functionality, emulating the
hub standard requests and exposing 5 UDC gadget drivers corresponding
to the ports.

The hub itself has HW provided dedicated EP0 and EP1 (the latter for
hub interrupts). It also has dedicated EP0s for each function. For
other endpoints, there's a pool of 15 "generic" endpoints that are
shared among the ports.

The driver relies on my previous patch adding a "dispose" EP op to
handle EP allocation between ports. EPs are allocated from the shared
pool in the UDC "match_ep" callback and assigned to the UDC instance
(added to the gadget ep_list).

When the composite driver gets unbound, the new hook will allow the UDC
to clean things up and return those EPs to the shared pool.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb/gadget: Constify usb_gadget_get_string "table" argument
Benjamin Herrenschmidt [Thu, 3 May 2018 20:59:42 +0000 (06:59 +1000)]
usb/gadget: Constify usb_gadget_get_string "table" argument

The table is never modified by the function. This allows us
to use it on a statically defined table that is marked const.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agousb: gadget: udc: core: Document the relation between usb_ep_queue() and completion...
Alan Stern [Tue, 27 Mar 2018 14:27:06 +0000 (10:27 -0400)]
usb: gadget: udc: core: Document the relation between usb_ep_queue() and completion callback

Improve the kerneldoc for usb_ep_queue() to note explicitly that the
request's completion routine will be called if and only if the return
value is 0.  The corresponding fact about usb_submit_urb() for the
host-side API has long been documented, and this has always been the
intention for the gadget API.  But until now, documentation seems to
have been lacking.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
6 years agoLinux 4.17-rc2
Linus Torvalds [Mon, 23 Apr 2018 02:20:09 +0000 (19:20 -0700)]
Linux 4.17-rc2

6 years agoMerge tag 'drm-fixes-for-v4.17-rc2' of git://people.freedesktop.org/~airlied/linux
Linus Torvalds [Mon, 23 Apr 2018 00:14:29 +0000 (17:14 -0700)]
Merge tag 'drm-fixes-for-v4.17-rc2' of git://people.freedesktop.org/~airlied/linux

Pull drm fixes from Dave Airlie:
 "Exynos, i915, vc4, amdgpu fixes.

  i915:
   - an oops fix
   - two race fixes
   - some gvt fixes

  amdgpu:
   - dark screen fix
   - clk/voltage fix
   - vega12 smu fix

  vc4:
   - memory leak fix

  exynos just drops some code"

* tag 'drm-fixes-for-v4.17-rc2' of git://people.freedesktop.org/~airlied/linux: (23 commits)
  drm/amd/powerplay: header file interface to SMU update
  drm/amd/pp: Fix bug voltage can't be OD separately on VI
  drm/amd/display: Don't program bypass on linear regamma LUT
  drm/i915: Fix LSPCON TMDS output buffer enabling from low-power state
  drm/i915/audio: Fix audio detection issue on GLK
  drm/i915: Call i915_perf_fini() on init_hw error unwind
  drm/i915/bios: filter out invalid DDC pins from VBT child devices
  drm/i915/pmu: Inspect runtime PM state more carefully while estimating RC6
  drm/i915: Do no use kfree() to free a kmem_cache_alloc() return value
  drm/exynos: exynos_drm_fb -> drm_framebuffer
  drm/exynos: Move dma_addr out of exynos_drm_fb
  drm/exynos: Move GEM BOs to drm_framebuffer
  drm: Fix HDCP downstream dev count read
  drm/vc4: Fix memory leak during BO teardown
  drm/i915/execlists: Clear user-active flag on preemption completion
  drm/i915/gvt: Add drm_format_mod update
  drm/i915/gvt: Disable primary/sprite/cursor plane at virtual display initialization
  drm/i915/gvt: Delete redundant error message in fb_decode.c
  drm/i915/gvt: Cancel dma map when resetting ggtt entries
  drm/i915/gvt: Missed to cancel dma map for ggtt entries
  ...

6 years agoMerge branch 'drm-next-4.17' of git://people.freedesktop.org/~agd5f/linux into drm...
Dave Airlie [Sun, 22 Apr 2018 22:54:06 +0000 (08:54 +1000)]
Merge branch 'drm-next-4.17' of git://people.freedesktop.org/~agd5f/linux into drm-next

- Fix a dark screen issue in DC
- Fix clk/voltage dependency tracking for wattman
- Update SMU interface for vega12

* 'drm-next-4.17' of git://people.freedesktop.org/~agd5f/linux:
  drm/amd/powerplay: header file interface to SMU update
  drm/amd/pp: Fix bug voltage can't be OD separately on VI
  drm/amd/display: Don't program bypass on linear regamma LUT

6 years agoMerge tag 'exynos-drm-fixes-for-v4.17-rc2' of git://git.kernel.org/pub/scm/linux...
Dave Airlie [Sun, 22 Apr 2018 22:53:41 +0000 (08:53 +1000)]
Merge tag 'exynos-drm-fixes-for-v4.17-rc2' of git://git./linux/kernel/git/daeinki/drm-exynos into drm-next

Remove Exynos specific framebuffer structure and
relevant functions.
- it removes exynos_drm_fb structure which is a wrapper of
  drm_framebuffer and unnecessary two exynos specific callback
  functions, exynos_drm_destory() and exynos_drm_fb_create_handle()
  because we can reuse existing drm common callback ones instead.

* tag 'exynos-drm-fixes-for-v4.17-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/daeinki/drm-exynos:
  drm/exynos: exynos_drm_fb -> drm_framebuffer
  drm/exynos: Move dma_addr out of exynos_drm_fb
  drm/exynos: Move GEM BOs to drm_framebuffer
  drm/amdkfd: Deallocate SDMA queues correctly
  drm/amdkfd: Fix scratch memory with HWS enabled

6 years agoMerge tag 'drm-intel-next-fixes-2018-04-19' of git://anongit.freedesktop.org/drm...
Dave Airlie [Sun, 22 Apr 2018 22:53:27 +0000 (08:53 +1000)]
Merge tag 'drm-intel-next-fixes-2018-04-19' of git://anongit.freedesktop.org/drm/drm-intel into drm-next

- Fix for FDO #105549: Avoid OOPS on bad VBT (Jani)
- Fix rare pre-emption race (Chris)
- Fix RC6 race against PM transitions (Tvrtko)

* tag 'drm-intel-next-fixes-2018-04-19' of git://anongit.freedesktop.org/drm/drm-intel:
  drm/i915/audio: Fix audio detection issue on GLK
  drm/i915: Call i915_perf_fini() on init_hw error unwind
  drm/i915/bios: filter out invalid DDC pins from VBT child devices
  drm/i915/pmu: Inspect runtime PM state more carefully while estimating RC6
  drm/i915: Do no use kfree() to free a kmem_cache_alloc() return value
  drm/i915/execlists: Clear user-active flag on preemption completion
  drm/i915/gvt: Add drm_format_mod update
  drm/i915/gvt: Disable primary/sprite/cursor plane at virtual display initialization
  drm/i915/gvt: Delete redundant error message in fb_decode.c
  drm/i915/gvt: Cancel dma map when resetting ggtt entries
  drm/i915/gvt: Missed to cancel dma map for ggtt entries
  drm/i915/gvt: Make MI_USER_INTERRUPT nop in cmd parser
  drm/i915/gvt: Mark expected switch fall-through in handle_g2v_notification
  drm/i915/gvt: throw error on unhandled vfio ioctls

6 years agoMerge tag 'drm-misc-fixes-2018-04-18-1' of git://anongit.freedesktop.org/drm/drm...
Dave Airlie [Sun, 22 Apr 2018 22:52:54 +0000 (08:52 +1000)]
Merge tag 'drm-misc-fixes-2018-04-18-1' of git://anongit.freedesktop.org/drm/drm-misc into drm-next

drm-misc-fixes:

stable: vc4: Fix memory leak during BO teardown (Daniel)
dp: Add i2c retry for LSPCON adapters (Imre)
hdcp: Fix device count mask (Ramalingam)

Cc: Daniel J Blueman <daniel@quora.org
Cc: Imre Deak <imre.deak@intel.com>
Cc: Ramalingam C <ramalingam.c@intel.com>
* tag 'drm-misc-fixes-2018-04-18-1' of git://anongit.freedesktop.org/drm/drm-misc:
  drm/i915: Fix LSPCON TMDS output buffer enabling from low-power state
  drm: Fix HDCP downstream dev count read
  drm/vc4: Fix memory leak during BO teardown

6 years agoMerge tag '4.17-rc1-SMB3-CIFS' of git://git.samba.org/sfrench/cifs-2.6
Linus Torvalds [Sun, 22 Apr 2018 19:13:04 +0000 (12:13 -0700)]
Merge tag '4.17-rc1-SMB3-CIFS' of git://git.samba.org/sfrench/cifs-2.6

Pull cifs fixes from Steve French:
 "Various SMB3/CIFS fixes.

  There are three more security related fixes in progress that are not
  included in this set but they are still being tested and reviewed, so
  sending this unrelated set of smaller fixes now"

* tag '4.17-rc1-SMB3-CIFS' of git://git.samba.org/sfrench/cifs-2.6:
  CIFS: fix typo in cifs_dbg
  cifs: do not allow creating sockets except with SMB1 posix exensions
  cifs: smbd: Dump SMB packet when configured
  cifs: smbd: Check for iov length on sending the last iov
  fs: cifs: Adding new return type vm_fault_t
  cifs: smb2ops: Fix NULL check in smb2_query_symlink