From nobody Sun Sep 7 12:30:58 2025 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 93B34C6FA85 for ; Fri, 2 Sep 2022 13:01:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238455AbiIBNBD (ORCPT ); Fri, 2 Sep 2022 09:01:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238692AbiIBM7U (ORCPT ); Fri, 2 Sep 2022 08:59:20 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 922C8CEB1B; Fri, 2 Sep 2022 05:40:34 -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 4E080B82AA2; Fri, 2 Sep 2022 12:27:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9AC0DC433D6; Fri, 2 Sep 2022 12:27:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662121656; bh=y22KnKr1+JIk3i0jCCB6oiluxBJ8/iLl7XYTywdc0s4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lSQowt24jAezOMoMU0t6ufWw28YOZKm7KWJR8UOWjXElf0yz1/p+fjopaMWBsVR6+ 2f1b5r1ZzXwVu56qTPxCb2DTXiCrVR+0aAjZxb5QhiqZkOr0AJ+PyKmadGy7cGDzWH 8H3nEIfvCvhFikiF65PCNiT4wVRCiy3OBBMxsLxI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peter Chen , Pawel Laszczak Subject: [PATCH 5.4 04/77] usb: cdns3: Fix issue for clear halt endpoint Date: Fri, 2 Sep 2022 14:18:13 +0200 Message-Id: <20220902121403.750784175@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220902121403.569927325@linuxfoundation.org> References: <20220902121403.569927325@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Pawel Laszczak commit b3fa25de31fb7e9afebe9599b8ff32eda13d7c94 upstream. Path fixes bug which occurs during resetting endpoint in __cdns3_gadget_ep_clear_halt function. During resetting endpoint controller will change HW/DMA owned TRB. It set Abort flag in trb->control and will change trb->length field. If driver want to use the aborted trb it must update the changed field in TRB. Fixes: 7733f6c32e36 ("usb: cdns3: Add Cadence USB3 DRD Driver") cc: Acked-by: Peter Chen Signed-off-by: Pawel Laszczak Link: https://lore.kernel.org/r/20220329084605.4022-1-pawell@cadence.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/cdns3/gadget.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/drivers/usb/cdns3/gadget.c +++ b/drivers/usb/cdns3/gadget.c @@ -2166,6 +2166,7 @@ int __cdns3_gadget_ep_clear_halt(struct struct usb_request *request; struct cdns3_request *priv_req; struct cdns3_trb *trb =3D NULL; + struct cdns3_trb trb_tmp; int ret; int val; =20 @@ -2175,8 +2176,10 @@ int __cdns3_gadget_ep_clear_halt(struct if (request) { priv_req =3D to_cdns3_request(request); trb =3D priv_req->trb; - if (trb) + if (trb) { + trb_tmp =3D *trb; trb->control =3D trb->control ^ TRB_CYCLE; + } } =20 writel(EP_CMD_CSTALL | EP_CMD_EPRST, &priv_dev->regs->ep_cmd); @@ -2191,7 +2194,8 @@ int __cdns3_gadget_ep_clear_halt(struct =20 if (request) { if (trb) - trb->control =3D trb->control ^ TRB_CYCLE; + *trb =3D trb_tmp; + cdns3_rearm_transfer(priv_ep, 1); }