Received: by 2002:a05:6358:16cd:b0:dc:6189:e246 with SMTP id r13csp3579086rwl; Sun, 6 Nov 2022 01:13:41 -0800 (PST) X-Google-Smtp-Source: AMsMyM5bezwckBh12GA582Wt6pQLWCL0Gb+Tjw2O6B+4rICCG6QJ3UryzB74YLsJU/DCdAoL8C1O X-Received: by 2002:a17:907:a0c7:b0:7ad:dc65:bf8e with SMTP id hw7-20020a170907a0c700b007addc65bf8emr31539899ejc.133.1667726020755; Sun, 06 Nov 2022 01:13:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667726020; cv=none; d=google.com; s=arc-20160816; b=RX6L47Vls9McV3DWovgFH/2ux4ul1NYBIKq/a6aJzft3+R+INl0mrsIu5M/hzD8y4j B2ZDOEdBGWFqavflpTEiprQjPJcMf9fnabm8lER2xRfAwgdr3P30BfLXac1utBuW85gd HNAb3lzLKkAXx5and+qlYwcvBQhrFxSB/HJEdQqJuDVstM5+xOQBklBUWvASdC+f4GUY N+t+SHSXx557EkqtDS2CKdxuKcjpwpBBxSBvDignj8zhLENZ8yIPbUSWIy8taINEMVj8 kw5oxFWVkJZxEtVwSN7P274ScafZJpeAc9nPkIgUIpS1FFTr6PJvC+meCsqPG/NQ80r5 a4Xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=FCqTHGTTtFkUYnWk1s9/sJnb/fWIzVTv6+PkGNQuFF4=; b=ZBrKW7fyQYJzMsbX0k44DzQ8EX0UNSybMHRE6cX3Xb6FCn7Zqi+sHfrDh4VeF5u77B ovQYrzBB+IcAA0yaYxfPdvsUqZHVZxeznLtRfPBWgZaT2F0TAqpxesK3h5v03JuvltLj ff4wxEEFma+Qyi3t2VaFPNGxXEmUrbp6V9PhZabEfUFi6Y1++4zjmE7hkrpdImnizZLH x2i8Ez62/+Gdtahz0ppJPXKpA8YUfILspwz0xatDaEqVpheF+UmnTSLKsZ1wa8TfKypS ewfwcFC8fK5lljidhTxNejGEaagpO7U+B7GH282uD8ZPBXS/jra4eaOgU6ULfsCFVEbM RTHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=T9unJaNs; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sb33-20020a1709076da100b007adef1dceffsi6093095ejc.677.2022.11.06.01.13.17; Sun, 06 Nov 2022 01:13:40 -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=@kernel.org header.s=k20201202 header.b=T9unJaNs; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229682AbiKFJCd (ORCPT + 97 others); Sun, 6 Nov 2022 04:02:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229564AbiKFJCa (ORCPT ); Sun, 6 Nov 2022 04:02:30 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61F1F2663; Sun, 6 Nov 2022 01:02:29 -0800 (PST) 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 9E218B80B30; Sun, 6 Nov 2022 09:02:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A2F8C433D6; Sun, 6 Nov 2022 09:02:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667725346; bh=xjKCgVmFbXFxtKFBYyK+XNvbHjCTI456JH43nwr0lEc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=T9unJaNs6HLnI2qRq4XbuONifxSjf0RJRYhKfas+wxK0doTZWhX2Vxi39kuPEzrO1 +BV+lm/BOobR6s2lIx1pnCeyyfzWQXnIHRZ0qr9Wgc8MsPH6MehxcEhifAsz/gCVMR wvbdlY7k7tV3PjNt7Ctd0UhP6JiWltIf9hTki/rSmR64249F9Up3gEhGCvzC/K1UUw q9WzrK8uP8dz9slhiVl6SMQbmszxY25erslacG3LzbC9pUj69lwABU9ze9xERKJkcR wekQkPj45xpacM2TntuWA291big5LixYfpfKE1aAa0O4qd/nFGMnoR+QB4LeTUmdNh lMSMKTgYI6f8Q== Date: Sun, 6 Nov 2022 17:02:21 +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 v2] usb: cdnsp: fix issue with ZLP - added TD_SIZE = 1 Message-ID: <20221106090221.GA152143@nchen-desktop> References: <1666620275-139704-1-git-send-email-pawell@cadence.com> <20221027072421.GA75844@nchen-desktop> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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: X-Mailing-List: linux-kernel@vger.kernel.org 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: > >> Fixes: 3d82904559f4 ("usb: cdnsp: cdns3 Add main part of Cadence > >> USBSSP DRD Driver") > >> Signed-off-by: Pawel Laszczak > >> > >> --- > >> 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 -- Thanks, Peter Chen