From patchwork Fri Jun 28 18:24:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 168123 Delivered-To: patches@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp4020620ilk; Fri, 28 Jun 2019 11:24:22 -0700 (PDT) X-Received: by 2002:a63:e356:: with SMTP id o22mr7852944pgj.150.1561746262777; Fri, 28 Jun 2019 11:24:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561746262; cv=none; d=google.com; s=arc-20160816; b=hDQIFph2fWrgFCvRXtfcJQXICLIFzax2LMoK+Y+Jd8dDr0+TaBn0khRqyWHP9RtKxA 7L4KhGB0OpHlJPNT0JbNiYPikvSdfrii378oiSSjMORlQFRCFfUXSnu9w2QmRUMy+CWC 2S9uuJ+aBrZVKHn9obS3gAfFKiJHscDirF9GVPdM0VtynqZPoIiFLGNwQ0xzULAzgDZR F9jawwxls4znfyTin26j8wiSBWSNffXwpQRmwL8TrFwyaqDDmhdpsFU8ac+u58Tuyrw3 k7Ew8U4TEDn/GqAYoQc21xj7VI9c4nTwBS3/4laExBkr/IRKNqiUfK7NPVteJTHladfG ZCfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ih7U4hpwGmfoDyYEDt6ssld4EzhtjygGMzYklaGP3Wc=; b=0F7oNUWiLqd7u8GpW0KvllembTeqen94+5NoFU/mDuYU8wGUXm5+6y5sPosBnUH6Ay Bjr8BsDDLIAfcJhwulYZDq23oSEDc4DpM0aPJ9ctnbrLflj3c7GTKctdLgF0Pt29bVjG +FG5+hRTWnlCNZWzwsN/WiNc+fi8WWEek+yAM8yX7u5wM8RyzNGLJnGCNzWPcBpnOwKk Q8He1FCrZ4f0f0+wqVE4/D2RqnZBCKsStgNQebqtEgpFCIEBPd9uiHMCqpc1/QtDoqcW Q0Mv4+rJuKhtkm6WE6C60/E5IKMOABpcF0x+SUJdY43KVv/8Is9SpyRw2yUUD8N9vrmd yyLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mk8J9R2L; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id m10sor3362709pje.25.2019.06.28.11.24.22 for (Google Transport Security); Fri, 28 Jun 2019 11:24:22 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mk8J9R2L; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=ih7U4hpwGmfoDyYEDt6ssld4EzhtjygGMzYklaGP3Wc=; b=mk8J9R2LyueC0i6f8ZRSA4DJA28jyZ55n95SHVFP+uj39/BO2/IP0UxjTWqCeq+eym C9Cw336mhXrmmHCrfxSmauKAhudkV8ioUSHg4cI7lRcrIbrEvlov9A8WtIgE1hoMLyse 1wJpZ57harz3Dfq81xg6bEm2chVzpT3sTF+rfxzjdoSOEZYIjxESghqgqV9Qvh2p9ZGg NN+KFLHYLoz9RCCQAayXKK5w6VZvIaRekatiZLtaetKv+W68+BQbUd+ugJqQewUhcykj 3at2yTQZPpWIatsQRPnl1GYEBbQH5ijtulJnlZqqxO/Yx0QsW6657rOMwAsQRVRHNIgb fMvQ== 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=ih7U4hpwGmfoDyYEDt6ssld4EzhtjygGMzYklaGP3Wc=; b=DRyTvrHkoGp3ljp+ZbozUBBIQ5m+iBJYli27dIWawVgfqoz7v3RxmN7Rkvvh8sozow M0RhVosdpiQHWsjwwGXmK4jqqowbI+YtX9rmuQEmoatPvFDy/vzP31YkBH4/hlFvIC1C Rp91A+330lWVy9AySqck1pDbp+w/BHZ/rWpKW5BjlPuCuwMdQFw+WZ0TEqrOF9/OkMPp 3pv2mnzQj+dTz+hJcgs7m6Uc50sqvWdA5/jrABJnTxQpKKLhxnCiRoOFo9IsFxzKWhCn PIF0cTO+3HiOhy4wTct0IrcYabaIMik2Jopxk+EZOLx+rRjL+9+m4j3/BjsK5kuaB/sZ Hzrw== X-Gm-Message-State: APjAAAWdp/Sj48i/ebZqIEj9qyUHRkzEdT+/dFHYFjio4W87ov3FYj/6 JFCrX70a2V1G68fxjsmgOi+8utBo X-Google-Smtp-Source: APXvYqwNCvTT67rkuVqcy61BjZbsAe5ofBN1aWGbeqvKWE2t4Pbv7bPlmW0h2lAhCJbdl9UBETECtA== X-Received: by 2002:a17:90a:a116:: with SMTP id s22mr14679396pjp.47.1561746262349; Fri, 28 Jun 2019 11:24:22 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id s15sm2916223pfd.183.2019.06.28.11.24.20 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 28 Jun 2019 11:24:21 -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 v2 3/9] usb: dwc3: gadget: track number of TRBs per request Date: Fri, 28 Jun 2019 18:24:07 +0000 Message-Id: <20190628182413.33225-4-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190628182413.33225-1-john.stultz@linaro.org> References: <20190628182413.33225-1-john.stultz@linaro.org> 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(+) -- 2.17.1 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 8db7466e4f76..fd91c494307c 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1041,6 +1041,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); } @@ -1075,6 +1077,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, @@ -1119,6 +1122,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, @@ -1135,6 +1139,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, @@ -2231,6 +2236,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