linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Neil Zhang <zhangwm@marvell.com>
To: <balbi@ti.com>, <gregkh@linuxfoundation.org>,
	<linux-usb@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: Neil Zhang <zhangwm@marvell.com>
Subject: [PATCH 5/6] USB: gadget: mv_udc: workaroud for missing dTD
Date: Mon, 24 Feb 2014 16:03:15 +0800	[thread overview]
Message-ID: <1393228996-14787-6-git-send-email-zhangwm@marvell.com> (raw)
In-Reply-To: <1393228996-14787-1-git-send-email-zhangwm@marvell.com>

There is an issue with the add dTD tripwire semaphore (ATDTW bit in
USBCMD register) that can cause the controller to ignore a dTD that is
added to a primed endpoint. When this happens, the software can read
the tripwire bit and the status bit at '1' even though the endpoint
is unprimed.

After executing a dTD, the device controller endpoint state machine
executes a final read of the dTD terminate bit to check if the
application added a dTD to the linked list at the last moment. This read
is done in the finpkt_read_latest_next_td (44) state. After the read is
performed, if the terminate bit is still set, the state machine moves to
unprime the endpoint. The decision to unprime the endpoint is done in
the checkqh_decision (59) state, based on the value of the terminate bit.

Before reaching the checkqh_decision state, the state machine traverses
the writeqhtd_status (57), writeqh_status (56), and release_prime_mask
(42) states. As shown in the waveform, the ep_addtd_tripwire_clr signal
is not set to clear the tripwire bit in these states.

Signed-off-by: Neil Zhang <zhangwm@marvell.com>
---
 drivers/usb/gadget/mv_udc_core.c |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/usb/gadget/mv_udc_core.c b/drivers/usb/gadget/mv_udc_core.c
index a620cff..8df8606 100644
--- a/drivers/usb/gadget/mv_udc_core.c
+++ b/drivers/usb/gadget/mv_udc_core.c
@@ -196,7 +196,27 @@ static int process_ep_req(struct mv_udc *udc, int index,
 			while (readl(&udc->op_regs->epstatus) & bit_pos)
 				udelay(1);
 			break;
+		} else {
+			if (!(readl(&udc->op_regs->epstatus) & bit_pos)) {
+				/* The DMA engine thinks there is no more dTD */
+				curr_dqh->next_dtd_ptr = curr_dtd->dtd_next
+					& EP_QUEUE_HEAD_NEXT_POINTER_MASK;
+
+				/* clear active and halt bit */
+				curr_dqh->size_ioc_int_sts &=
+						~(DTD_STATUS_ACTIVE
+						| DTD_STATUS_HALTED);
+
+				/* Do prime again */
+				wmb();
+				writel(bit_pos, &udc->op_regs->epprime);
+				while (readl(&udc->op_regs->epprime) & bit_pos)
+					cpu_relax();
+
+				break;
+			}
 		}
+
 		udelay(1);
 	}
 
-- 
1.7.9.5


  parent reply	other threads:[~2014-02-24  8:03 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-24  8:03 [PATCH 0/6] bug fix for mv_udc_core.c Neil Zhang
2014-02-24  8:03 ` [PATCH 1/6] usb: gadget: mv_udc: remove redundant pull up in udc_start Neil Zhang
2014-02-24  8:03 ` [PATCH 2/6] usb: gadget: mv_udc: disable HW zlt for ep0 Neil Zhang
2014-02-25  1:18   ` Peter Chen
2014-02-25  4:13     ` Neil Zhang
2014-02-25  5:15       ` Peter Chen
2014-02-25  7:11         ` Neil Zhang
2014-02-25  7:46           ` Peter Chen
2014-02-25 18:12             ` Felipe Balbi
2014-02-26  1:48               ` Neil Zhang
2014-02-26  2:36                 ` Peter Chen
2014-02-26 15:20                   ` Felipe Balbi
2014-02-26 15:23                   ` Felipe Balbi
2014-02-27  3:30                     ` Peter Chen
2014-02-27 16:52                       ` Felipe Balbi
2014-02-27 18:05                       ` Fabio Estevam
2014-02-27 19:04                         ` Felipe Balbi
2014-02-26 15:19                 ` Felipe Balbi
2014-02-27  9:12                   ` Neil Zhang
2014-02-24  8:03 ` [PATCH 3/6] usb: gadget: mv_udc: clear corresponding interrupt when flush fifo Neil Zhang
2014-02-25  1:59   ` Peter Chen
2014-02-25  7:26     ` Neil Zhang
2014-02-24  8:03 ` [PATCH 4/6] usb: gadget: mv_udc: check endpoint before queue dtd Neil Zhang
2014-02-24  8:03 ` Neil Zhang [this message]
2014-02-25  4:19   ` [PATCH 5/6] USB: gadget: mv_udc: workaroud for missing dTD Peter Chen
2014-02-25  7:16     ` Neil Zhang
2014-02-25  7:22       ` Peter Chen
2014-02-24  8:03 ` [PATCH 6/6] USB: gadget: mv_udc: fix corner case for missiong dTD Neil Zhang
2014-02-24 10:31 ` [PATCH 0/6] bug fix for mv_udc_core.c Matthieu CASTET
2014-02-24 12:42   ` Neil Zhang
2014-02-25  4:17     ` Peter Chen
2014-02-25  7:18       ` Neil Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1393228996-14787-6-git-send-email-zhangwm@marvell.com \
    --to=zhangwm@marvell.com \
    --cc=balbi@ti.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).