From patchwork Fri Aug 22 11:14:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 4763161 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 93158C0338 for ; Fri, 22 Aug 2014 11:14:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B403F20172 for ; Fri, 22 Aug 2014 11:14:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CA5FB20136 for ; Fri, 22 Aug 2014 11:14:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755967AbaHVLOn (ORCPT ); Fri, 22 Aug 2014 07:14:43 -0400 Received: from relmlor4.renesas.com ([210.160.252.174]:31221 "EHLO relmlie3.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753229AbaHVLOm (ORCPT ); Fri, 22 Aug 2014 07:14:42 -0400 Received: from unknown (HELO relmlir3.idc.renesas.com) ([10.200.68.153]) by relmlie3.idc.renesas.com with ESMTP; 22 Aug 2014 20:14:41 +0900 Received: from relmlac4.idc.renesas.com (relmlac4.idc.renesas.com [10.200.69.24]) by relmlir3.idc.renesas.com (Postfix) with ESMTP id AA5CE483EE; Fri, 22 Aug 2014 20:14:41 +0900 (JST) Received: by relmlac4.idc.renesas.com (Postfix, from userid 0) id A74B7480A6; Fri, 22 Aug 2014 20:14:41 +0900 (JST) Received: from relmlac4.idc.renesas.com (localhost [127.0.0.1]) by relmlac4.idc.renesas.com (Postfix) with ESMTP id 9F9F6480A4; Fri, 22 Aug 2014 20:14:41 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac4.idc.renesas.com with ESMTP id WAC07947; Fri, 22 Aug 2014 20:14:41 +0900 X-IronPort-AV: E=Sophos;i="5.04,379,1406559600"; d="scan'208";a="168408716" Received: from mail-hk1lp0120.outbound.protection.outlook.com (HELO APAC01-HK1-obe.outbound.protection.outlook.com) ([207.46.51.120]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA; 22 Aug 2014 20:14:40 +0900 Received: from [10.161.20.147] (211.11.155.147) by SINPR06MB329.apcprd06.prod.outlook.com (10.141.110.15) with Microsoft SMTP Server (TLS) id 15.0.1015.17; Fri, 22 Aug 2014 11:14:39 +0000 Message-ID: <53F72614.4030807@renesas.com> Date: Fri, 22 Aug 2014 20:14:28 +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 4/4] usb: renesas_usbhs: fix the usb_pkt_pop() X-Originating-IP: [211.11.155.147] X-ClientProxiedBy: HKXPR02CA0052.apcprd02.prod.outlook.com (25.161.48.37) To SINPR06MB329.apcprd06.prod.outlook.com (10.141.110.15) X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;UriScan:; X-Forefront-PRVS: 0311124FA9 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019008)(6009001)(6049001)(199003)(189002)(19580395003)(551934003)(83322001)(50466002)(80316001)(19580405001)(47776003)(33656002)(31966008)(107046002)(85852003)(106356001)(36756003)(83506001)(4396001)(86362001)(21056001)(105586002)(92566001)(74662001)(59896002)(229853001)(77982001)(83072002)(95666004)(74502001)(81342001)(92726001)(575784001)(23756003)(85306004)(76482001)(64706001)(54356999)(81542001)(101416001)(66066001)(65956001)(102836001)(80022001)(20776003)(87976001)(87266999)(50986999)(79102001)(77096002)(64126003)(99396002)(42186005)(65816999)(46102001)(90102001); DIR:OUT; SFP:1102; SCL:1; SRVR:SINPR06MB329; H:[10.161.20.147]; FPR:; MLV:sfv; PTR:InfoNoRecords; A:1; MX:1; LANG:; 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 usb_pkt_pop(). If a gadget driver calls usb_ep_dequeue(), this driver will call the usb_pkt_pop(). So, the usb_pkt_pop() should cancel the transaction. Signed-off-by: Yoshihiro Shimoda --- drivers/usb/renesas_usbhs/fifo.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c index 1564829..b0c97a3 100644 --- a/drivers/usb/renesas_usbhs/fifo.c +++ b/drivers/usb/renesas_usbhs/fifo.c @@ -108,19 +108,45 @@ static struct usbhs_pkt *__usbhsf_pkt_get(struct usbhs_pipe *pipe) return list_first_entry(&pipe->list, struct usbhs_pkt, node); } +static void usbhsf_fifo_clear(struct usbhs_pipe *pipe, + struct usbhs_fifo *fifo); +static void usbhsf_fifo_unselect(struct usbhs_pipe *pipe, + struct usbhs_fifo *fifo); +static struct dma_chan *usbhsf_dma_chan_get(struct usbhs_fifo *fifo, + struct usbhs_pkt *pkt); +#define usbhsf_dma_map(p) __usbhsf_dma_map_ctrl(p, 1) +#define usbhsf_dma_unmap(p) __usbhsf_dma_map_ctrl(p, 0) +static int __usbhsf_dma_map_ctrl(struct usbhs_pkt *pkt, int map); struct usbhs_pkt *usbhs_pkt_pop(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt) { struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); + struct usbhs_fifo *fifo = usbhs_pipe_to_fifo(pipe); unsigned long flags; /******************** spin lock ********************/ usbhs_lock(priv, flags); + usbhs_pipe_disable(pipe); + if (!pkt) pkt = __usbhsf_pkt_get(pipe); - if (pkt) + if (pkt) { + struct dma_chan *chan = NULL; + + if (fifo) + chan = usbhsf_dma_chan_get(fifo, pkt); + if (chan) { + dmaengine_terminate_all(chan); + usbhsf_fifo_clear(pipe, fifo); + usbhsf_dma_unmap(pkt); + } + __usbhsf_pkt_del(pkt); + } + + if (fifo) + usbhsf_fifo_unselect(pipe, fifo); usbhs_unlock(priv, flags); /******************** spin unlock ******************/ @@ -778,8 +804,6 @@ static void __usbhsf_dma_ctrl(struct usbhs_pipe *pipe, usbhs_bset(priv, fifo->sel, DREQE, dreqe); } -#define usbhsf_dma_map(p) __usbhsf_dma_map_ctrl(p, 1) -#define usbhsf_dma_unmap(p) __usbhsf_dma_map_ctrl(p, 0) static int __usbhsf_dma_map_ctrl(struct usbhs_pkt *pkt, int map) { struct usbhs_pipe *pipe = pkt->pipe;