From patchwork Thu Jun 27 20:52:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 167982 Delivered-To: patches@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2821857ilk; Thu, 27 Jun 2019 13:52:46 -0700 (PDT) X-Received: by 2002:a65:6102:: with SMTP id z2mr5482073pgu.194.1561668766557; Thu, 27 Jun 2019 13:52:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561668766; cv=none; d=google.com; s=arc-20160816; b=ahuhzUo0pAcxPBFNrvjdiAUmn9iOFV+fQq7aOUPQTmgh0c4DV9OdiUb5HWHCEp1pOc j2QYMjP6zJ2KrL1aReov4Fp98eqN2TR0oFXDyuRBPAUmx6p6/cGs3ZlHIP+jue1BBBI1 G4FPiL+I6gYDr2ZZYwULMK9r8ED96aJPEy3zPa+C4K5jXl6zt6e+rYPrL1o38OtCoXc+ EiGdGl7uWthUkuK3mcL/LTR4XiGq/54W393wXsF3NqrtqttH1+Kv0zLvGTkOqiP5gzsa M+SwRe1CLsUZiOKEaWZbesk0hffbZTkod7YVJFYwQ34WPKoS+1bHdzvRoA9+qmRTVdf6 zEdw== 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=XDEati5AnmeIwG/gbfDq9Iz0JoFW4jKO9V1cvoJDwbs=; b=MNEXRyKK/6KsnbIgujT9isaGNc5dlC+rbIghWHgb6ur7qOB3q/ivcHYY/5IZnD+eCb 6a3cC7xzIRciFS3EPId+FxgII5HNonOigUtzLtrgTDy++N08wfx8DmlxbSLuNeJzug3r OhS1RbEQ4Nh1EjmXsdhujoR9bHv65gK/X1KrBNgiJKKadfnANIJji5TXoACmQ0jFLbJG hzYqunzOinX5WI7ngPEcVYc7ta3fOm40jDT/GUNlJYhA74Gt+tpgIM0ni8bwJ1fheITN y2WZesZZfOES/5E52BnH2pgBh+zbs4pBu/9S2L8cgvNRunx61r+CWta5a2Ls+nJeV9SX 7U+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zj0cwyUJ; 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 bx14sor7818326pjb.21.2019.06.27.13.52.46 for (Google Transport Security); Thu, 27 Jun 2019 13:52:46 -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=zj0cwyUJ; 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=XDEati5AnmeIwG/gbfDq9Iz0JoFW4jKO9V1cvoJDwbs=; b=zj0cwyUJjc4490ScZRzBvv+fzHqbH+UoOGU6jOcMpp/NPafDKPGu0mfwwyGL4NSL8I aMuqyYlFFw9hV/Tss88XvbIqvsWoMbtRYuVkVP4a9rizV4aFKNqFOlvcBzfSxY3xN9ju ZTwyS0G/f1RnzSE9HsvPDQqJ1rJONC2miE/fcQbIfSkeLp8su0LErsR0MyIx0L1MT1AG c4yPv868SisEcCj0GjZXCdDrsh3uMv6BL5bkm+ysWAsuHWt0FGxkx83qr5i/E5AMhCsD DDE0VqI9oDz8T6cm6Anj3W+1CKy+btKOSUMnEPyRlkMBNO+Zk4cEU3Q5pNPWgCaRul+C FRew== 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=XDEati5AnmeIwG/gbfDq9Iz0JoFW4jKO9V1cvoJDwbs=; b=GctQhK5AXcT2kcgl7ZsXUFLseahvr/XcswU7fyuok78ZqsJrv8EfDIyDuLx1n72RjC bcGBExx13afKjTrmdA4+X0Y9ylh/CJs3H5tt1bbjXRsG+mFCLCAzA+HjWX5hPwSEjTmL 8stmMTGE7DGt5KS+oa/whN1SVBthd2ORt6ICmxPH7W3KX3idfjq5ZQynWkzZIKP+PQ/v rGipABwTNW20Ox1X288VjypCmZTSNJwY4SxA7ODWjbm4ryC/NyuvChhPrtf+zh4uxx4a CesHV8OZXSj+iQnYW7iexgDcn585zQUFl1FpjopIqKZwRYNNb0T8/89flEy0HsJ+cBkH vvbg== X-Gm-Message-State: APjAAAUx3pCEGfGSip+9aSZitZaG8r86AoGwpl+4X/ADB7bw+qc2LzZI pavOBIkIdvHwJXVzHCCHrCn+qyV2 X-Google-Smtp-Source: APXvYqw2DIFNltOk0pMfuDdIDROXrYNXCaXcRvY6zoErZhyNm0BDHfPoUZrYtANNsXav9qIru1U82g== X-Received: by 2002:a17:90a:2228:: with SMTP id c37mr8570819pje.9.1561668766064; Thu, 27 Jun 2019 13:52:46 -0700 (PDT) Return-Path: 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.44 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 27 Jun 2019 13:52:45 -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 1/9] usb: dwc3: gadget: combine unaligned and zero flags Date: Thu, 27 Jun 2019 20:52:32 +0000 Message-Id: <20190627205240.38366-2-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> 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 65ba1038b111..4894fed1441c 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1070,7 +1070,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); @@ -1114,7 +1114,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); @@ -1130,7 +1130,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); @@ -1412,7 +1412,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); @@ -1423,7 +1423,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); @@ -2252,7 +2252,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; } @@ -2329,11 +2330,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;