Message ID | 20221115092218.421267-1-pawell@cadence.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2612664wru; Tue, 15 Nov 2022 01:37:04 -0800 (PST) X-Google-Smtp-Source: AA0mqf5WCaGb04n78qLqEMiwVkiPQl9hfmDU4lZP3fPPLzgATxi/BBPxyJ4DQQVLhF/a3eh1a/cw X-Received: by 2002:a63:e748:0:b0:46e:bfec:d611 with SMTP id j8-20020a63e748000000b0046ebfecd611mr15170041pgk.281.1668505023821; Tue, 15 Nov 2022 01:37:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668505023; cv=pass; d=google.com; s=arc-20160816; b=LLYhpjyj2f2ga3yFBbiSOgb9Yj1Yv5XSMXRHyFFyOSouVSARQlWkidqrhR49S/OF5n hw6rWCsw+X9o9yhDz+yr9MpyPeQblS4/d+fmYPILPjjlP1NOeiBD9dV9jk5sfSFtQEms D52VJXabfOyKNC/xMhIStRJlZv+V3z8D0l75NwpGGPvZUWxiDiNYGvibe2SACJl4yExb h3P8wyZagtLUykvlYW8w5O6XVZE32jbp2D50Vbl6sPstyIVRMyqfsWJqq5oJUIcI+A+k 91Yuu7uztpUtVZRIKjeu8D1IXb1AicZBg4c6jqyLJstX/L8u8uoHT4ki/rKkEH+tuyw8 eEJg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=P6X+7Sab9QN1u5n+9Sc9YCvUqJsG8CA8mVhBeJNw0iY=; b=xzXtyliaxyszkv+TnpZdOSxQpR1x3bpTe59ELMtDLzvygq337Z8+NNItGSHr0yODpD gnt3SaorFNcjLFAvFKvV2ihaJJqsX0I9mvLW6CYxgKQAih0pMkkWsQK0bP/fQ3/Xdk8x NtkZxWS9mqFklsuqm6FU3kaqikawOdc18CssmT87cmBoggrlVNHnlm8lfd48c9GA3kpW Y2y2i1FWCywkQSXp2oXGU7T7y+fRc/Mdxn2/hZgDFjmKaGkbagg64dgpVLkVz56IlV4E aavJMoIucY1HqtHPtFs/DJ5OQxYlIGG7GMvc2nTppw2f6dWyMBIZiMNfUsi0XnKnomsh UmDA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@cadence.com header.s=proofpoint header.b=YMjUN6lW; dkim=pass header.i=@cadence.com header.s=selector2 header.b=acMnJbd4; arc=pass (i=1 spf=pass spfdomain=cadence.com dmarc=pass fromdomain=cadence.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cadence.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j6-20020a17090a738600b0020d3631f006si15066031pjg.161.2022.11.15.01.36.49; Tue, 15 Nov 2022 01:37:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@cadence.com header.s=proofpoint header.b=YMjUN6lW; dkim=pass header.i=@cadence.com header.s=selector2 header.b=acMnJbd4; arc=pass (i=1 spf=pass spfdomain=cadence.com dmarc=pass fromdomain=cadence.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cadence.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237819AbiKOJXM (ORCPT <rfc822;zwp10758@gmail.com> + 99 others); Tue, 15 Nov 2022 04:23:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232937AbiKOJW7 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 15 Nov 2022 04:22:59 -0500 Received: from mx0a-0014ca01.pphosted.com (mx0b-0014ca01.pphosted.com [208.86.201.193]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DB4D38A8; Tue, 15 Nov 2022 01:22:55 -0800 (PST) Received: from pps.filterd (m0042333.ppops.net [127.0.0.1]) by mx0b-0014ca01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AF8Lm0O008797; Tue, 15 Nov 2022 01:22:45 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cadence.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=proofpoint; bh=P6X+7Sab9QN1u5n+9Sc9YCvUqJsG8CA8mVhBeJNw0iY=; b=YMjUN6lWJLciDqP38EDVhzsMJ0SENxWhbfyJYYFIT487N4WAw2NwATnyTzzFo2z6gwhd IJPgDQORHtIk77HvAmmuISOWD6zFUQ+tcjgor439DKPGLcM68muKq5ruyvbcG07PI7DD P3r9VvzWdlcz4/QUUtjeHVraft8K8WlNQDblCjkoxyRdQZpRO2d8hC4g/zV+pJXjY5M4 3Z3/XrNMsDetOG1iQuP+XgTaMpWZgO9ltTrCNYWoVz7R+xn1K2/ow3IeAkp/Vlp3U8+h qcQ+akjmgerqCO4tDcOhY8TTebTCwav1jf3AfLXKt6ucQdaqyKCg6q7sPCCFD5ZmcCwh ZQ== Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2168.outbound.protection.outlook.com [104.47.55.168]) by mx0b-0014ca01.pphosted.com (PPS) with ESMTPS id 3kv76n86df-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Nov 2022 01:22:45 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KgxBij5/ribxLIEcUqS9XXDKBZUJw4k5V8gBHszaoZPjN+oWTeowwBfbWwbP4UOWzH12b5oo06pcAEOy4dXJQUwfbnygknLaZyJwp7Uz3Zwof1yD710EnJcWDUqorUaJmXsBWDr6GMyvvSxLhy5/O4X9kb0pPnuKRAOd7PgOwnPSVxNSHbJ2P1NCvkFjKGuKFY4TBR2+6j/nXMXxchHQ9bAw4oPx+hFUgGcwoszG07sbZ3UNnJMt+76slaevhcwlpwpJcE2w6ccp4IKjZQ5NP+aoqNBTbXsIWVi008/5NConM0rojEtFWKvL2cyp+xNuzGUFhWDDa2aP9rlFDPGIYw== 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=P6X+7Sab9QN1u5n+9Sc9YCvUqJsG8CA8mVhBeJNw0iY=; b=Efes+CPHDgL7ZmeYQEMXGkDX6/MdSbMO3fFsogjZNHRYbWXyWYdjm0smEvN1Z0R09GXnYOuKXFe6GB47eScuVOp86KQwb9O4bZMQSuoWoC+l1xNH0TstA6+EFYRdaHxpR4WlHpEEuPeMfe1f84PGfM/HCEdiOafNHW5jY9x131uut8yj7ivvV2t845c9XBJh2+LkZ7jMxIvFC7qn7HFhOlBgXqan+Jq4rl2OWyMuG05k5JKg0ZvZqI7/pwtcrB8IZLzTJ8YuPKFtjaxK7NkEccKJG+SveHdmiBIbWjXaJaR6aayaLC3yV9tYdo7HWKXyMt8H+DdeI68bE1fEcBvzew== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 64.207.220.244) smtp.rcpttodomain=linuxfoundation.org smtp.mailfrom=cadence.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=cadence.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cadence.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=P6X+7Sab9QN1u5n+9Sc9YCvUqJsG8CA8mVhBeJNw0iY=; b=acMnJbd4RRENwlk3EUgPR/FGvhRl0tPT3EU6G2M6MtXq3wM1hdkjgdOHm491B5KnyAqDgDFqdjqI6vvtZ6CkELYYpYrWfujkpF4l6TRVxjNCK7qbxGOCVFdjjQZFxmf8TI2v201CbhzEf9vJRun41NigSge3R0N92sMVIzl/DKE= Received: from BN0PR10CA0008.namprd10.prod.outlook.com (2603:10b6:408:143::27) by BY5PR07MB6920.namprd07.prod.outlook.com (2603:10b6:a03:1e5::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.26; Tue, 15 Nov 2022 09:22:42 +0000 Received: from BN8NAM12FT083.eop-nam12.prod.protection.outlook.com (2603:10b6:408:143:cafe::91) by BN0PR10CA0008.outlook.office365.com (2603:10b6:408:143::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17 via Frontend Transport; Tue, 15 Nov 2022 09:22:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 64.207.220.244) smtp.mailfrom=cadence.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=cadence.com; Received-SPF: Pass (protection.outlook.com: domain of cadence.com designates 64.207.220.244 as permitted sender) receiver=protection.outlook.com; client-ip=64.207.220.244; helo=wcmailrelayl01.cadence.com; pr=C Received: from wcmailrelayl01.cadence.com (64.207.220.244) by BN8NAM12FT083.mail.protection.outlook.com (10.13.182.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5834.6 via Frontend Transport; Tue, 15 Nov 2022 09:22:41 +0000 Received: from maileu3.global.cadence.com (maileu3.cadence.com [10.160.88.99]) by wcmailrelayl01.cadence.com (8.14.7/8.14.4) with ESMTP id 2AF9McOd190442 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=FAIL); Tue, 15 Nov 2022 01:22:39 -0800 X-CrossPremisesHeadersFilteredBySendConnector: maileu3.global.cadence.com Received: from maileu5.global.cadence.com (10.160.110.202) by maileu3.global.cadence.com (10.160.88.99) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Tue, 15 Nov 2022 10:22:25 +0100 Received: from eu-cn01.cadence.com (10.160.89.184) by maileu5.global.cadence.com (10.160.110.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24 via Frontend Transport; Tue, 15 Nov 2022 10:22:25 +0100 Received: from eu-cn01.cadence.com (localhost.localdomain [127.0.0.1]) by eu-cn01.cadence.com (8.14.7/8.14.7) with ESMTP id 2AF9MPFj421416; Tue, 15 Nov 2022 04:22:25 -0500 Received: (from pawell@localhost) by eu-cn01.cadence.com (8.14.7/8.14.7/Submit) id 2AF9MPxa421415; Tue, 15 Nov 2022 04:22:25 -0500 From: Pawel Laszczak <pawell@cadence.com> To: <peter.chen@kernel.org> CC: <gregkh@linuxfoundation.org>, <linux-usb@vger.kernel.org>, <linux-kernel@vger.kernel.org>, Pawel Laszczak <pawell@cadence.com>, <stable@vger.kernel.org> Subject: [PATCH v3] usb: cdnsp: fix issue with ZLP - added TD_SIZE = 1 Date: Tue, 15 Nov 2022 04:22:18 -0500 Message-ID: <20221115092218.421267-1-pawell@cadence.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-OrganizationHeadersPreserved: maileu3.global.cadence.com X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM12FT083:EE_|BY5PR07MB6920:EE_ X-MS-Office365-Filtering-Correlation-Id: 65e4a367-0dc5-46b4-f094-08dac6eaf23f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3MZenNbtMIMP9Z0qZ9WUmcAk/fx5ft00TB10JF7gpuQVo2hX+0KizkBdw1W/l9VnkpnoyRU2Z8qck3DEOoumozXgcw69C/KrFVOdR9pzP3cS2ZjLI/rGz5AV9kedg0HkOhMuqsi5XBi6IYDxLzenPj6VU0tYSlxJVZMYNP0pjdirXhzzktlGHIBpZ38yD40KhkRLecxTKDgJqsz4fL/Hw1eEY0lH+faN07hCb4ThQVIKMvecOAXQ1QNiJKuO2WW5W98gFy8xR1E15MyU8Ba2uGs2qOQJv3Q3DP0LQaOBURCSb+DIhbFAA9xIelSzF1uOQNu8uohZ/vrDQKfl/ZM0a+4mL72ImqWZwi90p6PimKUciYryl/rvvUYqpL8mhmV4RpQ2/GkizG+RSVOaq643HZ2hV1FpesBcKOqtLCXkyIX/g6ID1lnXvPPBkJx1rCC4TXy2Sa0/WRCP+yLiOXUQ9TtbFR85Rc20koYzgS4jOQzUdDWdUCYlbYrqCHdvGQGaKULAZI06YLpabPAOXsdbeCGJeeKDmpSRRu8KyxZUhG+79nlwzzejDazityQOUkrGlxVVh5VFgHQpxgAxKsDpvRA/0NC0Qf6YHGs1Lqg0Na413pRpHNmyvTEO/iLmwrPg/azcYaIKtpVuc6zEJ+8IJ9WivrO8H6OOlBafWWKWPz80khQxPq/ez2kG4d2X7eDEf8XPhwDcnMTefs/1VddZXacKIbBHe/Rtju7omiwV1NRWjYqPYSNk+gWh42QErK+/05bxH6ZPtybZhLqmNo9SuaId26563TwS/cRBYFZivAXjSIvcag/11ptvtP7x3FpE X-Forefront-Antispam-Report: CIP:64.207.220.244;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:wcmailrelayl01.cadence.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230022)(4636009)(396003)(39860400002)(376002)(346002)(136003)(36092001)(451199015)(40470700004)(46966006)(36840700001)(81166007)(82740400003)(36756003)(86362001)(356005)(40480700001)(40460700003)(186003)(426003)(26005)(1076003)(2616005)(6666004)(83380400001)(2906002)(36860700001)(336012)(8676002)(316002)(6916009)(70206006)(82310400005)(478600001)(54906003)(47076005)(4326008)(41300700001)(42186006)(70586007)(8936002)(5660300002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: cadence.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2022 09:22:41.2457 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 65e4a367-0dc5-46b4-f094-08dac6eaf23f X-MS-Exchange-CrossTenant-Id: d36035c5-6ce6-4662-a3dc-e762e61ae4c9 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=d36035c5-6ce6-4662-a3dc-e762e61ae4c9;Ip=[64.207.220.244];Helo=[wcmailrelayl01.cadence.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM12FT083.eop-nam12.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR07MB6920 X-Proofpoint-ORIG-GUID: RaTrsu8B1PUSXWZRtyMQxiBuWgxNsqLk X-Proofpoint-GUID: RaTrsu8B1PUSXWZRtyMQxiBuWgxNsqLk X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-15_04,2022-11-15_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_check_notspam policy=outbound_check score=0 malwarescore=0 lowpriorityscore=0 impostorscore=0 spamscore=0 phishscore=0 mlxlogscore=570 mlxscore=0 adultscore=0 priorityscore=1501 clxscore=1015 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211150066 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749554323970984296?= X-GMAIL-MSGID: =?utf-8?q?1749554323970984296?= |
Series |
[v3] usb: cdnsp: fix issue with ZLP - added TD_SIZE = 1
|
|
Commit Message
Pawel Laszczak
Nov. 15, 2022, 9:22 a.m. UTC
Patch modifies the TD_SIZE in TRB before ZLP TRB.
The TD_SIZE in TRB before ZLP TRB must be set to 1 to force
processing ZLP TRB by controller.
cc: <stable@vger.kernel.org>
Fixes: 3d82904559f4 ("usb: cdnsp: cdns3 Add main part of Cadence USBSSP DRD Driver")
Signed-off-by: Pawel Laszczak <pawell@cadence.com>
---
v2:
- returned value for last TRB must be 0
v3:
- fix issue for request->length > 64KB
drivers/usb/cdns3/cdnsp-ring.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
Comments
> >Hello > > I think the problem is that you want to handle the zero-length trb and the >other trbs in a transaction. but when we calculate the td size,we do not >count the zero-length trb. so maybe we can solve the problem as below: > > > >--- a/drivers/usb/cdns3/cdnsp-ring.c > >+++ b/drivers/usb/cdns3/cdnsp-ring.c > >@@ -1960,7 +1960,7 @@ int cdnsp_queue_bulk_tx(struct cdnsp_device >*pdev, struct cdnsp_request *preq) > > /* Set the TRB length, TD size, and interrupter fields. */ > > remainder = cdnsp_td_remainder(pdev, enqd_len, trb_buff_len, > > full_len, preq, > >- more_trbs_coming); > >+ more_trbs_coming) + (need_zero_pkt ? 1 : 0); > > > > length_field = TRB_LEN(trb_buff_len) | TRB_TD_SIZE(remainder) | > > TRB_INTR_TARGET(0); > Your proposition makes the same thing as the v3 patch but v3 contains the extra parameter. In my opinion the patch with extra parameter is more readably. Did you find something wrong in v3. I have tested it with ECM class which make possible to force ZLP. Thanks Pawel > >On Tue, Nov 15, 2022 at 5:31 PM Pawel Laszczak <pawell@cadence.com ><mailto:pawell@cadence.com> > wrote: > > > Patch modifies the TD_SIZE in TRB before ZLP TRB. > The TD_SIZE in TRB before ZLP TRB must be set to 1 to force > processing ZLP TRB by controller. > > cc: <stable@vger.kernel.org <mailto:stable@vger.kernel.org> > > Fixes: 3d82904559f4 ("usb: cdnsp: cdns3 Add main part of Cadence >USBSSP DRD Driver") > Signed-off-by: Pawel Laszczak <pawell@cadence.com ><mailto:pawell@cadence.com> > > --- > v2: > - returned value for last TRB must be 0 > v3: > - fix issue for request->length > 64KB > > drivers/usb/cdns3/cdnsp-ring.c | 14 ++++++++++---- > 1 file changed, 10 insertions(+), 4 deletions(-) > > diff --git a/drivers/usb/cdns3/cdnsp-ring.c b/drivers/usb/cdns3/cdnsp- >ring.c > index 794e413800ae..86e1141e150f 100644 > --- a/drivers/usb/cdns3/cdnsp-ring.c > +++ b/drivers/usb/cdns3/cdnsp-ring.c > @@ -1763,10 +1763,15 @@ static u32 cdnsp_td_remainder(struct >cdnsp_device *pdev, > int trb_buff_len, > unsigned int td_total_len, > struct cdnsp_request *preq, > - bool more_trbs_coming) > + bool more_trbs_coming, > + bool zlp) > { > u32 maxp, total_packet_count; > > + /* Before ZLP driver needs set TD_SIZE = 1. */ > + if (zlp) > + return 1; > + > /* One TRB with a zero-length data packet. */ > if (!more_trbs_coming || (transferred == 0 && trb_buff_len == 0) >|| > trb_buff_len == td_total_len) > @@ -1960,7 +1965,8 @@ int cdnsp_queue_bulk_tx(struct >cdnsp_device *pdev, struct cdnsp_request *preq) > /* Set the TRB length, TD size, and interrupter fields. */ > remainder = cdnsp_td_remainder(pdev, enqd_len, >trb_buff_len, > full_len, preq, > - more_trbs_coming); > + more_trbs_coming, > + zero_len_trb); > > length_field = TRB_LEN(trb_buff_len) | >TRB_TD_SIZE(remainder) | > TRB_INTR_TARGET(0); > @@ -2025,7 +2031,7 @@ int cdnsp_queue_ctrl_tx(struct >cdnsp_device *pdev, struct cdnsp_request *preq) > > if (preq->request.length > 0) { > remainder = cdnsp_td_remainder(pdev, 0, preq- >>request.length, > - preq->request.length, preq, 1); > + preq->request.length, preq, 1, 0); > > length_field = TRB_LEN(preq->request.length) | > TRB_TD_SIZE(remainder) | TRB_INTR_TARGET(0); > @@ -2225,7 +2231,7 @@ static int cdnsp_queue_isoc_tx(struct >cdnsp_device *pdev, > /* Set the TRB length, TD size, & interrupter fields. */ > remainder = cdnsp_td_remainder(pdev, running_total, > trb_buff_len, td_len, preq, > - more_trbs_coming); > + more_trbs_coming, 0); > > length_field = TRB_LEN(trb_buff_len) | >TRB_INTR_TARGET(0); > > -- > 2.25.1 > >
On Tue, Nov 15, 2022 at 5:22 PM Pawel Laszczak <pawell@cadence.com> wrote: > > Patch modifies the TD_SIZE in TRB before ZLP TRB. > The TD_SIZE in TRB before ZLP TRB must be set to 1 to force > processing ZLP TRB by controller. > > cc: <stable@vger.kernel.org> > Fixes: 3d82904559f4 ("usb: cdnsp: cdns3 Add main part of Cadence USBSSP DRD Driver") > Signed-off-by: Pawel Laszczak <pawell@cadence.com> > --- > v2: > - returned value for last TRB must be 0 > v3: > - fix issue for request->length > 64KB > > drivers/usb/cdns3/cdnsp-ring.c | 14 ++++++++++---- > 1 file changed, 10 insertions(+), 4 deletions(-) > > diff --git a/drivers/usb/cdns3/cdnsp-ring.c b/drivers/usb/cdns3/cdnsp-ring.c > index 794e413800ae..86e1141e150f 100644 > --- a/drivers/usb/cdns3/cdnsp-ring.c > +++ b/drivers/usb/cdns3/cdnsp-ring.c > @@ -1763,10 +1763,15 @@ static u32 cdnsp_td_remainder(struct cdnsp_device *pdev, > int trb_buff_len, > unsigned int td_total_len, > struct cdnsp_request *preq, > - bool more_trbs_coming) > + bool more_trbs_coming, > + bool zlp) > { > u32 maxp, total_packet_count; > > + /* Before ZLP driver needs set TD_SIZE = 1. */ > + if (zlp) > + return 1; > + Pawel, with your change, the TD_SIZE is 1 or 0, but not like the kernel doc defined like below: /* * TD size is the number of max packet sized packets remaining in the TD * (*not* including this TRB). * * Total TD packet count = total_packet_count = * DIV_ROUND_UP(TD size in bytes / wMaxPacketSize) * * Packets transferred up to and including this TRB = packets_transferred = * rounddown(total bytes transferred including this TRB / wMaxPacketSize) * * TD size = total_packet_count - packets_transferred * * It must fit in bits 21:17, so it can't be bigger than 31. * This is taken care of in the TRB_TD_SIZE() macro * * The last TRB in a TD must have the TD size set to zero. */ Peter > /* One TRB with a zero-length data packet. */ > if (!more_trbs_coming || (transferred == 0 && trb_buff_len == 0) || > trb_buff_len == td_total_len) > @@ -1960,7 +1965,8 @@ int cdnsp_queue_bulk_tx(struct cdnsp_device *pdev, struct cdnsp_request *preq) > /* Set the TRB length, TD size, and interrupter fields. */ > remainder = cdnsp_td_remainder(pdev, enqd_len, trb_buff_len, > full_len, preq, > - more_trbs_coming); > + more_trbs_coming, > + zero_len_trb); > > length_field = TRB_LEN(trb_buff_len) | TRB_TD_SIZE(remainder) | > TRB_INTR_TARGET(0); > @@ -2025,7 +2031,7 @@ int cdnsp_queue_ctrl_tx(struct cdnsp_device *pdev, struct cdnsp_request *preq) > > if (preq->request.length > 0) { > remainder = cdnsp_td_remainder(pdev, 0, preq->request.length, > - preq->request.length, preq, 1); > + preq->request.length, preq, 1, 0); > > length_field = TRB_LEN(preq->request.length) | > TRB_TD_SIZE(remainder) | TRB_INTR_TARGET(0); > @@ -2225,7 +2231,7 @@ static int cdnsp_queue_isoc_tx(struct cdnsp_device *pdev, > /* Set the TRB length, TD size, & interrupter fields. */ > remainder = cdnsp_td_remainder(pdev, running_total, > trb_buff_len, td_len, preq, > - more_trbs_coming); > + more_trbs_coming, 0); > > length_field = TRB_LEN(trb_buff_len) | TRB_INTR_TARGET(0); > > -- > 2.25.1 >
>On Tue, Nov 15, 2022 at 5:22 PM Pawel Laszczak <pawell@cadence.com> >wrote: >> >> Patch modifies the TD_SIZE in TRB before ZLP TRB. >> The TD_SIZE in TRB before ZLP TRB must be set to 1 to force processing >> ZLP TRB by controller. >> >> cc: <stable@vger.kernel.org> >> Fixes: 3d82904559f4 ("usb: cdnsp: cdns3 Add main part of Cadence >> USBSSP DRD Driver") >> Signed-off-by: Pawel Laszczak <pawell@cadence.com> >> --- >> v2: >> - returned value for last TRB must be 0 >> v3: >> - fix issue for request->length > 64KB >> >> drivers/usb/cdns3/cdnsp-ring.c | 14 ++++++++++---- >> 1 file changed, 10 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/usb/cdns3/cdnsp-ring.c >> b/drivers/usb/cdns3/cdnsp-ring.c index 794e413800ae..86e1141e150f >> 100644 >> --- a/drivers/usb/cdns3/cdnsp-ring.c >> +++ b/drivers/usb/cdns3/cdnsp-ring.c >> @@ -1763,10 +1763,15 @@ static u32 cdnsp_td_remainder(struct >cdnsp_device *pdev, >> int trb_buff_len, >> unsigned int td_total_len, >> struct cdnsp_request *preq, >> - bool more_trbs_coming) >> + bool more_trbs_coming, >> + bool zlp) >> { >> u32 maxp, total_packet_count; >> >> + /* Before ZLP driver needs set TD_SIZE = 1. */ >> + if (zlp) >> + return 1; >> + > >Pawel, with your change, the TD_SIZE is 1 or 0, but not like the kernel doc >defined like below: Description is not added in kernel doc but is added before "if (zlp)". I will add as last lines in kernel doc the description: * * TD containing ZLP must have TD size set to one in penultimate TRB in TD. */ Will this patch be correct for you then? Pawel > >/* > * TD size is the number of max packet sized packets remaining in the TD > * (*not* including this TRB). > * > * Total TD packet count = total_packet_count = > * DIV_ROUND_UP(TD size in bytes / wMaxPacketSize) > * > * Packets transferred up to and including this TRB = packets_transferred = > * rounddown(total bytes transferred including this TRB / wMaxPacketSize) > * > * TD size = total_packet_count - packets_transferred > * > * It must fit in bits 21:17, so it can't be bigger than 31. > * This is taken care of in the TRB_TD_SIZE() macro > * > * The last TRB in a TD must have the TD size set to zero. > */ > >Peter > >> /* One TRB with a zero-length data packet. */ >> if (!more_trbs_coming || (transferred == 0 && trb_buff_len == 0) || >> trb_buff_len == td_total_len) @@ -1960,7 +1965,8 @@ int >> cdnsp_queue_bulk_tx(struct cdnsp_device *pdev, struct cdnsp_request >*preq) >> /* Set the TRB length, TD size, and interrupter fields. */ >> remainder = cdnsp_td_remainder(pdev, enqd_len, trb_buff_len, >> full_len, preq, >> - more_trbs_coming); >> + more_trbs_coming, >> + zero_len_trb); >> >> length_field = TRB_LEN(trb_buff_len) | TRB_TD_SIZE(remainder) | >> TRB_INTR_TARGET(0); @@ -2025,7 +2031,7 @@ int >> cdnsp_queue_ctrl_tx(struct cdnsp_device *pdev, struct cdnsp_request >> *preq) >> >> if (preq->request.length > 0) { >> remainder = cdnsp_td_remainder(pdev, 0, preq->request.length, >> - preq->request.length, preq, 1); >> + preq->request.length, >> + preq, 1, 0); >> >> length_field = TRB_LEN(preq->request.length) | >> TRB_TD_SIZE(remainder) | >> TRB_INTR_TARGET(0); @@ -2225,7 +2231,7 @@ static int >cdnsp_queue_isoc_tx(struct cdnsp_device *pdev, >> /* Set the TRB length, TD size, & interrupter fields. */ >> remainder = cdnsp_td_remainder(pdev, running_total, >> trb_buff_len, td_len, preq, >> - more_trbs_coming); >> + more_trbs_coming, 0); >> >> length_field = TRB_LEN(trb_buff_len) | >> TRB_INTR_TARGET(0); >> >> -- >> 2.25.1 >>
> Pawel, with your change, the TD_SIZE is 1 or 0, but not like the > kernel doc defined like below: > Please omit my comments, I did not check the code carefully. > /* > * TD size is the number of max packet sized packets remaining in the TD > * (*not* including this TRB). > * With your current change, it may work. But your change conflicts with the xHCI spec that described above. With ZLP, the last useful trb's TD size should be 0, but if it is 0, the controller will be confused. With your change, it makes the code more different with xhci's. Do you consider handling ZLP packet at another TD instead of current at the same TD? Peter > * Total TD packet count = total_packet_count = > * DIV_ROUND_UP(TD size in bytes / wMaxPacketSize) > * > * Packets transferred up to and including this TRB = packets_transferred = > * rounddown(total bytes transferred including this TRB / wMaxPacketSize) > * > * TD size = total_packet_count - packets_transferred > * > * It must fit in bits 21:17, so it can't be bigger than 31. > * This is taken care of in the TRB_TD_SIZE() macro > * > * The last TRB in a TD must have the TD size set to zero. > */ > > Peter > > > /* One TRB with a zero-length data packet. */ > > if (!more_trbs_coming || (transferred == 0 && trb_buff_len == 0) || > > trb_buff_len == td_total_len) > > @@ -1960,7 +1965,8 @@ int cdnsp_queue_bulk_tx(struct cdnsp_device *pdev, struct cdnsp_request *preq) > > /* Set the TRB length, TD size, and interrupter fields. */ > > remainder = cdnsp_td_remainder(pdev, enqd_len, trb_buff_len, > > full_len, preq, > > - more_trbs_coming); > > + more_trbs_coming, > > + zero_len_trb); > > > > length_field = TRB_LEN(trb_buff_len) | TRB_TD_SIZE(remainder) | > > TRB_INTR_TARGET(0); > > @@ -2025,7 +2031,7 @@ int cdnsp_queue_ctrl_tx(struct cdnsp_device *pdev, struct cdnsp_request *preq) > > > > if (preq->request.length > 0) { > > remainder = cdnsp_td_remainder(pdev, 0, preq->request.length, > > - preq->request.length, preq, 1); > > + preq->request.length, preq, 1, 0); > > > > length_field = TRB_LEN(preq->request.length) | > > TRB_TD_SIZE(remainder) | TRB_INTR_TARGET(0); > > @@ -2225,7 +2231,7 @@ static int cdnsp_queue_isoc_tx(struct cdnsp_device *pdev, > > /* Set the TRB length, TD size, & interrupter fields. */ > > remainder = cdnsp_td_remainder(pdev, running_total, > > trb_buff_len, td_len, preq, > > - more_trbs_coming); > > + more_trbs_coming, 0); > > > > length_field = TRB_LEN(trb_buff_len) | TRB_INTR_TARGET(0); > > > > -- > > 2.25.1 > >
> >> Pawel, with your change, the TD_SIZE is 1 or 0, but not like the >> kernel doc defined like below: >> > >Please omit my comments, I did not check the code carefully. > >> /* >> * TD size is the number of max packet sized packets remaining in the >> TD >> * (*not* including this TRB). >> * > >With your current change, it may work. But your change conflicts with the >xHCI spec that described above. >With ZLP, the last useful trb's TD size should be 0, but if it is 0, the controller >will be confused. > >With your change, it makes the code more different with xhci's. Do you >consider handling ZLP packet at another TD instead of current at the same TD >? Yes, I considered it, but to simplify the driver I resigned from handling multiple TD per usb_request. Current solution is simpler and supported by device controller. Additionally, the next ZLP fix must be added for control endpoint for Data Stage and probably it will not work with 2 TDs. Pawel > >> * Total TD packet count = total_packet_count = >> * DIV_ROUND_UP(TD size in bytes / wMaxPacketSize) >> * >> * Packets transferred up to and including this TRB = packets_transferred = >> * rounddown(total bytes transferred including this TRB / >wMaxPacketSize) >> * >> * TD size = total_packet_count - packets_transferred >> * >> * It must fit in bits 21:17, so it can't be bigger than 31. >> * This is taken care of in the TRB_TD_SIZE() macro >> * >> * The last TRB in a TD must have the TD size set to zero. >> */ >> >> Peter >> >> > /* One TRB with a zero-length data packet. */ >> > if (!more_trbs_coming || (transferred == 0 && trb_buff_len == 0) || >> > trb_buff_len == td_total_len) @@ -1960,7 +1965,8 @@ int >> > cdnsp_queue_bulk_tx(struct cdnsp_device *pdev, struct cdnsp_request >*preq) >> > /* Set the TRB length, TD size, and interrupter fields. */ >> > remainder = cdnsp_td_remainder(pdev, enqd_len, trb_buff_len, >> > full_len, preq, >> > - more_trbs_coming); >> > + more_trbs_coming, >> > + zero_len_trb); >> > >> > length_field = TRB_LEN(trb_buff_len) | TRB_TD_SIZE(remainder) >| >> > TRB_INTR_TARGET(0); @@ -2025,7 +2031,7 @@ >> > int cdnsp_queue_ctrl_tx(struct cdnsp_device *pdev, struct >> > cdnsp_request *preq) >> > >> > if (preq->request.length > 0) { >> > remainder = cdnsp_td_remainder(pdev, 0, preq->request.length, >> > - preq->request.length, preq, 1); >> > + preq->request.length, >> > + preq, 1, 0); >> > >> > length_field = TRB_LEN(preq->request.length) | >> > TRB_TD_SIZE(remainder) | >> > TRB_INTR_TARGET(0); @@ -2225,7 +2231,7 @@ static int >cdnsp_queue_isoc_tx(struct cdnsp_device *pdev, >> > /* Set the TRB length, TD size, & interrupter fields. */ >> > remainder = cdnsp_td_remainder(pdev, running_total, >> > trb_buff_len, td_len, preq, >> > - more_trbs_coming); >> > + more_trbs_coming, 0); >> > >> > length_field = TRB_LEN(trb_buff_len) | >> > TRB_INTR_TARGET(0); >> > >> > -- >> > 2.25.1 >> >
On Tue, Nov 15, 2022 at 5:22 PM Pawel Laszczak <pawell@cadence.com> wrote: > > Patch modifies the TD_SIZE in TRB before ZLP TRB. > The TD_SIZE in TRB before ZLP TRB must be set to 1 to force > processing ZLP TRB by controller. > > cc: <stable@vger.kernel.org> > Fixes: 3d82904559f4 ("usb: cdnsp: cdns3 Add main part of Cadence USBSSP DRD Driver") > Signed-off-by: Pawel Laszczak <pawell@cadence.com> Reviewed-by: Peter Chen <peter.chen@kernel.org> Peter > --- > v2: > - returned value for last TRB must be 0 > v3: > - fix issue for request->length > 64KB > > drivers/usb/cdns3/cdnsp-ring.c | 14 ++++++++++---- > 1 file changed, 10 insertions(+), 4 deletions(-) > > diff --git a/drivers/usb/cdns3/cdnsp-ring.c b/drivers/usb/cdns3/cdnsp-ring.c > index 794e413800ae..86e1141e150f 100644 > --- a/drivers/usb/cdns3/cdnsp-ring.c > +++ b/drivers/usb/cdns3/cdnsp-ring.c > @@ -1763,10 +1763,15 @@ static u32 cdnsp_td_remainder(struct cdnsp_device *pdev, > int trb_buff_len, > unsigned int td_total_len, > struct cdnsp_request *preq, > - bool more_trbs_coming) > + bool more_trbs_coming, > + bool zlp) > { > u32 maxp, total_packet_count; > > + /* Before ZLP driver needs set TD_SIZE = 1. */ > + if (zlp) > + return 1; > + > /* One TRB with a zero-length data packet. */ > if (!more_trbs_coming || (transferred == 0 && trb_buff_len == 0) || > trb_buff_len == td_total_len) > @@ -1960,7 +1965,8 @@ int cdnsp_queue_bulk_tx(struct cdnsp_device *pdev, struct cdnsp_request *preq) > /* Set the TRB length, TD size, and interrupter fields. */ > remainder = cdnsp_td_remainder(pdev, enqd_len, trb_buff_len, > full_len, preq, > - more_trbs_coming); > + more_trbs_coming, > + zero_len_trb); > > length_field = TRB_LEN(trb_buff_len) | TRB_TD_SIZE(remainder) | > TRB_INTR_TARGET(0); > @@ -2025,7 +2031,7 @@ int cdnsp_queue_ctrl_tx(struct cdnsp_device *pdev, struct cdnsp_request *preq) > > if (preq->request.length > 0) { > remainder = cdnsp_td_remainder(pdev, 0, preq->request.length, > - preq->request.length, preq, 1); > + preq->request.length, preq, 1, 0); > > length_field = TRB_LEN(preq->request.length) | > TRB_TD_SIZE(remainder) | TRB_INTR_TARGET(0); > @@ -2225,7 +2231,7 @@ static int cdnsp_queue_isoc_tx(struct cdnsp_device *pdev, > /* Set the TRB length, TD size, & interrupter fields. */ > remainder = cdnsp_td_remainder(pdev, running_total, > trb_buff_len, td_len, preq, > - more_trbs_coming); > + more_trbs_coming, 0); > > length_field = TRB_LEN(trb_buff_len) | TRB_INTR_TARGET(0); > > -- > 2.25.1 >
diff --git a/drivers/usb/cdns3/cdnsp-ring.c b/drivers/usb/cdns3/cdnsp-ring.c index 794e413800ae..86e1141e150f 100644 --- a/drivers/usb/cdns3/cdnsp-ring.c +++ b/drivers/usb/cdns3/cdnsp-ring.c @@ -1763,10 +1763,15 @@ static u32 cdnsp_td_remainder(struct cdnsp_device *pdev, int trb_buff_len, unsigned int td_total_len, struct cdnsp_request *preq, - bool more_trbs_coming) + bool more_trbs_coming, + bool zlp) { u32 maxp, total_packet_count; + /* Before ZLP driver needs set TD_SIZE = 1. */ + if (zlp) + return 1; + /* One TRB with a zero-length data packet. */ if (!more_trbs_coming || (transferred == 0 && trb_buff_len == 0) || trb_buff_len == td_total_len) @@ -1960,7 +1965,8 @@ int cdnsp_queue_bulk_tx(struct cdnsp_device *pdev, struct cdnsp_request *preq) /* Set the TRB length, TD size, and interrupter fields. */ remainder = cdnsp_td_remainder(pdev, enqd_len, trb_buff_len, full_len, preq, - more_trbs_coming); + more_trbs_coming, + zero_len_trb); length_field = TRB_LEN(trb_buff_len) | TRB_TD_SIZE(remainder) | TRB_INTR_TARGET(0); @@ -2025,7 +2031,7 @@ int cdnsp_queue_ctrl_tx(struct cdnsp_device *pdev, struct cdnsp_request *preq) if (preq->request.length > 0) { remainder = cdnsp_td_remainder(pdev, 0, preq->request.length, - preq->request.length, preq, 1); + preq->request.length, preq, 1, 0); length_field = TRB_LEN(preq->request.length) | TRB_TD_SIZE(remainder) | TRB_INTR_TARGET(0); @@ -2225,7 +2231,7 @@ static int cdnsp_queue_isoc_tx(struct cdnsp_device *pdev, /* Set the TRB length, TD size, & interrupter fields. */ remainder = cdnsp_td_remainder(pdev, running_total, trb_buff_len, td_len, preq, - more_trbs_coming); + more_trbs_coming, 0); length_field = TRB_LEN(trb_buff_len) | TRB_INTR_TARGET(0);