From patchwork Mon Dec 30 16:13:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 182630 Delivered-To: patch@linaro.org Received: by 2002:a92:815a:0:0:0:0:0 with SMTP id e87csp6521093ild; Mon, 30 Dec 2019 08:13:14 -0800 (PST) X-Google-Smtp-Source: APXvYqy1cR0T9DYdh5Ctqk3nc7g1jHw8Vt5OL0T3XRyCOh+CB/3/s29VOLIbkLGELYOON6WT+MFk X-Received: by 2002:a9d:708f:: with SMTP id l15mr62521498otj.229.1577722394174; Mon, 30 Dec 2019 08:13:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577722394; cv=none; d=google.com; s=arc-20160816; b=BE4C87ERum5tZJiu9pnJULxSpBacr7eGywgJCVMLDt4zLq7+JQfd580JC+fpsMuY6k w/BCptCaFrT8Muyd/gcJPDsHdSLZfqAcghzXz6ZhiC9+PDZSMB7FNvPA5Rb2gUZ7YRj+ kmDFdrqnv5t3272mNlcD2po90ADW/gdjKDndVe/6rwDlwfFMLo7NiOSu3Hu3K+Audwj5 O5HcbMHUMe0inwbKYiN68WKzyzkj3fDrIwOBAFUv18HIs7bO5wE1tX025YlLVTSHv1C1 HSNKAlzArl2mizIZwL+pgPOGqIdc2CTiOK/E7FktNKN84iiPwq233XNL8ZLBLdCVKTJr W1LA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=G+IpvNYDr1r8qiuEoCpZSYzbw36vNuYa2znw2miGrDA=; b=1Ac0LC8bC4wg/w6nBgRsMZ7Rb1auWvm/p+r02temzL8kAommraOkYekJkWM/tXz41R l7i8uTWhI79QmJFqBKKGDUXzO1sbJmKiI9WbtrmfvlmUi3nRFaHE+WErkZC+VdGLLS6/ 7iwn0uZ0bLbLRRoyG3ZDxLV2asKErhoWySUeE4JY9YsNqhqcPDPFXuxU92PZvIdWuMEa lzoFqyPl3JBC/FE2NBQV8p1zr8Z9h0pa/JwRrPKaur2C0j05NHzKp2k2uSQXoYeK5Rw3 f6tzw9kaV3fBrugJVvnZe7w7KiP6MaTy20AR44FWMvEnsDQKYRkPohOhoh0aNLnDXMyV 7wCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WG4La9s5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v21si23710180otj.282.2019.12.30.08.13.13; Mon, 30 Dec 2019 08:13:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WG4La9s5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727299AbfL3QNB (ORCPT + 27 others); Mon, 30 Dec 2019 11:13:01 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:38484 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726675AbfL3QNB (ORCPT ); Mon, 30 Dec 2019 11:13:01 -0500 Received: by mail-ed1-f65.google.com with SMTP id i16so32998830edr.5 for ; Mon, 30 Dec 2019 08:13:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=G+IpvNYDr1r8qiuEoCpZSYzbw36vNuYa2znw2miGrDA=; b=WG4La9s5mhcbwYlQ2kAuW8nhMwm1/5+T0FR3m096MJaQPzYLHjRT7xh0wWL6r+JfG0 dqvqaKQ7/avtVROEZkFXTwLj+8qXpm+15l4CfZ5e2Qr7l2VziQaJcbx9VzNLbATaH2IN CuaTn8d1qmh24SQEFALHaHPKdxjzpGEstOXDDVFhTZdzQj9li4/h871hduxDHhI66zDt J2ZuN5HuFA1i3KgrEiF7KcbSAVoPqy741saZwRzvwB3kEI1EB7hYukmNVdiSYgpXAcow qDR7oK+104ETHLRk/CrIyTx47c7LF9f2d/Vg9oVyPOFjkgp1Ek5iM58TGTXnsXLtImxF CTxg== 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:mime-version :content-transfer-encoding; bh=G+IpvNYDr1r8qiuEoCpZSYzbw36vNuYa2znw2miGrDA=; b=hC0JeoXXjIqN+40iwm7RCCCSVmh4XNg+hr+kdNrhxnPsAA0K7ibAkKWdPLT7ClqpVF 3/Cibj7eR291NqID8Vf4FTkG0Roe/tD1yb6fHxnOoK2Y37xKku5N3+qrWCtYhZsitxN9 g7lEB2dRaaB6pKXHosydh3lYxBk19Jtz5UCX0KdSjEmRG0q2AZJb+DtqJdfmKf3hsHhK DpmYpcJGLAIRa5eKnuGhU7SVhj2y7Ai39lQ0BH5kzs5nqBpHvSDg+P+U0IwLEOeJBovS qXvi0xDy8FSgbMrb8t4z7jRdm0DEJGcRzktc33X0UrN9yD6NJJJkLzbUcXDweu9RqqjE Euzg== X-Gm-Message-State: APjAAAX+Aa/BEgvBhqqeTzlw6SNI8c88xc8Uq5fjozMAgHDqngJTuUDa 3JLwdlTbjTBkgSqVgjY0kZ5KCA== X-Received: by 2002:a17:906:4d46:: with SMTP id b6mr69483027ejv.79.1577722379278; Mon, 30 Dec 2019 08:12:59 -0800 (PST) Received: from localhost.localdomain ([176.61.57.127]) by smtp.gmail.com with ESMTPSA id dx7sm5624489ejb.81.2019.12.30.08.12.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Dec 2019 08:12:58 -0800 (PST) From: Bryan O'Donoghue To: balbi@kernel.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Bryan O'Donoghue Subject: [PATCH] usb: dwc3: gadget: Fix failure to detect end of transfer Date: Mon, 30 Dec 2019 16:13:21 +0000 Message-Id: <20191230161321.2738541-1-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.24.0 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A recent bugfix 8c7d4b7b3d43 ("usb: dwc3: gadget: Fix logical condition") correctly fixes a logical error in the gadget driver but, exposes a further bug in determining when a transfer has completed. Prior to 8c7d4b7b3d43 we were calling dwc3_gadget_giveback() when we shouldn't have been. Afer this change the below test fails to complete on my hardware. Host: echo "host" > /dev/ttyACM0 Device: cat < /dev/ttyGS0 This is caused by the driver incorrectly detecting end of transfer, a problem that had previous been masked by the continuous calling of dwc3_gadget_giveback() prior to 8c7d4b7b3d43. Remediate by making the test <= instead of == Fixes: e0c42ce590fe ("usb: dwc3: gadget: simplify IOC handling") Signed-off-by: Bryan O'Donoghue --- drivers/usb/dwc3/gadget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.24.0 diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 0c960a97ea02..464c4d9961c7 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2467,7 +2467,7 @@ static int dwc3_gadget_ep_reclaim_trb_linear(struct dwc3_ep *dep, static bool dwc3_gadget_ep_request_completed(struct dwc3_request *req) { - return req->request.actual == req->request.length; + return req->request.actual <= req->request.length; } static int dwc3_gadget_ep_cleanup_completed_request(struct dwc3_ep *dep,