From patchwork Wed May 30 07:34:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minas Harutyunyan X-Patchwork-Id: 10437815 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C40FE601E9 for ; Wed, 30 May 2018 07:36:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B219F2887D for ; Wed, 30 May 2018 07:36:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A6BB928898; Wed, 30 May 2018 07:36:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 100C02887D for ; Wed, 30 May 2018 07:36:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967924AbeE3HgC (ORCPT ); Wed, 30 May 2018 03:36:02 -0400 Received: from smtprelay6.synopsys.com ([198.182.37.59]:59474 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964986AbeE3Heh (ORCPT ); Wed, 30 May 2018 03:34:37 -0400 Received: from mailhost.synopsys.com (mailhost2.synopsys.com [10.13.184.66]) by smtprelay.synopsys.com (Postfix) with ESMTP id DF2F11E05E0 for ; Wed, 30 May 2018 09:34:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1527665675; bh=h10bstxtig+AGGvveletppiMFPXY+//xS9m8iyDXtpI=; h=Date:From:Subject:To:CC:From; b=eq8cgMsHHpys7kFyZKWL7dtkvMK8AAsdrornEaMus3NJyzuiwuA0g8I+UcIMQd/Bm YvCcsieEy63R3UaaAdxwXFIPlnSe3ijDIqKxrdIRAfrhEZg3wE3m5LPIGFNsEB6/fB OWji2RWWyqE8WLqUQfiStU3gDZIn12Yd3md78gbk+h/DPmjuY0HbAnvUiKC5WR//Qp JYnchRnZ+48JemY7TiZeDne4oQSGT0xZoBnRKSE9hjfxwz0IZBB5T+nBPAgLVWkikz vlS4arGDB9TnaIH1xCNEOoJ9dAQyiZkzsbHB8xvFqKvqG7ZnxGmeadrSOmrAFuKhTE ebdpXzx2weEpA== Received: from us01wehtc1.internal.synopsys.com (us01wehtc1.internal.synopsys.com [10.12.239.235]) by mailhost.synopsys.com (Postfix) with ESMTP id 4C251376C; Wed, 30 May 2018 00:34:34 -0700 (PDT) Received: from US01WEHTC3.internal.synopsys.com (10.15.84.232) by us01wehtc1.internal.synopsys.com (10.12.239.235) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 30 May 2018 00:34:09 -0700 Received: from hminas-z420 (10.13.184.19) by US01WEHTC3.internal.synopsys.com (10.15.84.231) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 30 May 2018 00:34:07 -0700 Received: by hminas-z420 (sSMTP sendmail emulation); Wed, 30 May 2018 11:34:04 +0400 Date: Wed, 30 May 2018 11:34:04 +0400 Message-ID: From: Minas Harutyunyan Subject: [PATCH v1] dwc2: gadget: Fix ISOC IN DDMA PID bitfield value calculation To: Felipe Balbi , Greg Kroah-Hartman , Minas Harutyunyan , CC: John Youn MIME-Version: 1.0 X-Originating-IP: [10.13.184.19] Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP PID bitfield in descriptor should be set based on particular request length, not based on EP's mc value. PID value can't be set to 0 even request length is 0. If request length is 0 then SP bit should be set along PID. Signed-off-by: Minas Harutyunyan --- drivers/usb/dwc2/gadget.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index f0d9ccf1d665..ff7f23218642 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -812,6 +812,8 @@ static int dwc2_gadget_fill_isoc_desc(struct dwc2_hsotg_ep *hs_ep, u32 index; u32 maxsize = 0; u32 mask = 0; + u8 pid = 0; + u8 sp = 0; maxsize = dwc2_gadget_get_desc_params(hs_ep, &mask); @@ -840,10 +842,15 @@ static int dwc2_gadget_fill_isoc_desc(struct dwc2_hsotg_ep *hs_ep, ((len << DEV_DMA_NBYTES_SHIFT) & mask)); if (hs_ep->dir_in) { - desc->status |= ((hs_ep->mc << DEV_DMA_ISOC_PID_SHIFT) & - DEV_DMA_ISOC_PID_MASK) | - ((len % hs_ep->ep.maxpacket) ? - DEV_DMA_SHORT : 0) | + if (len) { + pid = DIV_ROUND_UP(len, hs_ep->ep.maxpacket); + sp = (len % hs_ep->ep.maxpacket) ? DEV_DMA_SHORT : 0; + } else { + pid = 1; + sp = DEV_DMA_SHORT; + } + desc->status |= ((pid << DEV_DMA_ISOC_PID_SHIFT) & + DEV_DMA_ISOC_PID_MASK) | sp | ((hs_ep->target_frame << DEV_DMA_ISOC_FRNUM_SHIFT) & DEV_DMA_ISOC_FRNUM_MASK);