Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp200903iof; Wed, 8 Jun 2022 19:26:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwm72N+35yf9PMV8rs1xhh0G1JiuBf9ob7jDTULHdo+Ss4+zDQlDBrdxo6BKGX7D/DgDAm9 X-Received: by 2002:a17:90b:1d8c:b0:1e6:8032:a8dc with SMTP id pf12-20020a17090b1d8c00b001e68032a8dcmr1015614pjb.99.1654741576252; Wed, 08 Jun 2022 19:26:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654741576; cv=none; d=google.com; s=arc-20160816; b=zY88Ub3OsJ1YkmptrdOCAhzlX7kTH6VX5wed4tss938DKddYx7x81arV921sAIW/Ye KJRn+euCxOlavwZSYGv/7G/qxcpQ6T6QkcWB9AvPtoPHagwc6kLy+MDmwIwZe99Nd2Xk 5iW/aHjQma8slj+kr4mYKTMJzxjm+4sQDFfnCA4anTey0b6NFNHxw2z0ZbJmdsKhVw8D iDv3L0jk3NFEtdoBwWDsVx/fHIZLJu4SUBEggn4GW9SRYVmVOtFL8TYX4HDbfWq9njYA vkLmGylCR0btoBGkChmiZIPvHJ8lpcPOGRZYuSEK2iJ+AEYH6jQOeA8QLVfxu0a7Sh5M KV7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=vrLf3UAuZC8bVGa6ZPIF7Qn9wNplybo7emBHydpUfOI=; b=nUn8p2wS7XwTa+cQ1f+1VZgMM+okw6wV7Fp39Ein7vj78RD7vXLcYRnz+Y4CYwgCn7 uLqrJu1G4lO1nh2jtYVrY6g1rhW+ayrubBm50kiZDpzzW4TA4tKJrV649Kis2QZIllUe n+5s/jghM/4z/hgDDi7JMMhmN5/wIHIiPeqSfO9aVExLQKSRR6JUQHHeAKM4gpLHHtB0 eMWpjY4gElPU/sli48qv4dQWsYh+FTSjRPjVUMP5Bzb6rc9jORsoWfIKWvYrZ0OHBqiL Aa1t169W4nwbCx099pKEU0e1GrhYfaBBzCsyJNNh3MTTbEr5JnOjAOnOZdiTFRkz7sPk AHjA== ARC-Authentication-Results: i=1; mx.google.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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f24-20020a17090aa79800b001e016bba7bcsi6099533pjq.35.2022.06.08.19.26.03; Wed, 08 Jun 2022 19:26:16 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233180AbiFICMZ (ORCPT + 99 others); Wed, 8 Jun 2022 22:12:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229752AbiFICMY (ORCPT ); Wed, 8 Jun 2022 22:12:24 -0400 Received: from zg8tndyumtaxlji0oc4xnzya.icoremail.net (zg8tndyumtaxlji0oc4xnzya.icoremail.net [46.101.248.176]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 7D4F7233EA3 for ; Wed, 8 Jun 2022 19:12:18 -0700 (PDT) Received: from jleng.ambarella.net (unknown [116.246.37.178]) by mail-app2 (Coremail) with SMTP id by_KCgAnzUHjVqFi40WJAQ--.61551S2; Thu, 09 Jun 2022 10:11:55 +0800 (CST) From: 3090101217@zju.edu.cn To: pawell@cadence.com, gregkh@linuxfoundation.org, peter.chen@kernel.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Jing Leng Subject: [PATCH] usb: cdnsp: Fixed setting last_trb incorrectly Date: Thu, 9 Jun 2022 10:11:34 +0800 Message-Id: <20220609021134.1606-1-3090101217@zju.edu.cn> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: by_KCgAnzUHjVqFi40WJAQ--.61551S2 X-Coremail-Antispam: 1UD129KBjvJXoW7AryUtF4DXF4kuFWxJw1DZFb_yoW8Ar1xpF 47JFWqkr1fArW3Awn7KFn8X3W5GrnakFy7KFZ7Z3sakr13Aas7uFn8Kr10qrZxCryrZr4q 9FsIqas7Zanag3JanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9qb7Iv0xC_Cr1lb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rw A2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xII jxv20xvEc7CjxVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4 A2jsIEc7CjxVAFwI0_GcCE3s1lnxkEFVAIw20F6cxK64vIFxWlnxkEFVCFx7IYxxCEVcI2 5VAKI4IrM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMc Ij6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_ Jr0_Gr1lF7xvr2IYc2Ij64vIr41lw4CEc2x0rVAKj4xxMxAIw28IcxkI7VAKI48JMxC20s 026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_ JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14 v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwCI42IY6xAIw20EY4v20xva j40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVWUJV W8JbIYCTnIWIevJa73UjIFyTuYvjxU4038UUUUU X-CM-SenderInfo: qtqziiyqrsilo62m3hxhgxhubq/1tbiAwQPBVNG3GzSjQACs1 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Jing Leng When ZLP occurs in bulk transmission, currently cdnsp will set last_trb for the last two TRBs, it will trigger an error "ERROR Transfer event TRB DMA ptr not part of current TD ...". Fixes: e913aada0683 ("usb: cdnsp: Fixed issue with ZLP") Signed-off-by: Jing Leng --- drivers/usb/cdns3/cdnsp-ring.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/usb/cdns3/cdnsp-ring.c b/drivers/usb/cdns3/cdnsp-ring.c index e45c3d6e1536..794e413800ae 100644 --- a/drivers/usb/cdns3/cdnsp-ring.c +++ b/drivers/usb/cdns3/cdnsp-ring.c @@ -1941,13 +1941,16 @@ int cdnsp_queue_bulk_tx(struct cdnsp_device *pdev, struct cdnsp_request *preq) } if (enqd_len + trb_buff_len >= full_len) { - if (need_zero_pkt) - zero_len_trb = !zero_len_trb; - - field &= ~TRB_CHAIN; - field |= TRB_IOC; - more_trbs_coming = false; - preq->td.last_trb = ring->enqueue; + if (need_zero_pkt && !zero_len_trb) { + zero_len_trb = true; + } else { + zero_len_trb = false; + field &= ~TRB_CHAIN; + field |= TRB_IOC; + more_trbs_coming = false; + need_zero_pkt = false; + preq->td.last_trb = ring->enqueue; + } } /* Only set interrupt on short packet for OUT endpoints. */ @@ -1962,7 +1965,7 @@ int cdnsp_queue_bulk_tx(struct cdnsp_device *pdev, struct cdnsp_request *preq) length_field = TRB_LEN(trb_buff_len) | TRB_TD_SIZE(remainder) | TRB_INTR_TARGET(0); - cdnsp_queue_trb(pdev, ring, more_trbs_coming | zero_len_trb, + cdnsp_queue_trb(pdev, ring, more_trbs_coming, lower_32_bits(send_addr), upper_32_bits(send_addr), length_field, -- 2.17.1