Message ID | 1666620275-139704-1-git-send-email-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 l7csp573154wru; Mon, 24 Oct 2022 10:37:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7IOi4yBuDeNVh45DQCFU2y1OTjHKPKeL9vmRja+658gazyWDjusA/4rXdoEEF++gX9ROkg X-Received: by 2002:a17:902:eb89:b0:185:33d:cb34 with SMTP id q9-20020a170902eb8900b00185033dcb34mr34323017plg.55.1666633042671; Mon, 24 Oct 2022 10:37:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666633042; cv=pass; d=google.com; s=arc-20160816; b=tC4sGswWqcDc2TQixyu2fSOL8cC6BopYYLYxLugGpINaDcpo5+UhpbrINi+7LXi356 esyL66RTb6uUEg1mfb/SwrVO8elCTrMKR69zy8Rl7qZQCd65yIBr8gPmF3nAP7l/9nPm i+nQk9F3TDugElOyDsttyIZEZ0AmV0ryZ/CkhmGgPbj/TnHlG27Kb3M7l4jPAj9erWzh WwZ3DDgMArVxjKh56WKgBjr0h7pxl29lGyVsZ61FdecDwYxr0pxy68V5Kt1m+XxExqsl /GxW061zEuGNLdVOckVzZJhQGnSYTzua0htw/FZE/8+QOFE3oLvaO1VEjpnavyVqrccK 9Qxg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=/pk38fEZ9U0+nRNaqE9OQAzzGVgDKqaCIE5yNVgKWZU=; b=g/TgNCwj5gzd/mr8sSrvA25G/6ZTMyfPyaKXf/wgnAP1MHdV+TUEMHhy25cMGaZAlU 8Jrtgj+cj2R1fAIleR89yW+OOuKaL/4KmQV7jKdhvM/QPW/g6GvsUbr3xNb/qALauOGJ J5qAL+dzvXJ+wvLWiy5wPm3uGC7Qz96kUN7EwXMr56pjEh0VinB/4lB21r4pwLqP4vW0 NI8gzFlMieiQF77k46pA8YW1l1VgqI9Iq64999hDRz5pIkJVOgKjdeP4/v0ZRtu0mhcy J+ABqtQnU68YnZHxccfEdcT23fok0YqstG6QB4R6ta8f7H3nXaOmz8Ylmpvm0wizhNhA PtOw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@cadence.com header.s=proofpoint header.b=Gbt7rWGO; dkim=pass header.i=@cadence.com header.s=selector2 header.b=03Kw9fEZ; 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 u11-20020a63234b000000b0046aff26fe6dsi63753pgm.498.2022.10.24.10.37.09; Mon, 24 Oct 2022 10:37:22 -0700 (PDT) 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=Gbt7rWGO; dkim=pass header.i=@cadence.com header.s=selector2 header.b=03Kw9fEZ; 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 S233929AbiJXRfQ (ORCPT <rfc822;pwkd43@gmail.com> + 99 others); Mon, 24 Oct 2022 13:35:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233237AbiJXRex (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 24 Oct 2022 13:34:53 -0400 Received: from mx0a-0014ca01.pphosted.com (mx0a-0014ca01.pphosted.com [208.84.65.235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79C1A4DF13; Mon, 24 Oct 2022 09:09:52 -0700 (PDT) Received: from pps.filterd (m0042385.ppops.net [127.0.0.1]) by mx0a-0014ca01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29OCu0pT011978; Mon, 24 Oct 2022 07:04:57 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cadence.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=proofpoint; bh=/pk38fEZ9U0+nRNaqE9OQAzzGVgDKqaCIE5yNVgKWZU=; b=Gbt7rWGO+gU4SbmxkflEj+uVO8bmRjccs3rk0hkDaH8GORI/Rv3LjQ2Dpd55P6QToMRR d41el+UdBN9oRf+IZGPpjQmJeBfhpJ/TNU83WBi1toEzJ+7QMEXdjt8Dn4vfWsX6GM4X 2rK0Yknc6+HzD2O4lzoaIHZXHjLz+G86o3rck9PuFoWri3toHoru2qdRR91eFmDqo+Pz YZQ+TIKRhxEgboKpt6bpGSHQ+p0WaMEhH97T7oRoJ1W44NmjcmMhC0iuptiHqquqGJbV RZ2lNEkp97vrxRnWFG3koBgTcMvinWBB1rU/gx7wbexmbMtkB+I7myGOMBPxWqY2dqIm Og== Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam04lp2049.outbound.protection.outlook.com [104.47.74.49]) by mx0a-0014ca01.pphosted.com (PPS) with ESMTPS id 3kcd30rex2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Oct 2022 07:04:57 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WlHDOm/tLup3L4hgHeUlBNMDV+4ySZ3hW/935urcMP61tBHKgjKcdnjIIEZZZXCpNz8FLt23+Fi3RAx/gNiO7uk8xe5Q4c9sAcYXIXaXICejPTCJu2aZ2pLcPaRNtm2bkLAadBA+zu7bXZyOPweq6arM9ttSK62pQ1kSxPLrroOVLbEkyThtmHSstaU61zPZvXc2FSfmskb0R//tqMNvyH7DRD+/rxbq+8oOs5FBEkDAvujSLYngAKX292mSlJe4suwRHzDdoDacRYKDLuxCCHwIb+X33F7sXU207/Qv5yYOiG/K7SVdSXja3oXi2zVgzD7Xe85c63IxTxDEYjUmsw== 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=/pk38fEZ9U0+nRNaqE9OQAzzGVgDKqaCIE5yNVgKWZU=; b=ksBvzV+/bfv5H+tEufqDiR+z3EgStM459rfPRYV8KKCHvYWB+cuLvLrXBEDGy1SojpgRzRyedBncjOXRer47zxPsTmEFN+hvqdl6RhigT8NimSRgc+r86d+fqnjVy7gTj4XL+o6x+aSpx5oalJJeypH//VnSIoqIVTExziFbm/Fdv5LoRhlZ+6ntuSNul7t1XxEZxjZZwu14d/32NTa0OAnt5oXgwRayvBBgI12pP9T1fq8/tpqSwrzCYC9H0plD5kXfGK1J2+k2Dve2enbf4AHV2jjR7SJSRZAHgNdOtnz6TDzaOYvb8I/lLPms4JntvL1gPB43NWdTbWixECxlbg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 158.140.1.147) smtp.rcpttodomain=vger.kernel.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=/pk38fEZ9U0+nRNaqE9OQAzzGVgDKqaCIE5yNVgKWZU=; b=03Kw9fEZEBOyZYjM7x1+NnFSuC5ZaXB7xMoTs18WuOBN5VJWg8jApeOnG5bC1QN5uekFIbRCW3/qbl4r4zJtF1PkqHz4fzAiIrMrZOaUSEula65jTjORIU3zoV4YpoD5NUhWg2dwGql21qP9f8zNPGj6oZ6LvIchZ9K0I0X+dpg= Received: from MW4P221CA0007.NAMP221.PROD.OUTLOOK.COM (2603:10b6:303:8b::12) by PH8PR07MB9582.namprd07.prod.outlook.com (2603:10b6:510:225::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.29; Mon, 24 Oct 2022 14:04:53 +0000 Received: from MW2NAM12FT010.eop-nam12.prod.protection.outlook.com (2603:10b6:303:8b:cafe::db) by MW4P221CA0007.outlook.office365.com (2603:10b6:303:8b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.26 via Frontend Transport; Mon, 24 Oct 2022 14:04:53 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 158.140.1.147) 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 158.140.1.147 as permitted sender) receiver=protection.outlook.com; client-ip=158.140.1.147; helo=sjmaillnx1.cadence.com; pr=C Received: from sjmaillnx1.cadence.com (158.140.1.147) by MW2NAM12FT010.mail.protection.outlook.com (10.13.180.77) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.10 via Frontend Transport; Mon, 24 Oct 2022 14:04:52 +0000 Received: from maileu4.global.cadence.com (eudvw-maileu4.cadence.com [10.160.110.201]) by sjmaillnx1.cadence.com (8.14.4/8.14.4) with ESMTP id 29OE4o46005187 (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Oct 2022 07:04:51 -0700 Received: from maileu5.global.cadence.com (10.160.110.202) by maileu4.global.cadence.com (10.160.110.201) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Mon, 24 Oct 2022 16:04:49 +0200 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; Mon, 24 Oct 2022 16:04:49 +0200 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 29OE4naR139902; Mon, 24 Oct 2022 10:04:49 -0400 Received: (from pawell@localhost) by eu-cn01.cadence.com (8.14.7/8.14.7/Submit) id 29OE4nnV139899; Mon, 24 Oct 2022 10:04:49 -0400 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 v2] usb: cdnsp: fix issue with ZLP - added TD_SIZE = 1 Date: Mon, 24 Oct 2022 10:04:35 -0400 Message-ID: <1666620275-139704-1-git-send-email-pawell@cadence.com> X-Mailer: git-send-email 2.4.5 MIME-Version: 1.0 Content-Type: text/plain X-CrossPremisesHeadersFilteredBySendConnector: maileu4.global.cadence.com X-OrganizationHeadersPreserved: maileu4.global.cadence.com X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW2NAM12FT010:EE_|PH8PR07MB9582:EE_ X-MS-Office365-Filtering-Correlation-Id: f13f8119-9b9d-481b-52aa-08dab5c8b916 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qWBGWRT2dlEd/SbxcXbSGdqZZMKdvTE3xmC3+4C8AVlpPv6jP0YlA2qWqrcci3RW3/fJ6qBaT8Zx1iEZ17MKSgI7X+B03MV0vx+wBOVO9EyHWJPjCSqfabszxKXCHnwbgbjUBvrf5T5EqwfCEx3TwRTmR1Icsl2j1u0Gmb3nkN9OECIU5msZC2pGam6ukKzSbOdDSiZ3n2qrmMtuY27visZEI5wKx8zlGlxLQfR7OoGfCWsRUvr5ClA0MwhWjG8izJbvuLezkixsK/r1OGcDvkIJScsNkdya69nJoALONYjCsiJiBbjTlVt6ouddv8J/bQ0kqesydqiIQKCxtWsqXD0gCiO6EeeiCD3hlzj25mZA8/r9ww8Kpab1huEXJQ8LQLJsivxSiuWDmUz36ioPjEBuVymLN7ZmKu/jktUMi7nxNFwLn5mKI0Liwj5coeG7wTRhne7Lo16dgPnagH1EmQ5/LXBe96lO583Z0vl+oksDUyfXRfuB5WPJmjCggh0KQfpLn+o9YkvcXgIHToCnTUuod3CGZ2PdHsjMD5lN+jAzr1T2+Z7dEKk65JC/i/hYUzeVfk+LvbiE6TCSDm2JOzd9QHY4wyWe5RbOA3DVXxJMSlvuvFFe5yuAUCmrhqJN6+KjZIpZzAdyhxhy4hAxJVCrwRMCjt/ftVQjAQg+iVIru76Nn1Rh/G69bnSxO6kRQyf5oH2Ek6iC2aH50aziXX11JugPwz5XN1WnpcCjb++qaKP6rWbfoBYvQUm5ykyJoL96h5KAaFsgZRSCAfdyhA== X-Forefront-Antispam-Report: CIP:158.140.1.147;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:sjmaillnx1.cadence.com;PTR:unknown.Cadence.COM;CAT:NONE;SFS:(13230022)(4636009)(136003)(346002)(396003)(39860400002)(376002)(36092001)(451199015)(40470700004)(46966006)(36840700001)(83380400001)(82310400005)(36756003)(2616005)(36860700001)(356005)(47076005)(54906003)(5660300002)(336012)(426003)(70206006)(7636003)(4326008)(186003)(6916009)(82740400003)(86362001)(70586007)(316002)(40480700001)(478600001)(40460700003)(42186006)(2906002)(41300700001)(8936002)(26005)(8676002)(6666004);DIR:OUT;SFP:1101; X-OriginatorOrg: cadence.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Oct 2022 14:04:52.9212 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f13f8119-9b9d-481b-52aa-08dab5c8b916 X-MS-Exchange-CrossTenant-Id: d36035c5-6ce6-4662-a3dc-e762e61ae4c9 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=d36035c5-6ce6-4662-a3dc-e762e61ae4c9;Ip=[158.140.1.147];Helo=[sjmaillnx1.cadence.com] X-MS-Exchange-CrossTenant-AuthSource: MW2NAM12FT010.eop-nam12.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR07MB9582 X-Proofpoint-GUID: RXyMBqr0p2137ijI-LzIFHmLtizwhBRq X-Proofpoint-ORIG-GUID: RXyMBqr0p2137ijI-LzIFHmLtizwhBRq X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-24_04,2022-10-21_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_check_notspam policy=outbound_check score=0 bulkscore=0 clxscore=1015 priorityscore=1501 impostorscore=0 malwarescore=0 adultscore=0 suspectscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 mlxlogscore=488 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210240086 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?1747591409634019349?= X-GMAIL-MSGID: =?utf-8?q?1747591409634019349?= |
Series |
[v2] usb: cdnsp: fix issue with ZLP - added TD_SIZE = 1
|
|
Commit Message
Pawel Laszczak
Oct. 24, 2022, 2:04 p.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>
---
Changelog:
v2:
- returned value for last TRB must be 0
drivers/usb/cdns3/cdnsp-ring.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
Comments
On 22-10-24 10:04:35, Pawel Laszczak 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> > > --- > Changelog: > v2: > - returned value for last TRB must be 0 > > drivers/usb/cdns3/cdnsp-ring.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/cdns3/cdnsp-ring.c b/drivers/usb/cdns3/cdnsp-ring.c > index 04dfcaa08dc4..aa79bce89d8a 100644 > --- a/drivers/usb/cdns3/cdnsp-ring.c > +++ b/drivers/usb/cdns3/cdnsp-ring.c > @@ -1769,8 +1769,13 @@ static u32 cdnsp_td_remainder(struct cdnsp_device *pdev, > > /* One TRB with a zero-length data packet. */ > if (!more_trbs_coming || (transferred == 0 && trb_buff_len == 0) || > - trb_buff_len == td_total_len) > + trb_buff_len == td_total_len) { > + /* Before ZLP driver needs set TD_SIZE=1. */ > + if (more_trbs_coming) > + return 1; > + > return 0; > + } Does that fix the issue you want at bulk transfer, which has zero-length packet at the last packet? It seems not align with your previous fix. Would you mind explaining more? > > maxp = usb_endpoint_maxp(preq->pep->endpoint.desc); > total_packet_count = DIV_ROUND_UP(td_total_len, maxp); > -- > 2.25.1 >
> >On 22-10-24 10:04:35, Pawel Laszczak 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> >> >> --- >> Changelog: >> v2: >> - returned value for last TRB must be 0 >> >> drivers/usb/cdns3/cdnsp-ring.c | 7 ++++++- >> 1 file changed, 6 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/usb/cdns3/cdnsp-ring.c >> b/drivers/usb/cdns3/cdnsp-ring.c index 04dfcaa08dc4..aa79bce89d8a >> 100644 >> --- a/drivers/usb/cdns3/cdnsp-ring.c >> +++ b/drivers/usb/cdns3/cdnsp-ring.c >> @@ -1769,8 +1769,13 @@ static u32 cdnsp_td_remainder(struct >> cdnsp_device *pdev, >> >> /* One TRB with a zero-length data packet. */ >> if (!more_trbs_coming || (transferred == 0 && trb_buff_len == 0) || >> - trb_buff_len == td_total_len) >> + trb_buff_len == td_total_len) { >> + /* Before ZLP driver needs set TD_SIZE=1. */ >> + if (more_trbs_coming) >> + return 1; >> + >> return 0; >> + } > >Does that fix the issue you want at bulk transfer, which has zero-length packet >at the last packet? It seems not align with your previous fix. >Would you mind explaining more? Value returned by function cdnsp_td_remainder is used as TD_SIZE in TRB. The last TRB in TD should have TD_SIZE=0, so trb for ZLP should have set also TD_SIZE=0. If driver set TD_SIZE=0 on before the last one TRB then the controller stops the transfer and ignore trb for ZLP packet. To fix this, the driver in such case must set TD_SIZE = 1 before the last TRB. e.g. TD -> TRB1 transfer_length = 64KB, TD_SIZE =0 TRB2 transfer_length =0, TD_SIZE = 0 - controller will ignore this transfer and stop transfer on previous one TD -> TRB1 transfer_length = 64KB, TD_SIZE =1 TRB2 transfer_length =0, TD_SIZE = 0 - controller will execute this trb and send ZLP As you noticed previously, previous fix for last TRB returned TD_SIZE = 1 in some cases. Previous fix was working correct but was not compliance with controller specification. > >> >> maxp = usb_endpoint_maxp(preq->pep->endpoint.desc); >> total_packet_count = DIV_ROUND_UP(td_total_len, maxp); >> -- >> 2.25.1 >> > >-- > Thanks, Pawel Laszczak
On 22-10-27 08:46:17, Pawel Laszczak wrote: > > > > >On 22-10-24 10:04:35, Pawel Laszczak 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> > >> > >> --- > >> Changelog: > >> v2: > >> - returned value for last TRB must be 0 > >> > >> drivers/usb/cdns3/cdnsp-ring.c | 7 ++++++- > >> 1 file changed, 6 insertions(+), 1 deletion(-) > >> > >> diff --git a/drivers/usb/cdns3/cdnsp-ring.c > >> b/drivers/usb/cdns3/cdnsp-ring.c index 04dfcaa08dc4..aa79bce89d8a > >> 100644 > >> --- a/drivers/usb/cdns3/cdnsp-ring.c > >> +++ b/drivers/usb/cdns3/cdnsp-ring.c > >> @@ -1769,8 +1769,13 @@ static u32 cdnsp_td_remainder(struct > >> cdnsp_device *pdev, > >> > >> /* One TRB with a zero-length data packet. */ > >> if (!more_trbs_coming || (transferred == 0 && trb_buff_len == 0) || > >> - trb_buff_len == td_total_len) > >> + trb_buff_len == td_total_len) { > >> + /* Before ZLP driver needs set TD_SIZE=1. */ > >> + if (more_trbs_coming) > >> + return 1; > >> + > >> return 0; > >> + } > > > >Does that fix the issue you want at bulk transfer, which has zero-length packet > >at the last packet? It seems not align with your previous fix. > >Would you mind explaining more? > > Value returned by function cdnsp_td_remainder is used > as TD_SIZE in TRB. > > The last TRB in TD should have TD_SIZE=0, so trb for ZLP should have > set also TD_SIZE=0. If driver set TD_SIZE=0 on before the last one > TRB then the controller stops the transfer and ignore trb for ZLP packet. > > To fix this, the driver in such case must set TD_SIZE = 1 > before the last TRB. if (!more_trbs_coming || (transferred == 0 && trb_buff_len == 0) || - trb_buff_len == td_total_len) + trb_buff_len == td_total_len) { + /* Before ZLP driver needs set TD_SIZE=1. */ + if (more_trbs_coming) + return 1; + return 0; + } How your above fix could return TD_SIZE as 1 for last non-ZLP TRB? Which conditions are satisfied? Peter > e.g. > > TD -> TRB1 transfer_length = 64KB, TD_SIZE =0 > TRB2 transfer_length =0, TD_SIZE = 0 - controller will > ignore this transfer and stop transfer on previous one > > TD -> TRB1 transfer_length = 64KB, TD_SIZE =1 > TRB2 transfer_length =0, TD_SIZE = 0 - controller will > execute this trb and send ZLP > > As you noticed previously, previous fix for last TRB returned > TD_SIZE = 1 in some cases. > Previous fix was working correct but was not compliance with > controller specification. > > > > >> > >> maxp = usb_endpoint_maxp(preq->pep->endpoint.desc); > >> total_packet_count = DIV_ROUND_UP(td_total_len, maxp); > >> -- > >> 2.25.1 > >> > > > >-- > > > > Thanks, > Pawel Laszczak
> > >On 22-10-27 08:46:17, Pawel Laszczak wrote: >> >> > >> >On 22-10-24 10:04:35, Pawel Laszczak 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> >> >> >> >> --- >> >> Changelog: >> >> v2: >> >> - returned value for last TRB must be 0 >> >> >> >> drivers/usb/cdns3/cdnsp-ring.c | 7 ++++++- >> >> 1 file changed, 6 insertions(+), 1 deletion(-) >> >> >> >> diff --git a/drivers/usb/cdns3/cdnsp-ring.c >> >> b/drivers/usb/cdns3/cdnsp-ring.c index 04dfcaa08dc4..aa79bce89d8a >> >> 100644 >> >> --- a/drivers/usb/cdns3/cdnsp-ring.c >> >> +++ b/drivers/usb/cdns3/cdnsp-ring.c >> >> @@ -1769,8 +1769,13 @@ static u32 cdnsp_td_remainder(struct >> >> cdnsp_device *pdev, >> >> >> >> /* One TRB with a zero-length data packet. */ >> >> if (!more_trbs_coming || (transferred == 0 && trb_buff_len == 0) || >> >> - trb_buff_len == td_total_len) >> >> + trb_buff_len == td_total_len) { >> >> + /* Before ZLP driver needs set TD_SIZE=1. */ >> >> + if (more_trbs_coming) >> >> + return 1; >> >> + >> >> return 0; >> >> + } >> > >> >Does that fix the issue you want at bulk transfer, which has >> >zero-length packet at the last packet? It seems not align with your previous >fix. >> >Would you mind explaining more? >> >> Value returned by function cdnsp_td_remainder is used as TD_SIZE in >> TRB. >> >> The last TRB in TD should have TD_SIZE=0, so trb for ZLP should have >> set also TD_SIZE=0. If driver set TD_SIZE=0 on before the last one TRB >> then the controller stops the transfer and ignore trb for ZLP packet. >> >> To fix this, the driver in such case must set TD_SIZE = 1 before the >> last TRB. > > if (!more_trbs_coming || (transferred == 0 && trb_buff_len == 0) || > - trb_buff_len == td_total_len) > + trb_buff_len == td_total_len) { > + /* Before ZLP driver needs set TD_SIZE=1. */ > + if (more_trbs_coming) > + return 1; > + > return 0; > + } > >How your above fix could return TD_SIZE as 1 for last non-ZLP TRB? >Which conditions are satisfied? For last non-ZLP TRB TD_SIZE should be 0 or 1. We have three casess: 1. TRB1 - length > 1 TRb2 - ZLP In this case TRB1 should have set TD_SIZE = 1. In this case the condition if (more_trbs_coming) return 1; returns TD_SIZE=1. In this case more_trb_comming for TRB1 is 1 and for TRB2 is 0 2. TRB1 - length >1 and we don't except ZLP In this case TD_SIZE should be set to 0 for TRB1 and function returns 0, more_trbs_comming for TRB1 will be set to 0. 3 More TRBs without ZLP: e.g. TRB1 - length > 0, more_trbs_comming = 1 - TD_SIZE > 0 TRB2 - length > 0, more_trbs_comming = 1 - TD_SIZE > 0 TRB3 - length >= 0, more_trbs_comming = 0 - TD_SIZE = 0 Pawel > >Peter > >> e.g. >> >> TD -> TRB1 transfer_length = 64KB, TD_SIZE =0 >> TRB2 transfer_length =0, TD_SIZE = 0 - controller will >> ignore this transfer and stop transfer on previous one >> >> TD -> TRB1 transfer_length = 64KB, TD_SIZE =1 >> TRB2 transfer_length =0, TD_SIZE = 0 - controller will >> execute this trb and send ZLP >> >> As you noticed previously, previous fix for last TRB returned TD_SIZE >> = 1 in some cases. >> Previous fix was working correct but was not compliance with >> controller specification. >> >> > >> >> >> >> maxp = usb_endpoint_maxp(preq->pep->endpoint.desc); >> >> total_packet_count = DIV_ROUND_UP(td_total_len, maxp); >> >> -- >> >> 2.25.1 >> >> >> > >> >-- >> > >> >> Thanks, >> Pawel Laszczak > >-- > >Thanks, >Peter Chen Regards, Pawel Laszczak
On Mon, Nov 7, 2022 at 1:39 PM Pawel Laszczak <pawell@cadence.com> wrote: > > > > > > >On 22-10-27 08:46:17, Pawel Laszczak wrote: > >> > >> > > >> >On 22-10-24 10:04:35, Pawel Laszczak 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> > >> >> > >> >> --- > >> >> Changelog: > >> >> v2: > >> >> - returned value for last TRB must be 0 > >> >> > >> >> drivers/usb/cdns3/cdnsp-ring.c | 7 ++++++- > >> >> 1 file changed, 6 insertions(+), 1 deletion(-) > >> >> > >> >> diff --git a/drivers/usb/cdns3/cdnsp-ring.c > >> >> b/drivers/usb/cdns3/cdnsp-ring.c index 04dfcaa08dc4..aa79bce89d8a > >> >> 100644 > >> >> --- a/drivers/usb/cdns3/cdnsp-ring.c > >> >> +++ b/drivers/usb/cdns3/cdnsp-ring.c > >> >> @@ -1769,8 +1769,13 @@ static u32 cdnsp_td_remainder(struct > >> >> cdnsp_device *pdev, > >> >> > >> >> /* One TRB with a zero-length data packet. */ > >> >> if (!more_trbs_coming || (transferred == 0 && trb_buff_len == 0) || > >> >> - trb_buff_len == td_total_len) > >> >> + trb_buff_len == td_total_len) { > >> >> + /* Before ZLP driver needs set TD_SIZE=1. */ > >> >> + if (more_trbs_coming) > >> >> + return 1; > >> >> + > >> >> return 0; > >> >> + } > >> > > >> >Does that fix the issue you want at bulk transfer, which has > >> >zero-length packet at the last packet? It seems not align with your previous > >fix. > >> >Would you mind explaining more? > >> > >> Value returned by function cdnsp_td_remainder is used as TD_SIZE in > >> TRB. > >> > >> The last TRB in TD should have TD_SIZE=0, so trb for ZLP should have > >> set also TD_SIZE=0. If driver set TD_SIZE=0 on before the last one TRB > >> then the controller stops the transfer and ignore trb for ZLP packet. > >> > >> To fix this, the driver in such case must set TD_SIZE = 1 before the > >> last TRB. > > > > if (!more_trbs_coming || (transferred == 0 && trb_buff_len == 0) || > > - trb_buff_len == td_total_len) > > + trb_buff_len == td_total_len) { > > + /* Before ZLP driver needs set TD_SIZE=1. */ > > + if (more_trbs_coming) > > + return 1; > > + > > return 0; > > + } > > > >How your above fix could return TD_SIZE as 1 for last non-ZLP TRB? > >Which conditions are satisfied? > > For last non-ZLP TRB TD_SIZE should be 0 or 1. > > We have three casess: > 1. > TRB1 - length > 1 > TRb2 - ZLP > > In this case TRB1 should have set TD_SIZE = 1. In this case the condition > if (more_trbs_coming) > return 1; > > returns TD_SIZE=1. In this case more_trb_comming for TRB1 is 1 and for TRB2 is 0 > This one is my question. How below condition is true for your case 1: if (!more_trbs_coming || (transferred == 0 && trb_buff_len == 0) || trb_buff_len == td_total_len) Peter > > 2. > TRB1 - length >1 and we don't except ZLP > > In this case TD_SIZE should be set to 0 for TRB1 and function returns 0, more_trbs_comming for TRB1 will be set to 0. > > 3 More TRBs without ZLP: > e.g. > TRB1 - length > 0, more_trbs_comming = 1 - TD_SIZE > 0 > TRB2 - length > 0, more_trbs_comming = 1 - TD_SIZE > 0 > TRB3 - length >= 0, more_trbs_comming = 0 - TD_SIZE = 0 > > Pawel > > > > >Peter > > > >> e.g. > >> > >> TD -> TRB1 transfer_length = 64KB, TD_SIZE =0 > >> TRB2 transfer_length =0, TD_SIZE = 0 - controller will > >> ignore this transfer and stop transfer on previous one > >> > >> TD -> TRB1 transfer_length = 64KB, TD_SIZE =1 > >> TRB2 transfer_length =0, TD_SIZE = 0 - controller will > >> execute this trb and send ZLP > >> > >> As you noticed previously, previous fix for last TRB returned TD_SIZE > >> = 1 in some cases. > >> Previous fix was working correct but was not compliance with > >> controller specification. > >> > >> > > >> >> > >> >> maxp = usb_endpoint_maxp(preq->pep->endpoint.desc); > >> >> total_packet_count = DIV_ROUND_UP(td_total_len, maxp); > >> >> -- > >> >> 2.25.1 > >> >> > >> > > >> >-- > >> > > >> > >> Thanks, > >> Pawel Laszczak > > > >-- > > > >Thanks, > >Peter Chen > > Regards, > Pawel Laszczak
>On Mon, Nov 7, 2022 at 1:39 PM Pawel Laszczak <pawell@cadence.com> >wrote: >> >> > >> > >> >On 22-10-27 08:46:17, Pawel Laszczak wrote: >> >> >> >> > >> >> >On 22-10-24 10:04:35, Pawel Laszczak 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> >> >> >> >> >> >> --- >> >> >> Changelog: >> >> >> v2: >> >> >> - returned value for last TRB must be 0 >> >> >> >> >> >> drivers/usb/cdns3/cdnsp-ring.c | 7 ++++++- >> >> >> 1 file changed, 6 insertions(+), 1 deletion(-) >> >> >> >> >> >> diff --git a/drivers/usb/cdns3/cdnsp-ring.c >> >> >> b/drivers/usb/cdns3/cdnsp-ring.c index >> >> >> 04dfcaa08dc4..aa79bce89d8a >> >> >> 100644 >> >> >> --- a/drivers/usb/cdns3/cdnsp-ring.c >> >> >> +++ b/drivers/usb/cdns3/cdnsp-ring.c >> >> >> @@ -1769,8 +1769,13 @@ static u32 cdnsp_td_remainder(struct >> >> >> cdnsp_device *pdev, >> >> >> >> >> >> /* One TRB with a zero-length data packet. */ >> >> >> if (!more_trbs_coming || (transferred == 0 && trb_buff_len == 0) || >> >> >> - trb_buff_len == td_total_len) >> >> >> + trb_buff_len == td_total_len) { >> >> >> + /* Before ZLP driver needs set TD_SIZE=1. */ >> >> >> + if (more_trbs_coming) >> >> >> + return 1; >> >> >> + >> >> >> return 0; >> >> >> + } >> >> > >> >> >Does that fix the issue you want at bulk transfer, which has >> >> >zero-length packet at the last packet? It seems not align with >> >> >your previous >> >fix. >> >> >Would you mind explaining more? >> >> >> >> Value returned by function cdnsp_td_remainder is used as TD_SIZE in >> >> TRB. >> >> >> >> The last TRB in TD should have TD_SIZE=0, so trb for ZLP should >> >> have set also TD_SIZE=0. If driver set TD_SIZE=0 on before the last >> >> one TRB then the controller stops the transfer and ignore trb for ZLP >packet. >> >> >> >> To fix this, the driver in such case must set TD_SIZE = 1 before >> >> the last TRB. >> > >> > if (!more_trbs_coming || (transferred == 0 && trb_buff_len == 0) || >> > - trb_buff_len == td_total_len) >> > + trb_buff_len == td_total_len) { >> > + /* Before ZLP driver needs set TD_SIZE=1. */ >> > + if (more_trbs_coming) >> > + return 1; >> > + >> > return 0; >> > + } >> > >> >How your above fix could return TD_SIZE as 1 for last non-ZLP TRB? >> >Which conditions are satisfied? >> >> For last non-ZLP TRB TD_SIZE should be 0 or 1. >> >> We have three casess: >> 1. >> TRB1 - length > 1 >> TRb2 - ZLP >> >> In this case TRB1 should have set TD_SIZE = 1. In this case the condition >> if (more_trbs_coming) >> return 1; >> >> returns TD_SIZE=1. In this case more_trb_comming for TRB1 is 1 and for >> TRB2 is 0 >> > >This one is my question. How below condition is true for your case 1: > > if (!more_trbs_coming || (transferred == 0 && trb_buff_len == 0) || > trb_buff_len == td_total_len) For TRB1: more_trbs_coming = true transferred == 0 && trb_buff_len == 0 - false - it does not matter in this case trb_buff_len == td_total_len - true so whole condition is true. Because more_trb_comming = true so: if (more_trbs_coming) return 1; returns TD_SIZE = 1 For TRB2 - ZLP: more_trbs_coming = false transferred == 0 && trb_buff_len == 0 - false - it does not matter in this case trb_buff_len == td_total_len - true Because more_trb_comming = false so function returns TD_SIZE = 0 for last ZLP trb. Pawel > >Peter > > > >> >> 2. >> TRB1 - length >1 and we don't except ZLP >> >> In this case TD_SIZE should be set to 0 for TRB1 and function returns 0, >more_trbs_comming for TRB1 will be set to 0. >> >> 3 More TRBs without ZLP: >> e.g. >> TRB1 - length > 0, more_trbs_comming = 1 - TD_SIZE > 0 >> TRB2 - length > 0, more_trbs_comming = 1 - TD_SIZE > 0 >> TRB3 - length >= 0, more_trbs_comming = 0 - TD_SIZE = 0 >> >> Pawel >> >> > >> >Peter >> > >> >> e.g. >> >> >> >> TD -> TRB1 transfer_length = 64KB, TD_SIZE =0 >> >> TRB2 transfer_length =0, TD_SIZE = 0 - controller will >> >> ignore this transfer and stop transfer on previous >> >> one >> >> >> >> TD -> TRB1 transfer_length = 64KB, TD_SIZE =1 >> >> TRB2 transfer_length =0, TD_SIZE = 0 - controller will >> >> execute this trb and send ZLP >> >> >> >> As you noticed previously, previous fix for last TRB returned >> >> TD_SIZE = 1 in some cases. >> >> Previous fix was working correct but was not compliance with >> >> controller specification. >> >> >> >> > >> >> >> >> >> >> maxp = usb_endpoint_maxp(preq->pep->endpoint.desc); >> >> >> total_packet_count = DIV_ROUND_UP(td_total_len, maxp); >> >> >> -- >> >> >> 2.25.1 >> >> >> >> >> > >> >> >-- >> >> > >> >> >> >> Thanks, >> >> Pawel Laszczak >> > >> >-- >> > >> >Thanks, >> >Peter Chen >> >> Regards, >> Pawel Laszczak
On Thu, Nov 10, 2022 at 1:38 PM Pawel Laszczak <pawell@cadence.com> wrote: > > >On Mon, Nov 7, 2022 at 1:39 PM Pawel Laszczak <pawell@cadence.com> > >wrote: > >> > >> > > >> > > >> >On 22-10-27 08:46:17, Pawel Laszczak wrote: > >> >> > >> >> > > >> >> >On 22-10-24 10:04:35, Pawel Laszczak 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> > >> >> >> > >> >> >> --- > >> >> >> Changelog: > >> >> >> v2: > >> >> >> - returned value for last TRB must be 0 > >> >> >> > >> >> >> drivers/usb/cdns3/cdnsp-ring.c | 7 ++++++- > >> >> >> 1 file changed, 6 insertions(+), 1 deletion(-) > >> >> >> > >> >> >> diff --git a/drivers/usb/cdns3/cdnsp-ring.c > >> >> >> b/drivers/usb/cdns3/cdnsp-ring.c index > >> >> >> 04dfcaa08dc4..aa79bce89d8a > >> >> >> 100644 > >> >> >> --- a/drivers/usb/cdns3/cdnsp-ring.c > >> >> >> +++ b/drivers/usb/cdns3/cdnsp-ring.c > >> >> >> @@ -1769,8 +1769,13 @@ static u32 cdnsp_td_remainder(struct > >> >> >> cdnsp_device *pdev, > >> >> >> > >> >> >> /* One TRB with a zero-length data packet. */ > >> >> >> if (!more_trbs_coming || (transferred == 0 && trb_buff_len == 0) || > >> >> >> - trb_buff_len == td_total_len) > >> >> >> + trb_buff_len == td_total_len) { > >> >> >> + /* Before ZLP driver needs set TD_SIZE=1. */ > >> >> >> + if (more_trbs_coming) > >> >> >> + return 1; > >> >> >> + > >> >> >> return 0; > >> >> >> + } > >> >> > > >> >> >Does that fix the issue you want at bulk transfer, which has > >> >> >zero-length packet at the last packet? It seems not align with > >> >> >your previous > >> >fix. > >> >> >Would you mind explaining more? > >> >> > >> >> Value returned by function cdnsp_td_remainder is used as TD_SIZE in > >> >> TRB. > >> >> > >> >> The last TRB in TD should have TD_SIZE=0, so trb for ZLP should > >> >> have set also TD_SIZE=0. If driver set TD_SIZE=0 on before the last > >> >> one TRB then the controller stops the transfer and ignore trb for ZLP > >packet. > >> >> > >> >> To fix this, the driver in such case must set TD_SIZE = 1 before > >> >> the last TRB. > >> > > >> > if (!more_trbs_coming || (transferred == 0 && trb_buff_len == 0) || > >> > - trb_buff_len == td_total_len) > >> > + trb_buff_len == td_total_len) { > >> > + /* Before ZLP driver needs set TD_SIZE=1. */ > >> > + if (more_trbs_coming) > >> > + return 1; > >> > + > >> > return 0; > >> > + } > >> > > >> >How your above fix could return TD_SIZE as 1 for last non-ZLP TRB? > >> >Which conditions are satisfied? > >> > >> For last non-ZLP TRB TD_SIZE should be 0 or 1. > >> > >> We have three casess: > >> 1. > >> TRB1 - length > 1 > >> TRb2 - ZLP > >> > >> In this case TRB1 should have set TD_SIZE = 1. In this case the condition > >> if (more_trbs_coming) > >> return 1; > >> > >> returns TD_SIZE=1. In this case more_trb_comming for TRB1 is 1 and for > >> TRB2 is 0 > >> > > > >This one is my question. How below condition is true for your case 1: > > > > if (!more_trbs_coming || (transferred == 0 && trb_buff_len == 0) || > > trb_buff_len == td_total_len) > > For TRB1: > more_trbs_coming = true > transferred == 0 && trb_buff_len == 0 - false - it does not matter in this case > trb_buff_len == td_total_len - true Why trb_buff_len equals to td_total_length? Considering the bulk transfer with request length larger than 64KB. Peter > so whole condition is true. > > Because more_trb_comming = true so: > if (more_trbs_coming) > return 1; > returns TD_SIZE = 1 > > For TRB2 - ZLP: > more_trbs_coming = false > transferred == 0 && trb_buff_len == 0 - false - it does not matter in this case > trb_buff_len == td_total_len - true > > Because more_trb_comming = false so function returns TD_SIZE = 0 for last ZLP trb. > > Pawel
>On Thu, Nov 10, 2022 at 1:38 PM Pawel Laszczak <pawell@cadence.com> >wrote: >> >> >On Mon, Nov 7, 2022 at 1:39 PM Pawel Laszczak <pawell@cadence.com> >> >wrote: >> >> >> >> > >> >> > >> >> >On 22-10-27 08:46:17, Pawel Laszczak wrote: >> >> >> >> >> >> > >> >> >> >On 22-10-24 10:04:35, Pawel Laszczak 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> >> >> >> >> >> >> >> >> --- >> >> >> >> Changelog: >> >> >> >> v2: >> >> >> >> - returned value for last TRB must be 0 >> >> >> >> >> >> >> >> drivers/usb/cdns3/cdnsp-ring.c | 7 ++++++- >> >> >> >> 1 file changed, 6 insertions(+), 1 deletion(-) >> >> >> >> >> >> >> >> diff --git a/drivers/usb/cdns3/cdnsp-ring.c >> >> >> >> b/drivers/usb/cdns3/cdnsp-ring.c index >> >> >> >> 04dfcaa08dc4..aa79bce89d8a >> >> >> >> 100644 >> >> >> >> --- a/drivers/usb/cdns3/cdnsp-ring.c >> >> >> >> +++ b/drivers/usb/cdns3/cdnsp-ring.c >> >> >> >> @@ -1769,8 +1769,13 @@ static u32 cdnsp_td_remainder(struct >> >> >> >> cdnsp_device *pdev, >> >> >> >> >> >> >> >> /* One TRB with a zero-length data packet. */ >> >> >> >> if (!more_trbs_coming || (transferred == 0 && trb_buff_len == 0) >|| >> >> >> >> - trb_buff_len == td_total_len) >> >> >> >> + trb_buff_len == td_total_len) { >> >> >> >> + /* Before ZLP driver needs set TD_SIZE=1. */ >> >> >> >> + if (more_trbs_coming) >> >> >> >> + return 1; >> >> >> >> + >> >> >> >> return 0; >> >> >> >> + } >> >> >> > >> >> >> >Does that fix the issue you want at bulk transfer, which has >> >> >> >zero-length packet at the last packet? It seems not align with >> >> >> >your previous >> >> >fix. >> >> >> >Would you mind explaining more? >> >> >> >> >> >> Value returned by function cdnsp_td_remainder is used as TD_SIZE >> >> >> in TRB. >> >> >> >> >> >> The last TRB in TD should have TD_SIZE=0, so trb for ZLP should >> >> >> have set also TD_SIZE=0. If driver set TD_SIZE=0 on before the >> >> >> last one TRB then the controller stops the transfer and ignore >> >> >> trb for ZLP >> >packet. >> >> >> >> >> >> To fix this, the driver in such case must set TD_SIZE = 1 before >> >> >> the last TRB. >> >> > >> >> > if (!more_trbs_coming || (transferred == 0 && trb_buff_len == 0) >|| >> >> > - trb_buff_len == td_total_len) >> >> > + trb_buff_len == td_total_len) { >> >> > + /* Before ZLP driver needs set TD_SIZE=1. */ >> >> > + if (more_trbs_coming) >> >> > + return 1; >> >> > + >> >> > return 0; >> >> > + } >> >> > >> >> >How your above fix could return TD_SIZE as 1 for last non-ZLP TRB? >> >> >Which conditions are satisfied? >> >> >> >> For last non-ZLP TRB TD_SIZE should be 0 or 1. >> >> >> >> We have three casess: >> >> 1. >> >> TRB1 - length > 1 >> >> TRb2 - ZLP >> >> >> >> In this case TRB1 should have set TD_SIZE = 1. In this case the condition >> >> if (more_trbs_coming) >> >> return 1; >> >> >> >> returns TD_SIZE=1. In this case more_trb_comming for TRB1 is 1 and >> >> for >> >> TRB2 is 0 >> >> >> > >> >This one is my question. How below condition is true for your case 1: >> > >> > if (!more_trbs_coming || (transferred == 0 && trb_buff_len == 0) || >> > trb_buff_len == td_total_len) >> >> For TRB1: >> more_trbs_coming = true >> transferred == 0 && trb_buff_len == 0 - false - it does not matter in this >case >> trb_buff_len == td_total_len - true > >Why trb_buff_len equals to td_total_length? Considering the bulk transfer >with request length larger than 64KB. > You have right, there might still be a problem with ZLP. I've posted the v3 implemented a little differently. Thanks Pawel > >> so whole condition is true. >> >> Because more_trb_comming = true so: >> if (more_trbs_coming) >> return 1; >> returns TD_SIZE = 1 >> >> For TRB2 - ZLP: >> more_trbs_coming = false >> transferred == 0 && trb_buff_len == 0 - false - it does not matter in this >case >> trb_buff_len == td_total_len - true >> >> Because more_trb_comming = false so function returns TD_SIZE = 0 for >last ZLP trb. >> >> Pawel
diff --git a/drivers/usb/cdns3/cdnsp-ring.c b/drivers/usb/cdns3/cdnsp-ring.c index 04dfcaa08dc4..aa79bce89d8a 100644 --- a/drivers/usb/cdns3/cdnsp-ring.c +++ b/drivers/usb/cdns3/cdnsp-ring.c @@ -1769,8 +1769,13 @@ static u32 cdnsp_td_remainder(struct cdnsp_device *pdev, /* One TRB with a zero-length data packet. */ if (!more_trbs_coming || (transferred == 0 && trb_buff_len == 0) || - trb_buff_len == td_total_len) + trb_buff_len == td_total_len) { + /* Before ZLP driver needs set TD_SIZE=1. */ + if (more_trbs_coming) + return 1; + return 0; + } maxp = usb_endpoint_maxp(preq->pep->endpoint.desc); total_packet_count = DIV_ROUND_UP(td_total_len, maxp);