Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2139988iob; Thu, 5 May 2022 17:00:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwCk4KZxD9K8lmM+rhWxExnsppH5vreDUfAe+MIB6uSzWo3dgWjqGDdo4RvuZWdbr+w/mgL X-Received: by 2002:a05:6402:128b:b0:425:d1d7:b321 with SMTP id w11-20020a056402128b00b00425d1d7b321mr726588edv.179.1651795207436; Thu, 05 May 2022 17:00:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651795207; cv=none; d=google.com; s=arc-20160816; b=jiP1UPVXKL6pC4Tof8mQMDUSRQloCyqxrywvMUQgZRN4FIJjyDMdvXajBr7S6a9sWv RsuHmfLmaI75lLYmON6Rr4TdFNZFkuI7+QLn5GWhmf3BejhsaBf0+xLlH42VGgHbyVaq vJDMtEHxEjaVBeH7ujCiLCVvZEvHiK6QbQTGeHOBQnPLL8AlWFNyoXyA1l6Ggmxt0OZ2 lzXHGVmiA8oT7/oRBY1VcXEslf9c9YXMMwkn3d66MOUBFvKh3xxuOuMmoWf3F6eztjWk rMVVSnoDbMj7qFuxEg4GzP9YQUAdH6cy89asPOfqYsiTB5EHnYxnTjsQDfv6w+ysLOjQ jEHg== 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=hUkA1zAbGpS6xU4lVCAwOO/kuR0pup+5FpE8yr1JsR8=; b=u9k3KFqgj4FZfOehlwpqxtnVWa9qKE+NPjSfU3+iIl9Ecdf4hpa4Etim3cE4k0sp8d jNxRWj/pBfSkPNzm3mF8lAlTlKnAAfZkT8zWnzP5FRE2umCJF45jiN3AlQofyi1U//1E EU6pBFzaUFP29285ovd4oPq11iaRRwGeSB85wVddXHcc+pyKjaezinM/q/Cs8TtghaJS LVkJa6nhRGsiPADGs3FVZdULX1x5ao27SdIxYcwu2q0DFPSpIv3ms6/687TlWO1qUJ66 j/xANxTETiwHd/iesWrcaIvGsOoANaiBE9MHiA/8fnxjMsvrvzNg1iSJAIjS3Ca3Gg+f rjvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vDC1EBNF; 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 qc17-20020a170906d8b100b006eff1696032si3469976ejb.14.2022.05.05.16.59.44; Thu, 05 May 2022 17:00:07 -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=vDC1EBNF; 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 S1357896AbiEDRZN (ORCPT + 99 others); Wed, 4 May 2022 13:25:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355264AbiEDREO (ORCPT ); Wed, 4 May 2022 13:04:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0193D4EA29; Wed, 4 May 2022 09:52:54 -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 4568361794; Wed, 4 May 2022 16:52:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F37DC385A4; Wed, 4 May 2022 16:52:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651683168; bh=Emzh8uHhSp0GwuvkMv/03UFTT0OpFaBCbIsb6iocM0U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vDC1EBNFmDUYy2lDjcHqf0uEvJiszcAJLU9Ex5WV0GSnI4OzPcoP7lGvxmCHXxTWc ng1Uahp8qfy/SS+bo+Tq/ko4GAnm9Uu7H9oxTxBxODeCR04J+IjTIQqNQXBJA97WEv HPirJWodjw7EK2r16xvq0SUt37zCxubLuSGtmGpI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thinh Nguyen Subject: [PATCH 5.15 025/177] usb: dwc3: gadget: Return proper request status Date: Wed, 4 May 2022 18:43:38 +0200 Message-Id: <20220504153055.398072759@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504153053.873100034@linuxfoundation.org> References: <20220504153053.873100034@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 @@ -3199,6 +3199,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) @@ -3219,7 +3220,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;