From patchwork Fri Oct 31 04:20:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 5202061 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 399C29F318 for ; Fri, 31 Oct 2014 04:20:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 614AC20176 for ; Fri, 31 Oct 2014 04:20:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7F46420172 for ; Fri, 31 Oct 2014 04:20:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751805AbaJaEUb (ORCPT ); Fri, 31 Oct 2014 00:20:31 -0400 Received: from relmlor2.renesas.com ([210.160.252.172]:26939 "EHLO relmlie1.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751746AbaJaEUb (ORCPT ); Fri, 31 Oct 2014 00:20:31 -0400 Received: from unknown (HELO relmlir3.idc.renesas.com) ([10.200.68.153]) by relmlie1.idc.renesas.com with ESMTP; 31 Oct 2014 13:20:30 +0900 Received: from relmlac3.idc.renesas.com (relmlac3.idc.renesas.com [10.200.69.23]) by relmlir3.idc.renesas.com (Postfix) with ESMTP id 4B8593BC9E; Fri, 31 Oct 2014 13:20:30 +0900 (JST) Received: by relmlac3.idc.renesas.com (Postfix, from userid 0) id 412931800A; Fri, 31 Oct 2014 13:20:30 +0900 (JST) Received: from relmlac3.idc.renesas.com (localhost [127.0.0.1]) by relmlac3.idc.renesas.com (Postfix) with ESMTP id 3F99418070; Fri, 31 Oct 2014 13:20:30 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac3.idc.renesas.com with ESMTP id PAB04702; Fri, 31 Oct 2014 13:20:30 +0900 X-IronPort-AV: E=Sophos;i="5.07,292,1413212400"; d="scan'208";a="172720784" Received: from mail-hk1lp0118.outbound.protection.outlook.com (HELO APAC01-HK1-obe.outbound.protection.outlook.com) ([207.46.51.118]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA; 31 Oct 2014 13:20:29 +0900 Received: from localhost (211.11.155.147) by SINPR06MB331.apcprd06.prod.outlook.com (10.141.110.17) with Microsoft SMTP Server (TLS) id 15.1.6.9; Fri, 31 Oct 2014 04:20:28 +0000 From: Yoshihiro Shimoda To: , CC: , , Yoshihiro Shimoda Subject: [PATCH v5 3/4] usb: renesas_usbhs: fix the timing of dcp_control_transfer_done Date: Fri, 31 Oct 2014 13:20:10 +0900 Message-ID: <1414729211-3276-4-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 1.9.4.msysgit.1 In-Reply-To: <1414729211-3276-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> References: <1414729211-3276-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> MIME-Version: 1.0 X-Originating-IP: [211.11.155.147] X-ClientProxiedBy: SG2PR03CA0038.apcprd03.prod.outlook.com (25.160.233.48) To SINPR06MB331.apcprd06.prod.outlook.com (10.141.110.17) X-MS-Exchange-Transport-FromEntityHeader: Hosted X-Microsoft-Antispam: UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:SINPR06MB331; X-Forefront-PRVS: 03818C953D X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(6069001)(189002)(199003)(19580405001)(20776003)(50466002)(48376002)(46102003)(575784001)(92726001)(19580395003)(93916002)(78352002)(92566001)(4396001)(102836001)(31966008)(104166001)(76506005)(87976001)(97736003)(33646002)(80022003)(50226001)(64706001)(217423001)(42186005)(77096002)(88136002)(76176999)(50986999)(21056001)(62966002)(66066001)(120916001)(107046002)(99396003)(105586002)(95666004)(106356001)(122386002)(42382002)(36756003)(40100003)(101416001)(87286001)(47776003)(89996001)(229853001)(76482002)(77156001)(85306004)(85852003)(88662002); DIR:OUT; SFP:1102; SCL:1; SRVR:SINPR06MB331; H:localhost; FPR:; MLV:sfv; PTR:InfoNoRecords; MX:0; A:0; LANG:en; X-OriginatorOrg: renesas.com Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 According to the datasheet, this driver should clear the INTSTS0.CTRT bit before this controller detects the next stage transition. Otherwise, the driver may not be able to clear the bit after the controller went to the next stage transition. After that, the driver will not be able to clear the INTSTS0.VALID, and a usb control transfer will not finish finally. If we use the testusb tool, it is easy to reproduce this issue: # testusb -a -t 10 Since the previous code handled a data stage and a status stage in the usbhsf_pio_try_push(), it may not clear the INTSTS0.CTRT at the right timing. So, this patch change the timing of usbhs_dcp_control_transfer_done() to the usbhsg_irq_ctrl_stage(). Signed-off-by: Yoshihiro Shimoda --- drivers/usb/renesas_usbhs/fifo.c | 16 ---------------- drivers/usb/renesas_usbhs/mod_gadget.c | 3 +++ 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c index b0c97a3..0e07925 100644 --- a/drivers/usb/renesas_usbhs/fifo.c +++ b/drivers/usb/renesas_usbhs/fifo.c @@ -577,14 +577,6 @@ static int usbhsf_pio_try_push(struct usbhs_pkt *pkt, int *is_done) usbhs_pipe_number(pipe), pkt->length, pkt->actual, *is_done, pkt->zero); - /* - * Transmission end - */ - if (*is_done) { - if (usbhs_pipe_is_dcp(pipe)) - usbhs_dcp_control_transfer_done(pipe); - } - usbhsf_fifo_unselect(pipe, fifo); return 0; @@ -722,14 +714,6 @@ usbhs_fifo_read_end: usbhs_pipe_number(pipe), pkt->length, pkt->actual, *is_done, pkt->zero); - /* - * Transmission end - */ - if (*is_done) { - if (usbhs_pipe_is_dcp(pipe)) - usbhs_dcp_control_transfer_done(pipe); - } - usbhs_fifo_read_busy: usbhsf_fifo_unselect(pipe, fifo); diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c index b27b2bc..9cf07c0 100644 --- a/drivers/usb/renesas_usbhs/mod_gadget.c +++ b/drivers/usb/renesas_usbhs/mod_gadget.c @@ -485,6 +485,9 @@ static int usbhsg_irq_ctrl_stage(struct usbhs_priv *priv, case NODATA_STATUS_STAGE: pipe->handler = &usbhs_ctrl_stage_end_handler; break; + case READ_STATUS_STAGE: + case WRITE_STATUS_STAGE: + usbhs_dcp_control_transfer_done(pipe); default: return ret; }