From patchwork Wed Jul 9 11:30:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 4513561 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 BCF4ABEEAA for ; Wed, 9 Jul 2014 11:30:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D72C12028D for ; Wed, 9 Jul 2014 11:30:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DB75F20218 for ; Wed, 9 Jul 2014 11:30:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753955AbaGILam (ORCPT ); Wed, 9 Jul 2014 07:30:42 -0400 Received: from relmlor3.renesas.com ([210.160.252.173]:59932 "EHLO relmlie2.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752108AbaGILal (ORCPT ); Wed, 9 Jul 2014 07:30:41 -0400 Received: from unknown (HELO relmlir1.idc.renesas.com) ([10.200.68.151]) by relmlie2.idc.renesas.com with ESMTP; 09 Jul 2014 20:30:40 +0900 Received: from relmlac2.idc.renesas.com (relmlac2.idc.renesas.com [10.200.69.22]) by relmlir1.idc.renesas.com (Postfix) with ESMTP id 25BA94CE0C; Wed, 9 Jul 2014 20:30:40 +0900 (JST) Received: by relmlac2.idc.renesas.com (Postfix, from userid 0) id 19775280A6; Wed, 9 Jul 2014 20:30:40 +0900 (JST) Received: from relmlac2.idc.renesas.com (localhost [127.0.0.1]) by relmlac2.idc.renesas.com (Postfix) with ESMTP id 13097280A0; Wed, 9 Jul 2014 20:30:40 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac2.idc.renesas.com with ESMTP id WAG24787; Wed, 9 Jul 2014 20:30:40 +0900 X-IronPort-AV: E=Sophos;i="5.01,630,1399993200"; d="scan'208";a="164077562" Received: from mail-sg1lp0091.outbound.protection.outlook.com (HELO APAC01-SG1-obe.outbound.protection.outlook.com) ([207.46.51.91]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA; 09 Jul 2014 20:30:39 +0900 Received: from [10.161.20.147] (211.11.155.147) by HKNPR06MB322.apcprd06.prod.outlook.com (10.141.38.16) with Microsoft SMTP Server (TLS) id 15.0.980.8; Wed, 9 Jul 2014 11:30:37 +0000 Message-ID: <53BD27C5.80006@renesas.com> Date: Wed, 9 Jul 2014 20:30:13 +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" CC: Kuninori Morimoto , Felipe Balbi , SH-Linux Subject: [PATCH 2/2] usb: renesas_usbhs: gadget: fix re-enabling pipe without re-connecting X-Originating-IP: [211.11.155.147] X-ClientProxiedBy: HKNPR06CA003.apcprd06.prod.outlook.com (10.242.116.43) To HKNPR06MB322.apcprd06.prod.outlook.com (10.141.38.16) X-Microsoft-Antispam: BCL:0;PCL:0;RULEID: X-Forefront-PRVS: 0267E514F9 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(6049001)(6009001)(189002)(199002)(81342001)(99396002)(46102001)(54356999)(42186005)(76482001)(65806001)(50986999)(64706001)(229853001)(19580395003)(80022001)(50466002)(107046002)(4396001)(36756003)(65816999)(65956001)(66066001)(20776003)(33656002)(83322001)(92726001)(19580405001)(31966008)(87976001)(85306003)(106356001)(85852003)(83072002)(81542001)(2351001)(64126003)(47776003)(86362001)(21056001)(83506001)(101416001)(74662001)(23756003)(110136001)(74502001)(102836001)(77096002)(95666004)(92566001)(79102001)(105586002)(77982001); DIR:OUT; SFP:; SCL:1; SRVR:HKNPR06MB322; H:[10.161.20.147]; FPR:; MLV:nov; PTR:InfoNoRecords; MX: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 an issue that the renesas_usbhs driver in gadget mode cannot work correctly even if I disabled DMAC of the driver when I used the g_zero driver and the testusb tool. When a usb cable is re-connected, the renesas_usbhs driver calls the usbhsp_flags_init() (via usbhs_hotplug() --> usbhs_mod_call(start) --> usbhsg_try_start() --> usbhs_pipe_init()). However, the driver doesn't call the usbhsp_flags_init() when usbhsg_ep_disable() is called. So, if a gadget driver calls usb_ep_enable() and usb_ep_disable() again and again, the renesas_usbhs driver will output the following log: renesas_usbhs renesas_usbhs: can't get pipe (BULK) renesas_usbhs renesas_usbhs: wrong recip request Signed-off-by: Yoshihiro Shimoda --- drivers/usb/renesas_usbhs/mod_gadget.c | 2 ++ drivers/usb/renesas_usbhs/pipe.c | 10 ++++++++++ drivers/usb/renesas_usbhs/pipe.h | 1 + 3 files changed, 13 insertions(+) diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c index 458f376..04e6505 100644 --- a/drivers/usb/renesas_usbhs/mod_gadget.c +++ b/drivers/usb/renesas_usbhs/mod_gadget.c @@ -600,8 +600,10 @@ static int usbhsg_ep_enable(struct usb_ep *ep, static int usbhsg_ep_disable(struct usb_ep *ep) { struct usbhsg_uep *uep = usbhsg_ep_to_uep(ep); + struct usbhs_pipe *pipe = usbhsg_uep_to_pipe(uep); usbhsg_pipe_disable(uep); + usbhs_pipe_free(pipe); uep->pipe->mod_private = NULL; uep->pipe = NULL; diff --git a/drivers/usb/renesas_usbhs/pipe.c b/drivers/usb/renesas_usbhs/pipe.c index 239b889..75fbcf6 100644 --- a/drivers/usb/renesas_usbhs/pipe.c +++ b/drivers/usb/renesas_usbhs/pipe.c @@ -640,6 +640,11 @@ static struct usbhs_pipe *usbhsp_get_pipe(struct usbhs_priv *priv, u32 type) return pipe; } +static void usbhsp_put_pipe(struct usbhs_pipe *pipe) +{ + usbhsp_flags_init(pipe); +} + void usbhs_pipe_init(struct usbhs_priv *priv, int (*dma_map_ctrl)(struct usbhs_pkt *pkt, int map)) { @@ -727,6 +732,11 @@ struct usbhs_pipe *usbhs_pipe_malloc(struct usbhs_priv *priv, return pipe; } +void usbhs_pipe_free(struct usbhs_pipe *pipe) +{ + usbhsp_put_pipe(pipe); +} + void usbhs_pipe_select_fifo(struct usbhs_pipe *pipe, struct usbhs_fifo *fifo) { if (pipe->fifo) diff --git a/drivers/usb/renesas_usbhs/pipe.h b/drivers/usb/renesas_usbhs/pipe.h index 3e53498..406f36d 100644 --- a/drivers/usb/renesas_usbhs/pipe.h +++ b/drivers/usb/renesas_usbhs/pipe.h @@ -75,6 +75,7 @@ struct usbhs_pipe_info { char *usbhs_pipe_name(struct usbhs_pipe *pipe); struct usbhs_pipe *usbhs_pipe_malloc(struct usbhs_priv *priv, int endpoint_type, int dir_in); +void usbhs_pipe_free(struct usbhs_pipe *pipe); int usbhs_pipe_probe(struct usbhs_priv *priv); void usbhs_pipe_remove(struct usbhs_priv *priv); int usbhs_pipe_is_dir_in(struct usbhs_pipe *pipe);