From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 427F7C4332F for ; Thu, 20 Oct 2022 13:21:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231201AbiJTNVE (ORCPT ); Thu, 20 Oct 2022 09:21:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230481AbiJTNUy (ORCPT ); Thu, 20 Oct 2022 09:20:54 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14D0F51A0B; Thu, 20 Oct 2022 06:20:19 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 27B74B82648; Thu, 20 Oct 2022 13:20:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A9CFC433D6; Thu, 20 Oct 2022 13:20:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666272015; bh=Rsn6bw20rlalxQ/SID97AXkpPfvVGG+5j06netqtMyk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=j59LDTD/B7Zaiswj1/PchAfkOEHRbpLbB3ej8uTyuF4x8nxPjkCVDcpYZIGSe+WbC tYZoUNuBOPEssrYxUaCuOKmEsUphZs/87kBa/sHjolGygCZ+BtGkjWrFJT2L68ZHQ5 z5mjihBA2IWYiWYFG4we8OU1ztD3lRT/1jWeAWzr+g+F9GtziARY1vSyRX/xu8Y/pk JJDSjbW6Bkia95/dtwPsuYqpEgdHfrtLH160heyKobnAw4xrDAKbN4Sqm4mxMYVMNs u9ly/5LBRY5g3MlZwIlKrsOeU+/QN00SV6C6AcRpDDhHVvP2JrCnxHaG1STuqvFgKu wpTDeqEBA3Lyw== Date: Thu, 20 Oct 2022 21:20:10 +0800 From: Peter Chen To: Pawel Laszczak Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] usb: cdnsp: fix issue with ZLP - added TD_SIZE = 1 Message-ID: <20221020132010.GA29690@nchen-desktop> References: <1666159637-161135-1-git-send-email-pawell@cadence.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1666159637-161135-1-git-send-email-pawell@cadence.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 22-10-19 02:07:17, 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: > Fixes: 3d82904559f4 ("usb: cdnsp: cdns3 Add main part of Cadence USBSSP DRD Driver") > Signed-off-by: Pawel Laszczak > --- > drivers/usb/cdns3/cdnsp-ring.c | 15 ++++++++------- > 1 file changed, 8 insertions(+), 7 deletions(-) > > diff --git a/drivers/usb/cdns3/cdnsp-ring.c b/drivers/usb/cdns3/cdnsp-ring.c > index 794e413800ae..4809d0e894bb 100644 > --- a/drivers/usb/cdns3/cdnsp-ring.c > +++ b/drivers/usb/cdns3/cdnsp-ring.c > @@ -1765,18 +1765,19 @@ static u32 cdnsp_td_remainder(struct cdnsp_device *pdev, > struct cdnsp_request *preq, > bool more_trbs_coming) > { > - u32 maxp, total_packet_count; > - > - /* One TRB with a zero-length data packet. */ > - if (!more_trbs_coming || (transferred == 0 && trb_buff_len == 0) || > - trb_buff_len == td_total_len) > - return 0; > + u32 maxp, total_packet_count, remainder; > > maxp = usb_endpoint_maxp(preq->pep->endpoint.desc); > total_packet_count = DIV_ROUND_UP(td_total_len, maxp); > > /* Queuing functions don't count the current TRB into transferred. */ > - return (total_packet_count - ((transferred + trb_buff_len) / maxp)); > + remainder = (total_packet_count - ((transferred + trb_buff_len) / maxp)); > + > + /* Before ZLP driver needs set TD_SIZE=1. */ > + if (!remainder && more_trbs_coming) > + remainder = 1; Without ZLP, TD_SIZE = 0 for the last TRB. With ZLP, TD_SIZE = 1 for current TRB, and TD_SIZE = 0 for the next TRB (the last zero-length packet) right? Peter > + > + return remainder; > } > > static int cdnsp_align_td(struct cdnsp_device *pdev, > -- > 2.25.1 > -- Thanks, Peter Chen