Commit 69974963 authored by Yoshihiro Shimoda's avatar Yoshihiro Shimoda Committed by Sasha Levin

usb: renesas_usbhs: protect the CFIFOSEL setting in usbhsg_ep_enable()

[ Upstream commit 15e4292a ]

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: 97664a20 ("usb: renesas_usbhs: shrink spin lock area")
Cc: <stable@vger.kernel.org> # v3.1+
Signed-off-by: default avatarYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: default avatarSasha Levin <alexander.levin@verizon.com>
parent 83335cb7
...@@ -582,6 +582,9 @@ static int usbhsg_ep_enable(struct usb_ep *ep, ...@@ -582,6 +582,9 @@ static int usbhsg_ep_enable(struct usb_ep *ep,
struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv); struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv);
struct usbhs_pipe *pipe; struct usbhs_pipe *pipe;
int ret = -EIO; int ret = -EIO;
unsigned long flags;
usbhs_lock(priv, flags);
/* /*
* if it already have pipe, * if it already have pipe,
...@@ -590,7 +593,8 @@ static int usbhsg_ep_enable(struct usb_ep *ep, ...@@ -590,7 +593,8 @@ static int usbhsg_ep_enable(struct usb_ep *ep,
if (uep->pipe) { if (uep->pipe) {
usbhs_pipe_clear(uep->pipe); usbhs_pipe_clear(uep->pipe);
usbhs_pipe_sequence_data0(uep->pipe); usbhs_pipe_sequence_data0(uep->pipe);
return 0; ret = 0;
goto usbhsg_ep_enable_end;
} }
pipe = usbhs_pipe_malloc(priv, pipe = usbhs_pipe_malloc(priv,
...@@ -618,6 +622,9 @@ static int usbhsg_ep_enable(struct usb_ep *ep, ...@@ -618,6 +622,9 @@ static int usbhsg_ep_enable(struct usb_ep *ep,
ret = 0; ret = 0;
} }
usbhsg_ep_enable_end:
usbhs_unlock(priv, flags);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment