From patchwork Tue Nov 3 14:39:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 11877799 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 390DC921 for ; Tue, 3 Nov 2020 14:41:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F3C4A2080C for ; Tue, 3 Nov 2020 14:41:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="mtL1dX6X" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728035AbgKCOl1 (ORCPT ); Tue, 3 Nov 2020 09:41:27 -0500 Received: from mail-eopbgr80072.outbound.protection.outlook.com ([40.107.8.72]:48501 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727742AbgKCOkO (ORCPT ); Tue, 3 Nov 2020 09:40:14 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MbBY4dF9dlU/GhoMAkQfX830waoisxvLJrKE1e3C3EAoDvNvzACDHPNM7UMd7QTa0yw5GTyCTeGP0kPSdOT1v50Z2QWZAmNB1MPcr7nfOnnFdn333jC1FOIskEdId6DaL9ZwFl84Z9sZlbQofn3tS0eCEGyFl5xHMuiBneNJdIotJ0RXRpmdUEerM/4IY7w+j5XPoPZUjjruGAMdSJh2zOz2nm0kv98QBMo1tUS1CFbjVK/5T1nQB2HqagwqsDe4DHdw8EwX4FScgcwo+qMvuWrnhMjt0G3VlpOvmkkMk+FDn+6ee8Quyayney3vHKIU6qbeOA45gKl2YFdIuYX47A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AmJhA46Tr3+EEA0mxLbZGVSVw+fkV+VRMZK4nS3zhxM=; b=b1dBXrOMYMLadFey7Jo+nu0/fWIOOQVV+D6Ebb9d97DZcJXlaQ2jSmIO03091lQAzdayKczSGdfTrrlHAKXw/hX/kXbfx+4VJmdAK/0ZdOUBo7SecS5vUFtbD0V8ZafO7AHKnTygz5rk/bP0UrHU3eFplzEeivTPc3G4v3NqHnHfOWabi5JkiQQ0jbuAI7xYNEOOJAf9MQ159JED2V6RA+berWqxDctdQ2nqPH+NPIybmu1Q49oocZhCUe0U+tJbl+iPMt2fQqcIB0gmdJIokLEAIvDgfWluxi3zCxYcaY6UUIHkXPCtAHcLD7XMyArs9SZIjEPdCL+rIcLDesN7Sg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AmJhA46Tr3+EEA0mxLbZGVSVw+fkV+VRMZK4nS3zhxM=; b=mtL1dX6X7xMTP9YIg44wFaHdp7e2q+Z1Zj/EuP6l4wmw36dfQad6aNzb6TvPeC6ZFlu35QauDtX0ZgBWSOh2US/Xja1VPWzgIQ/eeW8D6163iSj6Ev9Ur/hZG3ukv08thkcnEcKPCTRcfGkXVZP+5E7s0F01p6tZGAXM9FLUWoQ= Authentication-Results: cadence.com; dkim=none (message not signed) header.d=none;cadence.com; dmarc=none action=none header.from=nxp.com; Received: from AM8PR04MB7300.eurprd04.prod.outlook.com (2603:10a6:20b:1c7::12) by AM0PR04MB4004.eurprd04.prod.outlook.com (2603:10a6:208:57::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.27; Tue, 3 Nov 2020 14:40:11 +0000 Received: from AM8PR04MB7300.eurprd04.prod.outlook.com ([fe80::b902:6be0:622b:26c2]) by AM8PR04MB7300.eurprd04.prod.outlook.com ([fe80::b902:6be0:622b:26c2%4]) with mapi id 15.20.3499.032; Tue, 3 Nov 2020 14:40:11 +0000 From: Peter Chen To: pawell@cadence.com, rogerq@ti.com Cc: balbi@kernel.org, linux-usb@vger.kernel.org, linux-imx@nxp.com, jun.li@nxp.com, Peter Chen , Dan Carpenter Subject: [PATCH 1/2] usb: cdns3: gadget: initialize link_trb as NULL Date: Tue, 3 Nov 2020 22:39:28 +0800 Message-Id: <20201103143929.8257-1-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.66] X-ClientProxiedBy: SG2PR03CA0141.apcprd03.prod.outlook.com (2603:1096:4:c8::14) To AM8PR04MB7300.eurprd04.prod.outlook.com (2603:10a6:20b:1c7::12) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from b29397-desktop.ap.freescale.net (119.31.174.66) by SG2PR03CA0141.apcprd03.prod.outlook.com (2603:1096:4:c8::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3541.10 via Frontend Transport; Tue, 3 Nov 2020 14:40:08 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 09628d3d-a9c2-49db-c444-08d880065ded X-MS-TrafficTypeDiagnostic: AM0PR04MB4004: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1332; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HnzxAd233rBow7MJkhXBZCCf0Dk16hA2EhhBCkZ50PHtbUmysR71EytZKZ8PoS4DJHR/I872zVRHZDCsPvkbnrRyBYJrDjYLgHxrlC+3ezEr+afOTWifbYEmD00eUTHDc1FtV3gK7ZksHfZy6uCi/zAtSYpPreY5Yh4a/sGJ+1zAmYCAHgEOvnxgeZsZbali4bNYFY/qsp7LJCxyFq/QJ985hXc+/fODfdwMg9/930PLiYGC1Xivo+fDI3kDgi2OhWN5lsE0OMS/e/ncS4KOLA++1GTVqHYFR/RqIkTLmWw3WpMZsk6vyrE75UMTVcZl X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM8PR04MB7300.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(36756003)(44832011)(6666004)(6486002)(8936002)(52116002)(66476007)(66556008)(8676002)(66946007)(54906003)(4744005)(498600001)(5660300002)(4326008)(6512007)(2906002)(186003)(2616005)(956004)(86362001)(26005)(1076003)(16526019)(6506007)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: TWodVSz/wdZK8nnqGVZGzTpNo2SIT7BdqBVBVmUFZBzTeS+VwnZSMKTHgfZEtSo/c+FIpxyXHKKgmM5p+bseDqTPylieNXEIuSm3ENYgg2T5mgRGtdq0QqM/H6Kb5iIHRotapCh6bP5hG68PMw6Ls8j9BSqBXHI4GQHNqJh1yR2No1NyDP3+ZQ5eSxW9MJF1IfeSuJPn8L8mBTKKX/hX3hrZkc6/DUPY7lJ8Xly3+gBD3zxWlb9Tp583t4uX0WJzup9LoPPydUKFPRpzyroZQdZO/UhaJFdS3rhkAJ7ci+k8Ls4d8VIoQXImYM6JswGB/yzi2DnU9t3ilKPXGuFJdSzSfIAN2JTdTT+DXOaVtC8RqJLN9p0EK6vfjBCBOWlj+ocK4kbFFbEMmLEiVXjhLuZ2m097ic0sRwyjIDjww3+TBTsw8zt1t3m1CJB2qn3BEkHFr6j4fiixq411zyUH24/Gyg3yzK9uyaA64dN9SBYZvC+/V0EMBMDZ71p5gMjUYUXogAi3hpBM9G3E2bl3H4yGWhAdL3jaO9uj0PdwPjYrMpeY7gIGzgSWGdYve4B1FnZ7CVG+aIdxUapB5XhIwtn19qrGSM3PjTcydUBy6NRvqHs7AHD+nC2wUKDVb8tmLd8tax2/T/dUkKQLHLTMBw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 09628d3d-a9c2-49db-c444-08d880065ded X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7300.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2020 14:40:11.0352 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: nklZxT2sdWi7sE15f574MWcBn6/OTqv3wXHaR3LS+zwZv/DH0hoacFae9HKihzTRYZvj4HoxQdPwrdXe+W7V4g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4004 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org There is an uninitialized variable "link_trb" usage at function cdns3_ep_run_transfer. Fixed it by initialize "link_trb" as NULL. Cc: Dan Carpenter Fixes: 4e218882eb5a ("usb: cdns3: gadget: improve the dump TRB operation at cdns3_ep_run_transfer") Reported-by: Dan Carpenter Signed-off-by: Peter Chen --- drivers/usb/cdns3/gadget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c index 26232917197a..ec1730109fd8 100644 --- a/drivers/usb/cdns3/gadget.c +++ b/drivers/usb/cdns3/gadget.c @@ -1114,7 +1114,7 @@ static int cdns3_ep_run_transfer(struct cdns3_endpoint *priv_ep, struct cdns3_device *priv_dev = priv_ep->cdns3_dev; struct cdns3_request *priv_req; struct cdns3_trb *trb; - struct cdns3_trb *link_trb; + struct cdns3_trb *link_trb = NULL; dma_addr_t trb_dma; u32 togle_pcs = 1; int sg_iter = 0; From patchwork Tue Nov 3 14:39:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 11877797 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 49F0A92A for ; Tue, 3 Nov 2020 14:41:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 24665223AC for ; Tue, 3 Nov 2020 14:41:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="dCzpdojU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728064AbgKCOl1 (ORCPT ); Tue, 3 Nov 2020 09:41:27 -0500 Received: from mail-eopbgr80072.outbound.protection.outlook.com ([40.107.8.72]:48501 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727754AbgKCOkQ (ORCPT ); Tue, 3 Nov 2020 09:40:16 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cTqisU0XKw/K6hnA6yXUhE4A5WFjIUf4WIRMIQgFlhkzZ6/gnsmHMBITts6Z8qJOqzffYPqJmxH+oYkHCB9fZTmIkBLOdkNbOgkxHyr0OnVYtiVDoZI0jXFRuWfk+DEN28iQNKjpHMD9i1wmEozEl4F2V0QXXnmnArf/R/IsxTh+g/hlVY2lXKRAFK/ENKklMRB7LoEgnLV3XL/yVtUVGyza9YwxCWNQPtCl8MwXLWXvbeDlhH1yd1dQJHMwfbFpqd2ykA+7WLLdhL47zbqRrcqqfAWEIqUWojGc3vyYKbNbns2RYdYT9uMTEmzHJ4+4RuEbfac48x083gfAfxWEPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=s9xm20+yg1a850AJVhIHsOmcwtjFwnj2OY2iYDULtZI=; b=DexJ32y1dOqhPPfeDfMlHl1q5LekoSXqivhzsDEpwXZSROPHEz2YOqLb7tr/VBQSQ2OOB/dcpRdfP+S0kOD1/MwTzPX6p54Tg/RmD+dK4mngRlcprc1H/F9UImXH7ibH8cC4BsiKK7miMMpsYZa/hOusE/bpLc/GANfOxQ8jU8Ie5/kjDByHWPxIeK58PWtOHpuu6ORIpmiiQ/c8l9a2n39Ot4YdHyaJtmOdTICjT82Ul+zI6ABROSWVMBBX4yTpxk1mNg8MGhMUWoirn0kH93//iGDll5wCxMxVFxA75HlhGqUCLldHjHRLhngryGAJH+wjYwe529Ch8RsntOPWSw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=s9xm20+yg1a850AJVhIHsOmcwtjFwnj2OY2iYDULtZI=; b=dCzpdojUQwAsvngEvIFkdiG1VOq4QL7VG2GiBs23gHLbI/JAyYNhit4Lb921j9aP/9tVl8hBevqbhtUEU1nlTCvD8R4p/GSpPDEiNrtJu+YgzOD7nqsjrDk2ZQA9skb30wywarwj6qrJt71K7Pk0zl58HRbEyoXGvG8vj5aCnGg= Authentication-Results: cadence.com; dkim=none (message not signed) header.d=none;cadence.com; dmarc=none action=none header.from=nxp.com; Received: from AM8PR04MB7300.eurprd04.prod.outlook.com (2603:10a6:20b:1c7::12) by AM0PR04MB4004.eurprd04.prod.outlook.com (2603:10a6:208:57::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.27; Tue, 3 Nov 2020 14:40:13 +0000 Received: from AM8PR04MB7300.eurprd04.prod.outlook.com ([fe80::b902:6be0:622b:26c2]) by AM8PR04MB7300.eurprd04.prod.outlook.com ([fe80::b902:6be0:622b:26c2%4]) with mapi id 15.20.3499.032; Tue, 3 Nov 2020 14:40:13 +0000 From: Peter Chen To: pawell@cadence.com, rogerq@ti.com Cc: balbi@kernel.org, linux-usb@vger.kernel.org, linux-imx@nxp.com, jun.li@nxp.com, Peter Chen Subject: [PATCH 2/2] usb: cdns3: gadget: calculate TD_SIZE based on TD Date: Tue, 3 Nov 2020 22:39:29 +0800 Message-Id: <20201103143929.8257-2-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201103143929.8257-1-peter.chen@nxp.com> References: <20201103143929.8257-1-peter.chen@nxp.com> X-Originating-IP: [119.31.174.66] X-ClientProxiedBy: SG2PR03CA0141.apcprd03.prod.outlook.com (2603:1096:4:c8::14) To AM8PR04MB7300.eurprd04.prod.outlook.com (2603:10a6:20b:1c7::12) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from b29397-desktop.ap.freescale.net (119.31.174.66) by SG2PR03CA0141.apcprd03.prod.outlook.com (2603:1096:4:c8::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3541.10 via Frontend Transport; Tue, 3 Nov 2020 14:40:11 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 9bf42574-6cd1-4834-22ad-08d880065f8b X-MS-TrafficTypeDiagnostic: AM0PR04MB4004: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2VBd1rOTpU17/nQ+ZVvqd5HBmRCxGPYu2dbeBMI6uHCxsgSkwQ3C3el2QFQ4EAh4wsApii7ixHpiGsn6H9U4g0bj6HF/fGPe3q2MAnFUUWnP9g1dtRWFjHsPO/zwaV/1OgZZghg8J/DFSssfV0XQFRj/7/zLa2JHGs09lh/t3IcwSFNlyvC+PxtmDjWj0XMnfoe2yCskwEXohvVXBAAUsk5B9wIHRmwTrdCx726rNXMj4U5zdBKfAYTPgAtEe5sy3Anfe9fIQEqGMGEusTpa1fAJh9M/ceI3IMwSIq9DJc/DeNTS1QG7y4jdBAMl8PeZ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM8PR04MB7300.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(36756003)(44832011)(6666004)(6486002)(8936002)(52116002)(66476007)(66556008)(8676002)(66946007)(498600001)(5660300002)(4326008)(6512007)(2906002)(186003)(2616005)(956004)(86362001)(26005)(1076003)(16526019)(6506007)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: sYCcN8KR4TmtpuCqjLSFXjf3KuwQBCjdcYX04MMsYndADZYC1jhENetTCGgumc0fBTCAIUc/vBLDMBS+EAmqrzh95U1qXG+slfdvmjlpdWPOphmRQlxxqbHVz0hPMCR4E9SSwkkPOsYxCIFeE5frIp3sx1DXeyac+0dVB0vxZNAhK5wMDrPBmGfyZYmI962yguzju2v+LjoXi3xNZalATDdIq+f6tj+mRZfyFFVilddJ0rNJfglVbcvfdi/twTHw5qjWwImyZUP5uwSvqZ5UMx3pe7WUnvs9XTXZw2Ab1EoOn0/fVGPd2IwYkTgwOz4hj5OFYQg/QI+0LHD64Az/mJli6i/r9ilxutKTPxCCeTulv5oI3r7GYe5kiJJLiIvljMcbh9zkUg6uOhD0lxkieuUjil6nMV5+U9bLALcwqhtdMgBZ7/aue9aV4UHvT00uROZ5URRl1tyG1ofSO/iu/s8Yf2NyFtdJELw7dRq/valGOBqV2ZBBTT5lcNeTU05g/efmrn5eoXnpquTFhhNhPcWnjVNZOqseWiyld4f52lo/ZtRO9LmeD8pwvCTa4p8JY8vDSC8W44YxUNMIQoBOEebAjZCwWPAtehC7dwQHD2FDHq0EL+UTbrpZw58gDQoK46KIC55//Mp1Lcg2L5wPTg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9bf42574-6cd1-4834-22ad-08d880065f8b X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7300.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2020 14:40:13.5959 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: cOYUB8oGG1sJuVeoJNr/yVd1Sy1zGbAvS8RjqiYcZJq/ctp0yDLjYQg2jsn385mY5Bz6s3VVe4jGNsYdCeD+mw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4004 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The TRB entry TD_SIZE is the packet number for the TD (request) but not the each TRB, so it only needs to be assigned for the first TRB during the TD, and the value of it is for TD too. Fixes: 7733f6c32e36 ("usb: cdns3: Add Cadence USB3 DRD Driver") Signed-off-by: Peter Chen --- drivers/usb/cdns3/gadget.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c index ec1730109fd8..c62e09ba9231 100644 --- a/drivers/usb/cdns3/gadget.c +++ b/drivers/usb/cdns3/gadget.c @@ -1193,10 +1193,20 @@ static int cdns3_ep_run_transfer(struct cdns3_endpoint *priv_ep, /* set incorrect Cycle Bit for first trb*/ control = priv_ep->pcs ? 0 : TRB_CYCLE; + trb->length = 0; + if (priv_dev->dev_ver >= DEV_VER_V2) { + u16 td_size; + + td_size = DIV_ROUND_UP(request->length, + priv_ep->endpoint.maxpacket); + if (priv_dev->gadget.speed == USB_SPEED_SUPER) + trb->length = TRB_TDL_SS_SIZE(td_size); + else + control |= TRB_TDL_HS_SIZE(td_size); + } do { u32 length; - u16 td_size = 0; /* fill TRB */ control |= TRB_TYPE(TRB_NORMAL); @@ -1208,20 +1218,12 @@ static int cdns3_ep_run_transfer(struct cdns3_endpoint *priv_ep, length = request->length; } - if (likely(priv_dev->dev_ver >= DEV_VER_V2)) - td_size = DIV_ROUND_UP(length, - priv_ep->endpoint.maxpacket); - else if (priv_ep->flags & EP_TDLCHK_EN) + if (priv_ep->flags & EP_TDLCHK_EN) total_tdl += DIV_ROUND_UP(length, priv_ep->endpoint.maxpacket); - trb->length = cpu_to_le32(TRB_BURST_LEN(priv_ep->trb_burst_size) | + trb->length |= cpu_to_le32(TRB_BURST_LEN(priv_ep->trb_burst_size) | TRB_LEN(length)); - if (priv_dev->gadget.speed == USB_SPEED_SUPER) - trb->length |= cpu_to_le32(TRB_TDL_SS_SIZE(td_size)); - else - control |= TRB_TDL_HS_SIZE(td_size); - pcs = priv_ep->pcs ? TRB_CYCLE : 0; /*