History log of /linux-master/drivers/usb/renesas_usbhs/fifo.h
Revision Date Author Comments
# ea0efd68 18-Jun-2020 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

usb: renesas_usbhs: getting residue from callback_result

This driver assumed that dmaengine_tx_status() could return
the residue even if the transfer was completed. However,
this was not correct usage [1] and this caused to break getting
the residue after the commit 24461d9792c2 ("dmaengine:
virt-dma: Fix access after free in vchan_complete()") actually.
So, this is possible to get wrong received size if the usb
controller gets a short packet. For example, g_zero driver
causes "bad OUT byte" errors.

The usb-dmac driver will support the callback_result, so this
driver can use it to get residue correctly. Note that even if
the usb-dmac driver has not supported the callback_result yet,
this patch doesn't cause any side-effects.

[1]
https://lore.kernel.org/dmaengine/20200616165550.GP2324254@vkoul-mobl/

Reported-by: Hien Dang <hien.dang.eb@renesas.com>
Fixes: 24461d9792c2 ("dmaengine: virt-dma: Fix access after free in vchan_complete()")
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Link: https://lore.kernel.org/r/1592482277-19563-1-git-send-email-yoshihiro.shimoda.uh@renesas.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 7edd9cba 19-Apr-2020 Nishad Kamdar <nishadkamdar@gmail.com>

usb: renesas_usbhs: Use the correct style for SPDX License Identifier

This patch corrects the SPDX License Identifier style in
header files related to Renesas USBHS Controller Drivers.
For C header files Documentation/process/license-rules.rst
mandates C-like comments (opposed to C source files where
C++ style should be used).

Changes made by using a script provided by Joe Perches here:
https://lkml.org/lkml/2019/2/7/46.

Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Suggested-by: Joe Perches <joe@perches.com>
Signed-off-by: Nishad Kamdar <nishadkamdar@gmail.com>
Signed-off-by: Felipe Balbi <balbi@kernel.org>


# d28e6171 19-Apr-2020 Nishad Kamdar <nishadkamdar@gmail.com>

usb: renesas_usbhs: Use the correct style for SPDX License Identifier

This patch corrects the SPDX License Identifier style in
header files related to Renesas USBHS Controller Drivers.
For C header files Documentation/process/license-rules.rst
mandates C-like comments (opposed to C source files where
C++ style should be used).

Changes made by using a script provided by Joe Perches here:
https://lkml.org/lkml/2019/2/7/46.

Suggested-by: Joe Perches <joe@perches.com>
Signed-off-by: Nishad Kamdar <nishadkamdar@gmail.com>
Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Link: https://lore.kernel.org/r/20200419125705.GA5172@nishad
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 4d599cd3 01-Oct-2019 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

usb: renesas_usbhs: gadget: Fix usb_ep_set_{halt,wedge}() behavior

According to usb_ep_set_halt()'s description,
__usbhsg_ep_set_halt_wedge() should return -EAGAIN if the IN endpoint
has any queue or data. Otherwise, this driver is possible to cause
just STALL without sending a short packet data on g_mass_storage driver,
and then a few resetting a device happens on a host side during
a usb enumaration.

Fixes: 2f98382dcdfe ("usb: renesas_usbhs: Add Renesas USBHS Gadget")
Cc: <stable@vger.kernel.org> # v3.0+
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Link: https://lore.kernel.org/r/1569924633-322-3-git-send-email-yoshihiro.shimoda.uh@renesas.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 1250413a 06-Nov-2017 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

USB: renesas_usbhs: Remove redundant license text

Now that the SPDX tag is in all USB files, that identifies the license
in a specific and legally-defined manner. So the extra GPL text wording
can be removed as it is no longer needed at all.

This is done on a quest to remove the 700+ different ways that files in
the kernel describe the GPL license text. And there's unneeded stuff
like the address (sometimes incorrect) for the FSF which is never
needed.

No copyright headers or other non-license-description text was removed.

Cc: Rob Herring <robh@kernel.org>
Cc: Simon Horman <horms+renesas@verge.net.au>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Chanwoo Choi <cw00.choi@samsung.com>
Cc: Johan Hovold <johan@kernel.org>
Cc: Kazuya Mizuguchi <kazuya.mizuguchi.ks@renesas.com>
Cc: Bhumika Goyal <bhumirks@gmail.com>
Acked-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Acked-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 5fd54ace 03-Nov-2017 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

USB: add SPDX identifiers to all remaining files in drivers/usb/

It's good to have SPDX identifiers in all files to make it easier to
audit the kernel tree for correct licenses.

Update the drivers/usb/ and include/linux/usb* files with the correct
SPDX license identifier based on the license text in the file itself.
The SPDX identifier is a legally binding shorthand, which can be used
instead of the full boiler plate text.

This work is based on a script and data from Thomas Gleixner, Philippe
Ombredanne, and Kate Stewart.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Kate Stewart <kstewart@linuxfoundation.org>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Acked-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# fcb42e23 27-Dec-2015 Julia Lawall <Julia.Lawall@lip6.fr>

usb: renesas_usbhs: constify usbhs_pkt_handle structures

The usbhs_pkt_handle structures are never modified, so declare them as
const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Acked-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 2d9c7f3c 13-Apr-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: tidyup usbhs_for_each_dfifo macro

Current usbhs_for_each_dfifo macro will read out-of-array's
memory after last loop operation.
It was not good C language operation, and the binary which was
compiled by (at least) gcc 4.8.1 is broken.

This patch is based on
925403f425a4a9c503f2fc295652647b1eb10d82
(usb: renesas_usbhs: tidyup original usbhsx_for_each_xxx macro)

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# ab330cf3 12-Mar-2015 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

usb: renesas_usbhs: add support for USB-DMAC

Some Renesas SoCs have the USB-DMAC. It is able to terminate transfers
when a short packet is received, even if less bytes than the transfer
counter size have been received. Also, it is able to send a short
packet even if the packet size is not multiples of 8bytes.

Since the previous code has used the interruption of USBHS controller
when receiving packets even if this driver has used a dmac, a lot of
interruptions has happened. This patch will reduce such interruptions.

This patch allows to use the USB-DMAC on R-Car H2 and M2.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# d3cf6a4b 10-Nov-2014 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

usb: renesas_usbhs: expand USB-DMAC channels for R-Car Gen2

This patch expands USB-DMAC channels for R-Car Gen2 SoCs. The SoCs
have 4 channels. If d{2,3}_{t,x}x_id are not set, this driver never
uses the expanded USB-DMAC channels.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# 3a2634a5 10-Nov-2014 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

usb: renesas_usbhs: standardize d{0,1}fifo control

To expand DnFIFOs in the future, this patch standardizes the d{0,1}fifo
control using new macros.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# c907e423 10-Nov-2014 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

usb: renesas_usbhs: change d{0,1}fifo to dfifo array

To extend DnFIFOs in the future, this patch changes d{0,1}fifo of
usbhs_fifo_info to dfifo array.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# cdeb7943 03-Nov-2014 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

usb: renesas_usbhs: fix usbhs_pipe_clear() for DCP PIPE

Since the DCPCTR doesn't have the ACLRM bit, the usbus_pipe_clear()
should not call the usbhsp_pipectrl_set() with ACLRM.
So, this patch fixes this issue to add the usbhs_fifo_clear_dcp()
in fifo.c because the controller needs the CFIFO to clear the
the DCP PIPE.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# 40b8156f 14-Mar-2013 Felipe Balbi <balbi@ti.com>

usb: renesas: remove unused DMA_ADDR_INVALID

DMA_ADDR_INVALID isn't used anymore, it's safe
to remove it.

Signed-off-by: Felipe Balbi <balbi@ti.com>


# 6e4b74e4 14-Feb-2012 Guennadi Liakhovetski <g.liakhovetski@gmx.de>

usb: renesas: fix scheduling in atomic context bug

The current renesas_usbhs driver triggers

BUG: scheduling while atomic: ksoftirqd/0/3/0x00000102

with enabled CONFIG_DEBUG_ATOMIC_SLEEP, by submitting DMA transfers from
an atomic (tasklet) context, which is not supported by the shdma dmaengine
driver. Fix it by switching to a work.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# 3edeee38 08-Dec-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: care pipe sequence

driver has to re-use the limited pipe for each device/endpoint
when it is USB host hub mode, since number of pipe has limitation.

Then, each pipe should care own pipe sequence for next packet.
This patch adds sequence control.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# 9e74d601 10-Oct-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: gadget: renesas_usbhs: add data/status stage handler

mod_host needs data/status stage handler

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# b331872b 10-Oct-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: gadget: renesas_usbhs: move done callback to struct usbhs_pkt

transfer done function was registered in struct struct usbhs_pipe_info.
It was good for mod_gadget, but not good for mod_host.
This function move it to struct usbhs_pkt.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# 0c6ef985 10-Oct-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: gadget: renesas_usbhs: struct usbhs_pipe hold handler

packet handler had moved to struct usbhs_pipe from struct usbhsg_uep.
it is preparation of mod_host support

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# 51b8a021 10-Oct-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: gadget: renesas_usbhs: move USBHSF_PKT_xxx to pipe.c

There is no longer necessity that USBHSF_PKT_xxx are in fifo.h.
it are used in only fifo.c now.
This patch move it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>


# e73a9891 05-Jun-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: add DMAEngine support

USB DMA was installed on "normal DMAC" when SH7724 or older SuperH,
but the "USB-DMAC" was prepared on recent SuperH.
These 2 DMAC have a little bit different behavior.

This patch add DMAEngine code for "normal DMAC",
but it is still using PIO fifo.
The DMA fifo will be formally supported in the future.

You can enable DMA fifo by local fixup
usbhs_fifo_pio_push_handler -> usbhs_fifo_dma_push_handler
usbhs_fifo_pio_pop_handler -> usbhs_fifo_dma_pop_handler
on usbhsg_ep_enable.

This DMAEngine was tested by g_file_storage on SH7724 Ecovec board

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 0cb7e61d 05-Jun-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: tidyup pio handler name

This patch tidyup PIO packet handler name.
This is a preparation for DMAEngine support

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# d77e3f4e 05-Jun-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: add pipe/fifo link

renesas_usbhs has CFIFO which is for PIO transfer,
and D0FIFO/D1FIFO which are for DMA transfer.
The pipe selects one of these fifo when it send/recv data.
But fifo must not be selected to different pipe in same time.
This patch add pipe/fifo link for each other,
and fifo is not selected by another pipe until it is unselected.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# d3af90a5 05-Jun-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: add usbhsf_fifo

renesas_usbhs has CFIFO/D0FIFO/D1FIFO.
But current renesas_usbhs is using CFIFO (for PIO) only for now.
The fifo selection method is needed for DMAEngine support.
This is a preparation for DMAEngine support

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 97664a20 05-Jun-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: shrink spin lock area

spin lock was very effective while doing 1 packet send/recv on
current renesas_usbhs driver.
But this lock is enough only
- modify packet/pipe link
- modify interrpt mask
- modify fifo access
This patch shrink spin lock area

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# dad67397 05-Jun-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: modify data transfer interrupt

On current driver, overall data transfer method was implemented in fifo.c,
but its interrupt which is member of packet queue control
was still in mod_gadget.c.
This patch move it into fifo.c.
By this patch, the packet/fifo control is independent from mod_gadget.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 659d4954 05-Jun-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: modify data transfer method

On current driver, main data transfer function was implemented in fifo.c,
but the overall controlling was implementing in mod_gadget.c.
This style is not useful to support host and DMAEngine in the future.

But the interrupt for data transfer cannot separate easily for now,
because it is deeply related to mod_gadget.

This patch move the overall data transfer method
into fifo.c except interrupt.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 6acb95d4 05-Jun-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: modify packet queue control method

Current renesas_usbhs driver is controlling packet queue on mod_gadget.c.
But it has relationship with pipe/fifo, not host/gadget.
So, controlling USB packet queue in pipe.c/fifo.c is
more convenient than in mod_gadget.c.
This patch modify it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 4bd04811 05-Jun-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: divide data transfer functions

DMAEngine will be supported to this driver in the future.
Then, both PIO and DMA data transfer method should be supported.
But, the transfer function can returns the result immediately
in PIO version, but it can't in DMA version.
This patch divides data transfer functions into top/bottom half
in preparation for DMAEngine support.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# e8d548d5 05-Jun-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

usb: renesas_usbhs: fifo became independent from pipe.

Current renesas_usbhs has PIO data transfer mode which controls CFIFO.
And it was implemented in pipe.c.
But, fifo control method needs more flexible implementation
to support DMAEngine.
This patch create fifo.c, and it became independent from pipe.c.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>