From patchwork Wed Nov 11 18:33:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 7597191 Return-Path: X-Original-To: patchwork-linux-rockchip@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4AD4F9F2E9 for ; Wed, 11 Nov 2015 18:34:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 676D7206DB for ; Wed, 11 Nov 2015 18:34:28 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 45E2520717 for ; Wed, 11 Nov 2015 18:34:27 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZwaDy-0003wn-KB; Wed, 11 Nov 2015 18:34:26 +0000 Received: from mail-pa0-x22a.google.com ([2607:f8b0:400e:c03::22a]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZwaDx-0003tO-Bn for linux-rockchip@lists.infradead.org; Wed, 11 Nov 2015 18:34:26 +0000 Received: by pasz6 with SMTP id z6so39200563pas.2 for ; Wed, 11 Nov 2015 10:34:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; bh=OmKbL7Xej4yei7ZTtePXpXHqZPStvmksp2VRqnugIkY=; b=O9vZb/hoJ4y+0goqZSAYtiNMF3vB8jCFBCKzQF/DGv+w0E8kCEkRl2ykLJ1WarevQO XGhIiapUTlcpzzshGAkXYrmUI6n95zqcevaCKAbbgNDFT2ArAmPALU4Lz0Tg5pxVhC9t a3kHvwl8woAhLA73276o98rlC08rP2+0VlbfU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-type:content-transfer-encoding; bh=OmKbL7Xej4yei7ZTtePXpXHqZPStvmksp2VRqnugIkY=; b=nNuRfLbUAKsGhJltTIwGNITku+tYFkD+GTK6KU/aJ+bARh45Nh/vXouqo0PhiJr9qQ hvo974cnnsP4z46MUKWinT66iaR+60QjxM7vuuHYBcR3juwDOfYH5SPsUUQoU3NWLjcR aRoTsBXZEx0HMcGDUkcUdaoZzCO/bccZ5XjZc4sJKur+VlyhVSIlUA+xG3sGFA+pG0dM qcHRyT9FHhdXpxDm1iA2YRK/kUBpsmTrhHVn5n8qgNdD20HKoAqKUTDNWaHnky6eEV3n o0+LsD+rTwq8YHeaYf4Sn8GhZ8VONYjLDuKmmKdnoC4zVAm06kgOPu3hYxn7RRDD7NqS TOWQ== X-Gm-Message-State: ALoCoQmLrQVpQUb6owiE7kFgW9+LqgQI9iZ4mjC782oZUMQR8gjqx/MKzNkdUDgiSCG/Bn+wqSJT X-Received: by 10.68.215.67 with SMTP id og3mr16566793pbc.30.1447266844961; Wed, 11 Nov 2015 10:34:04 -0800 (PST) Received: from tictac.mtv.corp.google.com ([172.22.65.76]) by smtp.gmail.com with ESMTPSA id dd4sm10571219pbb.52.2015.11.11.10.34.04 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Nov 2015 10:34:04 -0800 (PST) From: Douglas Anderson To: John Youn , balbi@ti.com Subject: [REPOST PATCH] usb: dwc2: host: Support immediate retries for split transactions Date: Wed, 11 Nov 2015 10:33:52 -0800 Message-Id: <1447266833-32096-1-git-send-email-dianders@chromium.org> X-Mailer: git-send-email 2.6.0.rc2.230.g3dd15c0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151111_103425_532117_D73E977C X-CRM114-Status: GOOD ( 11.86 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: gregory.herrero@intel.com, =?UTF-8?q?Heiko=20St=C3=BCbner?= , johnyoun@synopsys.com, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, Douglas Anderson , linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, yousaf.kaukab@intel.com, Yunzhi Li , Julius Werner , dinguyen@opensource.altera.com Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In some cases, like when you've got a "Microsoft Wireless Keyboard 2000" connected to dwc2 with a hub, expected that we'll get some transfer errors sometimes. The controller is expected to try at least 3 times before giving up. See figure "Figure A-67. Normal HS CSPLIT 3 Strikes Smash" in the USB spec. The dwc2 controller has a way to support this by using the "EC_MC" field. The Raspberry Pi driver has logic for setting this right. See fiq_fsm_queue_split_transaction() in their "dwc_otg_hcd.c". Let's use the same logic. After making this change, we no longer get dropped characters from the above mentioned keyboard. Other devices on the same bus as the keyboard also behave more properly. Thanks for Julius Werner for the expert analysis and suggestions. Signed-off-by: Douglas Anderson Acked-by: John Youn --- Repost without the WIP in tags (sorry for that). drivers/usb/dwc2/core.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c index ef73e498e98f..dcb4cd1d3b34 100644 --- a/drivers/usb/dwc2/core.c +++ b/drivers/usb/dwc2/core.c @@ -1707,6 +1707,7 @@ void dwc2_hc_start_transfer(struct dwc2_hsotg *hsotg, u32 hcchar; u32 hctsiz = 0; u16 num_packets; + u32 ec_mc; if (dbg_hc(chan)) dev_vdbg(hsotg->dev, "%s()\n", __func__); @@ -1743,6 +1744,13 @@ void dwc2_hc_start_transfer(struct dwc2_hsotg *hsotg, hctsiz |= chan->xfer_len << TSIZ_XFERSIZE_SHIFT & TSIZ_XFERSIZE_MASK; + + /* For split set ec_mc for immediate retries */ + if (chan->ep_type == USB_ENDPOINT_XFER_INT || + chan->ep_type == USB_ENDPOINT_XFER_ISOC) + ec_mc = 3; + else + ec_mc = 1; } else { if (dbg_hc(chan)) dev_vdbg(hsotg->dev, "no split\n"); @@ -1805,6 +1813,9 @@ void dwc2_hc_start_transfer(struct dwc2_hsotg *hsotg, hctsiz |= chan->xfer_len << TSIZ_XFERSIZE_SHIFT & TSIZ_XFERSIZE_MASK; + + /* The ec_mc gets the multi_count for non-split */ + ec_mc = chan->multi_count; } chan->start_pkt_count = num_packets; @@ -1855,8 +1866,7 @@ void dwc2_hc_start_transfer(struct dwc2_hsotg *hsotg, hcchar = dwc2_readl(hsotg->regs + HCCHAR(chan->hc_num)); hcchar &= ~HCCHAR_MULTICNT_MASK; - hcchar |= chan->multi_count << HCCHAR_MULTICNT_SHIFT & - HCCHAR_MULTICNT_MASK; + hcchar |= (ec_mc << HCCHAR_MULTICNT_SHIFT) & HCCHAR_MULTICNT_MASK; dwc2_hc_set_even_odd_frame(hsotg, chan, &hcchar); if (hcchar & HCCHAR_CHDIS)