From patchwork Wed May 6 02:47:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thinh Nguyen X-Patchwork-Id: 11530163 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A7F0117E8 for ; Wed, 6 May 2020 02:47:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 85D0120721 for ; Wed, 6 May 2020 02:47:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=synopsys.com header.i=@synopsys.com header.b="dq06K5Ob" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726222AbgEFCrG (ORCPT ); Tue, 5 May 2020 22:47:06 -0400 Received: from smtprelay-out1.synopsys.com ([149.117.87.133]:50106 "EHLO smtprelay-out1.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725900AbgEFCrF (ORCPT ); Tue, 5 May 2020 22:47:05 -0400 Received: from mailhost.synopsys.com (sv1-mailhost2.synopsys.com [10.205.2.132]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id D9699C1324; Wed, 6 May 2020 02:47:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1588733224; bh=x266bhHc995vTrO+GJqke9RLV7rizATihZjNwl6K25w=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=dq06K5ObXQO0Xip5N1m9Kka51dhGFPJgzltXfT4gdvuXmFx7vJM7kWpuqtAAIYgm4 jl6NujnyTsLyhiaGT7hOLf3lXx6U6EGNed68eMyQfRf+fw3qVW6Q07/NiIK8rUI41T UNi3eOGXfzNknUd/MyjFUbPT+hgYy1Z+gq5DrU6SzZi1hsq0DqW9DCjxoPZDrevLcz EsN0I80mlmkr0gQYEDWb9AkPBgx7KT/ur9+CoDYmDSyNlVTyXjBQVY2Pd5d52+NRvH rQYYfWR2YhsZQ1z9ljo36TtqgZqdLRHbt4hr4OrbJ1WQ79Wj98GH7xIpk/FglEDmle GcZpXmlxEeSZQ== Received: from te-lab16 (nanobot.internal.synopsys.com [10.10.186.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mailhost.synopsys.com (Postfix) with ESMTPSA id A945FA006D; Wed, 6 May 2020 02:47:03 +0000 (UTC) Received: by te-lab16 (sSMTP sendmail emulation); Tue, 05 May 2020 19:47:03 -0700 Date: Tue, 05 May 2020 19:47:03 -0700 Message-Id: In-Reply-To: References: From: Thinh Nguyen Subject: [PATCH v2 09/11] usb: dwc3: gadget: Don't prepare beyond a transfer To: Felipe Balbi , Greg Kroah-Hartman , Thinh Nguyen , linux-usb@vger.kernel.org Cc: John Youn Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Don't prepare TRBs beyond a transfer. In DWC_usb32, its transfer burst capability may try to read and use TRBs beyond the active transfer. For other controllers, they don't process the next transfer TRBs until the current transfer is completed. Explicitly prevent preparing TRBs ahead for all controllers. Signed-off-by: Thinh Nguyen --- drivers/usb/dwc3/gadget.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 97c6a5785725..07824b670440 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1231,6 +1231,14 @@ static void dwc3_prepare_trbs(struct dwc3_ep *dep) if (!dwc3_calc_trbs_left(dep)) return; + + /* + * Don't prepare beyond a transfer. In DWC_usb32, its transfer + * burst capability may try to read and use TRBs beyond the + * active transfer instead of stopping. + */ + if (dep->stream_capable && req->request.is_last) + return; } }