From patchwork Wed May 23 12:24:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minas Harutyunyan X-Patchwork-Id: 10421119 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 20DEE60327 for ; Wed, 23 May 2018 12:25:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 09C9728F3E for ; Wed, 23 May 2018 12:25:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F20F928F5A; Wed, 23 May 2018 12:25:03 +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 45AAD28F3E for ; Wed, 23 May 2018 12:25:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932086AbeEWMZB (ORCPT ); Wed, 23 May 2018 08:25:01 -0400 Received: from smtprelay.synopsys.com ([198.182.37.59]:54042 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932070AbeEWMZB (ORCPT ); Wed, 23 May 2018 08:25:01 -0400 Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by smtprelay.synopsys.com (Postfix) with ESMTP id B8B621E0433 for ; Wed, 23 May 2018 14:24:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1527078299; bh=rP11AdqB3gcC188Kh0gmemEvErWP9O6kRt8pLRGBNRg=; h=Date:From:Subject:To:CC:From; b=G2WqslbllziTrrx/zs3JQbNAb9nHbcHWt/f7Y5lIFSD7OIi69lkA3xzGWWuNYDa0I Nnx/bJQ7ykUhVbrH3UVOn8irqVE9ePJEjxwUuMIUFHPZIyTof8PgKtUgZcik/JTZQm xpg8haUzXRKEdeLeAkWGxHyBTWslke6GHtiQRFRZR4Z66niZGno84fsAhx5TRzC1q7 wQ1b/7uOxGY3YebR2LTRnyCgKm0peOjeqt7VyxCqFz6rij3ra48662G2iRxWLrl9pJ UuC/0lh59ZY6tL4fVNYzT+jnmanl9GcDu4Y5dI5WygFp/a6D3JoV30wGbZsryREsqL rBDNyzzx/3FvA== Received: from US01WXQAHTC1.internal.synopsys.com (us01wxqahtc1.internal.synopsys.com [10.12.238.230]) by mailhost.synopsys.com (Postfix) with ESMTP id 01F7D583B; Wed, 23 May 2018 05:24:58 -0700 (PDT) Received: from US01WEHTC1.internal.synopsys.com (10.12.239.236) by US01WXQAHTC1.internal.synopsys.com (10.12.238.230) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 23 May 2018 05:24:53 -0700 Received: from hminas-z420 (10.13.184.19) by us01wehtc1.internal.synopsys.com (10.12.239.236) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 23 May 2018 05:24:52 -0700 Received: by hminas-z420 (sSMTP sendmail emulation); Wed, 23 May 2018 16:24:44 +0400 Date: Wed, 23 May 2018 16:24:44 +0400 Message-ID: From: Minas Harutyunyan Subject: [PATCH] dwc2: gadget: Fix ISOC IN DDMA PID bitfield value calculation To: John Youn , Felipe Balbi , "Greg Kroah-Hartman" , CC: Minas Harutyunyan 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. Signed-off-by: Minas Harutyunyan --- drivers/usb/dwc2/gadget.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 6c32bf26e48e..9c79919a0a49 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -808,6 +808,7 @@ static int dwc2_gadget_fill_isoc_desc(struct dwc2_hsotg_ep *hs_ep, u32 index; u32 maxsize = 0; u32 mask = 0; + u8 pid = 0; maxsize = dwc2_gadget_get_desc_params(hs_ep, &mask); if (len > maxsize) { @@ -853,7 +854,11 @@ 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) & + if (len) + pid = DIV_ROUND_UP(len, hs_ep->ep.maxpacket); + else + pid = 1; + desc->status |= ((pid << DEV_DMA_ISOC_PID_SHIFT) & DEV_DMA_ISOC_PID_MASK) | ((len % hs_ep->ep.maxpacket) ? DEV_DMA_SHORT : 0) |