From patchwork Fri Aug 22 11:14: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: 4763151 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 EB624C0338 for ; Fri, 22 Aug 2014 11:14:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F01CA20179 for ; Fri, 22 Aug 2014 11:14:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 24D2720136 for ; Fri, 22 Aug 2014 11:14:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755967AbaHVLOZ (ORCPT ); Fri, 22 Aug 2014 07:14:25 -0400 Received: from relmlor3.renesas.com ([210.160.252.173]:38129 "EHLO relmlie2.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753229AbaHVLOZ (ORCPT ); Fri, 22 Aug 2014 07:14:25 -0400 Received: from unknown (HELO relmlir4.idc.renesas.com) ([10.200.68.154]) by relmlie2.idc.renesas.com with ESMTP; 22 Aug 2014 20:14:24 +0900 Received: from relmlac2.idc.renesas.com (relmlac2.idc.renesas.com [10.200.69.22]) by relmlir4.idc.renesas.com (Postfix) with ESMTP id 1068B471C4; Fri, 22 Aug 2014 20:14:24 +0900 (JST) Received: by relmlac2.idc.renesas.com (Postfix, from userid 0) id 0C843280A6; Fri, 22 Aug 2014 20:14:24 +0900 (JST) Received: from relmlac2.idc.renesas.com (localhost [127.0.0.1]) by relmlac2.idc.renesas.com (Postfix) with ESMTP id 06196280A0; Fri, 22 Aug 2014 20:14:24 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac2.idc.renesas.com with ESMTP id WBG11038; Fri, 22 Aug 2014 20:14:24 +0900 X-IronPort-AV: E=Sophos;i="5.04,379,1406559600"; d="scan'208";a="167334392" Received: from mail-hk1lp0122.outbound.protection.outlook.com (HELO APAC01-HK1-obe.outbound.protection.outlook.com) ([207.46.51.122]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA; 22 Aug 2014 20:14:23 +0900 Received: from [10.161.20.147] (211.11.155.147) by SIXPR06MB333.apcprd06.prod.outlook.com (10.141.120.15) with Microsoft SMTP Server (TLS) id 15.0.1010.18; Fri, 22 Aug 2014 11:14:21 +0000 Message-ID: <53F72602.3010704@renesas.com> Date: Fri, 22 Aug 2014 20:14:10 +0900 From: Yoshihiro Shimoda User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: "linux-usb@vger.kernel.org" , Felipe Balbi CC: SH-Linux , Greg Kroah-Hartman , Kuninori Morimoto Subject: [PATCH 3/4] usb: renesas_usbhs: fix the condition of is_done in usbhsf_dma_push_done X-Originating-IP: [211.11.155.147] X-ClientProxiedBy: HKXPR02CA0034.apcprd02.prod.outlook.com (25.161.48.19) To SIXPR06MB333.apcprd06.prod.outlook.com (10.141.120.15) X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;UriScan:; X-Forefront-PRVS: 0311124FA9 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019008)(6009001)(6049001)(189002)(199003)(79102001)(95666004)(106356001)(76482001)(64126003)(23756003)(20776003)(80316001)(19580405001)(551934003)(229853001)(64706001)(36756003)(46102001)(47776003)(77982001)(105586002)(107046002)(81342001)(92566001)(66066001)(74662001)(85852003)(83072002)(21056001)(81542001)(85306004)(31966008)(87976001)(77096002)(54356999)(74502001)(92726001)(101416001)(83322001)(65956001)(4396001)(102836001)(19580395003)(86362001)(83506001)(33656002)(50466002)(50986999)(65816999)(99396002)(87266999)(59896002)(80022001)(42186005)(90102001); DIR:OUT; SFP:1102; SCL:1; SRVR:SIXPR06MB333; H:[10.161.20.147]; FPR:; MLV:sfv; PTR:InfoNoRecords; MX:1; A:1; 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.6 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 This patch fixes the condition of is_done in usbhsf_dma_push_done(). This function will be called after a transmission finished by DMAC. So, the function should check if the transmission packet is short packet or not. Also the function should call try_run to send the zero packet by the pio handler if the "*is_done" is not set. Otherwize, the transaction will not finish if a gadget driver sets the "zero" flag in a transmission. Signed-off-by: Yoshihiro Shimoda --- drivers/usb/renesas_usbhs/fifo.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c index 3efece3..1564829 100644 --- a/drivers/usb/renesas_usbhs/fifo.c +++ b/drivers/usb/renesas_usbhs/fifo.c @@ -889,16 +889,29 @@ usbhsf_pio_prepare_push: static int usbhsf_dma_push_done(struct usbhs_pkt *pkt, int *is_done) { struct usbhs_pipe *pipe = pkt->pipe; + int is_short = pkt->trans % usbhs_pipe_get_maxpacket(pipe); - pkt->actual = pkt->trans; + pkt->actual += pkt->trans; + + if (pkt->actual < pkt->length) + *is_done = 0; /* there are remainder data */ + else if (is_short) + *is_done = 1; /* short packet */ + else + *is_done = !pkt->zero; /* send zero packet? */ - *is_done = !pkt->zero; /* send zero packet ? */ usbhs_pipe_running(pipe, !*is_done); usbhsf_dma_stop(pipe, pipe->fifo); usbhsf_dma_unmap(pkt); usbhsf_fifo_unselect(pipe, pipe->fifo); + if (!*is_done) { + /* change handler to PIO */ + pkt->handler = &usbhs_fifo_pio_push_handler; + return pkt->handler->try_run(pkt, is_done); + } + return 0; }