From patchwork Sun Dec 24 15:38:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 758202 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2084.outbound.protection.outlook.com [40.107.20.84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 27B81610D; Sun, 24 Dec 2023 15:38:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="Kwg0wfts" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SRXFw9IPx3a4wJxvGwD1oliOcrgf8dlUBehwU9r1sUjLZZYh0krg/ZRjAcbfM8wCv6dQGJZCS/nn49YZlqvgk7TItNt+B7EcSdHLajVRCdhtTil2Emp+y6DNlAeUtzWyvRQ3OhdhvqAUFBTY/voXVSrgFjmg4qoMA+W+S0OU4wcMUZl2QDoaBb+vjBbGESle81ZUOdCnfwazebJixz6RNliw/EX5kgA4jdRaUgRnrb3aYh1Lt62sHq8q4Vaf5DRCmWgdjqQSM77gyeu7KV0cGHBhrTYyC7d2glOwOD6FzuoGoh/L+SPml70i1B3E2O5+d2UTK91qy2A93UW2fIMtrA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Zn656wf7jWRtMbaJ0yciWoaFHp398qLzkH39Y1NJk/4=; b=DTM5DGEV2tkKHlRqB7yjlfAvUCBTf5mFyq6/4GmdeLMokcCX/n/fsXOJzGxdvEoWfdE8mBJOtG5i+Z7CTrIYsHTW6XzJGY0CS8r3ZRPDDa2K6RzsNsxGRsUmzh2kEr4XTIB3jtOo9NMG5JmXrBz4OYKtYIQ0WVT/Wk+i0AZLVnjKUtp4YvlA83O6stfmy6iZqjD4IkqyfxH/yH0CGb0cXRXqExgg7q+ZXkNcytC/iUFdIqhgQ/QZv+Em+e1AZeUmx1AbosuNzGm8Fewm79dkd/2s8sIHNqAHtxYmxrpRSl6JC9cArtTZAt/jWU/ftGTtEJ8UGN0KH8PemtpcpRUk+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=Zn656wf7jWRtMbaJ0yciWoaFHp398qLzkH39Y1NJk/4=; b=Kwg0wftscqtc71b/AGuLNbaSUwg7WKUnYpdvvPIFYwRKvAePwcyhBiLURCCPiYHucnlFxA08h1xBMKWrYM9bHl6QhE09/BTPMllmZiJg3FzW2SVnajCxHNPHvPJzL7vBZIRRtJCkn/J6YLBulGCrYXyh88IFDZkBzIk3cVwuBf8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) by DBAPR04MB7285.eurprd04.prod.outlook.com (2603:10a6:10:1ac::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.24; Sun, 24 Dec 2023 15:38:34 +0000 Received: from AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::95f5:5118:258f:ee40]) by AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::95f5:5118:258f:ee40%7]) with mapi id 15.20.7113.026; Sun, 24 Dec 2023 15:38:33 +0000 From: Frank Li To: cugyly@163.com Cc: Frank.Li@nxp.com, a-govindraju@ti.com, gregkh@linuxfoundation.org, imx@lists.linux.dev, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, pawell@cadence.com, peter.chen@kernel.org, rogerq@kernel.org Subject: [PATCH v2 0/4] usb: cdns3: usb uvc iso transfer fix Date: Sun, 24 Dec 2023 10:38:12 -0500 Message-Id: <20231224153816.1664687-1-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: BYAPR11CA0058.namprd11.prod.outlook.com (2603:10b6:a03:80::35) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|DBAPR04MB7285:EE_ X-MS-Office365-Filtering-Correlation-Id: 00ddd024-24ef-4122-b2af-08dc04966336 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LwSF1GBeYwVHRlEmGazblcWv42DrtLXl9839kpDnM27Fhvxs0AeuZH3pmGKevCAN75o2pFHzD+bSQVusJipj31w/VOS6QJCnAvqat49OcDIlGSOAoLTMYwrifkxEIDfDtP63ewCMHlAJqYbUfLiPt0JLmyL0hh/vFPV8FqJfIlPItE99GXKOezq7fAQTtGIcjap4/GC6sJ7ZY78XRbTOJQA5LOcUOeVSZPVbJmc71qzXIY1WeXMKw4P/zZJIRXI2SCMYA67yUpaWLT4Oc7UCQrIhZIfMRBlAL7+5YJcse3qJCvclOqrq50TgcqGsoFK4oJbnaKojFMdXAp6KhJTTeBZd4ogbO8aNRtnB1GxFK8hqpe8OPRkFFrRPnZX1oriXo9ybakPn0t/M39tY4tReL+b30ze1yeHEksCydPeLJzkQXTBOeXovNjHUNF8GuchGOSid6FIh7BqRfd9rotd58uZHcoPsfaOvmm55dooGuOPO2RhSw34TPCVQAJODdrWxim7FBVTnKXY7nRUrIl8NrjMVClKS85s0jr295yrmqeHJpPxkSmrznd6TY7oFocOM0B9eaaorTCkq0/nTRLnWF2HYhawZxqCss1olTQRmoncLUrEMlNAzE3CTR4qKC7FZNZoOqwQ6OBfCYP01dUVp8g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB4838.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(346002)(396003)(136003)(376002)(366004)(39850400004)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(66556008)(66476007)(66946007)(38100700002)(6916009)(316002)(2616005)(1076003)(26005)(4326008)(8936002)(8676002)(478600001)(6486002)(83380400001)(41300700001)(52116002)(2906002)(6506007)(6666004)(6512007)(36756003)(86362001)(38350700005)(5660300002)(1491003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RV5+YNCMOB3qE8DZ+yrt8H3XUiNLX6b4UfhjzXUyqI009r9sKPJw8oK0gkSldKIerafq9YVCdp4jkbRjRmHR/1hsUPMM2kKy4KcSYeJKsObBu4c6mcU3zJTjNNYPi2WueCbLbU7vfXO8AoWVHFAt2Tv3bzegrxnkH9fP7Q4nWDWdhy7VxfMXDtGHqEl4CyRTI5nxS5X8nJYg0x+vGSAk2q2wzu+P0QUhRQMyuGH5awC5ZBdV5nezGnjpSFDPWDGT10s1EbO0GjPA5eJ2ZYzOYlSGF7yQtTWz1nCD9sGrwxpUK35YPp67Xqs/eRiwRSYKJylf9VmJGDdwTlw8wfPl3SkhZ5UtDxMUBnzFyewHJwQ3yzI0Inp1bqYL3XXyFInXOvBaKRW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6qvihjk38+AwIgv6EfT76/BQlss38kQr3Kg7Yzi+H6dDml6/9cbW67l7n2wMTCScT0mDWh7+4w3BLVyf+ivx98F6h/dmPcZ8dA0D8SISmXAAZ4DGio16X4Muj0hxuOw= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 00ddd024-24ef-4122-b2af-08dc04966336 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Dec 2023 15:38:33.8507 (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: xI/OnEkr2WndQJdZ8g3lWq5T/J+GjBTKikiftf5dIfxQRUUy8snRcP3MSEjw3TZlffaLYow7Gbbo1A2b+uSe0A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR04MB7285 Fix UVC ISO transfer since enable sg. The basic there are 4 major problems. Problem 1: Previous code have not conside sg enable case at all for ISO transfer. A typcial UVC package is UVC Header: 8bytes UVC DATA: P(1K,2K... 3K) - 8 So need prepare two TRB for this TD transfer. CHAIN TRB DATA TRB. Hardware will fetch it when get every SOF regardless IN token. So driver have to dupicate it to interval. for example, if interval is 4. driver need duplcate 4 times [CHIAN TRB] [DATA TRB] [CHIAN TRB] [DATA TRB] [CHIAN TRB] [DATA TRB] [CHIAN TRB] [DATA TRB] Hardware have limitation, LINK have to be first one when ISO transfer. another words, the below pattern is *invalidate* [CHIAN TRB] [LINK TRB] [DATA TRB] So need insert some DUMMY LINK TRB when close to end of TRB list. Problem 2: When mult and wMaxburst is not zero, EP hardware config need match EP descriptor, otherwise some data will be lost. for example: if mult is 2 at EP descipor, but hardware EP_CFG is 0, only 1 package will be transfer. If 2k data lost every 3k data. Problem 3: Look like hardware have not fixed cross 4k bound problem at 8QXP for ISO transfer. If dma buffer + length cross 4k bound, DMA will fetch wrong data Problem 4: Latest f_uvc.c pass full speed descriptor, so missed mult and wMaxBurst information, so cdns3 check_config() have not reserve enough internal FIFO memory to ISO endponit. Linux and ardroid UVC test passed. NCM/masstorage test passed. Change from v1 to v2. -Add comment at f_uvc.c Please more detail for each patches. Frank Li (4): usb: cdns3: fix uvc failure work since sg support enabled usb: cdns3: fix iso transfer error when mult is not zero usb: cdns3: Fix uvc fail when DMA cross 4k boundery since sg enabled Revert "usb: gadget: f_uvc: change endpoint allocation in uvc_function_bind()" drivers/usb/cdns3/cdns3-gadget.c | 142 +++++++++++++++++++++------- drivers/usb/cdns3/cdns3-gadget.h | 3 + drivers/usb/gadget/function/f_uvc.c | 18 +++- 3 files changed, 127 insertions(+), 36 deletions(-)