From patchwork Thu Jun 27 20:52:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 11020525 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4415314C0 for ; Thu, 27 Jun 2019 20:52:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C04B28703 for ; Thu, 27 Jun 2019 20:52:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2FFEC2870D; Thu, 27 Jun 2019 20:52:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE19B2870F for ; Thu, 27 Jun 2019 20:52:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726500AbfF0Uws (ORCPT ); Thu, 27 Jun 2019 16:52:48 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:45441 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726480AbfF0Uws (ORCPT ); Thu, 27 Jun 2019 16:52:48 -0400 Received: by mail-pf1-f195.google.com with SMTP id r1so1795883pfq.12 for ; Thu, 27 Jun 2019 13:52:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4Ag3DptOQlKFvwhPzNLWrHIQu/RujtBlVJPxwQgjUZ4=; b=xHiJhrSX+JSre8rOd6Cct+h18tuOFNpJtHqH//2drv/WJrQ6DlvS6OjN+XkAzsSJ7p 5PGrfaHh8wCqeYYjfEkBEyoMNJv9B2jxgxogc8EE5RgIoDIweZHyEUI6gQjx7oNCB33d BRxXXO1g6O8f9BZu9HY400wvD7gnICKH88EKc4tLwdhBfBGXqTGbPNjEvl2jzw8fhYZQ /OCY8sLnUW6bsKHR/pgTJwJGLXMUu2MkuHeSG0XygFeBU7INB584rv6oPHJH5hsjNu32 zec75NOMp0HZM9oEmfWX2KCFQAYgAXO5A9eGXCOT2pokFSMya5iYtzOCkmro7ugBtjnU 5zrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4Ag3DptOQlKFvwhPzNLWrHIQu/RujtBlVJPxwQgjUZ4=; b=ciNPvLgHhOZcJ4TnKYUZxZZfMKjxcENp1XuKGjHe2bneh2wJkTC8Qw0y4cIBTxpGF4 dnpttbkrK7QBfCJQuhD8PWJrQ7YCeS5ELqANi9seWctHBLRlSWAMMzufzblwgnf6K/C5 NtQ32TDlbsglnpHYB6Qt7tOztfgf4n4nVuMKmaR+D1ZnnO/P4Mr5M4u/mBYTXNtq38GP xn5yxZgO+nbU7RdRPLyEkMXfjpHRDkG/y47+BLUHCCelaFdDmLNBDmE0aMhDy3V1k5KI G9hyKesLVDTa1NHe1skRIxGInibJbZRiF6X87VtU57biVouWxfMcSFPKgbgC6RPanSE/ ikSQ== X-Gm-Message-State: APjAAAUqsh8GRni/l7EGiQsMohgDSNpQIErlb+DQqqbF2Ll0G7TmnWRQ +cPZYnkK5Gzch8bif2bDEbEC0g== X-Google-Smtp-Source: APXvYqwFzFzc5WG5FDPcHRdqb2AaRR84Y9E3us/OjEIh46TdQGH18lAYeE49opbpuX3HCTe4z8EjjA== X-Received: by 2002:a17:90a:270f:: with SMTP id o15mr8423034pje.56.1561668767538; Thu, 27 Jun 2019 13:52:47 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id 2sm3674083pff.174.2019.06.27.13.52.46 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 27 Jun 2019 13:52:46 -0700 (PDT) From: John Stultz To: stable@vger.kernel.org Cc: Felipe Balbi , Fei Yang , Sam Protsenko , Felipe Balbi , linux-usb@vger.kernel.org, John Stultz Subject: [PATCH 4.19.y 2/9] usb: dwc3: gadget: track number of TRBs per request Date: Thu, 27 Jun 2019 20:52:33 +0000 Message-Id: <20190627205240.38366-3-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190627205240.38366-1-john.stultz@linaro.org> References: <20190627205240.38366-1-john.stultz@linaro.org> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Felipe Balbi commit 09fe1f8d7e2f461275b1cdd832f2cfa5e9be346d upstream This will help us remove the wait_event() from our ->dequeue(). Cc: Fei Yang Cc: Sam Protsenko Cc: Felipe Balbi Cc: linux-usb@vger.kernel.org Cc: stable@vger.kernel.org # 4.19.y Signed-off-by: Felipe Balbi (cherry picked from commit 09fe1f8d7e2f461275b1cdd832f2cfa5e9be346d) Signed-off-by: John Stultz --- drivers/usb/dwc3/core.h | 3 +++ drivers/usb/dwc3/gadget.c | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 4872cba8699b..0de78cb29f2c 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -847,6 +847,7 @@ struct dwc3_hwparams { * @epnum: endpoint number to which this request refers * @trb: pointer to struct dwc3_trb * @trb_dma: DMA address of @trb + * @num_trbs: number of TRBs used by this request * @needs_extra_trb: true when request needs one extra TRB (either due to ZLP * or unaligned OUT) * @direction: IN or OUT direction flag @@ -867,6 +868,8 @@ struct dwc3_request { struct dwc3_trb *trb; dma_addr_t trb_dma; + unsigned num_trbs; + unsigned needs_extra_trb:1; unsigned direction:1; unsigned mapped:1; diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 4894fed1441c..019643a6ce9d 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1043,6 +1043,8 @@ static void dwc3_prepare_one_trb(struct dwc3_ep *dep, req->trb_dma = dwc3_trb_dma_offset(dep, trb); } + req->num_trbs++; + __dwc3_prepare_one_trb(dep, trb, dma, length, chain, node, stream_id, short_not_ok, no_interrupt); } @@ -1077,6 +1079,7 @@ static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep, /* Now prepare one extra TRB to align transfer size */ trb = &dep->trb_pool[dep->trb_enqueue]; + req->num_trbs++; __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, maxp - rem, false, 1, req->request.stream_id, @@ -1121,6 +1124,7 @@ static void dwc3_prepare_one_trb_linear(struct dwc3_ep *dep, /* Now prepare one extra TRB to align transfer size */ trb = &dep->trb_pool[dep->trb_enqueue]; + req->num_trbs++; __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, maxp - rem, false, 1, req->request.stream_id, req->request.short_not_ok, @@ -1137,6 +1141,7 @@ static void dwc3_prepare_one_trb_linear(struct dwc3_ep *dep, /* Now prepare one extra TRB to handle ZLP */ trb = &dep->trb_pool[dep->trb_enqueue]; + req->num_trbs++; __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, 0, false, 1, req->request.stream_id, req->request.short_not_ok, @@ -2233,6 +2238,7 @@ static int dwc3_gadget_ep_reclaim_completed_trb(struct dwc3_ep *dep, dwc3_ep_inc_deq(dep); trace_dwc3_complete_trb(dep, trb); + req->num_trbs--; /* * If we're in the middle of series of chained TRBs and we