From patchwork Fri Jun 28 18:24:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 168122 Delivered-To: patches@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp4020589ilk; Fri, 28 Jun 2019 11:24:21 -0700 (PDT) X-Received: by 2002:a65:498c:: with SMTP id r12mr10331929pgs.27.1561746261145; Fri, 28 Jun 2019 11:24:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561746261; cv=none; d=google.com; s=arc-20160816; b=uf6z5iXAA64gbxwUa4Au9kQzgi5CClXxz3r/X2JI0uuKiqJJvMbCq8TejplqujN6e8 4TUNndc+H2H3XloQ+4NwOCdrDynAbs+AZJgzNkFuN6Vp3VPJmFW3Ow3NiZFV55EDC1Wo nmhG3QfwwIrJRFVJ1i3hPOqlMiUpzaDGo4pyUw5/NUDxxljJX77sDkwG/fj65iolfODd iBFYHowE2XtSIxP/6oOvBuUhSrrQr5L6py4BeN+zotmrvuCe0Rgx/YTcyg/hNfTsl10v HAlel6sTBd6VjpbnYHkA9Nr2oeC9Jm2G0u4/u/fXKj+K/x3FUVVirZyI57+EkqeSRGsY A+zQ== 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=88fRjj74GZN01nX0sSKgncvdEa4gXr3r1F+OW3u4lS8=; b=BNlfou9Qo+bhGHbUZYTTgBE98xLDpnncsby4O/pWJM+WZSEALly2jT6LwxPAV1DNu5 zeJmcyaUIzd0Z4OeYxi9aI3hIWvn0P7BaV1qL75ZOxyszZyNM1mT5n/TCnd9HftkL53e 6XbO68406xXR+jwDM8kEdPB91zFoRtKJpz9H8qD3WCzI200jLksBwcNj4M9Uq1NMXOVo tX5lln87k5i5yubn63ztoxfVyCYr+c7hj545SL8KNXSyLVb1ulg1Smi0tlt0S6QIZMO4 uWuUThz9kZeWLdFb9xUM5GIc5NqawgWtN8zuL7hfB1xpZGhUAhQkJK189b7xKuEwN28B ZTkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DFywPhvk; 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 n9sor650738pgl.53.2019.06.28.11.24.21 for (Google Transport Security); Fri, 28 Jun 2019 11:24:21 -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=DFywPhvk; 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=88fRjj74GZN01nX0sSKgncvdEa4gXr3r1F+OW3u4lS8=; b=DFywPhvkx8VftWLHnF+hjOhCP6z+9tHooSDVr5iWKkQbFcu5W0rypK+ZNa1k4CrKbB rgSLyJw90E0YW8ciwrDmdc6ngSaPML6MUHTa5+OAFRfKkOPKdlOYDyBfEwmV6otqdQ2k e4vBJlYrxYGGN3ip5ijM4/EzHyxDTV381B1Im51Bp2AzgD8zltbEBG4CmolNXogB+s1D Xma67Uu4qPudHxECpKjjiERRBudywazCn+n6NwdKH/6nDJw/+IhYguEkJRcAiH7ROKvH 4BJQUbgP/bazB9mr5ekU4tc0Fo7EdK1W6PiervT5dKCKSTLcjOgUS1gbPDxUeBu8F3pi Zbcw== 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=88fRjj74GZN01nX0sSKgncvdEa4gXr3r1F+OW3u4lS8=; b=RXxmYQ0sn3stO6DgKksYKwOSsSbm/DcEsg8a7BWR57MnDYkyZ7l66tJ+leYoC3lc3s 92S8jmY/GncRhmDbHgysKihXbqVGgj2miwENWTySeCq12zhLnPElwuSqvv5iEr1oSMkk 3DIyTeRcLg+4VQQ24WBmgd4q2YxpJdCtSIEhDFvFFi0ExWZ5NVFP/AXgbJe2Qpaec7aq PKB0ZjLdoaR7h+76JQDsOdgDq2+60xx597duGK9Yux73ZieJUiBLwRo1XPQBwA4byl5c BPNf8uBbm3KYtki1PIMgTe50bkUrDnuuDlX+3RG2z1V6r/MdI4OX64uLNZoXzgNrrMoO xygA== X-Gm-Message-State: APjAAAWWqF/rIvEAPLYN4f3sQE8tEkbWOnp6vU+73RG7lyJUGd9EbGmC e49KIxGyi7sHAiki6HOG8ysj/Dyx X-Google-Smtp-Source: APXvYqzSf+2FES9KMIflO6lAuK1yNAY9PsuuqnAtpqrmG1IdzcjRxQg9SWRS+em/RPAfgRad+TT+CA== X-Received: by 2002:a63:f817:: with SMTP id n23mr10705991pgh.35.1561746260608; Fri, 28 Jun 2019 11:24:20 -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.19 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 28 Jun 2019 11:24:19 -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 2/9] usb: dwc3: gadget: combine unaligned and zero flags Date: Fri, 28 Jun 2019 18:24:06 +0000 Message-Id: <20190628182413.33225-3-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 1a22ec643580626f439c8583edafdcc73798f2fb upstream Both flags are used for the same purpose in dwc3: appending an extra TRB at the end to deal with controller requirements. By combining both flags into one, we make it clear that the situation is the same and that they should be treated equally. 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 1a22ec643580626f439c8583edafdcc73798f2fb) Signed-off-by: John Stultz --- drivers/usb/dwc3/core.h | 7 +++---- drivers/usb/dwc3/gadget.c | 18 +++++++++--------- 2 files changed, 12 insertions(+), 13 deletions(-) -- 2.17.1 diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 5bfb62533e0f..4872cba8699b 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -847,11 +847,11 @@ struct dwc3_hwparams { * @epnum: endpoint number to which this request refers * @trb: pointer to struct dwc3_trb * @trb_dma: DMA address of @trb - * @unaligned: true for OUT endpoints with length not divisible by maxp + * @needs_extra_trb: true when request needs one extra TRB (either due to ZLP + * or unaligned OUT) * @direction: IN or OUT direction flag * @mapped: true when request has been dma-mapped * @started: request is started - * @zero: wants a ZLP */ struct dwc3_request { struct usb_request request; @@ -867,11 +867,10 @@ struct dwc3_request { struct dwc3_trb *trb; dma_addr_t trb_dma; - unsigned unaligned:1; + unsigned needs_extra_trb:1; unsigned direction:1; unsigned mapped:1; unsigned started:1; - unsigned zero:1; }; /* diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index eaa78e6c972c..8db7466e4f76 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1068,7 +1068,7 @@ static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep, struct dwc3 *dwc = dep->dwc; struct dwc3_trb *trb; - req->unaligned = true; + req->needs_extra_trb = true; /* prepare normal TRB */ dwc3_prepare_one_trb(dep, req, true, i); @@ -1112,7 +1112,7 @@ static void dwc3_prepare_one_trb_linear(struct dwc3_ep *dep, struct dwc3 *dwc = dep->dwc; struct dwc3_trb *trb; - req->unaligned = true; + req->needs_extra_trb = true; /* prepare normal TRB */ dwc3_prepare_one_trb(dep, req, true, 0); @@ -1128,7 +1128,7 @@ static void dwc3_prepare_one_trb_linear(struct dwc3_ep *dep, struct dwc3 *dwc = dep->dwc; struct dwc3_trb *trb; - req->zero = true; + req->needs_extra_trb = true; /* prepare normal TRB */ dwc3_prepare_one_trb(dep, req, true, 0); @@ -1410,7 +1410,7 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep, dwc3_ep_inc_deq(dep); } - if (r->unaligned || r->zero) { + if (r->needs_extra_trb) { trb = r->trb + r->num_pending_sgs + 1; trb->ctrl &= ~DWC3_TRB_CTRL_HWO; dwc3_ep_inc_deq(dep); @@ -1421,7 +1421,7 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep, trb->ctrl &= ~DWC3_TRB_CTRL_HWO; dwc3_ep_inc_deq(dep); - if (r->unaligned || r->zero) { + if (r->needs_extra_trb) { trb = r->trb + 1; trb->ctrl &= ~DWC3_TRB_CTRL_HWO; dwc3_ep_inc_deq(dep); @@ -2250,7 +2250,8 @@ static int dwc3_gadget_ep_reclaim_completed_trb(struct dwc3_ep *dep, * with one TRB pending in the ring. We need to manually clear HWO bit * from that TRB. */ - if ((req->zero || req->unaligned) && !(trb->ctrl & DWC3_TRB_CTRL_CHN)) { + + if (req->needs_extra_trb && !(trb->ctrl & DWC3_TRB_CTRL_CHN)) { trb->ctrl &= ~DWC3_TRB_CTRL_HWO; return 1; } @@ -2327,11 +2328,10 @@ static int dwc3_gadget_ep_cleanup_completed_request(struct dwc3_ep *dep, ret = dwc3_gadget_ep_reclaim_trb_linear(dep, req, event, status); - if (req->unaligned || req->zero) { + if (req->needs_extra_trb) { ret = dwc3_gadget_ep_reclaim_trb_linear(dep, req, event, status); - req->unaligned = false; - req->zero = false; + req->needs_extra_trb = false; } req->request.actual = req->request.length - req->remaining;