Skip to content

Commit

Permalink
usb: chipidea: need to mask when writting endptflush and endptprime
Browse files Browse the repository at this point in the history
ENDPTFLUSH and ENDPTPRIME registers are set by software and clear
by hardware. There is a bit for each endpoint. When we are setting
a bit for an endpoint we should make sure we do not touch other
endpoint bit. There is a race condition if the hardware clear the
bit between the read and the write in hw_write.

Cc: stable <stable@vger.kernel.org> # 3.11+
Signed-off-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Matthieu CASTET <matthieu.castet@parrot.com>
Tested-by: Michael Grzeschik <mgrzeschik@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Matthieu CASTET authored and Greg Kroah-Hartman committed Feb 21, 2014
1 parent 0fd7a82 commit 5bf5dbe
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/usb/chipidea/udc.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ static int hw_ep_flush(struct ci_hdrc *ci, int num, int dir)

do {
/* flush any pending transfer */
hw_write(ci, OP_ENDPTFLUSH, BIT(n), BIT(n));
hw_write(ci, OP_ENDPTFLUSH, ~0, BIT(n));
while (hw_read(ci, OP_ENDPTFLUSH, BIT(n)))
cpu_relax();
} while (hw_read(ci, OP_ENDPTSTAT, BIT(n)));
Expand Down Expand Up @@ -205,7 +205,7 @@ static int hw_ep_prime(struct ci_hdrc *ci, int num, int dir, int is_ctrl)
if (is_ctrl && dir == RX && hw_read(ci, OP_ENDPTSETUPSTAT, BIT(num)))
return -EAGAIN;

hw_write(ci, OP_ENDPTPRIME, BIT(n), BIT(n));
hw_write(ci, OP_ENDPTPRIME, ~0, BIT(n));

while (hw_read(ci, OP_ENDPTPRIME, BIT(n)))
cpu_relax();
Expand Down

0 comments on commit 5bf5dbe

Please sign in to comment.