From patchwork Thu Oct 30 10:30:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 5195471 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5F842C11AC for ; Thu, 30 Oct 2014 10:30:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 78A5A2024C for ; Thu, 30 Oct 2014 10:30:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9AF2620122 for ; Thu, 30 Oct 2014 10:30:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758417AbaJ3Kam (ORCPT ); Thu, 30 Oct 2014 06:30:42 -0400 Received: from relmlor3.renesas.com ([210.160.252.173]:49028 "EHLO relmlie2.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1758808AbaJ3Kaj (ORCPT ); Thu, 30 Oct 2014 06:30:39 -0400 Received: from unknown (HELO relmlir4.idc.renesas.com) ([10.200.68.154]) by relmlie2.idc.renesas.com with ESMTP; 30 Oct 2014 19:30:39 +0900 Received: from relmlac2.idc.renesas.com (relmlac2.idc.renesas.com [10.200.69.22]) by relmlir4.idc.renesas.com (Postfix) with ESMTP id 41AAE490C2; Thu, 30 Oct 2014 19:30:39 +0900 (JST) Received: by relmlac2.idc.renesas.com (Postfix, from userid 0) id 2E6CE2806F; Thu, 30 Oct 2014 19:30:39 +0900 (JST) Received: from relmlac2.idc.renesas.com (localhost [127.0.0.1]) by relmlac2.idc.renesas.com (Postfix) with ESMTP id 2320C2806E; Thu, 30 Oct 2014 19:30:39 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac2.idc.renesas.com with ESMTP id VBA27075; Thu, 30 Oct 2014 19:30:39 +0900 X-IronPort-AV: E=Sophos;i="5.07,284,1413212400"; d="scan'208";a="172476708" Received: from mail-hk1lp0124.outbound.protection.outlook.com (HELO APAC01-HK1-obe.outbound.protection.outlook.com) ([207.46.51.124]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA; 30 Oct 2014 19:30:38 +0900 Received: from localhost (211.11.155.147) by SIXPR06MB335.apcprd06.prod.outlook.com (10.141.120.17) with Microsoft SMTP Server (TLS) id 15.1.6.9; Thu, 30 Oct 2014 10:30:37 +0000 From: Yoshihiro Shimoda To: , CC: , , Yoshihiro Shimoda Subject: [PATCH v3 3/4] usb: renesas_usbhs: fix the timing of dcp_control_transfer_done Date: Thu, 30 Oct 2014 19:30:18 +0900 Message-ID: <1414665019-1340-4-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 1.9.4.msysgit.1 In-Reply-To: <1414665019-1340-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> References: <1414665019-1340-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> MIME-Version: 1.0 X-Originating-IP: [211.11.155.147] X-ClientProxiedBy: SIXPR06CA0025.apcprd06.prod.outlook.com (25.160.171.143) To SIXPR06MB335.apcprd06.prod.outlook.com (10.141.120.17) X-MS-Exchange-Transport-FromEntityHeader: Hosted X-Microsoft-Antispam: UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:SIXPR06MB335; X-Exchange-Antispam-Report-Test: UriScan:; X-Forefront-PRVS: 038002787A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6069001)(6009001)(189002)(199003)(20776003)(47776003)(48376002)(99396003)(80022003)(76506005)(95666004)(97736003)(85852003)(36756003)(78352002)(50986999)(87976001)(229853001)(46102003)(4396001)(64706001)(122386002)(88136002)(42382002)(120916001)(50466002)(76482002)(87286001)(85306004)(76176999)(50226001)(77156001)(40100003)(217423001)(93916002)(102836001)(92566001)(42186005)(77096002)(62966002)(92726001)(575784001)(105586002)(19580405001)(104166001)(21056001)(107046002)(101416001)(33646002)(31966008)(106356001)(66066001)(89996001)(19580395003)(88662002); DIR:OUT; SFP:1102; SCL:1; SRVR:SIXPR06MB335; 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 daecf74..c46641a 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; }