From patchwork Tue Sep 1 08:44:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 11747653 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 7D02C138A for ; Tue, 1 Sep 2020 08:45:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5E7C8205CB for ; Tue, 1 Sep 2020 08:45:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="nJ4k703Q" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726167AbgIAIpa (ORCPT ); Tue, 1 Sep 2020 04:45:30 -0400 Received: from mail-eopbgr30042.outbound.protection.outlook.com ([40.107.3.42]:38273 "EHLO EUR03-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726102AbgIAIp3 (ORCPT ); Tue, 1 Sep 2020 04:45:29 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i/VRTk8SLM0slNipMjNBTJyNWnQGkyI19N7av0soyFSjvTZ9NIk3JoOUL3Pml/o6xeQhRTBguIG73Cnz1VMfsWUuMxHKlPhb9GJSbhZXMQIr1/rPcXerWWVqG0acmT6YXgCVhkYFG/WjPOIEw1HvcViHufa3Ky2datLuyaXqkbGiI2p7hSBE5PZKHq/wyG6CFjSgsV1wVfMFLZpwMsy5Rb3iadldSwz5tPmPqnVqwOMJde4kq0uaku8JXVS6wc2DT+fczuD64zQNHvQakhURz3/GgnKyZB3/KqruVUX0RaMFzLNAmS+l8DVvD8zCooqqeqsuVwk8XwOCfnhc68hqDA== 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=1roug5CjisULmrLgVpHP08Kq/L2sqFO677koEUOcXh8=; b=PlFHy9aMVdgdEldR2jS2iP5AbV7NOhGURW4SfjWH2yQBmi3DL6MYJ1qgYch8+BtTCAMJsuxrsm5KLkvCopjZdJdeRflRd3HQ/hMIMGd6ZkJqVL4foGygNzoLbX7KmIaNxtNtrgiOBITjtawS0sfGJqcsYSztSErUDF5b5VRnEcH+LP0e5Oz3Ll17BcDCPoBPhCNJZXPxEAXD24aphAFUe//DPI0fC23Ygu0dqTkQD7PLU1gVT6ieQKa+RHotI5i1T685Q7RV4yY3iQUjjIvB2m5cSHxilErtEQh30Oio4eeexjpzM4Bt682J4YGZU8bJ1vftzPN3hTpXgHf6t7Hrcw== 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=1roug5CjisULmrLgVpHP08Kq/L2sqFO677koEUOcXh8=; b=nJ4k703QS2/OiHBjkn+XQig1dKaMLKTK1wKcXzDXf/oDa1UsgCn6FFEKlqMlid5x20cZkhvzqms2zV5NG6FRV6jc9PJqfSUgDSUR5LUESmAH4uqsxrRIT4UFzMPHzLa7iuDhmdk6bPxIjr5Zbbn69XSh0MSAQg4azTtdaCHrVIo= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=nxp.com; Received: from AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) by AM6PR0402MB3543.eurprd04.prod.outlook.com (2603:10a6:209:6::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.23; Tue, 1 Sep 2020 08:45:26 +0000 Received: from AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1023:be8d:40c:efe1]) by AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1023:be8d:40c:efe1%3]) with mapi id 15.20.3326.025; Tue, 1 Sep 2020 08:45:26 +0000 From: Peter Chen To: balbi@kernel.org Cc: linux-usb@vger.kernel.org, linux-imx@nxp.com, pawell@cadence.com, rogerq@ti.com, gregkh@linuxfoundation.org, jun.li@nxp.com, Peter Chen Subject: [PATCH 1/8] usb: cdns3: gadget: using correct sg operations Date: Tue, 1 Sep 2020 16:44:47 +0800 Message-Id: <20200901084454.28649-2-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200901084454.28649-1-peter.chen@nxp.com> References: <20200901084454.28649-1-peter.chen@nxp.com> X-ClientProxiedBy: SG2PR06CA0226.apcprd06.prod.outlook.com (2603:1096:4:68::34) To AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from b29397-desktop.ap.freescale.net (119.31.174.67) by SG2PR06CA0226.apcprd06.prod.outlook.com (2603:1096:4:68::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.19 via Frontend Transport; Tue, 1 Sep 2020 08:45:23 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.67] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: a8778f1d-0e87-4b02-ed00-08d84e535f41 X-MS-TrafficTypeDiagnostic: AM6PR0402MB3543: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:255; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dFcXVdbAo/9m6JXLnRuBgMUmEOP/D2v+2Hx0pURlsu81Ap0Dw0DfGYr/IVI+zpDyetVaTww1YUoHUKXsmeNRzSZvU+QKlerbZ9dvyMEzJi2orMDGnxzG5FDZDPDBJgGgTIS8BibLGyO0ELnMzJUCLl7Bw+v0S0eypDpiXthy7BB7jbJicsXqKAW+f9aS9qO4a8VHtnawV21s+03qB0a0Duz4G1H3NrWDDAU9wFcAwmYfAjDiNOdY7BSO2dib5wYVKW/5nhka/SGJn0PDIirQY2CjlsVarLwwmFy0XFVkSQ0AFY+bIqHrgcdbZqbCEo+5 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM7PR04MB7157.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(346002)(396003)(39860400002)(136003)(376002)(36756003)(44832011)(6916009)(478600001)(16526019)(186003)(26005)(956004)(52116002)(2616005)(6506007)(86362001)(83380400001)(4326008)(316002)(5660300002)(8936002)(66476007)(2906002)(1076003)(6486002)(66556008)(6512007)(6666004)(8676002)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: e9mfHXp5ox9a8U8g3nNVg4UWYX04iXpEXSJfcaHVIJzwxJghBlGysVJuv1gBxskYE0h13+KQ+knqJm13MLDPbY69kUBvvfnNYBG8Qh7vXGkMsuZboTl0g8K40SY+sb3zur3tsdb/ilaXZpp4z6mVfTRkyhhOKd2Ka/a/138D+QD8lu1ThGvLT1upw+pFGPIyj0Wo2FCBFnc+WRcuUBWqCjovowjY0Y1XE0pbpodvUrhRZmVpvW4ZvhSYX8PL8/zKk2qJZI4AxRrdhdhuFiXMIxDX56znvJgR9/zPpiKfZOFbcgBitEYzA1GTRXZSy+B6mSe2jbvMq1R48XfgIaD8rPWnjSHV15CNjslFclZiB2LKOi7DCJrwb7PbA2od5x8WXltG2LZ23IiOEQkE2yj+7Cw9yVLknntMlZVFVJqOFdkpKrBUq7oA/qNJjy7HEc28H5395ykltVdgHulxFh0kzgyJuWQQpdFaFiIK1+uXMWqbk767r14fWjBBoH/Zsl1vd6GQG78FI0oelXqjs29n9e+4YBbvX3fNcFNL/IX+UtnCGdwy3t5E8pAQlCW1kOgxBEEb2aauXtgtPT5Tufdf5dU6SNyN+uKj039Qu1p5olwsaGejRwiAjtRzLk/1EQDA9Vx2rdfw4TXUBeWkbKG05A== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a8778f1d-0e87-4b02-ed00-08d84e535f41 X-MS-Exchange-CrossTenant-AuthSource: AM7PR04MB7157.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2020 08:45:26.1996 (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: VsZkdWxmiSIifNyN0IPz6BEKWwPcy/37YjHT2rjM08pUrV4aNfAbCiYPCb5sO7JhxaXsemCOForZ5ijzcdcWcA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR0402MB3543 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org It needs to use request->num_mapped_sgs to indicate mapped sg number, the request->num_sgs is the sg number before the mapping. These two entries have different values for the platforms which iommu or swiotlb is used. Besides, it needs to use correct sg APIs for mapped sg list for TRB assignment. Signed-off-by: Peter Chen --- drivers/usb/cdns3/gadget.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c index 2ea4d30e1828..50282cab5fb6 100644 --- a/drivers/usb/cdns3/gadget.c +++ b/drivers/usb/cdns3/gadget.c @@ -1098,11 +1098,13 @@ static int cdns3_ep_run_transfer(struct cdns3_endpoint *priv_ep, u32 control; int pcs; u16 total_tdl = 0; + struct scatterlist *s = NULL; + bool sg_supported = !!(request->num_mapped_sgs); if (priv_ep->type == USB_ENDPOINT_XFER_ISOC) num_trb = priv_ep->interval; else - num_trb = request->num_sgs ? request->num_sgs : 1; + num_trb = sg_supported ? request->num_mapped_sgs : 1; if (num_trb > priv_ep->free_trbs) { priv_ep->flags |= EP_RING_FULL; @@ -1162,22 +1164,24 @@ static int cdns3_ep_run_transfer(struct cdns3_endpoint *priv_ep, if (priv_dev->dev_ver <= DEV_VER_V2) togle_pcs = cdns3_wa1_update_guard(priv_ep, trb); + if (sg_supported) + s = request->sg; + /* set incorrect Cycle Bit for first trb*/ control = priv_ep->pcs ? 0 : TRB_CYCLE; - do { u32 length; u16 td_size = 0; /* fill TRB */ control |= TRB_TYPE(TRB_NORMAL); - trb->buffer = cpu_to_le32(TRB_BUFFER(request->num_sgs == 0 - ? trb_dma : request->sg[sg_iter].dma_address)); - - if (likely(!request->num_sgs)) + if (sg_supported) { + trb->buffer = cpu_to_le32(TRB_BUFFER(sg_dma_address(s))); + length = sg_dma_len(s); + } else { + trb->buffer = cpu_to_le32(TRB_BUFFER(trb_dma)); length = request->length; - else - length = request->sg[sg_iter].length; + } if (likely(priv_dev->dev_ver >= DEV_VER_V2)) td_size = DIV_ROUND_UP(length, @@ -1215,6 +1219,9 @@ static int cdns3_ep_run_transfer(struct cdns3_endpoint *priv_ep, else priv_req->trb->control = cpu_to_le32(control); + if (sg_supported) + s = sg_next(s); + control = 0; ++sg_iter; priv_req->end_trb = priv_ep->enqueue; From patchwork Tue Sep 1 08:44:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 11747655 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 E7EC6138A for ; Tue, 1 Sep 2020 08:45:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CC7BA2098B for ; Tue, 1 Sep 2020 08:45:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="m6CdKXyi" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726400AbgIAIpg (ORCPT ); Tue, 1 Sep 2020 04:45:36 -0400 Received: from mail-am6eur05on2066.outbound.protection.outlook.com ([40.107.22.66]:53473 "EHLO EUR05-AM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726102AbgIAIpc (ORCPT ); Tue, 1 Sep 2020 04:45:32 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c9AFuiFRolVvn/dQTMsKKowf73IDq12nKXdI9jyvFROFt+KLxYslYn8loceTnhkXiQfxEYPgjedeWnbM//pfiR35mq6Z/uihtLknJ+cNcm1rdW4dGvKJBWl8bIzeB0oqJN1c3b4OkXkGbKvYSlyulTdWuKZ0SqHnsCjsYjdcSVgvtD3SLfRuD+iFsem1AHhcnK+9Tuz3Q7RxMajtjZsqnoDz9gpL1GMnHdPzT8pfzW4zSyR3WdZ4IBeg150JIC8dUwY8HMZSKLnmTRtt/5fho61LkO/A9N9zRc7SOmQ8Wu01DoaUWhvN8XwjrgsJZkhupF2KtGBfU3ScRCkpFcm4Ug== 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=vpWW6CynpXwRUl7rbuq/HIXcUDl888Iu3yCla980YuA=; b=kdlD5r/Z4n/Zu+yoHX4vOxp9W/t8cfTb+GN9t7Bd1bV5eHm2UqC8UB6l41gWVT71TMhS/dNjHjzVqmeuZ+tYiXsiDyHmSspzb4zjoLlTO8aP7UI1mw5pOAB8ZPl6zdn4nKD+Dv+QdU/sf/fPJhE7j7xkhoFdCwQECJFWbjZ1l7+B9JvbfNG52DDbJgLuTQpzXOJzkmt2sI9PGNGxFGUdcJ9FWw5M0MGYDB5h1BG/xsYswf1Ae365VDHmSJk+q6laoQLzspme17rsOVUHJC7AWRlIvlyb05oJTZMbFcUfWHO4+bUIRuV2c3rYgrKqWUXeKudgGwb1nClzoe1N/Gfz/A== 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=vpWW6CynpXwRUl7rbuq/HIXcUDl888Iu3yCla980YuA=; b=m6CdKXyif3VK8YrHavdiQuDoZUxJqLVXlT/lhkX18Fs7td/3DjVOtF4IAo2FP89VY5z20xVLYrMkxay9DuJyRwavW9nJr8EKTtBtyMJ6ZBYhdH7/I00T/JqamVxHddgNU/GwGTq6Jfj9jHAoykAzWjgUwTSY9/2dzHYKJDHk75o= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=nxp.com; Received: from AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) by AM6PR04MB4360.eurprd04.prod.outlook.com (2603:10a6:209:50::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.21; Tue, 1 Sep 2020 08:45:29 +0000 Received: from AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1023:be8d:40c:efe1]) by AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1023:be8d:40c:efe1%3]) with mapi id 15.20.3326.025; Tue, 1 Sep 2020 08:45:29 +0000 From: Peter Chen To: balbi@kernel.org Cc: linux-usb@vger.kernel.org, linux-imx@nxp.com, pawell@cadence.com, rogerq@ti.com, gregkh@linuxfoundation.org, jun.li@nxp.com, Peter Chen Subject: [PATCH 2/8] usb: cdns3: gadget: improve the dump TRB operation at cdns3_ep_run_transfer Date: Tue, 1 Sep 2020 16:44:48 +0800 Message-Id: <20200901084454.28649-3-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200901084454.28649-1-peter.chen@nxp.com> References: <20200901084454.28649-1-peter.chen@nxp.com> X-ClientProxiedBy: SG2PR06CA0226.apcprd06.prod.outlook.com (2603:1096:4:68::34) To AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from b29397-desktop.ap.freescale.net (119.31.174.67) by SG2PR06CA0226.apcprd06.prod.outlook.com (2603:1096:4:68::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.19 via Frontend Transport; Tue, 1 Sep 2020 08:45:26 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.67] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 372a195c-a421-4767-6bbb-08d84e5360e8 X-MS-TrafficTypeDiagnostic: AM6PR04MB4360: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:383; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zV5CcLvgDc0AK82QGL3EBZbR2aOIuCrhpiY5uzoyxcAE+mV3W8U0n5Tpt7plTNbNPNXh7WlxfqtLrzI3UCJ3tEtS722P95eRhM7rhZJ/IB38cPetZJXFvuxc54uNBmot1IOh35XfJM34guuHbsChxzfCGFa7K94Q3rnQWBZg0cg6aNgIAnO3n5L938a57N0AA6jUuoty4yd12p+D61HvOUjIbjKh0rSuXZgQLFJkrvvD5wGGCgtKGwmKvlPuASW6HaHM7/0xg1y+4NVyjYZvyX75YZo53wDo60nBA+LkF4oFtcnvRZrmgWRQb8uX3o7f2PjToCzfL3Ck/5CSMiEgDg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM7PR04MB7157.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(376002)(366004)(136003)(346002)(396003)(39860400002)(956004)(86362001)(26005)(8676002)(8936002)(66946007)(2906002)(36756003)(1076003)(6506007)(6512007)(6916009)(2616005)(316002)(5660300002)(478600001)(4326008)(66556008)(66476007)(83380400001)(186003)(6486002)(44832011)(16526019)(6666004)(52116002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: vplnAKpocNsfMzjBN7B+ozNWENkhT/04gRyhOlaJmZieWcju6Liy0YKDhnqv0mBz4/QVAY8kOsznocl20imYL1GLbGxxwZiChIcJZjmdavTXK2SUFZ2NanrRPXA9s2HGB7+7krnQ6DHj33GYIf+B/cYuDbAzfj5QBxW6abtElu6P131CW0tzdpcee49dkRBBuN8qOwRSrA2v3p9jHWGKuhSWvGU2GtoChrPqaFafsRUrVLDiesZX1egp2DqunVvig7gK7RWCIIW04fWGeYR1+LkFBIWJtXiJxlJWYlTv/l+JiLxd08AyRtIbXlee7Xi96bt9ueOeL6/kf90vHeMG7GBMBLJLPEymg+5k4Tg7IQcgnfobyaModtpzN4i/87UVKXpeLx5UJwYgZXLn9E4sdGGDsEMTp+iyXuPGW36LI+13ieCgDk6KLXE35VhrREfp7/RiJIxppvsbMRNE+Rj1I6FtGahLtAPqv6gorNiZf8o2oXIMjOoX6HZL5ul5iSNygWxksqVhohhSD8qTYwCwx7g0aHQ7jPUopnd1b5hPN8LI6c0xa/mZHXetIAvL4ii9hJ/VXeVFlmH5sJNhIG64zn94yb53i+qn5zXHzFTIVMM10Jdg050B6HQS2qRXFLT1OCbATIx+Dvr3YUjG9RzLHA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 372a195c-a421-4767-6bbb-08d84e5360e8 X-MS-Exchange-CrossTenant-AuthSource: AM7PR04MB7157.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2020 08:45:28.9724 (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: 5WCG8c+1KxuCkAQYvIbPzgC2jD5/jVoySAiPosjL88ow/Lj4gV4BQfO6FC1pbDg1SiLiIawf1pSg7ARLdhxyfw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB4360 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org It only dumps the first TRB per request, it is not useful if only dump the first TRB when there are several TRBs per request. We improve it by dumpping all TRBs per request in this commit. Signed-off-by: Peter Chen --- drivers/usb/cdns3/gadget.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c index 50282cab5fb6..f68c30b808dc 100644 --- a/drivers/usb/cdns3/gadget.c +++ b/drivers/usb/cdns3/gadget.c @@ -1089,7 +1089,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 *trb, *link_trb; dma_addr_t trb_dma; u32 togle_pcs = 1; int sg_iter = 0; @@ -1130,7 +1130,6 @@ static int cdns3_ep_run_transfer(struct cdns3_endpoint *priv_ep, /* prepare ring */ if ((priv_ep->enqueue + num_trb) >= (priv_ep->num_trbs - 1)) { - struct cdns3_trb *link_trb; int doorbell, dma_index; u32 ch_bit = 0; @@ -1265,7 +1264,22 @@ static int cdns3_ep_run_transfer(struct cdns3_endpoint *priv_ep, if (priv_dev->dev_ver <= DEV_VER_V2) cdns3_wa1_tray_restore_cycle_bit(priv_dev, priv_ep); - trace_cdns3_prepare_trb(priv_ep, priv_req->trb); + if (num_trb > 1) { + int i = 0; + + while (i < num_trb) { + trace_cdns3_prepare_trb(priv_ep, trb + i); + if (trb + i == link_trb) { + trb = priv_ep->trb_pool; + num_trb = num_trb - i; + i = 0; + } else { + i++; + } + } + } else { + trace_cdns3_prepare_trb(priv_ep, priv_req->trb); + } /* * Memory barrier - Cycle Bit must be set before trb->length and From patchwork Tue Sep 1 08:44:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 11747657 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 CAE1E138A for ; Tue, 1 Sep 2020 08:45:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A5320205CB for ; Tue, 1 Sep 2020 08:45:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="TIKpID3+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726510AbgIAIpj (ORCPT ); Tue, 1 Sep 2020 04:45:39 -0400 Received: from mail-am6eur05on2066.outbound.protection.outlook.com ([40.107.22.66]:53473 "EHLO EUR05-AM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726204AbgIAIpi (ORCPT ); Tue, 1 Sep 2020 04:45:38 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RjFhv/YPMVMBDXaJ2BviMiYysmMlnELCD+LZUJPfInGx8mvikzBwPu9+clYlKldIxNSQ39sYbHfeFfweUbwFisPjgtXcIvvzkH0lPJtVQfAhJJKu6MYNuZHK2E6RdR/8ia0iIhS6gl/zaqF/21LPniqH5mgdXjKfEjvZv758HzX47J5pYQ38CMQGh19hWalkiHI7XYCxJjfgoT/nfuoBc5uBtP7sHLjGZlTg4Lo0wYgN6EHS+3PVGD7BzgZtpmMnIMKQk/rUMOdZGvLvqxauPmYv2wDkn4aVF6rf7tdOwQqFBtpIC7Va6AKSOkQUiU9Pxo1uD0EZ9OhlCrgAgbpZLQ== 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=H6O9t0kUQq8Q4cKspPaKLNAHdXfkLa+kxGjfJVaK3PE=; b=X191Zv+20VOTtMUi8bOHuf9rehzAAq+Xb1XxBSMMH0iBT62fJ3yII52NTeXRZiFxCYwBf/px7blYssrpxfd4rNlzYPjmgpggwWxErt6O3n5SF9bCWysUsszNg/M9Apq50DPmV/P9MAeZWT8fZ5w4B66IIySzEv7CgVLOXl53JLN2syYt9/FgQd5+cIpPXRiodG5uOkj7ByJZf3DA8fOFVdjknOwocUmHwhH+6BpYskN2UKTbX4qRGfENethVUdH4aavzVHfgMLDr0tumw4adRd9cpO8AmkFcp29RSgDNQaKpVs1pFjLLA6tFAN/4UB02icHeyNNIeZK/wbAh4qtaAw== 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=H6O9t0kUQq8Q4cKspPaKLNAHdXfkLa+kxGjfJVaK3PE=; b=TIKpID3+YVCuruGqhDViaEZlbVtF+64VjADwdpT2feAbTODunB2QN9GFaseh5OWq8vC9QvulAso5sGumwHHdZYv7bWcMX/kwpmHCsBSEEGEon2R3nmMES2huUD0z8N22jkHN0fwif1W9BHXUrb5XHvUmBeA8y/jJTZfqqWs3x7w= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=nxp.com; Received: from AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) by AM6PR04MB4360.eurprd04.prod.outlook.com (2603:10a6:209:50::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.21; Tue, 1 Sep 2020 08:45:33 +0000 Received: from AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1023:be8d:40c:efe1]) by AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1023:be8d:40c:efe1%3]) with mapi id 15.20.3326.025; Tue, 1 Sep 2020 08:45:31 +0000 From: Peter Chen To: balbi@kernel.org Cc: linux-usb@vger.kernel.org, linux-imx@nxp.com, pawell@cadence.com, rogerq@ti.com, gregkh@linuxfoundation.org, jun.li@nxp.com, Peter Chen Subject: [PATCH 3/8] usb: cdns3: gadget: calculate TDL correctly Date: Tue, 1 Sep 2020 16:44:49 +0800 Message-Id: <20200901084454.28649-4-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200901084454.28649-1-peter.chen@nxp.com> References: <20200901084454.28649-1-peter.chen@nxp.com> X-ClientProxiedBy: SG2PR06CA0226.apcprd06.prod.outlook.com (2603:1096:4:68::34) To AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from b29397-desktop.ap.freescale.net (119.31.174.67) by SG2PR06CA0226.apcprd06.prod.outlook.com (2603:1096:4:68::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.19 via Frontend Transport; Tue, 1 Sep 2020 08:45:29 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.67] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 0f32fa08-a42f-4cc9-ace4-08d84e53628f X-MS-TrafficTypeDiagnostic: AM6PR04MB4360: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0GVcr3W5nsPvNT+MxsQ7cnLmCnf7AZeaOPd0ICaw+qx/ERZe79VYhrN3r/FN2wIZZ5Kxi9GxJlzuNjiWqPYqJa/yVEPH7yT+F0OBWyCYBPqY58id2OI2HdJolYZUt3d8qIGtWWLRoeKUYmjHxkFYAXhAsjwQjZX1xiFWT2c1vwDUh15f5lcZZZtVR1hzdn00u63sDzZmT1+JpjGPr+Ng+DcAF956/91ePKp5CbbTei2WMO62hgBxUTygzD2/sWjw6Br1DUK4WJ90VrQkAornN4Gpgil8oN1nUYH//COQwj9Z9asRWPIaFvIZRej5YFk524bHLs3kOQTZELZKE72PfA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM7PR04MB7157.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(376002)(366004)(136003)(346002)(396003)(39860400002)(956004)(86362001)(26005)(8676002)(8936002)(66946007)(2906002)(36756003)(1076003)(6506007)(6512007)(6916009)(2616005)(316002)(5660300002)(478600001)(4326008)(66556008)(66476007)(83380400001)(186003)(6486002)(44832011)(16526019)(6666004)(52116002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: kGKoTBzpim0V960siaMJroMzGSXO+GyLRyQjf7cikhMyAa4Eu69j533CMwf905LaFTadVZYKfwZpV+onY+iiRTKtdwe0KWjCqvddX/kvAt287YFt8PGeptE8kUv1F6A12LOt6JdSPyvGl/EdxMfZ1rsNsCf4zPc6xxoPLJdTcC+jV/gcnyKnHtxLgVAQcwUbHRBii+XHPMg0Gb0s91Olme0jtoMESfU1WJKDTc9JhpC+rfy1y+DSq6KlCs3ncIMEkJVFwWptcvDMkR5SZF2vP+YkJPn/2ZtvzkvwU1WjCA7gvgjQKJgYfw2txdJd2K0sJ72dLYWjtpiRlsm9/muUXzbE15n3WoF8dDqOb99hRTQFNDu95FMZsAPhxNtD8dZsd/kumzaUpcJxrfpsHJK+KyTRWOvcgEo09DN2O3+AvAXXHX/LnYPRvHQa7JsT0R0War9I4OajXKaw72cQlRes7ikHUwFxpX8Cw7UfjOo8iM8YRCj04eHers4ODWpu/4iW2763EiQdhnfkElFMT3dz4sx1oYAFXlhnrEWqCA2qr8nAG5dtz3OoidgQl3/7B/Kpae6A5/OaxZMXhSvd1IVfsqfuri0d3n0oQkln83ROmyrzpM9St5oX80oiHENgu1CvW3T4Rz9YROeuS5Nxuq6r8g== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0f32fa08-a42f-4cc9-ace4-08d84e53628f X-MS-Exchange-CrossTenant-AuthSource: AM7PR04MB7157.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2020 08:45:31.7910 (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: frmt97nGwXZobU+2Qvl6VIJ7CUC1X34+GRXWVyab4JAWJ6R9SF6UOFh8G7kct0CDQiB5lHmwcXS2QqYqNJ9BLA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB4360 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org TDL is for TD length, so we need to calculate this value for TD (request), but not for TRB, the TDL value is only needed to stored at the first TRB in TD. Signed-off-by: Peter Chen --- drivers/usb/cdns3/gadget.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c index f68c30b808dc..25e3ff1cdf61 100644 --- a/drivers/usb/cdns3/gadget.c +++ b/drivers/usb/cdns3/gadget.c @@ -1100,6 +1100,7 @@ static int cdns3_ep_run_transfer(struct cdns3_endpoint *priv_ep, u16 total_tdl = 0; struct scatterlist *s = NULL; bool sg_supported = !!(request->num_mapped_sgs); + u16 td_size = 0; if (priv_ep->type == USB_ENDPOINT_XFER_ISOC) num_trb = priv_ep->interval; @@ -1168,9 +1169,19 @@ 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) { + 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); @@ -1182,20 +1193,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; /* @@ -1226,6 +1229,7 @@ static int cdns3_ep_run_transfer(struct cdns3_endpoint *priv_ep, priv_req->end_trb = priv_ep->enqueue; cdns3_ep_inc_enq(priv_ep); trb = priv_ep->trb_pool + priv_ep->enqueue; + trb->length = 0; } while (sg_iter < num_trb); trb = priv_req->trb; From patchwork Tue Sep 1 08:44:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 11747659 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 3FD9B1575 for ; Tue, 1 Sep 2020 08:45:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1FF7A2098B for ; Tue, 1 Sep 2020 08:45:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="BIQLC7Mv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726625AbgIAIpl (ORCPT ); Tue, 1 Sep 2020 04:45:41 -0400 Received: from mail-am6eur05on2066.outbound.protection.outlook.com ([40.107.22.66]:53473 "EHLO EUR05-AM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726102AbgIAIpl (ORCPT ); Tue, 1 Sep 2020 04:45:41 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jjyczMb4+cvqkR07mOfGq8nspwXZ8iS56RnyACk9IImG8kpljuRULsG8B7/hZYACxegR6t/9UeVMb94C+ppc2/ZlFNdLhfAUKE9QaZqYVte370PAtTwRj6R5Xg9tFjxFeVlyrkHqDT1mYQLXnmlxavsi9IOanSJWteHbjKKCsNLPZ960N0orY997UWTNGPznh3qeSKIFZ6v0uzw8QUiDgA3FdZb3RXD9BxP4l9MOd6tMChKBJ3xweaCXVDEZsChjbZpcMyTGzzDX/gwp9TpNmTICw2yCsTlIrKZ7PlVWcBOlm/iiBn6RjIAmpc1D2fPZ744dflnYc7hchtJt0zZa2w== 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=SL5Tsp9KYd/tyTzgX0U/mm7qTYStRkIPuqOKOOYSfCE=; b=m0DUSpkeR559f6G3JuEaIvrpvfJydwmQTG5K4ykFEyZG8N/JJdGdOiaJaRJdv206Wygc5tTofWz6Fg54S5MPTj1OTIVThUIhOx3C6A85yInSoygghcUhUO2sc4sVcWjq3VvhQXEq3Wlk6APybtNnEVPvKqosz8HDCxLfNZoKja99Yr43nUKsD2Ean2xqR4zBSeo5xcBYfB6O1VcE4q3j918taDHxACduRebK4dgs/bvsbVTnnX+fpfRzzgjtth12tyMQExi4QlppjPqM+GZTqE84knN/BW24iT41ZwPiAsUZngt6OV3Aln3254Kyp0uLF6HzclHu5erQEN71FhlPYA== 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=SL5Tsp9KYd/tyTzgX0U/mm7qTYStRkIPuqOKOOYSfCE=; b=BIQLC7Mv+zWLPxcfIOu5pFFtx82ZDgV9Xp0C7Ovb3nYktJJB4YKmpEc2HzOtOKQT48WmezwOLyDbXnmKfZcYLhSI9kGlzMXoLgJO1IppL4jHjfOyov960WipCEycFqszMtPeohXmCEkWvXO1/wig/UWSCtU0vLJ9illm52Nh0yc= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=nxp.com; Received: from AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) by AM6PR04MB4360.eurprd04.prod.outlook.com (2603:10a6:209:50::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.21; Tue, 1 Sep 2020 08:45:34 +0000 Received: from AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1023:be8d:40c:efe1]) by AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1023:be8d:40c:efe1%3]) with mapi id 15.20.3326.025; Tue, 1 Sep 2020 08:45:34 +0000 From: Peter Chen To: balbi@kernel.org Cc: linux-usb@vger.kernel.org, linux-imx@nxp.com, pawell@cadence.com, rogerq@ti.com, gregkh@linuxfoundation.org, jun.li@nxp.com, Peter Chen Subject: [PATCH 4/8] usb: cdns3: gadget: add CHAIN and ISP bit for sg list use case Date: Tue, 1 Sep 2020 16:44:50 +0800 Message-Id: <20200901084454.28649-5-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200901084454.28649-1-peter.chen@nxp.com> References: <20200901084454.28649-1-peter.chen@nxp.com> X-ClientProxiedBy: SG2PR06CA0226.apcprd06.prod.outlook.com (2603:1096:4:68::34) To AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from b29397-desktop.ap.freescale.net (119.31.174.67) by SG2PR06CA0226.apcprd06.prod.outlook.com (2603:1096:4:68::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.19 via Frontend Transport; Tue, 1 Sep 2020 08:45:32 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.67] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: d230075a-6412-4bd7-38d9-08d84e53643e X-MS-TrafficTypeDiagnostic: AM6PR04MB4360: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:327; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RnZ6n+Y8qpgrY06zElgDeMO3FsXFsARWpCM7WJHTMnCtzp7Fjn6lkB+IUy8Nep35c+YQpT2XFuZ6Fo+91AZ+XkyXpU6FFpRPhyBlJKm+Bu6AOHIJB2K8NT2/mJM+NmOTCYxPEriVH8zJM4r4iK0cJt5JA1HrLLO05YDLhsj+CQBQ9bBzRN3X4vZ+Poiw1ccyTY4xTwjtD5sHvHjWSJbiWDCP3FEohJrDijgf2VOS8uWonctOWeNZTrXXCmtFULvEgDy5MTCVDiKV3tEZlNrp8juEzijHRPnC2pRJHjwdmjI96laMR1PbbyhIkf9kQKN8iqes9z7kcuRvMUoDpynKoA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM7PR04MB7157.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(376002)(366004)(136003)(346002)(396003)(39860400002)(956004)(86362001)(26005)(8676002)(8936002)(66946007)(2906002)(36756003)(1076003)(6506007)(6512007)(6916009)(2616005)(316002)(5660300002)(478600001)(4326008)(66556008)(66476007)(83380400001)(186003)(6486002)(44832011)(16526019)(4744005)(6666004)(52116002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 9i+A0QP0a8VzS/9dUMTdqyuB09tk53Y5hZ2cgdlN6+5WmCCNE4E1gq8cnuSJ0sOj+wlJb66kbBaYuB3gpEqSniNTfcdFpv0zCO2LyDbT4NWcVZI3OS7PzbaOfgqlRyi9nZifAaK413sfvCmXlXST0YjrXarbH11dXT5MUm1q2ZH/3YiI5d64vOfffAxn4cQ7edbHYw0UQlINi79NW63d5hINjZ+4CWAaybdabb8EkMeRiKdxu7VGWKtLloEGSS3Kl8nYCwfM76VLRMCLPXUtc5cWIZMQ3SGfMnwCGBVUNJYpjXKgVQCKAlrVPg7EXXx53bFKfKDjAwOg6g1DgmmnVo2PN13s8t6lsBLiw8kuc2g+LL84VppSWLvWVnOSz29AtWK/v7ghfpqKimFEmvzeZQuCyguw5/d4EbBPgFGYqW1s/KX1OxfQn04IZWoSQbrWgLq4GB3kM+qJ+w2GShC7qUaUJBawmeufkrfULDR4qEAR9AIn3Z9PZsYSN2w014tM3cHyIshIMari0ws/3R7jtJGSVq+ROkdSzW9qh0I8LwS6TipOPcpmwAWgsqJ/+GaA4oBKNNTYfscJERWojGKR4SaVGvxZQWbBKErpoW8DgY5qdcrMEIiwycWG83mtbpD8i4SAx8cr/rBuuZELyn12rQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d230075a-6412-4bd7-38d9-08d84e53643e X-MS-Exchange-CrossTenant-AuthSource: AM7PR04MB7157.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2020 08:45:34.7182 (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: IP9O4oV4xa+mZMnwTLacMYwljUCqS2oVZbhYYRMbKo3h08uA0HOKGcI9L3mkeWymuw8vax67qLfoFWWmHlNJFg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB4360 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org For sg buffer list use case, we need to add ISP for each TRB, and add CHAIN bit for each TRB except for the last TRB. Signed-off-by: Peter Chen --- drivers/usb/cdns3/gadget.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c index 25e3ff1cdf61..a308a694abc5 100644 --- a/drivers/usb/cdns3/gadget.c +++ b/drivers/usb/cdns3/gadget.c @@ -1221,8 +1221,14 @@ static int cdns3_ep_run_transfer(struct cdns3_endpoint *priv_ep, else priv_req->trb->control = cpu_to_le32(control); - if (sg_supported) + if (sg_supported) { + trb->control |= TRB_ISP; + /* Don't set chain bit for last TRB */ + if (sg_iter < num_trb - 1) + trb->control |= TRB_CHAIN; + s = sg_next(s); + } control = 0; ++sg_iter; From patchwork Tue Sep 1 08:44:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 11747661 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 E31CD1575 for ; Tue, 1 Sep 2020 08:45:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ADCF520866 for ; Tue, 1 Sep 2020 08:45:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="op18V+hr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726762AbgIAIpq (ORCPT ); Tue, 1 Sep 2020 04:45:46 -0400 Received: from mail-am6eur05on2066.outbound.protection.outlook.com ([40.107.22.66]:53473 "EHLO EUR05-AM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726204AbgIAIpp (ORCPT ); Tue, 1 Sep 2020 04:45:45 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZFuaLQY9L9sgK7rKTtRslo4E6Ml3/BndXOl3hxxGINiFab5kcXo4CvIjN378+wxDwNBDA+1ilqW/CaOiGaVT0ZhIrACppb8neyN0YHFOSLYT40WGmt5KmtamV/VxOvGE0S6tnpk9oVXTRbvefVJsNPI9ea7dTGQDVsFlO3YAijdzIV9GVmRJEfRFbgvNd1APCDTyD9RlgZx6OkxM5kQW0uGZ5jU3UwzeH57RN1MSA7DJosyyvQS9hsXIYF2lFVWZCGJXLmgtQkW3BIqZx80R0IqV+oXms34zC6w1SdIGufBmG4r0DWhdiOfKiUbXMaq2Y4QSh3vCyeQl/AyuSfDZVg== 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=kme46ZAuNqgq7TR7Tc5ir9VEi1ewUp1S0ILrYi2C+pQ=; b=i8VYzc7SqfzDFgcubOeaCH5KUHm6Zqmg+8AREams/KVghauMMzNFgYv8YaNVXmQskl8KsqzwhrqtLlMVvWLDAGgmMXQ9O0ZovYWHHJ/R/sDGXwWlGn260sXDP8m1sHaThRpOczEKQ0QlJ2Sh73VAO1ih3q4kzL6OgtaPRFa0it2IStMu4j/vitMJSfmp/LfmnVfxoJFiX0UYHFO3G5WsPWyXdpDmIWz6YRqSpc1i5UxtSSfyg7o0d7AIQBQA16YQmpQv+GuEkD8yNGx62Jp9Aeb1D8yZ+f2jddmHokYszgfw0XOUcLeWoJq+QP7EBcJP/PDW38UZaUQGptBxQzVIxg== 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=kme46ZAuNqgq7TR7Tc5ir9VEi1ewUp1S0ILrYi2C+pQ=; b=op18V+hrqfe9IovbnEtleL7bs6qYJc0hVF6l9Hor0McniowkheQYvZpoIJ1JSTT8uHM5Ku8ZL8V6/W71MNCx9u2YXVrZFIbFPGWd2raj23eusTHDmbroGq83SqpUvGtCzE5N8r84YfmcUhw/L2s93Nps5XjYi35WIcdBswfJjnc= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=nxp.com; Received: from AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) by AM6PR04MB4360.eurprd04.prod.outlook.com (2603:10a6:209:50::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.21; Tue, 1 Sep 2020 08:45:37 +0000 Received: from AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1023:be8d:40c:efe1]) by AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1023:be8d:40c:efe1%3]) with mapi id 15.20.3326.025; Tue, 1 Sep 2020 08:45:37 +0000 From: Peter Chen To: balbi@kernel.org Cc: linux-usb@vger.kernel.org, linux-imx@nxp.com, pawell@cadence.com, rogerq@ti.com, gregkh@linuxfoundation.org, jun.li@nxp.com, Peter Chen Subject: [PATCH 5/8] usb: cdns3: gadget: handle sg list use case at completion correctly Date: Tue, 1 Sep 2020 16:44:51 +0800 Message-Id: <20200901084454.28649-6-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200901084454.28649-1-peter.chen@nxp.com> References: <20200901084454.28649-1-peter.chen@nxp.com> X-ClientProxiedBy: SG2PR06CA0226.apcprd06.prod.outlook.com (2603:1096:4:68::34) To AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from b29397-desktop.ap.freescale.net (119.31.174.67) by SG2PR06CA0226.apcprd06.prod.outlook.com (2603:1096:4:68::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.19 via Frontend Transport; Tue, 1 Sep 2020 08:45:35 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.67] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: d4cebfa6-720a-4cc4-205d-08d84e536601 X-MS-TrafficTypeDiagnostic: AM6PR04MB4360: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 26QRroHummDX1yyM/H6v0I8TOF6Qj32bVIz7ktYpEdZArl6UlRRm33mtLKYtNBZUxHURAOPN8QgvLBApMmqjIApXd0S1MO5/g/pxEv3eJNr9HGE80zpqkvQqcx7gaoQx8+jjt4USWaSb2uA6tMXiIh+oWbz9Pc4T7Bk+rZfvXjnqs5UrqQkHcDlpD3M2nXdsgao7DrbzHue/IG0ZiHyj+cdm6AprW8GwAZcYu82M19zFbnHjtG1mfZ0c1HQT9E0XKwjj8bpvhEe/ZafYzNdScEQ0qTw0uh2h34N9wiGNmNyjsdD8VTJ3rUEpXB1hDV1OmszzRBbmIR7R2ZM4Qrobew== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM7PR04MB7157.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(376002)(366004)(136003)(346002)(396003)(39860400002)(956004)(86362001)(26005)(8676002)(8936002)(66946007)(2906002)(36756003)(1076003)(6506007)(6512007)(6916009)(2616005)(316002)(5660300002)(478600001)(4326008)(66556008)(66476007)(83380400001)(186003)(6486002)(44832011)(16526019)(6666004)(52116002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 8ZDTbvikT3MjK6G0zYuL0R35wUSPF2iTzFDMpySLouldQnmywaOKVNsGny67hXJYQmcK6uxm+qFu+7olXsj6yjPx/BGq0lO6h4pMTNHGvYJ7icrBNj9h5Qy5+1lTvUJTVbX5WWfpSXi0ex/qTiee4J3MCUTBSRSYQzG90GItUd9oTWCRiS8lK6003oLZqWnekJBJV9wMyMNK3Y3+DrgZDlQLyGNtOWI8mNxa3k7Flcd+yjU+FsLjzw8cEbICCp5Lspr53DtuuBllMjhkVEf/Mnvc7mq9VWIY7u0Eqmkqt62yjCoiQ4Webb63QOhsYU5HpKllfoBwb928sBr2cwSOFl7sDkRAEQH7Z/bdTir7ofaYED2DPrJYfNjMgJW7vD8Y8HDIR2jGdnsrDo7+pLQwq1ySddqPkelT/bBMTG0gH+riXOs0R1Jppd0Bj1Z4q/Lgy2gCtMxXXGLKnpPTsduwKjhmGcYNXWJwjQaL6m8dOZ/I2NiWdBFDf4yUFjXEFVDg+HR8l/Km3sEBLxOsuzP70ViXdeEVTP3oo3WYuBAfA9+Ld0dnHW5BtXvHgaoKgW8bdeiYawuQ1cGmxbVx+X6krFwRNFkA76Rv8RDndZ25e2FyBwyiIFfch1Wj8OCjXdGReYwLXrs1CTOeZYgLdL31tA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d4cebfa6-720a-4cc4-205d-08d84e536601 X-MS-Exchange-CrossTenant-AuthSource: AM7PR04MB7157.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2020 08:45:37.5598 (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: /B9cBRhF2MzH9Nu9ZNYZ82pKeESc9k6ATmgn5aBq+okgyhyWkLZfD7MuEvO7qn7wsb2QmcuT8OLr6vzA5A3Vmw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB4360 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org - Judge each TRB has been handled at cdns3_trb_handled, since the DMA pointer may be at the middle of the TD, we can't consider this TD has finished at that time. - Calcuate req->actual according to finished TRBs. - Handle short transfer for sg list use case correctly. When the short transfer occurs, we check OUT_SMM at TRB to see if it is the last TRB. Signed-off-by: Peter Chen --- drivers/usb/cdns3/gadget.c | 85 +++++++++++++++++++++++++------------- drivers/usb/cdns3/gadget.h | 9 ++++ 2 files changed, 65 insertions(+), 29 deletions(-) diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c index a308a694abc5..6cb44c354f40 100644 --- a/drivers/usb/cdns3/gadget.c +++ b/drivers/usb/cdns3/gadget.c @@ -817,6 +817,8 @@ void cdns3_gadget_giveback(struct cdns3_endpoint *priv_ep, request->length); priv_req->flags &= ~(REQUEST_PENDING | REQUEST_UNALIGNED); + /* All TRBs have finished, clear the counter */ + priv_req->finished_trb = 0; trace_cdns3_gadget_giveback(priv_req); if (priv_dev->dev_ver < DEV_VER_V2) { @@ -1241,6 +1243,7 @@ static int cdns3_ep_run_transfer(struct cdns3_endpoint *priv_ep, trb = priv_req->trb; priv_req->flags |= REQUEST_PENDING; + priv_req->num_of_trb = num_trb; if (sg_iter == 1) trb->control |= cpu_to_le32(TRB_IOC | TRB_ISP); @@ -1362,7 +1365,7 @@ void cdns3_set_hw_configuration(struct cdns3_device *priv_dev) } /** - * cdns3_request_handled - check whether request has been handled by DMA + * cdns3_trb_handled - check whether trb has been handled by DMA * * @priv_ep: extended endpoint object. * @priv_req: request object for checking @@ -1379,32 +1382,28 @@ void cdns3_set_hw_configuration(struct cdns3_device *priv_dev) * ET = priv_req->end_trb - index of last TRB in transfer ring * CI = current_index - index of processed TRB by DMA. * - * As first step, function checks if cycle bit for priv_req->start_trb is - * correct. + * As first step, we check if the TRB between the ST and ET. + * Then, we check if cycle bit for index priv_ep->dequeue + * is correct. * * some rules: - * 1. priv_ep->dequeue never exceed current_index. + * 1. priv_ep->dequeue never equals to current_index. * 2 priv_ep->enqueue never exceed priv_ep->dequeue * 3. exception: priv_ep->enqueue == priv_ep->dequeue * and priv_ep->free_trbs is zero. * This case indicate that TR is full. * - * Then We can split recognition into two parts: + * At below two cases, the request have been handled. * Case 1 - priv_ep->dequeue < current_index * SR ... EQ ... DQ ... CI ... ER * SR ... DQ ... CI ... EQ ... ER * - * Request has been handled by DMA if ST and ET is between DQ and CI. - * * Case 2 - priv_ep->dequeue > current_index - * This situation take place when CI go through the LINK TRB at the end of + * This situation takes place when CI go through the LINK TRB at the end of * transfer ring. * SR ... CI ... EQ ... DQ ... ER - * - * Request has been handled by DMA if ET is less then CI or - * ET is greater or equal DQ. */ -static bool cdns3_request_handled(struct cdns3_endpoint *priv_ep, +static bool cdns3_trb_handled(struct cdns3_endpoint *priv_ep, struct cdns3_request *priv_req) { struct cdns3_device *priv_dev = priv_ep->cdns3_dev; @@ -1416,7 +1415,25 @@ static bool cdns3_request_handled(struct cdns3_endpoint *priv_ep, current_index = cdns3_get_dma_pos(priv_dev, priv_ep); doorbell = !!(readl(&priv_dev->regs->ep_cmd) & EP_CMD_DRDY); - trb = &priv_ep->trb_pool[priv_req->start_trb]; + /* current trb doesn't belong to this request */ + if (priv_req->start_trb < priv_req->end_trb) { + if (priv_ep->dequeue > priv_req->end_trb) + goto finish; + + if (priv_ep->dequeue < priv_req->start_trb) + goto finish; + } + + if ((priv_req->start_trb > priv_req->end_trb) && + (priv_ep->dequeue > priv_req->end_trb) && + (priv_ep->dequeue < priv_req->start_trb)) + goto finish; + + if ((priv_req->start_trb == priv_req->end_trb) && + (priv_ep->dequeue != priv_req->end_trb)) + goto finish; + + trb = &priv_ep->trb_pool[priv_ep->dequeue]; if ((le32_to_cpu(trb->control) & TRB_CYCLE) != priv_ep->ccs) goto finish; @@ -1438,12 +1455,8 @@ static bool cdns3_request_handled(struct cdns3_endpoint *priv_ep, !priv_ep->dequeue) goto finish; - if (priv_req->end_trb >= priv_ep->dequeue && - priv_req->end_trb < current_index) - handled = 1; + handled = 1; } else if (priv_ep->dequeue > current_index) { - if (priv_req->end_trb < current_index || - priv_req->end_trb >= priv_ep->dequeue) handled = 1; } @@ -1459,6 +1472,8 @@ static void cdns3_transfer_completed(struct cdns3_device *priv_dev, struct cdns3_request *priv_req; struct usb_request *request; struct cdns3_trb *trb; + bool request_handled = false; + bool transfer_end = false; while (!list_empty(&priv_ep->pending_req_list)) { request = cdns3_next_request(&priv_ep->pending_req_list); @@ -1478,20 +1493,32 @@ static void cdns3_transfer_completed(struct cdns3_device *priv_dev, */ cdns3_select_ep(priv_dev, priv_ep->endpoint.address); - if (!cdns3_request_handled(priv_ep, priv_req)) - goto prepare_next_td; + while (cdns3_trb_handled(priv_ep, priv_req)) { + priv_req->finished_trb++; + if (priv_req->finished_trb >= priv_req->num_of_trb) + request_handled = true; - trb = priv_ep->trb_pool + priv_ep->dequeue; - trace_cdns3_complete_trb(priv_ep, trb); + trb = priv_ep->trb_pool + priv_ep->dequeue; + trace_cdns3_complete_trb(priv_ep, trb); - if (trb != priv_req->trb) - dev_warn(priv_dev->dev, - "request_trb=0x%p, queue_trb=0x%p\n", - priv_req->trb, trb); + if (!transfer_end) + request->actual += + TRB_LEN(le32_to_cpu(trb->length)); - request->actual = TRB_LEN(le32_to_cpu(trb->length)); - cdns3_move_deq_to_next_trb(priv_req); - cdns3_gadget_giveback(priv_ep, priv_req, 0); + if (priv_req->num_of_trb > 1 && + le32_to_cpu(trb->control) & TRB_SMM) + transfer_end = true; + + cdns3_ep_inc_deq(priv_ep); + } + + if (request_handled) { + cdns3_gadget_giveback(priv_ep, priv_req, 0); + request_handled = false; + transfer_end = false; + } else { + goto prepare_next_td; + } if (priv_ep->type != USB_ENDPOINT_XFER_ISOC && TRBS_PER_SEGMENT == 2) diff --git a/drivers/usb/cdns3/gadget.h b/drivers/usb/cdns3/gadget.h index 52765b098b9e..9f8bd452847e 100644 --- a/drivers/usb/cdns3/gadget.h +++ b/drivers/usb/cdns3/gadget.h @@ -1030,6 +1030,11 @@ struct cdns3_trb { * When set to '1', the device will toggle its interpretation of the Cycle bit */ #define TRB_TOGGLE BIT(1) +/* + * The controller will set it if OUTSMM (OUT size mismatch) is detected, + * this bit is for normal TRB + */ +#define TRB_SMM BIT(1) /* * Short Packet (SP). OUT EPs at DMULT=1 only. Indicates if the TRB was @@ -1215,6 +1220,8 @@ struct cdns3_aligned_buf { * this endpoint * @flags: flag specifying special usage of request * @list: used by internally allocated request to add to wa2_descmiss_req_list. + * @finished_trb: number of trb has already finished per request + * @num_of_trb: how many trbs in this request */ struct cdns3_request { struct usb_request request; @@ -1230,6 +1237,8 @@ struct cdns3_request { #define REQUEST_UNALIGNED BIT(4) u32 flags; struct list_head list; + int finished_trb; + int num_of_trb; }; #define to_cdns3_request(r) (container_of(r, struct cdns3_request, request)) From patchwork Tue Sep 1 08:44:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 11747663 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 7DFB8138A for ; Tue, 1 Sep 2020 08:45:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 55B9F20866 for ; Tue, 1 Sep 2020 08:45:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="lzccMVEG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726922AbgIAIps (ORCPT ); Tue, 1 Sep 2020 04:45:48 -0400 Received: from mail-am6eur05on2066.outbound.protection.outlook.com ([40.107.22.66]:53473 "EHLO EUR05-AM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726536AbgIAIpr (ORCPT ); Tue, 1 Sep 2020 04:45:47 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jmmEBXJYXgJCZxqDw7+jzXn9bCkcTHhZpc6vt2vBukIeroPwi8l3fhOieKhhRzRc9OCFJqs6H55q4+HObVx91ECs3fe6mEcxis8gqL+LbXQsyVW++CTwMpEs4+3MLa0+lw4lprBLvR9Yayb3wdZASeIBZABlweZynyd6evEbIf6JZkNtOO2ERM/aEDx0NZxJwCzZV532s/a/giIQKlFQAOQNjg2ak0AGv29fN/tUUbATblQ0fHa8ZxMCroB/jMlRBt3/+SriC6d5MPFkjBjPg9Mb6AwE8zTmfBqwDStXHxXUIqpUcenKwCm8mLEDXbYNUrG7vSnKeMYEMSEvN5v4wA== 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=Ku0G2l5P+XYR7LbTB6WKHJ+yXWxpsBQGyoi2DXXCCt0=; b=UUNSE+3B22DxupJ+P1Gu6o5iuJgd50Zo8sR5NuCdiDnqWENh9pU4hGGnecX0oDuXOL5m0czUcMMD1+iXLiBNn+rWFd6Y81dRXtffsawYTcGy/jaY/HL9bbn/jbLKoC3Z5Xtfb3Tn0v49ceYK1lUi517t0EvAI1oV64ToU0gkPZC17vgIjrloxJ0NKxc3LgNnVs91FbFTEz9t9VRFwU2hOhCdvSnpnj63vFHrPBtY54RuJ1wEHh7XssoZ+WKY10PD4gLe37MDQvRHOIb116lFh+JZtjmvaG3lpVk21Xo/yGB5cMy1MXgrAawRRP01RwpcwUFPF2t8nrbweiPGtZNICw== 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=Ku0G2l5P+XYR7LbTB6WKHJ+yXWxpsBQGyoi2DXXCCt0=; b=lzccMVEG542+XPfVq1O/LC+KfSCJ10ecapxihIR77paHgyCNAh2w080OjypRpsqjsa7vcG4lDiFiiuOkUMowq1gEl0tI+BhPBxRKzuNmzTzlSIyC4GP38G/I+TgaJl/8HhIUc2pFa6FVNRey7gjZ73Yt+h54v+KoYrN3hYrgYgI= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=nxp.com; Received: from AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) by AM6PR04MB4360.eurprd04.prod.outlook.com (2603:10a6:209:50::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.21; Tue, 1 Sep 2020 08:45:40 +0000 Received: from AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1023:be8d:40c:efe1]) by AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1023:be8d:40c:efe1%3]) with mapi id 15.20.3326.025; Tue, 1 Sep 2020 08:45:40 +0000 From: Peter Chen To: balbi@kernel.org Cc: linux-usb@vger.kernel.org, linux-imx@nxp.com, pawell@cadence.com, rogerq@ti.com, gregkh@linuxfoundation.org, jun.li@nxp.com, Peter Chen Subject: [PATCH 6/8] usb: cdns3: gadget: need to handle sg case for WA2 case Date: Tue, 1 Sep 2020 16:44:52 +0800 Message-Id: <20200901084454.28649-7-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200901084454.28649-1-peter.chen@nxp.com> References: <20200901084454.28649-1-peter.chen@nxp.com> X-ClientProxiedBy: SG2PR06CA0226.apcprd06.prod.outlook.com (2603:1096:4:68::34) To AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from b29397-desktop.ap.freescale.net (119.31.174.67) by SG2PR06CA0226.apcprd06.prod.outlook.com (2603:1096:4:68::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.19 via Frontend Transport; Tue, 1 Sep 2020 08:45:37 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.67] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: be0b1cf8-6a1e-4efa-3142-08d84e5367b1 X-MS-TrafficTypeDiagnostic: AM6PR04MB4360: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:281; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7te8+4g/H/mBl4EPbyMYDLqCpWvfISsR7PoYy+HXswmPwqTI0uoKtRGR9mU3kM9QuCv3ipIZZlSTjag7BVyjqXmcUfUojfA1XFEJy563VotzicLHkcnKAseD/1JHjaddD/BmLci3+NZfK83RS4gpzxnw5nCHKkCW7/eTkNu+SsfjGuhv6lhQkbXjX+YntUXTrwSqmVh2Zhh5iv6Auq9lMgdftKrspeRZJrtNhbuGSyZtY0MRwFhLMeJnpwRun5EJQipvMtfc+dPtxABH/H53X/jJkD+jZRA0rO73XDZVB1OqIkTvD13BX6LHbDW1JwDfmhZ1gu3kzYxuIeowC/7nLA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM7PR04MB7157.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(376002)(366004)(136003)(346002)(396003)(39860400002)(956004)(86362001)(26005)(8676002)(8936002)(66946007)(2906002)(36756003)(1076003)(6506007)(6512007)(6916009)(2616005)(316002)(5660300002)(478600001)(4326008)(66556008)(66476007)(83380400001)(186003)(6486002)(44832011)(16526019)(6666004)(52116002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: eSFUOb715XjiCjvymefHXRCAxJBsLPn+QGGU4OZccixuhyuW6hRDET5FbQUbQjMH2hE7Y3vChsRduAquEyKEdznSIJIz37FMArOqLXmdlOl3XWOwTQrDcgNRMes7gQ6mDHucVEAmdF0FHUBL5p6nA4V3iFpMk40L5ywEMUsAvVi54gBABeJm/EaMatCd/LqMJRB6ZUVAkfzM+a6AaUv2Rq71mFsPt6ArrEUJyCiKKfQgettgz2ksC2WfeEb8WoJQhFrAiheb8sNdJ5vXxc2KgzTyrlYEs6Kk5U6602r6as1Yp3hld6RgSB6ENdFeEwdoEJY3YNZHN+PRvyCC7l0WPKklkJN9v/bKdsbvdPC0Nzn54NyH3qp/dN2VkbZbnK9mHIItQoqAy5es3Ecr33d/H/nzNIospOE15PMk1gfQ6hFnpPAst6lTv3fhtrlnvfBes24rb57kMB4nxn9FiLO23vzzgDa3lli4qVsi+LNUbRyiov7Vt8RmP+xMtH0y9xJXZcsDKV5925zAlJZniG2D2sUGSc4sJa/9qyfNJOSRotI74VfQXB3fnDs2tHPPAiUiXKtNNwiu+5mCAcTYOdir++kAn8hruVLta9iMXARlDCf9BlqiIX0gENwTRJdhO3uxIJfYMcWZJ4HJxteKg4a+0A== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: be0b1cf8-6a1e-4efa-3142-08d84e5367b1 X-MS-Exchange-CrossTenant-AuthSource: AM7PR04MB7157.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2020 08:45:40.5795 (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: iQ+KRF62uBI+AryiJp9vHDWquhjwYXF9DAKmxSGyd4Dd1vu6VWMicYfi0z9SmCsiVILgqtzNqIFAdW2WIv+9Bg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB4360 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Add sg support for WA2 case. Signed-off-by: Peter Chen --- drivers/usb/cdns3/gadget.c | 44 +++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c index 6cb44c354f40..1fd36bc5c6db 100644 --- a/drivers/usb/cdns3/gadget.c +++ b/drivers/usb/cdns3/gadget.c @@ -462,6 +462,36 @@ static int cdns3_start_all_request(struct cdns3_device *priv_dev, (reg) |= EP_STS_EN_DESCMISEN; \ } } while (0) +static void __cdns3_descmiss_copy_data(struct usb_request *request, + struct usb_request *descmiss_req) +{ + int length = request->actual + descmiss_req->actual; + struct scatterlist *s = request->sg; + + if (!s) { + if (length <= request->length) { + memcpy(&((u8 *)request->buf)[request->actual], + descmiss_req->buf, + descmiss_req->actual); + request->actual = length; + } else { + /* It should never occures */ + request->status = -ENOMEM; + } + } else { + if (length <= sg_dma_len(s)) { + void *p = phys_to_virt(sg_dma_address(s)); + + memcpy(&((u8 *)p)[request->actual], + descmiss_req->buf, + descmiss_req->actual); + request->actual = length; + } else { + request->status = -ENOMEM; + } + } +} + /** * cdns3_wa2_descmiss_copy_data copy data from internal requests to * request queued by class driver. @@ -488,21 +518,9 @@ static void cdns3_wa2_descmiss_copy_data(struct cdns3_endpoint *priv_ep, chunk_end = descmiss_priv_req->flags & REQUEST_INTERNAL_CH; length = request->actual + descmiss_req->actual; - request->status = descmiss_req->status; - - if (length <= request->length) { - memcpy(&((u8 *)request->buf)[request->actual], - descmiss_req->buf, - descmiss_req->actual); - request->actual = length; - } else { - /* It should never occures */ - request->status = -ENOMEM; - } - + __cdns3_descmiss_copy_data(request, descmiss_req); list_del_init(&descmiss_priv_req->list); - kfree(descmiss_req->buf); cdns3_gadget_ep_free_request(&priv_ep->endpoint, descmiss_req); --priv_ep->wa2_counter; From patchwork Tue Sep 1 08:44:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 11747665 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 34183138A for ; Tue, 1 Sep 2020 08:45:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 145032098B for ; Tue, 1 Sep 2020 08:45:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="VRVP43lz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727061AbgIAIpy (ORCPT ); Tue, 1 Sep 2020 04:45:54 -0400 Received: from mail-am6eur05on2066.outbound.protection.outlook.com ([40.107.22.66]:53473 "EHLO EUR05-AM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726204AbgIAIpx (ORCPT ); Tue, 1 Sep 2020 04:45:53 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QAXEVY2zjbvXthskQXQTC1UM1NJ5CzrhLoi85M7IMT8aBy+1kcw9fAe+RKsd1GTJHgOtERnUhxv7AJ75YsJoonsF7WjhnJWph/qZeo4befhupsPilIOccWx4eJKHbvHUNAg8WaoDodv9m3E6d9CSd/wj7U7oYX+GLjEc/NPR0gE/WDGBVxkBrPKGPNDMLEw0PjkXmRDf/LiiZTTgQewi+HmIxj8Wt3dTzbHuQOxlgFtq6hmWf0e/GGP9XJt/AdXe4EWIV6qd1hvD7vymUgF3ckKc+YU9HkJZPDBgrExByEIDL/ybbC4dYvat5HMl4EUDhEofJAjHiGrSVsJtK0EMUg== 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=4ZWP+pWbo5dw9MlRV94vRk/FzC00vnkuaqDk9g9LEOM=; b=MvK5E1Dsf37DaOomMdeLpwdhnyv5KaMwznhD+2c/wWOIrZyJcFtDuPchTC/Oms5xVEGku9SkDnj+thUCI8z1oa/TyAdVlcO+pXXEcyxwEXb1gZ6F8vJ51tEcs3UbioOxX7kjiCI/2Irm5+NxYI5MevJYKsIMkBfPycLce14SQUehLQaRhlCLWpVi6ajk1GCMqqqMqJeSrFzl2cbujjk7S49L5J1xL5CJDL81zU99o0kiDMCwdfaB19aXPrH8QUbI1WNyjOSyyyaiXBk4qM6yv26V8UgsLIrKuMlUFWp+JSfRQHeGrLGF2fczf0jZCJtiO+P8V+m8sLr8CMT0GMyH9Q== 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=4ZWP+pWbo5dw9MlRV94vRk/FzC00vnkuaqDk9g9LEOM=; b=VRVP43lzr9x9QZptWhMnQf0NLU6Biwatekgtri3UtKx848f3eC/+PMX8ceN7KbSMZc8GG/98KRTdKsYwAZ47Rd8sXcK3UCZPBz4UvZTJYvTr/Ddjgh759cgRZCyrj/QJm9E1Do6ezLbN2GgXQ+c9gxulxg4f5W/RIzrOc8AEtQE= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=nxp.com; Received: from AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) by AM6PR04MB4360.eurprd04.prod.outlook.com (2603:10a6:209:50::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.21; Tue, 1 Sep 2020 08:45:43 +0000 Received: from AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1023:be8d:40c:efe1]) by AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1023:be8d:40c:efe1%3]) with mapi id 15.20.3326.025; Tue, 1 Sep 2020 08:45:43 +0000 From: Peter Chen To: balbi@kernel.org Cc: linux-usb@vger.kernel.org, linux-imx@nxp.com, pawell@cadence.com, rogerq@ti.com, gregkh@linuxfoundation.org, jun.li@nxp.com, Peter Chen Subject: [PATCH 7/8] usb: cdns3: gadget: sg_support is only for DEV_VER_V2 or above Date: Tue, 1 Sep 2020 16:44:53 +0800 Message-Id: <20200901084454.28649-8-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200901084454.28649-1-peter.chen@nxp.com> References: <20200901084454.28649-1-peter.chen@nxp.com> X-ClientProxiedBy: SG2PR06CA0226.apcprd06.prod.outlook.com (2603:1096:4:68::34) To AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from b29397-desktop.ap.freescale.net (119.31.174.67) by SG2PR06CA0226.apcprd06.prod.outlook.com (2603:1096:4:68::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.19 via Frontend Transport; Tue, 1 Sep 2020 08:45:40 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.67] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: d48e86aa-c93a-4608-bb3c-08d84e53697e X-MS-TrafficTypeDiagnostic: AM6PR04MB4360: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1824; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8JuX8Ls5GltJH3LFTB4rAKY7uy7dJRa6q6y4vlTu0KI8oiEQe67HHFC53pSB+C/nX5e6QtJ0ltz4aWbgTbQrgQEC9DHg9qto8CTndK9gUWLxeJmfgiq8S67UBDYVlSV9ZMQYJGIkZm+y03QsFcBhGgrfaWl4MtUwzkpdQIHjdojJwdFbrZGxppRe/owiekWJoW7fsp7j0qQCHebv8pcLG+vnp5qKBZ+MCVAVylUD1A48e3taLKcmDAyXvRAIBaKRlnbzGAYRgSwsbGeIwdhJROMM6qZVIJ54QhciyAtszoyKtCagBL7ykYv3zMimyUpK/qLs/QerUIyaJTSmA391GQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM7PR04MB7157.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(376002)(366004)(136003)(346002)(396003)(39860400002)(956004)(86362001)(26005)(8676002)(8936002)(66946007)(2906002)(36756003)(1076003)(6506007)(6512007)(6916009)(2616005)(316002)(5660300002)(478600001)(4326008)(66556008)(66476007)(83380400001)(186003)(6486002)(44832011)(16526019)(6666004)(52116002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: SK7hVmLVGgb/a2F8Witcf+/k/KiBdqtNbnma5pA8xLpD4AoS3qD8VsFVKt1GEWErMZKyLYqK0wi7brhazDux44qv1477SPmCLLw9/F6Tec+GjJAgnU/APhCTxN2CZVLl7O4cK/jndnExB0NvSS3cN7wrLs6wAAvFq+Tu3CxjidXA3rqk0LvdS3v0Tgp5Cmtj3rg6P5+CUDwx9osH+qdgIsO2plQhOUfLlRbyxg2cQr7KrKP4yGOflELv39cK3/gr9rJa5M3hay0GFZ+jH/hUc+yFKZbeUQAzf4WBW2wLxbPuJGlP84tCwN8Wc+4M9++J5E6b0Nj86jgq1y5un5VHnaMsF5HCRQ0cYIAki/RbXqSTQYVqLw80XOp0nvlAPd1KNL3NxJM5UhCu2iGCu8v0/2zUTM4scmzNouNKKckwB/fBDCzVco36fkZEIPUjjfGQP3AIR7249g5FQGdW6yBK+0ic6oCGGSWT141Z5XTdJLxxjx++zqaSzuR7/m3Pv+H0ZsTJ/IVvJo/RQpEMHXfSfozeDMrwPjr4l7UvJs9KRoQLt1VVJNxCwLQ/Btl9XWPFnZFGhif06O7nmP/mplUSdh518KJqaADDejnMKpPpgIvzAPfCYYPDhByRrFC31zqQjxOWxtAJon9p9+Iy2VtIog== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d48e86aa-c93a-4608-bb3c-08d84e53697e X-MS-Exchange-CrossTenant-AuthSource: AM7PR04MB7157.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2020 08:45:43.5196 (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: +ugF7UE1OLT2UaaiJO1uWkEALBEFHNHsfGCSqlHS/D7z9f2iBZpiAeNWCWzD5M0SuQgZ7DVtYCoUHtDFov33IQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB4360 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The scatter buffer list support earlier than DEV_VER_V2 is not good enough, software can't know well about short transfer for it. Cc: Pawel Laszczak Signed-off-by: Peter Chen --- drivers/usb/cdns3/gadget.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c index 1fd36bc5c6db..82dc362550bf 100644 --- a/drivers/usb/cdns3/gadget.c +++ b/drivers/usb/cdns3/gadget.c @@ -3161,7 +3161,6 @@ static int cdns3_gadget_start(struct cdns3 *cdns) priv_dev->gadget.speed = USB_SPEED_UNKNOWN; priv_dev->gadget.ops = &cdns3_gadget_ops; priv_dev->gadget.name = "usb-ss-gadget"; - priv_dev->gadget.sg_supported = 1; priv_dev->gadget.quirk_avoids_skb_reserve = 1; priv_dev->gadget.irq = cdns->dev_irq; @@ -3200,6 +3199,8 @@ static int cdns3_gadget_start(struct cdns3 *cdns) readl(&priv_dev->regs->usb_cap2)); priv_dev->dev_ver = GET_DEV_BASE_VERSION(priv_dev->dev_ver); + if (priv_dev->dev_ver >= DEV_VER_V2) + priv_dev->gadget.sg_supported = 1; priv_dev->zlp_buf = kzalloc(CDNS3_EP_ZLP_BUF_SIZE, GFP_KERNEL); if (!priv_dev->zlp_buf) { From patchwork Tue Sep 1 08:44:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 11747667 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 EB65C138A for ; Tue, 1 Sep 2020 08:45:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CA99F205CB for ; Tue, 1 Sep 2020 08:45:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="ggv5PhUk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726770AbgIAIp5 (ORCPT ); Tue, 1 Sep 2020 04:45:57 -0400 Received: from mail-am6eur05on2066.outbound.protection.outlook.com ([40.107.22.66]:53473 "EHLO EUR05-AM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726536AbgIAIp4 (ORCPT ); Tue, 1 Sep 2020 04:45:56 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=idMZ1JLtJUBFHZ7G9zj4a9y9PnVYgz6h4FLIf6C+FlYFadiHOBrEx1ixUpiGvaxCWr3EJMyXA2Cmr0NXI5nzOcyaDnhZzxLnYzoBolx+b1J3B91jRswnfyfKkxQ+XIWUx6GnS+ZESQXrlBkLcIcHixMqPLX7+/Meg9WYrWlDpuw3aKwCPB/+1yf2LXZzIIJYWpG4TX+bl6uU2r3k5sJqHoV359fK+FG8IYLdXqCvZ1YiC/5Ih3S5HlEDnMiIDv3eusPDnPluhgU8f09d+zbVTpQNeK9Y2GCkejqUziPhvnItSWq16oITDh+nACFNugw+AX0LGI8dEydp2FI93TiZew== 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=jhy7UcLevaxuqwBgWHcX2TitDFw+S+hOxViz0DqG+P0=; b=eYzdCqrW3UlrNhZJOwanAQrvUnQJ3NXcvJFRYP4WUeDCBMZnbTx15PpYjrKhkcn0euLLNItI8yHX1dFeduHn8KRtbXQwjpLpz4AXFPjC3WjeQCkWryntRZvnLEU8Nj+fq/AaZQEBWvMccSp8PtkOIdLeNbDbJZrdEURTXPvIDl9ixVyMvtWyjW2FxvzL8nQbqikV9Pm10ZPxtwphx12Vc1mwSRQU5QesmN97Vqj0S67AXtxDVRg3v7KEEYEmAwJPTxf2aAdiruPRR/X5MLQlia9lZb4Fzwg5v8QA0rtYbNt8Sw/ZNG+VCf943TMUHsrkDRIyeg5f6KfSeW9P2jXchg== 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=jhy7UcLevaxuqwBgWHcX2TitDFw+S+hOxViz0DqG+P0=; b=ggv5PhUkh/RPtN2h9jrVEqykaf/ytqJ6f2FxRq9BnTjE5tTKsvkbkCXiHrjrjMGTg1PfVPZ7tfK9yIPvFRfL9w2e7QVQXpiAbX0vi5nZSmpDmEwyFmoj+3dBVpaiEu4Z8h36vPsK2WlprTqa+otwNqLjZprv/JeAGbk+p6qZ3EY= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=nxp.com; Received: from AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) by AM6PR04MB4360.eurprd04.prod.outlook.com (2603:10a6:209:50::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.21; Tue, 1 Sep 2020 08:45:46 +0000 Received: from AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1023:be8d:40c:efe1]) by AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1023:be8d:40c:efe1%3]) with mapi id 15.20.3326.025; Tue, 1 Sep 2020 08:45:46 +0000 From: Peter Chen To: balbi@kernel.org Cc: linux-usb@vger.kernel.org, linux-imx@nxp.com, pawell@cadence.com, rogerq@ti.com, gregkh@linuxfoundation.org, jun.li@nxp.com, Peter Chen Subject: [PATCH 8/8] usb: cdns3: gadget: enlarge the TRB ring length Date: Tue, 1 Sep 2020 16:44:54 +0800 Message-Id: <20200901084454.28649-9-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200901084454.28649-1-peter.chen@nxp.com> References: <20200901084454.28649-1-peter.chen@nxp.com> X-ClientProxiedBy: SG2PR06CA0226.apcprd06.prod.outlook.com (2603:1096:4:68::34) To AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from b29397-desktop.ap.freescale.net (119.31.174.67) by SG2PR06CA0226.apcprd06.prod.outlook.com (2603:1096:4:68::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.19 via Frontend Transport; Tue, 1 Sep 2020 08:45:43 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.67] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 958b47d1-b72d-47dd-3483-08d84e536b3f X-MS-TrafficTypeDiagnostic: AM6PR04MB4360: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4125; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DbJMjyZYV4B4QXVGSC9kW1iq0+e2PvDgGpnzgP78hxTCqRHyRkjgp6376UQC9t4vKq1gCk8IXLuafbBYuW/lGWXS54QutMC+n3fKtausBCRkfV+JhLwhFRfb59tVWdkV/9+COijDyEDVPQR219SVhHGqW1VZrHHZtNqEQLPh5gePI3bMjD7qxjp2AoR22lM+wUODhzkXz44Mf335RHi5Kn9hNlKh5XgKhTNZ78reHWFTqrA/KcNxcz6zbfr6lwHunA4BhHHyMUgW5lXumP3yW6EccMsGLLGW42eyzo6wgHdOGZm0rErveet7UmUBpQPnlAgigUeRnnx3Mb0ohQkLymb50RwQLiM5SNEAYzmnpI4gA5O16KQcZXrbKzAcoSelkU1v3oPMh/H1loyGdVpzXQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM7PR04MB7157.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(376002)(366004)(136003)(346002)(396003)(39860400002)(956004)(86362001)(26005)(8676002)(8936002)(66946007)(2906002)(36756003)(1076003)(6506007)(6512007)(6916009)(2616005)(316002)(5660300002)(478600001)(4326008)(66556008)(66476007)(83380400001)(186003)(6486002)(44832011)(16526019)(4744005)(6666004)(52116002)(161623001)(147533002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: VeOvBbOOys9LlnoqOzhW9w+VoUDViXTqs0Ir6bPPE7Um4ieODIC1r0QUHRN0v5ezunEvdBtgPWepA+Bhn/LYRkMP55geerk5u+PQDdrbC1JINRdsdnZQlXzAugUd69JeCSbvR7qwVtyMOUo+NGaHRAXyOpxRLQujuorop3QKky/QD2zfYd4NY0zPAOHClwonA1xqZ1TnSVMLmRxzP4IGOMVfuWPpeAaKhgN+4g0lOJHqOXC2X42ug4nFT/Dm1Z6AFS6Y04bREgANmk8vJCaRC2l5OkPMiBPJRmYN0SLySXfSfAMTpnuM++/AJyXcTx1pBCa34Wxhct9Gs3zHFYRxqmCEaXm+ik62HHSElphMNyIsM7Z2MrOXiNAcBiy0vI/E+XbAM4UJuRT17fh23h7K1UbJoLpRknT/SgvI/yvsTS+gBPcInYXk/vZn7OYBuAj7gNSZwCUns/YsG/n/WE5CMwJDONFXx/X8Ih8NQtJVRYt5bL7wLhOBDJkSkuU7LlkUL2RDvq9H7YBSWKXJnOp0s51T5aKeqj3o1kSive/eQlVioJ6VCoIVrfj0v2lApyWMQG8OD5HbgDHAm7GvkN/J/qWMr5BzTAZEhfQNHoUGuOx5c+v7slUWLOdPvskiz6uRs/i9E55tn0BoctGV2ncuZQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 958b47d1-b72d-47dd-3483-08d84e536b3f X-MS-Exchange-CrossTenant-AuthSource: AM7PR04MB7157.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2020 08:45:46.4528 (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: aiQ61qzGqJ7EC8S6agP7hhlwqsXWqV4lSKcOGzHntx2RT4P17oysL6IrL1AVZN7bM6/6z3qAt4y9QMNaW5Ni0Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB4360 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org At Android ADB and MTP use case, it uses f_fs which supports scatter list, it means one request may need several TRBs for it. Besides, TRB consumes very fast compared to TRB has prepared for above use case, so we need to enlarge the TRB ring length to avoid "no free TRB error". Signed-off-by: Peter Chen --- drivers/usb/cdns3/gadget.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/cdns3/gadget.h b/drivers/usb/cdns3/gadget.h index 9f8bd452847e..1ccecd237530 100644 --- a/drivers/usb/cdns3/gadget.h +++ b/drivers/usb/cdns3/gadget.h @@ -966,7 +966,7 @@ struct cdns3_usb_regs { /* * USBSS-DEV DMA interface. */ -#define TRBS_PER_SEGMENT 40 +#define TRBS_PER_SEGMENT 600 #define ISO_MAX_INTERVAL 10