usb: renesas_usbhs: protect the CFIFOSEL setting in usbhsg_ep_enable()
authorYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Wed, 8 Jun 2016 07:32:50 +0000 (16:32 +0900)
committerSasha Levin <alexander.levin@verizon.com>
Tue, 16 Aug 2016 12:25:08 +0000 (08:25 -0400)
commit6997496351500fd6fb92f11e89e5024d8bd3f55e
treeffd04169ebdd8527b19f1eb79925942e50c9c80a
parent83335cb773c6ee89b8517bf7c16e4c299a1c80f2
usb: renesas_usbhs: protect the CFIFOSEL setting in usbhsg_ep_enable()

[ Upstream commit 15e4292a2d21e9997fdb2b8c014cc461b3f268f0 ]

This patch fixes an issue that the CFIFOSEL register value is possible
to be changed by usbhsg_ep_enable() wrongly. And then, a data transfer
using CFIFO may not work correctly.

For example:
 # modprobe g_multi file=usb-storage.bin
 # ifconfig usb0 192.168.1.1 up
 (During the USB host is sending file to the mass storage)
 # ifconfig usb0 down

In this case, since the u_ether.c may call usb_ep_enable() in
eth_stop(), if the renesas_usbhs driver is also using CFIFO for
mass storage, the mass storage may not work correctly.

So, this patch adds usbhs_lock() and usbhs_unlock() calling in
usbhsg_ep_enable() to protect CFIFOSEL register. This is because:
 - CFIFOSEL.CURPIPE = 0 is also needed for the pipe configuration
 - The CFIFOSEL (fifo->sel) is already protected by usbhs_lock()

Fixes: 97664a207bc2 ("usb: renesas_usbhs: shrink spin lock area")
Cc: <stable@vger.kernel.org> # v3.1+
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
drivers/usb/renesas_usbhs/mod_gadget.c