Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1649340iob; Thu, 5 May 2022 05:53:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjpxy6aaVjbOrfo81SsjI/sfcEIZ+6OMvXFDY+vV8GDqZc6YTzmot1/rXaJ7zuQbe+oq8a X-Received: by 2002:aa7:c58e:0:b0:425:b5e3:6c51 with SMTP id g14-20020aa7c58e000000b00425b5e36c51mr30352428edq.99.1651755182313; Thu, 05 May 2022 05:53:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651755182; cv=none; d=google.com; s=arc-20160816; b=UD7NcsJjmXqN4CGiU+WB3e6WVSAzoJc4DcARqrT+JR6ZjEXodl19Z2alc71JFSi7bJ HkLDUQ0Zi4gubcex3ovgvc82xexiwAjQ7+nVsPAncZmaXV+aB85QdqW8N3+usZrD5gsz QT5YXi/ACFmbyBch0wwRUx76m6tjoGaxwrYZNnkG+kYijlobcb5ho/A0PqOP+T4tYsip L/L8TeE9UK+NA2B1ZMG6EhOG//8Fh07PYtwoxTngBMs5ejz7AfBBxSr1AwmxgIZxrxxa u1kFX1qOgz2zos6qasxLXf1RLIlR/6Q0h0Ni5TrvWv4mkz1wrORnwV8HrLWNYQLgo0SU hrEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ke9hyx2mfe5xUiy3t0DbywqLLdDB5FvEQdpSuQgYvTk=; b=bX2vTf2VrCKjRkmjaobZONCTfE2F5CARjJ5UOvtaZcJ8M+f5J+aFVzcjrTwc/yZ3fc fHXg0Tfq+26TXv301kqufYtkcR5YLP3S7PArLDKQc/1FoQS1z3eTgNmq+4Z4JUmP+11I PcIJQbGdYUKsO8MVHjBJzAOehH/Si0qIIicceE0kxc6YsriwVCuZ6UEHe4WFtKvS+SOt FCnhVtLwc4mQq43juGDIFti7uhNBCa0aEd1G/BtCsOmVJzw7nFNtBH8covqiSrO05SoK /ozN0RhoQmxcFfTt5eADzcxIqpPpg41ZaXfZDQ9xLRZUQfIe6cqoQuBJnHXXtMcqm/Dp ZYmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nW0a0aaf; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r20-20020a05640251d400b00425d52f61c0si2153532edd.293.2022.05.05.05.52.38; Thu, 05 May 2022 05:53:02 -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=@linuxfoundation.org header.s=korg header.b=nW0a0aaf; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359184AbiEDRjk (ORCPT + 99 others); Wed, 4 May 2022 13:39:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356831AbiEDRJp (ORCPT ); Wed, 4 May 2022 13:09:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6828537A86; Wed, 4 May 2022 09:55:55 -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 dfw.source.kernel.org (Postfix) with ESMTPS id DBD11617DE; Wed, 4 May 2022 16:55:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 30255C385A5; Wed, 4 May 2022 16:55:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651683354; bh=4mjYDSdWePM+0k97YorWcmEeIKh9d7g1avgZ06w8JjQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nW0a0aafJIu3Kg26/LHRj2Nu6J3YQXyE37WJRNrs0nyk6wfHJnIg8nLFFa5F9UOHu sEkjuP7eNwpDxhoW70SYxm7AYS23r0t27agY2HDW0++FwWW9jWFynYfebmMa5BrR6P Qa0HxeaVACZKieXETtu0YsHjjlyFeDMEmJTjy+94= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thinh Nguyen Subject: [PATCH 5.17 027/225] usb: dwc3: gadget: Return proper request status Date: Wed, 4 May 2022 18:44:25 +0200 Message-Id: <20220504153112.731735152@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504153110.096069935@linuxfoundation.org> References: <20220504153110.096069935@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 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,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: Thinh Nguyen commit c7428dbddcf4ea1919e1c8e15f715b94ca359268 upstream. If the user sets the usb_request's no_interrupt, then there will be no completion event for the request. Currently the driver incorrectly uses the event status of a different request to report the status for a request with no_interrupt. The dwc3 driver needs to check the TRB status associated with the request when reporting its status. Note: this is only applicable to missed_isoc TRB completion status, but the other status are also listed for completeness/documentation. Fixes: 6d8a019614f3 ("usb: dwc3: gadget: check for Missed Isoc from event status") Cc: Signed-off-by: Thinh Nguyen Link: https://lore.kernel.org/r/db2c80108286cfd108adb05bad52138b78d7c3a7.1650673655.git.Thinh.Nguyen@synopsys.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc3/gadget.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -3229,6 +3229,7 @@ static int dwc3_gadget_ep_cleanup_comple const struct dwc3_event_depevt *event, struct dwc3_request *req, int status) { + int request_status; int ret; if (req->request.num_mapped_sgs) @@ -3249,7 +3250,35 @@ static int dwc3_gadget_ep_cleanup_comple req->needs_extra_trb = false; } - dwc3_gadget_giveback(dep, req, status); + /* + * The event status only reflects the status of the TRB with IOC set. + * For the requests that don't set interrupt on completion, the driver + * needs to check and return the status of the completed TRBs associated + * with the request. Use the status of the last TRB of the request. + */ + if (req->request.no_interrupt) { + struct dwc3_trb *trb; + + trb = dwc3_ep_prev_trb(dep, dep->trb_dequeue); + switch (DWC3_TRB_SIZE_TRBSTS(trb->size)) { + case DWC3_TRBSTS_MISSED_ISOC: + /* Isoc endpoint only */ + request_status = -EXDEV; + break; + case DWC3_TRB_STS_XFER_IN_PROG: + /* Applicable when End Transfer with ForceRM=0 */ + case DWC3_TRBSTS_SETUP_PENDING: + /* Control endpoint only */ + case DWC3_TRBSTS_OK: + default: + request_status = 0; + break; + } + } else { + request_status = status; + } + + dwc3_gadget_giveback(dep, req, request_status); out: return ret;